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;
105 size_t m_2ndDerivStep{1};
110
111 bool m_useDelayed{false};
112
113 bool m_enableRepass{false};
116
117 // Gain factors for low gain and high gain
118 //
121
122 // Uncertainties on the ADC values due to noise
123 //
126
129 std::vector<float> m_setPerSampleNoiseHG;
130 std::vector<float> m_setPerSampleNoiseLG;
131
132 // Default fit values and cuts that can be set via modifier methods
133 //
134 std::string m_fitOptions{};
138
141
146
151
152 //
153 // These two members are an unfortunately necessary temporary addition. Ultimately, constraints
154 // on the pulse model parameters should be better handled in a uniform way.
155 //
158 float m_inductbIHG{-1};
159 float m_inductbILG{-1};
160
161 float m_defaultFitTMax{}; // user-provided upper limit on samples to be included in fit
162 float m_defaultFitTMin{}; // user-provided upper limit on samples to be included in fit
163
164 float m_chisqDivAmpCutLG{}; // maximum good LG chisq / amplitude
165 float m_chisqDivAmpCutHG{}; // maximum good HG chisq / amplitude
166 float m_chisqDivAmpScaleLG{}; // maximum good LG chisq / amplitude
167 float m_chisqDivAmpScaleHG{}; // maximum good HG chisq / amplitude
168 float m_chisqDivAmpOffsetLG{}; // maximum good LG chisq / amplitude
169 float m_chisqDivAmpOffsetHG{}; // maximum good HG chisq / amplitude
170 float m_chisqDivAmpPowerLG{}; // maximum good LG chisq / amplitude
171 float m_chisqDivAmpPowerHG{}; // maximum good HG chisq / amplitude
172
173 float m_T0CutLowLG{}; // minimum good corrected time for LG fits
174 float m_T0CutHighLG{}; // maximum good corrected time for LG fits
175
176 float m_T0CutLowHG{}; // minimum good corrected time for HG fits
177 float m_T0CutHighHG{}; // maximum good corrected time for HG fits
178
179 std::unique_ptr<const TF1> m_timeResFuncHG_p{};
180 std::unique_ptr<const TF1> m_timeResFuncLG_p{};
181 float m_t0CutSig{};
182 unsigned int m_timeCutMode{0}; // 0 - no significance cut, 1 - cut ORed with fixed cut, 2 - cut ANDed with fixed cut
183
184 float m_defaultT0Max{}; // Upper limit on pulse t0
185 float m_defaultT0Min{}; // Lower limit on pulse t0
186
187 float m_fitAmpMinHG{}; // Minimum amplitude in the fit
188 float m_fitAmpMinLG{}; // Minimum amplitude in the fit
189
190 float m_fitAmpMaxHG{}; // Minimum am`plitude in the fit
191 float m_fitAmpMaxLG{}; // Minimum amplitude in the fit
192
193 bool m_haveSignifCuts{false};
194 float m_sigMinHG{}; // Minimum amplitude significance to be considered valid pulse
195 float m_sigMinLG{}; // Minimum amplitude significance to be considered valid pulse
196
197 // Enable or not post-pulse detection and associated parameters
198 //
199 bool m_doPrePulseCheck{false};
200
201 // Enable or not post-pulse detection and associated parameters
202 //
204 unsigned int m_postPulseDelta{0};
208
209 unsigned int m_prePulseDelta{0};
210
211 // Enabling (or not) of exclusion of early or late samples from OOT pileup
212 //
213 bool m_enablePreExcl{false};
214 unsigned int m_maxSamplesPreExcl{0};
215 unsigned int m_preExclHGADCThresh{0};
216 unsigned int m_preExclLGADCThresh{0};
217
218 bool m_enablePostExcl{false};
219 unsigned int m_postExclHGADCThresh{0};
220 unsigned int m_postExclLGADCThresh{0};
221 unsigned int m_maxSamplesPostExcl{0};
222
229
230 //
234 std::vector<float> m_LGT0CorrParams{}; // Parameters used to correct the fit LG times
235 std::vector<float> m_HGT0CorrParams{}; // Parameters used to correct the fit HG times
236
237 bool m_haveNonlinCorr{false};
240 std::vector<float> m_nonLinCorrParamsHG{};
241 std::vector<float> m_nonLinCorrParamsLG{};
242
246 std::unique_ptr<const TH1> m_FADCCorrHG{};
247 std::unique_ptr<const TH1> m_FADCCorrLG{};
248
249 // Histogram used to perform the fits and function wrappers
250 //
251 std::unique_ptr<TH1> m_fitHist{};
252 std::unique_ptr<TH1> m_fitHistLGRefit{};
253
254 bool m_initialized{false};
255 bool m_initializedFits{false};
256
257 std::unique_ptr<ZDCFitWrapper> m_defaultFitWrapperHG{};
258 std::unique_ptr<ZDCFitWrapper> m_defaultFitWrapperLG{};
259 std::unique_ptr<ZDCPrePulseFitWrapper> m_prePulseFitWrapperHG{};
260 std::unique_ptr<ZDCPrePulseFitWrapper> m_prePulseFitWrapperLG{};
261 std::unique_ptr<ZDCPreExpFitWrapper> m_preExpFitWrapperHG{};
262 std::unique_ptr<ZDCPreExpFitWrapper> m_preExpFitWrapperLG{};
263
264 // Members to keep track of adjustments to time range used in analysis/fit
265 //
266 bool m_adjTimeRangeEvent{false}; // indicates whether we adjust the time range for this specific event
267
268 unsigned int m_minSampleEvt{};
269 unsigned int m_maxSampleEvt{};
270
271 // Delayed pulse members
272 //
276 std::unique_ptr<TH1> m_delayedHist{};
277 std::unique_ptr<TH1> m_delayedHistLGRefit{};
278
279 std::unique_ptr<TFitter> m_prePulseCombinedFitter{};
280 std::unique_ptr<TFitter> m_defaultCombinedFitter{};
281
282 // Dynamic data loaded for each pulse (event)
283 // ==========================================
284
285 // -----------------------
286 // Statuses
287 //
288 bool m_haveData{false};
289
290 bool m_havePulse{false};
291 bool m_useLowGain{false};
292 bool m_fail{false};
293 bool m_HGOverflow{false};
294
295 bool m_HGUnderflow{false};
297 bool m_LGOverflow{false};
298 bool m_LGUnderflow{false};
299
300 bool m_prePulse{false};
301 bool m_postPulse{false};
302 bool m_fitFailed{false};
303 bool m_badChisq{false};
304
305 bool m_badT0{false};
306 bool m_ExcludeEarly{false};
307 bool m_ExcludeLate{false};
308 bool m_preExpTail{false};
309
310 bool m_fixPrePulse{false};
311 bool m_fitMinAmp{false};
312 bool m_repassPulse{false};
313 bool m_failSigCut{false};
315
316 // -----------------------
317
318 bool m_backToHG_pre{false};
320
321 // Pulse analysis
322 //
324 float m_preSample{};
325
326 float m_minADCHG{};
327 float m_maxADCHG{};
330
331 float m_maxADCLG{};
332 float m_minADCLG{};
335
336 float m_ADCPeakHG{};
337 float m_ADCPeakLG{};
338
339 float m_maxDelta{};
340 float m_minDelta{};
341
345
346 float m_fitTMax{}; // event-by-event specified fit tmax
347 float m_fitTMin{}; // event-by-event specified fit tmin
348
349 float m_fitPostT0lo{}; // use to assign lower bound of post pulse T0
350
354
357
359
362 float m_fitTime{};
365 float m_timeSig{};
367 float m_fitTau1{};
368 float m_fitTau2{};
369 float m_fitChisq{};
371 float m_fitNDoF{};
372 float m_fitPreT0{};
373 float m_fitPreAmp{};
374 float m_fitPostT0{};
376 float m_fitExpAmp{};
377 float m_amplitude{};
379 float m_ampError{};
386
387 std::vector<float> m_shapeParameters;
388
389 bool m_evtLGRefit{false};
398
401
402 unsigned int m_NSamplesAna{0};
403 std::vector<float> m_ADCSamplesHG;
404 std::vector<float> m_ADCSamplesLG;
405 std::vector<float> m_ADCSamplesHGSub;
406 std::vector<float> m_ADCSamplesLGSub;
407 std::vector<float> m_sampleNoiseHG;
408 std::vector<float> m_sampleNoiseLG;
409
410 std::vector<bool> m_useSampleLG;
411 std::vector<bool> m_useSampleHG;
412
413 std::vector<float> m_ADCSSampNoiseHG;
414 std::vector<float> m_ADCSSampNoiseLG;
415
416 std::vector<float> m_samplesSub;
417 std::vector<float> m_samplesNoise;
418
419 std::vector<float> m_samplesLGRefit;
420 std::vector<float> m_samplesNoiseLGRefit;
421
422 std::vector<float> m_samplesDeriv2nd;
423 std::vector<float> m_samplesDeriv2ndErr;
424
425 // When using combined delayed + undelayed pulses we calculate the chisquare ourselves
426 // so fill this vector as part of that calculation. For the cases where we do not use
427 // delayed samples (2015 and Run3 onward) this vector is not used as the pulls are calculated
428 // when they are fetched.
429 //
430 std::vector<float> m_fitPulls;
431
432 // Private methods
433 //
434 void initialize();
435 void reset(bool reanalyze = false);
436 void setDefaults();
437
438 std::pair<bool, std::string> ValidateJSONConfig(const JSON& config);
439 std::pair<bool, std::string> ConfigFromJSON(const JSON& config);
440
441 void SetupFitFunctions();
442
443 bool DoAnalysis(bool repass);
444
446
447 using ChisqCutLambdatype = std::function<bool(float,float,float, float&)>;
448
449 bool AnalyzeData(size_t nSamples, size_t preSample,
450 const std::vector<float>& samples, // The samples used for this event
451 const std::vector<float>& samplesNoise, // The per-sample noise used for this event
452 const std::vector<bool>& useSamples, // The samples used for this event
453 float peak2ndDerivMinThresh,
454 const std::vector<float>& toCorrParams, // The parameters used to correct the t0
455 ChisqCutLambdatype chisqCutLambda, // Lambda to apply chisq cut
456 float minT0Corr, float maxT0Corr // The minimum and maximum corrected T0 values
457 );
458
459
460 double getAmplitudeCorrection(bool highGain);
461
462 static std::vector<float> calculate2ndDerivative(const std::vector <float>& inputData, unsigned int step);
463
464 static std::pair<std::vector<float>, std::vector<float>>
465 calculate2ndDerivative(const std::vector<float>& inputData, const std::vector<float>& inputNoise, unsigned int step);
466
467 static std::vector<float> calculateDerivative(const std::vector <float>& inputData, unsigned int step);
468 static float obtainDelayedBaselineCorr(const std::vector<float>& samples);
469
470 void prepareLGRefit(const std::vector<float>& samplesLG, const std::vector<float>& samplesNoise,
471 const std::vector<bool>& useSamples);
472
473 void FillHistogram(bool refitLG)
474 {
475
476 if (!m_useDelayed) {
477 if (!refitLG) {
478 const std::vector<bool>& useSample_ref = useLowGain() ? m_useSampleLG : m_useSampleHG;
479
480 // Set the data and errors in the histogram object
481 //
482 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
483 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample]);
484 if (useSample_ref[isample]) m_fitHist->SetBinError(isample + 1, m_samplesNoise[isample]);
485 else m_fitHist->SetBinError(isample + 1, 0);
486 }
487 }
488 else {
489 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
490 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample]);
491 if (m_useSampleLG[isample]) m_fitHistLGRefit->SetBinError(isample + 1, m_samplesNoise[isample]);
492 else m_fitHistLGRefit->SetBinError(isample + 1, 0);
493 }
494 }
495 }
496 else {
497 if (!refitLG) {
498 // Set the data and errors in the histogram object
499 //
500 for (size_t isample = 0; isample < m_Nsample; isample++) {
501 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample * 2]);
502 m_delayedHist->SetBinContent(isample + 1, m_samplesSub[isample * 2 + 1]);
503
504 m_fitHist->SetBinError(isample + 1, m_samplesNoise[isample]);
505 m_delayedHist->SetBinError(isample + 1, m_samplesNoise[isample]);
506 }
507 }
508 else {
509 // Set the data and errors in the histogram object
510 //
511 for (size_t isample = 0; isample < m_Nsample; isample++) {
512 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2]);
513 m_delayedHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2 + 1]);
514
515 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
516 m_delayedHistLGRefit->SetBinError(isample + 1, m_samplesNoiseLGRefit[isample]);
517 }
518 }
519 }
520 }
521
522 void checkTF1Limits(TF1* func);
523
524 void DoFit(bool refitLG = false);
525 void DoFitCombined(bool refitLG = false);
526
527 static std::unique_ptr<TFitter> MakeCombinedFitter(TF1* func);
528
529 // The minuit FCN used for fitting combined undelayed and delayed pulses
530 //
531 static void CombinedPulsesFCN(int& numParam, double*, double& f, double* par, int flag);
532
533 void UpdateFitterTimeLimits(TFitter* fitter, ZDCFitWrapper* wrapper, bool prePulse);
534
535public:
536
537 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const std::string& tag, int Nsample, float deltaTSample, size_t preSampleIdx,
538 int pedestal, const std::string& fitFunction, int peak2ndDerivMinSample, float peak2DerivMinThreshHG,
539 float peak2DerivMinThreshLG);
540
541 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const JSON& configJSON);
542
544
545 void setFitOPtions(const std::string& fitOptions) { m_fitOptions = fitOptions;}
546 void saveFitFunc(bool save) {m_saveFitFunc = save;}
547
548 bool quietFits() const {return m_quietFits;}
549 void setQuietFits() {m_quietFits = true;}
550 void setUnquietFits() {m_quietFits = false;}
551
552 void enableDelayed(float deltaT, float pedestalShift, bool fixedBaseline = false);
553
554 void enableRepass(float peak2ndDerivMinRepassHG, float peak2ndDerivMinRepassLG);
555
556 void enableTimeSigCut(bool AND, float sigCut, const std::string& TF1String,
557 const std::vector<double>& parsHG,
558 const std::vector<double>& parsLG);
559
560 void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
561 {
562 m_enablePreExcl = true;
563 m_maxSamplesPreExcl = maxSamplesExcl;
564 m_preExclHGADCThresh = HGADCThresh;
565 m_preExclLGADCThresh = LGADCThresh;
566 }
567
568 void enablePostExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
569 {
570 m_enablePostExcl = true;
571 m_maxSamplesPostExcl = maxSamplesExcl;
572 m_postExclHGADCThresh = HGADCThresh;
573 m_postExclLGADCThresh = LGADCThresh;
574 }
575
580
581 void setPerSampleNoiseSigmas(const std::vector<float>& sigmaHG, const std::vector<float>& sigmaLG)
582 {
583 m_setPerSampleNoiseHG = sigmaHG;
584 m_setPerSampleNoiseLG = sigmaLG;
587 }
588
589 void setLGMode(unsigned int mode) {m_LGMode = mode;}
590 unsigned int getLGMode() const {return m_LGMode;}
591
592 void set2ndDerivStep(size_t step) {m_2ndDerivStep = step;}
593
594 void SetCutValues(float chisqDivAmpCutHG, float chisqDivAmpCutLG,
595 float deltaT0MinHG, float deltaT0MaxHG,
596 float deltaT0MinLG, float deltaT0MaxLG);
597
598 void SetTimeCuts(float deltaT0MinHG, float deltaT0MaxHG,
599 float deltaT0MinLG, float deltaT0MaxLG);
600
601 void SetChisqCuts(float chisqDivAmpCutHG, float chisqDivAmpScaleHG, float chisqDivAmpOffsetHG, float chisqDivAmpPowerHG,
602 float chisqDivAmpCutLG, float chisqDivAmpScaleLG, float chisqDivAmpOffsetLG, float chisqDivAmpPowerLG);
603
604 void SetNoiseSigmas(float noiseSigHG, float noiseSigLG)
605 {
606 m_noiseSigHG = noiseSigHG;
607 m_noiseSigLG = noiseSigLG;
608 }
609
610 void SetGainFactorsHGLG(float gainFactorHG, float gainFactorLG);
611
612 void SetFitMinMaxAmp(float minAmpHG, float minAmpLG, float maxAmpHG, float maxAmpLG);
613
614 void setMinimumSignificance(float sigMinHG, float sigMinLG);
615
616 void SetTauT0Values(bool fixTau1, bool fixTau2, float tau1, float tau2, float t0HG, float t0LG);
617
618 void enablePostPulseCheck(unsigned int postPulseSampleDelta, float postPulseDerivMinSig, float postPulseAbsDer2ndMinSig, float minMainDer2ndRatio);
620
621 void SetADCOverUnderflowValues(int HGOverflowADC, int HGUnderflowADC, int LGOverflowADC);
622
623 void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale,
624 const std::vector<float>& HGT0CorrParams, const std::vector<float>& LGT0CorrParams)
625 {
626 m_timingCorrMode = mode;
627 if (mode != NoTimingCorr) {
628 m_timingCorrRefADC = refADC;
629 m_timingCorrScale = refScale;
630
631 m_HGT0CorrParams = HGT0CorrParams;
632 m_LGT0CorrParams = LGT0CorrParams;
633 }
634 }
635
636 void SetFitTimeMax(float tmax);
637
638 void SetNonlinCorrParams(float refADC, float refScale, const std::vector<float>& paramsHG, const std::vector<float>& paramsLG)
639 {
640 std::string HGParamsStr = "HG coefficients = ", LGParamsStr = "LG coefficients = ";
641
642 for (auto val : paramsHG) {HGParamsStr += std::to_string(val) + " ";}
643 for (auto val : paramsLG) {LGParamsStr += std::to_string(val) + " ";}
644
645 (*m_msgFunc_p)(ZDCMsg::Info, ("Setting non-linear parameters for module: " + m_tag + ", reference ADC = " +
646 std::to_string(refADC) + ", reference scale = " + std::to_string(refScale)));
647
648 (*m_msgFunc_p)(ZDCMsg::Info, std::move(HGParamsStr));
649 (*m_msgFunc_p)(ZDCMsg::Info, std::move(LGParamsStr));
650
651 m_nonLinCorrRefADC = refADC;
652 m_nonLinCorrRefScale = refScale;
653 m_nonLinCorrParamsHG = paramsHG;
654 m_nonLinCorrParamsLG = paramsLG;
655 m_haveNonlinCorr = true;
656 }
657
658 // Provide a historam that provides per-ADC channel correction factors for integral and differential
659 // non-linearities
660 //
661 void enableFADCCorrections(bool correctPerSample, std::unique_ptr<const TH1>& correHistHG, std::unique_ptr<const TH1>& correHistLG);
663
664 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG);
665
666 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG,
667 const std::vector<float>& ADCSamplesHGDelayed, const std::vector<float>& ADCSamplesLGDelayed);
668
669 bool ReanalyzeData();
670
671 bool HaveData() const {return m_haveData;}
672
673 // ------------------------------------------------------------
674 // Status bit setting functions
675 //
676 bool havePulse() const {return m_havePulse;}
677 bool useLowGain() const {return m_useLowGain;}
678 bool failed() const {return m_fail;}
679 bool HGOverflow() const {return m_HGOverflow;}
680
681 bool HGUnderflow() const {return m_HGUnderflow;}
683 bool LGOverflow() const {return m_LGOverflow;}
684 bool LGUnderflow() const {return m_LGUnderflow;}
685
686 bool prePulse() const {return m_prePulse;}
687 bool postPulse() const {return m_postPulse;}
688 bool fitFailed() const {return m_fitFailed;}
689 bool badChisq() const {return m_badChisq;}
690
691 bool badT0() const {return m_badT0;}
692 bool excludeEarlyLG() const {return m_ExcludeEarly;}
693 bool excludeLateLG() const {return m_ExcludeLate;}
694 bool preExpTail() const {return m_preExpTail;}
695 bool fitMinimumAmplitude() const {return m_fitMinAmp;}
696 bool repassPulse() const {return m_repassPulse;}
697 bool armSumInclude() const {return havePulse() && !(failed() || fitFailed() || badChisq() || badT0() || fitMinimumAmplitude() || LGOverflow() || LGUnderflow() || failSigCut());}
698 bool failSigCut() const {return m_failSigCut;}
700
701 // ------------------------------------------------------------
702
703
704 // ---------------------------
705 // Get fit parameters
706 //
707 float GetFitAmplitude() const {return m_fitAmplitude;}
708 float GetFitT0() const {return m_fitTime;}
709 float GetT0Sub() const {return m_fitTimeSub;}
710 float GetT0Corr() const {return m_fitTimeCorr;}
711 float getTimeSig() const {return m_timeSig;}
712 float GetChisq() const {return m_fitChisq;}
713 float GetChisqRatio() const {return m_chisqRatio;}
714 float GetFitTau1() const {return m_fitTau1;}
715 float GetFitTau2() const {return m_fitTau2;}
716 float GetFitPreT0() const {return m_fitPreT0;}
717 float GetFitPreAmp() const {return m_preAmplitude;}
718 float GetFitPostT0() const {return m_fitPostT0;}
719 float GetFitPostAmp() const {return m_postAmplitude;}
720 float GetFitExpAmp() const {return m_fitExpAmp;}
721 // ---------------------------
722
723 float GetAmpNoNonLin() const {return m_ampNoNonLin;}
724 float GetAmplitude() const {return m_amplitude;}
725 float GetAmpError() const {return m_ampError;}
726 float GetPreExpAmp() const {return m_expAmplitude;}
727
728 const std::vector<float>& GetShapeParameters() const {return m_shapeParameters;}
729
730 float getRefitLGAmp() const
731 {
732 if (m_evtLGRefit) return m_refitLGAmpl;
733 else return 0;
734 }
735
736 float getRefitLGFitAmp() const
737 {
738 if (m_evtLGRefit) return m_refitLGFitAmpl;
739 else return 0;
740 }
741
742 float getRefitLGAmpCorr() const
743 {
745 else return 0;
746 }
747
748 float getRefitLGChisq() const
749 {
750 if (m_evtLGRefit) return m_refitLGChisq;
751 else return 0;
752 }
753
755 {
757 else return 0;
758 }
759
760 float getRefitLGTime() const
761 {
762 if (m_evtLGRefit) return m_refitLGTime;
763 else return 0;
764 }
765
766 float getRefitLGTimeSub() const
767 {
768 if (m_evtLGRefit) return m_refitLGTimeSub;
769 else return 0;
770 }
771
772 float getPresample() const {return m_preSample;}
773 float getMaxADCHG() const {return m_maxADCHG;}
774 float getMaxADCLG() const {return m_maxADCLG;}
775 float getMinADCHG() const {return m_minADCHG;}
776 float getMinADCLG() const {return m_minADCLG;}
777
778 float getMaxADCSub() const {
779 float maxADCNosub = m_useLowGain ? m_maxADCLG : m_maxADCHG;
780 return maxADCNosub - m_pedestal - m_preSample;
781 }
782
783 float getMinADCSub() const {
784 float minADCNosub = m_useLowGain ? m_minADCLG : m_minADCHG;
785 return minADCNosub - m_pedestal - m_preSample;
786 }
787
790
793
794 float getADCPeakHG() const {return m_ADCPeakHG;}
795 float getADCPeakLG() const {return m_ADCPeakLG;}
796
797 float GetMaxDelta() const {return m_maxDelta;}
798 float GetMinDelta() const {return m_minDelta;}
799
800 float GetFitTMax() const {return m_fitTMax;}
801 float GetFitTMin() const {return m_fitTMin;}
802
803 float GetdelayBS() const {return m_delayedBaselineShift;}
804
805 float GetMinDeriv2nd() const {return m_minDeriv2nd;}
807
808 unsigned int GetStatusMask() const;
809
810 float GetPreSampleAmp() const {return m_preSampleAmp;}
811 float GetBkgdMaxFraction() const {return m_bkgdMaxFraction;}
812
815
816 const TH1* GetHistogramPtr(bool refitLG = false)
817 {
818 //
819 // We defer filling the histogram if we don't have a pulse until the histogram is requested
820 //
821 if (!m_havePulse) {
822 FillHistogram(refitLG);
823 }
824
825 return refitLG ? m_fitHistLGRefit.get() : m_fitHist.get();
826 }
827
828 std::shared_ptr<TGraphErrors> GetCombinedGraph(bool forceLG = false);
829 std::shared_ptr<TGraphErrors> GetGraph(bool forceLG = false);
830
831 std::vector<float> GetFitPulls(bool forceLG = false) const;
832
833 void dump() const;
834 void dumpConfiguration() const;
835 void dumpTF1(const TF1*) const;
836
837 const std::vector<float>& GetSamplesSub() const {return m_samplesSub;}
838 const std::vector<float>& GetSamplesDeriv2nd() const {return m_samplesDeriv2nd;}
839};
840
841
842#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::unique_ptr< ZDCFitWrapper > m_defaultFitWrapperLG
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)
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
std::unique_ptr< ZDCFitWrapper > m_defaultFitWrapperHG
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
std::unique_ptr< ZDCPreExpFitWrapper > m_preExpFitWrapperHG
static float s_combinedFitTMin
std::vector< float > m_nonLinCorrParamsHG
std::unique_ptr< ZDCPreExpFitWrapper > m_preExpFitWrapperLG
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
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
std::unique_ptr< ZDCPrePulseFitWrapper > m_prePulseFitWrapperLG
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
std::string m_fitParameterSetHG
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
std::unique_ptr< ZDCPrePulseFitWrapper > m_prePulseFitWrapperHG
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
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
std::string m_fitParameterSetLG
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()