StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiMapUtilities.cxx
1 //StiMapUtilities.cxx
2 //M.L. Miller (Yale Software)
3 //3/01
4 
5 //STD
6 #include <Stiostream.h>
7 #include <math.h>
8 
9 //SCL
10 #include "StThreeVectorD.hh"
11 #include "StEventTypes.h"
12 #include "StGetConfigValue.hh"
13 
14 //Sti
15 #include "StiHit.h"
16 #include "StiMapUtilities.h"
17 #include "StiCompositeTreeNode.h"
18 #include "StiPlacement.h"
19 #include "StiDetector.h"
20 #include "StiTrackNode.h"
21 
22 //------------------------------ Hit Map Utilities ----------------------------
23 
24 //______________________________________________________________________________
25 //Equality defined by same refangle and position
26 bool HitMapKey::operator==(const HitMapKey& key2) const
27 {
28  //cout <<"HitMapKey::operator==(const HitMapKey&)"<<endl;
29  return (this->refangle==key2.refangle && this->position==key2.position);
30 }
31 
32 //______________________________________________________________________________
33 //Return true if key2 < key1. Order first by refangle, then by position.
34 bool MapKeyLessThan::operator() (const HitMapKey& key1, const HitMapKey& key2) const
35 {
36  //cout <<"HitMapKey::operator()"<<endl;
37  bool val = false;
38  if ( fabs(key1.refangle-key2.refangle) < reftolerance) {
39  //Call these equal, check position
40 
41  if ( fabs(key1.position-key2.position) < postolerance) {
42  //Call these equal
43  val = false;
44  }
45  else if (key1.position < key2.position) {val = true;}
46  else {val = false;}
47  }
48 
49  else if (key1.refangle < key2.refangle) {val = true;}
50  else {val = false;}
51 
52  return val;
53 }
54 
55 
56 //______________________________________________________________________________
57 bool StiDetectorNodePositionLessThan::operator() (const StiCompositeTreeNode<StiDetector> * lhs,
58  const StiCompositeTreeNode<StiDetector> * rhs) const {
59  if (lhs->getData()==0 || rhs->getData()==0)
60  cout <<"StiDetectorNodeLessThan::operator(). ERROR:\t" <<"null data. Return false"<<endl;
61 
62  StiPlacement* lhsp = lhs->getData()->getPlacement();
63  StiPlacement* rhsp = rhs->getData()->getPlacement();
64 
65  return lhsp->getNormalRadius()<rhsp->getNormalRadius();
66 }
67 
68 //----------------------- Detector Map Utilities ------------------------------------
69 
70 //______________________________________________________________________________
71 bool NameMapKey::operator==(const NameMapKey& key2) const{
72  //return( strcmp(name, key2.name) == 0 );
73  return( name ==key2.name );
74 }
75 
76 //______________________________________________________________________________
77 bool NameMapKey::operator<(const NameMapKey& key2) const{
78  //return( strcmp(name, key2.name) < 0 );
79  return( name < key2.name );
80 }
81 
82 //______________________________________________________________________________
83 void SetHitUsed::operator()(StiTrackNode& node)
84 {
85  StiHit* hit = node.getHit();
86  if(!hit) return;
87  if ( !node.isValid() || node.getChi2()>1e3) { node.setHit(0) ;}
88  else {hit->addTimesUsed();}
89 }
90 
91 //______________________________________________________________________________
92 void SetHitUnused::operator()(StiTrackNode& node)
93 {
94  StiHit* hit = node.getHit();
95  if(!hit) return;
96  if (hit->timesUsed()) hit->setTimesUsed(0);
97 }
98 
99 //----------------------- Streamers -------------------------------------------------
100 //______________________________________________________________________________
101 ostream& operator<<(ostream& os, const HitMapKey& a)
102 {
103  return os <<a.refangle<<"\t"<<a.position;
104 }
105 
106 //______________________________________________________________________________
107 ostream& operator<<(ostream& os, const NameMapKey& a){
108  return os << a.name;
109 }
110 
111 
T * getData() const
Return a (non-const!) pointer to the data hung on this node.
Definition: StiHit.h:51
void addTimesUsed()
???
Definition: StiHit.cxx:240
UInt_t timesUsed() const
Return the number of times this hit was assigned to a track.
Definition: StiHit.h:108