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

#include <RPDDataAnalyzer.h>

Collaboration diagram for ZDC::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, N_STATUS_BITS
}
 
enum  PileupFitFuncType { PileupFitFuncType::None, PileupFitFuncType::Exp, PileupFitFuncType::SecondOrderStretchedExp }
 

Public Member Functions

 RPDDataAnalyzer (ZDCMsg::MessageFunctionPtr messageFunc_p, std::string tag, RPDConfig const &config, std::vector< float > const &calibFactors)
 
virtual ~RPDDataAnalyzer ()=default
 
 RPDDataAnalyzer (RPDDataAnalyzer const &)=delete
 
RPDDataAnalyzeroperator= (RPDDataAnalyzer const &)=delete
 
 RPDDataAnalyzer (RPDDataAnalyzer &&)=delete
 
RPDDataAnalyzeroperator= (RPDDataAnalyzer &&)=delete
 
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_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...
 
float 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::array< float, s_nChannelsm_outputCalibFactors {}
 ADC values greater than or equal to this number are considered overflow. More...
 
std::array< std::vector< uint16_t >, s_nChannelsm_chFADCData
 multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel More...
 
std::array< std::vector< float >, s_nChannelsm_chCorrectedFadcData
 raw RPD data; index channel then sample More...
 
std::array< unsigned int, s_nChannelsm_chMaxSample {}
 RPD data with baseline and pileup subtracted; index channel then sample. More...
 
std::array< float, s_nChannelsm_chSumAdc {}
 sample of max of RPD data in signal range after pileup subtraction; per channel More...
 
std::array< float, s_nChannelsm_chSumAdcCalib {}
 sum of RPD data in signal range after baseline and pileup subtraction; per channel More...
 
std::array< float, s_nChannelsm_chMaxAdc {}
 sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied; per channel More...
 
std::array< float, s_nChannelsm_chMaxAdcCalib {}
 max of RPD data in signal range after baseline and pileup subtraction; per channel More...
 
std::array< float, s_nChannelsm_chPileupFrac {}
 max of RPD data in signal range after baseline and pileup subtraction, with output calibration factors applied; per channel More...
 
std::array< float, s_nChannelsm_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::array< std::vector< float >, s_nChannelsm_chPileupExpFitParams
 baseline used in baseline subtraction; per channel More...
 
std::array< std::vector< float >, s_nChannelsm_chPileupStretchedExpFitParams
 parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*sample ); per channel More...
 
std::array< std::vector< float >, s_nChannelsm_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::array< std::vector< float >, s_nChannelsm_chPileupStretchedExpFitParamErrs
 parameter errors for pileup exponential fit (if pileup was detected and fit did not fail); per channel More...
 
std::array< PileupFitFuncType, s_nChannelsm_chPileupFuncType {}
 parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail); per channel More...
 
std::array< std::function< float(unsigned int)>, s_nChannelsm_chExpPileupFuncs
 enum indicating type of pileup fit function; per channel More...
 
std::array< std::function< float(unsigned int)>, s_nChannelsm_ch2ndOrderStretchedExpPileupFuncs
 pileup exponential fit function (if pileup was detected and fit did not fail); per channel More...
 
std::array< float, s_nChannelsm_chExpPileupMSE {}
 pileup stretched exponential fit function (if pileup was detected and fit did not fail); per channel More...
 
std::array< float, s_nChannelsm_ch2ndOrderStretchedExpPileupMSE {}
 mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did not fail); per channel More...
 
std::array< std::bitset< N_STATUS_BITS >, s_nChannelsm_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< N_STATUS_BITSm_sideStatus
 status bits per channel More...
 

Static Private Attributes

static unsigned constexpr int s_nChannels = RPDUtils::nChannels
 
static unsigned constexpr int s_minPileupFitPoints = 3
 status bits for side More...
 

Detailed Description

Definition at line 34 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 
N_STATUS_BITS 

Definition at line 36 of file RPDDataAnalyzer.h.

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

◆ PileupFitFuncType

Enumerator
None 
Exp 
SecondOrderStretchedExp 

Definition at line 54 of file RPDDataAnalyzer.h.

54  {
55  None, Exp, SecondOrderStretchedExp
56  };

Constructor & Destructor Documentation

◆ RPDDataAnalyzer() [1/3]

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

Definition at line 22 of file RPDDataAnalyzer.cxx.

27  : m_msgFunc_p(std::move(messageFunc_p)),
28  m_tag(std::move(tag)),
29  m_nSamples(config.nSamples),
30  m_nBaselineSamples(config.nBaselineSamples),
31  m_endSignalSample(config.endSignalSample),
32  m_pulse2ndDerivThresh(config.pulse2ndDerivThresh),
33  m_postPulseFracThresh(config.postPulseFracThresh),
34  m_goodPulseSampleStart(config.goodPulseSampleStart),
35  m_goodPulseSampleStop(config.goodPulseSampleStop),
36  m_nominalBaseline(config.nominalBaseline),
37  m_pileupBaselineSumThresh(config.pileupBaselineSumThresh),
38  m_pileupBaselineStdDevThresh(config.pileupBaselineStdDevThresh),
39  m_nNegativesAllowed(config.nNegativesAllowed),
40  m_AdcOverflow(config.ADCOverflow)
41 {
42  if (m_endSignalSample == 0) m_endSignalSample = m_nSamples; // sentinel value 0 -> go to end of waveform
43  if (m_outputCalibFactors.size() != s_nChannels) {
44  (*m_msgFunc_p)(ZDCMsg::Fatal,
45  "RPDDataAnalyzer::RPDDataAnalyzer: received incorrect number of channels in calibration factors ("
47  );
48  }
49  std::copy(calibFactors.begin(), calibFactors.end(), m_outputCalibFactors.data());
50  m_chFADCData.fill(std::vector<uint16_t>(m_nSamples, 0));
51  m_chCorrectedFadcData.fill(std::vector<float>(m_nSamples, 0));
52  m_chPileupExpFitParams.fill(std::vector<float>(2, 0));
53  m_chPileupStretchedExpFitParams.fill(std::vector<float>(3, 0));
54  m_chPileupExpFitParamErrs.fill(std::vector<float>(2, 0));
55  m_chPileupStretchedExpFitParamErrs.fill(std::vector<float>(3, 0));
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 ZDC::RPDDataAnalyzer::~RPDDataAnalyzer ( )
virtualdefault

◆ RPDDataAnalyzer() [2/3]

ZDC::RPDDataAnalyzer::RPDDataAnalyzer ( RPDDataAnalyzer const )
delete

◆ RPDDataAnalyzer() [3/3]

ZDC::RPDDataAnalyzer::RPDDataAnalyzer ( RPDDataAnalyzer &&  )
delete

Member Function Documentation

◆ analyzeData()

void ZDC::RPDDataAnalyzer::analyzeData ( )

Analyze RPD data.

Definition at line 459 of file RPDDataAnalyzer.cxx.

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

◆ calculateBaselineSamplesMSE()

float ZDC::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 183 of file RPDDataAnalyzer.cxx.

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

◆ calculateMaxSampleMaxAdc()

void ZDC::RPDDataAnalyzer::calculateMaxSampleMaxAdc ( unsigned int  channel)
private

Calculate max ADC and max sample.

Definition at line 362 of file RPDDataAnalyzer.cxx.

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

◆ calculateSumAdc()

void ZDC::RPDDataAnalyzer::calculateSumAdc ( unsigned int  channel)
private

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

Definition at line 387 of file RPDDataAnalyzer.cxx.

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

◆ checkOverflow()

bool ZDC::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 124 of file RPDDataAnalyzer.cxx.

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

◆ checkPulses()

bool ZDC::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 140 of file RPDDataAnalyzer.cxx.

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

◆ countSignalRangeNegatives()

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

Calculate the number of negative values in signal range.

Definition at line 269 of file RPDDataAnalyzer.cxx.

270 {
271  unsigned int nNegatives = 0;
272  for (unsigned int sample = m_nBaselineSamples; sample < m_endSignalSample; sample++) {
273  if (values.at(sample) < 0) nNegatives++;
274  }
275  return nNegatives;
276 }

◆ doBaselinePileupSubtraction()

bool ZDC::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 282 of file RPDDataAnalyzer.cxx.

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

◆ doPileupExpFit()

bool ZDC::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 197 of file RPDDataAnalyzer.cxx.

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

◆ doPileupStretchedExpFit()

bool ZDC::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 228 of file RPDDataAnalyzer.cxx.

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

◆ getChBaseline()

float ZDC::RPDDataAnalyzer::getChBaseline ( unsigned int  channel) const

Get baseline used in baseline subtraction.

Definition at line 542 of file RPDDataAnalyzer.cxx.

542  {
543  return m_chBaseline.at(channel);
544 }

◆ getChMaxAdc()

float ZDC::RPDDataAnalyzer::getChMaxAdc ( unsigned int  channel) const

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

Definition at line 518 of file RPDDataAnalyzer.cxx.

519 {
520  return m_chMaxAdc.at(channel);
521 }

◆ getChMaxAdcCalib()

float ZDC::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 526 of file RPDDataAnalyzer.cxx.

527 {
528  return m_chMaxAdcCalib.at(channel);
529 }

◆ getChMaxSample()

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

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

Definition at line 494 of file RPDDataAnalyzer.cxx.

495 {
496  return m_chMaxSample.at(channel);
497 }

◆ getChPileupExpFitMSE()

float ZDC::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 577 of file RPDDataAnalyzer.cxx.

577  {
578  return m_chExpPileupMSE.at(channel);
579 }

◆ getChPileupExpFitParamErrs()

const std::vector< float > & ZDC::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 563 of file RPDDataAnalyzer.cxx.

563  {
565 }

◆ getChPileupExpFitParams()

const std::vector< float > & ZDC::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 549 of file RPDDataAnalyzer.cxx.

549  {
550  return m_chPileupExpFitParams.at(channel);
551 }

◆ getChPileupFrac()

float ZDC::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 534 of file RPDDataAnalyzer.cxx.

535 {
536  return m_chPileupFrac.at(channel);
537 }

◆ getChPileupStretchedExpFitMSE()

float ZDC::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 584 of file RPDDataAnalyzer.cxx.

584  {
586 }

◆ getChPileupStretchedExpFitParamErrs()

const std::vector< float > & ZDC::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 570 of file RPDDataAnalyzer.cxx.

570  {
572 }

◆ getChPileupStretchedExpFitParams()

const std::vector< float > & ZDC::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 556 of file RPDDataAnalyzer.cxx.

556  {
558 }

◆ getChStatus()

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

Get status word for channel.

Definition at line 591 of file RPDDataAnalyzer.cxx.

592 {
593  return static_cast<unsigned int>(m_chStatus.at(channel).to_ulong());
594 }

◆ getChSumAdc()

float ZDC::RPDDataAnalyzer::getChSumAdc ( unsigned int  channel) const

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

Definition at line 502 of file RPDDataAnalyzer.cxx.

503 {
504  return m_chSumAdc.at(channel);
505 }

◆ getChSumAdcCalib()

float ZDC::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 510 of file RPDDataAnalyzer.cxx.

511 {
512  return m_chSumAdcCalib.at(channel);
513 }

◆ getSideStatus()

unsigned int ZDC::RPDDataAnalyzer::getSideStatus ( ) const

Get status word for side.

Definition at line 599 of file RPDDataAnalyzer.cxx.

600 {
601  return static_cast<unsigned int>(m_sideStatus.to_ulong());
602 }

◆ loadChannelData()

void ZDC::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,
75  "RPDDataAnalyzer::loadChannelData: received incorrect number of samples "
76  "in FADC data (" + std::to_string(FadcData.size()) + ", expected " + std::to_string(m_nSamples) + ")"
77  );
78  }
79  m_chFADCData.at(channel) = FadcData;
81 }

◆ operator=() [1/2]

RPDDataAnalyzer& ZDC::RPDDataAnalyzer::operator= ( RPDDataAnalyzer &&  )
delete

◆ operator=() [2/2]

RPDDataAnalyzer& ZDC::RPDDataAnalyzer::operator= ( RPDDataAnalyzer const )
delete

◆ reset()

void ZDC::RPDDataAnalyzer::reset ( )

◆ setSideStatusBits()

void ZDC::RPDDataAnalyzer::setSideStatusBits ( )
private

Set side status bits according to channel status bits.

Definition at line 434 of file RPDDataAnalyzer.cxx.

435 {
436  for (unsigned int channel = 0; channel < s_nChannels; channel++) {
437  if (!m_chStatus.at(channel)[ValidBit]) m_sideStatus.set(ValidBit, false);
438 
443  if (m_chStatus.at(channel)[NoPulseBit]) m_sideStatus.set(NoPulseBit, true);
453  }
454 }

Member Data Documentation

◆ m_AdcOverflow

unsigned int ZDC::RPDDataAnalyzer::m_AdcOverflow
private

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

Definition at line 119 of file RPDDataAnalyzer.h.

◆ m_ch2ndOrderStretchedExpPileupFuncs

std::array<std::function<float(unsigned int)>, s_nChannels> ZDC::RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupFuncs
private

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

Definition at line 137 of file RPDDataAnalyzer.h.

◆ m_ch2ndOrderStretchedExpPileupMSE

std::array<float, s_nChannels> ZDC::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 139 of file RPDDataAnalyzer.h.

◆ m_chBaseline

std::array<float, s_nChannels> ZDC::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 130 of file RPDDataAnalyzer.h.

◆ m_chCorrectedFadcData

std::array<std::vector<float>, s_nChannels> ZDC::RPDDataAnalyzer::m_chCorrectedFadcData
private

raw RPD data; index channel then sample

Definition at line 123 of file RPDDataAnalyzer.h.

◆ m_chExpPileupFuncs

std::array<std::function<float(unsigned int)>, s_nChannels> ZDC::RPDDataAnalyzer::m_chExpPileupFuncs
private

enum indicating type of pileup fit function; per channel

Definition at line 136 of file RPDDataAnalyzer.h.

◆ m_chExpPileupMSE

std::array<float, s_nChannels> ZDC::RPDDataAnalyzer::m_chExpPileupMSE {}
private

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

Definition at line 138 of file RPDDataAnalyzer.h.

◆ m_chFADCData

std::array<std::vector<uint16_t>, s_nChannels> ZDC::RPDDataAnalyzer::m_chFADCData
private

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

Definition at line 122 of file RPDDataAnalyzer.h.

◆ m_chMaxAdc

std::array<float, s_nChannels> ZDC::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 127 of file RPDDataAnalyzer.h.

◆ m_chMaxAdcCalib

std::array<float, s_nChannels> ZDC::RPDDataAnalyzer::m_chMaxAdcCalib {}
private

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

Definition at line 128 of file RPDDataAnalyzer.h.

◆ m_chMaxSample

std::array<unsigned int, s_nChannels> ZDC::RPDDataAnalyzer::m_chMaxSample {}
private

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

Definition at line 124 of file RPDDataAnalyzer.h.

◆ m_chPileupExpFitParamErrs

std::array<std::vector<float>, s_nChannels> ZDC::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 133 of file RPDDataAnalyzer.h.

◆ m_chPileupExpFitParams

std::array<std::vector<float>, s_nChannels> ZDC::RPDDataAnalyzer::m_chPileupExpFitParams
private

baseline used in baseline subtraction; per channel

Definition at line 131 of file RPDDataAnalyzer.h.

◆ m_chPileupFrac

std::array<float, s_nChannels> ZDC::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 129 of file RPDDataAnalyzer.h.

◆ m_chPileupFuncType

std::array<PileupFitFuncType, s_nChannels> ZDC::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 135 of file RPDDataAnalyzer.h.

◆ m_chPileupStretchedExpFitParamErrs

std::array<std::vector<float>, s_nChannels> ZDC::RPDDataAnalyzer::m_chPileupStretchedExpFitParamErrs
private

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

Definition at line 134 of file RPDDataAnalyzer.h.

◆ m_chPileupStretchedExpFitParams

std::array<std::vector<float>, s_nChannels> ZDC::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 132 of file RPDDataAnalyzer.h.

◆ m_chStatus

std::array<std::bitset<N_STATUS_BITS>, s_nChannels> ZDC::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 140 of file RPDDataAnalyzer.h.

◆ m_chSumAdc

std::array<float, s_nChannels> ZDC::RPDDataAnalyzer::m_chSumAdc {}
private

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

Definition at line 125 of file RPDDataAnalyzer.h.

◆ m_chSumAdcCalib

std::array<float, s_nChannels> ZDC::RPDDataAnalyzer::m_chSumAdcCalib {}
private

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

Definition at line 126 of file RPDDataAnalyzer.h.

◆ m_endSignalSample

unsigned int ZDC::RPDDataAnalyzer::m_endSignalSample
private

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

Definition at line 110 of file RPDDataAnalyzer.h.

◆ m_goodPulseSampleStart

unsigned int ZDC::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 113 of file RPDDataAnalyzer.h.

◆ m_goodPulseSampleStop

unsigned int ZDC::RPDDataAnalyzer::m_goodPulseSampleStop
private

Pulses before this sample are considered pre-pulses.

Definition at line 114 of file RPDDataAnalyzer.h.

◆ m_msgFunc_p

ZDCMsg::MessageFunctionPtr ZDC::RPDDataAnalyzer::m_msgFunc_p
private

Definition at line 102 of file RPDDataAnalyzer.h.

◆ m_nBaselineSamples

unsigned int ZDC::RPDDataAnalyzer::m_nBaselineSamples
private

Definition at line 109 of file RPDDataAnalyzer.h.

◆ m_nChannelsLoaded

unsigned int ZDC::RPDDataAnalyzer::m_nChannelsLoaded = 0
private

Definition at line 107 of file RPDDataAnalyzer.h.

◆ m_nNegativesAllowed

unsigned int ZDC::RPDDataAnalyzer::m_nNegativesAllowed
private

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

Definition at line 118 of file RPDDataAnalyzer.h.

◆ m_nominalBaseline

float ZDC::RPDDataAnalyzer::m_nominalBaseline
private

Pulses after this sample are considered post-pulses.

Definition at line 115 of file RPDDataAnalyzer.h.

◆ m_nSamples

unsigned int ZDC::RPDDataAnalyzer::m_nSamples
private

Definition at line 108 of file RPDDataAnalyzer.h.

◆ m_outputCalibFactors

std::array<float, s_nChannels> ZDC::RPDDataAnalyzer::m_outputCalibFactors {}
private

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

Definition at line 120 of file RPDDataAnalyzer.h.

◆ m_pileupBaselineStdDevThresh

float ZDC::RPDDataAnalyzer::m_pileupBaselineStdDevThresh
private

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

Definition at line 117 of file RPDDataAnalyzer.h.

◆ m_pileupBaselineSumThresh

float ZDC::RPDDataAnalyzer::m_pileupBaselineSumThresh
private

The global nominal baseline; used when pileup is detected.

Definition at line 116 of file RPDDataAnalyzer.h.

◆ m_postPulseFracThresh

float ZDC::RPDDataAnalyzer::m_postPulseFracThresh
private

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

Definition at line 112 of file RPDDataAnalyzer.h.

◆ m_pulse2ndDerivThresh

float ZDC::RPDDataAnalyzer::m_pulse2ndDerivThresh
private

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

Definition at line 111 of file RPDDataAnalyzer.h.

◆ m_sideStatus

std::bitset<N_STATUS_BITS> ZDC::RPDDataAnalyzer::m_sideStatus
private

status bits per channel

Definition at line 141 of file RPDDataAnalyzer.h.

◆ m_tag

std::string ZDC::RPDDataAnalyzer::m_tag
private

Definition at line 103 of file RPDDataAnalyzer.h.

◆ s_minPileupFitPoints

unsigned constexpr int ZDC::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 149 of file RPDDataAnalyzer.h.

◆ s_nChannels

unsigned constexpr int ZDC::RPDDataAnalyzer::s_nChannels = RPDUtils::nChannels
staticconstexprprivate

Definition at line 105 of file RPDDataAnalyzer.h.


The documentation for this class was generated from the following files:
ZDC::RPDDataAnalyzer::m_nChannelsLoaded
unsigned int m_nChannelsLoaded
Definition: RPDDataAnalyzer.h:107
ZDC::RPDDataAnalyzer::m_nBaselineSamples
unsigned int m_nBaselineSamples
Definition: RPDDataAnalyzer.h:109
ZDC::RPDDataAnalyzer::m_chCorrectedFadcData
std::array< std::vector< float >, s_nChannels > m_chCorrectedFadcData
raw RPD data; index channel then sample
Definition: RPDDataAnalyzer.h:123
ZDC::RPDDataAnalyzer::PileupExpGrowthBit
@ PileupExpGrowthBit
Definition: RPDDataAnalyzer.h:49
ZDC::RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupFuncs
std::array< std::function< float(unsigned int)>, s_nChannels > m_ch2ndOrderStretchedExpPileupFuncs
pileup exponential fit function (if pileup was detected and fit did not fail); per channel
Definition: RPDDataAnalyzer.h:137
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
ZDC::RPDDataAnalyzer::m_nominalBaseline
float m_nominalBaseline
Pulses after this sample are considered post-pulses.
Definition: RPDDataAnalyzer.h:115
python.xAODTrackSummaryFiller.StdDev
string StdDev
Definition: xAODTrackSummaryFiller.py:30
ZDC::nullPileupFunc
float nullPileupFunc(unsigned int)
Definition: RPDDataAnalyzer.cxx:13
ZDCMsg::Warn
@ Warn
Definition: ZDCMsg.h:21
ZDC::RPDDataAnalyzer::m_goodPulseSampleStop
unsigned int m_goodPulseSampleStop
Pulses before this sample are considered pre-pulses.
Definition: RPDDataAnalyzer.h:114
ZDC::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:113
ZDC::RPDDataAnalyzer::PileupBadStretchedExpSubtrBit
@ PileupBadStretchedExpSubtrBit
Definition: RPDDataAnalyzer.h:47
ZDC::RPDDataAnalyzer::doBaselinePileupSubtraction
bool doBaselinePileupSubtraction(unsigned int channel)
Determine if there is pileup, subtract baseline and pileup, and set relevant status bits.
Definition: RPDDataAnalyzer.cxx:282
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
ZDC::RPDDataAnalyzer::OverflowBit
@ OverflowBit
Definition: RPDDataAnalyzer.h:39
ZDC::RPDDataAnalyzer::m_chPileupExpFitParamErrs
std::array< std::vector< float >, s_nChannels > m_chPileupExpFitParamErrs
parameters for pileup stretched exponential fit (if pileup was detected and fit did not fail): exp( [...
Definition: RPDDataAnalyzer.h:133
ZDC::RPDDataAnalyzer::ValidBit
@ ValidBit
Definition: RPDDataAnalyzer.h:37
ZDC::RPDDataAnalyzer::m_chMaxAdcCalib
std::array< float, s_nChannels > m_chMaxAdcCalib
max of RPD data in signal range after baseline and pileup subtraction; per channel
Definition: RPDDataAnalyzer.h:128
ZDC::RPDDataAnalyzer::PrePulseBit
@ PrePulseBit
Definition: RPDDataAnalyzer.h:40
ZDC::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:183
ZDC::RPDDataAnalyzer::checkPulses
bool checkPulses(unsigned int channel)
Calculate 2nd difference, identify pulses, and set relevant status bits.
Definition: RPDDataAnalyzer.cxx:140
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
ZDC::RPDDataAnalyzer::m_nNegativesAllowed
unsigned int m_nNegativesAllowed
Baseline standard deviations less than this number indicate there is not pileup.
Definition: RPDDataAnalyzer.h:118
ZDC::RPDDataAnalyzer::m_chFADCData
std::array< std::vector< uint16_t >, s_nChannels > m_chFADCData
multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel
Definition: RPDDataAnalyzer.h:122
x
#define x
ZDC::RPDDataAnalyzer::calculateMaxSampleMaxAdc
void calculateMaxSampleMaxAdc(unsigned int channel)
Calculate max ADC and max sample.
Definition: RPDDataAnalyzer.cxx:362
ZDC::RPDDataAnalyzer::N_STATUS_BITS
@ N_STATUS_BITS
Definition: RPDDataAnalyzer.h:52
ZDC::RPDDataAnalyzer::m_chPileupStretchedExpFitParams
std::array< std::vector< float >, s_nChannels > m_chPileupStretchedExpFitParams
parameters for pileup exponential fit (if pileup was detected and fit did not fail): exp( [0] + [1]*s...
Definition: RPDDataAnalyzer.h:132
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:808
ZDC::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:119
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
ZDC::RPDDataAnalyzer::m_chPileupExpFitParams
std::array< std::vector< float >, s_nChannels > m_chPileupExpFitParams
baseline used in baseline subtraction; per channel
Definition: RPDDataAnalyzer.h:131
ZDC::RPDDataAnalyzer::NoPulseBit
@ NoPulseBit
Definition: RPDDataAnalyzer.h:42
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
ZDC::RPDDataAnalyzer::m_msgFunc_p
ZDCMsg::MessageFunctionPtr m_msgFunc_p
Definition: RPDDataAnalyzer.h:102
ZDC::RPDDataAnalyzer::m_sideStatus
std::bitset< N_STATUS_BITS > m_sideStatus
status bits per channel
Definition: RPDDataAnalyzer.h:141
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
ZDC::RPDDataAnalyzer::s_minPileupFitPoints
static unsigned constexpr int s_minPileupFitPoints
status bits for side
Definition: RPDDataAnalyzer.h:149
ZDC::RPDDataAnalyzer::m_pileupBaselineSumThresh
float m_pileupBaselineSumThresh
The global nominal baseline; used when pileup is detected.
Definition: RPDDataAnalyzer.h:116
lumiFormat.i
int i
Definition: lumiFormat.py:85
ZDC::RPDDataAnalyzer::PileupFitFuncType::Exp
@ Exp
ZDC::RPDDataAnalyzer::m_chExpPileupFuncs
std::array< std::function< float(unsigned int)>, s_nChannels > m_chExpPileupFuncs
enum indicating type of pileup fit function; per channel
Definition: RPDDataAnalyzer.h:136
ZDC::RPDDataAnalyzer::PostPulseBit
@ PostPulseBit
Definition: RPDDataAnalyzer.h:41
ZDC::RPDDataAnalyzer::m_postPulseFracThresh
float m_postPulseFracThresh
Second differences less than or equal to this number indicate a pulse.
Definition: RPDDataAnalyzer.h:112
ZDC::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:197
ZDC::RPDDataAnalyzer::m_tag
std::string m_tag
Definition: RPDDataAnalyzer.h:103
ZDC::RPDDataAnalyzer::m_ch2ndOrderStretchedExpPileupMSE
std::array< float, s_nChannels > m_ch2ndOrderStretchedExpPileupMSE
mean squared error of pileup exponential fit in baseline samples (if pileup was detected and fit did ...
Definition: RPDDataAnalyzer.h:139
ZDC::RPDDataAnalyzer::m_outputCalibFactors
std::array< float, s_nChannels > m_outputCalibFactors
ADC values greater than or equal to this number are considered overflow.
Definition: RPDDataAnalyzer.h:120
ZDC::RPDDataAnalyzer::m_chPileupFrac
std::array< float, s_nChannels > m_chPileupFrac
max of RPD data in signal range after baseline and pileup subtraction, with output calibration factor...
Definition: RPDDataAnalyzer.h:129
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
ZDC::RPDDataAnalyzer::countSignalRangeNegatives
unsigned int countSignalRangeNegatives(std::vector< float > const &values) const
Calculate the number of negative values in signal range.
Definition: RPDDataAnalyzer.cxx:269
ZDC::RPDDataAnalyzer::setSideStatusBits
void setSideStatusBits()
Set side status bits according to channel status bits.
Definition: RPDDataAnalyzer.cxx:434
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
ZDC::RPDDataAnalyzer::m_chSumAdcCalib
std::array< float, s_nChannels > m_chSumAdcCalib
sum of RPD data in signal range after baseline and pileup subtraction; per channel
Definition: RPDDataAnalyzer.h:126
ZDC::RPDDataAnalyzer::PileupExpFitFailBit
@ PileupExpFitFailBit
Definition: RPDDataAnalyzer.h:48
ZDC::RPDDataAnalyzer::checkOverflow
bool checkOverflow(unsigned int channel)
Check for overflow and set relevant status bit.
Definition: RPDDataAnalyzer.cxx:124
ZDC::RPDDataAnalyzer::BadAvgBaselineSubtrBit
@ BadAvgBaselineSubtrBit
Definition: RPDDataAnalyzer.h:43
ZDC::RPDDataAnalyzer::s_nChannels
static unsigned constexpr int s_nChannels
Definition: RPDDataAnalyzer.h:105
ZDC::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:110
ZDC::RPDDataAnalyzer::m_chExpPileupMSE
std::array< float, s_nChannels > m_chExpPileupMSE
pileup stretched exponential fit function (if pileup was detected and fit did not fail); per channel
Definition: RPDDataAnalyzer.h:138
ZDC::RPDDataAnalyzer::InsufficientPileupFitPointsBit
@ InsufficientPileupFitPointsBit
Definition: RPDDataAnalyzer.h:44
ZDC::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:228
y
#define y
ZDC::RPDDataAnalyzer::calculateSumAdc
void calculateSumAdc(unsigned int channel)
Calculate sum ADC and if there is pileup, calculate fractional pileup.
Definition: RPDDataAnalyzer.cxx:387
ZDC::RPDDataAnalyzer::m_chPileupFuncType
std::array< PileupFitFuncType, s_nChannels > m_chPileupFuncType
parameter errors for pileup stretched exponential fit (if pileup was detected and fit did not fail); ...
Definition: RPDDataAnalyzer.h:135
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
ZDC::RPDDataAnalyzer::PileupBadExpSubtrBit
@ PileupBadExpSubtrBit
Definition: RPDDataAnalyzer.h:50
ZDC::RPDDataAnalyzer::PileupStretchedExpFitFailBit
@ PileupStretchedExpFitFailBit
Definition: RPDDataAnalyzer.h:45
ZDC::RPDDataAnalyzer::m_chSumAdc
std::array< float, s_nChannels > m_chSumAdc
sample of max of RPD data in signal range after pileup subtraction; per channel
Definition: RPDDataAnalyzer.h:125
ZDC::helpResetFuncs
void helpResetFuncs(std::span< std::function< float(unsigned int)>> v)
Definition: RPDDataAnalyzer.cxx:17
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
ZDC::RPDDataAnalyzer::m_chStatus
std::array< std::bitset< N_STATUS_BITS >, s_nChannels > m_chStatus
mean squared error of pileup stretched exponential fit in baseline samples (if pileup was detected an...
Definition: RPDDataAnalyzer.h:140
ZDC::RPDDataAnalyzer::PileupStretchedExpPulseLikeBit
@ PileupStretchedExpPulseLikeBit
Definition: RPDDataAnalyzer.h:51
ZDCMsg::Debug
@ Debug
Definition: ZDCMsg.h:19
ZDCMsg::Fatal
@ Fatal
Definition: ZDCMsg.h:23
ZDC::RPDDataAnalyzer::m_pileupBaselineStdDevThresh
float m_pileupBaselineStdDevThresh
Baseline sums less than this number indicate there is not pileup.
Definition: RPDDataAnalyzer.h:117
merge.status
status
Definition: merge.py:16
ZDC::RPDDataAnalyzer::PileupStretchedExpGrowthBit
@ PileupStretchedExpGrowthBit
Definition: RPDDataAnalyzer.h:46
calibdata.copy
bool copy
Definition: calibdata.py:26
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
ZDC::RPDDataAnalyzer::m_nSamples
unsigned int m_nSamples
Definition: RPDDataAnalyzer.h:108
ZDC::RPDDataAnalyzer::m_chMaxSample
std::array< unsigned int, s_nChannels > m_chMaxSample
RPD data with baseline and pileup subtracted; index channel then sample.
Definition: RPDDataAnalyzer.h:124
ZDC::RPDDataAnalyzer::m_chPileupStretchedExpFitParamErrs
std::array< std::vector< float >, s_nChannels > m_chPileupStretchedExpFitParamErrs
parameter errors for pileup exponential fit (if pileup was detected and fit did not fail); per channe...
Definition: RPDDataAnalyzer.h:134
ZDC::RPDDataAnalyzer::PileupFitFuncType::None
@ None
ZDC::RPDDataAnalyzer::m_chBaseline
std::array< float, s_nChannels > m_chBaseline
OOT pileup sum as a fraction of non-pileup sum in entire window (0 if no OOT pileup,...
Definition: RPDDataAnalyzer.h:130
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
ZDC::RPDDataAnalyzer::OutOfTimePileupBit
@ OutOfTimePileupBit
Definition: RPDDataAnalyzer.h:38
ZDC::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:111
ZDC::RPDDataAnalyzer::m_chMaxAdc
std::array< float, s_nChannels > m_chMaxAdc
sum of RPD data in signal range after baseline and pileup subtraction, with output calibration factor...
Definition: RPDDataAnalyzer.h:127
LArMonTransforms.Mean
def Mean(inputs)
Definition: LArMonTransforms.py:438
RPDUtils::helpZero
void helpZero(Range &v) requires(std
Definition: RPDUtils.h:27
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129
ZDC::RPDDataAnalyzer::PileupFitFuncType::SecondOrderStretchedExp
@ SecondOrderStretchedExp
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65