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