Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ZdcAnalysisTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
24 
25 namespace ZDC
26 {
27 
29 {
30 
32 
33 public:
34  ZdcAnalysisTool(const std::string& name);
35  virtual ~ZdcAnalysisTool() override;
36  void initializeDecorations();
37 
38  //interface from AsgTool
39  StatusCode initialize() override;
40  void initialize80MHz();
41  void initialize40MHz();
42  void initializeTriggerEffs(unsigned int runNumber);
43 
44  StatusCode recoZdcModules(const xAOD::ZdcModuleContainer& moduleContainer, const xAOD::ZdcModuleContainer& moduleSumContainer) override;
45  StatusCode reprocessZdc() override;
46 
47  // methods for processing, used for decoration
48  static bool sigprocMaxFinder(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual);
49  bool sigprocSincInterp(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual);
50 
51  void setEnergyCalibrations(unsigned int runNumber);
52  void setTimeCalibrations(unsigned int runNumber);
53  void setFADCCorrections(unsigned int runNumber = 0);
54 
55  float getModuleSum(int side);
56 
57  float getCalibModuleSum(int side);
58  float getCalibModuleSumErr(int side);
59 
60  float getUncalibModuleSum(int side);
61  float getUncalibModuleSumErr(int side);
62 
63  float getAverageTime(int side);
64  bool sideFailed(int side);
65  unsigned int getModuleMask();
66 
67  double getTriggerEfficiency(int side);
68  double getTriggerEfficiencyUncertainty(int side);
69 
70  const ZDCDataAnalyzer* getDataAnalyzer() {return m_zdcDataAnalyzer.get();}
71 
72  static void SetDebugLevel(int debugLevel = 0)
73  {
74  s_debugLevel = debugLevel;
75  }
76 
78  {
79  std::function<bool(int, std::string)> msgFunction = [this](int messageZdcLevel, const std::string& message)-> bool
80  {
81  MSG::Level messageAthenaLevel = static_cast<MSG::Level>(messageZdcLevel);
82  bool passesStreamOutputLevel = messageAthenaLevel >= this->msg().level();
83  if (passesStreamOutputLevel) {
84  this->msg(messageAthenaLevel) << message << endmsg;
85  }
86  return passesStreamOutputLevel;
87  };
88 
89  return ZDCMsg::MessageFunctionPtr(new ZDCMsg::MessageFunction(msgFunction));
90  }
91 
92  void Dump_setting() {
93  if (s_debugLevel > 2) {
94  ATH_MSG_INFO("========================================================================================================================");
95  for (int i = 0; i < 2; i++) {
96  for (int j = 0; j < 4; j++) {
97  ATH_MSG_INFO("-------------------------------------------------------------------------------------------------------------------");
98  ATH_MSG_INFO("Side: " << i << ", Module: " << j);
99  m_zdcDataAnalyzer->GetPulseAnalyzer(i, j)->dumpSetting();
100  }
101  }
102  ATH_MSG_INFO("========================================================================================================================");
103  }
104  }
105 
106 private:
107  // Private methods
108  //
109  std::unique_ptr<ZDCDataAnalyzer> initializeDefault();
110  std::unique_ptr<ZDCDataAnalyzer> initializePbPb2015G4();
111  std::unique_ptr<ZDCDataAnalyzer> initializepPb2016();
112  std::unique_ptr<ZDCDataAnalyzer> initializePbPb2018();
113  std::unique_ptr<ZDCDataAnalyzer> initializeLHCf2022();
114  std::unique_ptr<ZDCDataAnalyzer> initializepp2023();
115  std::unique_ptr<ZDCDataAnalyzer> initializePbPb2023();
116  std::unique_ptr<ZDCDataAnalyzer> initializepp2024();
117  std::unique_ptr<ZDCDataAnalyzer> initializePbPb2024();
118  std::unique_ptr<ZDCDataAnalyzer> initializeInjectorpp2024();
119  std::unique_ptr<ZDCDataAnalyzer> initializeInjectorPbPb2024();
120  std::unique_ptr<ZDCDataAnalyzer> initializeMonteCarloPbPb2023();
121 
122  StatusCode configureNewRun(unsigned int runNumber);
123 
124  // Data members
125  //
126  std::string m_name;
127  bool m_init;
128  std::string m_configuration;
133 
135  std::string m_auxSuffix;
136 
138  unsigned int m_runNumber;
139  unsigned int m_lumiBlock;
140 
141  // internal functions
142  std::unique_ptr<TF1> m_tf1SincInterp;
143 
145  this, "EventInfoKey", "EventInfo",
146  "Location of the event info."};
147 
149  const xAOD::ZdcModuleContainer* m_zdcModules {nullptr};
151  const xAOD::ZdcModuleContainer* m_zdcSums {nullptr};
153  unsigned int m_lowGainMode;
154  bool m_combineDelay{false};
155  bool m_doCalib{false};
156  bool m_doTrigEff{false};
157  bool m_doTimeCalib{false};
158  bool m_doFADCCorr{false};
159  bool m_doNonLinCorr{false};
160  bool m_doFADCCorrPerSample{false};
163  std::string m_calibVersion;
164 
165  // Parameters that control the pulse fitting analysis
166  //
167  unsigned int m_numSample;
169  unsigned int m_presample;
170  unsigned int m_peakSample;
172  float m_t0;
174  float m_tau1;
175  float m_tau2;
176  bool m_fixTau1;
177  bool m_fixTau2;
178  float m_deltaTCut;
180 
181  int m_LHCRun;
182 
183  // The objects that carry out the analysis
184  //
185  std::shared_ptr<ZDCDataAnalyzer> m_zdcDataAnalyzer;
186  std::shared_ptr<ZDCDataAnalyzer> m_zdcDataAnalyzer_40MHz;
187  std::shared_ptr<ZDCDataAnalyzer> m_zdcDataAnalyzer_80MHz;
188 
189  ZDCDataAnalyzer::ZDCModuleIntArray m_peak2ndDerivMinSamples{};
190  ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsHG{};
191  ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsLG{};
192 
193 
194  std::shared_ptr<ZDCTriggerEfficiency> m_zdcTriggerEfficiency;
195 
196  static std::atomic<int> s_debugLevel;
197 
198  // decoration list for ZDC modules
199  // ZDC
200  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmplitude{this, "ZdcModuleAmplitude", "", "ZDC module amplitude"};
201  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleCalibEnergy{this, "ZdcModuleCalibEnergy", "", "ZDC module calibrated energy"};
202  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleCalibTime{this, "ZdcModuleCalibTime", "", "ZDC module calibrated time"};
203  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleStatus{this, "ZdcModuleStatus", "", "ZDC module fit status"};
204  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleTime{this, "ZdcModuleTime", "", "ZDC module time"};
205  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleChisq{this, "ZdcModuleChisq", "", "ZDC module fit chisq"};
206  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmpNoNonLin{this, "ZdcModuleAmpNoNonLin", "", "ZDC module amplitude with gain factor applied but no nonlinear correction"};
207  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitAmp{this, "ZdcModuleFitAmp", "", "ZDC module fit amp"};
208  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitAmpError{this, "ZdcModuleFitAmpError", "", "ZDC module fit amp error"};
209  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitT0{this, "ZdcModuleFitT0", "", "ZDC module fit t0"};
210  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleBkgdMaxFraction{this, "ZdcModuleBkgdMaxFraction", "", "ZDC module background max fraction"};
211  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModulePreSampleAmp{this, "ZdcModulePreSampleAmp", "", "ZDC module presample amplitude"};
212  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModulePresample{this, "ZdcModulePresample", "", "ZDC module presample"};
213  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMinDeriv2nd{this, "ZdcModuleMinDeriv2nd", "", "ZDC module min 2nd derivative"};
214  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMaxADC{this, "ZdcModuleMaxADC", "", "ZDC module max ADC, minus pre-sample"};
215  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMaxADCHG{this, "ZdcModuleMaxADCHG", "", "ZDC module HG max ADC, unsubtracted"};
216  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleMaxADCLG{this, "ZdcModuleMaxADCLG", "", "ZDC module LG max ADC, unsubtracted"};
217 
218  // LG refit data
219  //
220  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleFitAmpLGRefit{this, "ZdcModuleFitAmpLGRefit", "", "ZDC module fit amp LG refit, with no gain factor or nonlinear correction applied"};
221  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmpLGRefit{this, "ZdcModuleAmpLGRefit", "", "ZDC module amp LG refit, with gain factor applied but no nonlinear correction"};
222  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleAmpCorrLGRefit{this, "ZdcModuleAmpCorrLGRefit", "", "ZDC module amp LG refit, with both gain factor and nonlinear correction applied"};
223  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleT0LGRefit{this, "ZdcModuleT0LGRefit", "", "ZDC module fit t0 LG refit"};
224  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleT0SubLGRefit{this, "ZdcModuleT0SubLGRefit", "", "ZDC module subtracted t0 LG refit"};
225  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcModuleChisqLGRefit{this, "ZdcModuleChisqLGRefit", "", "ZDC module LG refit chi square"};
226 
227  // decoration list for sums
228  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumUncalibSum{this, "ZdcSumUncalibSum", "", "ZDC side uncalibrated sum"};
229  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumUncalibSumErr{this, "ZdcSumUncalibSumErr", "", "ZDC side uncalibrated sum error"};
230  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumCalibEnergy{this, "ZdcSumCalibEnergy", "", "ZDC side calibrated energy"};
231  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumCalibEnergyErr{this, "ZdcSumCalibEnergyErr", "", "ZDC side calibrated energy error"};
232  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumFinalEnergy{this, "ZdcSumFinalEnergy", "", "ZDC side final energy"};
233  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumAverageTime{this, "ZdcSumAverageTime", "", "ZDC side average time"};
234  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumStatus{this, "ZdcSumStatus", "", "ZDC side status"};
235  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_zdcSumModuleMask{this, "ZdcSumModuleMask", "", "ZDC side module mask"};
236 
237 };
238 
239 } // namespace ZDC
240 
241 #endif
242 
243 
244 
ZDC::ZdcAnalysisTool::m_zdcTriggerEffParamsFileName
std::string m_zdcTriggerEffParamsFileName
Definition: ZdcAnalysisTool.h:132
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition: StoreGate/StoreGate/WriteDecorHandleKey.h:89
ZDC::ZdcAnalysisTool::Dump_setting
void Dump_setting()
Definition: ZdcAnalysisTool.h:92
ZDC::ZdcAnalysisTool::MakeMessageFunction
ZDCMsg::MessageFunctionPtr MakeMessageFunction()
Definition: ZdcAnalysisTool.h:77
ZDC::ZdcAnalysisTool::m_zdcModuleContainerName
std::string m_zdcModuleContainerName
Definition: ZdcAnalysisTool.h:148
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
ZDC::ZdcAnalysisTool::m_runNumber
unsigned int m_runNumber
Definition: ZdcAnalysisTool.h:138
ZDC::ZdcAnalysisTool::m_Peak2ndDerivThresh
float m_Peak2ndDerivThresh
Definition: ZdcAnalysisTool.h:171
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
ZDC::ZdcAnalysisTool::m_ChisqRatioCut
float m_ChisqRatioCut
Definition: ZdcAnalysisTool.h:179
ZDC::ZdcAnalysisTool::m_LHCRun
int m_LHCRun
Definition: ZdcAnalysisTool.h:181
ZDCDataAnalyzer::ZDCModuleFloatArray
std::array< std::array< float, 4 >, 2 > ZDCModuleFloatArray
Definition: ZDCDataAnalyzer.h:22
initialize
void initialize()
Definition: run_EoverP.cxx:894
ZDC::ZdcAnalysisTool::m_fixTau1
bool m_fixTau1
Definition: ZdcAnalysisTool.h:176
ZDCDataAnalyzer::ZDCModuleIntArray
std::array< std::array< int, 4 >, 2 > ZDCModuleIntArray
Definition: ZDCDataAnalyzer.h:24
ZDC::ZdcAnalysisTool::m_zdcAnalysisConfigPath
std::string m_zdcAnalysisConfigPath
Definition: ZdcAnalysisTool.h:129
ZDC::ZdcAnalysisTool::m_presample
unsigned int m_presample
Definition: ZdcAnalysisTool.h:169
IZdcAnalysisTool.h
SG::ReadHandleKey< xAOD::EventInfo >
ZDC::ZdcAnalysisTool::getDataAnalyzer
const ZDCDataAnalyzer * getDataAnalyzer()
Definition: ZdcAnalysisTool.h:70
ZDC::ZdcAnalysisTool::m_tf1SincInterp
std::unique_ptr< TF1 > m_tf1SincInterp
Definition: ZdcAnalysisTool.h:142
ZDC::ZdcAnalysisTool::m_tau1
float m_tau1
Definition: ZdcAnalysisTool.h:174
ReweightUtils.message
message
Definition: ReweightUtils.py:15
ZDC::ZdcAnalysisTool::m_lowGainMode
unsigned int m_lowGainMode
Definition: ZdcAnalysisTool.h:153
ZDC::IZdcAnalysisTool
Definition: IZdcAnalysisTool.h:15
ZDC::ZdcAnalysisTool
Definition: ZdcAnalysisTool.h:29
TRT::Hit::side
@ side
Definition: HitInfo.h:83
ZDCDataAnalyzer
Definition: ZDCDataAnalyzer.h:20
ZDCDataAnalyzer.h
ZDC::ZdcAnalysisTool::m_lumiBlock
unsigned int m_lumiBlock
Definition: ZdcAnalysisTool.h:139
ZDC::ZdcAnalysisTool::m_delayDeltaT
float m_delayDeltaT
Definition: ZdcAnalysisTool.h:173
ZDC::ZdcAnalysisTool::m_init
bool m_init
Definition: ZdcAnalysisTool.h:127
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:85
ZDC::ZdcAnalysisTool::m_numSample
unsigned int m_numSample
Definition: ZdcAnalysisTool.h:167
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
ZDC::ZdcAnalysisTool::m_forceCalibLB
int m_forceCalibLB
Definition: ZdcAnalysisTool.h:162
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer_80MHz
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_80MHz
Definition: ZdcAnalysisTool.h:187
DQHistogramMerge.debugLevel
debugLevel
Definition: DQHistogramMerge.py:41
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ZDC::ZdcAnalysisTool::m_zdcSumContainerName
std::string m_zdcSumContainerName
Definition: ZdcAnalysisTool.h:150
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer
Definition: ZdcAnalysisTool.h:185
ZDC::ZdcAnalysisTool::m_tau2
float m_tau2
Definition: ZdcAnalysisTool.h:175
ZDCMsg.h
ZDC::ZdcAnalysisTool::m_calibVersion
std::string m_calibVersion
Definition: ZdcAnalysisTool.h:163
ZDCMsg::MessageFunction
std::function< bool(int, std::string)> MessageFunction
Definition: ZDCMsg.h:12
ZDC::ZdcAnalysisTool::m_writeAux
bool m_writeAux
Definition: ZdcAnalysisTool.h:134
ZDC::ZdcAnalysisTool::m_configuration
std::string m_configuration
Definition: ZdcAnalysisTool.h:128
ZDCTriggerEfficiency.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ZDC::ZdcAnalysisTool::m_forceCalibRun
int m_forceCalibRun
Definition: ZdcAnalysisTool.h:161
ZDC::ZdcAnalysisTool::m_deltaTCut
float m_deltaTCut
Definition: ZdcAnalysisTool.h:178
ZDC::ZdcAnalysisTool::SetDebugLevel
static void SetDebugLevel(int debugLevel=0)
Definition: ZdcAnalysisTool.h:72
ZDC::ZdcAnalysisTool::s_debugLevel
static std::atomic< int > s_debugLevel
Definition: ZdcAnalysisTool.h:196
ZDCMsg::MessageFunctionPtr
std::shared_ptr< MessageFunction > MessageFunctionPtr
Definition: ZDCMsg.h:14
EventInfo.h
WriteDecorHandleKey.h
ZDC::ZdcAnalysisTool::m_zdcTriggerEfficiency
std::shared_ptr< ZDCTriggerEfficiency > m_zdcTriggerEfficiency
Definition: ZdcAnalysisTool.h:194
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
ZDC
Definition: RPDAnalysisTool.cxx:12
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer_40MHz
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_40MHz
Definition: ZdcAnalysisTool.h:186
ZDC::ZdcAnalysisTool::m_deltaTSample
float m_deltaTSample
Definition: ZdcAnalysisTool.h:168
ZDC::ZdcAnalysisTool::m_zdcTimeCalibFileName
std::string m_zdcTimeCalibFileName
Definition: ZdcAnalysisTool.h:131
ZDC::ZdcAnalysisTool::m_peakSample
unsigned int m_peakSample
Definition: ZdcAnalysisTool.h:170
beamspotman.qual
qual
Definition: beamspotman.py:481
ZDC::ZdcAnalysisTool::m_flipEMDelay
bool m_flipEMDelay
Definition: ZdcAnalysisTool.h:152
ZDC::ZdcAnalysisTool::m_zdcEnergyCalibFileName
std::string m_zdcEnergyCalibFileName
Definition: ZdcAnalysisTool.h:130
ZDC::ZdcAnalysisTool::m_t0
float m_t0
Definition: ZdcAnalysisTool.h:172
AsgTool.h
checker_macros.h
Define macros for attributes used to control the static checker.
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
ZdcModuleContainer.h
ZDC::ZdcAnalysisTool::m_auxSuffix
std::string m_auxSuffix
Definition: ZdcAnalysisTool.h:135
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ZDC::ZdcAnalysisTool::m_fixTau2
bool m_fixTau2
Definition: ZdcAnalysisTool.h:177
ZDC::ZdcAnalysisTool::m_name
std::string m_name
Definition: ZdcAnalysisTool.h:126
ZDC::ZdcAnalysisTool::m_eventReady
bool m_eventReady
Definition: ZdcAnalysisTool.h:137