MarlinTPC  1.2.0
RowTripletBasedTrackFinderProcessor.h
1 #ifndef ROWTRIPLETBASEDTRACKFINDERPROCESSOR_H
2 #define ROWTRIPLETBASEDTRACKFINDERPROCESSOR_H
3 
4 #include <marlin/Processor.h>
5 #include <marlin/Global.h>
6 #include <lcio.h>
7 #include <string>
8 
9 #include <gear/TPCModule.h>
10 
11 // LCIO:
12 #include "EVENT/TrackerHit.h"
13 
14 #include "TFile.h"
15 #include "TTree.h"
16 #include "TMath.h"
17 #include "TVectorD.h"
18 #include "TMatrixD.h"
19 #include "TMatrixDSym.h"
20 
21 namespace marlintpc {
23 
74 class RowTripletBasedTrackFinderProcessor: public marlin::Processor {
75  public:
76 
77  virtual Processor* newProcessor() {
79  }
80 
82 
83  virtual void init();
84 
85  virtual void processRunHeader(EVENT::LCRunHeader* run);
86 
87  virtual void processEvent(EVENT::LCEvent* evt);
88 
89  virtual void check(EVENT::LCEvent* evt);
90 
91  virtual void end();
92 
93  protected:
94  /* the place for protected and private member data and functions */
95  std::string _inputColName;
96  std::string _outputColName;
98  double _distCut;
99  double _trpCut;
100  double _posCut;
101  double _dirCut;
102  double _segCut;
103  double _unusedCut;
104  int _maxGap;
106  bool _refAtPCA;
107 
108  private:
109 
110  double _Bzc;
111  std::map<int, std::vector<int> > _modNeighbours;
112  double _Xcenter;
113  double _Ycenter;
114 
115  bool areNeighbourModules(gear::TPCModule*, gear::TPCModule*, bool);
116 };
117 
119 
122 class rb_Hit {
123  public:
124  rb_Hit(const int iHit, const int mod, const int row, const EVENT::TrackerHit& aHit);
125  void print() const;
126  int getHitNum() const;
127  int getMod() const;
128  int getRow() const;
129  double getX() const;
130  double getY() const;
131  double getZ() const;
132  void getPos(double*) const;
133  double getVarXY(const double = 0.) const;
134  double getVarZ(const double = 0.) const;
135  double getPhiMeas() const;
136  bool getUsed() const;
137  void setUsed(const double);
138  double getCosBeta() const;
139  double getDistXY(const double, const double, const double, const double) const;
140  double getDistZ(const double) const;
141 
142  private:
143  const int _hitNum;
144  const int _hitModule;
145  const int _hitRow;
146  const double _hitX;
147  const double _hitY;
148  const double _hitZ;
149  const double _hitPhiMeas;
150  const double _hitVarXY;
151  const double _hitVarR;
152  const double _hitVarZ;
153  bool _used;
154  double _cosb;
155 
156  double _calcPhiMeas(const EVENT::TrackerHit& aHit);
157  double _getVarXY(FloatVec);
158  double _getVarR(FloatVec);
159  double _getVarZ(FloatVec);
160 
161 };
162 
163 typedef std::vector<rb_Hit*> hitListType;
164 typedef std::map<int, hitListType> rowHitMapType;
165 typedef std::map<int, rowHitMapType> modHitMapType;
166 
168 
173 class rb_Doublet {
174  public:
176  bool match(rb_Hit*, const double, const double) const;
177  rb_Hit* getHit(const int) const;
178  void getParameters(double&, double&, double&, double&, double&, double&, double&, double&, double&, double&) const;
179 
180  private:
181  rb_Hit* _hit[2];
182  double _phiMeas;
183  double _cosPhi;
184  double _sinPhi;
185  double _xav;
186  double _yav;
187  double _zav;
188  double _phi;
189  double _tanl;
190  double _length;
191  double _cosb;
192  double _der2XY;
193  double _der2Z;
194  double _varXY;
195  double _varZ;
196 };
197 
199 
204 class rb_Triplet {
205  public:
207  int getRow() const;
208  double getX() const;
209  double getY() const;
210  double getZ() const;
211  void getPos(double*) const;
212  double getVarXYPos(const double = 0.) const;
213  double getVarXYDir() const;
214  double getVarZPos(const double = 0.) const;
215  double getVarZDir() const;
216  double getPhiMeas() const;
217  double getPhi() const;
218  double getTanl() const;
219  void getPosCloseTo(const double, const double, double*, double&) const;
220  rb_Hit* getHit(const int) const;
221  bool match(rb_Triplet*, const double, const double) const;
222  double getCosBeta() const;
223 
224  private:
225  rb_Hit* _hit[3];
226  double _phiMeas;
227  double _posX;
228  double _posY;
229  double _posZ;
230  double _varXY[2];
231  double _phi;
232  double _tanl;
233  double _varZ[2];
234  double _length;
235  double _cosb;
236 };
237 
238 typedef std::vector<rb_Triplet*> trpListType;
239 
241 
246 class rb_Segment {
247  public:
248  rb_Segment(double, trpListType);
249  rb_Segment(double, hitListType, unsigned int = 1);
250  rb_Segment(std::vector<rb_Segment*> segments);
251  double getBzc() const;
252  int getFirstRow() const;
253  int getLastRow() const;
254  void getRefPoint(double*) const;
255  int getNdf() const;
256  double getChi2() const;
257  void getPar(double *) const;
258  const hitListType& getHitList() const;
259  const TVectorD& getPar() const;
260  const TMatrixDSym& getCov() const;
261  bool match(rb_Segment*, const double, const int) const;
262  bool match(rb_Hit*, const double) const;
263  void match(hitListType&, hitListType&, const double) const;
264  void getLCIOStateAtRefPoint(const double*, TVectorD&, TMatrixDSym&) const;
265  void fillRowMap(std::map<int, int>&) const;
266  int getId() const;
267  void setId(int);
268  void addHit(rb_Hit *);
269 
270  private:
271  int _segId;
272  hitListType _hitList;
273  double _bzc;
274  double _refX;
275  double _refY;
276  double _refZ;
277  int _npar;
278  int _ndf;
279  double _chi2;
280  TVectorD _parameters;
281  TMatrixDSym _covariance;
282  void calcRefPoint();
283  void fitSegment(double);
284 };
285 
286 typedef std::vector<rb_Segment*> segListType;
287 typedef std::map<int, segListType> modSegMapType;
288 
290 
296  public:
298  void addIndex(int);
299  void addMatch(std::pair<int, int>);
300  std::map<int, std::vector<int> > getClasses();
301 
302  private:
303  std::map<int, int> _index;
304  std::vector<std::pair<int, int> > _matches;
305 };
306 
307 } // namespace marlintpc
308 #endif // ROWTRIPLETBASEDTRACKFINDERPROCESSOR_H
simpleEquiClasses()
Construct simple equivalence class.
Definition: RowTripletBasedTrackFinderProcessor.cc:1333
void setId(int)
Set segment ID.
Definition: RowTripletBasedTrackFinderProcessor.cc:1087
double getDistZ(const double) const
Get distance to point in Z.
Definition: RowTripletBasedTrackFinderProcessor.cc:617
Row based segment.
Definition: RowTripletBasedTrackFinderProcessor.h:246
const TVectorD & getPar() const
Get parameter vector.
Definition: RowTripletBasedTrackFinderProcessor.cc:1069
double getPhiMeas() const
Get XY measurement direction.
Definition: RowTripletBasedTrackFinderProcessor.cc:579
double getVarXY(const double=0.) const
Get XY variance.
Definition: RowTripletBasedTrackFinderProcessor.cc:566
double getChi2() const
Get chi2 from segment fit.
Definition: RowTripletBasedTrackFinderProcessor.cc:1049
int getHitNum() const
Get index to input hit collection.
Definition: RowTripletBasedTrackFinderProcessor.cc:523
void getPosCloseTo(const double, const double, double *, double &) const
Get position close to reference point.
Definition: RowTripletBasedTrackFinderProcessor.cc:865
void getPos(double *) const
Get position.
Definition: RowTripletBasedTrackFinderProcessor.cc:556
void addHit(rb_Hit *)
Add (unused) hit to segment.
Definition: RowTripletBasedTrackFinderProcessor.cc:1318
const TMatrixDSym & getCov() const
Get covariance matrix.
Definition: RowTripletBasedTrackFinderProcessor.cc:1074
void getLCIOStateAtRefPoint(const double *, TVectorD &, TMatrixDSym &) const
Get segment state at reference point.
Definition: RowTripletBasedTrackFinderProcessor.cc:1194
void setUsed(const double)
Set use flag.
Definition: RowTripletBasedTrackFinderProcessor.cc:592
double getPhiMeas() const
Get XY measurement direction (average of outer hits).
Definition: RowTripletBasedTrackFinderProcessor.cc:798
double getY() const
Get Y coordinate.
Definition: RowTripletBasedTrackFinderProcessor.cc:752
void addMatch(std::pair< int, int >)
Add match.
Definition: RowTripletBasedTrackFinderProcessor.cc:1349
void getRefPoint(double *) const
Get reference point.
Definition: RowTripletBasedTrackFinderProcessor.cc:1037
int getId() const
Get segment ID.
Definition: RowTripletBasedTrackFinderProcessor.cc:1079
int getFirstRow() const
Get first row number.
Definition: RowTripletBasedTrackFinderProcessor.cc:1024
rb_Doublet(rb_Hit *, rb_Hit *)
Construct row based doublet.
Definition: RowTripletBasedTrackFinderProcessor.cc:626
double getCosBeta() const
Get cos(beta).
Definition: RowTripletBasedTrackFinderProcessor.cc:598
int getLastRow() const
Get first last number.
Definition: RowTripletBasedTrackFinderProcessor.cc:1029
double _posCut
Chi2 cut for triplet position matching in XY and Z.
Definition: RowTripletBasedTrackFinderProcessor.h:100
double getTanl() const
Get slope in ZS.
Definition: RowTripletBasedTrackFinderProcessor.cc:808
double getCosBeta() const
Get cos(beta).
Definition: RowTripletBasedTrackFinderProcessor.cc:813
rb_Triplet(rb_Doublet &, rb_Hit *)
Construct row based triplet.
Definition: RowTripletBasedTrackFinderProcessor.cc:726
double getX() const
Get X coordinate.
Definition: RowTripletBasedTrackFinderProcessor.cc:747
std::map< int, std::vector< int > > getClasses()
Get equivalence classes.
Definition: RowTripletBasedTrackFinderProcessor.cc:1361
void addIndex(int)
Add index.
Definition: RowTripletBasedTrackFinderProcessor.cc:1341
std::string _outputColName
Name of the output collection.
Definition: RowTripletBasedTrackFinderProcessor.h:96
double _segCut
Chi2/Ndf cut for segment matching (Ndf=4 for B off, 5 for B on)
Definition: RowTripletBasedTrackFinderProcessor.h:102
rb_Hit(const int iHit, const int mod, const int row, const EVENT::TrackerHit &aHit)
Construct row based hit.
Definition: RowTripletBasedTrackFinderProcessor.cc:460
double getY() const
Get Y coordinate.
Definition: RowTripletBasedTrackFinderProcessor.cc:543
bool match(rb_Hit *, const double, const double) const
Match doublet with third hit.
Definition: RowTripletBasedTrackFinderProcessor.cc:671
Row based triplet.
Definition: RowTripletBasedTrackFinderProcessor.h:204
Equivalence classes.
Definition: RowTripletBasedTrackFinderProcessor.h:295
rb_Segment(double, trpListType)
Construct row based segment from (unused hits of) triplets.
Definition: RowTripletBasedTrackFinderProcessor.cc:890
double getPhi() const
Get direction in XY.
Definition: RowTripletBasedTrackFinderProcessor.cc:803
Row based doublet.
Definition: RowTripletBasedTrackFinderProcessor.h:173
bool match(rb_Segment *, const double, const int) const
Match segment with other segment.
Definition: RowTripletBasedTrackFinderProcessor.cc:1102
double _unusedCut
Chi2 cut for matching unused hits in XY and Z.
Definition: RowTripletBasedTrackFinderProcessor.h:103
double getDistXY(const double, const double, const double, const double) const
Get distance to point in XY (along direction)
Definition: RowTripletBasedTrackFinderProcessor.cc:609
bool match(rb_Triplet *, const double, const double) const
Match triplet with other triplet.
Definition: RowTripletBasedTrackFinderProcessor.cc:831
double getVarZ(const double=0.) const
Get Z variance.
Definition: RowTripletBasedTrackFinderProcessor.cc:574
double getX() const
Get X coordinate.
Definition: RowTripletBasedTrackFinderProcessor.cc:538
Row based hit.
Definition: RowTripletBasedTrackFinderProcessor.h:122
RowTripletBasedTrackFinderProcessor()
Construct processor.
Definition: RowTripletBasedTrackFinderProcessor.cc:38
int getRow() const
Get row number (of center hit).
Definition: RowTripletBasedTrackFinderProcessor.cc:742
const hitListType & getHitList() const
Get list of hits.
Definition: RowTripletBasedTrackFinderProcessor.cc:1064
int getNdf() const
Get number of degrees of freedom (of segment fit).
Definition: RowTripletBasedTrackFinderProcessor.cc:1044
rb_Hit * getHit(const int) const
Get hit.
Definition: RowTripletBasedTrackFinderProcessor.cc:717
std::string _inputColName
Name of the input collection.
Definition: RowTripletBasedTrackFinderProcessor.h:95
bool _refAtPCA
Use Pca as reference point (else 1. hit)
Definition: RowTripletBasedTrackFinderProcessor.h:106
int _maxGap
Cut for (row) distance to segment for matching unused hits in XY and Z.
Definition: RowTripletBasedTrackFinderProcessor.h:104
double getVarXYDir() const
Get XY variance (direction: phi).
Definition: RowTripletBasedTrackFinderProcessor.cc:780
virtual void init()
Initialize processor.
Definition: RowTripletBasedTrackFinderProcessor.cc:76
int getMod() const
Get module number.
Definition: RowTripletBasedTrackFinderProcessor.cc:528
bool _encodedModuleID
Module ID is encoded in CellID0.
Definition: RowTripletBasedTrackFinderProcessor.h:105
double getVarXYPos(const double=0.) const
Get XY variance (position).
Definition: RowTripletBasedTrackFinderProcessor.cc:775
double _bfieldScaleFactor
scale factor for magnetic field (default: 1.0)
Definition: RowTripletBasedTrackFinderProcessor.h:97
double getBzc() const
Get Bz*c.
Definition: RowTripletBasedTrackFinderProcessor.cc:1019
void getParameters(double &, double &, double &, double &, double &, double &, double &, double &, double &, double &) const
Get parameters.
Definition: RowTripletBasedTrackFinderProcessor.cc:698
double getVarZDir() const
Get Z variance (direction: tan(lambda)).
Definition: RowTripletBasedTrackFinderProcessor.cc:793
void getPos(double *) const
Get position.
Definition: RowTripletBasedTrackFinderProcessor.cc:765
int getRow() const
Get row number.
Definition: RowTripletBasedTrackFinderProcessor.cc:533
virtual void processEvent(EVENT::LCEvent *evt)
Process event.
Definition: RowTripletBasedTrackFinderProcessor.cc:104
double getVarZPos(const double=0.) const
Get Z variance (position).
Definition: RowTripletBasedTrackFinderProcessor.cc:788
rb_Hit * getHit(const int) const
Get hit.
Definition: RowTripletBasedTrackFinderProcessor.cc:879
double getZ() const
Get Z coordinate.
Definition: RowTripletBasedTrackFinderProcessor.cc:548
double _distCut
Coarse cut on XY and Z residuals for triplet preselection.
Definition: RowTripletBasedTrackFinderProcessor.h:98
bool getUsed() const
Get use flag.
Definition: RowTripletBasedTrackFinderProcessor.cc:584
void print() const
Print.
Definition: RowTripletBasedTrackFinderProcessor.cc:467
Track finder based on triplets of rows.
Definition: RowTripletBasedTrackFinderProcessor.h:74
double getZ() const
Get Z coordinate.
Definition: RowTripletBasedTrackFinderProcessor.cc:757
void fillRowMap(std::map< int, int > &) const
Fill row map.
Definition: RowTripletBasedTrackFinderProcessor.cc:1307
double _dirCut
Chi2 cut for triplet direction matching in XY and Z.
Definition: RowTripletBasedTrackFinderProcessor.h:101
double _trpCut
Chi2 cut for triplet definition on XY and Z residuals.
Definition: RowTripletBasedTrackFinderProcessor.h:99