MyMarlinTPC  170316
TimePixLocalRoadSearchProcessor.h
Go to the documentation of this file.
1 #ifndef TIMEPIXLOCALROADSEARCHPROCESSOR_H
2 #define TIMEPIXLOCALROADSEARCHPROCESSOR_H
3 
5 
6 #include <marlin/Processor.h>
7 #include <marlin/Global.h>
8 #include <lcio.h>
9 #include <string>
10 
11 #include <gear/TPCModule.h>
12 
13 // LCIO:
14 #include "EVENT/TrackerHit.h"
15 
16 #include "TFile.h"
17 #include "TTree.h"
18 #include "TMath.h"
19 #include "TVectorD.h"
20 #include "TMatrixD.h"
21 #include "TMatrixDSym.h"
22 
23 namespace marlintpc {
25 
78 class TimePixLocalRoadSearchProcessor: public marlin::Processor {
79  public:
80 
81  virtual Processor* newProcessor() {
83  }
84 
86 
87  virtual void init();
88 
89  virtual void processRunHeader(EVENT::LCRunHeader* run);
90 
91  virtual void processEvent(EVENT::LCEvent* evt);
92 
93  virtual void check(EVENT::LCEvent* evt);
94 
95  virtual void end();
96 
97  protected:
98  /* the place for protected and private member data and functions */
99  std::string _inputColName;
100  std::string _outputColName;
103  int _mpSize;
104  double _minZmeas;
105  double _maxZmeas;
106  double _sigmaZ;
107  double _xOffset;
108  double _yOffset;
109  int _maxMult;
111  int _minDist;
112  double _maxPull2XY;
113  double _maxPull2Z;
114  double _maxChi2;
115  double _maxSvar;
116  double _maxGap;
119  double _chi2CutChip;
120  double _chi2CutOcto;
121  double _chi2CutMod;
122  double _distCut;
123  bool _refAtPCA;
124 
125  private:
126  double _Bzc;
127  double _Xcenter;
128  double _Ycenter;
129 };
130 
132 class tp_Pixel {
133  public:
134  tp_Pixel(const int iHit, const EVENT::TrackerHit& aHit, const double xOffset, const double yOffset);
135  void print() const;
136  int getHitNum() const;
137  int getChip() const;
138  int getRow() const;
139  int getCol() const;
140  double getX() const;
141  double getY() const;
142  double getZ() const;
143  void getPos(double*) const;
144  double getSigma2XY() const;
145  double getSigma2Z() const;
146  double getArcLength() const;
147  bool getUsed() const;
148  void setUsed();
149  void setArcLength(const double);
150 
151  private:
152  const int _hitNum;
153  const int _chipNum;
154  const int _rowNum;
155  const int _colNum;
156  const double _posX;
157  const double _posY;
158  const double _posZ;
159  const double _sigma2XY;
160  const double _sigma2Z;
161  bool _used;
162  double _sarc;
163 
164 };
165 
166 typedef std::vector<tp_Pixel*> pixelListType;
167 typedef std::map<int, pixelListType> chipPixelMapType;
168 
171  public:
172  tp_MacroPixel(const int, pixelListType&, const int);
173  ~tp_MacroPixel();
174  void print() const;
175  int getId() const;
176  int getSize() const;
177  int getEntries() const;
178  int getRow() const;
179  int getCol() const;
180  double getX() const;
181  double getY() const;
182  double getZ() const;
183  void getPos(double*) const;
184  double getVarXY(const double, const double) const;
185  double getVarZ() const;
186  double getSigma2XY() const;
187  double getSigma2Z() const;
188  bool getUsed() const;
189  void setUsed();
190  pixelListType getPixels() const;
191 
192  private:
193  const int _mpId;
194  const int _size;
195  const int _entries;
196  pixelListType _pixels;
197  bool _used;
198  double _posX;
199  double _posY;
200  double _posZ;
201  double _varXX;
202  double _varXY;
203  double _varYY;
204  double _varZZ;
205  double _sigma2XY;
206  double _sigma2Z;
207  int _locRow;
208  int _locCol;
209 
210 };
211 
212 typedef std::vector<tp_MacroPixel*> macroPixelListType;
213 typedef std::pair<tp_MacroPixel*, tp_MacroPixel*> macroPixelPairType;
214 typedef std::vector<macroPixelPairType> macroPixelPairListType;
215 typedef std::map<int, macroPixelPairListType> macroPixelPairListMapType;
216 
218 class tp_PixelBin {
219  public:
220  tp_PixelBin(const int, const int, pixelListType&, const int, const double, const double);
221  ~tp_PixelBin();
222  void print() const;
223  int getId() const;
224  int getNumPix() const;
225  int getNumMPix() const;
226  macroPixelListType getMacroPixels() const;
227 
228  private:
229  const int _binId;
230  const int _size;
231  int _numPix;
232  macroPixelListType _macroPixels;
233 };
234 
235 typedef std::vector<tp_PixelBin*> pixelBinListType;
236 
239  public:
240  tp_PixelRoad(macroPixelPairType, pixelBinListType&, const double*);
241  ~tp_PixelRoad();
242  void print() const;
243  bool isValid() const;
244  int getNumPix() const;
245  int getNumMPix() const;
246  double getChi2() const;
247  macroPixelListType getMacroPixels() const;
248 
249  private:
250  const int _mpId1;
251  const int _mpId2;
252  bool _valid;
253  int _numPix;
254  double _chi2ByNdf;
255  std::vector<double> _sList;
256  macroPixelListType _macroPixels;
257 };
258 
261  public:
262  tp_PixelSegment(const int, const int, const double, macroPixelListType&);
263  ~tp_PixelSegment();
264  void print() const;
265  int getNumPar() const;
266  int getLevel() const;
267  double getChi2() const;
268  int getNdf() const;
269  double getLength() const;
270  void getRefPoint(double*) const;
271  void getPar(double *) const;
272  const TVectorD& getPar() const;
273  const TMatrixDSym& getCov() const;
274  bool match(tp_PixelSegment*, const double, const double) const;
275  macroPixelListType getMacroPixels() const;
276  void getLCIOStateAtRefPoint(const double*, TVectorD&, TMatrixDSym&) const;
277 
278  private:
279  const int _segId;
280  const int _level;
281  const double _bzc;
282  const int _npar;
283  macroPixelListType _macroPixels;
284  double _refX;
285  double _refY;
286  double _refZ;
287  double _length;
288  int _ndf;
289  double _chi2;
290  TVectorD _parameters;
291  TMatrixDSym _covariance;
292 };
293 
294 typedef std::vector<tp_PixelSegment*> pixelSegmentListType;
295 typedef std::map<int, pixelSegmentListType> pixelSegmentListMapType;
296 
299  public:
300  tp_PixelChip(const int, pixelListType&, const int, const double);
301  ~tp_PixelChip();
302  void print() const;
303  int getId() const;
304  int getNumPix() const;
305  int getNumMPix() const;
306  int getNumBins() const;
307  int findSegments(const double, const int*, const double*);
308  pixelSegmentListType getPixelSegments() const;
309 
310  private:
311  const int _chipId;
312  const int _size;
313  int _numPix;
314  int _numMPix;
315  pixelBinListType _pixelBins;
316  pixelSegmentListType _pixelSegments;
317 };
318 
319 typedef std::vector<tp_PixelChip*> pixelChipListType;
320 
323  public:
324  tp_PixelSegmentCombiner(const double);
325  pixelSegmentListType run(const int, const int, pixelSegmentListType&, const double, const double);
326 
327  private:
328  double _bzc;
329 };
330 
331 } // namespace marlintpc
332 #endif // TIMEPIXLOCALROADSEARCHPROCESSOR_H
double _sarc
arc length (from segment fitting)
int _octoScale
octoboard number scale (in module=(octo+offset)/scale) (default 12)
double _maxGap
max. (arc-length) gap for road (default: 4.0)
int _numPix
number of pixels in macro pixels
std::string _outputColName
Name of the output collection.
const int _hitNum
input hit collection index
TMatrixDSym _covariance
covariance matrix
int _numMPix
number of macro pixels
double _minZmeas
min. measured Z value (default 0.)
std::map< int, pixelListType > chipPixelMapType
const double _sigma2XY
resolution (squared) for XY measurement
int _numPix
number of pixels in macro pixels
pixelSegmentListType _pixelSegments
pixel segments
std::vector< tp_Pixel * > pixelListType
double _chi2CutChip
max. Chi2/Ndf for chip segment matching (default: 30.)
const double _posZ
Z position.
std::string _inputColName
Name of the input collection.
Track finder for TimePix data based on local road search.
const int _mpId2
ID of macro pixel 2.
pixelBinListType _pixelBins
(macro) pixel bins
std::vector< tp_PixelBin * > pixelBinListType
int _maxMult
max. multiplicity for road seeding bins (default: 3)
virtual void processEvent(EVENT::LCEvent *evt)
Process event.
int _minDist
min. distance for road seeding bins (default: 2)
double _distCut
max. relative (to track length sum) distance (of centers) for segment matching (default: 2...
const double _posY
Y position.
const int _binId
bin Id (row, col)
const double _bzc
magnetic field strength (Bz*c)
int _octoOffset
octoboard number offset (in module=(octo+offset)/scale) (default 8)
std::vector< macroPixelPairType > macroPixelPairListType
virtual void processRunHeader(EVENT::LCRunHeader *run)
macroPixelListType _macroPixels
macro pixel
std::vector< tp_PixelSegment * > pixelSegmentListType
double _bzc
magnetic field strength (Bz*c)
int _minTrackLevel
min. track level for output (default 1)
std::map< int, macroPixelPairListType > macroPixelPairListMapType
const double _posX
X position.
const int _mpId
ID (row/col bin: z bin)
std::map< int, pixelSegmentListType > pixelSegmentListMapType
int _mpSize
macro pixel (bin) size (default: 32)
std::vector< tp_MacroPixel * > macroPixelListType
double _bfieldScaleFactor
scale factor for magnetic field (default: 1.0)
int _minPixels
min. number of pixels for road seeding maxro pixel (default: 3)
double _maxPull2Z
max. pull squared to road in Z (default: 15.)
TimePix (macro) pixel road.
const int _npar
number of parameters (5: helix, 4: line)
double _sigma2Z
resolution (squared) for Z measurement
int _ndf
number of degrees of freedom of segment fit
double _maxSvar
max. relative arc-length variance for road (default: 0.15)
double _maxChi2
max. Chi2/Ndf for road (default 5.)
double _chi2CutOcto
max. Chi2/Ndf for octoboard segment matching (default: 30.)
double _maxZmeas
max. measured Z value (default 600.)
std::vector< tp_PixelChip * > pixelChipListType
std::vector< double > _sList
arc length list
double _sigma2XY
resolution (squared) for XY measurement
double _xOffset
offset in x of (local) coordinate system (default 0.)
int _numPix
number of pixels in macro pixels
macroPixelListType _macroPixels
macro pixel
macroPixelListType _macroPixels
macro pixels
double _yOffset
offset in y of (local) coordinate system (default 1500.)
std::pair< tp_MacroPixel *, tp_MacroPixel * > macroPixelPairType
double _chi2CutMod
max. Chi2/Ndf for module segment matching (default: 50.)
const double _sigma2Z
resolution (squared) for Z measurement
bool _refAtPCA
Use Pca as reference point (else 1. hit)
double _maxPull2XY
max. pull squared to road in XY (default: 15.)
const int _mpId1
ID of macro pixel 1.