![]() |
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, 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 | |
RPDDataAnalyzer & | operator= (RPDDataAnalyzer const &)=delete |
RPDDataAnalyzer (RPDDataAnalyzer &&)=delete | |
RPDDataAnalyzer & | operator= (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_nChannels > | m_outputCalibFactors {} |
ADC values greater than or equal to this number are considered overflow. More... | |
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 More... | |
std::array< std::vector< float >, s_nChannels > | m_chCorrectedFadcData |
raw RPD data; index channel then sample More... | |
std::array< unsigned int, s_nChannels > | m_chMaxSample {} |
RPD data with baseline and pileup subtracted; index channel then sample. More... | |
std::array< float, s_nChannels > | m_chSumAdc {} |
sample of max of RPD data in signal range after pileup subtraction; per channel More... | |
std::array< float, s_nChannels > | m_chSumAdcCalib {} |
sum of RPD data in signal range after baseline and pileup subtraction; per channel More... | |
std::array< float, s_nChannels > | m_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_nChannels > | m_chMaxAdcCalib {} |
max of RPD data in signal range after baseline and pileup subtraction; per channel More... | |
std::array< float, s_nChannels > | m_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_nChannels > | 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::array< std::vector< float >, s_nChannels > | m_chPileupExpFitParams |
baseline used in baseline subtraction; per channel More... | |
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]*sample ); per channel More... | |
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( [0] + [1]*(sample + 4)**(0.5) + [2]*(sample + 4)**(-0.5) ); per channel More... | |
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 channel More... | |
std::array< PileupFitFuncType, s_nChannels > | m_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_nChannels > | m_chExpPileupFuncs |
enum indicating type of pileup fit function; per channel More... | |
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 More... | |
std::array< float, s_nChannels > | m_chExpPileupMSE {} |
pileup stretched exponential fit function (if pileup was detected and fit did not fail); per channel More... | |
std::array< float, s_nChannels > | 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::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 and fit did not fail); per channel More... | |
std::bitset< N_STATUS_BITS > | m_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... | |
Definition at line 34 of file RPDDataAnalyzer.h.
anonymous enum |
Definition at line 36 of file RPDDataAnalyzer.h.
|
strong |
Enumerator | |
---|---|
None | |
Exp | |
SecondOrderStretchedExp |
Definition at line 54 of file RPDDataAnalyzer.h.
ZDC::RPDDataAnalyzer::RPDDataAnalyzer | ( | ZDCMsg::MessageFunctionPtr | messageFunc_p, |
std::string | tag, | ||
RPDConfig const & | config, | ||
std::vector< float > const & | calibFactors | ||
) |
Definition at line 21 of file RPDDataAnalyzer.cxx.
|
virtualdefault |
|
delete |
|
delete |
void ZDC::RPDDataAnalyzer::analyzeData | ( | ) |
Analyze RPD data.
Definition at line 458 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 386 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 268 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 281 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 ZDC::RPDDataAnalyzer::getChBaseline | ( | unsigned int | channel | ) | const |
Get baseline used in baseline subtraction.
Definition at line 541 of file RPDDataAnalyzer.cxx.
float ZDC::RPDDataAnalyzer::getChMaxAdc | ( | unsigned int | channel | ) | const |
Get max of RPD data in signal range after baseline and pileup subtraction.
Definition at line 517 of file RPDDataAnalyzer.cxx.
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 525 of file RPDDataAnalyzer.cxx.
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 493 of file RPDDataAnalyzer.cxx.
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 576 of file RPDDataAnalyzer.cxx.
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 562 of file RPDDataAnalyzer.cxx.
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 548 of file RPDDataAnalyzer.cxx.
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 533 of file RPDDataAnalyzer.cxx.
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 583 of file RPDDataAnalyzer.cxx.
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 569 of file RPDDataAnalyzer.cxx.
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 555 of file RPDDataAnalyzer.cxx.
unsigned int ZDC::RPDDataAnalyzer::getChStatus | ( | unsigned int | channel | ) | const |
Get status word for channel.
Definition at line 590 of file RPDDataAnalyzer.cxx.
float ZDC::RPDDataAnalyzer::getChSumAdc | ( | unsigned int | channel | ) | const |
Get sum of RPD data in signal range after baseline and pileup subtraction.
Definition at line 501 of file RPDDataAnalyzer.cxx.
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 509 of file RPDDataAnalyzer.cxx.
unsigned int ZDC::RPDDataAnalyzer::getSideStatus | ( | ) | const |
Get status word for side.
Definition at line 598 of file RPDDataAnalyzer.cxx.
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 70 of file RPDDataAnalyzer.cxx.
|
delete |
|
delete |
void ZDC::RPDDataAnalyzer::reset | ( | ) |
|
private |
Set side status bits according to channel status bits.
Definition at line 433 of file RPDDataAnalyzer.cxx.
|
private |
Maximum number of negative ADC values after baseline and pileup subtraction allowed in signal range.
Definition at line 119 of file RPDDataAnalyzer.h.
|
private |
pileup exponential fit function (if pileup was detected and fit did not fail); per channel
Definition at line 137 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 139 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 130 of file RPDDataAnalyzer.h.
|
private |
raw RPD data; index channel then sample
Definition at line 123 of file RPDDataAnalyzer.h.
|
private |
enum indicating type of pileup fit function; per channel
Definition at line 136 of file RPDDataAnalyzer.h.
|
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.
|
private |
multiplicative calibration factors to apply to output, e.g., max and sum ADC; per channel
Definition at line 122 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 127 of file RPDDataAnalyzer.h.
|
private |
max of RPD data in signal range after baseline and pileup subtraction; per channel
Definition at line 128 of file RPDDataAnalyzer.h.
|
private |
RPD data with baseline and pileup subtracted; index channel then sample.
Definition at line 124 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 133 of file RPDDataAnalyzer.h.
|
private |
baseline used in baseline subtraction; per channel
Definition at line 131 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 129 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 135 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 134 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 132 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 140 of file RPDDataAnalyzer.h.
|
private |
sample of max of RPD data in signal range after pileup subtraction; per channel
Definition at line 125 of file RPDDataAnalyzer.h.
|
private |
sum of RPD data in signal range after baseline and pileup subtraction; per channel
Definition at line 126 of file RPDDataAnalyzer.h.
|
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.
|
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.
|
private |
Pulses before this sample are considered pre-pulses.
Definition at line 114 of file RPDDataAnalyzer.h.
|
private |
Definition at line 102 of file RPDDataAnalyzer.h.
|
private |
Definition at line 109 of file RPDDataAnalyzer.h.
|
private |
Definition at line 107 of file RPDDataAnalyzer.h.
|
private |
Baseline standard deviations less than this number indicate there is not pileup.
Definition at line 118 of file RPDDataAnalyzer.h.
|
private |
Pulses after this sample are considered post-pulses.
Definition at line 115 of file RPDDataAnalyzer.h.
|
private |
Definition at line 108 of file RPDDataAnalyzer.h.
|
private |
ADC values greater than or equal to this number are considered overflow.
Definition at line 120 of file RPDDataAnalyzer.h.
|
private |
Baseline sums less than this number indicate there is not pileup.
Definition at line 117 of file RPDDataAnalyzer.h.
|
private |
The global nominal baseline; used when pileup is detected.
Definition at line 116 of file RPDDataAnalyzer.h.
|
private |
Second differences less than or equal to this number indicate a pulse.
Definition at line 112 of file RPDDataAnalyzer.h.
|
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.
|
private |
status bits per channel
Definition at line 141 of file RPDDataAnalyzer.h.
|
private |
Definition at line 103 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 149 of file RPDDataAnalyzer.h.
|
staticconstexprprivate |
Definition at line 105 of file RPDDataAnalyzer.h.