5#ifndef ZDCANALYSIS_ZDCPulseAnalyzer_h
6#define ZDCANALYSIS_ZDCPulseAnalyzer_h
12#include "TGraphErrors.h"
386 void Reset(
bool reanalyze =
false);
399 bool AnalyzeData(
size_t nSamples,
size_t preSample,
400 const std::vector<float>& samples,
401 const std::vector<bool>& useSamples,
402 float peak2ndDerivMinThresh,
404 const std::vector<float>& toCorrParams,
406 float minT0Corr,
float maxT0Corr
412 static std::vector<float>
Calculate2ndDerivative(
const std::vector <float>& inputData,
unsigned int step);
413 static std::vector<float>
CalculateDerivative(
const std::vector <float>& inputData,
unsigned int step);
416 void prepareLGRefit(
const std::vector<float>& samplesLG,
const std::vector<float>& samplesSig,
417 const std::vector<bool>& useSamples);
425 for (
size_t isample = 0; isample <
m_NSamplesAna; isample++) {
431 for (
size_t isample = 0; isample <
m_NSamplesAna; isample++) {
441 for (
size_t isample = 0; isample <
m_Nsample; isample++) {
452 for (
size_t isample = 0; isample <
m_Nsample; isample++) {
463 void checkTF1Limits(TF1* func);
465 void DoFit(
bool refitLG =
false);
466 void DoFitCombined(
bool refitLG =
false);
468 static std::unique_ptr<TFitter> MakeCombinedFitter(TF1* func);
472 static void CombinedPulsesFCN(
int& numParam,
double*,
double& f,
double* par,
int flag);
474 void UpdateFitterTimeLimits(TFitter* fitter,
ZDCFitWrapper* wrapper,
bool prePulse);
479 int pedestal,
const std::string& fitFunction,
int peak2ndDerivMinSample,
float peak2DerivMinThreshHG,
480 float peak2DerivMinThreshLG);
493 void enableDelayed(
float deltaT,
float pedestalShift,
bool fixedBaseline =
false);
495 void enableRepass(
float peak2ndDerivMinRepassHG,
float peak2ndDerivMinRepassLG);
497 void enableTimeSigCut(
bool AND,
float sigCut,
const std::string& TF1String,
498 const std::vector<double>& parsHG,
499 const std::vector<double>& parsLG);
501 void enablePreExclusion(
unsigned int maxSamplesExcl,
unsigned int HGADCThresh,
unsigned int LGADCThresh)
527 void SetCutValues(
float chisqDivAmpCutHG,
float chisqDivAmpCutLG,
528 float deltaT0MinHG,
float deltaT0MaxHG,
529 float deltaT0MinLG,
float deltaT0MaxLG) ;
537 void SetGainFactorsHGLG(
float gainFactorHG,
float gainFactorLG);
539 void SetFitMinMaxAmp(
float minAmpHG,
float minAmpLG,
float maxAmpHG,
float maxAmpLG);
541 void setMinimumSignificance(
float sigMinHG,
float sigMinLG);
543 void SetTauT0Values(
bool fixTau1,
bool fixTau2,
float tau1,
float tau2,
float t0HG,
float t0LG);
545 void SetADCOverUnderflowValues(
int HGOverflowADC,
int HGUnderflowADC,
int LGOverflowADC);
548 const std::vector<float>& HGT0CorrParams,
const std::vector<float>& LGT0CorrParams)
560 void SetFitTimeMax(
float tmax);
562 void SetNonlinCorrParams(
float refADC,
float refScale,
const std::vector<float>& paramsHG,
const std::vector<float>& paramsLG)
564 std::string HGParamsStr =
"HG coefficients = ", LGParamsStr =
"LG coefficients = ";
566 for (
auto val : paramsHG) {HGParamsStr += std::to_string(val) +
" ";}
567 for (
auto val : paramsLG) {LGParamsStr += std::to_string(val) +
" ";}
569 (*m_msgFunc_p)(
ZDCMsg::Info, (
"Setting non-linear parameters for module: " +
m_tag +
", reference ADC = " +
570 std::to_string(refADC) +
", reference scale = " + std::to_string(refScale)));
585 void enableFADCCorrections(
bool correctPerSample, std::unique_ptr<const TH1>& correHistHG, std::unique_ptr<const TH1>& correHistLG);
588 bool LoadAndAnalyzeData(
const std::vector<float>& ADCSamplesHG,
const std::vector<float>& ADCSamplesLG);
590 bool LoadAndAnalyzeData(
const std::vector<float>& ADCSamplesHG,
const std::vector<float>& ADCSamplesLG,
591 const std::vector<float>& ADCSamplesHGDelayed,
const std::vector<float>& ADCSamplesLGDelayed);
593 bool ReanalyzeData();
723 unsigned int GetStatusMask()
const;
743 std::shared_ptr<TGraphErrors> GetCombinedGraph(
bool forceLG =
false);
744 std::shared_ptr<TGraphErrors> GetGraph(
bool forceLG =
false);
746 std::vector<float> GetFitPulls(
bool forceLG =
false)
const;
749 void dumpConfiguration()
const;
750 void dumpTF1(
const TF1*)
const;
Define macros for attributes used to control the static checker.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
std::map< std::string, JSONParamDescr > JSONParamList
std::vector< bool > m_useSampleHG
float GetFitPostAmp() const
static TF1 * s_combinedFitFunc
float m_initialPrePulseAmp
std::unique_ptr< const TF1 > m_timeResFuncHG_p
float GetAmpError() const
float m_chisqDivAmpOffsetLG
std::unique_ptr< TFitter > m_prePulseCombinedFitter
bool underflowExclusion() const
float GetDelayedBaselineCorr() const
float m_initialPostPulseT0
unsigned int m_timeCutMode
std::unique_ptr< const TH1 > m_FADCCorrLG
size_t m_peak2ndDerivMinTolerance
std::vector< float > m_fitPulls
const std::vector< float > & GetSamplesDeriv2nd() const
std::vector< float > m_ADCSSampSigHG
size_t m_peak2ndDerivMinSample
bool ScanAndSubtractSamples()
std::vector< float > m_nonLinCorrParamsLG
int getMaxADCSampleLG() const
float GetFitPostT0() const
bool excludeEarlyLG() const
float m_peak2ndDerivMinThreshHG
float GetAmplitude() const
static std::vector< float > s_pullValues
void enablePostExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
std::unique_ptr< const TF1 > m_timeResFuncLG_p
static TH1 * s_undelayedFitHist
std::pair< bool, std::string > ConfigFromJSON(const JSON &config)
std::unique_ptr< ZDCFitWrapper > m_defaultFitWrapper
float getMaxADCLG() const
std::string m_fitFunction
float getADCPeakHG() const
unsigned int m_preSampleIdx
float getRefitLGAmpCorr() const
int getMinADCSampleHG() const
std::vector< float > m_LGT0CorrParams
std::vector< float > m_samplesLGRefit
float getMinADCLG() const
float getMinADCSub() const
bool fitMinimumAmplitude() const
float m_chisqDivAmpPowerLG
const TH1 * GetHistogramPtr(bool refitLG=false)
float m_peak2ndDerivMinRepassLG
void SetNoiseSigmas(float noiseSigHG, float noiseSigLG)
int m_lastHGOverFlowSample
float GetMinDeriv2ndIndex() const
void prepareLGRefit(const std::vector< float > &samplesLG, const std::vector< float > &samplesSig, const std::vector< bool > &useSamples)
unsigned int m_preExclLGADCThresh
float getMinADCHG() const
std::vector< float > m_ADCSSampSigLG
unsigned int m_postExclLGADCThresh
unsigned int m_NSamplesAna
bool DoAnalysis(bool repass)
std::vector< float > m_samplesSig
float GetDelayedBaselineShiftFit() const
std::unique_ptr< TH1 > m_delayedHistLGRefit
unsigned int getLGMode() const
float m_delayedBaselineShift
unsigned int m_timingCorrMode
static std::vector< float > Calculate2ndDerivative(const std::vector< float > &inputData, unsigned int step)
unsigned int m_maxSampleEvt
float getRefitLGAmp() const
int m_firstHGOverFlowSample
unsigned int m_maxSamplesPreExcl
std::vector< float > m_ADCSamplesLG
unsigned int m_underFlowExclSamplesPreLG
static float s_combinedFitTMin
std::vector< float > m_nonLinCorrParamsHG
ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const std::string &tag, int Nsample, float deltaTSample, size_t preSampleIdx, int pedestal, const std::string &fitFunction, int peak2ndDerivMinSample, float peak2DerivMinThreshHG, float peak2DerivMinThreshLG)
void setFitOPtions(const std::string &fitOptions)
unsigned int m_underFlowExclSamplesPostHG
static std::vector< float > CalculateDerivative(const std::vector< float > &inputData, unsigned int step)
unsigned int m_maxSamplesPostExcl
float getADCPeakLG() const
float m_chisqDivAmpPowerHG
int getMaxADCSampleHG() const
std::vector< float > m_ADCSamplesHGSub
std::unique_ptr< ZDCPrePulseFitWrapper > m_prePulseFitWrapper
void setLGMode(unsigned int mode)
float getRefitLGChisq() const
static float obtainDelayedBaselineCorr(const std::vector< float > &samples)
double getAmplitudeCorrection(bool highGain)
float GetFitAmplitude() const
float m_peak2ndDerivMinRepassHG
unsigned int m_underFlowExclSamplesPreHG
float GetMaxDelta() const
float m_peak2ndDerivMinThreshLG
void SetPeak2ndDerivMinTolerance(size_t tolerance)
int getMinADCSampleLG() const
std::vector< float > m_ADCSamplesLGSub
float GetMinDelta() const
bool m_enableUnderflowExclHG
float m_delayedPedestalDiff
const std::vector< float > & GetSamplesSub() const
std::vector< float > m_samplesSub
static float s_combinedFitTMax
bool AnalyzeData(size_t nSamples, size_t preSample, const std::vector< float > &samples, const std::vector< bool > &useSamples, float peak2ndDerivMinThresh, float noiseSig, const std::vector< float > &toCorrParams, ChisqCutLambdatype chisqCutLambda, float minT0Corr, float maxT0Corr)
std::vector< bool > m_useSampleLG
float GetPreExpAmp() const
float GetAmpNoNonLin() const
unsigned int m_underFlowExclSamplesPostLG
std::vector< float > m_ADCSamplesHG
std::vector< float > m_samplesSigLGRefit
bool m_underflowExclusion
float getRefitLGTimeSub() const
bool armSumInclude() const
std::function< bool(float, float, float)> ChisqCutLambdatype
std::vector< float > m_HGT0CorrParams
void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
float getMaxADCHG() const
std::unique_ptr< TH1 > m_fitHistLGRefit
std::unique_ptr< TH1 > m_delayedHist
unsigned int m_preExclHGADCThresh
float GetFitExpAmp() const
static TH1 * s_delayedFitHist
float GetFitPreT0() const
std::unique_ptr< TH1 > m_fitHist
void set2ndDerivStep(size_t step)
std::unique_ptr< TFitter > m_defaultCombinedFitter
unsigned int m_minSampleEvt
bool PSHGOverUnderflow() const
float getRefitLGFitAmp() const
float GetMinDeriv2nd() const
float m_nonLinCorrRefScale
float GetFitPreAmp() const
void disableFADCCorrections()
float getPresample() const
bool m_enableUnderflowExclLG
unsigned int m_postExclHGADCThresh
bool m_haveFADCCorrections
void SetNonlinCorrParams(float refADC, float refScale, const std::vector< float > ¶msHG, const std::vector< float > ¶msLG)
float m_chisqDivAmpOffsetHG
std::unique_ptr< const TH1 > m_FADCCorrHG
float getMaxADCSub() const
std::unique_ptr< ZDCPreExpFitWrapper > m_preExpFitWrapper
float GetPreSampleAmp() const
float getRefitLGTime() const
void Reset(bool reanalyze=false)
ZDCMsg::MessageFunctionPtr m_msgFunc_p
void FillHistogram(bool refitLG)
std::vector< float >::const_iterator SampleCIter
float m_initialPrePulseT0
std::vector< float > m_samplesDeriv2nd
float GetBkgdMaxFraction() const
std::pair< bool, std::string > ValidateJSONConfig(const JSON &config)
std::string m_fadcCorrFileName
bool excludeLateLG() const
void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale, const std::vector< float > &HGT0CorrParams, const std::vector< float > &LGT0CorrParams)
std::shared_ptr< MessageFunction > MessageFunctionPtr