StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FwdHit.h
1 #ifndef FwdHit_h
2 #define FwdHit_h
3 
4 #include "KiTrack/IHit.h"
5 #include "KiTrack/ISectorConnector.h"
6 #include "KiTrack/ISectorSystem.h"
7 #include "KiTrack/KiTrackExceptions.h"
8 
9 #include <memory>
10 #include <set>
11 #include <string.h>
12 #include <vector>
13 
14 class StHit;
15 
16 class FwdSystem : public KiTrack::ISectorSystem {
17  public:
18  static const int sNFwdLayers = 7;
19  static const int sNFttLayers = 4;
20  static const int sNFstLayers = 3;
21  FwdSystem(const int ndisks = FwdSystem::sNFwdLayers) : KiTrack::ISectorSystem(), mNDisks(ndisks){};
22  ~FwdSystem(){/* */};
23  virtual unsigned int getLayer(int diskid) const throw(KiTrack::OutOfRange) {
24  return diskid;
25  }
26 
27  int mNDisks;
28  std::string getInfoOnSector(int sec) const { return "NOOP"; }
29  static FwdSystem *sInstance; // setup and torn down by StFwdTrackMaker
30 };
31 
32 //_____________________________________________________________________________________________
33 
34 // small class to store Mc Track information
35 class McTrack {
36  public:
37  McTrack() {
38  set( -999, -999, -999, 0, -1 );
39  }
40  McTrack(double pt, double eta = -999, double phi = -999, int q = 0,
41  int start_vertex = -1) {
42  set( pt, eta, phi, q, start_vertex );
43  }
44 
45  void set(double pt, double eta = -999, double phi = -999, int q = 0, int start_vertex = -1){
46  mPt = pt;
47  mEta = eta;
48  mPhi = phi;
49  mQ = q;
50  mStartVertex = start_vertex;
51  }
52 
53  void addHit(KiTrack::IHit *hit) { mHits.push_back(hit); }
54  // void addFstHit(KiTrack::IHit *hit) { mFstHits.push_back(hit); }
55 
56  double mPt, mEta, mPhi;
57  int mTid, mQ, mStartVertex;
58 
59  std::vector<KiTrack::IHit *> mHits;
60  // std::vector<KiTrack::IHit *> mFstHits;
61 };
62 
63 
64 /*
65  * Note, this class does not follow STAR naming convention.
66  * Instead, keep the conventions of KiTrack
67  */
68 class FwdHit : public KiTrack::IHit {
69  public:
70  FwdHit(unsigned int id, float x, float y, float z, int vid, int tid,
71  TMatrixDSym covmat, std::shared_ptr<McTrack> mcTrack = nullptr )
72  : KiTrack::IHit() {
73  _id = id;
74  _x = x;
75  _y = y;
76  _z = z;
77  _tid = tid;
78  _vid = vid;
79  _mcTrack = mcTrack;
80  _hit = 0;
81  _covmat.ResizeTo( 3, 3 );
82  _covmat = covmat;
83 
84  // these are the sector ids mapped to layers
85  int map[] = {0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 5, 6}; // ftsref6a
86 
87  if (vid > 0)
88  _sector = map[vid];
89  else {
90  _sector = abs(vid); // set directly if you want
91  // now set vid back so we retain info on the tru origin of the hit
92  _vid = abs(vid) + 9; // we only use this for sTGC only. Needs to be
93  // cleaner in future.
94  }
95  };
96 
97  const KiTrack::ISectorSystem *getSectorSystem() const {
98  return FwdSystem::sInstance;
99  }
100 
101  int getTrackId() { return _tid;}
102  int _tid; // aka ID truth
103  int _vid; // volume id
104  unsigned int _id; // just a unique id for each hit in this event.
105  std::shared_ptr<McTrack> _mcTrack;
106  TMatrixDSym _covmat;
107 
108  StHit *_hit;
109 };
110 
111 using Seed_t = std::vector<KiTrack::IHit *>;
112 
113 class FwdConnector : public KiTrack::ISectorConnector {
114  public:
115  FwdConnector(unsigned int distance)
116  : _distance(distance) {}
117  ~FwdConnector(){};
118 
119  // Return the possible sectors (layers) given current
120  virtual std::set<int> getTargetSectors(int disk) {
121 
122  std::set<int> r;
123 
124  if (disk > 0 && _distance >= 1)
125  r.insert(disk - 1);
126 
127  if (disk > 1 && _distance >= 2)
128  r.insert(disk - 2);
129 
130  if (disk > 2 && _distance >= 3)
131  r.insert(disk - 3);
132 
133  if (disk > 3 && _distance >= 4)
134  r.insert(disk - 4);
135 
136  return r;
137  };
138 
139  private:
140  protected:
141  // const FwdSystem _system; // numbering system
142  unsigned int _distance; // number of layers forward to search
143 }; // FwdConnector
144 
145 struct SeedQual {
146  inline double operator()(Seed_t s) { return double(s.size()) / FwdSystem::sNFttLayers ; } // seeds only use the 4 hits from Ftt
147 };
148 
149 struct SeedCompare {
150  inline bool operator()(Seed_t trackA, Seed_t trackB) {
151  std::map<unsigned int, unsigned int> hit_counts;
152  // we are assuming that the same hit can never be used twice on a single
153  // track!
154 
155  for (auto h : trackA) {
156  hit_counts[static_cast<FwdHit *>(h)->_id]++;
157  }
158 
159  // now look at the other track and see if it has the same hits in it
160  for (auto h : trackB) {
161  hit_counts[static_cast<FwdHit *>(h)->_id]++;
162 
163  // incompatible if they share a single hit
164  if (hit_counts[static_cast<FwdHit *>(h)->_id] >= 2) {
165  return false;
166  }
167  }
168 
169  // no hits are shared, they are compatible
170  return true;
171  }
172 };
173 
174 #endif
Definition: StHit.h:125
Definition: FwdHit.h:68
Definition: FwdHit.h:35