ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcAnalysisTool.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_ZDCANALYSISTOOL_H
6#define ZDCANALYSIS_ZDCANALYSISTOOL_H
7
8#include "AsgTools/AsgTool.h"
11
13
17#include "ZdcAnalysis/ZDCMsg.h"
18
19#include "TF1.h"
20
23#include <memory>
24
25
26namespace ZDC
27{
28
30{
31
33
34public:
35 ZdcAnalysisTool(const std::string& name);
36 virtual ~ZdcAnalysisTool() override;
38
39 //interface from AsgTool
40 StatusCode initialize() override;
41 void initialize80MHz();
42 void initialize40MHz();
43 void initializeTriggerEffs(unsigned int runNumber);
44
45 StatusCode recoZdcModules(const xAOD::ZdcModuleContainer& moduleContainer, const xAOD::ZdcModuleContainer& moduleSumContainer) override;
46 StatusCode reprocessZdc() override;
47
48 // methods for processing, used for decoration
49 static bool sigprocMaxFinder(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual);
50 bool sigprocSincInterp(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual);
51
52 void setEnergyCalibrations(unsigned int runNumber);
53 void setTimeCalibrations(unsigned int runNumber);
54 void setFADCCorrections(unsigned int runNumber = 0);
55
56 float getModuleSum(int side);
57
58 float getCalibModuleSum(int side);
59 float getCalibModuleSumErr(int side);
60
61 float getNLCalibModuleSum(int side);
62 float getNLCalibModuleSumErr(int side);
63
64 float getUncalibModuleSum(int side);
65 float getUncalibModuleSumErr(int side);
66
67 float getAverageTime(int side);
68 bool sideFailed(int side);
69 unsigned int getModuleMask();
70
71 double getTriggerEfficiency(int side);
72 double getTriggerEfficiencyUncertainty(int side);
73
75
76 static void SetDebugLevel(int debugLevel = 0)
77 {
78 s_debugLevel = debugLevel;
79 }
80
82 {
83 std::function<bool(int, std::string)> msgFunction = [this](int messageZdcLevel, const std::string& message)-> bool
84 {
85 MSG::Level messageAthenaLevel = static_cast<MSG::Level>(messageZdcLevel);
86 bool passesStreamOutputLevel = messageAthenaLevel >= this->msg().level();
87 if (passesStreamOutputLevel) {
88 this->msg(messageAthenaLevel) << message << endmsg;
89 }
90 return passesStreamOutputLevel;
91 };
92
93 return ZDCMsg::MessageFunctionPtr(new ZDCMsg::MessageFunction(std::move(msgFunction)));
94 }
95
96 void Dump_setting() {
97 ATH_MSG_INFO("========================================================================================================================");
98 for (int i = 0; i < 2; i++) {
99 for (int j = 0; j < 4; j++) {
100 ATH_MSG_INFO("-------------------------------------------------------------------------------------------------------------------");
101 ATH_MSG_INFO("Side: " << i << ", Module: " << j);
102 m_zdcDataAnalyzer->GetPulseAnalyzer(i, j)->dumpConfiguration();
103 }
104 }
105 ATH_MSG_INFO("========================================================================================================================");
106 }
107
108private:
109 // Private methods
110 //
111 std::unique_ptr<ZDCDataAnalyzer> initializeDefault();
112 std::unique_ptr<ZDCDataAnalyzer> initializePbPb2015G4();
113 std::unique_ptr<ZDCDataAnalyzer> initializepPb2016();
114 std::unique_ptr<ZDCDataAnalyzer> initializePbPb2018();
115 std::unique_ptr<ZDCDataAnalyzer> initializeLHCf2022();
116 std::unique_ptr<ZDCDataAnalyzer> initializepp2023();
117 std::unique_ptr<ZDCDataAnalyzer> initializePbPb2023();
118 std::unique_ptr<ZDCDataAnalyzer> initializepp2024();
119 std::unique_ptr<ZDCDataAnalyzer> initializePbPb2024();
120 std::unique_ptr<ZDCDataAnalyzer> initializeOONeNe2025();
121 std::unique_ptr<ZDCDataAnalyzer> initializepO2025();
122 std::unique_ptr<ZDCDataAnalyzer> initializepO2025B();
123 std::unique_ptr<ZDCDataAnalyzer> initializeInjectorpp2024();
124 std::unique_ptr<ZDCDataAnalyzer> initializeInjectorPbPb2024();
125 std::unique_ptr<ZDCDataAnalyzer> initializeInjectorpOOONeNe2025();
126 std::unique_ptr<ZDCDataAnalyzer> initializeMonteCarloPbPb2023();
127 std::unique_ptr<ZDCDataAnalyzer> initializeFromJSON();
128
129 StatusCode configureNewRun(unsigned int runNumber);
130
131 // Data members
132 //
133 std::string m_name;
134 bool m_init;
135 std::string m_configuration;
141
143 std::string m_auxSuffix;
144
146 unsigned int m_runNumber;
147 unsigned int m_lumiBlock;
148
149 // internal functions
150 std::unique_ptr<TF1> m_tf1SincInterp;
151
153 this, "EventInfoKey", "EventInfo",
154 "Location of the event info."};
155
161 unsigned int m_lowGainMode;
162 bool m_combineDelay{false};
163 bool m_doCalib{false};
164 bool m_doTrigEff{false};
165 bool m_doTimeCalib{false};
166 bool m_doFADCCorr{false};
167 bool m_doNonLinCorr{false};
171 std::string m_calibVersion;
172
173 // Parameters that control the pulse fitting analysis
174 //
175 unsigned int m_numSample;
177 unsigned int m_presample;
178 unsigned int m_peakSample;
180 float m_t0;
182 float m_tau1;
183 float m_tau2;
188
190
191 // The objects that carry out the analysis
192 //
193 std::shared_ptr<ZDCDataAnalyzer> m_zdcDataAnalyzer;
194 std::shared_ptr<ZDCDataAnalyzer> m_zdcDataAnalyzer_40MHz;
195 std::shared_ptr<ZDCDataAnalyzer> m_zdcDataAnalyzer_80MHz;
196
200
201
202 std::shared_ptr<ZDCTriggerEfficiency> m_zdcTriggerEfficiency;
203
204 static std::atomic<int> s_debugLevel;
205
206 // decoration list for ZDC modules
207 // ZDC
208 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmplitude{this, "ZdcModuleAmplitude", "", "ZDC module amplitude"};
209 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleCalibEnergy{this, "ZdcModuleCalibEnergy", "", "ZDC module calibrated energy"};
210 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleNLCalibEnergy{this, "ZdcModuleNLCalibEnergy", "", "ZDC module NL calibrated energy"};
211 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleCalibTime{this, "ZdcModuleCalibTime", "", "ZDC module calibrated time"};
212 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleStatus{this, "ZdcModuleStatus", "", "ZDC module fit status"};
213 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleTime{this, "ZdcModuleTime", "", "ZDC module time"};
214 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleChisq{this, "ZdcModuleChisq", "", "ZDC module fit chisq"};
215 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmpNoNonLin{this, "ZdcModuleAmpNoNonLin", "", "ZDC module amplitude with gain factor applied but no nonlinear correction"};
216 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitAmp{this, "ZdcModuleFitAmp", "", "ZDC module fit amp"};
217 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitAmpError{this, "ZdcModuleFitAmpError", "", "ZDC module fit amp error"};
218 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitT0{this, "ZdcModuleFitT0", "", "ZDC module fit t0"};
219 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleBkgdMaxFraction{this, "ZdcModuleBkgdMaxFraction", "", "ZDC module background max fraction"};
220 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModulePreSampleAmp{this, "ZdcModulePreSampleAmp", "", "ZDC module presample amplitude"};
221 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModulePresample{this, "ZdcModulePresample", "", "ZDC module presample"};
222 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMinDeriv2nd{this, "ZdcModuleMinDeriv2nd", "", "ZDC module min 2nd derivative"};
223 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMaxADC{this, "ZdcModuleMaxADC", "", "ZDC module max ADC, minus pre-sample"};
224 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMaxADCHG{this, "ZdcModuleMaxADCHG", "", "ZDC module HG max ADC, unsubtracted"};
225 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMaxADCLG{this, "ZdcModuleMaxADCLG", "", "ZDC module LG max ADC, unsubtracted"};
226
227 // LG refit data
228 //
229 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitAmpLGRefit{this, "ZdcModuleFitAmpLGRefit", "", "ZDC module fit amp LG refit, with no gain factor or nonlinear correction applied"};
230 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmpLGRefit{this, "ZdcModuleAmpLGRefit", "", "ZDC module amp LG refit, with gain factor applied but no nonlinear correction"};
231 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmpCorrLGRefit{this, "ZdcModuleAmpCorrLGRefit", "", "ZDC module amp LG refit, with both gain factor and nonlinear correction applied"};
232 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleT0LGRefit{this, "ZdcModuleT0LGRefit", "", "ZDC module fit t0 LG refit"};
233 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleT0SubLGRefit{this, "ZdcModuleT0SubLGRefit", "", "ZDC module subtracted t0 LG refit"};
234 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleChisqLGRefit{this, "ZdcModuleChisqLGRefit", "", "ZDC module LG refit chi square"};
235
236 // decoration list for sums
237 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumUncalibSum{this, "ZdcSumUncalibSum", "", "ZDC side uncalibrated sum"};
238 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumUncalibSumErr{this, "ZdcSumUncalibSumErr", "", "ZDC side uncalibrated sum error"};
239 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumCalibEnergy{this, "ZdcSumCalibEnergy", "", "ZDC side calibrated energy"};
240 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumCalibEnergyErr{this, "ZdcSumCalibEnergyErr", "", "ZDC side calibrated energy error"};
241 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumNLCalibEnergy{this, "ZdcSumNLCalibEnergy", "", "ZDC side NL calibrated energy"};
242 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumNLCalibEnergyErr{this, "ZdcSumNLCalibEnergyErr", "", "ZDC side NL calibrated energy error"};
243 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumFinalEnergy{this, "ZdcSumFinalEnergy", "", "ZDC side final energy"};
244 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumFinalEnergyErr{this, "ZdcSumFinalEnergyErr", "", "ZDC side final energy error"};
245 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumAverageTime{this, "ZdcSumAverageTime", "", "ZDC side average time"};
246 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumStatus{this, "ZdcSumStatus", "", "ZDC side status"};
247 SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumModuleMask{this, "ZdcSumModuleMask", "", "ZDC side module mask"};
248
249};
250
251} // namespace ZDC
252
253#endif
254
255
256
#define endmsg
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
#define ATH_MSG_INFO(x)
Property holding a SG store/key/clid from which a ReadHandle is made.
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
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
std::array< std::array< float, 4 >, 2 > ZDCModuleFloatArray
std::array< std::array< int, 4 >, 2 > ZDCModuleIntArray
static bool sigprocMaxFinder(const std::vector< unsigned short > &adc, float deltaT, float &amp, float &time, float &qual)
void setEnergyCalibrations(unsigned int runNumber)
std::string m_zdcTriggerEffParamsFileName
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitT0
std::unique_ptr< TF1 > m_tf1SincInterp
double getTriggerEfficiency(int side)
ZdcAnalysisTool(const std::string &name)
float getCalibModuleSumErr(int side)
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer
void setTimeCalibrations(unsigned int runNumber)
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_80MHz
ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsHG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADC
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleT0SubLGRefit
std::shared_ptr< ZDCTriggerEfficiency > m_zdcTriggerEfficiency
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumModuleMask
std::string m_zdcSumContainerName
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleT0LGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleChisqLGRefit
float getCalibModuleSum(int side)
StatusCode recoZdcModules(const xAOD::ZdcModuleContainer &moduleContainer, const xAOD::ZdcModuleContainer &moduleSumContainer) override
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumStatus
std::string m_zdcAnalysisConfigPath
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumCalibEnergyErr
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumNLCalibEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumUncalibSum
ZDCDataAnalyzer::ZDCModuleIntArray m_peak2ndDerivMinSamples
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADCHG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumAverageTime
const xAOD::ZdcModuleContainer * m_zdcModules
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTime
ZDCMsg::MessageFunctionPtr MakeMessageFunction()
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_40MHz
float getUncalibModuleSum(int side)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumCalibEnergy
float getNLCalibModuleSumErr(int side)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmpLGRefit
std::string m_zdcEnergyCalibFileName
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumUncalibSumErr
const xAOD::ZdcModuleContainer * m_zdcSums
static void SetDebugLevel(int debugLevel=0)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumFinalEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumFinalEnergyErr
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMinDeriv2nd
double getTriggerEfficiencyUncertainty(int side)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpCorrLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleChisq
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmp
float getNLCalibModuleSum(int side)
ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsLG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmpError
std::string m_zdcModuleContainerName
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModulePresample
float getAverageTime(int side)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADCLG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmplitude
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumNLCalibEnergyErr
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleStatus
std::string m_zdcTimeCalibFileName
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibEnergy
std::string m_jsonConfigurationFile
void initializeTriggerEffs(unsigned int runNumber)
StatusCode reprocessZdc() override
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleBkgdMaxFraction
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
const ZDCDataAnalyzer * getDataAnalyzer()
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleNLCalibEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpNoNonLin
float getUncalibModuleSumErr(int side)
bool sigprocSincInterp(const std::vector< unsigned short > &adc, float deltaT, float &amp, float &time, float &qual)
float getModuleSum(int side)
void setFADCCorrections(unsigned int runNumber=0)
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModulePreSampleAmp
static std::atomic< int > s_debugLevel
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibTime
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
std::function< bool(int, std::string)> MessageFunction
Definition ZDCMsg.h:12
std::shared_ptr< MessageFunction > MessageFunctionPtr
Definition ZDCMsg.h:14
ZdcModuleContainer_v1 ZdcModuleContainer
void initialize()
MsgStream & msg
Definition testRead.cxx:32