ATLAS Offline Software
Loading...
Searching...
No Matches
ZDCPulseAnalyzer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ZDCANALYSIS_ZDCPulseAnalyzer_h
6#define ZDCANALYSIS_ZDCPulseAnalyzer_h
7
11#include "ZdcAnalysis/ZDCMsg.h"
12#include "TGraphErrors.h"
13#include "TFitter.h"
14#include "TF1.h"
15#include "TH1.h"
16
17#include <vector>
18#include <string>
19#include <memory>
20#include <tuple>
21#include <functional>
22
24{
25public:
27
28 enum {PulseBit = 0, // &1
29 LowGainBit = 1, // &2
30 FailBit = 2, // &4
31 HGOverflowBit = 3, // &8
32 // -------------------------
33 HGUnderflowBit = 4, // &16
35 LGOverflowBit = 6, // &64
36 LGUnderflowBit = 7, // &128
37 // -------------------------
38 PrePulseBit = 8, // &256
39 PostPulseBit = 9, // &512
40 FitFailedBit = 10, // &1024
41 BadChisqBit = 11, // &2048
42 // -------------------------
43 BadT0Bit = 12, // &4096
44 ExcludeEarlyLGBit = 13, // &8192
45 ExcludeLateLGBit = 14, // &16384
46 preExpTailBit = 15, // &32768
47 //
48 FitMinAmpBit = 16, // 0x10000
49 RepassPulseBit = 17, // 0x20000
50 ArmSumIncludeBit = 18, // 0x40000
51 FailSigCutBit = 19, // 0x80000
52 UnderFlowExclusionBit = 20, // 0x100000
54 };
55
61
63
64 //
65 // List of allowed JSON configuration parameters
66 //
67 // For each parameter we have name, JSON value type, whether it can be set per channel, and whether it is required
68 //
69 // if the type is -1, then there's no value, the presence of the parameter itself is a boolean -- i.e. enabling
70 //
71
72 static const ZDCJSONConfig::JSONParamList JSONConfigParams;
73private:
74 typedef std::vector<float>::const_iterator SampleCIter;
75
76 // Static data
77 //
78
79 static TH1* s_undelayedFitHist;
80 static TH1* s_delayedFitHist;
81 static TF1* s_combinedFitFunc;
82 static float s_combinedFitTMax;
83 static float s_combinedFitTMin;
84 static std::vector<float> s_pullValues;
85
86 // Quantities provided/set in the constructor
87 //
89 std::string m_tag{};
90 unsigned int m_Nsample{};
91 unsigned int m_preSampleIdx{};
92 float m_freqMHz{};
95 unsigned int m_LGMode{LGModeNormal};
96 float m_tmin{};
97 float m_tmax{};
98
99 bool m_quietFits{true};
100 bool m_saveFitFunc{false};
101
102 std::string m_fitFunction;
103 size_t m_2ndDerivStep{1};
108
109 bool m_useDelayed{false};
110
111 bool m_enableRepass{false};
114
115 // Gain factors for low gain and high gain
116 //
119
120 // Uncertainties on the ADC values due to noise
121 //
124
127 std::vector<float> m_setPerSampleNoiseHG;
128 std::vector<float> m_setPerSampleNoiseLG;
129
130 // Default fit values and cuts that can be set via modifier methods
131 //
132 std::string m_fitOptions{};
136
139
142
143 bool m_fixTau1{};
144 bool m_fixTau2{};
145
146 float m_defaultFitTMax{}; // user-provided upper limit on samples to be included in fit
147 float m_defaultFitTMin{}; // user-provided upper limit on samples to be included in fit
148
149 float m_chisqDivAmpCutLG{}; // maximum good LG chisq / amplitude
150 float m_chisqDivAmpCutHG{}; // maximum good HG chisq / amplitude
151 float m_chisqDivAmpScaleLG{}; // maximum good LG chisq / amplitude
152 float m_chisqDivAmpScaleHG{}; // maximum good HG chisq / amplitude
153 float m_chisqDivAmpOffsetLG{}; // maximum good LG chisq / amplitude
154 float m_chisqDivAmpOffsetHG{}; // maximum good HG chisq / amplitude
155 float m_chisqDivAmpPowerLG{}; // maximum good LG chisq / amplitude
156 float m_chisqDivAmpPowerHG{}; // maximum good HG chisq / amplitude
157
158 float m_T0CutLowLG{}; // minimum good corrected time for LG fits
159 float m_T0CutHighLG{}; // maximum good corrected time for LG fits
160
161 float m_T0CutLowHG{}; // minimum good corrected time for HG fits
162 float m_T0CutHighHG{}; // maximum good corrected time for HG fits
163
164 std::unique_ptr<const TF1> m_timeResFuncHG_p{};
165 std::unique_ptr<const TF1> m_timeResFuncLG_p{};
166 float m_t0CutSig{};
167 unsigned int m_timeCutMode{0}; // 0 - no significance cut, 1 - cut ORed with fixed cut, 2 - cut ANDed with fixed cut
168
169 float m_defaultT0Max{}; // Upper limit on pulse t0
170 float m_defaultT0Min{}; // Lower limit on pulse t0
171
172 float m_fitAmpMinHG{}; // Minimum amplitude in the fit
173 float m_fitAmpMinLG{}; // Minimum amplitude in the fit
174
175 float m_fitAmpMaxHG{}; // Minimum am`plitude in the fit
176 float m_fitAmpMaxLG{}; // Minimum amplitude in the fit
177
178 bool m_haveSignifCuts{false};
179 float m_sigMinHG{}; // Minimum amplitude significance to be considered valid pulse
180 float m_sigMinLG{}; // Minimum amplitude significance to be considered valid pulse
181
182 // Enable or not post-pulse detection and associated parameters
183 //
185 unsigned int m_postPulseDelta{0};
189
190 unsigned int m_prePulseDelta{0};
191
192 // Enabling (or not) of exclusion of early or late samples from OOT pileup
193 //
194 bool m_enablePreExcl{false};
195 unsigned int m_maxSamplesPreExcl{0};
196 unsigned int m_preExclHGADCThresh{0};
197 unsigned int m_preExclLGADCThresh{0};
198
199 bool m_enablePostExcl{false};
200 unsigned int m_postExclHGADCThresh{0};
201 unsigned int m_postExclLGADCThresh{0};
202 unsigned int m_maxSamplesPostExcl{0};
203
210
211 //
215 std::vector<float> m_LGT0CorrParams{}; // Parameters used to correct the fit LG times
216 std::vector<float> m_HGT0CorrParams{}; // Parameters used to correct the fit HG times
217
218 bool m_haveNonlinCorr{false};
221 std::vector<float> m_nonLinCorrParamsHG{};
222 std::vector<float> m_nonLinCorrParamsLG{};
223
227 std::unique_ptr<const TH1> m_FADCCorrHG{};
228 std::unique_ptr<const TH1> m_FADCCorrLG{};
229
230 // Histogram used to perform the fits and function wrappers
231 //
232 std::unique_ptr<TH1> m_fitHist{};
233 std::unique_ptr<TH1> m_fitHistLGRefit{};
234
235 bool m_initialized{false};
236 bool m_initializedFits{false};
237 std::unique_ptr<ZDCFitWrapper> m_defaultFitWrapper{};
238 std::unique_ptr<ZDCPrePulseFitWrapper> m_prePulseFitWrapper{};
239 std::unique_ptr<ZDCPreExpFitWrapper> m_preExpFitWrapper{};
240
241 // Members to keep track of adjustments to time range used in analysis/fit
242 //
243 bool m_adjTimeRangeEvent{false}; // indicates whether we adjust the time range for this specific event
244
245 unsigned int m_minSampleEvt{};
246 unsigned int m_maxSampleEvt{};
247
248 // Delayed pulse members
249 //
253 std::unique_ptr<TH1> m_delayedHist{};
254 std::unique_ptr<TH1> m_delayedHistLGRefit{};
255
256 std::unique_ptr<TFitter> m_prePulseCombinedFitter{};
257 std::unique_ptr<TFitter> m_defaultCombinedFitter{};
258
259 // Dynamic data loaded for each pulse (event)
260 // ==========================================
261
262 // -----------------------
263 // Statuses
264 //
265 bool m_haveData{false};
266
267 bool m_havePulse{false};
268 bool m_useLowGain{false};
269 bool m_fail{false};
270 bool m_HGOverflow{false};
271
272 bool m_HGUnderflow{false};
274 bool m_LGOverflow{false};
275 bool m_LGUnderflow{false};
276
277 bool m_prePulse{false};
278 bool m_postPulse{false};
279 bool m_fitFailed{false};
280 bool m_badChisq{false};
281
282 bool m_badT0{false};
283 bool m_ExcludeEarly{false};
284 bool m_ExcludeLate{false};
285 bool m_preExpTail{false};
286
287 bool m_fixPrePulse{false};
288 bool m_fitMinAmp{false};
289 bool m_repassPulse{false};
290 bool m_failSigCut{false};
292
293 // -----------------------
294
295 bool m_backToHG_pre{false};
297
298 // Pulse analysis
299 //
301 float m_preSample{};
302
303 float m_minADCHG{};
304 float m_maxADCHG{};
307
308 float m_maxADCLG{};
309 float m_minADCLG{};
312
313 float m_ADCPeakHG{};
314 float m_ADCPeakLG{};
315
316 float m_maxDelta{};
317 float m_minDelta{};
318
322
323 float m_fitTMax{}; // event-by-event specified fit tmax
324 float m_fitTMin{}; // event-by-event specified fit tmin
325
326 float m_fitPostT0lo{}; // use to assign lower bound of post pulse T0
327
331
334
336
339 float m_fitTime{};
342 float m_timeSig{};
344 float m_fitTau1{};
345 float m_fitTau2{};
346 float m_fitChisq{};
348 float m_fitNDoF{};
349 float m_fitPreT0{};
350 float m_fitPreAmp{};
351 float m_fitPostT0{};
353 float m_fitExpAmp{};
354 float m_amplitude{};
356 float m_ampError{};
363
364 std::vector<float> m_shapeParameters;
365
366 bool m_evtLGRefit{false};
375
378
379 unsigned int m_NSamplesAna{0};
380 std::vector<float> m_ADCSamplesHG;
381 std::vector<float> m_ADCSamplesLG;
382 std::vector<float> m_ADCSamplesHGSub;
383 std::vector<float> m_ADCSamplesLGSub;
384 std::vector<float> m_sampleNoiseHG;
385 std::vector<float> m_sampleNoiseLG;
386
387 std::vector<bool> m_useSampleLG;
388 std::vector<bool> m_useSampleHG;
389
390 std::vector<float> m_ADCSSampNoiseHG;
391 std::vector<float> m_ADCSSampNoiseLG;
392
393 std::vector<float> m_samplesSub;
394 std::vector<float> m_samplesNoise;
395
396 std::vector<float> m_samplesLGRefit;
397 std::vector<float> m_samplesNoiseLGRefit;
398
399 std::vector<float> m_samplesDeriv2nd;
400 std::vector<float> m_samplesDeriv2ndErr;
401
402 // When using combined delayed + undelayed pulses we calculate the chisquare ourselves
403 // so fill this vector as part of that calculation. For the cases where we do not use
404 // delayed samples (2015 and Run3 onward) this vector is not used as the pulls are calculated
405 // when they are fetched.
406 //
407 std::vector<float> m_fitPulls;
408
409 // Private methods
410 //
411 void initialize();
412 void reset(bool reanalyze = false);
413 void setDefaults();
414
415 std::pair<bool, std::string> ValidateJSONConfig(const JSON& config);
416 std::pair<bool, std::string> ConfigFromJSON(const JSON& config);
417
418 void SetupFitFunctions();
419
420 bool DoAnalysis(bool repass);
421
423
424 using ChisqCutLambdatype = std::function<bool(float,float,float, float&)>;
425
426 bool AnalyzeData(size_t nSamples, size_t preSample,
427 const std::vector<float>& samples, // The samples used for this event
428 const std::vector<float>& samplesNoise, // The per-sample noise used for this event
429 const std::vector<bool>& useSamples, // The samples used for this event
430 float peak2ndDerivMinThresh,
431 const std::vector<float>& toCorrParams, // The parameters used to correct the t0
432 ChisqCutLambdatype chisqCutLambda, // Lambda to apply chisq cut
433 float minT0Corr, float maxT0Corr // The minimum and maximum corrected T0 values
434 );
435
436
437 double getAmplitudeCorrection(bool highGain);
438
439 static std::vector<float> calculate2ndDerivative(const std::vector <float>& inputData, unsigned int step);
440
441 static std::pair<std::vector<float>, std::vector<float>>
442 calculate2ndDerivative(const std::vector<float>& inputData, const std::vector<float>& inputNoise, unsigned int step);
443
444 static std::vector<float> calculateDerivative(const std::vector <float>& inputData, unsigned int step);
445 static float obtainDelayedBaselineCorr(const std::vector<float>& samples);
446
447 void prepareLGRefit(const std::vector<float>& samplesLG, const std::vector<float>& samplesNoise,
448 const std::vector<bool>& useSamples);
449
450 void FillHistogram(bool refitLG)
451 {
452 if (!m_useDelayed) {
453 if (!refitLG) {
454 // Set the data and errors in the histogram object
455 //
456 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
457 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample]);
458 m_fitHist->SetBinError(isample + 1, m_samplesNoise[isample]);
459 }
460 }
461 else {
462 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
463 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample]);
464 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
465 }
466 }
467 }
468 else {
469 if (!refitLG) {
470 // Set the data and errors in the histogram object
471 //
472 for (size_t isample = 0; isample < m_Nsample; isample++) {
473 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample * 2]);
474 m_delayedHist->SetBinContent(isample + 1, m_samplesSub[isample * 2 + 1]);
475
476 m_fitHist->SetBinError(isample + 1, m_samplesNoise[isample]);
477 m_delayedHist->SetBinError(isample + 1, m_samplesNoise[isample]);
478 }
479 }
480 else {
481 // Set the data and errors in the histogram object
482 //
483 for (size_t isample = 0; isample < m_Nsample; isample++) {
484 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2]);
485 m_delayedHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2 + 1]);
486
487 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
488 m_delayedHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
489 }
490 }
491 }
492 }
493
494 void checkTF1Limits(TF1* func);
495
496 void DoFit(bool refitLG = false);
497 void DoFitCombined(bool refitLG = false);
498
499 static std::unique_ptr<TFitter> MakeCombinedFitter(TF1* func);
500
501 // The minuit FCN used for fitting combined undelayed and delayed pulses
502 //
503 static void CombinedPulsesFCN(int& numParam, double*, double& f, double* par, int flag);
504
505 void UpdateFitterTimeLimits(TFitter* fitter, ZDCFitWrapper* wrapper, bool prePulse);
506
507public:
508
509 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const std::string& tag, int Nsample, float deltaTSample, size_t preSampleIdx,
510 int pedestal, const std::string& fitFunction, int peak2ndDerivMinSample, float peak2DerivMinThreshHG,
511 float peak2DerivMinThreshLG);
512
513 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const JSON& configJSON);
514
516
517 void setFitOPtions(const std::string& fitOptions) { m_fitOptions = fitOptions;}
518 void saveFitFunc(bool save) {m_saveFitFunc = save;}
519
520 bool quietFits() const {return m_quietFits;}
521 void setQuietFits() {m_quietFits = true;}
522 void setUnquietFits() {m_quietFits = false;}
523
524 void enableDelayed(float deltaT, float pedestalShift, bool fixedBaseline = false);
525
526 void enableRepass(float peak2ndDerivMinRepassHG, float peak2ndDerivMinRepassLG);
527
528 void enableTimeSigCut(bool AND, float sigCut, const std::string& TF1String,
529 const std::vector<double>& parsHG,
530 const std::vector<double>& parsLG);
531
532 void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
533 {
534 m_enablePreExcl = true;
535 m_maxSamplesPreExcl = maxSamplesExcl;
536 m_preExclHGADCThresh = HGADCThresh;
537 m_preExclLGADCThresh = LGADCThresh;
538 }
539
540 void enablePostExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
541 {
542 m_enablePostExcl = true;
543 m_maxSamplesPostExcl = maxSamplesExcl;
544 m_postExclHGADCThresh = HGADCThresh;
545 m_postExclLGADCThresh = LGADCThresh;
546 }
547
552
553 void setPerSampleNoiseSigmas(const std::vector<float>& sigmaHG, const std::vector<float>& sigmaLG)
554 {
555 m_setPerSampleNoiseHG = sigmaHG;
556 m_setPerSampleNoiseLG = sigmaLG;
559 }
560
561 void setLGMode(unsigned int mode) {m_LGMode = mode;}
562 unsigned int getLGMode() const {return m_LGMode;}
563
564 void set2ndDerivStep(size_t step) {m_2ndDerivStep = step;}
565
566 void SetCutValues(float chisqDivAmpCutHG, float chisqDivAmpCutLG,
567 float deltaT0MinHG, float deltaT0MaxHG,
568 float deltaT0MinLG, float deltaT0MaxLG);
569
570 void SetTimeCuts(float deltaT0MinHG, float deltaT0MaxHG,
571 float deltaT0MinLG, float deltaT0MaxLG);
572
573 void SetChisqCuts(float chisqDivAmpCutHG, float chisqDivAmpScaleHG, float chisqDivAmpOffsetHG, float chisqDivAmpPowerHG,
574 float chisqDivAmpCutLG, float chisqDivAmpScaleLG, float chisqDivAmpOffsetLG, float chisqDivAmpPowerLG);
575
576 void SetNoiseSigmas(float noiseSigHG, float noiseSigLG)
577 {
578 m_noiseSigHG = noiseSigHG;
579 m_noiseSigLG = noiseSigLG;
580 }
581
582 void SetGainFactorsHGLG(float gainFactorHG, float gainFactorLG);
583
584 void SetFitMinMaxAmp(float minAmpHG, float minAmpLG, float maxAmpHG, float maxAmpLG);
585
586 void setMinimumSignificance(float sigMinHG, float sigMinLG);
587
588 void SetTauT0Values(bool fixTau1, bool fixTau2, float tau1, float tau2, float t0HG, float t0LG);
589
590 void enablePostPulseCheck(unsigned int postPulseSampleDelta, float postPulseDerivMinSig, float postPulseAbsDer2ndMinSig, float minMainDer2ndRatio);
592
593 void SetADCOverUnderflowValues(int HGOverflowADC, int HGUnderflowADC, int LGOverflowADC);
594
595 void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale,
596 const std::vector<float>& HGT0CorrParams, const std::vector<float>& LGT0CorrParams)
597 {
598 m_timingCorrMode = mode;
599 if (mode != NoTimingCorr) {
600 m_timingCorrRefADC = refADC;
601 m_timingCorrScale = refScale;
602
603 m_HGT0CorrParams = HGT0CorrParams;
604 m_LGT0CorrParams = LGT0CorrParams;
605 }
606 }
607
608 void SetFitTimeMax(float tmax);
609
610 void SetNonlinCorrParams(float refADC, float refScale, const std::vector<float>& paramsHG, const std::vector<float>& paramsLG)
611 {
612 std::string HGParamsStr = "HG coefficients = ", LGParamsStr = "LG coefficients = ";
613
614 for (auto val : paramsHG) {HGParamsStr += std::to_string(val) + " ";}
615 for (auto val : paramsLG) {LGParamsStr += std::to_string(val) + " ";}
616
617 (*m_msgFunc_p)(ZDCMsg::Info, ("Setting non-linear parameters for module: " + m_tag + ", reference ADC = " +
618 std::to_string(refADC) + ", reference scale = " + std::to_string(refScale)));
619
620 (*m_msgFunc_p)(ZDCMsg::Info, std::move(HGParamsStr));
621 (*m_msgFunc_p)(ZDCMsg::Info, std::move(LGParamsStr));
622
623 m_nonLinCorrRefADC = refADC;
624 m_nonLinCorrRefScale = refScale;
625 m_nonLinCorrParamsHG = paramsHG;
626 m_nonLinCorrParamsLG = paramsLG;
627 m_haveNonlinCorr = true;
628 }
629
630 // Provide a historam that provides per-ADC channel correction factors for integral and differential
631 // non-linearities
632 //
633 void enableFADCCorrections(bool correctPerSample, std::unique_ptr<const TH1>& correHistHG, std::unique_ptr<const TH1>& correHistLG);
635
636 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG);
637
638 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG,
639 const std::vector<float>& ADCSamplesHGDelayed, const std::vector<float>& ADCSamplesLGDelayed);
640
641 bool ReanalyzeData();
642
643 bool HaveData() const {return m_haveData;}
644
645 // ------------------------------------------------------------
646 // Status bit setting functions
647 //
648 bool havePulse() const {return m_havePulse;}
649 bool useLowGain() const {return m_useLowGain;}
650 bool failed() const {return m_fail;}
651 bool HGOverflow() const {return m_HGOverflow;}
652
653 bool HGUnderflow() const {return m_HGUnderflow;}
655 bool LGOverflow() const {return m_LGOverflow;}
656 bool LGUnderflow() const {return m_LGUnderflow;}
657
658 bool prePulse() const {return m_prePulse;}
659 bool postPulse() const {return m_postPulse;}
660 bool fitFailed() const {return m_fitFailed;}
661 bool badChisq() const {return m_badChisq;}
662
663 bool badT0() const {return m_badT0;}
664 bool excludeEarlyLG() const {return m_ExcludeEarly;}
665 bool excludeLateLG() const {return m_ExcludeLate;}
666 bool preExpTail() const {return m_preExpTail;}
667 bool fitMinimumAmplitude() const {return m_fitMinAmp;}
668 bool repassPulse() const {return m_repassPulse;}
669 bool armSumInclude() const {return havePulse() && !(failed() || fitFailed() || badChisq() || badT0() || fitMinimumAmplitude() || LGOverflow() || LGUnderflow() || failSigCut());}
670 bool failSigCut() const {return m_failSigCut;}
672
673 // ------------------------------------------------------------
674
675
676 // ---------------------------
677 // Get fit parameters
678 //
679 float GetFitAmplitude() const {return m_fitAmplitude;}
680 float GetFitT0() const {return m_fitTime;}
681 float GetT0Sub() const {return m_fitTimeSub;}
682 float GetT0Corr() const {return m_fitTimeCorr;}
683 float getTimeSig() const {return m_timeSig;}
684 float GetChisq() const {return m_fitChisq;}
685 float GetChisqRatio() const {return m_chisqRatio;}
686 float GetFitTau1() const {return m_fitTau1;}
687 float GetFitTau2() const {return m_fitTau2;}
688 float GetFitPreT0() const {return m_fitPreT0;}
689 float GetFitPreAmp() const {return m_preAmplitude;}
690 float GetFitPostT0() const {return m_fitPostT0;}
691 float GetFitPostAmp() const {return m_postAmplitude;}
692 float GetFitExpAmp() const {return m_fitExpAmp;}
693 // ---------------------------
694
695 float GetAmpNoNonLin() const {return m_ampNoNonLin;}
696 float GetAmplitude() const {return m_amplitude;}
697 float GetAmpError() const {return m_ampError;}
698 float GetPreExpAmp() const {return m_expAmplitude;}
699
700 const std::vector<float>& GetShapeParameters() const {return m_shapeParameters;}
701
702 float getRefitLGAmp() const
703 {
704 if (m_evtLGRefit) return m_refitLGAmpl;
705 else return 0;
706 }
707
708 float getRefitLGFitAmp() const
709 {
710 if (m_evtLGRefit) return m_refitLGFitAmpl;
711 else return 0;
712 }
713
714 float getRefitLGAmpCorr() const
715 {
717 else return 0;
718 }
719
720 float getRefitLGChisq() const
721 {
722 if (m_evtLGRefit) return m_refitLGChisq;
723 else return 0;
724 }
725
727 {
729 else return 0;
730 }
731
732 float getRefitLGTime() const
733 {
734 if (m_evtLGRefit) return m_refitLGTime;
735 else return 0;
736 }
737
738 float getRefitLGTimeSub() const
739 {
740 if (m_evtLGRefit) return m_refitLGTimeSub;
741 else return 0;
742 }
743
744 float getPresample() const {return m_preSample;}
745 float getMaxADCHG() const {return m_maxADCHG;}
746 float getMaxADCLG() const {return m_maxADCLG;}
747 float getMinADCHG() const {return m_minADCHG;}
748 float getMinADCLG() const {return m_minADCLG;}
749
750 float getMaxADCSub() const {
751 float maxADCNosub = m_useLowGain ? m_maxADCLG : m_maxADCHG;
752 return maxADCNosub - m_pedestal - m_preSample;
753 }
754
755 float getMinADCSub() const {
756 float minADCNosub = m_useLowGain ? m_minADCLG : m_minADCHG;
757 return minADCNosub - m_pedestal - m_preSample;
758 }
759
762
765
766 float getADCPeakHG() const {return m_ADCPeakHG;}
767 float getADCPeakLG() const {return m_ADCPeakLG;}
768
769 float GetMaxDelta() const {return m_maxDelta;}
770 float GetMinDelta() const {return m_minDelta;}
771
772 float GetFitTMax() const {return m_fitTMax;}
773 float GetFitTMin() const {return m_fitTMin;}
774
775 float GetdelayBS() const {return m_delayedBaselineShift;}
776
777 float GetMinDeriv2nd() const {return m_minDeriv2nd;}
779
780 unsigned int GetStatusMask() const;
781
782 float GetPreSampleAmp() const {return m_preSampleAmp;}
783 float GetBkgdMaxFraction() const {return m_bkgdMaxFraction;}
784
787
788 const TH1* GetHistogramPtr(bool refitLG = false)
789 {
790 //
791 // We defer filling the histogram if we don't have a pulse until the histogram is requested
792 //
793 if (!m_havePulse) {
794 FillHistogram(refitLG);
795 }
796
797 return refitLG ? m_fitHistLGRefit.get() : m_fitHist.get();
798 }
799
800 std::shared_ptr<TGraphErrors> GetCombinedGraph(bool forceLG = false);
801 std::shared_ptr<TGraphErrors> GetGraph(bool forceLG = false);
802
803 std::vector<float> GetFitPulls(bool forceLG = false) const;
804
805 void dump() const;
806 void dumpConfiguration() const;
807 void dumpTF1(const TF1*) const;
808
809 const std::vector<float>& GetSamplesSub() const {return m_samplesSub;}
810 const std::vector<float>& GetSamplesDeriv2nd() const {return m_samplesDeriv2nd;}
811};
812
813
814#endif
ZDCJSONConfig::JSON JSON
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
nlohmann::json JSON
std::vector< bool > m_useSampleHG
float GetFitPostAmp() const
static TF1 * s_combinedFitFunc
const std::vector< float > & GetShapeParameters() const
bool LGOverflow() const
bool HaveData() const
std::unique_ptr< const TF1 > m_timeResFuncHG_p
float GetAmpError() const
std::unique_ptr< TFitter > m_prePulseCombinedFitter
bool HGOverflow() const
bool underflowExclusion() const
float GetDelayedBaselineCorr() const
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_setPerSampleNoiseHG
std::vector< float > m_nonLinCorrParamsLG
int getMaxADCSampleLG() const
float GetFitPostT0() const
bool excludeEarlyLG() const
float GetAmplitude() const
std::vector< float > m_samplesNoiseLGRefit
static std::vector< float > s_pullValues
float GetFitT0() const
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)
static std::vector< float > calculate2ndDerivative(const std::vector< float > &inputData, unsigned int step)
std::unique_ptr< ZDCFitWrapper > m_defaultFitWrapper
float getMaxADCLG() const
std::string m_fitFunction
float getADCPeakHG() const
unsigned int m_preSampleIdx
bool prePulse() const
float getRefitLGAmpCorr() const
int getMinADCSampleHG() const
float getTimeSig() const
std::vector< float > m_LGT0CorrParams
std::vector< float > m_samplesLGRefit
std::vector< float > m_samplesNoise
float getMinADCLG() const
float getMinADCSub() const
bool fitMinimumAmplitude() const
const TH1 * GetHistogramPtr(bool refitLG=false)
void SetNoiseSigmas(float noiseSigHG, float noiseSigLG)
float GetT0Corr() const
float GetMinDeriv2ndIndex() const
ZDCJSONConfig::JSON JSON
unsigned int m_preExclLGADCThresh
float getMinADCHG() const
bool useLowGain() const
unsigned int m_prePulseDelta
unsigned int m_postExclLGADCThresh
std::vector< float > m_shapeParameters
unsigned int m_NSamplesAna
bool DoAnalysis(bool repass)
float GetDelayedBaselineShiftFit() const
std::unique_ptr< TH1 > m_delayedHistLGRefit
unsigned int getLGMode() const
bool HGUnderflow() const
unsigned int m_timingCorrMode
std::vector< float > m_sampleNoiseLG
unsigned int m_maxSampleEvt
float getRefitLGAmp() const
bool fitFailed() const
void saveFitFunc(bool save)
unsigned int m_maxSamplesPreExcl
float GetChisqRatio() const
std::string m_fitOptions
std::vector< float > m_setPerSampleNoiseLG
std::vector< float > m_ADCSamplesLG
unsigned int m_underFlowExclSamplesPreLG
float m_postPulseMainMinDer2ndRatio
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
unsigned int m_maxSamplesPostExcl
float getADCPeakLG() const
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)
void prepareLGRefit(const std::vector< float > &samplesLG, const std::vector< float > &samplesNoise, const std::vector< bool > &useSamples)
double getAmplitudeCorrection(bool highGain)
float GetFitTau1() const
float GetFitAmplitude() const
unsigned int m_underFlowExclSamplesPreHG
float GetMaxDelta() const
void SetPeak2ndDerivMinTolerance(size_t tolerance)
int getMinADCSampleLG() const
std::vector< float > m_ADCSamplesLGSub
float GetMinDelta() const
const std::vector< float > & GetSamplesSub() const
bool havePulse() const
std::vector< float > m_samplesSub
static float s_combinedFitTMax
std::vector< bool > m_useSampleLG
void reset(bool reanalyze=false)
float GetPreExpAmp() const
float GetdelayBS() const
float GetAmpNoNonLin() const
unsigned int m_underFlowExclSamplesPostLG
unsigned int m_postPulseDelta
std::vector< float > m_ADCSamplesHG
bool quietFits() const
bool AnalyzeData(size_t nSamples, size_t preSample, const std::vector< float > &samples, const std::vector< float > &samplesNoise, const std::vector< bool > &useSamples, float peak2ndDerivMinThresh, const std::vector< float > &toCorrParams, ChisqCutLambdatype chisqCutLambda, float minT0Corr, float maxT0Corr)
unsigned int m_Nsample
float getRefitLGTimeSub() const
std::vector< float > m_sampleNoiseHG
bool armSumInclude() const
std::vector< float > m_HGT0CorrParams
void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
float getMaxADCHG() const
float getRefitLGChisqRatio() const
std::unique_ptr< TH1 > m_fitHistLGRefit
std::unique_ptr< TH1 > m_delayedHist
float GetFitTau2() const
float GetChisq() const
float GetFitTMin() const
unsigned int m_preExclHGADCThresh
bool failSigCut() const
float GetFitExpAmp() const
static TH1 * s_delayedFitHist
float GetFitPreT0() const
std::unique_ptr< TH1 > m_fitHist
bool badChisq() const
void set2ndDerivStep(size_t step)
std::unique_ptr< TFitter > m_defaultCombinedFitter
unsigned int m_minSampleEvt
bool preExpTail() const
std::vector< float > m_ADCSSampNoiseLG
bool PSHGOverUnderflow() const
float getRefitLGFitAmp() const
float GetMinDeriv2nd() const
float GetFitPreAmp() const
float getPresample() const
bool postPulse() const
unsigned int m_postExclHGADCThresh
void setPerSampleNoiseSigmas(const std::vector< float > &sigmaHG, const std::vector< float > &sigmaLG)
bool repassPulse() const
bool LGUnderflow() const
static std::vector< float > calculateDerivative(const std::vector< float > &inputData, unsigned int step)
void SetNonlinCorrParams(float refADC, float refScale, const std::vector< float > &paramsHG, const std::vector< float > &paramsLG)
float GetT0Sub() const
std::unique_ptr< const TH1 > m_FADCCorrHG
std::vector< float > m_samplesDeriv2ndErr
float getMaxADCSub() const
std::unique_ptr< ZDCPreExpFitWrapper > m_preExpFitWrapper
float GetPreSampleAmp() const
float getRefitLGTime() const
ZDCMsg::MessageFunctionPtr m_msgFunc_p
void FillHistogram(bool refitLG)
std::vector< float >::const_iterator SampleCIter
std::vector< float > m_ADCSSampNoiseHG
std::vector< float > m_samplesDeriv2nd
float GetBkgdMaxFraction() const
std::pair< bool, std::string > ValidateJSONConfig(const JSON &config)
float GetFitTMax() const
std::string m_fadcCorrFileName
bool excludeLateLG() const
unsigned int m_LGMode
std::function< bool(float, float, float, float &)> ChisqCutLambdatype
void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale, const std::vector< float > &HGT0CorrParams, const std::vector< float > &LGT0CorrParams)
bool fitFailed
@ Info
Definition ZDCMsg.h:20
std::shared_ptr< MessageFunction > MessageFunctionPtr
Definition ZDCMsg.h:14
-event-from-file
void initialize()