MarlinTPC  1.2.0
PulseFinder.h
1 #ifndef PULSEFINDER_H
2 #define PULSEFINDER_H
3 
4 //LCIO
5 #include "lcio.h"
6 #include "EVENT/LCCollection.h"
7 #include "EVENT/TrackerData.h"
8 #include <IMPL/TrackerDataImpl.h>
9 #include "EVENT/TrackerPulse.h"
10 
11 #include "PedestalListener.h"
12 #include "ADCElectronicsListener.h"
13 
14 //C++
15 #include <string>
16 
17 namespace marlintpc
18 {
19 
67  {
68 
69  public:
70 
115  PulseFinder( float minimumPulseHeight,
116  int minimumPulseLength,
117  float pulseStartPedestalWidthFactor,
118  float pulseEndPedestalWidthFactor,
119  float noiseValuePedestalWidthFactor,
120  PedestalListener const * pedestalListener,
121  ADCElectronicsListener const * adcElectronicsListener,
122  int saveNBinsBeforeStart = 0,
123  int saveNBinsAfterEnd = 0,
124  int timeCalculationMode = INFLEXION_POINT,
125  double timeCalculationParameter = 0.9,
126  int chargeCalculationMode = SUMQ
127  );
128 
129  //The modes for charge and time calculation
130  static const int INFLEXION_POINT = 0;
131  static const int FIT_PARABOLA = 1;
132  static const int CENTRE_OF_GRAVITY = 2;
133  static const int FIRST_ABOVE_THRESHOLD = 3;
134  static const int AT_MAXIMUM = 4;
135  static const int CONSTANT_FRACTION = 5;
136  static const int GAMMA_FIT = 6;
137  static const int COG_ATMAX = 7;
138  static const int BOX = 8;
139  static const int GAUSSIAN_INFLEXION = 9;
140 
141 
142  static const int SUMQ = 0;
143  // FIT_PARABOLA = 1 already defined in the time section.
144  static const int MAXQ = 2;
145  static std::string getRevisionNumber();
146 
147  protected:
148 
152 
153 
158 
163 
168 
169  // override variables
170 
171  // A set of variables for which values the override value should be used.
172  bool _usePedestalValueOverride;
173  bool _usePedestalWidthOverride;
174  bool _use_isPedestalSubtractedOverride;
175  bool _usePolarityOverride;
176  bool _useReadoutFrequencyOverride;
177  bool _useMaxADCValueOverride;
178 
179 
183 
187 
191 
195 
199 
203 
204 
207 
209 
210 
212  class PulseTime
213  {
214  public:
215  PulseTime() : _time(0.), _timeError(0.)
216  {
217  ;
218  };
219  void setTime(float t)
220  {
221  _time = t;
222  };
223  void setTimeError(float e)
224  {
225  _timeError = e;
226  };
227  float getTime()
228  {
229  return _time;
230  };
231  float getTimeError()
232  {
233  return _timeError;
234  };
235  private:
236  float _time, _timeError;
237  };
238 
241  {
242  public:
243  PulseCharge() : _charge(0.), _chargeError(0.)
244  {
245  ;
246  };
247  void setCharge(float t)
248  {
249  _charge = t;
250  };
251  void setChargeError(float e)
252  {
253  _chargeError = e;
254  };
255  float getCharge()
256  {
257  return _charge;
258  };
259  float getChargeError()
260  {
261  return _chargeError;
262  };
263  private:
264  float _charge, _chargeError;
265  };
266 
268  class Pulse : public PulseCharge, public PulseTime
269  {
270  public:
271  Pulse() : PulseCharge(), PulseTime()
272  {
273  ;
274  };
275  void set(PulseCharge c)
276  {
277  setCharge(c.getCharge());
278  setChargeError(c.getChargeError());
279  };
280  void set(PulseTime t)
281  {
282  setTime(t.getTime());
283  setTimeError(t.getTimeError());
284  };
285  };
286 
291  {
292  InternalSplitPulse(std::vector<float>::const_iterator s,
293  std::vector<float>::const_iterator e, bool f)
294  {
295  startBin = s;
296  endBin = e;
297  isSplit = f;
298  }
299  std::vector<float>::const_iterator startBin;
300  std::vector<float>::const_iterator endBin;
301  bool isSplit;
302 
304  {
305  ;
306  };
307  };
308 
309  public:
319  std::vector<TrackerPulse *> findPulses(TrackerData* inputData);
320 
328  Pulse calculatePulseTimeAndCharge(const EVENT::TrackerData *tracker_data);
329 
330 
331  // the internal functions
332  protected:
340  void findPulseCandidates(lcio::TrackerData* thisData,
341  std::vector<std::pair<lcio::TrackerDataImpl*, int> >* tempPulse);
342 
343 
344 
353  void brutePulseSearch(TrackerData const * inputTrackerData,
354  std::vector<std::pair<std::vector<float>::const_iterator,
355  std::vector<float>::const_iterator> >* theCandidatePulses);
356 
357 
358 
369  std::vector<InternalSplitPulse> splitMultiplePulses(
370  std::vector< std::pair< std::vector<float>::const_iterator,
371  std::vector<float>::const_iterator> >* theCandidatePulses,
372  float noiseThreshold);
373 
374 
375 
376 
380  Pulse calculatePulseWithFit(const EVENT::TrackerData *tracker_data);
381 
385  PulseTime calcPulseTimeWithGammaFit(const lcio::TrackerData *thisPulse);
386 
390  PulseTime calcPulseTimeInflexionPoint(const lcio::TrackerData* thisPulse);
391 
394  PulseTime calcPulseTimeAtMaximum(const lcio::TrackerData* thisPulse);
395 
398  PulseTime calcPulseTimeAtConstantFraction(const lcio::TrackerData* thisPulse);
399 
402  PulseTime calcPulseTimeCentreOfGravity(const lcio::TrackerData* thisPulse);
403 
406  PulseTime calcPulseTimeCOGAtMaximum(const lcio::TrackerData* thisPulse);
407 
410  PulseTime calcPulseTimeFirstBinAboveThreshold(const lcio::TrackerData* thisPulse);
411 
414  PulseTime calcPulseTimeBoxMethod(const lcio::TrackerData* thisPulse);
415 
418  PulseTime calcuPulseTimeGaussianInflexion(const lcio::TrackerData* thisPulse);
423  PulseCharge calcPulseChargeSumQ(const lcio::TrackerData* thisPulse);
424 
429  PulseCharge calcPulseChargeMaxQ(const lcio::TrackerData* thisPulse);
430 
431 
434  float getPedestalValue(const int hardware_channel, const int readout_group);
435 
436 
437 
440  float getPedestalWidth(const int hardware_channel, const int readout_group);
441 
442 
443 
446  bool isPedestalSubtracted(const int readout_group);
447 
448 
449 
452  int getPolarity(const int readout_group);
453 
454 
455 
459  float getReadoutFrequency(const int readout_group);
460 
461 
462 
466  float getMaxADCValue(const int readout_group);
467  public:
468 
471  void setMaxADCValueOverride(float maxADCValue);
472 
475  void setPedestalValueOverride(float pedestalValue);
476 
479  void setPedestalWidthOverride(float pedestalWidth);
480 
483  void setReadoutFrequencyOverride(float readoutFrequency);
484 
488 
491  void setPolarityOverride(int polarity);
492 
496  void setForceSpectrumSave(bool doSave = true);
497 
500  void setSwitchOffSplitting(bool doNotSplit = false);
501 
505  void setPlateauCutOff(int maxPlateauLength);
506 
507  // declare the tester as friend so we can unit-test the protected member functions
508  friend class PulseFinderTester;
509  };
510 }
511 #endif // PULSEFINDER_H
PedestalListener const * _pedestalListener
the recommended way of providing the access to the pedestal values:
Definition: PulseFinder.h:165
void setSwitchOffSplitting(bool doNotSplit=false)
Flag whether to try to split pulses.
Definition: PulseFinder.cc:1673
float _minimumPulseHeight
minimal value for the pulse maximum in adc counts
Definition: PulseFinder.h:159
ADCElectronicsListener const * _adcElectronicsListener
the recommended way to access the electronics parameters
Definition: PulseFinder.h:167
float _noiseValuePedestalWidthFactor
factor to calculate noise value
Definition: PulseFinder.h:151
static const int FIT_PARABOLA
Time and/or charge is determined by parabolic fit.
Definition: PulseFinder.h:131
Helper class to store the charge and it's error.
Definition: PulseFinder.h:240
void setReadoutFrequencyOverride(float readoutFrequency)
Set an override value for the readout frequency in MHz.
Definition: PulseFinder.cc:157
Pulse calculatePulseTimeAndCharge(const EVENT::TrackerData *tracker_data)
This wrapper function handles the calculation of the pulse time and the pulse charge.
Definition: PulseFinder.cc:743
Helper class which combined PulseCharge and PulseTime.
Definition: PulseFinder.h:268
Helper class to make more sense to the splitting phase: actually keep track of the "split" flag...
Definition: PulseFinder.h:290
static const int AT_MAXIMUM
Time is the first sample at the maximum.
Definition: PulseFinder.h:134
Helper Class which provides access to the pedestals for every event.
Definition: PedestalListener.h:37
PulseTime calcuPulseTimeGaussianInflexion(const lcio::TrackerData *thisPulse)
Calculate the time information from the inflexion point of a gausssian fit.
Definition: PulseFinder.cc:1445
Helper Class which provides access to the parameters of ADC Electroncis.
Definition: ADCElectronicsListener.h:39
PulseCharge calcPulseChargeMaxQ(const lcio::TrackerData *thisPulse)
Use the maximum value as pulse charge.
Definition: PulseFinder.cc:1130
static const int GAMMA_FIT
Time from a Gamma_4 function fit to the pulse.
Definition: PulseFinder.h:136
float getReadoutFrequency(const int readout_group)
Returns the readout frequency of a readout group (in Mhz) taking into consideration whether it should...
Definition: PulseFinder.cc:1626
float _maximumADCValueOverride
maximum adc value, needed to determine if a pulse is maxed out
Definition: PulseFinder.h:182
float _pulseStartPedestalWidthFactor
factor to calculate the start threshold
Definition: PulseFinder.h:149
float _pedestalWidthOverride
The default pedestal width which is used if the pedestalListener is not set.
Definition: PulseFinder.h:194
PulseTime calcPulseTimeAtConstantFraction(const lcio::TrackerData *thisPulse)
Calculate the time information as the time of crossing the threshold set by a fraction of the max...
Definition: PulseFinder.cc:1233
bool _isPedestalSubtractedOverride
Sets, if the data is already pedestal subtracted in the read-out electronics.
Definition: PulseFinder.h:198
float _pulseEndPedestalWidthFactor
factor to calculate the end threshold
Definition: PulseFinder.h:150
double _ConstFracParameter
parameters for time methods
Definition: PulseFinder.h:156
static const int GAUSSIAN_INFLEXION
Inflexion point of a gaussian fit.
Definition: PulseFinder.h:139
float getMaxADCValue(const int readout_group)
Returns the maximum ADC value of a readout group taking into consideration whether it should be overw...
Definition: PulseFinder.cc:1650
static const int MAXQ
Charge is the maximal ADC value.
Definition: PulseFinder.h:144
bool _switchOffSplitting
flag whether to try to split pulses
Definition: PulseFinder.h:206
static std::string getRevisionNumber()
Log the revision number.
Definition: PulseFinder.cc:180
PulseTime calcPulseTimeCentreOfGravity(const lcio::TrackerData *thisPulse)
Calculate the time information as centre of gravity.
Definition: PulseFinder.cc:1265
static const int FIRST_ABOVE_THRESHOLD
Time is the first sample above the start threshold.
Definition: PulseFinder.h:133
int _timeCalculationMode
The mode used for time calculation.
Definition: PulseFinder.h:154
float getPedestalWidth(const int hardware_channel, const int readout_group)
Returns the pedestal width for a given TrackerData / TrackerPulse object taking into consideration wh...
Definition: PulseFinder.cc:1555
void setPedestalValueOverride(float pedestalValue)
Set an overide value for the pedestal value (in ADC counts).
Definition: PulseFinder.cc:145
float _pedestalValueOverride
The default pedestal value which is used if the pedestalListener is not set.
Definition: PulseFinder.h:190
int getPolarity(const int readout_group)
Returns the polarity of a TrackerData / TrackerPulse object taking into consideration whether is shou...
Definition: PulseFinder.cc:1604
float _readoutFrequencyOverride
The readout frequency of every readout group (in MHz).
Definition: PulseFinder.h:186
Helper class to store the time and it's error.
Definition: PulseFinder.h:212
The PulseFinder class is working horse of the ModularPulseFinderProcessor.
Definition: PulseFinder.h:66
float getPedestalValue(const int hardware_channel, const int readout_group)
Returns the pedestal value for a given TrackerData / TrackerPulse object taking into consideration wh...
Definition: PulseFinder.cc:1525
static const int INFLEXION_POINT
Time is the inflexion point of the rising slope.
Definition: PulseFinder.h:130
static const int SUMQ
Charge is the sum of all ADC counts.
Definition: PulseFinder.h:142
PulseTime calcPulseTimeAtMaximum(const lcio::TrackerData *thisPulse)
Calculate the time information as the time of the bin with pulse maximum.
Definition: PulseFinder.cc:1163
int _COGAtMaxParameter
parameters for time methods
Definition: PulseFinder.h:155
Pulse calculatePulseWithFit(const EVENT::TrackerData *tracker_data)
This function calculates the pulse time and charge by fitting a parabola to the log of the data surro...
Definition: PulseFinder.cc:871
int _saveNBinsBeforeStart
of bins stored before the start threshold
Definition: PulseFinder.h:161
int _maxPlateauLength
The maximum length of a plateau within a pulse in time bins.
Definition: PulseFinder.h:208
PulseTime calcPulseTimeFirstBinAboveThreshold(const lcio::TrackerData *thisPulse)
Calculate the time information as the first bin above threshold.
Definition: PulseFinder.cc:1308
PulseTime calcPulseTimeCOGAtMaximum(const lcio::TrackerData *thisPulse)
Calculate the time information as the cog for 2 bin range around the maximum.
Definition: PulseFinder.cc:1184
PulseTime calcPulseTimeBoxMethod(const lcio::TrackerData *thisPulse)
Calculate the time information from the box method.
Definition: PulseFinder.cc:1342
void findPulseCandidates(lcio::TrackerData *thisData, std::vector< std::pair< lcio::TrackerDataImpl *, int > > *tempPulse)
Find pulses by threshold in the ADC information and closer inspection.
Definition: PulseFinder.cc:266
void setPlateauCutOff(int maxPlateauLength)
Set he maximum length of a plateau allowed within a pulse in time bins.
Definition: PulseFinder.cc:175
int _minimumPulseLength
minimal length for a pulse in number of time bins
Definition: PulseFinder.h:160
int _saveNBinsAfterEnd
of bins stored after the end threshold
Definition: PulseFinder.h:162
A class which is friend of PulseFinder so it can access the protected members for testing...
Definition: PulseFinderTester.h:11
static const int CENTRE_OF_GRAVITY
Time is the center of gravity of the charge.
Definition: PulseFinder.h:132
static const int COG_ATMAX
COG for 2 bin range around maximum.
Definition: PulseFinder.h:137
PulseTime calcPulseTimeWithGammaFit(const lcio::TrackerData *thisPulse)
This function calculates the pulse time and charge by fitting a Gamma_n to the pulse.
Definition: PulseFinder.cc:815
std::vector< InternalSplitPulse > splitMultiplePulses(std::vector< std::pair< std::vector< float >::const_iterator, std::vector< float >::const_iterator > > *theCandidatePulses, float noiseThreshold)
The second part in the pulse finding process.
Definition: PulseFinder.cc:616
PulseFinder(float minimumPulseHeight, int minimumPulseLength, float pulseStartPedestalWidthFactor, float pulseEndPedestalWidthFactor, float noiseValuePedestalWidthFactor, PedestalListener const *pedestalListener, ADCElectronicsListener const *adcElectronicsListener, int saveNBinsBeforeStart=0, int saveNBinsAfterEnd=0, int timeCalculationMode=INFLEXION_POINT, double timeCalculationParameter=0.9, int chargeCalculationMode=SUMQ)
The constructor.
Definition: PulseFinder.cc:41
std::vector< TrackerPulse * > findPulses(TrackerData *inputData)
Create TrackerPulses from the TrackerData input.
Definition: PulseFinder.cc:186
bool isPedestalSubtracted(const int readout_group)
Returns if the data has been pedestal subtracted in the read-out electronics or not.
Definition: PulseFinder.cc:1583
static const int CONSTANT_FRACTION
Time is at the constant fraction of the maximum pulse.
Definition: PulseFinder.h:135
void setForceSpectrumSave(bool doSave=true)
Flag whether the spectrum is always stored.
Definition: PulseFinder.cc:1668
void set_isPedestalSubtractedOverride(bool isPedestalSubtracted)
Set an override value whether the pedestal has been subtracted.
Definition: PulseFinder.cc:163
void setPolarityOverride(int polarity)
Set an override value for the polarity.
Definition: PulseFinder.cc:169
static const int BOX
Box Method.
Definition: PulseFinder.h:138
bool _forceSpectrumSave
flag whether to always save the spectrum
Definition: PulseFinder.h:205
void setPedestalWidthOverride(float pedestalWidth)
Set an overide value for the pedestal width (in ADC counts).
Definition: PulseFinder.cc:151
int _polarityOverride
the polarity of all readout groups, overrides LCCD
Definition: PulseFinder.h:202
int _chargeCalculationMode
The mode used for charge calculation.
Definition: PulseFinder.h:157
void setMaxADCValueOverride(float maxADCValue)
Set an overide value for the maximal ADC value.
Definition: PulseFinder.cc:139
PulseCharge calcPulseChargeSumQ(const lcio::TrackerData *thisPulse)
Calculate the integrated charge of the given pulse by summing up all bins of the ADC spectrum...
Definition: PulseFinder.cc:1103
void brutePulseSearch(TrackerData const *inputTrackerData, std::vector< std::pair< std::vector< float >::const_iterator, std::vector< float >::const_iterator > > *theCandidatePulses)
The first function that is called during the pulse finding, it simply looks for values above the star...
Definition: PulseFinder.cc:513
PulseTime calcPulseTimeInflexionPoint(const lcio::TrackerData *thisPulse)
Calculate the time information as the inflextion point of the rising slope.
Definition: PulseFinder.cc:1017