ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RPDDataAnalyzer Class Reference

#include <RPDDataAnalyzer.h>

Collaboration diagram for RPDDataAnalyzer:

Public Types

enum  {
  ValidBit = 0, OutOfTimePileupBit = 1, OverflowBit = 2, PrePulseBit = 3,
  PostPulseBit = 4, NoPulseBit = 5, BadAvgBaselineSubtrBit = 6, InsufficientPileupFitPointsBit = 7,
  PileupStretchedExpFitFailBit = 8, PileupStretchedExpGrowthBit = 9, PileupBadStretchedExpSubtrBit = 10, PileupExpFitFailBit = 11,
  PileupExpGrowthBit = 12, PileupBadExpSubtrBit = 13, PileupStretchedExpPulseLikeBit = 14
}
 

Public Member Functions

 RPDDataAnalyzer (ZDCMsg::MessageFunctionPtr messageFunc_p, const std::string &tag, const RPDConfig &config, std::vector< float > const &calibFactors)
 
virtual ~RPDDataAnalyzer ()=default
 
void loadChannelData (unsigned int channel, const std::vector< uint16_t > &FadcData)
 Load a single channel's FADC data into member variable. More...
 
void analyzeData ()
 Analyze RPD data. More...
 
unsigned int getChMaxSample (unsigned int channel) const
 Get sample of max of RPD data in signal range after pileup subtraction. More...
 
float getChSumAdc (unsigned int channel) const
 Get sum of RPD data in signal range after baseline and pileup subtraction. More...
 
float getChSumAdcCalib (unsigned int channel) const
 Get sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied. More...
 
float getChMaxAdc (unsigned int channel) const
 Get max of RPD data in signal range after baseline and pileup subtraction. More...
 
float getChMaxAdcCalib (unsigned int channel) const
 Get max of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied. More...
 
float getChPileupFrac (unsigned int channel) const
 Get OOT pileup sum as a fraction of non-pileup sum in entire window (0 if no OOT pileup, -1 if sum ADC <= 0). More...
 
float getChBaseline (unsigned int channel) const
 Get baseline used in baseline subtraction. More...
 
const std::vector< float > & getChPileupExpFitParams (unsigned int channel) const
 Get parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*sample ). More...
 
const std::vector< float > & getChPileupStretchedExpFitParams (unsigned int channel) const
 Get parameters for pileup stretched exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*(sample + 4)**(0.5) + [2]*(sample + 4)**(-0.5) ). More...
 
const std::vector< float > & getChPileupExpFitParamErrs (unsigned int channel) const
 Get parameter errors for pileup exponential fit (if pileup was detected and fit did not fail). More...
 
const std::vector< float > & getChPileupStretchedExpFitParamErrs (unsigned int channel) const
 Get parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail). More...
 
float getChPileupExpFitMSE (unsigned int channel) const
 Get mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did not fail). More...
 
float getChPileupStretchedExpFitMSE (unsigned int channel) const
 Get mean squared error of pileup stretched exponential fit in baseline samples (if pileup was detected and fit did not fail). More...
 
unsigned int getChStatus (unsigned int channel) const
 Get status word for channel. More...
 
unsigned int getSideStatus () const
 Get status word for side. More...
 
void reset ()
 Reset all member variables to default values. More...
 

Private Member Functions

bool checkOverflow (unsigned int channel)
 Check for overflow and set relevant status bit. More...
 
bool checkPulses (unsigned int channel)
 Calculate 2nd difference, identify pulses, and set relevant status bits. More...
 
unsigned int countSignalRangeNegatives (std::vector< float > const &values) const
 Calculate the number of negative values in signal range. More...
 
bool doBaselinePileupSubtraction (unsigned int channel)
 Determine if there is pileup, subtract baseline and pileup, and set relevant status bits. More...
 
void calculateMaxSampleMaxAdc (unsigned int channel)
 Calculate max ADC and max sample. More...
 
void calculateSumAdc (unsigned int channel)
 Calculate sum ADC and if there is pileup, calculate fractional pileup. More...
 
void setSideStatusBits ()
 Set side status bits according to channel status bits. More...
 
bool doPileupExpFit (unsigned int channel, std::vector< std::pair< unsigned int, float >> const &pileupFitPoints)
 Perform an exponential fit in baseline-subtracted baseline samples and set relevant status bits. More...
 
bool doPileupStretchedExpFit (unsigned int channel, std::vector< std::pair< unsigned int, float >> const &pileupFitPoints)
 Perform a stretched exponential fit in baseline-subtracted baseline samples and set relevant status bits. More...
 
float calculateBaselineSamplesMSE (unsigned int channel, std::function< float(unsigned int)> const &fit) const
 Calculate the mean squared error of the fit function in the baseline samples. More...
 

Private Attributes

ZDCMsg::MessageFunctionPtr m_msgFunc_p
 
std::string m_tag
 
unsigned int m_nRows
 
unsigned int m_nColumns
 
unsigned int m_nChannels
 
unsigned int m_nChannelsLoaded = 0
 
unsigned int m_nSamples
 
unsigned int m_nBaselineSamples
 
unsigned int m_endSignalSample
 Number of baseline samples; the sample equal to this number is the start of signal region. More...
 
float m_pulse2ndDerivThresh
 Samples before (not including) this sample are the signal region; nSamples goes to end of window. More...
 
float m_postPulseFracThresh
 Second differences less than or equal to this number indicate a pulse. More...
 
unsigned int m_goodPulseSampleStart
 If there is a good pulse and post-pulse and size of post-pulse as a fraction of good pulse is less than or equal to this number, ignore post-pulse. More...
 
unsigned int m_goodPulseSampleStop
 Pulses before this sample are considered pre-pulses. More...
 
unsigned int m_nominalBaseline
 Pulses after this sample are considered post-pulses. More...
 
float m_pileupBaselineSumThresh
 The global nominal baseline; used when pileup is detected. More...
 
float m_pileupBaselineStdDevThresh
 Baseline sums less than this number indicate there is not pileup. More...
 
unsigned int m_nNegativesAllowed
 Baseline standard deviations less than this number indicate there is not pileup. More...
 
unsigned int m_AdcOverflow
 Maximum number of negative ADC values after baseline and pileup subtraction allowed in signal range. More...
 
std::vector< float > m_outputCalibFactors
 ADC values greater than or equal to this number are considered overflow. More...
 
std::vector< std::vector< float > > m_chFadcData
 multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel More...
 
std::vector< std::vector< float > > m_chCorrectedFadcData
 raw RPD data; index channel then sample More...
 
std::vector< float > m_chMaxSample
 RPD data with baseline and pileup subtracted; index channel then sample. More...
 
std::vector< float > m_chSumAdc
 sample of max of RPD data in signal range after pileup subtraction; per channel More...
 
std::vector< float > m_chSumAdcCalib
 sum of RPD data in signal range after baseline and pileup subtraction; per channel More...
 
std::vector< float > m_chMaxAdc
 sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied; per channel More...
 
std::vector< float > m_chMaxAdcCalib
 max of RPD data in signal range after baseline and pileup subtraction; per channel More...
 
std::vector< float > m_chPileupFrac
 max of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied; per channel More...
 
std::vector< float > m_chBaseline
 OOT pileup sum as a fraction of non-pileup sum in entire window (0 if no OOT pileup, -1 if sum ADC <= 0); per channel. More...
 
std::vector< std::vector< float > > m_chPileupExpFitParams
 baseline used in baseline subtraction; per channel More...
 
std::vector< std::vector< float > > m_chPileupStretchedExpFitParams
 parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*sample ); per channel More...
 
std::vector< std::vector< float > > m_chPileupExpFitParamErrs
 parameters for pileup stretched exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*(sample + 4)**(0.5) + [2]*(sample + 4)**(-0.5) ); per channel More...
 
std::vector< std::vector< float > > m_chPileupStretchedExpFitParamErrs
 parameter errors for pileup exponential fit (if pileup was detected and fit did not fail); per channel More...
 
std::vector< bool > m_chPileupFuncType
 parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail); per channel More...
 
std::vector< std::function< float(unsigned int)> > m_chExpPileupFuncs
 true when stretched exponential is used, false if exponential is used for pileup subtraction (if pileup was detected); per channel More...
 
std::vector< std::function< float(unsigned int)> > m_ch2ndOrderStretchedExpPileupFuncs
 pileup exponential fit function (if pileup was detected and fit did not fail); per channel More...
 
std::vector< float > m_chExpPileupMSE
 pileup stretched exponential fit function (if pileup was detected and fit did not fail); per channel More...
 
std::vector< float > m_ch2ndOrderStretchedExpPileupMSE
 mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did not fail); per channel More...
 
std::vector< std::bitset< 32 > > m_chStatus
 mean squared error of pileup stretched exponential fit in baseline samples (if pileup was detected and fit did not fail); per channel More...
 
std::bitset< 32 > m_sideStatus
 status bits per channel More...
 

Static Private Attributes

static unsigned constexpr int s_minPileupFitPoints = 3
 status bits for side More...
 

Detailed Description

Definition at line 35 of file RPDDataAnalyzer.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ValidBit 
OutOfTimePileupBit 
OverflowBit 
PrePulseBit 
PostPulseBit 
NoPulseBit 
BadAvgBaselineSubtrBit 
InsufficientPileupFitPointsBit 
PileupStretchedExpFitFailBit 
PileupStretchedExpGrowthBit 
PileupBadStretchedExpSubtrBit 
PileupExpFitFailBit 
PileupExpGrowthBit 
PileupBadExpSubtrBit 
PileupStretchedExpPulseLikeBit 

Definition at line 38 of file RPDDataAnalyzer.h.

38  {
39  ValidBit = 0, // analysis and output are valid
40  OutOfTimePileupBit = 1, // OOT detected, pileup subtraction attempted
41  OverflowBit = 2, // overflow detected => invalid
42  PrePulseBit = 3, // pulse detected before expected range => invalid
43  PostPulseBit = 4, // pulse detected after expected range => invalid
44  NoPulseBit = 5, // no pulse detected => invalid
45  BadAvgBaselineSubtrBit = 6, // subtraction of avg. of baseline samples yielded too many negatives => invalid
46  InsufficientPileupFitPointsBit = 7, // baseline samples indicate pileup, but there are not enough points to perform fit -> nominal baseline used without pileup subtraction
47  PileupStretchedExpFitFailBit = 8, // fit to stretched exponential failed -> fallback to exponential fit
48  PileupStretchedExpGrowthBit = 9, // fit to stretched exponential does not decay -> fallback to exponential fit
49  PileupBadStretchedExpSubtrBit = 10, // subtraction of stretched exponential fit yielded too many negatives -> fallback to exponential fit
50  PileupExpFitFailBit = 11, // fit to exponential failed => invalid IF stretched exponential fit is also bad
51  PileupExpGrowthBit = 12, // fit to exponential does not decay => invalid IF stretched exponential fit is also bad
52  PileupBadExpSubtrBit = 13, // subtraction of stretched exponential yielded too many negatives => invalid IF stretched exponential fit is also bad
53  PileupStretchedExpPulseLikeBit = 14, // fit to stretched exponential probably looks more like a pulse than pileup
54  };

Constructor & Destructor Documentation

◆ RPDDataAnalyzer()

RPDDataAnalyzer::RPDDataAnalyzer ( ZDCMsg::MessageFunctionPtr  messageFunc_p,
const std::string &  tag,
const RPDConfig config,
std::vector< float > const calibFactors 
)

Definition at line 12 of file RPDDataAnalyzer.cxx.

14  :
15  m_msgFunc_p(std::move(messageFunc_p)),
16  m_tag(tag),
17  m_nRows(config.nRows),
18  m_nColumns(config.nColumns),
20  m_nSamples(config.nSamples),
21  m_nBaselineSamples(config.nBaselineSamples),
22  m_endSignalSample(config.endSignalSample),
23  m_pulse2ndDerivThresh(config.pulse2ndDerivThresh),
24  m_postPulseFracThresh(config.postPulseFracThresh),
25  m_goodPulseSampleStart(config.goodPulseSampleStart),
26  m_goodPulseSampleStop(config.goodPulseSampleStop),
27  m_nominalBaseline(config.nominalBaseline),
28  m_pileupBaselineSumThresh(config.pileupBaselineSumThresh),
29  m_pileupBaselineStdDevThresh(config.pileupBaselineStdDevThresh),
30  m_nNegativesAllowed(config.nNegativesAllowed),
31  m_AdcOverflow(config.AdcOverflow),
32  m_outputCalibFactors(calibFactors),
33  m_chFadcData(m_nChannels, std::vector<float>(m_nSamples, 0)),
34  m_chCorrectedFadcData(m_nChannels, std::vector<float>(m_nSamples, 0)),
42  m_chPileupExpFitParams(m_nChannels, std::vector<float>(2, 0)),
43  m_chPileupStretchedExpFitParams(m_nChannels, std::vector<float>(3, 0)),
44  m_chPileupExpFitParamErrs(m_nChannels, std::vector<float>(2, 0)),
45  m_chPileupStretchedExpFitParamErrs(m_nChannels, std::vector<float>(3, 0)),
52 {
53  if (m_endSignalSample == 0) m_endSignalSample = m_nSamples; // sentinel value 0 -> go to end of waveform
54  if (m_outputCalibFactors.size() != m_nChannels) {
55  (*m_msgFunc_p)(ZDCMsg::Fatal,
56  "RPDDataAnalyzer::RPDDataAnalyzer: received incorrect number of channels in calibration factors ("
58  );
59  }
60  m_sideStatus.reset();
61  m_sideStatus.set(ValidBit, true);
62  for (auto& status : m_chStatus) {
63  status.reset();
64  status.set(ValidBit, true);
65  }
66 }

◆ ~RPDDataAnalyzer()

virtual RPDDataAnalyzer::~RPDDataAnalyzer ( )
virtualdefault

Member Function Documentation

◆ analyzeData()

void RPDDataAnalyzer::analyzeData ( )

Analyze RPD data.

Definition at line 450 of file RPDDataAnalyzer.cxx.

451 {
453  (*m_msgFunc_p)(ZDCMsg::Warn,
454  "RPDDataAnalyzer::analyzeData: analyzing data with " + std::to_string(m_nChannelsLoaded) + " of "
455  + std::to_string(m_nChannels) + " channels loaded"
456  );
457  }
458  for (unsigned int channel = 0; channel < m_nChannels; channel++) {
459  if (!checkOverflow(channel)) {
460  // there was overflow, stop analysis
461  m_chStatus.at(channel).set(ValidBit, false);
462  continue;
463  }
464  if (!checkPulses(channel)) {
465  // there was a pre-pulse or post-pulse, stop analysis
466  m_chStatus.at(channel).set(ValidBit, false);
467  continue;
468  }
469  // there is either only a good pulse or no pulse
470  // only do baseline and pileup subtraction if there is a pulse!
471  if (!m_chStatus.at(channel)[NoPulseBit] /* there is a pulse -> */ && !doBaselinePileupSubtraction(channel)) {
472  // there was a pulse and a problem with baseline/pileup subtraction, stop analysis
473  m_chStatus.at(channel).set(ValidBit, false);
474  continue;
475  }
478  }
480 }

◆ calculateBaselineSamplesMSE()

float RPDDataAnalyzer::calculateBaselineSamplesMSE ( unsigned int  channel,
std::function< float(unsigned int)> const fit 
) const
private

Calculate the mean squared error of the fit function in the baseline samples.

Definition at line 182 of file RPDDataAnalyzer.cxx.

183 {
184  float MSE = 0;
185  for (unsigned int sample = 0; sample < m_nBaselineSamples; sample++) {
186  MSE += std::pow(m_chFadcData.at(channel).at(sample) - m_chBaseline.at(channel) - fit(sample), 2);
187  }
188  MSE /= m_nBaselineSamples;
189  return MSE;
190 }

◆ calculateMaxSampleMaxAdc()

void RPDDataAnalyzer::calculateMaxSampleMaxAdc ( unsigned int  channel)
private

Calculate max ADC and max sample.

Definition at line 356 of file RPDDataAnalyzer.cxx.

357 {
358  if (m_chStatus.at(channel)[NoPulseBit]) {
359  m_chMaxAdc.at(channel) = 0;
360  m_chMaxAdcCalib.at(channel) = 0;
361  m_chMaxSample.at(channel) = -1;
362  return;
363  }
364  float maxAdc = -std::numeric_limits<float>::infinity();
365  unsigned int maxSample = 0;
366  for (unsigned int sample = m_nBaselineSamples; sample < m_endSignalSample; sample++) {
367  float adc = m_chCorrectedFadcData.at(channel).at(sample);
368  if (adc > maxAdc) {
369  maxAdc = adc;
370  maxSample = sample;
371  }
372  }
373  m_chMaxAdc.at(channel) = maxAdc;
375  m_chMaxSample.at(channel) = maxSample;
376 }

◆ calculateSumAdc()

void RPDDataAnalyzer::calculateSumAdc ( unsigned int  channel)
private

Calculate sum ADC and if there is pileup, calculate fractional pileup.

Definition at line 381 of file RPDDataAnalyzer.cxx.

381  {
382  if (m_chStatus.at(channel)[NoPulseBit]) {
383  m_chSumAdc.at(channel) = 0;
384  m_chSumAdcCalib.at(channel) = 0;
385  return;
386  }
387  // sum range is after baseline until end of signal
388  float signalRangeAdcSum = 0;
389  for (unsigned int sample = m_nBaselineSamples; sample < m_endSignalSample; sample++) {
390  signalRangeAdcSum += m_chCorrectedFadcData.at(channel).at(sample);
391  }
392  m_chSumAdc.at(channel) = signalRangeAdcSum;
393  m_chSumAdcCalib.at(channel) = signalRangeAdcSum*m_outputCalibFactors.at(channel);
394 
396  // there is pileup in this channel, calculate fraction of baseline-subtracted raw signal
397  // that is pileup (beginning of window until end of signal)
398  std::function<float(unsigned int)> pileupFunc;
399  if (m_chPileupFuncType.at(channel)) {
400  // use stretched exponential
402  } else {
403  // use exponential
404  pileupFunc = m_chExpPileupFuncs.at(channel);
405  }
406 
407  float totalAdcSum = 0;
408  float pileupTotalAdcSum = 0;
409  for (unsigned int sample = 0; sample < m_endSignalSample; sample++) {
410  totalAdcSum += m_chFadcData.at(channel).at(sample) - m_nominalBaseline;
411  pileupTotalAdcSum += pileupFunc(sample);
412  }
413  if (totalAdcSum > 0) {
414  m_chPileupFrac.at(channel) = pileupTotalAdcSum/totalAdcSum;
415  } else {
416  // avoid dividing by zero or negative, return sentinel value of -1
417  m_chPileupFrac.at(channel) = -1;
418  }
419  } // else fractional pileup is zero initialized, and this is what we want for no pileup
420 }

◆ checkOverflow()

bool RPDDataAnalyzer::checkOverflow ( unsigned int  channel)
private

Check for overflow and set relevant status bit.

Returns true if there was NO overflow (c'est bon).

Definition at line 123 of file RPDDataAnalyzer.cxx.

124 {
125  for (unsigned int sample = 0; sample < m_nSamples; sample++) {
126  if (m_chFadcData.at(channel).at(sample) >= m_AdcOverflow) {
127  m_chStatus.at(channel).set(OverflowBit, true);
128  return false; // overflow - not good
129  }
130  }
131  return true; // all good
132 }

◆ checkPulses()

bool RPDDataAnalyzer::checkPulses ( unsigned int  channel)
private

Calculate 2nd difference, identify pulses, and set relevant status bits.

Returns true if there is a good pulse detected, false if there was a problem, e.g., no pulse or a pulse outside of the expected range.

Definition at line 139 of file RPDDataAnalyzer.cxx.

139  {
140  float prePulseSize = 0;
141  unsigned int prePulseSample = 0;
142  float goodPulseSize = 0;
143  unsigned int goodPulseSample = 0;
144  float postPulseSize = 0;
145  unsigned int postPulseSample = 0;
146  for (unsigned int sample = 1; sample < m_nSamples - 1; sample++) {
147  float secondDiff = m_chFadcData.at(channel).at(sample + 1) - 2*m_chFadcData.at(channel).at(sample) + m_chFadcData.at(channel).at(sample - 1);
148  if (secondDiff > m_pulse2ndDerivThresh) continue; // no pulse here
149  if (sample < m_goodPulseSampleStart && secondDiff < prePulseSize) {
150  prePulseSize = secondDiff;
151  prePulseSample = sample;
152  } else if (sample >= m_goodPulseSampleStart && sample <= m_goodPulseSampleStop && secondDiff < goodPulseSize) {
153  goodPulseSize = secondDiff;
154  goodPulseSample = sample;
155  } else if (sample > m_goodPulseSampleStop && secondDiff < postPulseSize) {
156  postPulseSize = secondDiff;
157  postPulseSample = sample;
158  }
159  }
160 
161  bool hasPrePulse = prePulseSample;
162  bool hasGoodPulse = goodPulseSample;
163  bool hasPostPulse = postPulseSample;
164 
165  // we need to accomodate side A, which has dips in second derivative after good pulse range
166  // if post-pulses are sufficiently small, we ignore them
167  // we expect these anomolies at ~ sample 11 or 12
168  if (hasGoodPulse && hasPostPulse && postPulseSize/goodPulseSize <= m_postPulseFracThresh) hasPostPulse = false;
169 
170  bool hasNoPulse = !hasPrePulse && !hasGoodPulse && !hasPostPulse;
171 
172  if (hasPrePulse) m_chStatus.at(channel).set(PrePulseBit, true);
173  if (hasPostPulse) m_chStatus.at(channel).set(PostPulseBit, true);
174  if (hasNoPulse) m_chStatus.at(channel).set(NoPulseBit, true);
175 
176  return !hasPrePulse && !hasPostPulse; // true if there is a only good pulse or if there is no pulse
177 }

◆ countSignalRangeNegatives()

unsigned int RPDDataAnalyzer::countSignalRangeNegatives ( std::vector< float > const values) const
private

Calculate the number of negative values in signal range.

Definition at line 264 of file RPDDataAnalyzer.cxx.

265 {
266  unsigned int nNegatives = 0;
267  for (unsigned int sample = m_nBaselineSamples; sample < m_endSignalSample; sample++) {
268  if (values.at(sample) < 0) nNegatives++;
269  }
270  return nNegatives;
271 }

◆ doBaselinePileupSubtraction()

bool RPDDataAnalyzer::doBaselinePileupSubtraction ( unsigned int  channel)
private

Determine if there is pileup, subtract baseline and pileup, and set relevant status bits.

Returns true if pileup subtraction succeeded, false if there was a problem.

points (sample, baseline-subtracted ADC) with ADC above baseline, to be used in fit in case of pileup

Definition at line 277 of file RPDDataAnalyzer.cxx.

277  {
278  float nominalBaselineSubtrSum = 0;
280  std::vector<std::pair<unsigned int, float>> pileupFitPoints;
281  for (unsigned int sample = 0; sample < m_nBaselineSamples; sample++) {
282  float const& adc = m_chFadcData.at(channel).at(sample);
283  float const adcBaselineSubtr = adc - m_nominalBaseline;
284  nominalBaselineSubtrSum += adcBaselineSubtr;
285  if (adcBaselineSubtr > 0) {
286  // this sample is a candidate for pileup fit
287  pileupFitPoints.emplace_back(sample, adcBaselineSubtr);
288  }
289  }
290  float baselineStdDev = TMath::RMS(m_chFadcData.at(channel).begin(), std::next(m_chFadcData.at(channel).begin(), m_nBaselineSamples));
291 
292  if (nominalBaselineSubtrSum < m_pileupBaselineSumThresh || baselineStdDev < m_pileupBaselineStdDevThresh) {
293  // there is NO pileup, we will trust the average of baseline samples as a good baseline estimate
295  // calculate fadc data with baseline subtracted
296  for (unsigned int sample = 0; sample < m_nSamples; sample++) {
298  }
301  return false;
302  }
303  return true; // all good
304  }
305 
306  // we suspect that there is pileup - use nominal baseline
308 
309  if (pileupFitPoints.size() < s_minPileupFitPoints) {
311  // there are not enough points to do fit, so just use nominal baseline and call it a day
312  for (unsigned int sample = 0; sample < m_nSamples; sample++) {
314  }
315  return true; // all good
316  }
317 
318  // there is OOT pileup in this channel => expect approx. negative exponential in baseline samples
319  m_chStatus.at(channel).set(OutOfTimePileupBit, true);
320  // fit (approximately) to exponential and stretched exponential in baseline samples
321  bool expFitSuccess = doPileupExpFit(channel, pileupFitPoints);
322  bool stretchedExpFitSuccess = doPileupStretchedExpFit(channel, pileupFitPoints);
323 
324  if (stretchedExpFitSuccess) {
325  // calculate fadc data with baseline and pileup contribution subtracted
326  for (unsigned int sample = 0; sample < m_nSamples; sample++) {
328  }
331  // fallback to exponential fit
332  } else {
333  m_chPileupFuncType.at(channel) = true;
334  return true; // all good
335  }
336  }
337 
338  if (expFitSuccess) {
339  // calculate fadc data with baseline and pileup contribution subtracted
340  for (unsigned int sample = 0; sample < m_nSamples; sample++) {
342  }
344  m_chStatus.at(channel).set(PileupBadExpSubtrBit, true);
345  return false;
346  }
347  return true; // all good
348  }
349 
350  return false; // both fits are bad...we have no measure of pileup!
351 }

◆ doPileupExpFit()

bool RPDDataAnalyzer::doPileupExpFit ( unsigned int  channel,
std::vector< std::pair< unsigned int, float >> const pileupFitPoints 
)
private

Perform an exponential fit in baseline-subtracted baseline samples and set relevant status bits.

Returns true if the fit and subtraction are good, false if there was a problem.

Definition at line 196 of file RPDDataAnalyzer.cxx.

197 {
198  TLinearFitter fitter(1, "1 ++ x");
199  double x;
200  for (auto const& [sample, y] : pileupFitPoints) {
201  x = sample;
202  fitter.AddPoint(&x, std::log(y));
203  }
204  if (fitter.Eval()) {
205  (*m_msgFunc_p)(ZDCMsg::Warn, "RPDDataAnalyzer::doPileupExpFit: there was an error while evaluating TLinearFitter!");
206  m_chStatus.at(channel).set(PileupExpFitFailBit, true);
207  return false;
208  }
209  m_chPileupExpFitParams.at(channel) = {static_cast<float>(fitter.GetParameter(0)), static_cast<float>(fitter.GetParameter(1))};
210  m_chPileupExpFitParamErrs.at(channel) = {static_cast<float>(fitter.GetParError(0)), static_cast<float>(fitter.GetParError(1))};
211  m_chExpPileupFuncs.at(channel) = [intercept = fitter.GetParameter(0), slope = fitter.GetParameter(1)](unsigned int sample) { return std::exp(intercept + slope*sample); };
213 
214  // check for exponential growth in parameters - we definitely don't want that for a function that describes pileup
215  if (fitter.GetParameter(1) >= 0) {
216  (*m_msgFunc_p)(ZDCMsg::Debug, "RPDDataAnalyzer::doPileupExpFit: p1 is " + std::to_string(fitter.GetParameter(1)) + " > 0 -> there is exponential growth in fit function!");
217  m_chStatus.at(channel).set(PileupExpGrowthBit, true);
218  return false;
219  }
220  return true; // all good
221 }

◆ doPileupStretchedExpFit()

bool RPDDataAnalyzer::doPileupStretchedExpFit ( unsigned int  channel,
std::vector< std::pair< unsigned int, float >> const pileupFitPoints 
)
private

Perform a stretched exponential fit in baseline-subtracted baseline samples and set relevant status bits.

Returns true if the fit and subtraction are good, false if there was a problem.

Definition at line 227 of file RPDDataAnalyzer.cxx.

228 {
229  TLinearFitter fitter(1, "1 ++ (x + 4)**(0.5) ++ (x + 4)**(-0.5)");
230  double x;
231  for (auto const& [sample, y] : pileupFitPoints) {
232  x = sample;
233  fitter.AddPoint(&x, std::log(y));
234  }
235  if (fitter.Eval()) {
236  (*m_msgFunc_p)(ZDCMsg::Warn, "RPDDataAnalyzer::doPileupStretchedExpFit: there was an error while evaluating TLinearFitter!");
238  return false;
239  }
240  m_chPileupStretchedExpFitParams.at(channel) = {static_cast<float>(fitter.GetParameter(0)), static_cast<float>(fitter.GetParameter(1)), static_cast<float>(fitter.GetParameter(2))};
241  m_chPileupStretchedExpFitParamErrs.at(channel) = {static_cast<float>(fitter.GetParError(0)), static_cast<float>(fitter.GetParError(1)), static_cast<float>(fitter.GetParError(2))};
242  m_ch2ndOrderStretchedExpPileupFuncs.at(channel) = [p0 = fitter.GetParameter(0), p1 = fitter.GetParameter(1), p2 = fitter.GetParameter(2)](unsigned int sample) {
243  return std::exp(p0 + p1*std::pow(sample + 4, 0.5) + p2*std::pow(sample + 4, -0.5));
244  };
246 
247  // check for exponential growth in parameters - we definitely don't want that for a function that describes pileup
248  if (fitter.GetParameter(1) >= 0) {
249  (*m_msgFunc_p)(ZDCMsg::Debug, "RPDDataAnalyzer::doPileupStretchedExpFit: p1 is " + std::to_string(fitter.GetParameter(1)) + " > 0 -> there is exponential growth in fit function!");
251  return false;
252  }
253  if (fitter.GetParameter(2)/fitter.GetParameter(1) - 4 > 0) {
254  (*m_msgFunc_p)(ZDCMsg::Debug, "RPDDataAnalyzer::doPileupStretchedExpFit: 1st deriv max occurs at sample " + std::to_string(fitter.GetParameter(1)) + " > 0 -> fit probably looks like a pulse (and not like pileup)");
256  // analysis remains valid (for now)
257  }
258  return true; // all good
259 }

◆ getChBaseline()

float RPDDataAnalyzer::getChBaseline ( unsigned int  channel) const

Get baseline used in baseline subtraction.

Definition at line 533 of file RPDDataAnalyzer.cxx.

533  {
534  return m_chBaseline.at(channel);
535 }

◆ getChMaxAdc()

float RPDDataAnalyzer::getChMaxAdc ( unsigned int  channel) const

Get max of RPD data in signal range after baseline and pileup subtraction.

Definition at line 509 of file RPDDataAnalyzer.cxx.

510 {
511  return m_chMaxAdc.at(channel);
512 }

◆ getChMaxAdcCalib()

float RPDDataAnalyzer::getChMaxAdcCalib ( unsigned int  channel) const

Get max of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied.

Definition at line 517 of file RPDDataAnalyzer.cxx.

518 {
519  return m_chMaxAdcCalib.at(channel);
520 }

◆ getChMaxSample()

unsigned int RPDDataAnalyzer::getChMaxSample ( unsigned int  channel) const

Get sample of max of RPD data in signal range after pileup subtraction.

Definition at line 485 of file RPDDataAnalyzer.cxx.

486 {
487  return m_chMaxSample.at(channel);
488 }

◆ getChPileupExpFitMSE()

float RPDDataAnalyzer::getChPileupExpFitMSE ( unsigned int  channel) const

Get mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did not fail).

Definition at line 568 of file RPDDataAnalyzer.cxx.

568  {
569  return m_chExpPileupMSE.at(channel);
570 }

◆ getChPileupExpFitParamErrs()

const std::vector< float > & RPDDataAnalyzer::getChPileupExpFitParamErrs ( unsigned int  channel) const

Get parameter errors for pileup exponential fit (if pileup was detected and fit did not fail).

Definition at line 554 of file RPDDataAnalyzer.cxx.

554  {
556 }

◆ getChPileupExpFitParams()

const std::vector< float > & RPDDataAnalyzer::getChPileupExpFitParams ( unsigned int  channel) const

Get parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*sample ).

Definition at line 540 of file RPDDataAnalyzer.cxx.

540  {
541  return m_chPileupExpFitParams.at(channel);
542 }

◆ getChPileupFrac()

float RPDDataAnalyzer::getChPileupFrac ( unsigned int  channel) const

Get OOT pileup sum as a fraction of non-pileup sum in entire window (0 if no OOT pileup, -1 if sum ADC <= 0).

Definition at line 525 of file RPDDataAnalyzer.cxx.

526 {
527  return m_chPileupFrac.at(channel);
528 }

◆ getChPileupStretchedExpFitMSE()

float RPDDataAnalyzer::getChPileupStretchedExpFitMSE ( unsigned int  channel) const

Get mean squared error of pileup stretched exponential fit in baseline samples (if pileup was detected and fit did not fail).

Definition at line 575 of file RPDDataAnalyzer.cxx.

575  {
577 }

◆ getChPileupStretchedExpFitParamErrs()

const std::vector< float > & RPDDataAnalyzer::getChPileupStretchedExpFitParamErrs ( unsigned int  channel) const

Get parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail).

Definition at line 561 of file RPDDataAnalyzer.cxx.

561  {
563 }

◆ getChPileupStretchedExpFitParams()

const std::vector< float > & RPDDataAnalyzer::getChPileupStretchedExpFitParams ( unsigned int  channel) const

Get parameters for pileup stretched exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*(sample + 4)**(0.5) + [2]*(sample + 4)**(-0.5) ).

Definition at line 547 of file RPDDataAnalyzer.cxx.

547  {
549 }

◆ getChStatus()

unsigned int RPDDataAnalyzer::getChStatus ( unsigned int  channel) const

Get status word for channel.

Definition at line 582 of file RPDDataAnalyzer.cxx.

583 {
584  return static_cast<unsigned int>(m_chStatus.at(channel).to_ulong());
585 }

◆ getChSumAdc()

float RPDDataAnalyzer::getChSumAdc ( unsigned int  channel) const

Get sum of RPD data in signal range after baseline and pileup subtraction.

Definition at line 493 of file RPDDataAnalyzer.cxx.

494 {
495  return m_chSumAdc.at(channel);
496 }

◆ getChSumAdcCalib()

float RPDDataAnalyzer::getChSumAdcCalib ( unsigned int  channel) const

Get sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied.

Definition at line 501 of file RPDDataAnalyzer.cxx.

502 {
503  return m_chSumAdcCalib.at(channel);
504 }

◆ getSideStatus()

unsigned int RPDDataAnalyzer::getSideStatus ( ) const

Get status word for side.

Definition at line 590 of file RPDDataAnalyzer.cxx.

591 {
592  return static_cast<unsigned int>(m_sideStatus.to_ulong());
593 }

◆ loadChannelData()

void RPDDataAnalyzer::loadChannelData ( unsigned int  channel,
const std::vector< uint16_t > &  FadcData 
)

Load a single channel's FADC data into member variable.

Definition at line 71 of file RPDDataAnalyzer.cxx.

72 {
73  if (FadcData.size() != m_nSamples) {
74  (*m_msgFunc_p)(ZDCMsg::Fatal, "RPDDataAnalyzer::loadChannelData: received incorrect number of samples in FADC data");
75  }
76  for (unsigned int sample = 0; sample < m_nSamples; sample++) {
77  m_chFadcData.at(channel).at(sample) = FadcData.at(sample);
78  }
80 }

◆ reset()

void RPDDataAnalyzer::reset ( )

Reset all member variables to default values.

Definition at line 85 of file RPDDataAnalyzer.cxx.

◆ setSideStatusBits()

void RPDDataAnalyzer::setSideStatusBits ( )
private

Set side status bits according to channel status bits.

Definition at line 425 of file RPDDataAnalyzer.cxx.

426 {
427  for (unsigned int channel = 0; channel < m_nChannels; channel++) {
428  if (!m_chStatus.at(channel)[ValidBit]) m_sideStatus.set(ValidBit, false);
429 
434  if (m_chStatus.at(channel)[NoPulseBit]) m_sideStatus.set(NoPulseBit, true);
444  }
445 }

Member Data Documentation

◆ m_AdcOverflow

unsigned int RPDDataAnalyzer::m_AdcOverflow
private

Maximum number of negative ADC values after baseline and pileup subtraction allowed in signal range.

Definition at line 113 of file RPDDataAnalyzer.h.

◆ m_ch2ndOrderStretchedExpPileupFuncs

std::vector<std::function<float(unsigned int)> > RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupFuncs
private

pileup exponential fit function (if pileup was detected and fit did not fail); per channel

Definition at line 131 of file RPDDataAnalyzer.h.

◆ m_ch2ndOrderStretchedExpPileupMSE

std::vector<float> RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupMSE
private

mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did not fail); per channel

Definition at line 133 of file RPDDataAnalyzer.h.

◆ m_chBaseline

std::vector<float> RPDDataAnalyzer::m_chBaseline
private

OOT pileup sum as a fraction of non-pileup sum in entire window (0 if no OOT pileup, -1 if sum ADC <= 0); per channel.

Definition at line 124 of file RPDDataAnalyzer.h.

◆ m_chCorrectedFadcData

std::vector<std::vector<float> > RPDDataAnalyzer::m_chCorrectedFadcData
private

raw RPD data; index channel then sample

Definition at line 117 of file RPDDataAnalyzer.h.

◆ m_chExpPileupFuncs

std::vector<std::function<float(unsigned int)> > RPDDataAnalyzer::m_chExpPileupFuncs
private

true when stretched exponential is used, false if exponential is used for pileup subtraction (if pileup was detected); per channel

Definition at line 130 of file RPDDataAnalyzer.h.

◆ m_chExpPileupMSE

std::vector<float> RPDDataAnalyzer::m_chExpPileupMSE
private

pileup stretched exponential fit function (if pileup was detected and fit did not fail); per channel

Definition at line 132 of file RPDDataAnalyzer.h.

◆ m_chFadcData

std::vector<std::vector<float> > RPDDataAnalyzer::m_chFadcData
private

multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel

Definition at line 116 of file RPDDataAnalyzer.h.

◆ m_chMaxAdc

std::vector<float> RPDDataAnalyzer::m_chMaxAdc
private

sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied; per channel

Definition at line 121 of file RPDDataAnalyzer.h.

◆ m_chMaxAdcCalib

std::vector<float> RPDDataAnalyzer::m_chMaxAdcCalib
private

max of RPD data in signal range after baseline and pileup subtraction; per channel

Definition at line 122 of file RPDDataAnalyzer.h.

◆ m_chMaxSample

std::vector<float> RPDDataAnalyzer::m_chMaxSample
private

RPD data with baseline and pileup subtracted; index channel then sample.

Definition at line 118 of file RPDDataAnalyzer.h.

◆ m_chPileupExpFitParamErrs

std::vector<std::vector<float> > RPDDataAnalyzer::m_chPileupExpFitParamErrs
private

parameters for pileup stretched exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*(sample + 4)**(0.5) + [2]*(sample + 4)**(-0.5) ); per channel

Definition at line 127 of file RPDDataAnalyzer.h.

◆ m_chPileupExpFitParams

std::vector<std::vector<float> > RPDDataAnalyzer::m_chPileupExpFitParams
private

baseline used in baseline subtraction; per channel

Definition at line 125 of file RPDDataAnalyzer.h.

◆ m_chPileupFrac

std::vector<float> RPDDataAnalyzer::m_chPileupFrac
private

max of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied; per channel

Definition at line 123 of file RPDDataAnalyzer.h.

◆ m_chPileupFuncType

std::vector<bool> RPDDataAnalyzer::m_chPileupFuncType
private

parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail); per channel

Definition at line 129 of file RPDDataAnalyzer.h.

◆ m_chPileupStretchedExpFitParamErrs

std::vector<std::vector<float> > RPDDataAnalyzer::m_chPileupStretchedExpFitParamErrs
private

parameter errors for pileup exponential fit (if pileup was detected and fit did not fail); per channel

Definition at line 128 of file RPDDataAnalyzer.h.

◆ m_chPileupStretchedExpFitParams

std::vector<std::vector<float> > RPDDataAnalyzer::m_chPileupStretchedExpFitParams
private

parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*sample ); per channel

Definition at line 126 of file RPDDataAnalyzer.h.

◆ m_chStatus

std::vector<std::bitset<32> > RPDDataAnalyzer::m_chStatus
private

mean squared error of pileup stretched exponential fit in baseline samples (if pileup was detected and fit did not fail); per channel

Definition at line 134 of file RPDDataAnalyzer.h.

◆ m_chSumAdc

std::vector<float> RPDDataAnalyzer::m_chSumAdc
private

sample of max of RPD data in signal range after pileup subtraction; per channel

Definition at line 119 of file RPDDataAnalyzer.h.

◆ m_chSumAdcCalib

std::vector<float> RPDDataAnalyzer::m_chSumAdcCalib
private

sum of RPD data in signal range after baseline and pileup subtraction; per channel

Definition at line 120 of file RPDDataAnalyzer.h.

◆ m_endSignalSample

unsigned int RPDDataAnalyzer::m_endSignalSample
private

Number of baseline samples; the sample equal to this number is the start of signal region.

Definition at line 104 of file RPDDataAnalyzer.h.

◆ m_goodPulseSampleStart

unsigned int RPDDataAnalyzer::m_goodPulseSampleStart
private

If there is a good pulse and post-pulse and size of post-pulse as a fraction of good pulse is less than or equal to this number, ignore post-pulse.

Definition at line 107 of file RPDDataAnalyzer.h.

◆ m_goodPulseSampleStop

unsigned int RPDDataAnalyzer::m_goodPulseSampleStop
private

Pulses before this sample are considered pre-pulses.

Definition at line 108 of file RPDDataAnalyzer.h.

◆ m_msgFunc_p

ZDCMsg::MessageFunctionPtr RPDDataAnalyzer::m_msgFunc_p
private

Definition at line 96 of file RPDDataAnalyzer.h.

◆ m_nBaselineSamples

unsigned int RPDDataAnalyzer::m_nBaselineSamples
private

Definition at line 103 of file RPDDataAnalyzer.h.

◆ m_nChannels

unsigned int RPDDataAnalyzer::m_nChannels
private

Definition at line 100 of file RPDDataAnalyzer.h.

◆ m_nChannelsLoaded

unsigned int RPDDataAnalyzer::m_nChannelsLoaded = 0
private

Definition at line 101 of file RPDDataAnalyzer.h.

◆ m_nColumns

unsigned int RPDDataAnalyzer::m_nColumns
private

Definition at line 99 of file RPDDataAnalyzer.h.

◆ m_nNegativesAllowed

unsigned int RPDDataAnalyzer::m_nNegativesAllowed
private

Baseline standard deviations less than this number indicate there is not pileup.

Definition at line 112 of file RPDDataAnalyzer.h.

◆ m_nominalBaseline

unsigned int RPDDataAnalyzer::m_nominalBaseline
private

Pulses after this sample are considered post-pulses.

Definition at line 109 of file RPDDataAnalyzer.h.

◆ m_nRows

unsigned int RPDDataAnalyzer::m_nRows
private

Definition at line 98 of file RPDDataAnalyzer.h.

◆ m_nSamples

unsigned int RPDDataAnalyzer::m_nSamples
private

Definition at line 102 of file RPDDataAnalyzer.h.

◆ m_outputCalibFactors

std::vector<float> RPDDataAnalyzer::m_outputCalibFactors
private

ADC values greater than or equal to this number are considered overflow.

Definition at line 114 of file RPDDataAnalyzer.h.

◆ m_pileupBaselineStdDevThresh

float RPDDataAnalyzer::m_pileupBaselineStdDevThresh
private

Baseline sums less than this number indicate there is not pileup.

Definition at line 111 of file RPDDataAnalyzer.h.

◆ m_pileupBaselineSumThresh

float RPDDataAnalyzer::m_pileupBaselineSumThresh
private

The global nominal baseline; used when pileup is detected.

Definition at line 110 of file RPDDataAnalyzer.h.

◆ m_postPulseFracThresh

float RPDDataAnalyzer::m_postPulseFracThresh
private

Second differences less than or equal to this number indicate a pulse.

Definition at line 106 of file RPDDataAnalyzer.h.

◆ m_pulse2ndDerivThresh

float RPDDataAnalyzer::m_pulse2ndDerivThresh
private

Samples before (not including) this sample are the signal region; nSamples goes to end of window.

Definition at line 105 of file RPDDataAnalyzer.h.

◆ m_sideStatus

std::bitset<32> RPDDataAnalyzer::m_sideStatus
private

status bits per channel

Definition at line 135 of file RPDDataAnalyzer.h.

◆ m_tag

std::string RPDDataAnalyzer::m_tag
private

Definition at line 97 of file RPDDataAnalyzer.h.

◆ s_minPileupFitPoints

unsigned constexpr int RPDDataAnalyzer::s_minPileupFitPoints = 3
staticconstexprprivate

status bits for side

in the case of pileup, the number of points (above baseline) in baseline samples required to perform fit. this number must be at least the number of parameters in pileup fits, else inversion of Gram matrix in TLinearFitter will fail and generate ROOT error that propagates to Athena. if insufficient points, set InsufficientPileupFitPointsBit and abort pileup subtraction.

Definition at line 143 of file RPDDataAnalyzer.h.


The documentation for this class was generated from the following files:
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
RPDDataAnalyzer::m_chPileupStretchedExpFitParamErrs
std::vector< std::vector< float > > m_chPileupStretchedExpFitParamErrs
parameter errors for pileup exponential fit (if pileup was detected and fit did not fail); per channe...
Definition: RPDDataAnalyzer.h:128
RPDDataAnalyzer::PileupStretchedExpPulseLikeBit
@ PileupStretchedExpPulseLikeBit
Definition: RPDDataAnalyzer.h:53
RPDDataAnalyzer::m_chSumAdc
std::vector< float > m_chSumAdc
sample of max of RPD data in signal range after pileup subtraction; per channel
Definition: RPDDataAnalyzer.h:119
RPDDataAnalyzer::InsufficientPileupFitPointsBit
@ InsufficientPileupFitPointsBit
Definition: RPDDataAnalyzer.h:46
RPDDataAnalyzer::m_chMaxAdcCalib
std::vector< float > m_chMaxAdcCalib
max of RPD data in signal range after baseline and pileup subtraction; per channel
Definition: RPDDataAnalyzer.h:122
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
ZDCMsg::Warn
@ Warn
Definition: ZDCMsg.h:21
RPDDataAnalyzer::m_pileupBaselineSumThresh
float m_pileupBaselineSumThresh
The global nominal baseline; used when pileup is detected.
Definition: RPDDataAnalyzer.h:110
RPDDataAnalyzer::m_nNegativesAllowed
unsigned int m_nNegativesAllowed
Baseline standard deviations less than this number indicate there is not pileup.
Definition: RPDDataAnalyzer.h:112
RPDDataAnalyzer::m_chPileupStretchedExpFitParams
std::vector< std::vector< float > > m_chPileupStretchedExpFitParams
parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*s...
Definition: RPDDataAnalyzer.h:126
RPDDataAnalyzer::calculateMaxSampleMaxAdc
void calculateMaxSampleMaxAdc(unsigned int channel)
Calculate max ADC and max sample.
Definition: RPDDataAnalyzer.cxx:356
RPDDataAnalyzer::BadAvgBaselineSubtrBit
@ BadAvgBaselineSubtrBit
Definition: RPDDataAnalyzer.h:45
RPDDataAnalyzer::m_nColumns
unsigned int m_nColumns
Definition: RPDDataAnalyzer.h:99
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
RPDDataAnalyzer::m_chSumAdcCalib
std::vector< float > m_chSumAdcCalib
sum of RPD data in signal range after baseline and pileup subtraction; per channel
Definition: RPDDataAnalyzer.h:120
RPDDataAnalyzer::m_chBaseline
std::vector< float > m_chBaseline
OOT pileup sum as a fraction of non-pileup sum in entire window (0 if no OOT pileup,...
Definition: RPDDataAnalyzer.h:124
RPDDataAnalyzer::m_sideStatus
std::bitset< 32 > m_sideStatus
status bits per channel
Definition: RPDDataAnalyzer.h:135
RPDDataAnalyzer::m_outputCalibFactors
std::vector< float > m_outputCalibFactors
ADC values greater than or equal to this number are considered overflow.
Definition: RPDDataAnalyzer.h:114
RPDDataAnalyzer::m_chPileupExpFitParams
std::vector< std::vector< float > > m_chPileupExpFitParams
baseline used in baseline subtraction; per channel
Definition: RPDDataAnalyzer.h:125
RPDDataAnalyzer::m_nRows
unsigned int m_nRows
Definition: RPDDataAnalyzer.h:98
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
x
#define x
RPDDataAnalyzer::m_chPileupFrac
std::vector< float > m_chPileupFrac
max of RPD data in signal range after baseline and pileup subtraction, with output calibration factor...
Definition: RPDDataAnalyzer.h:123
RPDDataAnalyzer::PrePulseBit
@ PrePulseBit
Definition: RPDDataAnalyzer.h:42
RPDDataAnalyzer::countSignalRangeNegatives
unsigned int countSignalRangeNegatives(std::vector< float > const &values) const
Calculate the number of negative values in signal range.
Definition: RPDDataAnalyzer.cxx:264
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
RPDDataAnalyzer::NoPulseBit
@ NoPulseBit
Definition: RPDDataAnalyzer.h:44
RPDDataAnalyzer::m_chCorrectedFadcData
std::vector< std::vector< float > > m_chCorrectedFadcData
raw RPD data; index channel then sample
Definition: RPDDataAnalyzer.h:117
RPDDataAnalyzer::PileupStretchedExpGrowthBit
@ PileupStretchedExpGrowthBit
Definition: RPDDataAnalyzer.h:48
zeroPileupFuncVector
const auto zeroPileupFuncVector
Definition: RPDDataAnalyzer.cxx:10
RPDDataAnalyzer::m_AdcOverflow
unsigned int m_AdcOverflow
Maximum number of negative ADC values after baseline and pileup subtraction allowed in signal range.
Definition: RPDDataAnalyzer.h:113
RPDDataAnalyzer::m_chExpPileupMSE
std::vector< float > m_chExpPileupMSE
pileup stretched exponential fit function (if pileup was detected and fit did not fail); per channel
Definition: RPDDataAnalyzer.h:132
RPDDataAnalyzer::m_chMaxAdc
std::vector< float > m_chMaxAdc
sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factor...
Definition: RPDDataAnalyzer.h:121
RPDDataAnalyzer::calculateSumAdc
void calculateSumAdc(unsigned int channel)
Calculate sum ADC and if there is pileup, calculate fractional pileup.
Definition: RPDDataAnalyzer.cxx:381
RPDDataAnalyzer::calculateBaselineSamplesMSE
float calculateBaselineSamplesMSE(unsigned int channel, std::function< float(unsigned int)> const &fit) const
Calculate the mean squared error of the fit function in the baseline samples.
Definition: RPDDataAnalyzer.cxx:182
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupMSE
std::vector< float > m_ch2ndOrderStretchedExpPileupMSE
mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did ...
Definition: RPDDataAnalyzer.h:133
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
zeroPileupFunc
const auto zeroPileupFunc
Definition: RPDDataAnalyzer.cxx:9
RPDDataAnalyzer::m_chPileupFuncType
std::vector< bool > m_chPileupFuncType
parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail); ...
Definition: RPDDataAnalyzer.h:129
RPDDataAnalyzer::m_goodPulseSampleStart
unsigned int m_goodPulseSampleStart
If there is a good pulse and post-pulse and size of post-pulse as a fraction of good pulse is less th...
Definition: RPDDataAnalyzer.h:107
RPDDataAnalyzer::m_goodPulseSampleStop
unsigned int m_goodPulseSampleStop
Pulses before this sample are considered pre-pulses.
Definition: RPDDataAnalyzer.h:108
RPDDataAnalyzer::setSideStatusBits
void setSideStatusBits()
Set side status bits according to channel status bits.
Definition: RPDDataAnalyzer.cxx:425
RPDDataAnalyzer::ValidBit
@ ValidBit
Definition: RPDDataAnalyzer.h:39
RPDDataAnalyzer::doPileupStretchedExpFit
bool doPileupStretchedExpFit(unsigned int channel, std::vector< std::pair< unsigned int, float >> const &pileupFitPoints)
Perform a stretched exponential fit in baseline-subtracted baseline samples and set relevant status b...
Definition: RPDDataAnalyzer.cxx:227
RPDDataAnalyzer::m_nChannelsLoaded
unsigned int m_nChannelsLoaded
Definition: RPDDataAnalyzer.h:101
RPDDataAnalyzer::checkOverflow
bool checkOverflow(unsigned int channel)
Check for overflow and set relevant status bit.
Definition: RPDDataAnalyzer.cxx:123
RPDDataAnalyzer::PileupExpGrowthBit
@ PileupExpGrowthBit
Definition: RPDDataAnalyzer.h:51
RPDDataAnalyzer::PileupExpFitFailBit
@ PileupExpFitFailBit
Definition: RPDDataAnalyzer.h:50
RPDDataAnalyzer::PileupStretchedExpFitFailBit
@ PileupStretchedExpFitFailBit
Definition: RPDDataAnalyzer.h:47
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
zeroVectorVector
const auto zeroVectorVector
Definition: RPDDataAnalyzer.cxx:8
RPDDataAnalyzer::m_endSignalSample
unsigned int m_endSignalSample
Number of baseline samples; the sample equal to this number is the start of signal region.
Definition: RPDDataAnalyzer.h:104
RPDDataAnalyzer::m_nChannels
unsigned int m_nChannels
Definition: RPDDataAnalyzer.h:100
RPDDataAnalyzer::m_chPileupExpFitParamErrs
std::vector< std::vector< float > > m_chPileupExpFitParamErrs
parameters for pileup stretched exponential fit (if pileup was detected and fit did not fail): exp( [...
Definition: RPDDataAnalyzer.h:127
RPDDataAnalyzer::m_postPulseFracThresh
float m_postPulseFracThresh
Second differences less than or equal to this number indicate a pulse.
Definition: RPDDataAnalyzer.h:106
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupFuncs
std::vector< std::function< float(unsigned int)> > m_ch2ndOrderStretchedExpPileupFuncs
pileup exponential fit function (if pileup was detected and fit did not fail); per channel
Definition: RPDDataAnalyzer.h:131
RPDDataAnalyzer::m_nSamples
unsigned int m_nSamples
Definition: RPDDataAnalyzer.h:102
RPDDataAnalyzer::m_pulse2ndDerivThresh
float m_pulse2ndDerivThresh
Samples before (not including) this sample are the signal region; nSamples goes to end of window.
Definition: RPDDataAnalyzer.h:105
RPDDataAnalyzer::m_chStatus
std::vector< std::bitset< 32 > > m_chStatus
mean squared error of pileup stretched exponential fit in baseline samples (if pileup was detected an...
Definition: RPDDataAnalyzer.h:134
RPDDataAnalyzer::doBaselinePileupSubtraction
bool doBaselinePileupSubtraction(unsigned int channel)
Determine if there is pileup, subtract baseline and pileup, and set relevant status bits.
Definition: RPDDataAnalyzer.cxx:277
y
#define y
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
RPDDataAnalyzer::m_pileupBaselineStdDevThresh
float m_pileupBaselineStdDevThresh
Baseline sums less than this number indicate there is not pileup.
Definition: RPDDataAnalyzer.h:111
DiTauMassTools::HistInfoV2::RMS
@ RMS
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:31
RPDDataAnalyzer::m_chMaxSample
std::vector< float > m_chMaxSample
RPD data with baseline and pileup subtracted; index channel then sample.
Definition: RPDDataAnalyzer.h:118
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
zeroVector
const auto zeroVector
Definition: RPDDataAnalyzer.cxx:7
RPDDataAnalyzer::PileupBadExpSubtrBit
@ PileupBadExpSubtrBit
Definition: RPDDataAnalyzer.h:52
RPDDataAnalyzer::m_nominalBaseline
unsigned int m_nominalBaseline
Pulses after this sample are considered post-pulses.
Definition: RPDDataAnalyzer.h:109
RPDDataAnalyzer::m_chFadcData
std::vector< std::vector< float > > m_chFadcData
multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel
Definition: RPDDataAnalyzer.h:116
RPDDataAnalyzer::s_minPileupFitPoints
static unsigned constexpr int s_minPileupFitPoints
status bits for side
Definition: RPDDataAnalyzer.h:143
RPDDataAnalyzer::m_tag
std::string m_tag
Definition: RPDDataAnalyzer.h:97
RPDDataAnalyzer::m_nBaselineSamples
unsigned int m_nBaselineSamples
Definition: RPDDataAnalyzer.h:103
ZDCMsg::Debug
@ Debug
Definition: ZDCMsg.h:19
RPDDataAnalyzer::m_msgFunc_p
ZDCMsg::MessageFunctionPtr m_msgFunc_p
Definition: RPDDataAnalyzer.h:96
ZDCMsg::Fatal
@ Fatal
Definition: ZDCMsg.h:23
merge.status
status
Definition: merge.py:17
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
RPDDataAnalyzer::checkPulses
bool checkPulses(unsigned int channel)
Calculate 2nd difference, identify pulses, and set relevant status bits.
Definition: RPDDataAnalyzer.cxx:139
RPDDataAnalyzer::doPileupExpFit
bool doPileupExpFit(unsigned int channel, std::vector< std::pair< unsigned int, float >> const &pileupFitPoints)
Perform an exponential fit in baseline-subtracted baseline samples and set relevant status bits.
Definition: RPDDataAnalyzer.cxx:196
RPDDataAnalyzer::OutOfTimePileupBit
@ OutOfTimePileupBit
Definition: RPDDataAnalyzer.h:40
RPDDataAnalyzer::OverflowBit
@ OverflowBit
Definition: RPDDataAnalyzer.h:41
readCCLHist.float
float
Definition: readCCLHist.py:83
RPDDataAnalyzer::m_chExpPileupFuncs
std::vector< std::function< float(unsigned int)> > m_chExpPileupFuncs
true when stretched exponential is used, false if exponential is used for pileup subtraction (if pile...
Definition: RPDDataAnalyzer.h:130
RPDDataAnalyzer::PostPulseBit
@ PostPulseBit
Definition: RPDDataAnalyzer.h:43
LArMonTransforms.Mean
def Mean(inputs)
Definition: LArMonTransforms.py:438
RPDDataAnalyzer::PileupBadStretchedExpSubtrBit
@ PileupBadStretchedExpSubtrBit
Definition: RPDDataAnalyzer.h:49