StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CriteriaKeeper.h
1 #ifndef CRITERIA_KEEPER_H
2 #define CRITERIA_KEEPER_H
3 
4 #include "Criteria/Criteria.h"
5 
6 class CriteriaKeeper : public KiTrack::ICriterion {
7 
8  public:
9  CriteriaKeeper(KiTrack::ICriterion *child) {
10  mChild = child;
11  values.clear();
12 
13  _name = mChild->getName();
14  _type = mChild->getType();
15  }
16 
17  ~CriteriaKeeper() {
18  if (mChild)
19  delete mChild;
20  mChild = nullptr;
21  }
22 
23  virtual bool areCompatible(KiTrack::Segment *parent, KiTrack::Segment *child) {
24  bool result = mChild->areCompatible(parent, child);
25 
26 
27 
28  // capture the primary result of the criteria
29  float value = mChild->getMapOfValues()[mChild->getName()];
30  bool same_track = false;
31  int track_id = -1;
32 
33 
34 
35  // two hit criteria
36  if ((parent->getHits().size() == 1) && (child->getHits().size() == 1)) {
37  KiTrack::IHit *a = parent->getHits()[0];
38  KiTrack::IHit *b = child->getHits()[0];
39 
40  auto fwdA = static_cast<FwdHit *>(a);
41  auto fwdB = static_cast<FwdHit *>(b);
42 
43 
44 
45  same_track = (fwdA->_tid == fwdB->_tid && fwdA->_tid != 0);
46  if (same_track)
47  track_id = fwdA->_tid;
48  else
49  track_id = -1;
50 
51  if ( _name == "Crit2_RZRatio" ){
52  // LOG_INFO << "Hit a_id = " << fwdA->_id << "Hit b_id = " << fwdB->_id << endm;
53  std::map < std::string , float > my_map_name_value = mChild->getMapOfValues();
54  my_map_name_value["Crit2_RZRatio_x1"] = a->getX();
55  my_map_name_value["Crit2_RZRatio_y1"] = a->getY();
56  my_map_name_value["Crit2_RZRatio_z1"] = a->getZ();
57  my_map_name_value["Crit2_RZRatio_x2"] = b->getX();
58  my_map_name_value["Crit2_RZRatio_y2"] = b->getY();
59  my_map_name_value["Crit2_RZRatio_z2"] = b->getZ();
60 
61  my_map_name_value["Crit2_RZRatio_h1"] = fwdA->_id;
62  my_map_name_value["Crit2_RZRatio_h2"] = fwdB->_id;
63 
64  allValues.push_back( my_map_name_value );
65  } else {
66  std::map < std::string , float > my_map_name_value = mChild->getMapOfValues();
67  allValues.push_back( my_map_name_value);
68  }
69  }
70 
71  // three hit criteria (two two-segments)
72  if ((parent->getHits().size() == 2) && (child->getHits().size() == 2)) {
73  KiTrack::IHit *a = child->getHits()[0];
74  KiTrack::IHit *b = child->getHits()[1];
75  KiTrack::IHit *c = parent->getHits()[1];
76 
77 
78 
79  auto fwdA = static_cast<FwdHit *>(a);
80  auto fwdB = static_cast<FwdHit *>(b);
81  auto fwdC = static_cast<FwdHit *>(c);
82 
83  std::map < std::string , float > my_map_name_value = mChild->getMapOfValues();
84 
85  my_map_name_value["Crit2_RZRatio_h1"] = fwdA->_id;
86  my_map_name_value["Crit2_RZRatio_h2"] = fwdB->_id;
87  my_map_name_value["Crit2_RZRatio_h3"] = fwdC->_id;
88 
89  allValues.push_back( my_map_name_value );
90 
91  same_track = (fwdA->_tid == fwdB->_tid && fwdB->_tid == fwdC->_tid && fwdA->_tid != 0);
92  if (same_track)
93  track_id = fwdA->_tid;
94  else
95  track_id = -1;
96  }
97 
98  values.push_back(value);
99  track_ids.push_back(track_id);
100 
101  return result;
102  }
103 
104  std::vector<float> getValues( ) {
105  return values;
106  }
107  std::vector<std::map < std::string , float >> getAllValues() {
108  return allValues;
109  }
110  std::vector<int> getTrackIds() {
111  return track_ids;
112  }
113 
114  void clear() {
115  values.clear();
116  track_ids.clear();
117  allValues.clear();
118  }
119 
120  protected:
121  ICriterion *mChild = nullptr;
122 
123  std::vector<float> values;
124  std::vector<std::map < std::string , float >> allValues;
125  std::vector<int> track_ids;
126 };
127 
128 
129 #endif
Definition: FwdHit.h:68