![]() |
ATLAS Offline Software
|
#include <RPDDataAnalyzer.h>
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... | |
Definition at line 35 of file RPDDataAnalyzer.h.
anonymous enum |
Definition at line 38 of file RPDDataAnalyzer.h.
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.
|
virtualdefault |
void RPDDataAnalyzer::analyzeData | ( | ) |
Analyze RPD data.
Definition at line 450 of file RPDDataAnalyzer.cxx.
|
private |
Calculate the mean squared error of the fit function in the baseline samples.
Definition at line 182 of file RPDDataAnalyzer.cxx.
|
private |
|
private |
Calculate sum ADC and if there is pileup, calculate fractional pileup.
Definition at line 381 of file RPDDataAnalyzer.cxx.
|
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.
|
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.
|
private |
Calculate the number of negative values in signal range.
Definition at line 264 of file RPDDataAnalyzer.cxx.
|
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.
|
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.
|
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.
float RPDDataAnalyzer::getChBaseline | ( | unsigned int | channel | ) | const |
Get baseline used in baseline subtraction.
Definition at line 533 of file RPDDataAnalyzer.cxx.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
unsigned int RPDDataAnalyzer::getChStatus | ( | unsigned int | channel | ) | const |
Get status word for channel.
Definition at line 582 of file RPDDataAnalyzer.cxx.
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.
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.
unsigned int RPDDataAnalyzer::getSideStatus | ( | ) | const |
Get status word for side.
Definition at line 590 of file RPDDataAnalyzer.cxx.
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.
void RPDDataAnalyzer::reset | ( | ) |
|
private |
Set side status bits according to channel status bits.
Definition at line 425 of file RPDDataAnalyzer.cxx.
|
private |
Maximum number of negative ADC values after baseline and pileup subtraction allowed in signal range.
Definition at line 113 of file RPDDataAnalyzer.h.
|
private |
pileup exponential fit function (if pileup was detected and fit did not fail); per channel
Definition at line 131 of file RPDDataAnalyzer.h.
|
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.
|
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.
|
private |
raw RPD data; index channel then sample
Definition at line 117 of file RPDDataAnalyzer.h.
|
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.
|
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.
|
private |
multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel
Definition at line 116 of file RPDDataAnalyzer.h.
|
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.
|
private |
max of RPD data in signal range after baseline and pileup subtraction; per channel
Definition at line 122 of file RPDDataAnalyzer.h.
|
private |
RPD data with baseline and pileup subtracted; index channel then sample.
Definition at line 118 of file RPDDataAnalyzer.h.
|
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.
|
private |
baseline used in baseline subtraction; per channel
Definition at line 125 of file RPDDataAnalyzer.h.
|
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.
|
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.
|
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.
|
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.
|
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.
|
private |
sample of max of RPD data in signal range after pileup subtraction; per channel
Definition at line 119 of file RPDDataAnalyzer.h.
|
private |
sum of RPD data in signal range after baseline and pileup subtraction; per channel
Definition at line 120 of file RPDDataAnalyzer.h.
|
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.
|
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.
|
private |
Pulses before this sample are considered pre-pulses.
Definition at line 108 of file RPDDataAnalyzer.h.
|
private |
Definition at line 96 of file RPDDataAnalyzer.h.
|
private |
Definition at line 103 of file RPDDataAnalyzer.h.
|
private |
Definition at line 100 of file RPDDataAnalyzer.h.
|
private |
Definition at line 101 of file RPDDataAnalyzer.h.
|
private |
Definition at line 99 of file RPDDataAnalyzer.h.
|
private |
Baseline standard deviations less than this number indicate there is not pileup.
Definition at line 112 of file RPDDataAnalyzer.h.
|
private |
Pulses after this sample are considered post-pulses.
Definition at line 109 of file RPDDataAnalyzer.h.
|
private |
Definition at line 98 of file RPDDataAnalyzer.h.
|
private |
Definition at line 102 of file RPDDataAnalyzer.h.
|
private |
ADC values greater than or equal to this number are considered overflow.
Definition at line 114 of file RPDDataAnalyzer.h.
|
private |
Baseline sums less than this number indicate there is not pileup.
Definition at line 111 of file RPDDataAnalyzer.h.
|
private |
The global nominal baseline; used when pileup is detected.
Definition at line 110 of file RPDDataAnalyzer.h.
|
private |
Second differences less than or equal to this number indicate a pulse.
Definition at line 106 of file RPDDataAnalyzer.h.
|
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.
|
private |
status bits per channel
Definition at line 135 of file RPDDataAnalyzer.h.
|
private |
Definition at line 97 of file RPDDataAnalyzer.h.
|
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.