ATLAS Offline Software
ZdcAnalysisTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "TGraph.h"
7 #include "TEnv.h"
8 #include "TSystem.h"
11 #include "TFile.h"
12 #include <sstream>
13 #include <memory>
20 #include "ZdcUtils/ZdcEventInfo.h"
21 
22 namespace ZDC
23 {
25  : asg::AsgTool(name), m_name(name), m_init(false),
26  m_writeAux(false), m_eventReady(false),
27  m_runNumber(0), m_lumiBlock(0),
28  m_zdcTriggerEfficiency(0)
29 {
30 
31 #ifndef XAOD_STANDALONE
32  declareInterface<IZdcAnalysisTool>(this);
33 #endif
34 
35  declareProperty("ZdcModuleContainerName", m_zdcModuleContainerName = "ZdcModules", "Location of ZDC processed data");
36  declareProperty("ZdcSumContainerName", m_zdcSumContainerName = "ZdcSums", "Location of ZDC processed sums");
37  declareProperty("Configuration", m_configuration = "PbPb2015");
38  declareProperty("FlipEMDelay", m_flipEMDelay = false);
39  declareProperty("LowGainMode", m_lowGainMode = 0);
40  declareProperty("WriteAux", m_writeAux = true);
41  declareProperty("AuxSuffix", m_auxSuffix = "");
42 
43  // The following job properties enable/disable and affect the calibration of the ZDC energies
44  //
45  declareProperty("DoCalib", m_doCalib = true);
46  declareProperty("CalibVersion", m_calibVersion = "");
47  declareProperty("DoTrigEff", m_doTrigEff = true);
48  declareProperty("DoTimeCalib", m_doTimeCalib = true);
49  declareProperty("ZdcAnalysisConfigPath", m_zdcAnalysisConfigPath = "$ROOTCOREBIN/data/ZdcAnalysis", "ZDC Analysis config file path");
50  //declareProperty("ForceCalibRun",m_forceCalibRun=287931); // last run of Pb+Pb 2015
51  declareProperty("ForceCalibRun", m_forceCalibRun = -1); // last run of Pb+Pb 2015
52  declareProperty("ForceCalibLB", m_forceCalibLB = 814); // last LB of Pb+Pb 2015
53 
54  declareProperty("DoNonLinCorr", m_doNonLinCorr = true); // how we have run with 2023 and most of 2024
55  declareProperty("DoFADCCorr", m_doFADCCorr = false);
56  declareProperty("DoFADCCorrPerSample", m_doFADCCorrPerSample = false);
57 
58  // The following parameters are primarily used for the "default" configuration, but also may be
59  // use to modify/tailor other configurations
60  //
61  declareProperty("NumSampl", m_numSample = 7);
62  declareProperty("DeltaTSample", m_deltaTSample = 25);
63  declareProperty("Presample", m_presample = 0);
64  declareProperty("CombineDelay", m_combineDelay = false);
65  declareProperty("DelayDeltaT", m_delayDeltaT = -12.5);
66 
67  declareProperty("PeakSample", m_peakSample = 11);
68  declareProperty("Peak2ndDerivThresh", m_Peak2ndDerivThresh = 20);
69 
70  declareProperty("T0", m_t0 = 30);
71  declareProperty("Tau1", m_tau1 = 5);
72  declareProperty("Tau2", m_tau2 = 25);
73  declareProperty("FixTau1", m_fixTau1 = false);
74  declareProperty("FixTau2", m_fixTau2 = false);
75 
76  declareProperty("DeltaTCut", m_deltaTCut = 10);
77  declareProperty("ChisqRatioCut", m_ChisqRatioCut = 10);
78 
79  declareProperty("LHCRun", m_LHCRun = 3);
80 
81 }
82 
84 {
85  ATH_MSG_DEBUG("Deleting ZdcAnalysisTool named " << m_name);
86 }
87 
89 {
90  if (!m_doTrigEff) return;
91 
93  {
94  ATH_MSG_DEBUG("Creating new ZDCTriggerEfficiency");
96  }
97 
98  std::string filename = PathResolverFindCalibFile( ("ZdcAnalysis/" + m_zdcTriggerEffParamsFileName) );
99  ATH_MSG_DEBUG ("Found trigger config file " << filename);
100  ATH_MSG_DEBUG("Opening trigger efficiency file " << filename);
101 
102  std::unique_ptr<TFile> file (TFile::Open(filename.c_str(), "READ"));
103  if (file == nullptr || file->IsZombie())
104  {
105  ATH_MSG_WARNING("No trigger efficiencies at " << filename);
106  return;
107  }
108 
109  //file->Print();
110 
111  ATH_MSG_DEBUG("Reading in trigger efficiencies");
112 
113  std::stringstream Aalpha_name;
114  Aalpha_name << "A_alpha_" << runNumber;
115  TSpline3* par_A_alpha = (TSpline3*)file->GetObjectChecked(Aalpha_name.str().c_str(), "TSpline3");
116 
117  if (!par_A_alpha)
118  {
119  ATH_MSG_WARNING("No trigger efficiencies for run number " << runNumber);
120  m_doCalib = false;
121  }
122 
123  std::stringstream Abeta_name;
124  Abeta_name << "A_beta_" << runNumber;
125  TSpline3* par_A_beta = (TSpline3*)file->GetObjectChecked(Abeta_name.str().c_str(), "TSpline3");
126  std::stringstream Atheta_name;
127  Atheta_name << "A_theta_" << runNumber;
128  TSpline3* par_A_theta = (TSpline3*)file->GetObjectChecked(Atheta_name.str().c_str(), "TSpline3");
129 
130  std::stringstream Calpha_name;
131  Calpha_name << "C_alpha_" << runNumber;
132  TSpline3* par_C_alpha = (TSpline3*)file->GetObjectChecked(Calpha_name.str().c_str(), "TSpline3");
133  std::stringstream Cbeta_name;
134  Cbeta_name << "C_beta_" << runNumber;
135  TSpline3* par_C_beta = (TSpline3*)file->GetObjectChecked(Cbeta_name.str().c_str(), "TSpline3");
136  std::stringstream Ctheta_name;
137  Ctheta_name << "C_theta_" << runNumber;
138  TSpline3* par_C_theta = (TSpline3*)file->GetObjectChecked(Ctheta_name.str().c_str(), "TSpline3");
139 
140  std::stringstream Err_Aalpha_name;
141  Err_Aalpha_name << "A_alpha_error_" << runNumber;
142  TSpline3* parErr_A_alpha = (TSpline3*)file->GetObjectChecked(Err_Aalpha_name.str().c_str(), "TSpline3");
143  std::stringstream Err_Abeta_name;
144  Err_Abeta_name << "A_beta_error_" << runNumber;
145  TSpline3* parErr_A_beta = (TSpline3*)file->GetObjectChecked(Err_Abeta_name.str().c_str(), "TSpline3");
146  std::stringstream Err_Atheta_name;
147  Err_Atheta_name << "A_theta_error_" << runNumber;
148  TSpline3* parErr_A_theta = (TSpline3*)file->GetObjectChecked(Err_Atheta_name.str().c_str(), "TSpline3");
149 
150  std::stringstream Err_Calpha_name;
151  Err_Calpha_name << "C_alpha_error_" << runNumber;
152  TSpline3* parErr_C_alpha = (TSpline3*)file->GetObjectChecked(Err_Calpha_name.str().c_str(), "TSpline3");
153  std::stringstream Err_Cbeta_name;
154  Err_Cbeta_name << "C_beta_error_" << runNumber;
155  TSpline3* parErr_C_beta = (TSpline3*)file->GetObjectChecked(Err_Cbeta_name.str().c_str(), "TSpline3");
156  std::stringstream Err_Ctheta_name;
157  Err_Ctheta_name << "C_theta_error_" << runNumber;
158  TSpline3* parErr_C_theta = (TSpline3*)file->GetObjectChecked(Err_Ctheta_name.str().c_str(), "TSpline3");
159 
160 
161  std::stringstream Cov_A_alpha_beta_name;
162  Cov_A_alpha_beta_name << "cov_A_alpha_beta_" << runNumber;
163  TSpline3* cov_A_alpha_beta = (TSpline3*)file->GetObjectChecked(Cov_A_alpha_beta_name.str().c_str(), "TSpline3");
164  std::stringstream Cov_A_alpha_theta_name;
165  Cov_A_alpha_theta_name << "cov_A_alpha_theta_" << runNumber;
166  TSpline3* cov_A_alpha_theta = (TSpline3*)file->GetObjectChecked(Cov_A_alpha_theta_name.str().c_str(), "TSpline3");
167  std::stringstream Cov_A_beta_theta_name;
168  Cov_A_beta_theta_name << "cov_A_beta_theta_" << runNumber;
169  TSpline3* cov_A_beta_theta = (TSpline3*)file->GetObjectChecked(Cov_A_beta_theta_name.str().c_str(), "TSpline3");
170 
171  std::stringstream Cov_C_alpha_beta_name;
172  Cov_C_alpha_beta_name << "cov_C_alpha_beta_" << runNumber;
173  TSpline3* cov_C_alpha_beta = (TSpline3*)file->GetObjectChecked(Cov_C_alpha_beta_name.str().c_str(), "TSpline3");
174  std::stringstream Cov_C_alpha_theta_name;
175  Cov_C_alpha_theta_name << "cov_C_alpha_theta_" << runNumber;
176  TSpline3* cov_C_alpha_theta = (TSpline3*)file->GetObjectChecked(Cov_C_alpha_theta_name.str().c_str(), "TSpline3");
177  std::stringstream Cov_C_beta_theta_name;
178  Cov_C_beta_theta_name << "cov_C_beta_theta_" << runNumber;
179  TSpline3* cov_C_beta_theta = (TSpline3*)file->GetObjectChecked(Cov_C_beta_theta_name.str().c_str(), "TSpline3");
180 
181  std::array<std::vector<TSpline3*>, 2> effparams;
182  std::array<std::vector<TSpline3*>, 2> effparamErrors;
183  std::array<std::vector<TSpline3*>, 2> effparamsCorrCoeffs;
184  //side0: C; side1: A
185  effparams[0] = {par_C_alpha, par_C_beta, par_C_theta};
186  effparams[1] = {par_A_alpha, par_A_beta, par_A_theta};
187  effparamErrors[0] = {parErr_C_alpha, parErr_C_beta, parErr_C_theta};
188  effparamErrors[1] = {parErr_A_alpha, parErr_A_beta, parErr_A_theta};
189  effparamsCorrCoeffs[0] = {cov_C_alpha_beta, cov_C_alpha_theta, cov_C_beta_theta};
190  effparamsCorrCoeffs[1] = {cov_A_alpha_beta, cov_A_alpha_theta, cov_A_beta_theta};
191 
192  ATH_MSG_DEBUG("Trying to set parameters and errors at " << m_zdcTriggerEfficiency);
193 
194  m_zdcTriggerEfficiency->SetEffParamsAndErrors(effparams, effparamErrors);
195  m_zdcTriggerEfficiency->SetEffParamCorrCoeffs(effparamsCorrCoeffs);
196 
197  return;
198 
199 }
200 
201 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeLHCf2022()
202 {
203 
204  m_deltaTSample = 3.125;
205  m_numSample = 24;
206 
207  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples = {{{0, 9, 9, 9}, {0, 9, 10, 8}}};
208 
209  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
210  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow{}, deltaT0CutHigh{}, chisqDivAmpCut{};
211  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
212 
213  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{0, 1.1, 1.1, 1.1},
214  {0, 1.1, 1.1, 1.1}}};
215 
216  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{6, 5, 5, 5}, {5.5, 5.5, 5.5, 5.5}}};
217 
218  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{0, 26.3, 26.5, 26.8}, {32, 32, 32, 32}}};
219 
220  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{0, 31.1, 28.1, 27.0}, {0, 26.6, 26.3, 25.3}}};
221 
222  for (size_t side : {0, 1}) {
223  for (size_t module : {0, 1, 2, 3}) {
224  fixTau1Arr[side][module] = true;
225  fixTau2Arr[side][module] = false;
226 
227  peak2ndDerivMinThresholdsHG[side][module] = -35;
228  peak2ndDerivMinThresholdsLG[side][module] = -16;
229 
230  deltaT0CutLow[side][module] = -10;
231  deltaT0CutHigh[side][module] = 10;
232  chisqDivAmpCut[side][module] = 20;
233  }
234  }
235 
236  ATH_MSG_DEBUG( "LHCF2022: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
237 
238  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
239  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
240  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
241 
242  // For the LHCf run, use low gain samples
243  //
245 
246  // Construct the data analyzer
247  //
248  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
250  m_presample, "FermiExpLHCf",
251  peak2ndDerivMinSamples,
252  peak2ndDerivMinThresholdsHG,
253  peak2ndDerivMinThresholdsLG,
254  m_lowGainMode));
255 
256  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(2);
257  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
258  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
259  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
260 
261  zdcDataAnalyzer->SetGainFactorsHGLG(0.1, 1); // a gain adjustment of unity applied to LG ADC, 0.1 to HG ADC values
262 
263  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{2, 2, 2, 2}, {2, 2, 2, 2}}};
264  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{20, 20, 20, 20}, {20, 20, 20, 20}}};
265 
266  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
267 
268  // Enable two-pass analysis
269  //
270  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-12, -12, -12, -12},
271  {-12, -12, -12, -12}}};
272 
273  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
274  {-8, -8, -8, -8}}};
275 
276  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
277 
278  // Set the amplitude fit range limits
279  //
280  zdcDataAnalyzer->SetFitMinMaxAmpValues(5, 2, 5000, 5000);
281 
282  // disable EM module on each side
283  zdcDataAnalyzer->disableModule(0, 0);
284  zdcDataAnalyzer->disableModule(1, 0);
285 
286  return zdcDataAnalyzer;
287 
288 }
289 
290 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializepp2023()
291 {
292 
293  m_deltaTSample = 3.125;
294  m_numSample = 24;
296 
297  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples = {{{12, 12, 12, 12}, {12, 12, 12, 12}}};
298 
299  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
300  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow{}, deltaT0CutHigh{}, chisqDivAmpCut{};
301  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
302 
303  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.1, 1.1, 1.1, 1.1},
304  {1.1, 1.1, 1.1, 1.1}}};
305 
306  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{5.5, 5.5, 5.5, 5.5}, {5.5, 5.5, 5.5, 5.5}}};
307 
308  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{36, 36, 36, 36}, {36, 36, 36, 36}}};
309 
310  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{36, 36, 36, 36}, {36, 36, 36, 36}}};
311 
312  const int deriv2ndThreshDSHG = -35;
313  const int deriv2ndThreshDSLG = -10;
314 
315  const float deltaTcutLow = -10;
316  const float deltaTcutHigh = 10;
317  const float chisqDivAmpCutVal = 10;
318 
319  for (size_t side : {0, 1}) {
320  for (size_t module : {0, 1, 2, 3}) {
321  fixTau1Arr[side][module] = true;
322  fixTau2Arr[side][module] = false;
323 
324  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
325  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
326 
327  deltaT0CutLow[side][module] = deltaTcutLow;
328  deltaT0CutHigh[side][module] = deltaTcutHigh;
329  chisqDivAmpCut[side][module] = chisqDivAmpCutVal;
330  }
331  }
332 
333  ATH_MSG_DEBUG( "pp2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
334 
335  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
336  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
337  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
338 
339  // Construct the data analyzer
340  //
341  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
343  m_presample, "FermiExpLHCf",
344  peak2ndDerivMinSamples,
345  peak2ndDerivMinThresholdsHG,
346  peak2ndDerivMinThresholdsLG,
347  m_lowGainMode));
348 
349  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
350  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
351  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
352  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
353 
354  zdcDataAnalyzer->SetGainFactorsHGLG(1, 10); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
355 
356  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{0.5, 0.5, 0.5, 0.5}, {0.5, 0.5, 0.5, 0.5}}};
357  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{2, 2, 2, 2}, {2, 2, 2, 2}}};
358 
359  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
360 
361  // Enable two-pass analysis
362  //
363  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-12, -12, -12, -12},
364  {-12, -12, -12, -12}}};
365 
366  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
367  {-8, -8, -8, -8}}};
368 
369  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
370 
371  // Set the amplitude fit range limits
372  //
373  zdcDataAnalyzer->SetFitMinMaxAmpValues(5, 2, 5000, 5000);
374 
375  return zdcDataAnalyzer;
376 
377 }
378 
379 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializepp2024()
380 {
381 
382  m_deltaTSample = 3.125;
383  m_numSample = 24;
385 
386  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples = {{{12, 12, 12, 12}, {12, 12, 12, 12}}};
387 
388  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
389  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh, chisqDivAmpCut;
390  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
391 
392  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.1, 1.1, 1.1, 1.1},
393  {1.1, 1.1, 1.1, 1.1}}};
394 
395  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{5.5, 5.5, 5.5, 5.5}, {5.5, 5.5, 5.5, 5.5}}};
396 
397  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{36, 36, 36, 36}, {36, 36, 36, 36}}};
398 
399  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{36, 36, 36, 36}, {36, 36, 36, 36}}};
400 
401  const int deriv2ndThreshDSHG = -35;
402  const int deriv2ndThreshDSLG = -10;
403 
404  const float deltaTcutLow = -10;
405  const float deltaTcutHigh = 10;
406  const float chisqDivAmpCutVal = 100;
407 
408  for (size_t side : {0, 1}) {
409  for (size_t module : {0, 1, 2, 3}) {
410  fixTau1Arr[side][module] = true;
411  fixTau2Arr[side][module] = false;
412 
413  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
414  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
415 
416  deltaT0CutLow[side][module] = deltaTcutLow;
417  deltaT0CutHigh[side][module] = deltaTcutHigh;
418  chisqDivAmpCut[side][module] = chisqDivAmpCutVal;
419  }
420  }
421 
422  ATH_MSG_DEBUG( "pp2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
423 
424  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
425  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
426  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
427 
428  // Construct the data analyzer
429  //
430  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
432  m_presample, "FermiExpLHCf",
433  peak2ndDerivMinSamples,
434  peak2ndDerivMinThresholdsHG,
435  peak2ndDerivMinThresholdsLG,
436  m_lowGainMode));
437 
438  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
439  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
440  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
441  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
442 
443  zdcDataAnalyzer->SetGainFactorsHGLG(1, 10); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
444 
445  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{0.5, 0.5, 0.5, 0.5}, {0.5, 0.5, 0.5, 0.5}}};
446  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{2, 2, 2, 2}, {2, 2, 2, 2}}};
447 
448  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
449 
450  // Enable two-pass analysis
451  //
452  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-12, -12, -12, -12},
453  {-12, -12, -12, -12}}};
454 
455  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
456  {-8, -8, -8, -8}}};
457 
458  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
459 
460  // Set the amplitude fit range limits
461  //
462  zdcDataAnalyzer->SetFitMinMaxAmpValues(5, 2, 5000, 5000);
463 
464  return zdcDataAnalyzer;
465 
466 }
467 
468 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializePbPb2023()
469 {
470  // Key configuration parameters needed for the data analyzer construction
471  //
472  m_deltaTSample = 3.125;
473  m_numSample = 24;
474 
475  const int deriv2ndThreshDSHG = -25;
476  const int deriv2ndThreshDSLG = -10;
477  const unsigned int peakSample = 10;
478 
479  const float deltaTcutLow = -10;
480  const float deltaTcutHigh = 10;
481  const float chisqDivAmpCutHGVal = 30;
482  const float chisqDivAmpCutLGVal = 50;
483 
484  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
485  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
486 
487  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow{}, deltaT0CutHigh{};
488  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG{}, chisqDivAmpCutLG{};
489  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
490 
491  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
492  {1.35, 1.4, 1.3, 1.1}}};
493 
494  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
495 
496  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
497  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{28, 28, 28, 28}, {28, 28, 28, 28}}};
498 
499  for (size_t side : {0, 1}) {
500  for (size_t module : {0, 1, 2, 3}) {
501  fixTau1Arr[side][module] = true;
502  fixTau2Arr[side][module] = false;
503 
504  peak2ndDerivMinSamples[side][module] = peakSample;
505  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
506  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
507 
508  deltaT0CutLow[side][module] = deltaTcutLow;
509  deltaT0CutHigh[side][module] = deltaTcutHigh;
510  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
511  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
512  }
513  }
514 
515  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
516 
517  // Construct the data analyzer
518  //
519  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
521  m_presample, "FermiExpLHCf",
522  peak2ndDerivMinSamples,
523  peak2ndDerivMinThresholdsHG,
524  peak2ndDerivMinThresholdsLG,
526  zdcDataAnalyzer->set2ndDerivStep(2);
527  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
528 
529  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1.042, 1.078, 1.008, 1.066},{1.047, 1.060, 1.010, 0.99}}};
530  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
531 
532  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
533 
534  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
535  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
536  //
537  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
538  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{1.5, 1.7, 3, 1.7}, {1.7, 1.6, 2.2, 1.8}}};
539 
540  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
541 
542  // Now set cuts and default fit parameters
543  //
544  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
545  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
546  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
547 
548  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
549  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
550  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
551 
552  // Enable two-pass analysis
553  //
554  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-20, -20, -20, -20},
555  {-20, -20, -20, -20},}};
556 
557  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
558  {-8, -8, -8, -8}}};
559 
560  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
561 
562  // Turn on exclusion of early and late samples to address OOT pileup
563  //
564  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
565  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
566 
567  // Set up non-linear corrections for the ZDC
568  //
569  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
570 
571  nonLinearCorrCoefficHG[0][0] = {-0.0225871, 0.00702802, 0.00201155, -0.00675293, 0.00186212} ;
572  nonLinearCorrCoefficHG[0][1] = {-0.0155562, 0.00594092, 0.00382112, -0.00665466, 0.00143384} ;
573  nonLinearCorrCoefficHG[0][2] = {-0.0313621, 0.0134528, 0.00529013, -0.0111751, 0.0029913} ;
574  nonLinearCorrCoefficHG[0][3] = {-0.025108, 0.00301898, 0.022472, -0.0204288, 0.00453215} ;
575  nonLinearCorrCoefficHG[1][0] = {-0.0266648, 0.0106792, -0.00939959, 0.000833011, 0.000199051} ;
576  nonLinearCorrCoefficHG[1][1] = {-0.0246541, 0.000327376, 0.00754946, -0.00710273, 0.00136899} ;
577  nonLinearCorrCoefficHG[1][2] = {-0.0175283, 0.0127954, 0.000235749, -0.00769698, 0.00221995} ;;
578  nonLinearCorrCoefficHG[1][3] = {-0.0279931, 0.0188122, 0.0126234, -0.0169907, 0.00398826} ;
579 
580  // For now we don't use corrections on the LG as it's much harder to measure them
581  //
582  nonLinearCorrCoefficLG = {{ {{{0},
583  {0},
584  {0},
585  {0}}},
586  {{{0},
587  {0},
588  {0},
589  {0}}} }};
590 
591  // Now use 1000 as the offset for the high gain non-linear correction due to the improved
592  // clarity in the high gain/low gain response change around the 10 bit mark with the new LG refit procedure
593  //
594  if (m_doNonLinCorr)
595  zdcDataAnalyzer->SetNonlinCorrParams(1000, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
596 
597  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
598  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
599  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
600  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
601  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
602 
603  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
604  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
605  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
606  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
607 
608  // +++ BAC 07-26-24
609  //
610  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
611  // made at the same time to match the timing shift of the LG channels
612  //
613  // ---
614  timeCorrCoefficLG[0][0] = {0.035+3.25, -0.126189, 0.022724, 0.039116, -0.098255};
615  timeCorrCoefficLG[0][1] = {0.022+3.25, -0.165988, -0.014125, 0.057323, -0.205109};
616  timeCorrCoefficLG[0][2] = {0.01+3.25, -0.136087, -0.007248, -0.014452, -0.060469};
617  timeCorrCoefficLG[0][3] = {0.0+3.25, -0.131067, 0.025579, 0.059994, -0.065595};
618 
619  timeCorrCoefficLG[1][0] = {0.076+3.25, -0.300587, -0.041827, 0.641108, -0.594157};
620  timeCorrCoefficLG[1][1] = {0.057+3.25, -0.223443, -0.125013, -0.176900, 0.348081};
621  timeCorrCoefficLG[1][2] = {0.015+3.25, -0.141721, 0.023936, 0.099657, -0.188526};
622  timeCorrCoefficLG[1][3] = {0.01+3.25, -0.152589, 0.016122, -0.086580, 0.563625};
623 
624  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
625 
626  // Set the amplitude fit range limits
627  //
628  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
629 
630  return zdcDataAnalyzer;
631 }
632 
633 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializePbPb2024()
634 {
635  // Key configuration parameters needed for the data analyzer construction
636  //
637  m_deltaTSample = 3.125;
638  m_numSample = 24;
639 
640  const int deriv2ndThreshDSHG = -45;
641  const int deriv2ndThreshDSLG = -10;
642  const unsigned int peakSample = 10;
643 
644  const float deltaTcutLow = -10;
645  const float deltaTcutHigh = 10;
646  const float chisqDivAmpCutHGVal = 30;
647  const float chisqDivAmpCutLGVal = 50;
648 
649  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
650  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
651 
652  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
653  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
654  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
655 
656  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
657  {1.35, 1.4, 1.3, 1.1}}};
658 
659  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
660 
661  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.5, 31.5, 29.5, 30.5}, {34.5, 33.0, 33, 34.0}}};
662  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{32.25, 32.0, 30.5, 30.5}, {32.4, 33.5, 30.5, 31.4}}};
663 
664  for (size_t side : {0, 1}) {
665  for (size_t module : {0, 1, 2, 3}) {
666  fixTau1Arr[side][module] = true;
667  fixTau2Arr[side][module] = false;
668 
669  peak2ndDerivMinSamples[side][module] = peakSample;
670  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
671  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
672 
673  deltaT0CutLow[side][module] = deltaTcutLow;
674  deltaT0CutHigh[side][module] = deltaTcutHigh;
675  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
676  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
677  }
678  }
679 
680  ATH_MSG_DEBUG( "PbPb2024: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
681 
682  // Construct the data analyzer
683  //
684  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
686  m_presample, "FermiExpLHCf",
687  peak2ndDerivMinSamples,
688  peak2ndDerivMinThresholdsHG,
689  peak2ndDerivMinThresholdsLG,
691  zdcDataAnalyzer->set2ndDerivStep(2);
692  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
693 
694  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1, 1, 1, 1},{1, 1, 1, 1.0}}};
695  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{9.36, 9.7, 10.95, 10.5}, {9.9, 10.5, 11.2, 10.4}}};
696 
697  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
698 
699  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
700  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
701  //
702  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.5, 1.5, 1.5, 1.5}, {1.5, 1.5, 1.5, 1.5}}};
703  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
704 
705  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
706 
707  // Now set cuts and default fit parameters
708  //
709  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
710  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
711  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
712 
713  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
714  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
715  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
716 
717  // Enable two-pass analysis
718  //
719  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-30, -30, -30, -30},
720  {-30, -30, -30, -30},}};
721 
722  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
723  {-8, -8, -8, -8}}};
724 
725  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
726 
727  // Turn on exclusion of early and late samples to address OOT pileup
728  //
729  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
730  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
731 
732  // Set up non-linear corrections for the ZDC
733  //
734  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
735 
736  nonLinearCorrCoefficHG[0][0] = {-0.0225871, 0.00702802, 0.00201155, -0.00675293, 0.00186212} ;
737  nonLinearCorrCoefficHG[0][1] = {-0.0155562, 0.00594092, 0.00382112, -0.00665466, 0.00143384} ;
738  nonLinearCorrCoefficHG[0][2] = {-0.0313621, 0.0134528, 0.00529013, -0.0111751, 0.0029913} ;
739  nonLinearCorrCoefficHG[0][3] = {-0.025108, 0.00301898, 0.022472, -0.0204288, 0.00453215} ;
740  nonLinearCorrCoefficHG[1][0] = {-0.0266648, 0.0106792, -0.00939959, 0.000833011, 0.000199051} ;
741  nonLinearCorrCoefficHG[1][1] = {-0.0246541, 0.000327376, 0.00754946, -0.00710273, 0.00136899} ;
742  nonLinearCorrCoefficHG[1][2] = {-0.0175283, 0.0127954, 0.000235749, -0.00769698, 0.00221995} ;;
743  nonLinearCorrCoefficHG[1][3] = {-0.0279931, 0.0188122, 0.0126234, -0.0169907, 0.00398826} ;
744 
745 
746  // Remove nonlinear corrections while we study the injector pulse
747  nonLinearCorrCoefficHG = {{ {{{0},
748  {0},
749  {0},
750  {0}}},
751  {{{0},
752  {0},
753  {0},
754  {0}}} }};
755 
756  //
757  // We are disabling the old FADC correction moving forward
758  if (m_doNonLinCorr)
759  zdcDataAnalyzer->SetNonlinCorrParams(1000, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
760 
761  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
762  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
763  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
764  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
765  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
766 
767  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
768  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
769  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
770  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
771 
772  // +++ BAC 07-26-24
773  //
774  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
775  // made at the same time to match the timing shift of the LG channels
776  //
777  // ---
778  timeCorrCoefficLG[0][0] = {0.035+3.25, -0.126189, 0.022724, 0.039116, -0.098255};
779  timeCorrCoefficLG[0][1] = {0.022+3.25, -0.165988, -0.014125, 0.057323, -0.205109};
780  timeCorrCoefficLG[0][2] = {0.01+3.25, -0.136087, -0.007248, -0.014452, -0.060469};
781  timeCorrCoefficLG[0][3] = {0.0+3.25, -0.131067, 0.025579, 0.059994, -0.065595};
782 
783  timeCorrCoefficLG[1][0] = {0.076+3.25, -0.300587, -0.041827, 0.641108, -0.594157};
784  timeCorrCoefficLG[1][1] = {0.057+3.25, -0.223443, -0.125013, -0.176900, 0.348081};
785  timeCorrCoefficLG[1][2] = {0.015+3.25, -0.141721, 0.023936, 0.099657, -0.188526};
786  timeCorrCoefficLG[1][3] = {0.01+3.25, -0.152589, 0.016122, -0.086580, 0.563625};
787 
788  // Commenting out the timing correlation for PbPb2024: re-calibraton needed
789  // zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
790 
791  // Set the amplitude fit range limits
792  //
793  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
794 
795  return zdcDataAnalyzer;
796 }
797 
798 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeInjectorpp2024()
799 {
800  // Key configuration parameters needed for the data analyzer construction
801  //
802  m_deltaTSample = 3.125;
803  m_numSample = 24;
804 
805  const int deriv2ndThreshDSHG = -10;
806  const int deriv2ndThreshDSLG = -10;
807  const unsigned int peakSample = 10;
808 
809  const float deltaTcutLow = -50;
810  const float deltaTcutHigh = 50;
811  const float chisqDivAmpCutHGVal = 30;
812  const float chisqDivAmpCutLGVal = 50;
813 
814  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
815  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
816 
817  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
818  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
819  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
820 
821  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
822  {1.35, 1.4, 1.3, 1.1}}};
823 
824  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
825 
826  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
827  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{28, 28, 28, 28}, {28, 28, 28, 28}}};
828 
829  for (size_t side : {0, 1}) {
830  for (size_t module : {0, 1, 2, 3}) {
831  fixTau1Arr[side][module] = false;
832  fixTau2Arr[side][module] = true;
833 
834  peak2ndDerivMinSamples[side][module] = peakSample;
835  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
836  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
837 
838  deltaT0CutLow[side][module] = deltaTcutLow;
839  deltaT0CutHigh[side][module] = deltaTcutHigh;
840  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
841  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
842  }
843  }
844 
845  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
846 
847  // Construct the data analyzer
848  //
849  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
851  m_presample, "FermiExpLHCf",
852  peak2ndDerivMinSamples,
853  peak2ndDerivMinThresholdsHG,
854  peak2ndDerivMinThresholdsLG,
856  zdcDataAnalyzer->set2ndDerivStep(2);
857  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(10);
858 
859  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
860  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
861 
862  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
863 
864  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
865  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
866  //
867  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
868  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{10.0, 10.0, 10.0, 10.0}, {10.0, 10.0, 10.0, 10.0}}};
869 
870  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
871 
872  // Now set cuts and default fit parameters
873  //
874  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
875  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
876  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
877 
878  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
879  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
880  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
881 
882  // Turn on exclusion of early and late samples to address OOT pileup
883  //
884  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
885  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
886 
887 
888  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
889  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
890  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
891  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
892  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
893 
894  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
895  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
896  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
897  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
898 
899  // +++ BAC 07-26-24
900  //
901  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
902  // made at the same time to match the timing shift of the LG channels
903  //
904  // ---
905  timeCorrCoefficLG[0][0] = {0.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
906  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
907  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
908  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
909 
910  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
911  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
912  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
913  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -0.152589, 0.016122, -0.086580, 0.563625};
914 
915  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
916 
917  // Set the amplitude fit range limits
918  //
919  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
920 
921  return zdcDataAnalyzer;
922 }
923 
924 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeInjectorPbPb2024()
925 {
926  // Key configuration parameters needed for the data analyzer construction
927  //
928  m_deltaTSample = 3.125;
929  m_numSample = 24;
930 
931  const int deriv2ndThreshDSHG = -25;
932  const int deriv2ndThreshDSLG = -10;
933  const unsigned int peakSample = 10;
934 
935  const float deltaTcutLow = -10;
936  const float deltaTcutHigh = 10;
937  const float chisqDivAmpCutHGVal = 30;
938  const float chisqDivAmpCutLGVal = 50;
939 
940  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
941  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
942 
943  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
944  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
945  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
946 
947  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.8, 1.8, 1.8, 1.8}, {1.8, 1.8, 1.8, 1.8}}};
948 
949  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{5.5, 5.5, 5.5, 5.5}, {5.5, 5.5, 5.5, 5.5}}};
950 
951  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{33.25, 33, 29.5, 33}, {31.5, 32.5, 32, 32.25}}};
952  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{30.5, 30, 26.75, 30}, {29.5, 32.5, 29.5, 29}}};
953 
954  for (size_t side : {0, 1}) {
955  for (size_t module : {0, 1, 2, 3}) {
956  fixTau1Arr[side][module] = false;
957  fixTau2Arr[side][module] = true;
958 
959  peak2ndDerivMinSamples[side][module] = peakSample;
960  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
961  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
962 
963  deltaT0CutLow[side][module] = deltaTcutLow;
964  deltaT0CutHigh[side][module] = deltaTcutHigh;
965  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
966  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
967  }
968  }
969 
970  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
971 
972  // Construct the data analyzer
973  //
974  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
976  m_presample, "FermiExpLHCf",
977  peak2ndDerivMinSamples,
978  peak2ndDerivMinThresholdsHG,
979  peak2ndDerivMinThresholdsLG,
981 
982  zdcDataAnalyzer->set2ndDerivStep(2);
983  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
984 
985  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
986  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
987 
988  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
989 
990  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
991  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
992  //
993  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{2.0, 2.0, 2.0, 2.0}, {2.0, 2.0, 2.0, 2.0}}};
994  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{15.0, 15.0, 15.0, 15.0}, {15.0, 15.0, 15.0, 15.0}}};
995 
996  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
997 
998  // Now set cuts and default fit parameters
999  //
1000  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1001  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1002  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1003 
1004  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1005  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1006  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1007 
1008  // Set the amplitude fit range limits
1009  //
1010  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1011 
1012  return zdcDataAnalyzer;
1013 }
1014 
1015 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeMonteCarloPbPb2023()
1016 {
1017  // Key configuration parameters needed for the data analyzer construction
1018  //
1019  m_deltaTSample = 3.125;
1020  m_numSample = 24;
1021 
1022  const int deriv2ndThreshDSHG = -25;
1023  const int deriv2ndThreshDSLG = -10;
1024  const unsigned int peakSample = 10;
1025 
1026  const float deltaTcutLow = -10;
1027  const float deltaTcutHigh = 10;
1028  const float chisqDivAmpCutHGVal = 30;
1029  const float chisqDivAmpCutLGVal = 50;
1030 
1031  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1032  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1033 
1034  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1035  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1036  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1037 
1038  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.1, 1.1, 1.1, 1.1},
1039  {1.1, 1.1, 1.1, 1.1}}};
1040 
1041  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
1042 
1043  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
1044  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
1045 
1046  for (size_t side : {0, 1}) {
1047  for (size_t module : {0, 1, 2, 3}) {
1048  fixTau1Arr[side][module] = false;
1049  fixTau2Arr[side][module] = false;
1050 
1051  peak2ndDerivMinSamples[side][module] = peakSample;
1052  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1053  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1054 
1055  deltaT0CutLow[side][module] = deltaTcutLow;
1056  deltaT0CutHigh[side][module] = deltaTcutHigh;
1057  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1058  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1059  }
1060  }
1061 
1062  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1063 
1064  // Construct the data analyzer
1065  //
1066  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1068  m_presample, "FermiExpLHCf",
1069  peak2ndDerivMinSamples,
1070  peak2ndDerivMinThresholdsHG,
1071  peak2ndDerivMinThresholdsLG,
1072  m_lowGainMode));
1073  zdcDataAnalyzer->set2ndDerivStep(2);
1074  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
1075 
1076  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1, 1, 1, 1},{1, 1, 1, 1}}};
1077  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{10.,10.,10.,10.},{10.,10.,10.,10.}}}; // apply constant factor of 10 to high gain data
1078 
1079  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
1080 
1081  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1082  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1083  //
1084  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1085  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{1.5, 1.7, 3, 1.7}, {1.7, 1.6, 2.2, 1.8}}};
1086 
1087  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1088 
1089  // Now set cuts and default fit parameters
1090  //
1091  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1092  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1093  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1094 
1095  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1096  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1097  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1098 
1099  // Enable two-pass analysis
1100  //
1101  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-10, -10, -10, -10},
1102  {-10, -10, -10, -10}}};
1103 
1104  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
1105  {-8, -8, -8, -8}}};
1106 
1107  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
1108 
1109  // Turn on exclusion of early and late samples to address OOT pileup
1110  //
1111  //zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
1112  //zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
1113 
1114  // Set up non-linear corrections for the ZDC
1115  //
1116  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
1117 
1118  nonLinearCorrCoefficHG = {{ {{{0},
1119  {0},
1120  {0},
1121  {0}}},
1122  {{{0},
1123  {0},
1124  {0},
1125  {0}}} }};
1126 
1127  // For now we don't use corrections on the LG as it's much harder to measure them
1128  //
1129  nonLinearCorrCoefficLG = {{ {{{0},
1130  {0},
1131  {0},
1132  {0}}},
1133  {{{0},
1134  {0},
1135  {0},
1136  {0}}} }};
1137 
1138  if (m_doNonLinCorr)
1139  zdcDataAnalyzer->SetNonlinCorrParams(0, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
1140 
1141  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
1142  timeCorrCoefficHG[0][0] = {};
1143  timeCorrCoefficHG[0][1] = {};
1144  timeCorrCoefficHG[0][2] = {};
1145  timeCorrCoefficHG[0][3] = {};
1146 
1147  timeCorrCoefficHG[1][0] = {};
1148  timeCorrCoefficHG[1][1] = {};
1149  timeCorrCoefficHG[1][2] = {};
1150  timeCorrCoefficHG[1][3] = {};
1151 
1152  timeCorrCoefficLG[0][0] = {};
1153  timeCorrCoefficLG[0][1] = {};
1154  timeCorrCoefficLG[0][2] = {};
1155  timeCorrCoefficLG[0][3] = {};
1156 
1157  timeCorrCoefficLG[1][0] = {};
1158  timeCorrCoefficLG[1][1] = {};
1159  timeCorrCoefficLG[1][2] = {};
1160  timeCorrCoefficLG[1][3] = {};
1161 
1162  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
1163 
1164  // Set the amplitude fit range limits
1165  //
1166  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1167 
1168  return zdcDataAnalyzer;
1169 }
1170 
1171 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeDefault()
1172 {
1173  // We rely completely on the default parameters specified in the job properties to control:
1174  // # samples
1175  // frequency (more precisely, time/sample)
1176  // which sample to use as the pre-sample
1177  // where to expact the maxim of the peak (min 2nd derivative)
1178  // thresholds on the 2nd derivative for valid pulses
1179  // whether to fix the tau values in the pulse fitting
1180  // the default tau values
1181  // the nominal T0
1182  // delta T and chisq/amp cuts
1183  //
1184  // For now, we continue to use hard-coded values for the maximum and minimum ADC values
1185  // For now we also use the FermiExp pulse model.
1186  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1187  ZDCDataAnalyzer::ZDCModuleFloatArray tau1{}, tau2{}, t0{};
1188  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
1189  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow{}, deltaT0CutHigh{}, chisqDivAmpCut{};
1190  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1191 
1192  for (size_t side : {0, 1}) {
1193  for (size_t module : {0, 1, 2, 3}) {
1194  fixTau1Arr[side][module] = m_fixTau1;
1195  fixTau2Arr[side][module] = m_fixTau2;
1196  tau1[side][module] = m_tau1;
1197  tau2[side][module] = m_tau2;
1198 
1199  peak2ndDerivMinSamples[side][module] = m_peakSample;
1200  peak2ndDerivMinThresholdsHG[side][module] = -m_Peak2ndDerivThresh;
1201  peak2ndDerivMinThresholdsLG[side][module] = -m_Peak2ndDerivThresh / 2;
1202 
1203  t0[side][module] = m_t0;
1204  deltaT0CutLow[side][module] = -m_deltaTCut;
1205  deltaT0CutHigh[side][module] = m_deltaTCut;
1206  chisqDivAmpCut[side][module] = m_ChisqRatioCut;
1207  }
1208  }
1209 
1210  ATH_MSG_DEBUG( "Default: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1211 
1212  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1213  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1214  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1215 
1216  // Construct the data analyzer
1217  //
1218  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(), m_numSample, m_deltaTSample, m_presample, "FermiExp", peak2ndDerivMinSamples,
1219  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1220 
1221  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1222  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0, t0);
1223  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1224 
1225  if (m_combineDelay) {
1226  ZDCDataAnalyzer::ZDCModuleFloatArray defaultPedestalShifts = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
1227 
1228  zdcDataAnalyzer->enableDelayed(m_delayDeltaT, defaultPedestalShifts);
1229  }
1230 
1231  return zdcDataAnalyzer;
1232 }
1233 
1234 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializePbPb2015G4()
1235 {
1236  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1237  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1238  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
1239  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCut{};
1240  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1241 
1242  const int peakSample = 4;
1243  const float peak2ndDerivThreshHG = -12;
1244  const float peak2ndDerivThreshLG = -10;
1245  ZDCDataAnalyzer::ZDCModuleFloatArray tau1Arr = {{{4.000, 4.000, 4.000, 4.000},
1246  {4.000, 4.000, 4.000, 4.000}}};
1247  ZDCDataAnalyzer::ZDCModuleFloatArray tau2Arr = {{{25.36, 25.05, 25.43, 25.60},
1248  {25.11, 25.08, 25.18, 25.48}}};
1249 
1250  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{57.31, 57.28, 57.30, 57.28},
1251  {57.28, 57.29, 57.31, 57.33}}};
1252  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{57.31, 57.28, 57.30, 57.28},
1253  {57.28, 57.29, 57.31, 57.33}}};
1254 
1255  // Delta T0 cut
1256  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{-10, -10, -10, -10}, {-10, -10, -10, -10}}};
1257  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{ 10, 10, 10, 10}, { 10, 10, 10, 10}}};
1258  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{-10, -10, -10, -10}, {-10, -10, -10, -10}}};
1259  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{ 10, 10, 10, 10}, { 10, 10, 10, 10}}};
1260 
1261  for (size_t side : {0, 1}) {
1262  for (size_t module : {0, 1, 2, 3}) {
1263  fixTau1Arr[side][module] = true;
1264  fixTau2Arr[side][module] = true;
1265 
1266  peak2ndDerivMinSamples[side][module] = peakSample;
1267  peak2ndDerivMinThresholdsHG[side][module] = peak2ndDerivThreshHG;
1268  peak2ndDerivMinThresholdsLG[side][module] = peak2ndDerivThreshLG;
1269 
1270  chisqDivAmpCut[side][module] = 15;
1271  }
1272  }
1273 
1274  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{ 800, 800, 800, 800}}, {{ 800, 800, 800, 800}}}};
1275  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{ 10, 10, 10, 10}}, {{ 10, 10, 10, 10}}}};
1276  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1277 
1278  m_deltaTSample = 12.5;
1279 
1280  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(), 7, m_deltaTSample, 0, "FermiExp", peak2ndDerivMinSamples,
1281  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1282 
1283  // Open up tolerances on the position of the peak for now
1284  //
1285  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(1);
1286 
1287  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1288  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1Arr, tau2Arr, t0HG, t0LG);
1289  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
1290 
1291  zdcDataAnalyzer->SetFitTimeMax(85);
1292  zdcDataAnalyzer->SetSaveFitFunc(false);
1293 
1294  return zdcDataAnalyzer;
1295 }
1296 
1297 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializepPb2016()
1298 {
1299  //
1300  // For now, we continue to use hard-coded values for the maximum and minimum ADC values
1301  // For now we also use the FermiExp pulse model.
1302 
1303  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1304  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
1305  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCut{};
1306  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1307 
1308  // For now we allow the tau values to be controlled by the job properties until they are better determined
1309  //
1310  const int peakSample = 5;
1311  const float peak2ndDerivThreshHG = -12;
1312  const float peak2ndDerivThreshLG = -10;
1313  ZDCDataAnalyzer::ZDCModuleFloatArray tau1Arr = {{{4.000, 3.380, 3.661, 3.679},
1314  {4.472, 4.656, 3.871, 4.061}
1315  }};
1316 
1317  ZDCDataAnalyzer::ZDCModuleFloatArray tau2Arr = {{{22, 24.81, 24.48, 24.45},
1318  {24.17, 24.22, 25.46, 24.45}
1319  }};
1320 
1321  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{70.00, 72.74, 73.09, 72.25},
1322  {75.11, 74.94, 73.93, 74.45}
1323  }};
1324  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{70.00, 73.41, 74.27, 73.30},
1325  {76.28, 76.07, 74.98, 76.54}
1326  }};
1327 
1328  // Delta T0 cut
1329  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
1330  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
1331  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
1332  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
1333 
1334 
1335  for (size_t side : {0, 1}) {
1336  for (size_t module : {0, 1, 2, 3}) {
1337  fixTau1Arr[side][module] = true;
1338  fixTau2Arr[side][module] = true;
1339 
1340  peak2ndDerivMinSamples[side][module] = peakSample;
1341  peak2ndDerivMinThresholdsHG[side][module] = peak2ndDerivThreshHG;
1342  peak2ndDerivMinThresholdsLG[side][module] = peak2ndDerivThreshLG;
1343 
1344  chisqDivAmpCut[side][module] = 15;
1345  }
1346  }
1347 
1348  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1349  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1350  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1351 
1352  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
1353  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1354  slewingParamsHG[0][0] = {0, 0, 0, 0};
1355  slewingParamsHG[0][1] = { -4.780244e-01, -7.150874e-02, 4.614585e-02, 8.015731e-04};
1356  slewingParamsHG[0][2] = { -5.253412e-01, -5.718167e-02, 5.243121e-02, 2.128398e-03};
1357  slewingParamsHG[0][3] = { -5.773952e-01, -5.687478e-02, 4.564267e-02, 1.462294e-03};
1358 
1359  slewingParamsHG[1][0] = { 7.105115e-01, -3.686143e-02, 7.727447e-02, 5.924152e-03};
1360  slewingParamsHG[1][1] = { 4.052120e-02, 4.450686e-03, 8.031615e-02, 4.038097e-03};
1361  slewingParamsHG[1][2] = { 3.389476e-02, -2.056782e-02, 4.805321e-02, -2.627999e-03};
1362  slewingParamsHG[1][3] = { 2.069765e-01, -2.890419e-02, 6.084375e-02, 3.742011e-03};
1363 
1364  slewingParamsLG[0][0] = {0, 0, 0, 0};
1365  slewingParamsLG[0][1] = { -1.632547e+00, -4.827813e-01, -1.379131e-01, -2.522607e-02};
1366  slewingParamsLG[0][2] = { -7.254288e+00, -5.454064e+00, -1.619126e+00, -1.739665e-01};
1367  slewingParamsLG[0][3] = { -1.548400e+01, -1.277708e+01, -3.729333e+00, -3.700458e-01};
1368 
1369  slewingParamsLG[1][0] = { 1.142767e-01, -3.608906e-02, 9.642735e-02, -3.097043e-03};
1370  slewingParamsLG[1][1] = { -5.615388e-01, -1.655047e-02, 8.327350e-02, -4.231348e-03};
1371  slewingParamsLG[1][2] = { -7.370728e-01, -2.887482e-02, 8.293875e-02, -4.482743e-03};
1372  slewingParamsLG[1][3] = { -1.270636e+00, -2.791777e-01, -5.807295e-02, -2.332612e-02};
1373 
1374  // Construct the data analyzer
1375  //
1376  // We adopt hard-coded values for the number of samples and the frequency which we kept fixed for all physics data
1377  //
1378  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(), 7, 25, 0, "FermiExpLinear", peak2ndDerivMinSamples,
1379  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1380 
1381  // Open up tolerances on the position of the peak for now
1382  //
1383  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(1);
1384 
1385  // We alwyas disable the 12EM (sideC) module which was not present (LHCf)
1386  //
1387  zdcDataAnalyzer->disableModule(0, 0);
1388 
1389  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1390  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1Arr, tau2Arr, t0HG, t0LG);
1391  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
1392 
1393  // We allow the combineDelay to be controlled by the properties
1394  //
1395  // if (m_combineDelay) {
1396  m_combineDelay = true;
1397  ZDCDataAnalyzer::ZDCModuleFloatArray defaultPedestalShifts = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
1398 
1399  zdcDataAnalyzer->enableDelayed(-12.5, defaultPedestalShifts);
1400  zdcDataAnalyzer->SetFitTimeMax(140); // This restrict the fit range of the pulse fitting
1401  zdcDataAnalyzer->SetSaveFitFunc(false);
1402  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
1403  slewingParamsHG, slewingParamsLG); // add time slewing correction Sep 17 2019 Bill
1404  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1405 
1406  return zdcDataAnalyzer;
1407 }
1408 
1409 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializePbPb2018()
1410 {
1411  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1412  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{}, peak2ndDerivMinRepassHG{}, peak2ndDerivMinRepassLG{};
1413  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCut{};
1414  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1415 
1416  static constexpr int peakSample = 5;
1417  static constexpr float peak2ndDerivThreshHG = -35;
1418  static constexpr float peak2ndDerivThreshLG = -20;
1419  static constexpr float peak2ndDerivRepassHG = -10;
1420  static constexpr float peak2ndDerivRepassLG = -6;
1421 
1422  ZDCDataAnalyzer::ZDCModuleFloatArray tau1Arr = {{{3.877, 3.998, 3.821, 3.858},
1423  {4.296, 4.064, 3.497, 3.642}
1424  }};
1425 
1426  ZDCDataAnalyzer::ZDCModuleFloatArray tau2Arr = {{{24.40, 25.28, 25.66, 24.12},
1427  {24.42, 24.99, 25.72, 25.29}
1428  }};
1429 
1430  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{70.51, 70.57, 70.13, 69.98},
1431  {74.18, 72.79, 71.77, 72.62}
1432  }};
1433  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{70.70, 70.78, 70.76, 70.91},
1434  {75.16, 73.71, 72.25, 73.61}
1435  }};
1436 
1437  ZDCDataAnalyzer::ZDCModuleFloatArray moduleAmpFractionLG = {{{0.2760, 0.3045, 0.2369, 0.1826},
1438  {0.3216, 0.2593, 0.2511, 0.1680}
1439  }};
1440 
1441  // Delta T0 cut
1442  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
1443  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
1444  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
1445  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
1446 
1447  for (size_t side : {0, 1}) {
1448  for (size_t module : {0, 1, 2, 3}) {
1449  fixTau1Arr[side][module] = true;
1450  fixTau2Arr[side][module] = true;
1451 
1452  peak2ndDerivMinSamples[side][module] = peakSample;
1453  peak2ndDerivMinThresholdsHG[side][module] = peak2ndDerivThreshHG;
1454  peak2ndDerivMinThresholdsLG[side][module] = peak2ndDerivThreshLG;
1455  peak2ndDerivMinRepassHG [side][module] = peak2ndDerivRepassHG;
1456  peak2ndDerivMinRepassLG [side][module] = peak2ndDerivRepassLG;
1457 
1458  chisqDivAmpCut[side][module] = 15;
1459  }
1460  }
1461 
1462  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1463  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1464  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1465 
1466  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1, 1, 1, 1}, {1, 1, 1, 1}}};
1467  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{12, 12, 12, 12}, {12, 12, 12, 12}}};
1468 
1469 
1470  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
1471  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1472  slewingParamsHG[0][0] = { -1.335560e-01, -6.071869e-03, 5.858193e-02, 2.473300e-03};
1473  slewingParamsHG[0][1] = { -1.223062e-01, -4.379469e-02, 4.452285e-02, 2.130210e-03};
1474  slewingParamsHG[0][2] = { -1.021415e-01, -4.254239e-02, 4.939866e-02, 3.849738e-03};
1475  slewingParamsHG[0][3] = { -8.234056e-02, -3.938803e-02, 4.689029e-02, 2.784816e-03};
1476 
1477  slewingParamsHG[1][0] = { -1.640979e-01, -2.780350e-02, 5.755065e-02, -4.244651e-04};
1478  slewingParamsHG[1][1] = { -1.422324e-01, 2.663803e-02, 7.295366e-02, 3.740496e-03};
1479  slewingParamsHG[1][2] = { -9.858124e-02, -2.426132e-02, 4.895967e-02, 2.291393e-03};
1480  slewingParamsHG[1][3] = { -1.070401e-01, -2.256383e-03, 5.833770e-02, 2.255208e-03};
1481 
1482  slewingParamsLG[0][0] = { -2.588446e-01, -3.241086e-02, 7.828661e-02, 1.945547e-03};
1483  slewingParamsLG[0][1] = { -3.112495e-01, -7.419508e-02, 6.825776e-02, 2.148860e-03};
1484  slewingParamsLG[0][2] = { -3.470650e-01, -5.836748e-02, 6.204396e-02, 1.550421e-03};
1485  slewingParamsLG[0][3] = { -4.485435e-01, -4.603790e-02, 5.944799e-02, -1.174585e-03};
1486 
1487  slewingParamsLG[1][0] = { -3.291676e-01, -4.023732e-02, 8.608755e-02, -3.958167e-03};
1488  slewingParamsLG[1][1] = { -2.608969e-01, -2.129786e-03, 6.930791e-02, -4.141910e-03};
1489  slewingParamsLG[1][2] = { -2.505712e-01, -2.195804e-02, 5.137261e-02, -4.058378e-03};
1490  slewingParamsLG[1][3] = { -5.083206e-01, 3.776601e-02, 1.284275e-01, 1.014067e-02};
1491 
1492  // Construct the data analyzer
1493  //
1494  // We adopt hard-coded values for the number of samples and the frequency which we kept fixed for all physics data
1495  //
1496  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer = std::make_unique<ZDCDataAnalyzer>(MakeMessageFunction(), 7, 25, 0, "FermiExpLinear", peak2ndDerivMinSamples, // presample index changed to zero 4/6/19
1497  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode);
1498 
1499  // Open up tolerances on the position of the peak for now
1500  //
1501  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(1);
1502 
1503  // We alwyas disable the 12EM (sideC) module which was not present (LHCf)
1504  //
1505 
1506  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1507  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1Arr, tau2Arr, t0HG, t0LG);
1508  zdcDataAnalyzer->SetModuleAmpFractionLG(moduleAmpFractionLG); // fraction calculation for LGOverflows added Nov 23, 2020
1509  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
1510 
1511  // We allow the combineDelay to be controlled by the properties
1512  //
1513  m_combineDelay = true;
1514  ZDCDataAnalyzer::ZDCModuleFloatArray defaultPedestalShifts = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
1515 
1516  // We use per-module delays to handle the delayed-undelayed swap on EMC
1517  //
1518  ZDCDataAnalyzer::ZDCModuleFloatArray delayDeltaTs = {{{{12.5, -12.5, -12.5, -12.5}},
1519  {{ -12.5, -12.5, -12.5, -12.5}}
1520  }
1521  };
1522 
1523  zdcDataAnalyzer->enableDelayed(delayDeltaTs, defaultPedestalShifts);
1524  zdcDataAnalyzer->SetFitTimeMax(140); // This restrict the fit range of the pulse fitting, requested by BAC 4/6/19
1525  zdcDataAnalyzer->SetSaveFitFunc(false);
1526  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG); // add repass as default Jul 21 2020 Bill
1527  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
1528  slewingParamsHG, slewingParamsLG); // add time slewing correction Sep 17 2019 Bill
1529  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1530 
1531  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1532 
1533  return zdcDataAnalyzer;
1534 }
1535 
1537 {
1538  // We have a complete configuration and so we override all of the default parameters
1539  //
1540 
1541  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{{4.2, 3.8, 5.2, 5.0}},
1542  {{5.0, 3.7, 3.5, 3.5}}
1543  }
1544  };
1545 
1546  // identical to 80 MHz -- is this right
1547  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{{20.0, 20.4, 18.9, 20.8}},
1548  {{19.1, 21.9, 22.6, 23.4}}
1549  }
1550  };
1551 
1552  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples = {{{{1, 1, 2, 1}},
1553  {{1, 1, 1, 1}}
1554  }
1555  };
1556 
1557  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG = {{{{ -8, -8, -8, -8}},
1558  {{ -8, -8, -8, -8}}
1559  }
1560  };
1561 
1562  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsLG = {{{{ -4, -4, -4, -4}},
1563  {{ -4, -4, -4, -4}}
1564  }
1565  };
1566 
1567  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1568  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1569  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1570 
1571  // Set Tau and nominal timing offsets
1572  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1573 
1574  bool fixTau1 = true;
1575  bool fixTau2 = true;
1576 
1577  for (size_t side : {0, 1}) {
1578  for (size_t module : {0, 1, 2, 3}) {
1579  fixTau1Arr[side][module] = fixTau1;
1580  fixTau2Arr[side][module] = fixTau2;
1581  }
1582  }
1583 
1584  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{{53.942, 49.887, 59.633, 46.497}},
1585  {{46.314, 42.267, 50.327, 41.605}}
1586  }
1587  };
1588  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{{51.771, 47.936, 57.438, 44.191}},
1589  {{44.295, 41.755, 48.081, 40.175}}
1590  }
1591  };
1592 
1593 
1594  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1595  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutLG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1596  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
1597  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
1598  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
1599  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
1600 
1601  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
1602 
1603  slewingParamsHG[0][0] = {0, -7.904e-02, 4.686e-02, 1.530e-03 };
1604  slewingParamsHG[0][1] = {0, 2.250e-02, 4.732e-02, 6.050e-03 };
1605  slewingParamsHG[0][2] = {0, 4.388e-02, 6.707e-02, -5.526e-05 };
1606  slewingParamsHG[0][3] = {0, 1.205e-01, 2.726e-02, 2.610e-03 };
1607 
1608  slewingParamsHG[1][0] = {0, 6.861e-02, 5.175e-03, -9.018e-04 };
1609  slewingParamsHG[1][1] = {0, 3.855e-01, -4.442e-02, -2.022e-02 };
1610  slewingParamsHG[1][2] = {0, -4.337e-03, 3.841e-02, 4.661e-03 };
1611  slewingParamsHG[1][3] = {0, 3.623e-01, -3.882e-02, -1.805e-02 };
1612 
1613  slewingParamsLG[0][0] = {0, 1.708e-02, 7.929e-02, 5.079e-03 };
1614  slewingParamsLG[0][1] = {0, 1.406e-01, 1.209e-01, -1.922e-04 };
1615  slewingParamsLG[0][2] = {0, 1.762e-01, 1.118e-01, 1.679e-04 };
1616  slewingParamsLG[0][3] = {0, 1.361e-02, -2.685e-02, -4.168e-02 };
1617 
1618  slewingParamsLG[1][0] = {0, 1.962e-01, -5.025e-03, -2.001e-02 };
1619  slewingParamsLG[1][1] = {0, 3.258e-01, 1.229e-02, -2.925e-02 };
1620  slewingParamsLG[1][2] = {0, 1.393e-01, 8.113e-02, -2.594e-03 };
1621  slewingParamsLG[1][3] = {0, 1.939e-01, 2.188e-02, -5.579e-02 };
1622 
1623  m_zdcDataAnalyzer_40MHz.reset (new ZDCDataAnalyzer(MakeMessageFunction(), 7, 25, 0, "FermiExp", peak2ndDerivMinSamples,
1624  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1625 
1626  m_zdcDataAnalyzer_40MHz->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1627  m_zdcDataAnalyzer_40MHz->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1628  m_zdcDataAnalyzer_40MHz->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
1629  m_zdcDataAnalyzer_40MHz->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
1630  slewingParamsHG, slewingParamsLG);
1631 
1632  std::array<std::array<std::vector<float>, 4>, 2> moduleHGNonLinCorr, moduleLGNonLinCorr;
1633  moduleHGNonLinCorr[0][0] = { -3.76800e-02, 4.63597e-02};
1634  moduleHGNonLinCorr[0][1] = { -1.02185e-01, -1.17548e-01};
1635  moduleHGNonLinCorr[0][2] = { -8.78451e-02, -1.52174e-01};
1636  moduleHGNonLinCorr[0][3] = { -1.04835e-01, -1.96514e-01};
1637  moduleHGNonLinCorr[1][0] = { -6.83115e-02, 3.57802e-02};
1638  moduleHGNonLinCorr[1][1] = { -1.08162e-01, -1.91413e-01};
1639  moduleHGNonLinCorr[1][2] = { -7.82514e-02, -1.21218e-01};
1640  moduleHGNonLinCorr[1][3] = { -2.34354e-02, -2.52033e-01};
1641 
1642  moduleLGNonLinCorr = {{ {{{0},
1643  {0},
1644  {0},
1645  {0}}},
1646  {{{0},
1647  {0},
1648  {0},
1649  {0}}} }};
1650 
1651  if (m_doNonLinCorr) m_zdcDataAnalyzer_40MHz->SetNonlinCorrParams(500, 1000, moduleHGNonLinCorr, moduleLGNonLinCorr);
1652  m_zdcDataAnalyzer_40MHz->SetSaveFitFunc(false);
1653 
1654 }
1655 
1657 {
1658  // We have a complete configuration and so we override all of the default parameters
1659  //
1660 
1661  m_peak2ndDerivMinSamples = {{{{3, 2, 3, 2}},
1662  {{2, 2, 2, 2}}
1663  }
1664  };
1665 
1666  m_peak2ndDerivMinThresholdsHG = {{{{ -8, -8, -8, -8}},
1667  {{ -8, -8, -8, -8}}
1668  }
1669  };
1670 
1671  m_peak2ndDerivMinThresholdsLG = {{{{ -4, -4, -4, -4}},
1672  {{ -4, -4, -4, -4}}
1673  }
1674  };
1675 
1676  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1677  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1678  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{950, 950, 950, 950}}, {{950, 950, 950, 950}}}};
1679 
1680  // Set Tau and nominal timing offsets
1681  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1682 
1683  bool fixTau1 = true;
1684  bool fixTau2 = true;
1685 
1686  for (size_t side : {0, 1}) {
1687  for (size_t module : {0, 1, 2, 3}) {
1688  fixTau1Arr[side][module] = fixTau1;
1689  fixTau2Arr[side][module] = fixTau2;
1690  }
1691  }
1692 
1693  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{{3.9, 3.4, 4.1, 4.2}},
1694  {{4.2, 3.6, 3.3, 3.4}}
1695  }
1696  };
1697 
1698  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{{20.0, 20.4, 18.9, 20.8}},
1699  {{19.1, 21.9, 22.6, 23.4}}
1700  }
1701  };
1702 
1703  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{{44.24, 40.35, 49.3, 36.0}},
1704  {{36.0, 31.1, 40.75, 30.5}}
1705  }
1706  };
1707 
1708  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{{42.65, 38.5, 47.4, 34}},
1709  {{33.7, 29.9, 39.0, 29.3}}
1710  }
1711  };
1712 
1713  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1714  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutLG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1715  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
1716  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
1717  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
1718  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
1719 
1720  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
1721 
1722  slewingParamsHG[0][0] = {0, -6.5e-2, 2.85e-2, -2.83e-3};
1723  slewingParamsHG[0][1] = {0, -5.5e-2, 5.13e-2, 5.6e-3};
1724  slewingParamsHG[0][2] = {0, -1.45e-3, 9.3e-2, 3.9e-3};
1725  slewingParamsHG[0][3] = {0, -2.36e-2, 8.3e-2, 1.1e-3};
1726 
1727  slewingParamsHG[1][0] = {0, -6.5e-2, 4.84e-2, -3.7e-3};
1728  slewingParamsHG[1][1] = {0, 1.34e-2, 6.57e-2, 5.37e-3};
1729  slewingParamsHG[1][2] = {0, -5.37e-2, 3.49e-2, 3.8e-3};
1730  slewingParamsHG[1][3] = {0, -3.3e-2, 3.9e-2, 2.2e-3};
1731 
1732  slewingParamsLG[0][0] = {0, -9.6e-2, 4.39e-2, 2.93e-3 };
1733  slewingParamsLG[0][1] = {0, -5.0e-2, 14.9e-2, 20.6e-3 };
1734  slewingParamsLG[0][2] = {0, -4.4e-2, 5.3e-2, 0, };
1735  slewingParamsLG[0][3] = {0, -9.90e-2, 4.08e-2, 0, };
1736 
1737  slewingParamsLG[1][0] = {0, -8.7e-2, 4.2e-2, -3.2e-3 };
1738  slewingParamsLG[1][1] = {0, -3.26e-2, 3.84e-2, -2.32e-3};
1739  slewingParamsLG[1][2] = {0, -26.8e-2, -2.64e-2, -5.3e-3 };
1740  slewingParamsLG[1][3] = {0, -13.2e-2, 0.45e-2, -2.4e-3 };
1741 
1742 
1745 
1746  m_zdcDataAnalyzer_80MHz->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1747  m_zdcDataAnalyzer_80MHz->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1748  m_zdcDataAnalyzer_80MHz->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
1749  m_zdcDataAnalyzer_80MHz->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
1750  slewingParamsHG, slewingParamsLG);
1751 
1752  std::array<std::array<std::vector<float>, 4>, 2> moduleHGNonLinCorr, moduleLGNonLinCorr;
1753  moduleHGNonLinCorr[0][0] = { -3.76800e-02, 4.63597e-02};
1754  moduleHGNonLinCorr[0][1] = { -1.02185e-01, -1.17548e-01};
1755  moduleHGNonLinCorr[0][2] = { -8.78451e-02, -1.52174e-01};
1756  moduleHGNonLinCorr[0][3] = { -1.04835e-01, -1.96514e-01};
1757  moduleHGNonLinCorr[1][0] = { -6.83115e-02, 3.57802e-02};
1758  moduleHGNonLinCorr[1][1] = { -1.08162e-01, -1.91413e-01};
1759  moduleHGNonLinCorr[1][2] = { -7.82514e-02, -1.21218e-01};
1760  moduleHGNonLinCorr[1][3] = { -2.34354e-02, -2.52033e-01};
1761 
1762  moduleLGNonLinCorr = {{ {{{0},
1763  {0},
1764  {0},
1765  {0}}},
1766  {{{0},
1767  {0},
1768  {0},
1769  {0}}} }};
1770 
1771  if (m_doNonLinCorr) m_zdcDataAnalyzer_80MHz->SetNonlinCorrParams(500, 1000, moduleHGNonLinCorr, moduleLGNonLinCorr);
1772  m_zdcDataAnalyzer_80MHz->SetSaveFitFunc(false);
1773 }
1774 
1776 {
1777  m_tf1SincInterp.reset (new TF1("SincInterp", ZDC::SincInterp, -5., 160., 8));
1778  m_tf1SincInterp->SetNpx(300);
1779 
1780  // Set up calibrations
1781  //
1782  std::string filename = PathResolverFindCalibFile( "ZdcAnalysis/ZdcAnalysisConfig.conf" );
1783  TEnv env(filename.c_str());
1784 
1785  m_zdcEnergyCalibFileName = std::string(env.GetValue("ZdcEnergyCalibFileName", "ZdcCalibrations_v1.root"));
1786  ATH_MSG_INFO("ZDC energy calibration filename " << m_zdcEnergyCalibFileName);
1787  m_zdcTimeCalibFileName = std::string(env.GetValue("ZdcTimeCalibFileName", "ZdcTimeCalibrations_v1.root"));
1788  ATH_MSG_INFO("ZDC time calibration filename " << m_zdcTimeCalibFileName);
1789  m_zdcTriggerEffParamsFileName = std::string(env.GetValue("ZdcTriggerEffFileName", "ZdcTriggerEffParameters_v6.root"));
1790  ATH_MSG_INFO("ZDC trigger efficiencies filename " << m_zdcTriggerEffParamsFileName);
1791 
1792 
1793  if (m_forceCalibRun > -1) {
1794  ATH_MSG_DEBUG("CAREFUL: forcing calibration run/LB =" << m_forceCalibRun << "/" << m_forceCalibLB);
1795 
1796  if (m_forceCalibLB < 0) {
1797  ATH_MSG_ERROR("Invalid settings: Forced run > 0 but lumi block < 0");
1798  return StatusCode::FAILURE;
1799  }
1800  }
1801 
1802  // Use configuration to direct initialization
1803  //
1804  if (m_configuration == "default") {
1806  }
1807  else if (m_configuration == "PbPb2015") {
1808  initialize80MHz();
1809  initialize40MHz();
1810 
1812  }
1813  else if (m_configuration == "pPb2016") {
1815  }
1816  else if (m_configuration == "PbPb2018") {
1818  }
1819  else if (m_configuration == "PbPb2015G4") {
1821  }
1822  else if (m_configuration == "LHCf2022") {
1824  }
1825  else if (m_configuration == "pp2023") {
1827  }
1828  else if (m_configuration == "pp2024") {
1830  }
1831  else if (m_configuration == "PbPb2023") {
1833  }
1834  else if (m_configuration == "PbPb2024") {
1836  }
1837  else if (m_configuration == "Injectorpp2024") {
1839  }
1840  else if (m_configuration == "InjectorPbPb2024") {
1842  }
1843  else if (m_configuration == "MonteCarloPbPb2023") {
1845  }
1846  else {
1847  ATH_MSG_ERROR("Unknown configuration: " << m_configuration);
1848  return StatusCode::FAILURE;
1849  }
1850 
1851  // If an aux suffix is provided, prepend it with "_" so we don't have to do so at each use
1852  //
1853 
1854  ATH_MSG_INFO("Configuration: " << m_configuration);
1855  ATH_MSG_DEBUG("FlipEMDelay: " << m_flipEMDelay);
1856  ATH_MSG_DEBUG("LowGainMode: " << m_lowGainMode);
1857 
1858  ATH_MSG_DEBUG("Using Combined delayed and undelayed samples: " << m_combineDelay);
1859 
1860  ATH_MSG_DEBUG("WriteAux: " << m_writeAux);
1861  ATH_MSG_DEBUG("AuxSuffix: " << m_auxSuffix);
1862  ATH_MSG_DEBUG("DoCalib: " << m_doCalib);
1863  ATH_MSG_DEBUG("ForceCalibRun: " << m_forceCalibRun);
1864  ATH_MSG_DEBUG("ForceCalibLB: " << m_forceCalibLB);
1865  ATH_MSG_DEBUG("NumSampl: " << m_numSample);
1866  ATH_MSG_DEBUG("DeltaTSample: " << m_deltaTSample);
1867  ATH_MSG_DEBUG("Presample: " << m_presample);
1868  ATH_MSG_DEBUG("PeakSample: " << m_peakSample);
1869  ATH_MSG_DEBUG("Peak2ndDerivThresh: " << m_Peak2ndDerivThresh);
1870 
1871  if (m_combineDelay) ATH_MSG_DEBUG("DelayDeltaT: " << m_delayDeltaT);
1872 
1873  ATH_MSG_DEBUG("T0: " << m_t0);
1874  ATH_MSG_DEBUG("Tau1: " << m_tau1);
1875  ATH_MSG_DEBUG("Tau2: " << m_tau2);
1876  ATH_MSG_DEBUG("FixTau1: " << m_fixTau1);
1877  ATH_MSG_DEBUG("FixTau2: " << m_fixTau2);
1878  ATH_MSG_DEBUG("DeltaTCut: " << m_deltaTCut);
1879  ATH_MSG_DEBUG("ChisqRatioCut: " << m_ChisqRatioCut);
1880 
1882 
1883  // Initialize decorations
1884 
1886  ATH_CHECK( m_zdcModuleAmplitude.initialize());
1888  ATH_CHECK( m_zdcModuleCalibEnergy.initialize());
1890  ATH_CHECK( m_zdcModuleCalibTime.initialize());
1892  ATH_CHECK( m_zdcModuleStatus.initialize());
1894  ATH_CHECK( m_zdcModuleTime.initialize());
1896  ATH_CHECK( m_zdcModuleChisq.initialize());
1898  ATH_CHECK( m_zdcModuleAmpNoNonLin.initialize());
1900  ATH_CHECK( m_zdcModuleFitAmp.initialize());
1902  ATH_CHECK( m_zdcModuleFitAmpError.initialize());
1904  ATH_CHECK( m_zdcModuleFitT0.initialize());
1906  ATH_CHECK( m_zdcModuleBkgdMaxFraction.initialize());
1908  ATH_CHECK( m_zdcModulePreSampleAmp.initialize());
1910  ATH_CHECK( m_zdcModulePresample.initialize());
1912  ATH_CHECK( m_zdcModuleMinDeriv2nd.initialize());
1914  ATH_CHECK( m_zdcModuleMaxADC.initialize());
1915 
1917  ATH_CHECK( m_zdcModuleMaxADCHG.initialize());
1919  ATH_CHECK( m_zdcModuleMaxADCLG.initialize());
1920 
1921  // LG refit data
1922  //
1924  ATH_CHECK(m_zdcModuleFitAmpLGRefit.initialize());
1926  ATH_CHECK(m_zdcModuleAmpLGRefit.initialize());
1928  ATH_CHECK(m_zdcModuleAmpCorrLGRefit.initialize());
1930  ATH_CHECK(m_zdcModuleT0LGRefit.initialize());
1932  ATH_CHECK(m_zdcModuleT0SubLGRefit.initialize());
1934  ATH_CHECK( m_zdcModuleChisqLGRefit.initialize());
1935 
1936  // ZDC per-calorimeter data
1937  //
1939  ATH_CHECK( m_zdcSumUncalibSum.initialize());
1941  ATH_CHECK( m_zdcSumCalibEnergy.initialize());
1943  ATH_CHECK( m_zdcSumCalibEnergyErr.initialize());
1945  ATH_CHECK( m_zdcSumUncalibSumErr.initialize());
1947  ATH_CHECK( m_zdcSumFinalEnergy.initialize());
1949  ATH_CHECK( m_zdcSumAverageTime.initialize());
1951  ATH_CHECK( m_zdcSumStatus.initialize());
1953  ATH_CHECK( m_zdcSumModuleMask.initialize());
1954 
1955  if (m_writeAux && m_auxSuffix != "") {
1956  ATH_MSG_DEBUG("suffix string = " << m_auxSuffix);
1957  }
1958 
1959  m_init = true;
1960 
1961  return StatusCode::SUCCESS;
1962 }
1963 
1965 {
1966 
1967 }
1968 
1970 {
1971  ATH_MSG_DEBUG("Setting up new run " << runNumber);
1972 
1973  // We do nothing for the default configuration
1974  //
1975  if (m_configuration != "default") {
1976  if (m_configuration == "PbPb2015") {
1977  //
1978  // Two periods, 40 MHz and 80 MHz readout
1979  //
1982  }
1983  }
1984 
1985  return StatusCode::SUCCESS;
1986 }
1987 
1988 
1990 {
1991 
1992  if (moduleContainer.size()==0) return StatusCode::SUCCESS; // if no modules, do nothing
1993 
1995  if (!eventInfo.isValid()) return StatusCode::FAILURE;
1996 
1997  // Check for decoding errors and bail out if ZDC error found
1999  if (zdcErr)
2000  {
2001  ATH_MSG_WARNING("ZDC decoding error found - abandoning ZDC reco!");
2002  return StatusCode::SUCCESS;
2003  }
2004 
2005  // check for new run number, if new, possibly update configuration and/or calibrations
2006  //
2007  unsigned int thisRunNumber = eventInfo->runNumber();
2008  if (thisRunNumber != m_runNumber) {
2009  ATH_MSG_DEBUG("ZDC analysis tool will be configured for run " << thisRunNumber);
2010 
2011  ATH_CHECK(configureNewRun(thisRunNumber)); // ALWAYS check methods that return StatusCode
2012 
2013  ATH_MSG_DEBUG("Setting up calibrations");
2014 
2015  if (m_doFADCCorr)
2016  {
2017  unsigned int calibRunNumber = thisRunNumber;
2018  if (m_forceCalibRun > -1) calibRunNumber = m_forceCalibRun;
2019  try
2020  {
2021  setFADCCorrections(calibRunNumber);
2022  }
2023  catch(std::runtime_error&)
2024  {
2025  m_doFADCCorr = false;
2026  }
2027  }
2028 
2029  if (m_doCalib) {
2030  //
2031  // Check for calibration override
2032  //
2033  unsigned int calibRunNumber = thisRunNumber;
2034  if (m_forceCalibRun > -1) calibRunNumber = m_forceCalibRun;
2035  try
2036  {
2037  setEnergyCalibrations(calibRunNumber);
2038  }
2039  catch(std::runtime_error&)
2040  {
2041  m_doCalib = false;
2042  }
2043 
2044  if (m_doTrigEff) initializeTriggerEffs(calibRunNumber); // if energy calibrations fail to load, then so will trigger efficiencies
2045  if (m_doTimeCalib) setTimeCalibrations(calibRunNumber);
2046  }
2047 
2048  m_runNumber = thisRunNumber;
2049  }
2050 
2051  m_lumiBlock = eventInfo->lumiBlock();
2052 
2053  unsigned int calibLumiBlock = m_lumiBlock;
2054  if (m_doCalib) {
2055  if (m_forceCalibRun > 0) calibLumiBlock = m_forceCalibLB;
2056  }
2057 
2058  ATH_MSG_DEBUG("Starting event processing");
2059  ATH_MSG_DEBUG("LB=" << calibLumiBlock);
2060 
2061  m_zdcDataAnalyzer->StartEvent(calibLumiBlock);
2062 
2063  static const SG::ConstAccessor<std::vector<uint16_t> > g0dataAcc ("g0data");
2064  static const SG::ConstAccessor<std::vector<uint16_t> > g1dataAcc ("g1data");
2065 
2066  const std::vector<unsigned short>* adcUndelayLG = 0;
2067  const std::vector<unsigned short>* adcUndelayHG = 0;
2068 
2069  const std::vector<unsigned short>* adcDelayLG = 0;
2070  const std::vector<unsigned short>* adcDelayHG = 0;
2071 
2072  ATH_MSG_DEBUG("Processing modules");
2073  for (const auto zdcModule : moduleContainer)
2074  {
2075  int side = -1;
2076  if (zdcModule->zdcSide() == -1) side = 0;
2077  else if (zdcModule->zdcSide() == 1) side = 1;
2078  else {
2079  // Invalid side
2080  //
2081  ATH_MSG_WARNING("Invalid side value found for module number: " << zdcModule->zdcModule() << ", side value = " << side);
2082  continue;
2083  }
2084  // Ignore MC only modules
2085  if(zdcModule->zdcModule() > 4) continue;
2086 
2087  if (zdcModule->zdcType() == 0) {
2088  //
2089  // This is ZDC data
2090  //
2091  if (m_LHCRun==3) // no delay channels, so we drop the index
2092  {
2093  adcUndelayLG = &g0dataAcc(*zdcModule); // g0
2094  adcUndelayHG = &g1dataAcc(*zdcModule); // g1
2095  }
2096  else if (m_LHCRun==2)
2097  {
2098 
2099 
2100  static const SG::ConstAccessor<std::vector<uint16_t> > g0d1dataAcc ("g0d1data");
2101  static const SG::ConstAccessor<std::vector<uint16_t> > g1d1dataAcc ("g1d1data");
2102  static const SG::ConstAccessor<std::vector<uint16_t> > g0d0dataAcc ("g0d0data");
2103  static const SG::ConstAccessor<std::vector<uint16_t> > g1d0dataAcc ("g1d0data");
2104 
2105  if (zdcModule->zdcModule() == 0 && m_flipEMDelay) // flip delay/non-delay for 2015 ONLY
2106  {
2107  adcUndelayLG = &g0d1dataAcc(*zdcModule); // g0d1
2108  adcUndelayHG = &g1d1dataAcc(*zdcModule); // g1d1
2109  adcDelayLG = &g0d0dataAcc(*zdcModule); // g0d0
2110  adcDelayHG = &g1d0dataAcc(*zdcModule); // g1d0
2111  }
2112  else // nominal configuation
2113  {
2114  adcUndelayLG = &g0d0dataAcc(*zdcModule); // g0d0
2115  adcUndelayHG = &g1d0dataAcc(*zdcModule); // g1d0
2116  adcDelayLG = &g0d1dataAcc(*zdcModule); // g0d1
2117  adcDelayHG = &g1d1dataAcc(*zdcModule); // g1d1
2118  }
2119  }
2120  else
2121  {
2122  ATH_MSG_WARNING("Unknown LHC Run " << m_LHCRun);
2123  return StatusCode::FAILURE;
2124  }
2125 
2126  // Why were these static? to optimize processing time
2127  std::vector<float> HGUndelADCSamples(m_numSample);
2128  std::vector<float> LGUndelADCSamples(m_numSample);
2129 
2130  if (LGUndelADCSamples.size() < adcUndelayLG->size()) {
2131  LGUndelADCSamples.resize(adcUndelayLG->size());
2132  }
2133 
2134  if (HGUndelADCSamples.size() < adcUndelayHG->size()) {
2135  HGUndelADCSamples.resize(adcUndelayHG->size());
2136  }
2137 
2138  std::copy(adcUndelayLG->begin(), adcUndelayLG->end(), LGUndelADCSamples.begin());
2139  std::copy(adcUndelayHG->begin(), adcUndelayHG->end(), HGUndelADCSamples.begin());
2140 
2141  int side = (zdcModule->zdcSide() == -1) ? 0 : 1 ;
2142 
2143  if (!m_combineDelay) {
2144  m_zdcDataAnalyzer->LoadAndAnalyzeData(side, zdcModule->zdcModule(), HGUndelADCSamples, LGUndelADCSamples);
2145  }
2146  else {
2147  std::vector<float> HGDelayADCSamples(m_numSample);
2148  std::vector<float> LGDelayADCSamples(m_numSample);
2149  if (adcDelayLG and adcDelayHG){
2150  std::copy(adcDelayLG->begin(), adcDelayLG->end(), LGDelayADCSamples.begin());
2151  std::copy(adcDelayHG->begin(), adcDelayHG->end(), HGDelayADCSamples.begin());
2152  }else{
2153  ATH_MSG_ERROR("adcDelayLG or adcDelayHG pointers are null");
2154  return StatusCode::FAILURE;
2155  }
2156  // If the delayed channels actually come earlier (as in the pPb in 2016), we invert the meaning of delayed and undelayed
2157  // see the initialization sections for similar inversion on the sign of the pedestal difference
2158  //
2159 
2160  m_zdcDataAnalyzer->LoadAndAnalyzeData(side, zdcModule->zdcModule(),
2161  HGUndelADCSamples, LGUndelADCSamples,
2162  HGDelayADCSamples, LGDelayADCSamples);
2163  }
2164  }
2165  }
2166 
2167  ATH_MSG_DEBUG("Finishing event processing");
2168 
2169  m_zdcDataAnalyzer->FinishEvent();
2170 
2171  ATH_MSG_DEBUG("Adding variables with suffix=" + m_auxSuffix);
2172 
2190 
2197 
2198  // CalibTime
2199  // Status
2200  // Time
2201  // Chisq
2202  // AmpNoNonLin
2203  // FitAmp
2204  // FitAmpError
2205  // FitT0
2206  // BkgdMaxFraction
2207  // PreSampleAmp
2208  // Presample
2209  // MinDeriv2nd
2210  // MaxADC
2211 
2212  for (const auto zdcModule : moduleContainer)
2213  {
2214  int side = (zdcModule->zdcSide() == -1) ? 0 : 1 ;
2215  int mod = zdcModule->zdcModule();
2216  // Ignore MC only modules
2217  if(mod > 4) continue;
2218 
2219  if (zdcModule->zdcType() == 0) {
2220  // this is the main ZDC
2221  if (m_writeAux) {
2222  float calibEnergy = m_zdcDataAnalyzer->GetModuleCalibAmplitude(side, mod);
2223  zdcModuleCalibEnergy(*zdcModule) = calibEnergy;
2224  zdcModuleCalibTime(*zdcModule) = m_zdcDataAnalyzer->GetModuleCalibTime(side, mod);
2225 
2226  zdcModuleAmplitude(*zdcModule) = m_zdcDataAnalyzer->GetModuleAmplitude(side, mod);
2227  zdcModuleStatus(*zdcModule) = m_zdcDataAnalyzer->GetModuleStatus(side, mod);
2228  zdcModuleTime(*zdcModule) = m_zdcDataAnalyzer->GetModuleTime(side, mod);
2229 
2230  const ZDCPulseAnalyzer* pulseAna_p = m_zdcDataAnalyzer->GetPulseAnalyzer(side, mod);
2231  zdcModuleChisq(*zdcModule) = pulseAna_p->GetChisq();
2232  zdcModuleAmpNoNonLin(*zdcModule) = pulseAna_p->GetAmpNoNonLin();
2233  zdcModuleFitAmp(*zdcModule) = pulseAna_p->GetFitAmplitude();
2234  zdcModuleFitAmpError(*zdcModule) = pulseAna_p->GetAmpError();
2235  zdcModuleFitT0(*zdcModule) = pulseAna_p->GetFitT0();
2236  zdcModuleBkgdMaxFraction(*zdcModule) = pulseAna_p->GetBkgdMaxFraction();
2237  zdcModulePreSampleAmp(*zdcModule) = pulseAna_p->GetPreSampleAmp();
2238  zdcModulePresample(*zdcModule) = pulseAna_p->getPresample();
2239  zdcModuleMinDeriv2nd(*zdcModule) = pulseAna_p->GetMinDeriv2nd();
2240  zdcModuleMaxADC(*zdcModule) = pulseAna_p->getMaxADCSub();
2241  zdcModuleMaxADCHG(*zdcModule) = pulseAna_p->getMaxADCHG();
2242  zdcModuleMaxADCLG(*zdcModule) = pulseAna_p->getMaxADCLG();
2243 
2244  zdcModuleAmpLGRefit(*zdcModule) = pulseAna_p->getRefitLGAmp();
2245  zdcModuleFitAmpLGRefit(*zdcModule) = pulseAna_p->getRefitLGFitAmp();
2246  zdcModuleAmpCorrLGRefit(*zdcModule) = pulseAna_p->getRefitLGAmpCorr();
2247  zdcModuleT0LGRefit(*zdcModule) = pulseAna_p->getRefitLGTime();
2248  zdcModuleT0SubLGRefit(*zdcModule) = pulseAna_p->getRefitLGTimeSub();
2249  zdcModuleChisqLGRefit(*zdcModule) = pulseAna_p->getRefitLGChisq();
2250  }
2251  //ATH_MSG_DEBUG ("side = " << side << " module=" << zdcModule->zdcModule() << " CalibEnergy=" << zdcModule->auxdecor<float>("CalibEnergy")
2252  // << " should be " << m_zdcDataAnalyzer->GetModuleCalibAmplitude(side, mod));
2253  }
2254  }
2255 
2256  // Output sum information
2257  // In Run 3 - we have to assume the container already exists (since it is needed to store the per-side trigger info)
2258  // reprocessing will add new variables with the suffix
2259 
2268 
2269  for (const auto zdc_sum: moduleSumContainer)
2270  {
2271  ATH_MSG_DEBUG("Extracting ZDC side " << zdc_sum->zdcSide());
2272 
2273  if (zdc_sum->zdcSide()==0) continue; // skip new global sum
2274 
2275  int iside = (zdc_sum->zdcSide()==-1) ? 0 : 1;
2276 
2277  float uncalibSum = getUncalibModuleSum(iside);
2278  zdcSumUncalibSum(*zdc_sum) = uncalibSum;
2279  float uncalibSumErr = getUncalibModuleSumErr(iside);
2280  zdcSumUncalibSumErr(*zdc_sum) = uncalibSumErr;
2281 
2282  float calibEnergy = getCalibModuleSum(iside);
2283  zdcSumCalibEnergy(*zdc_sum) = calibEnergy;
2284  float calibEnergyErr = getCalibModuleSumErr(iside);
2285  zdcSumCalibEnergyErr(*zdc_sum) = calibEnergyErr;
2286 
2287  float finalEnergy = calibEnergy;
2288  zdcSumFinalEnergy(*zdc_sum) = finalEnergy;
2289  zdcSumAverageTime(*zdc_sum) = getAverageTime(iside);
2290  zdcSumStatus(*zdc_sum) = !sideFailed(iside);
2291  zdcSumModuleMask(*zdc_sum) = (getModuleMask() >> (4 * iside)) & 0xF;
2292  }
2293 
2294  return StatusCode::SUCCESS;
2295 }
2296 
2298 {
2299 
2300  char name[128];
2301 
2302  std::string filename;
2303  if (m_LHCRun==3)
2304  {
2305  filename = PathResolverFindCalibFile( ("ZdcAnalysis/ZdcCalib_Run"+TString::Itoa(runNumber,10)+".root").Data() );
2306  }
2307  else if (m_LHCRun==2)
2308  {
2309  filename = PathResolverFindCalibFile( ("ZdcAnalysis/" + m_zdcEnergyCalibFileName).c_str() );
2310  }
2311  else
2312  {
2313  ATH_MSG_WARNING("No LHC Run defined, so no calibration allowed");
2314  return;
2315  }
2316 
2317  ATH_MSG_INFO("Opening energy calibration file " << filename);
2318  std::unique_ptr<TFile> fCalib (TFile::Open(filename.c_str(), "READ"));
2319 
2320  if (fCalib == nullptr || fCalib->IsZombie())
2321  {
2322  ATH_MSG_INFO ("failed to open file: " << filename);
2323  throw std::runtime_error ("failed to open file " + filename);
2324  }
2325 
2326  std::array<std::array<std::unique_ptr<TSpline>, 4>, 2> splines;
2327 
2328  // "m_calibVersion", called CalibVersion when settings parameters in python, is a directory within the run-based calibration file
2329  TString calibVersion;
2330  if (m_calibVersion != "") calibVersion = m_calibVersion + "/";
2331 
2332  for (int iside = 0; iside < 2; iside++)
2333  {
2334  for (int imod = 0; imod < 4; imod++)
2335  {
2336  sprintf(name, "ZDC_Ecalib_run%u_s%d_m%d", runNumber, iside, imod);
2337  ATH_MSG_DEBUG("Searching for spline " << name);
2338  TSpline3* s = (TSpline3*) fCalib->GetObjectChecked(calibVersion+TString(name), "TSpline3");
2339  if (!s && m_doCalib)
2340  {
2341  ATH_MSG_WARNING("No calibrations for run " << runNumber);
2342  m_doCalib = false;
2343  }
2344 
2345  if (s)
2346  {
2347  splines[iside][imod].reset (s);
2348  }
2349  else
2350  {
2351  ATH_MSG_WARNING("No spline " << name);
2352  }
2353  }
2354  }
2355  fCalib->Close();
2356 
2357  if (m_doCalib) m_zdcDataAnalyzer->LoadEnergyCalibrations(splines);
2358 
2359  return;
2360 }
2361 
2363 {
2364  std::string filename;
2365 
2366  if (m_LHCRun==3)
2367  {
2368  filename = PathResolverFindCalibFile( ("ZdcAnalysis/ZdcCalib_Run"+TString::Itoa(runNumber,10)+".root").Data() );
2369  }
2370  else if (m_LHCRun==2)
2371  {
2373  }
2374  else
2375  {
2376  ATH_MSG_WARNING("No LHC Run defined, so no time calibration allowed");
2377  return;
2378  }
2379 
2380  char name[128] = {0};
2381  ATH_MSG_INFO("Opening time calibration file " << filename);
2382  std::unique_ptr<TFile> fCalib (TFile::Open(filename.c_str(), "READ"));
2383 
2384  // "m_calibVersion", called CalibVersion when settings parameters in python, is a directory within the run-based calibration file
2385  TString calibVersion = "";
2386  if (m_calibVersion != "") calibVersion = m_calibVersion + "/";
2387 
2388  if (fCalib && !fCalib->IsZombie())
2389  {
2390  bool success = true;
2391  std::array<std::array<std::unique_ptr<TSpline>, 4>, 2> T0HGOffsetSplines;
2392  std::array<std::array<std::unique_ptr<TSpline>, 4>, 2> T0LGOffsetSplines;
2393  std::unique_ptr<TSpline3> spline;
2394  for (int iside = 0; iside < 2; iside++)
2395  {
2396  for (int imod = 0; imod < 4; imod++)
2397  {
2398  sprintf(name, "ZDC_T0calib_run%u_HG_s%d_m%d", runNumber, iside, imod);
2399  spline.reset (static_cast<TSpline3*>(fCalib->GetObjectChecked(calibVersion+TString(name), "TSpline3")));
2400  if (spline)
2401  {
2402  T0HGOffsetSplines[iside][imod] = std::move (spline);
2403  }
2404  else
2405  {
2406  ATH_MSG_WARNING("No time calib. spline " << calibVersion+name);
2407  success = false;
2408  }
2409 
2410  sprintf(name, "ZDC_T0calib_run%u_LG_s%d_m%d", runNumber, iside, imod);
2411  spline.reset (static_cast<TSpline3*>(fCalib->GetObjectChecked(calibVersion+TString(name), "TSpline3")));
2412  if (spline)
2413  {
2414  T0LGOffsetSplines[iside][imod] = std::move (spline);
2415  }
2416  else
2417  {
2418  ATH_MSG_WARNING("No time calib. spline " << calibVersion+name);
2419  success = false;
2420  }
2421  }
2422  }
2423 
2424  if (success)
2425  m_zdcDataAnalyzer->LoadT0Calibrations(T0HGOffsetSplines, T0LGOffsetSplines);
2426  else
2427  ATH_MSG_WARNING("Time calibration failed - no T0 offsets loaded " << calibVersion+name);
2428 
2429  fCalib->Close();
2430  }
2431  else
2432  {
2433  ATH_MSG_WARNING("No time calibration file " << filename);
2434  }
2435 }
2436 
2438 {
2439  std::string filename;
2440 
2441  if (m_LHCRun==3) {
2442  std::string runString;
2443 
2444  if (runNumber == 0) runString = "ZdcFADCCorr_" + m_configuration + "_default.root";
2445  else runString = ("ZdcFADCCorr_Run"+TString::Itoa(runNumber,10)+".root").Data();
2446 
2447  filename = PathResolverFindCalibFile("ZdcAnalysis/" + runString );
2448  }
2449  else {
2450  ATH_MSG_WARNING("setFADCCorrections: FADC corrections not implemented for Run 2");
2451  return;
2452  }
2453 
2454  if (filename.empty())
2455  {
2456  ATH_MSG_INFO("FADC correction requested but no calibration file found");
2457  m_doFADCCorr = false;
2458  return;
2459  }
2460 
2461  ATH_MSG_INFO("Opening FADC corrections file " << filename);
2462  std::unique_ptr<TFile> fFADCCorr(TFile::Open(filename.c_str(), "READ"));
2463 
2464  if (!fFADCCorr->IsOpen()) {
2465  ATH_MSG_INFO ("setFADCCorrections: failed to open file: " << filename);
2466  throw std::runtime_error ("ZdcAnalysisTool failed to open FADCCorrections file " + filename);
2467  }
2468 
2469  // Attempt to read histograms with corrections from file
2470  //
2471  bool readSuccess = true;
2472  std::array<std::array<std::unique_ptr<const TH1>, 4>, 2> histogramsHG;
2473  std::array<std::array<std::unique_ptr<const TH1>, 4>, 2> histogramsLG;
2474 
2475  for (size_t side : {0, 1}) {
2476  for (int module : {0, 1, 2, 3}) {
2477  std::string histNameHG = "ZDC_FADCCorr_s" + std::to_string(side) + "_m" + std::to_string(module)+"_HG";
2478  std::string histNameLG = "ZDC_FADCCorr_s" + std::to_string(side) + "_m" + std::to_string(module)+"_LG";
2479 
2480  ATH_MSG_DEBUG("setFADCCorrections: Searching for histograms HG and LG: " << histNameHG << ", " << histNameLG);
2481 
2482  TH1* histHG_ptr = static_cast<TH1*>(fFADCCorr->GetObjectChecked(histNameHG.c_str(), "TH1"));
2483  TH1* histLG_ptr = static_cast<TH1*>(fFADCCorr->GetObjectChecked(histNameLG.c_str(), "TH1"));
2484 
2485  if (!histHG_ptr || !histLG_ptr) {
2486  std::string errMsg = "setFADCCorrections: unable to read FADC correction histogram(s) ";
2487  if (!histHG_ptr) errMsg += histNameHG + " ";
2488  if (!histLG_ptr) errMsg += histNameLG;
2489 
2490  ATH_MSG_ERROR(errMsg);
2491  readSuccess = false;
2492  break;
2493  }
2494  else {
2495  //
2496  // Check for valid range (Lion uses -0.5 to 4095.5)
2497  //
2498 
2499  if ( std::abs(histHG_ptr->GetXaxis()->GetXmin()+0.5) > 1e-3 || std::abs(histHG_ptr->GetXaxis()->GetXmax() - 4095.5) > 1e-3) {
2500  ATH_MSG_ERROR("setFADCCorrections: invalid axis range for HG FADC corrections in histogram with name " << histNameHG);
2501  readSuccess = false;
2502  break;
2503  }
2504  if (std::abs(histLG_ptr->GetXaxis()->GetXmin()+0.5) > 1e-3 || std::abs(histLG_ptr->GetXaxis()->GetXmax() - 4095.5) > 1e-3) {
2505  ATH_MSG_ERROR("setFADCCorrections: invalid axis range for HG FADC corrections in histogram with name " << histNameLG);
2506  readSuccess = false;
2507  break;
2508  }
2509 
2510  histogramsHG[side][module].reset(histHG_ptr);
2511  histogramsLG[side][module].reset(histLG_ptr);
2512  }
2513  }
2514  }
2515 
2516  fFADCCorr->Close();
2517 
2518  if (readSuccess) {
2519  m_zdcDataAnalyzer->enableFADCCorrections(m_doFADCCorrPerSample, histogramsHG, histogramsLG);
2520  }
2521  else {
2522  ATH_MSG_ERROR("setFADCCorrections: due to at least one error, FADC corrections are not implemented");
2523  m_doFADCCorr = false;
2524  }
2525 
2526  return;
2527 }
2528 
2529 
2531 {
2532  if (!m_init)
2533  {
2534  ATH_MSG_WARNING("Tool not initialized!");
2535  return StatusCode::FAILURE;
2536  }
2537  m_eventReady = false;
2538  ATH_MSG_DEBUG ("Trying to retrieve " << m_zdcModuleContainerName);
2539 
2540  m_zdcModules = 0;
2542 
2543  m_zdcSums = 0;
2545 
2546  m_eventReady = true;
2547 
2549 
2550  return StatusCode::SUCCESS;
2551 }
2552 
2553 bool ZdcAnalysisTool::sigprocMaxFinder(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual)
2554 {
2555  size_t nsamp = adc.size();
2556  float presamp = adc.at(0);
2557  unsigned short max_adc = 0;
2558  int max_index = -1;
2559  for (size_t i = 0; i < nsamp; i++)
2560  {
2561  if (adc[i] > max_adc)
2562  {
2563  max_adc = adc[i];
2564  max_index = i;
2565  }
2566  }
2567  amp = max_adc - presamp;
2568  time = max_index * deltaT;
2569  qual = 1.;
2570 
2571  if (max_index == -1)
2572  {
2573  qual = 0.;
2574  return false;
2575  }
2576 
2577  return true;
2578 }
2579 
2580 bool ZdcAnalysisTool::sigprocSincInterp(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual)
2581 {
2582  size_t nsamp = adc.size();
2583  float presamp = adc.at(0);
2584  m_tf1SincInterp->SetParameter(0, deltaT);
2585  for (size_t i = 0; i < nsamp; i++)
2586  {
2587  m_tf1SincInterp->SetParameter(i + 1, adc.at(i) - presamp);
2588  }
2589  amp = m_tf1SincInterp->GetMaximum();
2590  time = m_tf1SincInterp->GetMaximumX();
2591  qual = 1.;
2592  return true;
2593 }
2594 
2596 {
2597  if (!m_zdcDataAnalyzer) return 0;
2598  return m_zdcDataAnalyzer->GetModuleSum(side);
2599 }
2600 
2602 {
2603  if (!m_zdcDataAnalyzer) return 0;
2604  return m_zdcDataAnalyzer->GetCalibModuleSum(side);
2605 }
2606 
2608 {
2609  if (!m_zdcDataAnalyzer) return 0;
2610  return m_zdcDataAnalyzer->GetCalibModuleSumErr(side);
2611 }
2612 
2614 {
2615  if (!m_zdcDataAnalyzer) return 0;
2616  return m_zdcDataAnalyzer->GetModuleSum(side);
2617 }
2618 
2620 {
2621  if (!m_zdcDataAnalyzer) return 0;
2622  return m_zdcDataAnalyzer->GetModuleSumErr(side);
2623 }
2624 
2626 {
2627  if (!m_zdcDataAnalyzer) return 0;
2628  return m_zdcDataAnalyzer->GetAverageTime(side);
2629 }
2630 
2632 {
2633  if (!m_zdcDataAnalyzer) return 0;
2634  return m_zdcDataAnalyzer->SideFailed(side);
2635 }
2636 
2638 {
2639  if (!m_zdcDataAnalyzer) return 0;
2640  return m_zdcDataAnalyzer->GetModuleMask();
2641 }
2642 
2644 {
2645  if (!m_doTrigEff) return -1;
2646 
2647  m_zdcTriggerEfficiency->UpdatelumiBlock(m_lumiBlock);
2648  float adcSum = getModuleSum(side);
2649  double eff = m_zdcTriggerEfficiency->GetEfficiency(side, adcSum);
2650  return eff;
2651 }
2652 
2654 {
2655  if (!m_doCalib) return -1;
2656 
2657  m_zdcTriggerEfficiency->UpdatelumiBlock(m_lumiBlock);
2658  float adcSum = getModuleSum(side);
2659  std::pair<double, double> eff_pair = m_zdcTriggerEfficiency->GetEfficiencyAndError(msg(), side, adcSum);
2660  return eff_pair.second;
2661 }
2662 
2663 
2664 } // namespace ZDC
ZDC::ZdcAnalysisTool::m_zdcTriggerEffParamsFileName
std::string m_zdcTriggerEffParamsFileName
Definition: ZdcAnalysisTool.h:132
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ZDC::ZdcAnalysisTool::m_zdcModuleMaxADCHG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADCHG
Definition: ZdcAnalysisTool.h:215
WriteHandle.h
Handle class for recording to StoreGate.
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ZDC::ZdcAnalysisTool::MakeMessageFunction
ZDCMsg::MessageFunctionPtr MakeMessageFunction()
Definition: ZdcAnalysisTool.h:77
ZDC::ZdcAnalysisTool::m_zdcModuleContainerName
std::string m_zdcModuleContainerName
Definition: ZdcAnalysisTool.h:148
ZDC::ZdcAnalysisTool::initializeInjectorpp2024
std::unique_ptr< ZDCDataAnalyzer > initializeInjectorpp2024()
Definition: ZdcAnalysisTool.cxx:798
ZDCPulseAnalyzer::getRefitLGAmp
float getRefitLGAmp() const
Definition: ZDCPulseAnalyzer.h:603
ZDC::ZdcAnalysisTool::m_doFADCCorr
bool m_doFADCCorr
Definition: ZdcAnalysisTool.h:158
ZDC::ZdcAnalysisTool::m_peak2ndDerivMinSamples
ZDCDataAnalyzer::ZDCModuleIntArray m_peak2ndDerivMinSamples
Definition: ZdcAnalysisTool.h:189
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
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
ZDC::ZdcAnalysisTool::m_zdcModuleChisq
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleChisq
Definition: ZdcAnalysisTool.h:205
ZDC::ZdcAnalysisTool::m_zdcModules
const xAOD::ZdcModuleContainer * m_zdcModules
Definition: ZdcAnalysisTool.h:149
ZDC::ZdcAnalysisTool::reprocessZdc
StatusCode reprocessZdc() override
Definition: ZdcAnalysisTool.cxx:2530
ZDC::ZdcAnalysisTool::initializePbPb2024
std::unique_ptr< ZDCDataAnalyzer > initializePbPb2024()
Definition: ZdcAnalysisTool.cxx:633
ZDC::ZdcAnalysisTool::m_zdcModuleCalibEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibEnergy
Definition: ZdcAnalysisTool.h:201
ZDC::ZdcAnalysisTool::m_peak2ndDerivMinThresholdsLG
ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsLG
Definition: ZdcAnalysisTool.h:191
ZDCPulseAnalyzer::getMaxADCLG
float getMaxADCLG() const
Definition: ZDCPulseAnalyzer.h:641
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ZDC::ZdcAnalysisTool::m_doTrigEff
bool m_doTrigEff
Definition: ZdcAnalysisTool.h:156
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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
ZDCPulseAnalyzer::GetAmpError
float GetAmpError() const
Definition: ZDCPulseAnalyzer.h:600
Data
@ Data
Definition: BaseObject.h:11
ZDC::ZdcAnalysisTool::m_fixTau1
bool m_fixTau1
Definition: ZdcAnalysisTool.h:176
ZDCPulseAnalyzer::getRefitLGTime
float getRefitLGTime() const
Definition: ZDCPulseAnalyzer.h:627
ZDC::ZdcAnalysisTool::m_zdcModuleFitAmp
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmp
Definition: ZdcAnalysisTool.h:207
ZDCPulseAnalyzer::GetAmpNoNonLin
float GetAmpNoNonLin() const
Definition: ZDCPulseAnalyzer.h:598
ZDC::ZdcAnalysisTool::getUncalibModuleSumErr
float getUncalibModuleSumErr(int side)
Definition: ZdcAnalysisTool.cxx:2619
asg
Definition: DataHandleTestTool.h:28
ZDC::ZdcAnalysisTool::m_doTimeCalib
bool m_doTimeCalib
Definition: ZdcAnalysisTool.h:157
ZDCDataAnalyzer::ZDCModuleIntArray
std::array< std::array< int, 4 >, 2 > ZDCModuleIntArray
Definition: ZDCDataAnalyzer.h:24
ZDC::ZdcAnalysisTool::m_zdcModuleAmpNoNonLin
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpNoNonLin
Definition: ZdcAnalysisTool.h:206
ZDC::ZdcAnalysisTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: ZdcAnalysisTool.cxx:1775
ZDC::ZdcAnalysisTool::initializepp2024
std::unique_ptr< ZDCDataAnalyzer > initializepp2024()
Definition: ZdcAnalysisTool.cxx:379
ZDC::ZdcAnalysisTool::m_zdcAnalysisConfigPath
std::string m_zdcAnalysisConfigPath
Definition: ZdcAnalysisTool.h:129
ZDC::SincInterp
double SincInterp(const double *xvec, const double *pvec)
Definition: ZdcSincInterp.cxx:11
ZDC::ZdcAnalysisTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ZdcAnalysisTool.h:144
ZDC::ZdcAnalysisTool::m_presample
unsigned int m_presample
Definition: ZdcAnalysisTool.h:169
ZDC::ZdcAnalysisTool::m_zdcSumModuleMask
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumModuleMask
Definition: ZdcAnalysisTool.h:235
ZDCPulseAnalyzer
Definition: ZDCPulseAnalyzer.h:24
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
ZDC::ZdcAnalysisTool::getTriggerEfficiency
double getTriggerEfficiency(int side)
Definition: ZdcAnalysisTool.cxx:2643
ZDC::ZdcAnalysisTool::m_zdcModuleStatus
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleStatus
Definition: ZdcAnalysisTool.h:203
ZDC::ZdcAnalysisTool::m_zdcSumAverageTime
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumAverageTime
Definition: ZdcAnalysisTool.h:233
ZDCPulseAnalyzer::getRefitLGTimeSub
float getRefitLGTimeSub() const
Definition: ZDCPulseAnalyzer.h:633
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
ZDC::ZdcAnalysisTool::m_lowGainMode
unsigned int m_lowGainMode
Definition: ZdcAnalysisTool.h:153
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
ZDC::ZdcAnalysisTool::~ZdcAnalysisTool
virtual ~ZdcAnalysisTool() override
Definition: ZdcAnalysisTool.cxx:83
ZDCDataAnalyzer::set2ndDerivStep
void set2ndDerivStep(size_t step)
Definition: ZDCDataAnalyzer.cxx:182
ZDCDataAnalyzer::SetCutValues
void SetCutValues(const ZDCModuleFloatArray &chisqDivAmpCutHG, const ZDCModuleFloatArray &chisqDivAmpCutLG, const ZDCModuleFloatArray &deltaT0MinHG, const ZDCModuleFloatArray &deltaT0MaxHG, const ZDCModuleFloatArray &deltaT0MinLG, const ZDCModuleFloatArray &deltaT0MaxLG)
Definition: ZDCDataAnalyzer.cxx:292
ZDC::ZdcAnalysisTool::setFADCCorrections
void setFADCCorrections(unsigned int runNumber=0)
Definition: ZdcAnalysisTool.cxx:2437
TRT::Hit::side
@ side
Definition: HitInfo.h:83
ZdcAnalysisTool.h
ZdcSincInterp.h
ZDCDataAnalyzer
Definition: ZDCDataAnalyzer.h:20
ZDC::ZdcAnalysisTool::m_zdcSumStatus
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumStatus
Definition: ZdcAnalysisTool.h:234
ZdcModuleAuxContainer.h
ZDC::ZdcAnalysisTool::m_zdcModuleAmplitude
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmplitude
Definition: ZdcAnalysisTool.h:200
ZDC::ZdcAnalysisTool::sideFailed
bool sideFailed(int side)
Definition: ZdcAnalysisTool.cxx:2631
ZDC::ZdcAnalysisTool::getModuleSum
float getModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:2595
ZDC::ZdcAnalysisTool::initializepp2023
std::unique_ptr< ZDCDataAnalyzer > initializepp2023()
Definition: ZdcAnalysisTool.cxx:290
ZDC::ZdcAnalysisTool::m_zdcSumFinalEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumFinalEnergy
Definition: ZdcAnalysisTool.h:232
python.PyAthena.module
module
Definition: PyAthena.py:131
ZDC::ZdcAnalysisTool::m_lumiBlock
unsigned int m_lumiBlock
Definition: ZdcAnalysisTool.h:139
ZDCPulseAnalyzer::TimingCorrLog
@ TimingCorrLog
Definition: ZDCPulseAnalyzer.h:59
ZDC::ZdcAnalysisTool::setEnergyCalibrations
void setEnergyCalibrations(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:2297
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ZDC::ZdcAnalysisTool::m_delayDeltaT
float m_delayDeltaT
Definition: ZdcAnalysisTool.h:173
ZDC::ZdcAnalysisTool::m_doNonLinCorr
bool m_doNonLinCorr
Definition: ZdcAnalysisTool.h:159
ZDC::ZdcAnalysisTool::m_init
bool m_init
Definition: ZdcAnalysisTool.h:127
ZDCPulseAnalyzer::getPresample
float getPresample() const
Definition: ZDCPulseAnalyzer.h:639
ZDCPulseAnalyzer::getMaxADCHG
float getMaxADCHG() const
Definition: ZDCPulseAnalyzer.h:640
ZDC::ZdcAnalysisTool::getCalibModuleSumErr
float getCalibModuleSumErr(int side)
Definition: ZdcAnalysisTool.cxx:2607
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ZDC::ZdcAnalysisTool::m_zdcSumUncalibSum
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumUncalibSum
Definition: ZdcAnalysisTool.h:228
ZDCDataAnalyzer::SetNoiseSigmas
void SetNoiseSigmas(const ZDCModuleFloatArray &noiseSigmasHG, const ZDCModuleFloatArray &noiseSigmasLG)
Definition: ZDCDataAnalyzer.cxx:244
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
ZDCPulseAnalyzer::getRefitLGFitAmp
float getRefitLGFitAmp() const
Definition: ZDCPulseAnalyzer.h:609
ZdcEventInfo::ZDCDECODINGERROR
@ ZDCDECODINGERROR
Definition: ZdcEventInfo.h:19
lumiFormat.i
int i
Definition: lumiFormat.py:85
ZDC::ZdcAnalysisTool::initializeInjectorPbPb2024
std::unique_ptr< ZDCDataAnalyzer > initializeInjectorPbPb2024()
Definition: ZdcAnalysisTool.cxx:924
ZDC::ZdcAnalysisTool::m_combineDelay
bool m_combineDelay
Definition: ZdcAnalysisTool.h:154
ZDC::ZdcAnalysisTool::m_numSample
unsigned int m_numSample
Definition: ZdcAnalysisTool.h:167
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ZDC::ZdcAnalysisTool::initializepPb2016
std::unique_ptr< ZDCDataAnalyzer > initializepPb2016()
Definition: ZdcAnalysisTool.cxx:1297
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ZDC::ZdcAnalysisTool::m_forceCalibLB
int m_forceCalibLB
Definition: ZdcAnalysisTool.h:162
ZDC::ZdcAnalysisTool::initializePbPb2023
std::unique_ptr< ZDCDataAnalyzer > initializePbPb2023()
Definition: ZdcAnalysisTool.cxx:468
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer_80MHz
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_80MHz
Definition: ZdcAnalysisTool.h:187
ZDC::ZdcAnalysisTool::m_zdcModuleChisqLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleChisqLGRefit
Definition: ZdcAnalysisTool.h:225
ZDCDataAnalyzer::SetADCOverUnderflowValues
void SetADCOverUnderflowValues(const ZDCModuleFloatArray &HGOverflowADC, const ZDCModuleFloatArray &HGUnderflowADC, const ZDCModuleFloatArray &LGOverflowADC)
Definition: ZDCDataAnalyzer.cxx:282
file
TFile * file
Definition: tile_monitor.h:29
ZDC::ZdcAnalysisTool::m_zdcModuleMaxADC
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADC
Definition: ZdcAnalysisTool.h:214
ZDCPulseAnalyzer::LGModeForceLG
@ LGModeForceLG
Definition: ZDCPulseAnalyzer.h:55
ZDC::ZdcAnalysisTool::m_zdcModuleFitT0
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitT0
Definition: ZdcAnalysisTool.h:209
ZDC::ZdcAnalysisTool::recoZdcModules
StatusCode recoZdcModules(const xAOD::ZdcModuleContainer &moduleContainer, const xAOD::ZdcModuleContainer &moduleSumContainer) override
Definition: ZdcAnalysisTool.cxx:1989
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ZDC::ZdcAnalysisTool::getModuleMask
unsigned int getModuleMask()
Definition: ZdcAnalysisTool.cxx:2637
ZDCPulseAnalyzer::getMaxADCSub
float getMaxADCSub() const
Definition: ZDCPulseAnalyzer.h:645
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
ZDCPulseAnalyzer::TimingCorrLin
@ TimingCorrLin
Definition: ZDCPulseAnalyzer.h:59
ZDCDataAnalyzer::SetFitMinMaxAmpValues
void SetFitMinMaxAmpValues(const ZDCModuleFloatArray &minAmpHG, const ZDCModuleFloatArray &minAmpLG, const ZDCModuleFloatArray &maxAmpHG, const ZDCModuleFloatArray &maxAmpLG)
Definition: ZDCDataAnalyzer.cxx:261
ZDC::ZdcAnalysisTool::m_zdcModuleT0SubLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleT0SubLGRefit
Definition: ZdcAnalysisTool.h:224
ZDC::ZdcAnalysisTool::m_zdcModuleMinDeriv2nd
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMinDeriv2nd
Definition: ZdcAnalysisTool.h:213
ZDCDataAnalyzer::SetTauT0Values
void SetTauT0Values(const ZDCModuleBoolArray &fxiTau1, const ZDCModuleBoolArray &fxiTau2, const ZDCModuleFloatArray &tau1, const ZDCModuleFloatArray &tau2, const ZDCModuleFloatArray &t0HG, const ZDCModuleFloatArray &t0LG)
Definition: ZDCDataAnalyzer.cxx:232
ZDC::ZdcAnalysisTool::m_zdcModuleBkgdMaxFraction
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleBkgdMaxFraction
Definition: ZdcAnalysisTool.h:210
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
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::setTimeCalibrations
void setTimeCalibrations(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:2362
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition: EventInfo_v1.h:338
ZDC::ZdcAnalysisTool::m_tau2
float m_tau2
Definition: ZdcAnalysisTool.h:175
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ZDC::ZdcAnalysisTool::m_zdcSumCalibEnergyErr
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumCalibEnergyErr
Definition: ZdcAnalysisTool.h:231
ZDCDataAnalyzer::enableDelayed
void enableDelayed(float deltaT, const ZDCModuleFloatArray &undelayedDelayedPedestalDiff)
Definition: ZDCDataAnalyzer.cxx:109
ZDC::ZdcAnalysisTool::m_calibVersion
std::string m_calibVersion
Definition: ZdcAnalysisTool.h:163
ZDCDataAnalyzer::enablePostExclusion
void enablePostExclusion(unsigned int maxSamplesExcl, const ZDCModuleIntArray &HGADCThresh, const ZDCModuleIntArray &LGADCThresh)
Definition: ZDCDataAnalyzer.cxx:153
ZDC::ZdcAnalysisTool::m_zdcModuleT0LGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleT0LGRefit
Definition: ZdcAnalysisTool.h:223
ZDC::ZdcAnalysisTool::m_zdcModuleAmpLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpLGRefit
Definition: ZdcAnalysisTool.h:221
ZDC::ZdcAnalysisTool::m_writeAux
bool m_writeAux
Definition: ZdcAnalysisTool.h:134
ZDC::ZdcAnalysisTool::m_configuration
std::string m_configuration
Definition: ZdcAnalysisTool.h:128
PathResolver.h
ZDC::ZdcAnalysisTool::m_doFADCCorrPerSample
bool m_doFADCCorrPerSample
Definition: ZdcAnalysisTool.h:160
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
ZDC::ZdcAnalysisTool::m_forceCalibRun
int m_forceCalibRun
Definition: ZdcAnalysisTool.h:161
ZDC::ZdcAnalysisTool::m_deltaTCut
float m_deltaTCut
Definition: ZdcAnalysisTool.h:178
ZDCTriggerEfficiency
Definition: ZDCTriggerEfficiency.h:16
ReadHandle.h
Handle class for reading from StoreGate.
ZDC::ZdcAnalysisTool::m_zdcModuleCalibTime
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibTime
Definition: ZdcAnalysisTool.h:202
ZDC::ZdcAnalysisTool::m_zdcSums
const xAOD::ZdcModuleContainer * m_zdcSums
Definition: ZdcAnalysisTool.h:151
ZDC::ZdcAnalysisTool::getTriggerEfficiencyUncertainty
double getTriggerEfficiencyUncertainty(int side)
Definition: ZdcAnalysisTool.cxx:2653
ZDCDataAnalyzer::enablePreExclusion
void enablePreExclusion(unsigned int maxSamplesExcl, const ZDCModuleIntArray &HGADCThresh, const ZDCModuleIntArray &LGADCThresh)
Definition: ZDCDataAnalyzer.cxx:135
ZDCPulseAnalyzer::GetFitAmplitude
float GetFitAmplitude() const
Definition: ZDCPulseAnalyzer.h:583
ZDC::ZdcAnalysisTool::initializeLHCf2022
std::unique_ptr< ZDCDataAnalyzer > initializeLHCf2022()
Definition: ZdcAnalysisTool.cxx:201
ZDCPulseAnalyzer::getRefitLGChisq
float getRefitLGChisq() const
Definition: ZDCPulseAnalyzer.h:621
EventInfo.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
ZDCPulseAnalyzer::GetMinDeriv2nd
float GetMinDeriv2nd() const
Definition: ZDCPulseAnalyzer.h:672
ZDC::ZdcAnalysisTool::m_zdcTriggerEfficiency
std::shared_ptr< ZDCTriggerEfficiency > m_zdcTriggerEfficiency
Definition: ZdcAnalysisTool.h:194
ZDCPulseAnalyzer::GetFitT0
float GetFitT0() const
Definition: ZDCPulseAnalyzer.h:584
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
ZDCDataAnalyzer::SetNonlinCorrParams
void SetNonlinCorrParams(float refADC, float refScale, const std::array< std::array< std::vector< float >, 4 >, 2 > &HGNonlinCorrParams, const std::array< std::array< std::vector< float >, 4 >, 2 > &LHGNonlinCorrParams)
Definition: ZDCDataAnalyzer.cxx:318
ZDC::ZdcAnalysisTool::m_zdcModuleFitAmpError
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmpError
Definition: ZdcAnalysisTool.h:208
ZDC::ZdcAnalysisTool::getAverageTime
float getAverageTime(int side)
Definition: ZdcAnalysisTool.cxx:2625
ZDC::ZdcAnalysisTool::m_zdcModulePresample
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModulePresample
Definition: ZdcAnalysisTool.h:212
ZDCPulseAnalyzer::GetBkgdMaxFraction
float GetBkgdMaxFraction() const
Definition: ZDCPulseAnalyzer.h:678
ZDCDataAnalyzer::disableModule
bool disableModule(size_t side, size_t module)
Definition: ZDCDataAnalyzer.cxx:92
ZDC::ZdcAnalysisTool::initializeTriggerEffs
void initializeTriggerEffs(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:88
ZDC::ZdcAnalysisTool::m_zdcModuleTime
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTime
Definition: ZdcAnalysisTool.h:204
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
ZDC::ZdcAnalysisTool::configureNewRun
StatusCode configureNewRun(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:1969
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ZDCDataAnalyzer::ZDCModuleBoolArray
std::array< std::array< bool, 4 >, 2 > ZDCModuleBoolArray
Definition: ZDCDataAnalyzer.h:23
ZDC::ZdcAnalysisTool::sigprocMaxFinder
static bool sigprocMaxFinder(const std::vector< unsigned short > &adc, float deltaT, float &amp, float &time, float &qual)
Definition: ZdcAnalysisTool.cxx:2553
ZDC::ZdcAnalysisTool::m_peak2ndDerivMinThresholdsHG
ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsHG
Definition: ZdcAnalysisTool.h:190
ZDC::ZdcAnalysisTool::initializeDefault
std::unique_ptr< ZDCDataAnalyzer > initializeDefault()
Definition: ZdcAnalysisTool.cxx:1171
ZDC
Definition: RPDAnalysisTool.cxx:12
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer_40MHz
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_40MHz
Definition: ZdcAnalysisTool.h:186
ZDCPulseAnalyzer::getRefitLGAmpCorr
float getRefitLGAmpCorr() const
Definition: ZDCPulseAnalyzer.h:615
ZDCDataAnalyzer::SetFitTimeMax
void SetFitTimeMax(float tmax)
Definition: ZDCDataAnalyzer.cxx:218
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
ZDC::ZdcAnalysisTool::m_deltaTSample
float m_deltaTSample
Definition: ZdcAnalysisTool.h:168
ZDC::ZdcAnalysisTool::initializeDecorations
void initializeDecorations()
Definition: ZdcAnalysisTool.cxx:1964
ZDCPulseAnalyzer::LGModeRefitLG
@ LGModeRefitLG
Definition: ZDCPulseAnalyzer.h:56
ZDC::ZdcAnalysisTool::initializeMonteCarloPbPb2023
std::unique_ptr< ZDCDataAnalyzer > initializeMonteCarloPbPb2023()
Definition: ZdcAnalysisTool.cxx:1015
xAOD::EventInfo_v1::isEventFlagBitSet
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Definition: EventInfo_v1.cxx:703
ZDC::ZdcAnalysisTool::m_zdcSumUncalibSumErr
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumUncalibSumErr
Definition: ZdcAnalysisTool.h:229
ZDC::ZdcAnalysisTool::m_zdcTimeCalibFileName
std::string m_zdcTimeCalibFileName
Definition: ZdcAnalysisTool.h:131
ZDC::ZdcAnalysisTool::m_peakSample
unsigned int m_peakSample
Definition: ZdcAnalysisTool.h:170
ZDC::ZdcAnalysisTool::m_zdcModuleFitAmpLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmpLGRefit
Definition: ZdcAnalysisTool.h:220
beamspotman.qual
qual
Definition: beamspotman.py:481
ZDC::ZdcAnalysisTool::getCalibModuleSum
float getCalibModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:2601
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
ZDC::ZdcAnalysisTool::initialize80MHz
void initialize80MHz()
Definition: ZdcAnalysisTool.cxx:1656
ZDCDataAnalyzer::enableRepass
void enableRepass(const ZDCModuleFloatArray &peak2ndDerivMinRepassHG, const ZDCModuleFloatArray &peak2ndDerivMinRepassLG)
Definition: ZDCDataAnalyzer.cxx:172
calibdata.copy
bool copy
Definition: calibdata.py:27
ZDC::ZdcAnalysisTool::initializePbPb2018
std::unique_ptr< ZDCDataAnalyzer > initializePbPb2018()
Definition: ZdcAnalysisTool.cxx:1409
ZDC::ZdcAnalysisTool::m_flipEMDelay
bool m_flipEMDelay
Definition: ZdcAnalysisTool.h:152
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
ZDC::ZdcAnalysisTool::m_zdcModulePreSampleAmp
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModulePreSampleAmp
Definition: ZdcAnalysisTool.h:211
ZDCDataAnalyzer::SetPeak2ndDerivMinTolerances
void SetPeak2ndDerivMinTolerances(size_t tolerance)
Definition: ZDCDataAnalyzer.cxx:209
ZDCPulseAnalyzer::GetChisq
float GetChisq() const
Definition: ZDCPulseAnalyzer.h:588
ZDC::ZdcAnalysisTool::initializePbPb2015G4
std::unique_ptr< ZDCDataAnalyzer > initializePbPb2015G4()
Definition: ZdcAnalysisTool.cxx:1234
ZDC::ZdcAnalysisTool::m_zdcEnergyCalibFileName
std::string m_zdcEnergyCalibFileName
Definition: ZdcAnalysisTool.h:130
ZDC::ZdcAnalysisTool::m_t0
float m_t0
Definition: ZdcAnalysisTool.h:172
ZDC::ZdcAnalysisTool::m_zdcModuleAmpCorrLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpCorrLGRefit
Definition: ZdcAnalysisTool.h:222
ZDC::ZdcAnalysisTool::sigprocSincInterp
bool sigprocSincInterp(const std::vector< unsigned short > &adc, float deltaT, float &amp, float &time, float &qual)
Definition: ZdcAnalysisTool.cxx:2580
python.DataFormatRates.env
env
Definition: DataFormatRates.py:32
ZDC::ZdcAnalysisTool::ZdcAnalysisTool
ZdcAnalysisTool(const std::string &name)
Definition: ZdcAnalysisTool.cxx:24
ZDCDataAnalyzer::SetSaveFitFunc
void SetSaveFitFunc(bool save)
Definition: ZDCDataAnalyzer.cxx:227
ZDC::ZdcAnalysisTool::m_doCalib
bool m_doCalib
Definition: ZdcAnalysisTool.h:155
ZDCDataAnalyzer::SetGainFactorsHGLG
void SetGainFactorsHGLG(float gainFactorHG, float gainFactorLG)
Definition: ZDCDataAnalyzer.cxx:191
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ZDCDataAnalyzer::SetTimingCorrParams
void SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrMode mode, float refADC, float refScale, const std::array< std::array< std::vector< float >, 4 >, 2 > &HGParamArr, const std::array< std::array< std::vector< float >, 4 >, 2 > &LGParamArr)
Definition: ZDCDataAnalyzer.cxx:305
ZDC::ZdcAnalysisTool::m_auxSuffix
std::string m_auxSuffix
Definition: ZdcAnalysisTool.h:135
ZdcEventInfo.h
Define enumerations for event-level ZDC data.
ZDC::ZdcAnalysisTool::initialize40MHz
void initialize40MHz()
Definition: ZdcAnalysisTool.cxx:1536
ZDC::ZdcAnalysisTool::m_fixTau2
bool m_fixTau2
Definition: ZdcAnalysisTool.h:177
ZDC::ZdcAnalysisTool::m_zdcSumCalibEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumCalibEnergy
Definition: ZdcAnalysisTool.h:230
ZDC::ZdcAnalysisTool::m_name
std::string m_name
Definition: ZdcAnalysisTool.h:126
ZDC::ZdcAnalysisTool::m_eventReady
bool m_eventReady
Definition: ZdcAnalysisTool.h:137
ZDC::ZdcAnalysisTool::m_zdcModuleMaxADCLG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADCLG
Definition: ZdcAnalysisTool.h:216
ZDCPulseAnalyzer::GetPreSampleAmp
float GetPreSampleAmp() const
Definition: ZDCPulseAnalyzer.h:677
ZDCDataAnalyzer::SetModuleAmpFractionLG
void SetModuleAmpFractionLG(const ZDCDataAnalyzer::ZDCModuleFloatArray &moduleAmpFractionLG)
Definition: ZDCDataAnalyzer.cxx:253
ZDC::ZdcAnalysisTool::getUncalibModuleSum
float getUncalibModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:2613