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
125 // Default fit values and cuts that can be set via modifier methods
126 //
127 std::string m_fitOptions{};
131
134
137
138 bool m_fixTau1{};
139 bool m_fixTau2{};
140
141 float m_defaultFitTMax{}; // user-provided upper limit on samples to be included in fit
142 float m_defaultFitTMin{}; // user-provided upper limit on samples to be included in fit
143
144 float m_chisqDivAmpCutLG{}; // maximum good LG chisq / amplitude
145 float m_chisqDivAmpCutHG{}; // maximum good HG chisq / amplitude
146 float m_chisqDivAmpOffsetLG{}; // maximum good LG chisq / amplitude
147 float m_chisqDivAmpOffsetHG{}; // maximum good HG chisq / amplitude
148 float m_chisqDivAmpPowerLG{}; // maximum good LG chisq / amplitude
149 float m_chisqDivAmpPowerHG{}; // maximum good HG chisq / amplitude
150
151 float m_T0CutLowLG{}; // minimum good corrected time for LG fits
152 float m_T0CutHighLG{}; // maximum good corrected time for LG fits
153
154 float m_T0CutLowHG{}; // minimum good corrected time for HG fits
155 float m_T0CutHighHG{}; // maximum good corrected time for HG fits
156
157 std::unique_ptr<const TF1> m_timeResFuncHG_p{};
158 std::unique_ptr<const TF1> m_timeResFuncLG_p{};
159 float m_t0CutSig{};
160 unsigned int m_timeCutMode{0}; // 0 - no significance cut, 1 - cut ORed with fixed cut, 2 - cut ANDed with fixed cut
161
162 float m_defaultT0Max{}; // Upper limit on pulse t0
163 float m_defaultT0Min{}; // Lower limit on pulse t0
164
165 float m_fitAmpMinHG{}; // Minimum amplitude in the fit
166 float m_fitAmpMinLG{}; // Minimum amplitude in the fit
167
168 float m_fitAmpMaxHG{}; // Minimum am`plitude in the fit
169 float m_fitAmpMaxLG{}; // Minimum amplitude in the fit
170
171 bool m_haveSignifCuts{false};
172 float m_sigMinHG{}; // Minimum amplitude significance to be considered valid pulse
173 float m_sigMinLG{}; // Minimum amplitude significance to be considered valid pulse
174
175 // Enabling (or not) of exclusion of early or late samples from OOT pileup
176 //
177 bool m_enablePreExcl{false};
178 unsigned int m_maxSamplesPreExcl{0};
179 unsigned int m_preExclHGADCThresh{0};
180 unsigned int m_preExclLGADCThresh{0};
181
182 bool m_enablePostExcl{false};
183 unsigned int m_postExclHGADCThresh{0};
184 unsigned int m_postExclLGADCThresh{0};
185 unsigned int m_maxSamplesPostExcl{0};
186
193
194 //
198 std::vector<float> m_LGT0CorrParams{}; // Parameters used to correct the fit LG times
199 std::vector<float> m_HGT0CorrParams{}; // Parameters used to correct the fit HG times
200
201 bool m_haveNonlinCorr{false};
204 std::vector<float> m_nonLinCorrParamsHG{};
205 std::vector<float> m_nonLinCorrParamsLG{};
206
210 std::unique_ptr<const TH1> m_FADCCorrHG{};
211 std::unique_ptr<const TH1> m_FADCCorrLG{};
212
213 // Histogram used to perform the fits and function wrappers
214 //
215 std::unique_ptr<TH1> m_fitHist{};
216 std::unique_ptr<TH1> m_fitHistLGRefit{};
217
218 bool m_initializedFits{false};
219 std::unique_ptr<ZDCFitWrapper> m_defaultFitWrapper{};
220 std::unique_ptr<ZDCPrePulseFitWrapper> m_prePulseFitWrapper{};
221 std::unique_ptr<ZDCPreExpFitWrapper> m_preExpFitWrapper{};
222
223 // Members to keep track of adjustments to time range used in analysis/fit
224 //
225 bool m_adjTimeRangeEvent{false}; // indicates whether we adjust the time range for this specific event
226
227 unsigned int m_minSampleEvt{};
228 unsigned int m_maxSampleEvt{};
229
230 // Delayed pulse members
231 //
235 std::unique_ptr<TH1> m_delayedHist{};
236 std::unique_ptr<TH1> m_delayedHistLGRefit{};
237
238 std::unique_ptr<TFitter> m_prePulseCombinedFitter{};
239 std::unique_ptr<TFitter> m_defaultCombinedFitter{};
240
241 // Dynamic data loaded for each pulse (event)
242 // ==========================================
243
244 // -----------------------
245 // Statuses
246 //
247 bool m_haveData{false};
248
249 bool m_havePulse{false};
250 bool m_useLowGain{false};
251 bool m_fail{false};
252 bool m_HGOverflow{false};
253
254 bool m_HGUnderflow{false};
256 bool m_LGOverflow{false};
257 bool m_LGUnderflow{false};
258
259 bool m_prePulse{false};
260 bool m_postPulse{false};
261 bool m_fitFailed{false};
262 bool m_badChisq{false};
263
264 bool m_badT0{false};
265 bool m_ExcludeEarly{false};
266 bool m_ExcludeLate{false};
267 bool m_preExpTail{false};
268
269 bool m_fixPrePulse{false};
270 bool m_fitMinAmp{false};
271 bool m_repassPulse{false};
272 bool m_failSigCut{false};
274
275 // -----------------------
276
277 bool m_backToHG_pre{false};
279
280 // Pulse analysis
281 //
283 float m_preSample{};
284
285 float m_minADCHG{};
286 float m_maxADCHG{};
289
290 float m_maxADCLG{};
291 float m_minADCLG{};
294
295 float m_ADCPeakHG{};
296 float m_ADCPeakLG{};
297
298 float m_maxDelta{};
299 float m_minDelta{};
300
304
305 float m_fitTMax{}; // event-by-event specified fit tmax
306 float m_fitTMin{}; // event-by-event specified fit tmin
307
308 float m_fitPostT0lo{}; // use to assign lower bound of post pulse T0
309
313
316
318
321 float m_fitTime{};
324 float m_timeSig{};
326 float m_fitTau1{};
327 float m_fitTau2{};
328 float m_fitChisq{};
329 float m_fitNDoF{};
330 float m_fitPreT0{};
331 float m_fitPreAmp{};
332 float m_fitPostT0{};
334 float m_fitExpAmp{};
335 float m_amplitude{};
337 float m_ampError{};
344
345 bool m_evtLGRefit{false};
353
356
357 unsigned int m_NSamplesAna{0};
358 std::vector<float> m_ADCSamplesHG;
359 std::vector<float> m_ADCSamplesLG;
360 std::vector<float> m_ADCSamplesHGSub;
361 std::vector<float> m_ADCSamplesLGSub;
362
363 std::vector<bool> m_useSampleLG;
364 std::vector<bool> m_useSampleHG;
365
366 std::vector<float> m_ADCSSampSigHG;
367 std::vector<float> m_ADCSSampSigLG;
368
369 std::vector<float> m_samplesSub;
370 std::vector<float> m_samplesSig;
371
372 std::vector<float> m_samplesLGRefit;
373 std::vector<float> m_samplesSigLGRefit;
374
375 std::vector<float> m_samplesDeriv2nd;
376
377 // When using combined delayed + undelayed pulses we calculate the chisquare ourselves
378 // so fill this vector as part of that calculation. For the cases where we do not use
379 // delayed samples (2015 and Run3 onward) this vector is not used as the pulls are calculated
380 // when they are fetched.
381 //
382 std::vector<float> m_fitPulls;
383
384 // Private methods
385 //
386 void Reset(bool reanalyze = false);
387 void SetDefaults();
388
389 std::pair<bool, std::string> ValidateJSONConfig(const JSON& config);
390 std::pair<bool, std::string> ConfigFromJSON(const JSON& config);
391
392 void SetupFitFunctions();
393
394 bool DoAnalysis(bool repass);
395
397
398 using ChisqCutLambdatype = std::function<bool(float,float,float)>;
399 bool AnalyzeData(size_t nSamples, size_t preSample,
400 const std::vector<float>& samples, // The samples used for this event
401 const std::vector<bool>& useSamples, // The samples used for this event
402 float peak2ndDerivMinThresh,
403 float noiseSig, // The "resolution" on the ADC value
404 const std::vector<float>& toCorrParams, // The parameters used to correct the t0
405 ChisqCutLambdatype chisqCutLambda, // Lambda to apply chisq cut
406 float minT0Corr, float maxT0Corr // The minimum and maximum corrected T0 values
407 );
408
409
410 double getAmplitudeCorrection(bool highGain);
411
412 static std::vector<float> Calculate2ndDerivative(const std::vector <float>& inputData, unsigned int step);
413 static std::vector<float> CalculateDerivative(const std::vector <float>& inputData, unsigned int step);
414 static float obtainDelayedBaselineCorr(const std::vector<float>& samples);
415
416 void prepareLGRefit(const std::vector<float>& samplesLG, const std::vector<float>& samplesSig,
417 const std::vector<bool>& useSamples);
418
419 void FillHistogram(bool refitLG)
420 {
421 if (!m_useDelayed) {
422 if (!refitLG) {
423 // Set the data and errors in the histogram object
424 //
425 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
426 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample]);
427 m_fitHist->SetBinError(isample + 1, m_samplesSig[isample]);
428 }
429 }
430 else {
431 for (size_t isample = 0; isample < m_NSamplesAna; isample++) {
432 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample]);
433 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesSigLGRefit[isample]);
434 }
435 }
436 }
437 else {
438 if (!refitLG) {
439 // Set the data and errors in the histogram object
440 //
441 for (size_t isample = 0; isample < m_Nsample; isample++) {
442 m_fitHist->SetBinContent(isample + 1, m_samplesSub[isample * 2]);
443 m_delayedHist->SetBinContent(isample + 1, m_samplesSub[isample * 2 + 1]);
444
445 m_fitHist->SetBinError(isample + 1, m_samplesSig[isample]);
446 m_delayedHist->SetBinError(isample + 1, m_samplesSig[isample]);
447 }
448 }
449 else {
450 // Set the data and errors in the histogram object
451 //
452 for (size_t isample = 0; isample < m_Nsample; isample++) {
453 m_fitHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2]);
454 m_delayedHistLGRefit->SetBinContent(isample + 1, m_samplesLGRefit[isample * 2 + 1]);
455
456 m_fitHistLGRefit->SetBinError(isample + 1, m_samplesSigLGRefit[isample]);
457 m_delayedHistLGRefit->SetBinError(isample + 1, m_samplesSigLGRefit[isample]);
458 }
459 }
460 }
461 }
462
463 void checkTF1Limits(TF1* func);
464
465 void DoFit(bool refitLG = false);
466 void DoFitCombined(bool refitLG = false);
467
468 static std::unique_ptr<TFitter> MakeCombinedFitter(TF1* func);
469
470 // The minuit FCN used for fitting combined undelayed and delayed pulses
471 //
472 static void CombinedPulsesFCN(int& numParam, double*, double& f, double* par, int flag);
473
474 void UpdateFitterTimeLimits(TFitter* fitter, ZDCFitWrapper* wrapper, bool prePulse);
475
476public:
477
478 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const std::string& tag, int Nsample, float deltaTSample, size_t preSampleIdx,
479 int pedestal, const std::string& fitFunction, int peak2ndDerivMinSample, float peak2DerivMinThreshHG,
480 float peak2DerivMinThreshLG);
481
482 ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const JSON& configJSON);
483
485
486 void setFitOPtions(const std::string& fitOptions) { m_fitOptions = fitOptions;}
487 void saveFitFunc() {m_saveFitFunc = true;}
488
489 bool quietFits() const {return m_quietFits;}
490 void setQuietFits() {m_quietFits = true;}
491 void setUnquietFits() {m_quietFits = false;}
492
493 void enableDelayed(float deltaT, float pedestalShift, bool fixedBaseline = false);
494
495 void enableRepass(float peak2ndDerivMinRepassHG, float peak2ndDerivMinRepassLG);
496
497 void enableTimeSigCut(bool AND, float sigCut, const std::string& TF1String,
498 const std::vector<double>& parsHG,
499 const std::vector<double>& parsLG);
500
501 void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
502 {
503 m_enablePreExcl = true;
504 m_maxSamplesPreExcl = maxSamplesExcl;
505 m_preExclHGADCThresh = HGADCThresh;
506 m_preExclLGADCThresh = LGADCThresh;
507 }
508
509 void enablePostExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
510 {
511 m_enablePostExcl = true;
512 m_maxSamplesPostExcl = maxSamplesExcl;
513 m_postExclHGADCThresh = HGADCThresh;
514 m_postExclLGADCThresh = LGADCThresh;
515 }
516
521
522 void setLGMode(unsigned int mode) {m_LGMode = mode;}
523 unsigned int getLGMode() const {return m_LGMode;}
524
525 void set2ndDerivStep(size_t step) {m_2ndDerivStep = step;}
526
527 void SetCutValues(float chisqDivAmpCutHG, float chisqDivAmpCutLG,
528 float deltaT0MinHG, float deltaT0MaxHG,
529 float deltaT0MinLG, float deltaT0MaxLG) ;
530
531 void SetNoiseSigmas(float noiseSigHG, float noiseSigLG)
532 {
533 m_noiseSigHG = noiseSigHG;
534 m_noiseSigLG = noiseSigLG;
535 }
536
537 void SetGainFactorsHGLG(float gainFactorHG, float gainFactorLG);
538
539 void SetFitMinMaxAmp(float minAmpHG, float minAmpLG, float maxAmpHG, float maxAmpLG);
540
541 void setMinimumSignificance(float sigMinHG, float sigMinLG);
542
543 void SetTauT0Values(bool fixTau1, bool fixTau2, float tau1, float tau2, float t0HG, float t0LG);
544
545 void SetADCOverUnderflowValues(int HGOverflowADC, int HGUnderflowADC, int LGOverflowADC);
546
547 void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale,
548 const std::vector<float>& HGT0CorrParams, const std::vector<float>& LGT0CorrParams)
549 {
550 m_timingCorrMode = mode;
551 if (mode != NoTimingCorr) {
552 m_timingCorrRefADC = refADC;
553 m_timingCorrScale = refScale;
554
555 m_HGT0CorrParams = HGT0CorrParams;
556 m_LGT0CorrParams = LGT0CorrParams;
557 }
558 }
559
560 void SetFitTimeMax(float tmax);
561
562 void SetNonlinCorrParams(float refADC, float refScale, const std::vector<float>& paramsHG, const std::vector<float>& paramsLG)
563 {
564 std::string HGParamsStr = "HG coefficients = ", LGParamsStr = "LG coefficients = ";
565
566 for (auto val : paramsHG) {HGParamsStr += std::to_string(val) + " ";}
567 for (auto val : paramsLG) {LGParamsStr += std::to_string(val) + " ";}
568
569 (*m_msgFunc_p)(ZDCMsg::Info, ("Setting non-linear parameters for module: " + m_tag + ", reference ADC = " +
570 std::to_string(refADC) + ", reference scale = " + std::to_string(refScale)));
571
572 (*m_msgFunc_p)(ZDCMsg::Info, std::move(HGParamsStr));
573 (*m_msgFunc_p)(ZDCMsg::Info, std::move(LGParamsStr));
574
575 m_nonLinCorrRefADC = refADC;
576 m_nonLinCorrRefScale = refScale;
577 m_nonLinCorrParamsHG = paramsHG;
578 m_nonLinCorrParamsLG = paramsLG;
579 m_haveNonlinCorr = true;
580 }
581
582 // Provide a historam that provides per-ADC channel correction factors for integral and differential
583 // non-linearities
584 //
585 void enableFADCCorrections(bool correctPerSample, std::unique_ptr<const TH1>& correHistHG, std::unique_ptr<const TH1>& correHistLG);
587
588 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG);
589
590 bool LoadAndAnalyzeData(const std::vector<float>& ADCSamplesHG, const std::vector<float>& ADCSamplesLG,
591 const std::vector<float>& ADCSamplesHGDelayed, const std::vector<float>& ADCSamplesLGDelayed);
592
593 bool ReanalyzeData();
594
595 bool HaveData() const {return m_haveData;}
596
597 // ------------------------------------------------------------
598 // Status bit setting functions
599 //
600 bool havePulse() const {return m_havePulse;}
601 bool useLowGain() const {return m_useLowGain;}
602 bool failed() const {return m_fail;}
603 bool HGOverflow() const {return m_HGOverflow;}
604
605 bool HGUnderflow() const {return m_HGUnderflow;}
607 bool LGOverflow() const {return m_LGOverflow;}
608 bool LGUnderflow() const {return m_LGUnderflow;}
609
610 bool prePulse() const {return m_prePulse;}
611 bool postPulse() const {return m_postPulse;}
612 bool fitFailed() const {return m_fitFailed;}
613 bool badChisq() const {return m_badChisq;}
614
615 bool badT0() const {return m_badT0;}
616 bool excludeEarlyLG() const {return m_ExcludeEarly;}
617 bool excludeLateLG() const {return m_ExcludeLate;}
618 bool preExpTail() const {return m_preExpTail;}
619 bool fitMinimumAmplitude() const {return m_fitMinAmp;}
620 bool repassPulse() const {return m_repassPulse;}
621 bool armSumInclude() const {return havePulse() && !(failed() || fitFailed() || badChisq() || badT0() || fitMinimumAmplitude() || LGOverflow() || LGUnderflow() || failSigCut());}
622 bool failSigCut() const {return m_failSigCut;}
624
625 // ------------------------------------------------------------
626
627
628 // ---------------------------
629 // Get fit parameters
630 //
631 float GetFitAmplitude() const {return m_fitAmplitude;}
632 float GetFitT0() const {return m_fitTime;}
633 float GetT0Sub() const {return m_fitTimeSub;}
634 float GetT0Corr() const {return m_fitTimeCorr;}
635 float getTimeSig() const {return m_timeSig;}
636 float GetChisq() const {return m_fitChisq;}
637 float GetFitTau1() const {return m_fitTau1;}
638 float GetFitTau2() const {return m_fitTau2;}
639 float GetFitPreT0() const {return m_fitPreT0;}
640 float GetFitPreAmp() const {return m_preAmplitude;}
641 float GetFitPostT0() const {return m_fitPostT0;}
642 float GetFitPostAmp() const {return m_postAmplitude;}
643 float GetFitExpAmp() const {return m_fitExpAmp;}
644 // ---------------------------
645
646 float GetAmpNoNonLin() const {return m_ampNoNonLin;}
647 float GetAmplitude() const {return m_amplitude;}
648 float GetAmpError() const {return m_ampError;}
649 float GetPreExpAmp() const {return m_expAmplitude;}
650
651 float getRefitLGAmp() const
652 {
653 if (m_evtLGRefit) return m_refitLGAmpl;
654 else return 0;
655 }
656
657 float getRefitLGFitAmp() const
658 {
659 if (m_evtLGRefit) return m_refitLGFitAmpl;
660 else return 0;
661 }
662
663 float getRefitLGAmpCorr() const
664 {
666 else return 0;
667 }
668
669 float getRefitLGChisq() const
670 {
671 if (m_evtLGRefit) return m_refitLGChisq;
672 else return 0;
673 }
674
675 float getRefitLGTime() const
676 {
677 if (m_evtLGRefit) return m_refitLGTime;
678 else return 0;
679 }
680
681 float getRefitLGTimeSub() const
682 {
683 if (m_evtLGRefit) return m_refitLGTimeSub;
684 else return 0;
685 }
686
687 float getPresample() const {return m_preSample;}
688 float getMaxADCHG() const {return m_maxADCHG;}
689 float getMaxADCLG() const {return m_maxADCLG;}
690 float getMinADCHG() const {return m_minADCHG;}
691 float getMinADCLG() const {return m_minADCLG;}
692
693 float getMaxADCSub() const {
694 float maxADCNosub = m_useLowGain ? m_maxADCLG : m_maxADCHG;
695 return maxADCNosub - m_pedestal - m_preSample;
696 }
697
698 float getMinADCSub() const {
699 float minADCNosub = m_useLowGain ? m_minADCLG : m_minADCHG;
700 return minADCNosub - m_pedestal - m_preSample;
701 }
702
705
708
709 float getADCPeakHG() const {return m_ADCPeakHG;}
710 float getADCPeakLG() const {return m_ADCPeakLG;}
711
712 float GetMaxDelta() const {return m_maxDelta;}
713 float GetMinDelta() const {return m_minDelta;}
714
715 float GetFitTMax() const {return m_fitTMax;}
716 float GetFitTMin() const {return m_fitTMin;}
717
718 float GetdelayBS() const {return m_delayedBaselineShift;}
719
720 float GetMinDeriv2nd() const {return m_minDeriv2nd;}
722
723 unsigned int GetStatusMask() const;
724
725 float GetPreSampleAmp() const {return m_preSampleAmp;}
726 float GetBkgdMaxFraction() const {return m_bkgdMaxFraction;}
727
730
731 const TH1* GetHistogramPtr(bool refitLG = false)
732 {
733 //
734 // We defer filling the histogram if we don't have a pulse until the histogram is requested
735 //
736 if (!m_havePulse) {
737 FillHistogram(refitLG);
738 }
739
740 return refitLG ? m_fitHistLGRefit.get() : m_fitHist.get();
741 }
742
743 std::shared_ptr<TGraphErrors> GetCombinedGraph(bool forceLG = false);
744 std::shared_ptr<TGraphErrors> GetGraph(bool forceLG = false);
745
746 std::vector<float> GetFitPulls(bool forceLG = false) const;
747
748 void dump() const;
749 void dumpConfiguration() const;
750 void dumpTF1(const TF1*) const;
751
752 const std::vector<float>& GetSamplesSub() const {return m_samplesSub;}
753 const std::vector<float>& GetSamplesDeriv2nd() const {return m_samplesDeriv2nd;}
754};
755
756
757#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
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_ADCSSampSigHG
std::vector< float > m_nonLinCorrParamsLG
int getMaxADCSampleLG() const
float GetFitPostT0() const
bool excludeEarlyLG() const
float GetAmplitude() const
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)
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
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
void prepareLGRefit(const std::vector< float > &samplesLG, const std::vector< float > &samplesSig, const std::vector< bool > &useSamples)
unsigned int m_preExclLGADCThresh
float getMinADCHG() const
bool useLowGain() const
std::vector< float > m_ADCSSampSigLG
unsigned int m_postExclLGADCThresh
unsigned int m_NSamplesAna
bool DoAnalysis(bool repass)
std::vector< float > m_samplesSig
float GetDelayedBaselineShiftFit() const
std::unique_ptr< TH1 > m_delayedHistLGRefit
unsigned int getLGMode() const
bool HGUnderflow() const
unsigned int m_timingCorrMode
static std::vector< float > Calculate2ndDerivative(const std::vector< float > &inputData, unsigned int step)
unsigned int m_maxSampleEvt
float getRefitLGAmp() const
bool fitFailed() const
unsigned int m_maxSamplesPreExcl
std::string m_fitOptions
std::vector< float > m_ADCSamplesLG
unsigned int m_underFlowExclSamplesPreLG
static float s_combinedFitTMin
std::vector< float > m_nonLinCorrParamsHG
ZDCPulseAnalyzer(ZDCMsg::MessageFunctionPtr msgFunc_p, const std::string &tag, int Nsample, float deltaTSample, size_t preSampleIdx, int pedestal, const std::string &fitFunction, int peak2ndDerivMinSample, float peak2DerivMinThreshHG, float peak2DerivMinThreshLG)
void setFitOPtions(const std::string &fitOptions)
unsigned int m_underFlowExclSamplesPostHG
static std::vector< float > CalculateDerivative(const std::vector< float > &inputData, unsigned int step)
unsigned int m_maxSamplesPostExcl
float getADCPeakLG() const
int getMaxADCSampleHG() const
std::vector< float > m_ADCSamplesHGSub
std::unique_ptr< ZDCPrePulseFitWrapper > m_prePulseFitWrapper
void setLGMode(unsigned int mode)
float getRefitLGChisq() const
static float obtainDelayedBaselineCorr(const std::vector< float > &samples)
double getAmplitudeCorrection(bool highGain)
float 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
bool AnalyzeData(size_t nSamples, size_t preSample, const std::vector< float > &samples, const std::vector< bool > &useSamples, float peak2ndDerivMinThresh, float noiseSig, const std::vector< float > &toCorrParams, ChisqCutLambdatype chisqCutLambda, float minT0Corr, float maxT0Corr)
std::vector< bool > m_useSampleLG
float GetPreExpAmp() const
float GetdelayBS() const
float GetAmpNoNonLin() const
unsigned int m_underFlowExclSamplesPostLG
std::vector< float > m_ADCSamplesHG
bool quietFits() const
std::vector< float > m_samplesSigLGRefit
unsigned int m_Nsample
float getRefitLGTimeSub() const
bool armSumInclude() const
std::function< bool(float, float, float)> ChisqCutLambdatype
std::vector< float > m_HGT0CorrParams
void enablePreExclusion(unsigned int maxSamplesExcl, unsigned int HGADCThresh, unsigned int LGADCThresh)
float getMaxADCHG() const
std::unique_ptr< TH1 > m_fitHistLGRefit
std::unique_ptr< TH1 > m_delayedHist
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
bool PSHGOverUnderflow() const
float getRefitLGFitAmp() const
float GetMinDeriv2nd() const
float GetFitPreAmp() const
float getPresample() const
bool postPulse() const
unsigned int m_postExclHGADCThresh
bool repassPulse() const
bool LGUnderflow() const
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
float getMaxADCSub() const
std::unique_ptr< ZDCPreExpFitWrapper > m_preExpFitWrapper
float GetPreSampleAmp() const
float getRefitLGTime() const
void Reset(bool reanalyze=false)
ZDCMsg::MessageFunctionPtr m_msgFunc_p
void FillHistogram(bool refitLG)
std::vector< float >::const_iterator SampleCIter
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
void SetTimingCorrParams(TimingCorrMode mode, float refADC, float refScale, const std::vector< float > &HGT0CorrParams, const std::vector< float > &LGT0CorrParams)
bool fitFailed
@ Info
Definition ZDCMsg.h:20
std::shared_ptr< MessageFunction > MessageFunctionPtr
Definition ZDCMsg.h:14
-event-from-file