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 //
184 bool m_doPrePulseCheck{false};
185
186 // Enable or not post-pulse detection and associated parameters
187 //
189 unsigned int m_postPulseDelta{0};
193
194 unsigned int m_prePulseDelta{0};
195
196 // Enabling (or not) of exclusion of early or late samples from OOT pileup
197 //
198 bool m_enablePreExcl{false};
199 unsigned int m_maxSamplesPreExcl{0};
200 unsigned int m_preExclHGADCThresh{0};
201 unsigned int m_preExclLGADCThresh{0};
202
203 bool m_enablePostExcl{false};
204 unsigned int m_postExclHGADCThresh{0};
205 unsigned int m_postExclLGADCThresh{0};
206 unsigned int m_maxSamplesPostExcl{0};
207
214
215 //
219 std::vector<float> m_LGT0CorrParams{}; // Parameters used to correct the fit LG times
220 std::vector<float> m_HGT0CorrParams{}; // Parameters used to correct the fit HG times
221
222 bool m_haveNonlinCorr{false};
225 std::vector<float> m_nonLinCorrParamsHG{};
226 std::vector<float> m_nonLinCorrParamsLG{};
227
231 std::unique_ptr<const TH1> m_FADCCorrHG{};
232 std::unique_ptr<const TH1> m_FADCCorrLG{};
233
234 // Histogram used to perform the fits and function wrappers
235 //
236 std::unique_ptr<TH1> m_fitHist{};
237 std::unique_ptr<TH1> m_fitHistLGRefit{};
238
239 bool m_initialized{false};
240 bool m_initializedFits{false};
241 std::unique_ptr<ZDCFitWrapper> m_defaultFitWrapper{};
242 std::unique_ptr<ZDCPrePulseFitWrapper> m_prePulseFitWrapper{};
243 std::unique_ptr<ZDCPreExpFitWrapper> m_preExpFitWrapper{};
244
245 // Members to keep track of adjustments to time range used in analysis/fit
246 //
247 bool m_adjTimeRangeEvent{false}; // indicates whether we adjust the time range for this specific event
248
249 unsigned int m_minSampleEvt{};
250 unsigned int m_maxSampleEvt{};
251
252 // Delayed pulse members
253 //
257 std::unique_ptr<TH1> m_delayedHist{};
258 std::unique_ptr<TH1> m_delayedHistLGRefit{};
259
260 std::unique_ptr<TFitter> m_prePulseCombinedFitter{};
261 std::unique_ptr<TFitter> m_defaultCombinedFitter{};
262
263 // Dynamic data loaded for each pulse (event)
264 // ==========================================
265
266 // -----------------------
267 // Statuses
268 //
269 bool m_haveData{false};
270
271 bool m_havePulse{false};
272 bool m_useLowGain{false};
273 bool m_fail{false};
274 bool m_HGOverflow{false};
275
276 bool m_HGUnderflow{false};
278 bool m_LGOverflow{false};
279 bool m_LGUnderflow{false};
280
281 bool m_prePulse{false};
282 bool m_postPulse{false};
283 bool m_fitFailed{false};
284 bool m_badChisq{false};
285
286 bool m_badT0{false};
287 bool m_ExcludeEarly{false};
288 bool m_ExcludeLate{false};
289 bool m_preExpTail{false};
290
291 bool m_fixPrePulse{false};
292 bool m_fitMinAmp{false};
293 bool m_repassPulse{false};
294 bool m_failSigCut{false};
296
297 // -----------------------
298
299 bool m_backToHG_pre{false};
301
302 // Pulse analysis
303 //
305 float m_preSample{};
306
307 float m_minADCHG{};
308 float m_maxADCHG{};
311
312 float m_maxADCLG{};
313 float m_minADCLG{};
316
317 float m_ADCPeakHG{};
318 float m_ADCPeakLG{};
319
320 float m_maxDelta{};
321 float m_minDelta{};
322
326
327 float m_fitTMax{}; // event-by-event specified fit tmax
328 float m_fitTMin{}; // event-by-event specified fit tmin
329
330 float m_fitPostT0lo{}; // use to assign lower bound of post pulse T0
331
335
338
340
343 float m_fitTime{};
346 float m_timeSig{};
348 float m_fitTau1{};
349 float m_fitTau2{};
350 float m_fitChisq{};
352 float m_fitNDoF{};
353 float m_fitPreT0{};
354 float m_fitPreAmp{};
355 float m_fitPostT0{};
357 float m_fitExpAmp{};
358 float m_amplitude{};
360 float m_ampError{};
367
368 std::vector<float> m_shapeParameters;
369
370 bool m_evtLGRefit{false};
379
382
383 unsigned int m_NSamplesAna{0};
384 std::vector<float> m_ADCSamplesHG;
385 std::vector<float> m_ADCSamplesLG;
386 std::vector<float> m_ADCSamplesHGSub;
387 std::vector<float> m_ADCSamplesLGSub;
388 std::vector<float> m_sampleNoiseHG;
389 std::vector<float> m_sampleNoiseLG;
390
391 std::vector<bool> m_useSampleLG;
392 std::vector<bool> m_useSampleHG;
393
394 std::vector<float> m_ADCSSampNoiseHG;
395 std::vector<float> m_ADCSSampNoiseLG;
396
397 std::vector<float> m_samplesSub;
398 std::vector<float> m_samplesNoise;
399
400 std::vector<float> m_samplesLGRefit;
401 std::vector<float> m_samplesNoiseLGRefit;
402
403 std::vector<float> m_samplesDeriv2nd;
404 std::vector<float> m_samplesDeriv2ndErr;
405
406 // When using combined delayed + undelayed pulses we calculate the chisquare ourselves
407 // so fill this vector as part of that calculation. For the cases where we do not use
408 // delayed samples (2015 and Run3 onward) this vector is not used as the pulls are calculated
409 // when they are fetched.
410 //
411 std::vector<float> m_fitPulls;
412
413 // Private methods
414 //
415 void initialize();
416 void reset(bool reanalyze = false);
417 void setDefaults();
418
419 std::pair<bool, std::string> ValidateJSONConfig(const JSON& config);
420 std::pair<bool, std::string> ConfigFromJSON(const JSON& config);
421
422 void SetupFitFunctions();
423
424 bool DoAnalysis(bool repass);
425
427
428 using ChisqCutLambdatype = std::function<bool(float,float,float, float&)>;
429
430 bool AnalyzeData(size_t nSamples, size_t preSample,
431 const std::vector<float>& samples, // The samples used for this event
432 const std::vector<float>& samplesNoise, // The per-sample noise used for this event
433 const std::vector<bool>& useSamples, // The samples used for this event
434 float peak2ndDerivMinThresh,
435 const std::vector<float>& toCorrParams, // The parameters used to correct the t0
436 ChisqCutLambdatype chisqCutLambda, // Lambda to apply chisq cut
437 float minT0Corr, float maxT0Corr // The minimum and maximum corrected T0 values
438 );
439
440
441 double getAmplitudeCorrection(bool highGain);
442
443 static std::vector<float> calculate2ndDerivative(const std::vector <float>& inputData, unsigned int step);
444
445 static std::pair<std::vector<float>, std::vector<float>>
446 calculate2ndDerivative(const std::vector<float>& inputData, const std::vector<float>& inputNoise, unsigned int step);
447
448 static std::vector<float> calculateDerivative(const std::vector <float>& inputData, unsigned int step);
449 static float obtainDelayedBaselineCorr(const std::vector<float>& samples);
450
451 void prepareLGRefit(const std::vector<float>& samplesLG, const std::vector<float>& samplesNoise,
452 const std::vector<bool>& useSamples);
453
454 void FillHistogram(bool refitLG)
455 {
456 if (!m_useDelayed) {
457 if (!refitLG) {
458 // Set the data and errors in the histogram object
459 //
460 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
461 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample]);
462 m_fitHist->SetBinError(isample + 1, m_samplesNoise[isample]);
463 }
464 }
465 else {
466 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
467 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample]);
468 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
469 }
470 }
471 }
472 else {
473 if (!refitLG) {
474 // Set the data and errors in the histogram object
475 //
476 for (size_t isample = 0; isample < m_Nsample; isample++) {
477 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample * 2]);
478 m_delayedHist->SetBinContent(isample + 1, m_samplesSub[isample * 2 + 1]);
479
480 m_fitHist->SetBinError(isample + 1, m_samplesNoise[isample]);
481 m_delayedHist->SetBinError(isample + 1, m_samplesNoise[isample]);
482 }
483 }
484 else {
485 // Set the data and errors in the histogram object
486 //
487 for (size_t isample = 0; isample < m_Nsample; isample++) {
488 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2]);
489 m_delayedHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2 + 1]);
490
491 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
492 m_delayedHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
493 }
494 }
495 }
496 }
497
498 void checkTF1Limits(TF1* func);
499
500 void DoFit(bool refitLG = false);
501 void DoFitCombined(bool refitLG = false);
502
503 static std::unique_ptr<TFitter> MakeCombinedFitter(TF1* func);
504
505 // The minuit FCN used for fitting combined undelayed and delayed pulses
506 //
507 static void CombinedPulsesFCN(int& numParam, double*, double& f, double* par, int flag);
508
509 void UpdateFitterTimeLimits(TFitter* fitter, ZDCFitWrapper* wrapper, bool prePulse);
510
511public:
512
513 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const std::string& tag, int Nsample, float deltaTSample, size_t preSampleIdx,
514 int pedestal, const std::string& fitFunction, int peak2ndDerivMinSample, float peak2DerivMinThreshHG,
515 float peak2DerivMinThreshLG);
516
517 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const JSON& configJSON);
518
520
521 void setFitOPtions(const std::string& fitOptions) { m_fitOptions = fitOptions;}
522 void saveFitFunc(bool save) {m_saveFitFunc = save;}
523
524 bool quietFits() const {return m_quietFits;}
525 void setQuietFits() {m_quietFits = true;}
526 void setUnquietFits() {m_quietFits = false;}
527
528 void enableDelayed(float deltaT, float pedestalShift, bool fixedBaseline = false);
529
530 void enableRepass(float peak2ndDerivMinRepassHG, float peak2ndDerivMinRepassLG);
531
532 void enableTimeSigCut(bool AND, float sigCut, const std::string& TF1String,
533 const std::vector<double>& parsHG,
534 const std::vector<double>& parsLG);
535
536 void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
537 {
538 m_enablePreExcl = true;
539 m_maxSamplesPreExcl = maxSamplesExcl;
540 m_preExclHGADCThresh = HGADCThresh;
541 m_preExclLGADCThresh = LGADCThresh;
542 }
543
544 void enablePostExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
545 {
546 m_enablePostExcl = true;
547 m_maxSamplesPostExcl = maxSamplesExcl;
548 m_postExclHGADCThresh = HGADCThresh;
549 m_postExclLGADCThresh = LGADCThresh;
550 }
551
556
557 void setPerSampleNoiseSigmas(const std::vector<float>& sigmaHG, const std::vector<float>& sigmaLG)
558 {
559 m_setPerSampleNoiseHG = sigmaHG;
560 m_setPerSampleNoiseLG = sigmaLG;
563 }
564
565 void setLGMode(unsigned int mode) {m_LGMode = mode;}
566 unsigned int getLGMode() const {return m_LGMode;}
567
568 void set2ndDerivStep(size_t step) {m_2ndDerivStep = step;}
569
570 void SetCutValues(float chisqDivAmpCutHG, float chisqDivAmpCutLG,
571 float deltaT0MinHG, float deltaT0MaxHG,
572 float deltaT0MinLG, float deltaT0MaxLG);
573
574 void SetTimeCuts(float deltaT0MinHG, float deltaT0MaxHG,
575 float deltaT0MinLG, float deltaT0MaxLG);
576
577 void SetChisqCuts(float chisqDivAmpCutHG, float chisqDivAmpScaleHG, float chisqDivAmpOffsetHG, float chisqDivAmpPowerHG,
578 float chisqDivAmpCutLG, float chisqDivAmpScaleLG, float chisqDivAmpOffsetLG, float chisqDivAmpPowerLG);
579
580 void SetNoiseSigmas(float noiseSigHG, float noiseSigLG)
581 {
582 m_noiseSigHG = noiseSigHG;
583 m_noiseSigLG = noiseSigLG;
584 }
585
586 void SetGainFactorsHGLG(float gainFactorHG, float gainFactorLG);
587
588 void SetFitMinMaxAmp(float minAmpHG, float minAmpLG, float maxAmpHG, float maxAmpLG);
589
590 void setMinimumSignificance(float sigMinHG, float sigMinLG);
591
592 void SetTauT0Values(bool fixTau1, bool fixTau2, float tau1, float tau2, float t0HG, float t0LG);
593
594 void enablePostPulseCheck(unsigned int postPulseSampleDelta, float postPulseDerivMinSig, float postPulseAbsDer2ndMinSig, float minMainDer2ndRatio);
596
597 void SetADCOverUnderflowValues(int HGOverflowADC, int HGUnderflowADC, int LGOverflowADC);
598
599 void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale,
600 const std::vector<float>& HGT0CorrParams, const std::vector<float>& LGT0CorrParams)
601 {
602 m_timingCorrMode = mode;
603 if (mode != NoTimingCorr) {
604 m_timingCorrRefADC = refADC;
605 m_timingCorrScale = refScale;
606
607 m_HGT0CorrParams = HGT0CorrParams;
608 m_LGT0CorrParams = LGT0CorrParams;
609 }
610 }
611
612 void SetFitTimeMax(float tmax);
613
614 void SetNonlinCorrParams(float refADC, float refScale, const std::vector<float>& paramsHG, const std::vector<float>& paramsLG)
615 {
616 std::string HGParamsStr = "HG coefficients = ", LGParamsStr = "LG coefficients = ";
617
618 for (auto val : paramsHG) {HGParamsStr += std::to_string(val) + " ";}
619 for (auto val : paramsLG) {LGParamsStr += std::to_string(val) + " ";}
620
621 (*m_msgFunc_p)(ZDCMsg::Info, ("Setting non-linear parameters for module: " + m_tag + ", reference ADC = " +
622 std::to_string(refADC) + ", reference scale = " + std::to_string(refScale)));
623
624 (*m_msgFunc_p)(ZDCMsg::Info, std::move(HGParamsStr));
625 (*m_msgFunc_p)(ZDCMsg::Info, std::move(LGParamsStr));
626
627 m_nonLinCorrRefADC = refADC;
628 m_nonLinCorrRefScale = refScale;
629 m_nonLinCorrParamsHG = paramsHG;
630 m_nonLinCorrParamsLG = paramsLG;
631 m_haveNonlinCorr = true;
632 }
633
634 // Provide a historam that provides per-ADC channel correction factors for integral and differential
635 // non-linearities
636 //
637 void enableFADCCorrections(bool correctPerSample, std::unique_ptr<const TH1>& correHistHG, std::unique_ptr<const TH1>& correHistLG);
639
640 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG);
641
642 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG,
643 const std::vector<float>& ADCSamplesHGDelayed, const std::vector<float>& ADCSamplesLGDelayed);
644
645 bool ReanalyzeData();
646
647 bool HaveData() const {return m_haveData;}
648
649 // ------------------------------------------------------------
650 // Status bit setting functions
651 //
652 bool havePulse() const {return m_havePulse;}
653 bool useLowGain() const {return m_useLowGain;}
654 bool failed() const {return m_fail;}
655 bool HGOverflow() const {return m_HGOverflow;}
656
657 bool HGUnderflow() const {return m_HGUnderflow;}
659 bool LGOverflow() const {return m_LGOverflow;}
660 bool LGUnderflow() const {return m_LGUnderflow;}
661
662 bool prePulse() const {return m_prePulse;}
663 bool postPulse() const {return m_postPulse;}
664 bool fitFailed() const {return m_fitFailed;}
665 bool badChisq() const {return m_badChisq;}
666
667 bool badT0() const {return m_badT0;}
668 bool excludeEarlyLG() const {return m_ExcludeEarly;}
669 bool excludeLateLG() const {return m_ExcludeLate;}
670 bool preExpTail() const {return m_preExpTail;}
671 bool fitMinimumAmplitude() const {return m_fitMinAmp;}
672 bool repassPulse() const {return m_repassPulse;}
673 bool armSumInclude() const {return havePulse() && !(failed() || fitFailed() || badChisq() || badT0() || fitMinimumAmplitude() || LGOverflow() || LGUnderflow() || failSigCut());}
674 bool failSigCut() const {return m_failSigCut;}
676
677 // ------------------------------------------------------------
678
679
680 // ---------------------------
681 // Get fit parameters
682 //
683 float GetFitAmplitude() const {return m_fitAmplitude;}
684 float GetFitT0() const {return m_fitTime;}
685 float GetT0Sub() const {return m_fitTimeSub;}
686 float GetT0Corr() const {return m_fitTimeCorr;}
687 float getTimeSig() const {return m_timeSig;}
688 float GetChisq() const {return m_fitChisq;}
689 float GetChisqRatio() const {return m_chisqRatio;}
690 float GetFitTau1() const {return m_fitTau1;}
691 float GetFitTau2() const {return m_fitTau2;}
692 float GetFitPreT0() const {return m_fitPreT0;}
693 float GetFitPreAmp() const {return m_preAmplitude;}
694 float GetFitPostT0() const {return m_fitPostT0;}
695 float GetFitPostAmp() const {return m_postAmplitude;}
696 float GetFitExpAmp() const {return m_fitExpAmp;}
697 // ---------------------------
698
699 float GetAmpNoNonLin() const {return m_ampNoNonLin;}
700 float GetAmplitude() const {return m_amplitude;}
701 float GetAmpError() const {return m_ampError;}
702 float GetPreExpAmp() const {return m_expAmplitude;}
703
704 const std::vector<float>& GetShapeParameters() const {return m_shapeParameters;}
705
706 float getRefitLGAmp() const
707 {
708 if (m_evtLGRefit) return m_refitLGAmpl;
709 else return 0;
710 }
711
712 float getRefitLGFitAmp() const
713 {
714 if (m_evtLGRefit) return m_refitLGFitAmpl;
715 else return 0;
716 }
717
718 float getRefitLGAmpCorr() const
719 {
721 else return 0;
722 }
723
724 float getRefitLGChisq() const
725 {
726 if (m_evtLGRefit) return m_refitLGChisq;
727 else return 0;
728 }
729
731 {
733 else return 0;
734 }
735
736 float getRefitLGTime() const
737 {
738 if (m_evtLGRefit) return m_refitLGTime;
739 else return 0;
740 }
741
742 float getRefitLGTimeSub() const
743 {
744 if (m_evtLGRefit) return m_refitLGTimeSub;
745 else return 0;
746 }
747
748 float getPresample() const {return m_preSample;}
749 float getMaxADCHG() const {return m_maxADCHG;}
750 float getMaxADCLG() const {return m_maxADCLG;}
751 float getMinADCHG() const {return m_minADCHG;}
752 float getMinADCLG() const {return m_minADCLG;}
753
754 float getMaxADCSub() const {
755 float maxADCNosub = m_useLowGain ? m_maxADCLG : m_maxADCHG;
756 return maxADCNosub - m_pedestal - m_preSample;
757 }
758
759 float getMinADCSub() const {
760 float minADCNosub = m_useLowGain ? m_minADCLG : m_minADCHG;
761 return minADCNosub - m_pedestal - m_preSample;
762 }
763
766
769
770 float getADCPeakHG() const {return m_ADCPeakHG;}
771 float getADCPeakLG() const {return m_ADCPeakLG;}
772
773 float GetMaxDelta() const {return m_maxDelta;}
774 float GetMinDelta() const {return m_minDelta;}
775
776 float GetFitTMax() const {return m_fitTMax;}
777 float GetFitTMin() const {return m_fitTMin;}
778
779 float GetdelayBS() const {return m_delayedBaselineShift;}
780
781 float GetMinDeriv2nd() const {return m_minDeriv2nd;}
783
784 unsigned int GetStatusMask() const;
785
786 float GetPreSampleAmp() const {return m_preSampleAmp;}
787 float GetBkgdMaxFraction() const {return m_bkgdMaxFraction;}
788
791
792 const TH1* GetHistogramPtr(bool refitLG = false)
793 {
794 //
795 // We defer filling the histogram if we don't have a pulse until the histogram is requested
796 //
797 if (!m_havePulse) {
798 FillHistogram(refitLG);
799 }
800
801 return refitLG ? m_fitHistLGRefit.get() : m_fitHist.get();
802 }
803
804 std::shared_ptr<TGraphErrors> GetCombinedGraph(bool forceLG = false);
805 std::shared_ptr<TGraphErrors> GetGraph(bool forceLG = false);
806
807 std::vector<float> GetFitPulls(bool forceLG = false) const;
808
809 void dump() const;
810 void dumpConfiguration() const;
811 void dumpTF1(const TF1*) const;
812
813 const std::vector<float>& GetSamplesSub() const {return m_samplesSub;}
814 const std::vector<float>& GetSamplesDeriv2nd() const {return m_samplesDeriv2nd;}
815};
816
817
818#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
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)
const std::string reset
bool fitFailed
@ Info
Definition ZDCMsg.h:20
std::shared_ptr< MessageFunction > MessageFunctionPtr
Definition ZDCMsg.h:14
-event-from-file
void initialize()