MyMarlinTPC  170316
RowBasedPadPulseRoadSearchProcessor.h
Go to the documentation of this file.
1 #ifndef ROWBASEDPADPULSEROADSEARCHPROCESSOR_H
2 #define ROWBASEDPADPULSEROADSEARCHPROCESSOR_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/TrackerPulse.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 
99 class RowBasedPadPulseRoadSearchProcessor: public marlin::Processor {
100  public:
101 
102  virtual Processor* newProcessor() {
104  }
105 
107 
108  virtual void init();
109 
110  virtual void processRunHeader(EVENT::LCRunHeader* run);
111 
112  virtual void processEvent(EVENT::LCEvent* evt);
113 
114  virtual void check(EVENT::LCEvent* evt);
115 
116  virtual void end();
117 
118  protected:
119  /* the place for protected and private member data and functions */
122  std::string _outputTrackColName;
124  double _driftVelocity;
126  double _dtMax;
129  double _maxDxyRoad;
130  double _maxDzRoad;
131  int _minRows;
132  double _rowDensityCut;
133  double _maxVarXY;
138  double _offsetCol;
139  double _slopeCol;
140  double _offsetDrift;
141  double _slopeDrift;
142  double _offsetRow;
143  double _slopeRow;
145  double _segCut;
146  bool _refAtPCA;
149 
150  private:
151 
152  double _Bzc;
153  std::map<int, std::vector<int> > _modNeighbours;
154  double _Xcenter;
155  double _Ycenter;
156  std::map<int, int> _moduleRowOffset;
157 
158  bool areNeighbourModules(gear::TPCModule*, gear::TPCModule*, bool);
159 };
160 
161 typedef std::list<int> seedIdListType;
162 
164 
167 class pb_Pulse {
168  public:
169  pb_Pulse(const int iPulse, const EVENT::TrackerPulse& aPulse, const gear::TPCModule& aModule, const double zPos);
170  void print() const;
171  int getPulseNum() const;
172  int getModule() const;
173  int getPadId() const;
174  int getRow() const;
175  int getColumn() const;
176  int getQuality() const;
177  double getCharge() const;
178  double getRelCharge() const;
179  double getTime() const;
180  double getX() const;
181  double getY() const;
182  double getZ() const;
183  void getPos(double*) const;
184  void getCOG(double*) const;
185  void getMeasDir(double*) const;
186  double getPhiMeas() const;
187  bool isMaxPulse() const;
188  bool inSeed() const;
189  int getNumSeeds() const;
190  void addSeed(int);
191  void removeSeed(int);
192  void clearSeeds();
193  const seedIdListType& getSeedIdList() const;
194  int getSeedId() const;
195  void addNeighbour(pb_Pulse*);
196  bool inHit() const;
197  void addToHit();
198  int getIndex() const;
199  void setIndex(int);
200  int getHitNum() const;
201  void setHitNum(int);
202 
203  private:
204  const int _pulseNum;
205  const int _pulseModule;
206  const int _pulsePadID;
207  const int _pulseRow;
208  const int _pulseCol;
209  const int _pulseQuality;
210  const double _pulseCharge;
211  const double _pulseTime;
212  const double _pulseX;
213  const double _pulseY;
214  const double _pulseZ;
215  const double _pulsePhiMeas;
216  const double _pulseDirX;
217  const double _pulseDirY;
218  int _firstCol;
219  int _lastCol;
220  double _maxCharge;
221  double _sumCharge;
222  double _sumChargeDist;
223  seedIdListType _seeds;
224  bool _inHit;
225  int _indexCol;
226  int _hitNum;
227 };
228 
229 typedef std::vector<pb_Pulse*> pulseListType;
230 typedef std::map<int, pulseListType> rowPulseMapType;
231 typedef std::map<int, rowPulseMapType> modPulseMapType;
232 
234 
237 class pb_Seed {
238  public:
239  pb_Seed(const int seedID, const double Bzc, const pulseListType& pulses, const int minRows, const double rowDensityCut,
240  const double maxVarXY);
241  pb_Seed(const int seedID, const double Bzc, const pulseListType& pulses);
242  void print() const;
243  int getSeedId() const;
244  bool getValid() const;
245  void setInvalid();
246  int getNumSeedPulses() const;
247  int getNumUniqueSeedPulses() const;
248  bool hasAddedPulses() const;
249  double getVarXY() const;
250  void getRefPoint(double*) const;
251  void getPar(double *) const;
252  void markPulses();
253  void freePulses();
254  void addPulse(pb_Pulse*);
255  const pulseListType& getPulseList() const;
256  void roadSearch(pulseListType& pulses, pulseListType& insidePulses, const double maxDxy, const double maxDz) const;
257 
258  private:
259  const int _seedId;
260  const double _bzc;
261  const bool _checked;
262  const unsigned int _numPulses;
263  pulseListType _pulseList;
264  bool _valid;
265  double _refX;
266  double _refY;
267  double _refZ;
268  int _npar;
269  double _varXY;
270  double _varZS;
271  TVectorD _parameters;
272  void _fitSeed();
273 
274 };
275 
276 typedef std::vector<pb_Seed*> seedListType;
277 
279 
283  public:
284  rb_SegmentMatch(const rb_Segment* segment1, const rb_Segment* segment2);
285  void print() const;
286  int getSegId1() const;
287  int getSegId2() const;
288  int getFirstRow1() const;
289  int getFirstRow2() const;
290  int getLastRow1() const;
291  int getLastRow2() const;
292  bool getValid() const;
293  bool overlap(rb_SegmentMatch*) const;
294  void setInvalid();
295 
296  private:
297  const int _segId1;
298  const int _segId2;
299  const int _firstRow1;
300  const int _firstRow2;
301  const int _lastRow1;
302  const int _lastRow2;
303  bool _valid;
304 };
305 
306 typedef std::vector<rb_SegmentMatch*> segMatchListType;
307 typedef std::map<int, segMatchListType> segMatchMapType;
308 
309 } // namespace marlintpc
310 #endif // ROWBASEDPADPULSEROADSEARCHPROCESSOR_H
const int _firstRow1
first row of first segment
virtual void processEvent(EVENT::LCEvent *evt)
Process event.
const double _pulsePhiMeas
measurement direction in XY (tangential to row)
std::vector< rb_SegmentMatch * > segMatchListType
const double _bzc
magnetic field strength (Bz*c)
double _slopeRow
measurement variance: diffusion term in row direction
std::map< int, std::vector< int > > _modNeighbours
neighbour modules
double _offsetRow
measurement variance: sigma0^2 in row direction (use rowHeight^2/12. if < 0.)
std::map< int, pulseListType > rowPulseMapType
std::map< int, int > _moduleRowOffset
row offsets per module layer
std::vector< pb_Pulse * > pulseListType
Simultaneous hit and track finding (pad row based).
pulseListType _pulseList
pointers to pulses
double _offsetDrift
measurement variance: sigma0^2 in drift direction
const int _lastRow2
last row of second segment
int _maxColDiffHit
maximum distance of pad to seed in hit (if > 0)
const double _pulseX
X position (local)
bool areNeighbourModules(gear::TPCModule *, gear::TPCModule *, bool)
Check if modules are neighbours.
int _maxColDiff
maximal column difference to pulse in neighbourhood
const int _pulseNum
input pulse collection index
double _maxOverlapFraction
maximum overlap fraction of segment seeds
std::string _outputTrackerHitsColName
Name of the TPC hit output collection.
const unsigned int _numPulses
number of pulses
std::string _inputTrackerPulsesColName
Name of the TPc pulse input collection.
TVectorD _parameters
parameter vector
double _dtMax
maximum drift time difference in neighboorhood/hit
double _rowDensityCut
minimum row &#39;density&#39; for segment seed
double _sumCharge
sum of charge in local neigbourhood
int _firstCol
start (column) of local neigbourhood
std::string _outputTrackColName
Name of the track output collection.
double _varZS
chi2/ndf from (unweighted) ZS fit
const double _pulseY
Y position (local)
double _maxDxyRoad
maximum interpolation deviation in XY (road search)
double _maxCharge
maximum charge in local neigbourhood
int _indexCol
index in list of pulses per row
int _maxSeedsInRow
maximum number of seeding pulses in row
const double _pulseDirY
measurement direction in Y
int _minRowDiff
minimum row difference for pulse pair seeding road
Pad based (track segment) seed.
const int _lastRow1
last row of first segment
double _varXY
chi2/ndf from (unweighted) XY fit
double _segCut
Chi2/Ndf cut for segment matching (Ndf=4 for B off, 5 for B on)
bool _inHit
flag for being part of a hit
int _lastCol
end (column) of local neigbourhood
double _maxVarXY
maximum (average) XY variance (unweighted Chi2/ndf) for segment seed
seedIdListType _seeds
list of seeds (using pulse)
double _slopeCol
measurement variance: diffusion term in column direction
bool _refAtPCA
Use Pca as reference point (else 1. hit)
double _sumChargeDist
sum of charge*distance (to pulse) in local neigbourhood
const double _pulseDirX
measurement direction in X
double _refZ
Z of reference point.
double _refX
X of reference point.
std::map< int, segMatchListType > segMatchMapType
const int _firstRow2
first row of second segment
bool _skipMultiplePulses
skip multiple pulse candidates as road search seeds
double _offsetCol
measurement variance: sigma0^2 in column direction
std::vector< pb_Seed * > seedListType
std::map< int, rowPulseMapType > modPulseMapType
double _slopeDrift
measurement variance: diffusion term in drift direction
double _maxDzRoad
maximum interpolation deviation in Z (road search)
double _refY
Y of reference point.
double _chargeConversionFactor
charge conversion factor from ADC values to primary electrons
int _npar
number of parameters (5: helix, 4: line)
double _bfieldScaleFactor
scale factor for magnetic field (default: 1.0)