MarlinTPC  1.2.0
RowBasedHitFinderProcessor.h
1 #ifndef ROWBASEDHITFINDERPROCESSOR_H
2 #define ROWBASEDHITFINDERPROCESSOR_H
3 
4 // MARLIN
5 #include "marlin/Processor.h"
6 #include "marlin/Global.h"
7 
8 //LCIO
9 #include "lcio.h"
10 #include "EVENT/LCCollection.h"
11 #include "IMPL/LCCollectionVec.h"
12 #include "EVENT/TrackerPulse.h"
13 
14 //GEAR
15 #include "gear/TPCParameters.h"
16 
17 // C++
18 #include <string>
19 #include <vector>
20 #include <map>
21 
22 // MARLINTPC
23 #include "ChannelCorrectionListener.h"
24 #include "TPCConditionsListener.h"
25 
26 namespace marlintpc
27 {
28 
70  class RowBasedHitFinderProcessor : public marlin::Processor
71  {
72  public:
73 
74  virtual Processor* newProcessor()
75  {
76  return new RowBasedHitFinderProcessor;
77  }
78 
80 
84  virtual void init() ;
85 
88  virtual void processRunHeader(lcio::LCRunHeader* run) ;
89 
92  virtual void processEvent(lcio::LCEvent * evt) ;
93 
94 
95  virtual void check(lcio::LCEvent * evt) ;
96 
97 
100  virtual void end() ;
101 
102  private:
105  std::string _inputTrackerPulsesCollectionName ;
106 
109  std::string _outputTrackerHitsCollectionName ;
110 
113  std::string _inputTPCConditionsCollectionName;
114 
116  std::string _channelCorrectionCollectionName;
117 
123  std::vector<int> _deadChannelIndicesOverride;
124 
127  bool _outputHitsPersistent;
128 
131  int _deprecated;
132 
135  int _maxEmptyChannelsOverride;
136 
139  int _maxDeadChannelsOverride;
140 
143  int _minHitSizeOverride;
144 
147  float _minMaxPulseSliceHeightOverride;
148 
151  float _maxTimeSpreadOverride;
152 
155  float _driftVelocityOverride;
156 
159  bool _chargeIsCalibrated;
160 
163  float _chargeConversionFactorOverride;
164 
167  ChannelCorrectionListener* _channelCorrectionListener;
168 
171  TPCConditionsListener* _tpcConditionsListener;
172 
173  // a helper class -- does it make sense to externalise it from the HitFinder?
174  class hitCandidate
175  {
176  public:
177  hitCandidate(EVENT::TrackerPulse*);
178 
179  void addPulse(EVENT::TrackerPulse*);
180  void addDeadChannel();
181 
182  int qualityFlag;
183 
184  const EVENT::TrackerPulse* getMaximumPulse() const
185  {
186  return _maxPulse;
187  };
188  double getCharge() const;
189  double getChargeMeasError() const;
190  double getMaxPulseHeight();
191  const std::vector<EVENT::TrackerPulse*>& getPulses() const
192  {
193  return _thePulses;
194  };
195  unsigned int getWidth() const;
196 
197  private:
198  hitCandidate()
199  {
200  ;
201  };
202  std::vector<EVENT::TrackerPulse*> _thePulses;
203  EVENT::TrackerPulse* _maxPulse;
204  double _maxPulseCharge;
205  int _numberOfDeadChannels;
206  };
207 
210  void _sortPulses(EVENT::LCCollection*, const gear::TPCParameters&,
211  std::map<int, std::map<int, std::vector<EVENT::TrackerPulse*>* >* >&);
212  void _findHitCandidates(std::map<int, std::map<int, std::vector<EVENT::TrackerPulse*>* >* >&,
213  const gear::TPCParameters&,
214  std::map<int, std::vector<RowBasedHitFinderProcessor::hitCandidate> >&);
215  void _createHitCollection(std::map<int, std::vector<RowBasedHitFinderProcessor::hitCandidate> >&,
216  const gear::TPCParameters&, IMPL::LCCollectionVec*);
217 
218  bool _pulseComparator(EVENT::TrackerPulse*, EVENT::TrackerPulse*);
219  EVENT::TrackerPulse* _findHighestPulseInRow(std::vector<EVENT::TrackerPulse*>&);
220  bool _maxPulseHeightCheck(EVENT::TrackerPulse*);
221  void _addNeighbourPulses(hitCandidate&, const gear::TPCParameters&, std::vector<EVENT::TrackerPulse*>&);
222  std::vector<EVENT::TrackerPulse*>::iterator _findBestNeighbourPulseMatch
223  (std::vector<std::vector<EVENT::TrackerPulse*>::iterator>&, float);
224 
225  bool _hitIsValid(const RowBasedHitFinderProcessor::hitCandidate&);
226  gear::Vector3D _calculatePositionsAndErrors(const RowBasedHitFinderProcessor::hitCandidate&, const gear::TPCParameters&, float*);
227  double _convertCharge(const RowBasedHitFinderProcessor::hitCandidate&);
228 
229  unsigned int _getMaxDeadChannels();
230  int _getMinHitSize();
231  double _getMinMaxPulseSliceHeight();
232  double _getMaxTimeSpread();
233  double _getDriftVelocity();
234  bool _padIsDead(const int, const int);
235  bool _padIsNoisy(const int, const int);
236  double _getChargeConversionFactor();
237 
238  };
239 }//namespace marlintpc
240 #endif//ROWBASEDHITFINDERPROCESSOR_H
virtual void processRunHeader(lcio::LCRunHeader *run)
Called for every run.
Definition: RowBasedHitFinderProcessor.cc:196
A hit finder for row based (pad) geometries It searches for connected pulses in a row and combines th...
Definition: RowBasedHitFinderProcessor.h:70
Helper Class which provides access to the ChannelCorrections for every event.
Definition: ChannelCorrectionListener.h:39
virtual void init()
Called at the begin of the job before anything is read.
Definition: RowBasedHitFinderProcessor.cc:128
Helper Class which provides access to the TPC conditions for every event.
Definition: TPCConditionsListener.h:37
virtual void end()
Called after data processing for clean up.
Definition: RowBasedHitFinderProcessor.cc:322
virtual void processEvent(lcio::LCEvent *evt)
Called for every event - the working horse.
Definition: RowBasedHitFinderProcessor.cc:209