ATLAS Offline Software
ZdcAnalysisTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 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, 1); // 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.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
615  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
616  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
617  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
618 
619  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
620  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
621  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
622  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -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.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
779  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
780  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
781  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
782 
783  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
784  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
785  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
786  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -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  std::array< std::array< std::array<float,6>, 3>, 2> nlCalib = {{
792  {{ {{0.3, 1, -0.00753349, 0.882218, 0.019739, 1.0803}},{{0.3, 1, 0.0181165, 0.620646, -0.171213, 2.2143}},{{0.25, 1, -0.108547, 0.106, -1.3594, 4.1509}} }},
793  {{ {{0.3, 1, -0.00753349, 0.882218, 0.019739, 1.0803}},{{0.3, 1, 0.0181165, 0.620646, -0.171213, 2.2143}},{{0.25, 1, -0.108547, 0.106, -1.3594, 4.1509}} }}
794  }};
795 
796  zdcDataAnalyzer->SetNLcalibParams(nlCalib);
797 
798  // Set the amplitude fit range limits
799  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
800 
801  return zdcDataAnalyzer;
802 }
803 
804 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeOONeNe2025()
805 {
806  // Key configuration parameters needed for the data analyzer construction
807  //
808  m_deltaTSample = 3.125;
809  m_numSample = 24;
810 
811  const int deriv2ndThreshDSHG = -45;
812  const int deriv2ndThreshDSLG = -10;
813  const unsigned int peakSample = 10;
814 
815  const float deltaTcutLow = -10;
816  const float deltaTcutHigh = 10;
817  const float chisqDivAmpCutHGVal = 30;
818  const float chisqDivAmpCutLGVal = 50;
819 
820  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
821  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
822 
823  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
824  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
825  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
826 
827  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
828  {1.35, 1.4, 1.3, 1.1}}};
829 
830  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
831 
832  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.5, 31.5, 29.5, 30.5}, {34.5, 33.0, 33, 34.0}}};
833  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{32.25, 32.0, 30.5, 30.5}, {32.4, 33.5, 30.5, 31.4}}};
834 
835  for (size_t side : {0, 1}) {
836  for (size_t module : {0, 1, 2, 3}) {
837  fixTau1Arr[side][module] = true;
838  fixTau2Arr[side][module] = false;
839 
840  peak2ndDerivMinSamples[side][module] = peakSample;
841  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
842  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
843 
844  deltaT0CutLow[side][module] = deltaTcutLow;
845  deltaT0CutHigh[side][module] = deltaTcutHigh;
846  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
847  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
848  }
849  }
850 
851  ATH_MSG_DEBUG( "PbPb2024: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
852 
853  // Construct the data analyzer
854  //
855  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
857  m_presample, "FermiExpLHCf",
858  peak2ndDerivMinSamples,
859  peak2ndDerivMinThresholdsHG,
860  peak2ndDerivMinThresholdsLG,
862  zdcDataAnalyzer->set2ndDerivStep(1);
863  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
864 
865  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1, 1, 1, 1},{1, 1, 1, 1.0}}};
866  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{4,4,4,4}, {4,4,4,4}}};
867 
868  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 4 applied to LG ADC, 1 to HG ADC values
869 
870  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
871  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
872  //
873  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.5, 1.5, 1.5, 1.5}, {1.5, 1.5, 1.5, 1.5}}};
874  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
875 
876  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
877 
878  // Now set cuts and default fit parameters
879  //
880  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
881  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
882  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
883 
884  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
885  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
886  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
887 
888  // Enable two-pass analysis
889  //
890  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-30, -30, -30, -30},
891  {-30, -30, -30, -30},}};
892 
893  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
894  {-8, -8, -8, -8}}};
895 
896  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
897 
898  // Turn on exclusion of early and late samples to address OOT pileup
899  //
900  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
901  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
902 
903  // Set up non-linear corrections for the ZDC
904  //
905  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
906 
907  nonLinearCorrCoefficHG[0][0] = {-0.0225871, 0.00702802, 0.00201155, -0.00675293, 0.00186212} ;
908  nonLinearCorrCoefficHG[0][1] = {-0.0155562, 0.00594092, 0.00382112, -0.00665466, 0.00143384} ;
909  nonLinearCorrCoefficHG[0][2] = {-0.0313621, 0.0134528, 0.00529013, -0.0111751, 0.0029913} ;
910  nonLinearCorrCoefficHG[0][3] = {-0.025108, 0.00301898, 0.022472, -0.0204288, 0.00453215} ;
911  nonLinearCorrCoefficHG[1][0] = {-0.0266648, 0.0106792, -0.00939959, 0.000833011, 0.000199051} ;
912  nonLinearCorrCoefficHG[1][1] = {-0.0246541, 0.000327376, 0.00754946, -0.00710273, 0.00136899} ;
913  nonLinearCorrCoefficHG[1][2] = {-0.0175283, 0.0127954, 0.000235749, -0.00769698, 0.00221995} ;;
914  nonLinearCorrCoefficHG[1][3] = {-0.0279931, 0.0188122, 0.0126234, -0.0169907, 0.00398826} ;
915 
916 
917  // Remove nonlinear corrections while we study the injector pulse
918  nonLinearCorrCoefficHG = {{ {{{0},
919  {0},
920  {0},
921  {0}}},
922  {{{0},
923  {0},
924  {0},
925  {0}}} }};
926 
927  //
928  // We are disabling the old FADC correction moving forward
929  if (m_doNonLinCorr)
930  zdcDataAnalyzer->SetNonlinCorrParams(1000, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
931 
932  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
933  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
934  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
935  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
936  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
937 
938  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
939  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
940  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
941  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
942 
943  // +++ BAC 07-26-24
944  //
945  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
946  // made at the same time to match the timing shift of the LG channels
947  //
948  // ---
949  timeCorrCoefficLG[0][0] = {0.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
950  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
951  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
952  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
953 
954  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
955  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
956  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
957  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -0.152589, 0.016122, -0.086580, 0.563625};
958 
959  // Commenting out the timing correlation for PbPb2024: re-calibraton needed
960  // zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
961 
962  // Set the amplitude fit range limits
963  //
964  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
965 
966 
967  /*
968 {{
969  {{{{0.3, 1, -0.00753349, 0.882218, 0.019739, 1.0803}},{{0.3, 1, 0.0181165, 0.620646, -0.171213, 2.2143}},{{0.25, 1, -0.108547, 0.106, -1.3594, 4.1509}}}},
970  {{{{0.3, 1, -0.00753349, 0.882218, 0.019739, 1.0803}},{{0.3, 1, 0.0181165, 0.620646, -0.171213, 2.2143}},{{0.25, 1, -0.108547, 0.106, -1.3594, 4.1509}}}}
971  }};
972  */
973 
974  std::array< std::array< std::array<float,6>, 3>, 2> nlCalib = {{
975  {{ {{0.3, 1, -0.00753349, 0.882218, 0.019739, 1.0803}},{{0.3, 1, 0.0181165, 0.620646, -0.171213, 2.2143}},{{0.25, 1, -0.108547, 0.106, -1.3594, 4.1509}} }},
976  {{ {{0.3, 1, -0.00753349, 0.882218, 0.019739, 1.0803}},{{0.3, 1, 0.0181165, 0.620646, -0.171213, 2.2143}},{{0.25, 1, -0.108547, 0.106, -1.3594, 4.1509}} }}
977  }};
978 
979  zdcDataAnalyzer->SetNLcalibParams(nlCalib);
980 
981  return zdcDataAnalyzer;
982 }
983 
984 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializepO2025()
985 {
986  // Key configuration parameters needed for the data analyzer construction
987  //
988  m_deltaTSample = 3.125;
989  m_numSample = 24;
990 
991  const int deriv2ndThreshDSHG = -45;
992  const int deriv2ndThreshDSLG = -10;
993  const unsigned int peakSample = 10;
994 
995  const float deltaTcutLow = -10;
996  const float deltaTcutHigh = 10;
997  const float chisqDivAmpCutHGVal = 30;
998  const float chisqDivAmpCutLGVal = 50;
999 
1000  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1001  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1002 
1003  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1004  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1005  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1006 
1007  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
1008  {1.35, 1.4, 1.3, 1.1}}};
1009 
1010  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
1011 
1012  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.5, 31.5, 29.5, 30.5}, {34.5, 33.0, 33, 34.0}}};
1013  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{32.25, 32.0, 30.5, 30.5}, {32.4, 33.5, 30.5, 31.4}}};
1014 
1015  for (size_t side : {0, 1}) {
1016  for (size_t module : {0, 1, 2, 3}) {
1017  fixTau1Arr[side][module] = true;
1018  fixTau2Arr[side][module] = false;
1019 
1020  peak2ndDerivMinSamples[side][module] = peakSample;
1021  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1022  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1023 
1024  deltaT0CutLow[side][module] = deltaTcutLow;
1025  deltaT0CutHigh[side][module] = deltaTcutHigh;
1026  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1027  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1028  }
1029  }
1030 
1031  ATH_MSG_DEBUG( "PbPb2024: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1032 
1033  // Construct the data analyzer
1034  //
1035  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1037  m_presample, "FermiExpLHCf",
1038  peak2ndDerivMinSamples,
1039  peak2ndDerivMinThresholdsHG,
1040  peak2ndDerivMinThresholdsLG,
1042  zdcDataAnalyzer->set2ndDerivStep(1);
1043  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
1044 
1045  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1, 1, 1, 1},{1, 1, 1, 1.0}}};
1046  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{4,4,4,4}, {4,4,4,4}}};
1047 
1048  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
1049 
1050  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1051  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1052  //
1053  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.5, 1.5, 1.5, 1.5}, {1.5, 1.5, 1.5, 1.5}}};
1054  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
1055 
1056  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1057 
1058  // Now set cuts and default fit parameters
1059  //
1060  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1061  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1062  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1063 
1064  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1065  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1066  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1067 
1068  // Enable two-pass analysis
1069  //
1070  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-30, -30, -30, -30},
1071  {-30, -30, -30, -30},}};
1072 
1073  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
1074  {-8, -8, -8, -8}}};
1075 
1076  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
1077 
1078  // Turn on exclusion of early and late samples to address OOT pileup
1079  //
1080  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
1081  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
1082 
1083  // Set up non-linear corrections for the ZDC
1084  //
1085  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
1086 
1087  nonLinearCorrCoefficHG[0][0] = {-0.0225871, 0.00702802, 0.00201155, -0.00675293, 0.00186212} ;
1088  nonLinearCorrCoefficHG[0][1] = {-0.0155562, 0.00594092, 0.00382112, -0.00665466, 0.00143384} ;
1089  nonLinearCorrCoefficHG[0][2] = {-0.0313621, 0.0134528, 0.00529013, -0.0111751, 0.0029913} ;
1090  nonLinearCorrCoefficHG[0][3] = {-0.025108, 0.00301898, 0.022472, -0.0204288, 0.00453215} ;
1091  nonLinearCorrCoefficHG[1][0] = {-0.0266648, 0.0106792, -0.00939959, 0.000833011, 0.000199051} ;
1092  nonLinearCorrCoefficHG[1][1] = {-0.0246541, 0.000327376, 0.00754946, -0.00710273, 0.00136899} ;
1093  nonLinearCorrCoefficHG[1][2] = {-0.0175283, 0.0127954, 0.000235749, -0.00769698, 0.00221995} ;;
1094  nonLinearCorrCoefficHG[1][3] = {-0.0279931, 0.0188122, 0.0126234, -0.0169907, 0.00398826} ;
1095 
1096 
1097  // Remove nonlinear corrections while we study the injector pulse
1098  nonLinearCorrCoefficHG = {{ {{{0},
1099  {0},
1100  {0},
1101  {0}}},
1102  {{{0},
1103  {0},
1104  {0},
1105  {0}}} }};
1106 
1107  //
1108  // We are disabling the old FADC correction moving forward
1109  if (m_doNonLinCorr)
1110  zdcDataAnalyzer->SetNonlinCorrParams(1000, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
1111 
1112  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
1113  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
1114  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
1115  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
1116  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
1117 
1118  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
1119  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
1120  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
1121  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
1122 
1123  // +++ BAC 07-26-24
1124  //
1125  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
1126  // made at the same time to match the timing shift of the LG channels
1127  //
1128  // ---
1129  timeCorrCoefficLG[0][0] = {0.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
1130  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
1131  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
1132  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
1133 
1134  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
1135  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
1136  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
1137  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -0.152589, 0.016122, -0.086580, 0.563625};
1138 
1139  // Commenting out the timing correlation for PbPb2024: re-calibraton needed
1140  // zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
1141 
1142  // Set the amplitude fit range limits
1143  //
1144  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1145 
1146  zdcDataAnalyzer->disableModule(0, 0); // required since EM not installed
1147 
1148  return zdcDataAnalyzer;
1149 }
1150 
1151 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializepO2025B()
1152 {
1153  // Key configuration parameters needed for the data analyzer construction
1154  //
1155  m_deltaTSample = 3.125;
1156  m_numSample = 24;
1157 
1158  const int deriv2ndThreshDSHG = -45;
1159  const int deriv2ndThreshDSLG = -10;
1160  const unsigned int peakSample = 10;
1161 
1162  const float deltaTcutLow = -10;
1163  const float deltaTcutHigh = 10;
1164  const float chisqDivAmpCutHGVal = 30;
1165  const float chisqDivAmpCutLGVal = 50;
1166 
1167  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1168  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1169 
1170  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1171  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1172  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1173 
1174  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
1175  {1.35, 1.4, 1.3, 1.1}}};
1176 
1177  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
1178 
1179  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.5, 31.5, 29.5, 30.5}, {34.5, 33.0, 33, 34.0}}};
1180  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{32.25, 32.0, 30.5, 30.5}, {32.4, 33.5, 30.5, 31.4}}};
1181 
1182  for (size_t side : {0, 1}) {
1183  for (size_t module : {0, 1, 2, 3}) {
1184  fixTau1Arr[side][module] = true;
1185  fixTau2Arr[side][module] = false;
1186 
1187  peak2ndDerivMinSamples[side][module] = peakSample;
1188  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1189  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1190 
1191  deltaT0CutLow[side][module] = deltaTcutLow;
1192  deltaT0CutHigh[side][module] = deltaTcutHigh;
1193  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1194  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1195  }
1196  }
1197 
1198  ATH_MSG_DEBUG( "PbPb2024: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1199 
1200  // Construct the data analyzer
1201  //
1202  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1204  m_presample, "FermiExpLHCf",
1205  peak2ndDerivMinSamples,
1206  peak2ndDerivMinThresholdsHG,
1207  peak2ndDerivMinThresholdsLG,
1209  zdcDataAnalyzer->set2ndDerivStep(1);
1210  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
1211 
1212  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1, 1, 1, 1},{1, 1, 1, 1.0}}}; //
1213  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{4,4,4,4}, {3,4,4,4}}}; // decided to move the change to the HG/LG ratio
1214 
1215  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
1216 
1217  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1218  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1219  //
1220  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.5, 1.5, 1.5, 1.5}, {1.5, 1.5, 1.5, 1.5}}};
1221  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
1222 
1223  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1224 
1225  // Now set cuts and default fit parameters
1226  //
1227  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1228  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1229  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1230 
1231  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1232  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1233  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1234 
1235  // Enable two-pass analysis
1236  //
1237  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-30, -30, -30, -30},
1238  {-30, -30, -30, -30},}};
1239 
1240  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
1241  {-8, -8, -8, -8}}};
1242 
1243  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
1244 
1245  // Turn on exclusion of early and late samples to address OOT pileup
1246  //
1247  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
1248  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
1249 
1250  // Set up non-linear corrections for the ZDC
1251  //
1252  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
1253 
1254  nonLinearCorrCoefficHG[0][0] = {-0.0225871, 0.00702802, 0.00201155, -0.00675293, 0.00186212} ;
1255  nonLinearCorrCoefficHG[0][1] = {-0.0155562, 0.00594092, 0.00382112, -0.00665466, 0.00143384} ;
1256  nonLinearCorrCoefficHG[0][2] = {-0.0313621, 0.0134528, 0.00529013, -0.0111751, 0.0029913} ;
1257  nonLinearCorrCoefficHG[0][3] = {-0.025108, 0.00301898, 0.022472, -0.0204288, 0.00453215} ;
1258  nonLinearCorrCoefficHG[1][0] = {-0.0266648, 0.0106792, -0.00939959, 0.000833011, 0.000199051} ;
1259  nonLinearCorrCoefficHG[1][1] = {-0.0246541, 0.000327376, 0.00754946, -0.00710273, 0.00136899} ;
1260  nonLinearCorrCoefficHG[1][2] = {-0.0175283, 0.0127954, 0.000235749, -0.00769698, 0.00221995} ;;
1261  nonLinearCorrCoefficHG[1][3] = {-0.0279931, 0.0188122, 0.0126234, -0.0169907, 0.00398826} ;
1262 
1263 
1264  // Remove nonlinear corrections while we study the injector pulse
1265  nonLinearCorrCoefficHG = {{ {{{0},
1266  {0},
1267  {0},
1268  {0}}},
1269  {{{0},
1270  {0},
1271  {0},
1272  {0}}} }};
1273 
1274  //
1275  // We are disabling the old FADC correction moving forward
1276  if (m_doNonLinCorr)
1277  zdcDataAnalyzer->SetNonlinCorrParams(1000, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
1278 
1279  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
1280  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
1281  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
1282  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
1283  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
1284 
1285  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
1286  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
1287  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
1288  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
1289 
1290  // +++ BAC 07-26-24
1291  //
1292  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
1293  // made at the same time to match the timing shift of the LG channels
1294  //
1295  // ---
1296  timeCorrCoefficLG[0][0] = {0.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
1297  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
1298  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
1299  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
1300 
1301  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
1302  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
1303  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
1304  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -0.152589, 0.016122, -0.086580, 0.563625};
1305 
1306  // Commenting out the timing correlation for PbPb2024: re-calibraton needed
1307  // zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
1308 
1309  // Set the amplitude fit range limits
1310  //
1311  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1312 
1313  zdcDataAnalyzer->disableModule(0, 0); // required since EM not installed
1314 
1315  return zdcDataAnalyzer;
1316 }
1317 
1318 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeInjectorpp2024()
1319 {
1320  // Key configuration parameters needed for the data analyzer construction
1321  //
1322  m_deltaTSample = 3.125;
1323  m_numSample = 24;
1324 
1325  const int deriv2ndThreshDSHG = -10;
1326  const int deriv2ndThreshDSLG = -10;
1327  const unsigned int peakSample = 10;
1328 
1329  const float deltaTcutLow = -50;
1330  const float deltaTcutHigh = 50;
1331  const float chisqDivAmpCutHGVal = 30;
1332  const float chisqDivAmpCutLGVal = 50;
1333 
1334  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1335  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1336 
1337  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1338  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1339  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1340 
1341  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.2, 1.4, 1.3, 1.2},
1342  {1.35, 1.4, 1.3, 1.1}}};
1343 
1344  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
1345 
1346  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
1347  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{28, 28, 28, 28}, {28, 28, 28, 28}}};
1348 
1349  for (size_t side : {0, 1}) {
1350  for (size_t module : {0, 1, 2, 3}) {
1351  fixTau1Arr[side][module] = false;
1352  fixTau2Arr[side][module] = true;
1353 
1354  peak2ndDerivMinSamples[side][module] = peakSample;
1355  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1356  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1357 
1358  deltaT0CutLow[side][module] = deltaTcutLow;
1359  deltaT0CutHigh[side][module] = deltaTcutHigh;
1360  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1361  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1362  }
1363  }
1364 
1365  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1366 
1367  // Construct the data analyzer
1368  //
1369  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1371  m_presample, "FermiExpLHCf",
1372  peak2ndDerivMinSamples,
1373  peak2ndDerivMinThresholdsHG,
1374  peak2ndDerivMinThresholdsLG,
1376  zdcDataAnalyzer->set2ndDerivStep(2);
1377  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(10);
1378 
1379  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1380  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1381 
1382  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
1383 
1384  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1385  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1386  //
1387  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1388  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{10.0, 10.0, 10.0, 10.0}, {10.0, 10.0, 10.0, 10.0}}};
1389 
1390  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1391 
1392  // Now set cuts and default fit parameters
1393  //
1394  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1395  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1396  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1397 
1398  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1399  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1400  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1401 
1402  // Turn on exclusion of early and late samples to address OOT pileup
1403  //
1404  zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
1405  zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
1406 
1407 
1408  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
1409  timeCorrCoefficHG[0][0] = {0.07, -0.020672, 0.070206, 0.004961, -0.010821, -0.001835};
1410  timeCorrCoefficHG[0][1] = {0.04, -0.012961, 0.008204, 0.010771, 0.011593, 0.002045};
1411  timeCorrCoefficHG[0][2] = {0.04, 0.017393, 0.017597, 0.003736, -0.001696, -0.000465};
1412  timeCorrCoefficHG[0][3] = {0.04, 0.018463, 0.009862, -0.000277, -0.000268, 0.000192};
1413 
1414  timeCorrCoefficHG[1][0] = {0.13, -0.106068, 0.078153, 0.034479, -0.004964, -0.001688};
1415  timeCorrCoefficHG[1][1] = {0.03, -0.007518, 0.008937, 0.015319, 0.012290, 0.001889};
1416  timeCorrCoefficHG[1][2] = {-0.01, 0.006711, -0.001652, -0.004223, -0.000573, 0.000161};
1417  timeCorrCoefficHG[1][3] = {0.015, 0.017993, 0.006339, 0.003122, 0.002980, 0.000735};
1418 
1419  // +++ BAC 07-26-24
1420  //
1421  // The +3.25 in the constant t0 correction term accounts for a change in the nominal T0 from 31.25 to 28
1422  // made at the same time to match the timing shift of the LG channels
1423  //
1424  // ---
1425  timeCorrCoefficLG[0][0] = {0.035f+3.25f, -0.126189, 0.022724, 0.039116, -0.098255};
1426  timeCorrCoefficLG[0][1] = {0.022f+3.25f, -0.165988, -0.014125, 0.057323, -0.205109};
1427  timeCorrCoefficLG[0][2] = {0.01f+3.25f, -0.136087, -0.007248, -0.014452, -0.060469};
1428  timeCorrCoefficLG[0][3] = {0.0f+3.25f, -0.131067, 0.025579, 0.059994, -0.065595};
1429 
1430  timeCorrCoefficLG[1][0] = {0.076f+3.25f, -0.300587, -0.041827, 0.641108, -0.594157};
1431  timeCorrCoefficLG[1][1] = {0.057f+3.25f, -0.223443, -0.125013, -0.176900, 0.348081};
1432  timeCorrCoefficLG[1][2] = {0.015f+3.25f, -0.141721, 0.023936, 0.099657, -0.188526};
1433  timeCorrCoefficLG[1][3] = {0.01f+3.25f, -0.152589, 0.016122, -0.086580, 0.563625};
1434 
1435  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
1436 
1437  // Set the amplitude fit range limits
1438  //
1439  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1440 
1441  return zdcDataAnalyzer;
1442 }
1443 
1444 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeInjectorPbPb2024()
1445 {
1446  // Key configuration parameters needed for the data analyzer construction
1447  //
1448  m_deltaTSample = 3.125;
1449  m_numSample = 24;
1450 
1451  const int deriv2ndThreshDSHG = -25;
1452  const int deriv2ndThreshDSLG = -10;
1453  const unsigned int peakSample = 10;
1454 
1455  const float deltaTcutLow = -10;
1456  const float deltaTcutHigh = 10;
1457  const float chisqDivAmpCutHGVal = 30;
1458  const float chisqDivAmpCutLGVal = 50;
1459 
1460  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1461  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1462 
1463  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1464  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1465  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1466 
1467  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.8, 1.8, 1.8, 1.8}, {1.8, 1.8, 1.8, 1.8}}};
1468 
1469  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{5.5, 5.5, 5.5, 5.5}, {5.5, 5.5, 5.5, 5.5}}};
1470 
1471  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{33.25, 33, 29.5, 33}, {31.5, 32.5, 32, 32.25}}};
1472  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{30.5, 30, 26.75, 30}, {29.5, 32.5, 29.5, 29}}};
1473 
1474  for (size_t side : {0, 1}) {
1475  for (size_t module : {0, 1, 2, 3}) {
1476  fixTau1Arr[side][module] = false;
1477  fixTau2Arr[side][module] = true;
1478 
1479  peak2ndDerivMinSamples[side][module] = peakSample;
1480  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1481  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1482 
1483  deltaT0CutLow[side][module] = deltaTcutLow;
1484  deltaT0CutHigh[side][module] = deltaTcutHigh;
1485  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1486  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1487  }
1488  }
1489 
1490  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1491 
1492  // Construct the data analyzer
1493  //
1494  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1496  m_presample, "FermiExpLHCf",
1497  peak2ndDerivMinSamples,
1498  peak2ndDerivMinThresholdsHG,
1499  peak2ndDerivMinThresholdsLG,
1501 
1502  zdcDataAnalyzer->set2ndDerivStep(2);
1503  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
1504 
1505  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1506  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{10, 10, 10, 10}, {10, 10, 10, 10}}};
1507 
1508  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
1509 
1510  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1511  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1512  //
1513  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{2.0, 2.0, 2.0, 2.0}, {2.0, 2.0, 2.0, 2.0}}};
1514  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{15.0, 15.0, 15.0, 15.0}, {15.0, 15.0, 15.0, 15.0}}};
1515 
1516  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1517 
1518  // Now set cuts and default fit parameters
1519  //
1520  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1521  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1522  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1523 
1524  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1525  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1526  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1527 
1528  // Set the amplitude fit range limits
1529  //
1530  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1531 
1532  return zdcDataAnalyzer;
1533 }
1534 
1535 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeInjectorpOOONeNe2025()
1536 {
1537  // Key configuration parameters needed for the data analyzer construction
1538  //
1539  m_deltaTSample = 3.125;
1540  m_numSample = 24;
1541 
1542  const int deriv2ndThreshDSHG = -25;
1543  const int deriv2ndThreshDSLG = -10;
1544  const unsigned int peakSample = 10;
1545 
1546  const float deltaTcutLow = -10;
1547  const float deltaTcutHigh = 10;
1548  const float chisqDivAmpCutHGVal = 30;
1549  const float chisqDivAmpCutLGVal = 50;
1550 
1551  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1552  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1553 
1554  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1555  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1556  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1557 
1558  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.8, 1.8, 1.8, 1.8}, {1.8, 1.8, 1.8, 1.8}}};
1559 
1560  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{5.5, 5.5, 5.5, 5.5}, {5.5, 5.5, 5.5, 5.5}}};
1561 
1562  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{33.25, 33, 29.5, 33}, {31.5, 32.5, 32, 32.25}}};
1563  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{30.5, 30, 26.75, 30}, {29.5, 32.5, 29.5, 29}}};
1564 
1565  for (size_t side : {0, 1}) {
1566  for (size_t module : {0, 1, 2, 3}) {
1567  fixTau1Arr[side][module] = false;
1568  fixTau2Arr[side][module] = true;
1569 
1570  peak2ndDerivMinSamples[side][module] = peakSample;
1571  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1572  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1573 
1574  deltaT0CutLow[side][module] = deltaTcutLow;
1575  deltaT0CutHigh[side][module] = deltaTcutHigh;
1576  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1577  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1578  }
1579  }
1580 
1581  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1582 
1583  // Construct the data analyzer
1584  //
1585  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1587  m_presample, "FermiExpLHCf",
1588  peak2ndDerivMinSamples,
1589  peak2ndDerivMinThresholdsHG,
1590  peak2ndDerivMinThresholdsLG,
1592 
1593  zdcDataAnalyzer->set2ndDerivStep(2);
1594  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
1595 
1596  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1597  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{4,4,4,4}, {4,4,4,4}}};
1598 
1599  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 4 applied to LG ADC, 1 to HG ADC values
1600 
1601  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1602  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1603  //
1604  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{2.0, 2.0, 2.0, 2.0}, {2.0, 2.0, 2.0, 2.0}}};
1605  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{15.0, 15.0, 15.0, 15.0}, {15.0, 15.0, 15.0, 15.0}}};
1606 
1607  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1608 
1609  // Now set cuts and default fit parameters
1610  //
1611  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1612  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1613  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1614 
1615  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1616  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1617  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1618 
1619  // Set the amplitude fit range limits
1620  //
1621  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1622 
1623  return zdcDataAnalyzer;
1624 }
1625 
1626 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeMonteCarloPbPb2023()
1627 {
1628  // Key configuration parameters needed for the data analyzer construction
1629  //
1630  m_deltaTSample = 3.125;
1631  m_numSample = 24;
1632 
1633  const int deriv2ndThreshDSHG = -25;
1634  const int deriv2ndThreshDSLG = -10;
1635  const unsigned int peakSample = 10;
1636 
1637  const float deltaTcutLow = -10;
1638  const float deltaTcutHigh = 10;
1639  const float chisqDivAmpCutHGVal = 30;
1640  const float chisqDivAmpCutLGVal = 50;
1641 
1642  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples;
1643  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG;
1644 
1645  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow, deltaT0CutHigh;
1646  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG, chisqDivAmpCutLG;
1647  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr, fixTau2Arr;
1648 
1649  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{1.1, 1.1, 1.1, 1.1},
1650  {1.1, 1.1, 1.1, 1.1}}};
1651 
1652  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{4.4, 4.7, 4.5, 4.6}, {4.8, 4.6, 4.4, 4.2}}};
1653 
1654  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
1655  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{31.25, 31.25, 31.25, 31.25}, {31.25, 31.25, 31.25, 31.25}}};
1656 
1657  for (size_t side : {0, 1}) {
1658  for (size_t module : {0, 1, 2, 3}) {
1659  fixTau1Arr[side][module] = false;
1660  fixTau2Arr[side][module] = false;
1661 
1662  peak2ndDerivMinSamples[side][module] = peakSample;
1663  peak2ndDerivMinThresholdsHG[side][module] = deriv2ndThreshDSHG;
1664  peak2ndDerivMinThresholdsLG[side][module] = deriv2ndThreshDSLG;
1665 
1666  deltaT0CutLow[side][module] = deltaTcutLow;
1667  deltaT0CutHigh[side][module] = deltaTcutHigh;
1668  chisqDivAmpCutLG[side][module] = chisqDivAmpCutLGVal;
1669  chisqDivAmpCutHG[side][module] = chisqDivAmpCutHGVal;
1670  }
1671  }
1672 
1673  ATH_MSG_DEBUG( "PbPb2023: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1674 
1675  // Construct the data analyzer
1676  //
1677  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(),
1679  m_presample, "FermiExpLHCf",
1680  peak2ndDerivMinSamples,
1681  peak2ndDerivMinThresholdsHG,
1682  peak2ndDerivMinThresholdsLG,
1683  m_lowGainMode));
1684  zdcDataAnalyzer->set2ndDerivStep(2);
1685  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(3);
1686 
1687  ZDCDataAnalyzer::ZDCModuleFloatArray gainsHG = {{{1, 1, 1, 1},{1, 1, 1, 1}}};
1688  ZDCDataAnalyzer::ZDCModuleFloatArray gainsLG = {{{10.,10.,10.,10.},{10.,10.,10.,10.}}}; // apply constant factor of 10 to high gain data
1689 
1690  zdcDataAnalyzer->SetGainFactorsHGLG(gainsHG, gainsLG); // a gain adjustment of 10 applied to LG ADC, 1 to HG ADC values
1691 
1692  // These noise sigmas we read off from the ch_x_BaselineStdev monitoring histograms with our
1693  // final readout configuration for the Pb+Pb run by BAC on 25-09-2023
1694  //
1695  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}}};
1696  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{1.5, 1.7, 3, 1.7}, {1.7, 1.6, 2.2, 1.8}}};
1697 
1698  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
1699 
1700  // Now set cuts and default fit parameters
1701  //
1702  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{3500, 3500, 3500, 3500}}, {{3500, 3500, 3500, 3500}}}};
1703  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{1, 1, 1, 1}}, {{1, 1, 1, 1}}}};
1704  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{4000, 4000, 4000, 4000}}, {{4000, 4000, 4000, 4000}}}};
1705 
1706  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1707  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
1708  zdcDataAnalyzer->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1709 
1710  // Enable two-pass analysis
1711  //
1712  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassHG = {{{-10, -10, -10, -10},
1713  {-10, -10, -10, -10}}};
1714 
1715  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinRepassLG = {{{-8, -8, -8, -8},
1716  {-8, -8, -8, -8}}};
1717 
1718  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG);
1719 
1720  // Turn on exclusion of early and late samples to address OOT pileup
1721  //
1722  //zdcDataAnalyzer->enablePreExclusion(4, 500, 200);
1723  //zdcDataAnalyzer->enablePostExclusion(4, 300, 200);
1724 
1725  // Set up non-linear corrections for the ZDC
1726  //
1727  std::array<std::array<std::vector<float>, 4>, 2> nonLinearCorrCoefficHG, nonLinearCorrCoefficLG;
1728 
1729  nonLinearCorrCoefficHG = {{ {{{0},
1730  {0},
1731  {0},
1732  {0}}},
1733  {{{0},
1734  {0},
1735  {0},
1736  {0}}} }};
1737 
1738  // For now we don't use corrections on the LG as it's much harder to measure them
1739  //
1740  nonLinearCorrCoefficLG = {{ {{{0},
1741  {0},
1742  {0},
1743  {0}}},
1744  {{{0},
1745  {0},
1746  {0},
1747  {0}}} }};
1748 
1749  if (m_doNonLinCorr)
1750  zdcDataAnalyzer->SetNonlinCorrParams(0, 1000, nonLinearCorrCoefficHG, nonLinearCorrCoefficLG);
1751 
1752  std::array<std::array<std::vector<float>, 4>, 2> timeCorrCoefficHG, timeCorrCoefficLG;
1753  timeCorrCoefficHG[0][0] = {};
1754  timeCorrCoefficHG[0][1] = {};
1755  timeCorrCoefficHG[0][2] = {};
1756  timeCorrCoefficHG[0][3] = {};
1757 
1758  timeCorrCoefficHG[1][0] = {};
1759  timeCorrCoefficHG[1][1] = {};
1760  timeCorrCoefficHG[1][2] = {};
1761  timeCorrCoefficHG[1][3] = {};
1762 
1763  timeCorrCoefficLG[0][0] = {};
1764  timeCorrCoefficLG[0][1] = {};
1765  timeCorrCoefficLG[0][2] = {};
1766  timeCorrCoefficLG[0][3] = {};
1767 
1768  timeCorrCoefficLG[1][0] = {};
1769  timeCorrCoefficLG[1][1] = {};
1770  timeCorrCoefficLG[1][2] = {};
1771  timeCorrCoefficLG[1][3] = {};
1772 
1773  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLog, 0, 700, timeCorrCoefficHG, timeCorrCoefficLG);
1774 
1775  // Set the amplitude fit range limits
1776  //
1777  zdcDataAnalyzer->SetFitMinMaxAmpValues(2, 2, 6000, 6000);
1778 
1779  return zdcDataAnalyzer;
1780 }
1781 
1782 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializeDefault()
1783 {
1784  // We rely completely on the default parameters specified in the job properties to control:
1785  // # samples
1786  // frequency (more precisely, time/sample)
1787  // which sample to use as the pre-sample
1788  // where to expact the maxim of the peak (min 2nd derivative)
1789  // thresholds on the 2nd derivative for valid pulses
1790  // whether to fix the tau values in the pulse fitting
1791  // the default tau values
1792  // the nominal T0
1793  // delta T and chisq/amp cuts
1794  //
1795  // For now, we continue to use hard-coded values for the maximum and minimum ADC values
1796  // For now we also use the FermiExp pulse model.
1797  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1798  ZDCDataAnalyzer::ZDCModuleFloatArray tau1{}, tau2{}, t0{};
1799  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
1800  ZDCDataAnalyzer::ZDCModuleFloatArray deltaT0CutLow{}, deltaT0CutHigh{}, chisqDivAmpCut{};
1801  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1802 
1803  for (size_t side : {0, 1}) {
1804  for (size_t module : {0, 1, 2, 3}) {
1805  fixTau1Arr[side][module] = m_fixTau1;
1806  fixTau2Arr[side][module] = m_fixTau2;
1807  tau1[side][module] = m_tau1;
1808  tau2[side][module] = m_tau2;
1809 
1810  peak2ndDerivMinSamples[side][module] = m_peakSample;
1811  peak2ndDerivMinThresholdsHG[side][module] = -m_Peak2ndDerivThresh;
1812  peak2ndDerivMinThresholdsLG[side][module] = -m_Peak2ndDerivThresh / 2;
1813 
1814  t0[side][module] = m_t0;
1815  deltaT0CutLow[side][module] = -m_deltaTCut;
1816  deltaT0CutHigh[side][module] = m_deltaTCut;
1817  chisqDivAmpCut[side][module] = m_ChisqRatioCut;
1818  }
1819  }
1820 
1821  ATH_MSG_DEBUG( "Default: delta t cut, value low = " << deltaT0CutLow[0][0] << ", high = " << deltaT0CutHigh[0][0] );
1822 
1823  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1824  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1825  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1826 
1827  // Construct the data analyzer
1828  //
1829  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(), m_numSample, m_deltaTSample, m_presample, "FermiExp", peak2ndDerivMinSamples,
1830  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1831 
1832  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1833  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0, t0);
1834  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, deltaT0CutLow, deltaT0CutHigh, deltaT0CutLow, deltaT0CutHigh);
1835 
1836  if (m_combineDelay) {
1837  ZDCDataAnalyzer::ZDCModuleFloatArray defaultPedestalShifts = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
1838 
1839  zdcDataAnalyzer->enableDelayed(m_delayDeltaT, defaultPedestalShifts);
1840  }
1841 
1842  return zdcDataAnalyzer;
1843 }
1844 
1845 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializePbPb2015G4()
1846 {
1847  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1848  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1849  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
1850  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCut{};
1851  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1852 
1853  const int peakSample = 4;
1854  const float peak2ndDerivThreshHG = -12;
1855  const float peak2ndDerivThreshLG = -10;
1856  ZDCDataAnalyzer::ZDCModuleFloatArray tau1Arr = {{{4.000, 4.000, 4.000, 4.000},
1857  {4.000, 4.000, 4.000, 4.000}}};
1858  ZDCDataAnalyzer::ZDCModuleFloatArray tau2Arr = {{{25.36, 25.05, 25.43, 25.60},
1859  {25.11, 25.08, 25.18, 25.48}}};
1860 
1861  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{57.31, 57.28, 57.30, 57.28},
1862  {57.28, 57.29, 57.31, 57.33}}};
1863  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{57.31, 57.28, 57.30, 57.28},
1864  {57.28, 57.29, 57.31, 57.33}}};
1865 
1866  // Delta T0 cut
1867  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{-10, -10, -10, -10}, {-10, -10, -10, -10}}};
1868  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{ 10, 10, 10, 10}, { 10, 10, 10, 10}}};
1869  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{-10, -10, -10, -10}, {-10, -10, -10, -10}}};
1870  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{ 10, 10, 10, 10}, { 10, 10, 10, 10}}};
1871 
1872  for (size_t side : {0, 1}) {
1873  for (size_t module : {0, 1, 2, 3}) {
1874  fixTau1Arr[side][module] = true;
1875  fixTau2Arr[side][module] = true;
1876 
1877  peak2ndDerivMinSamples[side][module] = peakSample;
1878  peak2ndDerivMinThresholdsHG[side][module] = peak2ndDerivThreshHG;
1879  peak2ndDerivMinThresholdsLG[side][module] = peak2ndDerivThreshLG;
1880 
1881  chisqDivAmpCut[side][module] = 15;
1882  }
1883  }
1884 
1885  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{ 800, 800, 800, 800}}, {{ 800, 800, 800, 800}}}};
1886  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{ 10, 10, 10, 10}}, {{ 10, 10, 10, 10}}}};
1887  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1888 
1889  m_deltaTSample = 12.5;
1890 
1891  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(), 7, m_deltaTSample, 0, "FermiExp", peak2ndDerivMinSamples,
1892  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1893 
1894  // Open up tolerances on the position of the peak for now
1895  //
1896  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(1);
1897 
1898  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
1899  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1Arr, tau2Arr, t0HG, t0LG);
1900  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
1901 
1902  zdcDataAnalyzer->SetFitTimeMax(85);
1903  zdcDataAnalyzer->SetSaveFitFunc(false);
1904 
1905  return zdcDataAnalyzer;
1906 }
1907 
1908 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializepPb2016()
1909 {
1910  //
1911  // For now, we continue to use hard-coded values for the maximum and minimum ADC values
1912  // For now we also use the FermiExp pulse model.
1913 
1914  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
1915  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{};
1916  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCut{};
1917  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
1918 
1919  // For now we allow the tau values to be controlled by the job properties until they are better determined
1920  //
1921  const int peakSample = 5;
1922  const float peak2ndDerivThreshHG = -12;
1923  const float peak2ndDerivThreshLG = -10;
1924  ZDCDataAnalyzer::ZDCModuleFloatArray tau1Arr = {{{4.000, 3.380, 3.661, 3.679},
1925  {4.472, 4.656, 3.871, 4.061}
1926  }};
1927 
1928  ZDCDataAnalyzer::ZDCModuleFloatArray tau2Arr = {{{22, 24.81, 24.48, 24.45},
1929  {24.17, 24.22, 25.46, 24.45}
1930  }};
1931 
1932  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{70.00, 72.74, 73.09, 72.25},
1933  {75.11, 74.94, 73.93, 74.45}
1934  }};
1935  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{70.00, 73.41, 74.27, 73.30},
1936  {76.28, 76.07, 74.98, 76.54}
1937  }};
1938 
1939  // Delta T0 cut
1940  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
1941  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
1942  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
1943  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
1944 
1945 
1946  for (size_t side : {0, 1}) {
1947  for (size_t module : {0, 1, 2, 3}) {
1948  fixTau1Arr[side][module] = true;
1949  fixTau2Arr[side][module] = true;
1950 
1951  peak2ndDerivMinSamples[side][module] = peakSample;
1952  peak2ndDerivMinThresholdsHG[side][module] = peak2ndDerivThreshHG;
1953  peak2ndDerivMinThresholdsLG[side][module] = peak2ndDerivThreshLG;
1954 
1955  chisqDivAmpCut[side][module] = 15;
1956  }
1957  }
1958 
1959  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
1960  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
1961  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
1962 
1963  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
1964  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
1965  slewingParamsHG[0][0] = {0, 0, 0, 0};
1966  slewingParamsHG[0][1] = { -4.780244e-01, -7.150874e-02, 4.614585e-02, 8.015731e-04};
1967  slewingParamsHG[0][2] = { -5.253412e-01, -5.718167e-02, 5.243121e-02, 2.128398e-03};
1968  slewingParamsHG[0][3] = { -5.773952e-01, -5.687478e-02, 4.564267e-02, 1.462294e-03};
1969 
1970  slewingParamsHG[1][0] = { 7.105115e-01, -3.686143e-02, 7.727447e-02, 5.924152e-03};
1971  slewingParamsHG[1][1] = { 4.052120e-02, 4.450686e-03, 8.031615e-02, 4.038097e-03};
1972  slewingParamsHG[1][2] = { 3.389476e-02, -2.056782e-02, 4.805321e-02, -2.627999e-03};
1973  slewingParamsHG[1][3] = { 2.069765e-01, -2.890419e-02, 6.084375e-02, 3.742011e-03};
1974 
1975  slewingParamsLG[0][0] = {0, 0, 0, 0};
1976  slewingParamsLG[0][1] = { -1.632547e+00, -4.827813e-01, -1.379131e-01, -2.522607e-02};
1977  slewingParamsLG[0][2] = { -7.254288e+00, -5.454064e+00, -1.619126e+00, -1.739665e-01};
1978  slewingParamsLG[0][3] = { -1.548400e+01, -1.277708e+01, -3.729333e+00, -3.700458e-01};
1979 
1980  slewingParamsLG[1][0] = { 1.142767e-01, -3.608906e-02, 9.642735e-02, -3.097043e-03};
1981  slewingParamsLG[1][1] = { -5.615388e-01, -1.655047e-02, 8.327350e-02, -4.231348e-03};
1982  slewingParamsLG[1][2] = { -7.370728e-01, -2.887482e-02, 8.293875e-02, -4.482743e-03};
1983  slewingParamsLG[1][3] = { -1.270636e+00, -2.791777e-01, -5.807295e-02, -2.332612e-02};
1984 
1985  // Construct the data analyzer
1986  //
1987  // We adopt hard-coded values for the number of samples and the frequency which we kept fixed for all physics data
1988  //
1989  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer (new ZDCDataAnalyzer(MakeMessageFunction(), 7, 25, 0, "FermiExpLinear", peak2ndDerivMinSamples,
1990  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
1991 
1992  // Open up tolerances on the position of the peak for now
1993  //
1994  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(1);
1995 
1996  // We alwyas disable the 12EM (sideC) module which was not present (LHCf)
1997  //
1998  zdcDataAnalyzer->disableModule(0, 0);
1999 
2000  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
2001  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1Arr, tau2Arr, t0HG, t0LG);
2002  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
2003 
2004  // We allow the combineDelay to be controlled by the properties
2005  //
2006  // if (m_combineDelay) {
2007  m_combineDelay = true;
2008  ZDCDataAnalyzer::ZDCModuleFloatArray defaultPedestalShifts = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
2009 
2010  zdcDataAnalyzer->enableDelayed(-12.5, defaultPedestalShifts);
2011  zdcDataAnalyzer->SetFitTimeMax(140); // This restrict the fit range of the pulse fitting
2012  zdcDataAnalyzer->SetSaveFitFunc(false);
2013  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
2014  slewingParamsHG, slewingParamsLG); // add time slewing correction Sep 17 2019 Bill
2015  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
2016 
2017  return zdcDataAnalyzer;
2018 }
2019 
2020 std::unique_ptr<ZDCDataAnalyzer> ZdcAnalysisTool::initializePbPb2018()
2021 {
2022  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples{};
2023  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG{}, peak2ndDerivMinThresholdsLG{}, peak2ndDerivMinRepassHG{}, peak2ndDerivMinRepassLG{};
2024  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCut{};
2025  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
2026 
2027  static constexpr int peakSample = 5;
2028  static constexpr float peak2ndDerivThreshHG = -35;
2029  static constexpr float peak2ndDerivThreshLG = -20;
2030  static constexpr float peak2ndDerivRepassHG = -10;
2031  static constexpr float peak2ndDerivRepassLG = -6;
2032 
2033  ZDCDataAnalyzer::ZDCModuleFloatArray tau1Arr = {{{3.877, 3.998, 3.821, 3.858},
2034  {4.296, 4.064, 3.497, 3.642}
2035  }};
2036 
2037  ZDCDataAnalyzer::ZDCModuleFloatArray tau2Arr = {{{24.40, 25.28, 25.66, 24.12},
2038  {24.42, 24.99, 25.72, 25.29}
2039  }};
2040 
2041  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{70.51, 70.57, 70.13, 69.98},
2042  {74.18, 72.79, 71.77, 72.62}
2043  }};
2044  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{70.70, 70.78, 70.76, 70.91},
2045  {75.16, 73.71, 72.25, 73.61}
2046  }};
2047 
2048  ZDCDataAnalyzer::ZDCModuleFloatArray moduleAmpFractionLG = {{{0.2760, 0.3045, 0.2369, 0.1826},
2049  {0.3216, 0.2593, 0.2511, 0.1680}
2050  }};
2051 
2052  // Delta T0 cut
2053  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
2054  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
2055  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{ -6, -5, -5, -5}, {-5, -5, -5, -5}}};
2056  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{8, 8, 8, 11}, {8, 10, 8, 12}}};
2057 
2058  for (size_t side : {0, 1}) {
2059  for (size_t module : {0, 1, 2, 3}) {
2060  fixTau1Arr[side][module] = true;
2061  fixTau2Arr[side][module] = true;
2062 
2063  peak2ndDerivMinSamples[side][module] = peakSample;
2064  peak2ndDerivMinThresholdsHG[side][module] = peak2ndDerivThreshHG;
2065  peak2ndDerivMinThresholdsLG[side][module] = peak2ndDerivThreshLG;
2066  peak2ndDerivMinRepassHG [side][module] = peak2ndDerivRepassHG;
2067  peak2ndDerivMinRepassLG [side][module] = peak2ndDerivRepassLG;
2068 
2069  chisqDivAmpCut[side][module] = 15;
2070  }
2071  }
2072 
2073  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
2074  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2075  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
2076 
2077  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasLG = {{{1, 1, 1, 1}, {1, 1, 1, 1}}};
2078  ZDCDataAnalyzer::ZDCModuleFloatArray noiseSigmasHG = {{{12, 12, 12, 12}, {12, 12, 12, 12}}};
2079 
2080 
2081  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
2082  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
2083  slewingParamsHG[0][0] = { -1.335560e-01, -6.071869e-03, 5.858193e-02, 2.473300e-03};
2084  slewingParamsHG[0][1] = { -1.223062e-01, -4.379469e-02, 4.452285e-02, 2.130210e-03};
2085  slewingParamsHG[0][2] = { -1.021415e-01, -4.254239e-02, 4.939866e-02, 3.849738e-03};
2086  slewingParamsHG[0][3] = { -8.234056e-02, -3.938803e-02, 4.689029e-02, 2.784816e-03};
2087 
2088  slewingParamsHG[1][0] = { -1.640979e-01, -2.780350e-02, 5.755065e-02, -4.244651e-04};
2089  slewingParamsHG[1][1] = { -1.422324e-01, 2.663803e-02, 7.295366e-02, 3.740496e-03};
2090  slewingParamsHG[1][2] = { -9.858124e-02, -2.426132e-02, 4.895967e-02, 2.291393e-03};
2091  slewingParamsHG[1][3] = { -1.070401e-01, -2.256383e-03, 5.833770e-02, 2.255208e-03};
2092 
2093  slewingParamsLG[0][0] = { -2.588446e-01, -3.241086e-02, 7.828661e-02, 1.945547e-03};
2094  slewingParamsLG[0][1] = { -3.112495e-01, -7.419508e-02, 6.825776e-02, 2.148860e-03};
2095  slewingParamsLG[0][2] = { -3.470650e-01, -5.836748e-02, 6.204396e-02, 1.550421e-03};
2096  slewingParamsLG[0][3] = { -4.485435e-01, -4.603790e-02, 5.944799e-02, -1.174585e-03};
2097 
2098  slewingParamsLG[1][0] = { -3.291676e-01, -4.023732e-02, 8.608755e-02, -3.958167e-03};
2099  slewingParamsLG[1][1] = { -2.608969e-01, -2.129786e-03, 6.930791e-02, -4.141910e-03};
2100  slewingParamsLG[1][2] = { -2.505712e-01, -2.195804e-02, 5.137261e-02, -4.058378e-03};
2101  slewingParamsLG[1][3] = { -5.083206e-01, 3.776601e-02, 1.284275e-01, 1.014067e-02};
2102 
2103  // Construct the data analyzer
2104  //
2105  // We adopt hard-coded values for the number of samples and the frequency which we kept fixed for all physics data
2106  //
2107  std::unique_ptr<ZDCDataAnalyzer> zdcDataAnalyzer = std::make_unique<ZDCDataAnalyzer>(MakeMessageFunction(), 7, 25, 0, "FermiExpLinear", peak2ndDerivMinSamples, // presample index changed to zero 4/6/19
2108  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode);
2109 
2110  // Open up tolerances on the position of the peak for now
2111  //
2112  zdcDataAnalyzer->SetPeak2ndDerivMinTolerances(1);
2113 
2114  // We alwyas disable the 12EM (sideC) module which was not present (LHCf)
2115  //
2116 
2117  zdcDataAnalyzer->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
2118  zdcDataAnalyzer->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1Arr, tau2Arr, t0HG, t0LG);
2119  zdcDataAnalyzer->SetModuleAmpFractionLG(moduleAmpFractionLG); // fraction calculation for LGOverflows added Nov 23, 2020
2120  zdcDataAnalyzer->SetCutValues(chisqDivAmpCut, chisqDivAmpCut, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
2121 
2122  // We allow the combineDelay to be controlled by the properties
2123  //
2124  m_combineDelay = true;
2125  ZDCDataAnalyzer::ZDCModuleFloatArray defaultPedestalShifts = {{{{0, 0, 0, 0}}, {{0, 0, 0, 0}}}};
2126 
2127  // We use per-module delays to handle the delayed-undelayed swap on EMC
2128  //
2129  ZDCDataAnalyzer::ZDCModuleFloatArray delayDeltaTs = {{{{12.5, -12.5, -12.5, -12.5}},
2130  {{ -12.5, -12.5, -12.5, -12.5}}
2131  }
2132  };
2133 
2134  zdcDataAnalyzer->enableDelayed(delayDeltaTs, defaultPedestalShifts);
2135  zdcDataAnalyzer->SetFitTimeMax(140); // This restrict the fit range of the pulse fitting, requested by BAC 4/6/19
2136  zdcDataAnalyzer->SetSaveFitFunc(false);
2137  zdcDataAnalyzer->enableRepass(peak2ndDerivMinRepassHG, peak2ndDerivMinRepassLG); // add repass as default Jul 21 2020 Bill
2138  zdcDataAnalyzer->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
2139  slewingParamsHG, slewingParamsLG); // add time slewing correction Sep 17 2019 Bill
2140  // ref. https://indico.cern.ch/event/849143/contributions/3568263/attachments/1909759/3155352/ZDCWeekly_20190917_PengqiYin.pdf
2141 
2142  zdcDataAnalyzer->SetNoiseSigmas(noiseSigmasHG, noiseSigmasLG);
2143 
2144  return zdcDataAnalyzer;
2145 }
2146 
2148 {
2149  // We have a complete configuration and so we override all of the default parameters
2150  //
2151 
2152  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{{4.2, 3.8, 5.2, 5.0}},
2153  {{5.0, 3.7, 3.5, 3.5}}
2154  }
2155  };
2156 
2157  // identical to 80 MHz -- is this right
2158  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{{20.0, 20.4, 18.9, 20.8}},
2159  {{19.1, 21.9, 22.6, 23.4}}
2160  }
2161  };
2162 
2163  ZDCDataAnalyzer::ZDCModuleIntArray peak2ndDerivMinSamples = {{{{1, 1, 2, 1}},
2164  {{1, 1, 1, 1}}
2165  }
2166  };
2167 
2168  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsHG = {{{{ -8, -8, -8, -8}},
2169  {{ -8, -8, -8, -8}}
2170  }
2171  };
2172 
2173  ZDCDataAnalyzer::ZDCModuleFloatArray peak2ndDerivMinThresholdsLG = {{{{ -4, -4, -4, -4}},
2174  {{ -4, -4, -4, -4}}
2175  }
2176  };
2177 
2178  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
2179  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2180  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{1020, 1020, 1020, 1020}}, {{1020, 1020, 1020, 1020}}}};
2181 
2182  // Set Tau and nominal timing offsets
2183  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
2184 
2185  bool fixTau1 = true;
2186  bool fixTau2 = true;
2187 
2188  for (size_t side : {0, 1}) {
2189  for (size_t module : {0, 1, 2, 3}) {
2190  fixTau1Arr[side][module] = fixTau1;
2191  fixTau2Arr[side][module] = fixTau2;
2192  }
2193  }
2194 
2195  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{{53.942, 49.887, 59.633, 46.497}},
2196  {{46.314, 42.267, 50.327, 41.605}}
2197  }
2198  };
2199  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{{51.771, 47.936, 57.438, 44.191}},
2200  {{44.295, 41.755, 48.081, 40.175}}
2201  }
2202  };
2203 
2204 
2205  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2206  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutLG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2207  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
2208  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
2209  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
2210  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
2211 
2212  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
2213 
2214  slewingParamsHG[0][0] = {0, -7.904e-02, 4.686e-02, 1.530e-03 };
2215  slewingParamsHG[0][1] = {0, 2.250e-02, 4.732e-02, 6.050e-03 };
2216  slewingParamsHG[0][2] = {0, 4.388e-02, 6.707e-02, -5.526e-05 };
2217  slewingParamsHG[0][3] = {0, 1.205e-01, 2.726e-02, 2.610e-03 };
2218 
2219  slewingParamsHG[1][0] = {0, 6.861e-02, 5.175e-03, -9.018e-04 };
2220  slewingParamsHG[1][1] = {0, 3.855e-01, -4.442e-02, -2.022e-02 };
2221  slewingParamsHG[1][2] = {0, -4.337e-03, 3.841e-02, 4.661e-03 };
2222  slewingParamsHG[1][3] = {0, 3.623e-01, -3.882e-02, -1.805e-02 };
2223 
2224  slewingParamsLG[0][0] = {0, 1.708e-02, 7.929e-02, 5.079e-03 };
2225  slewingParamsLG[0][1] = {0, 1.406e-01, 1.209e-01, -1.922e-04 };
2226  slewingParamsLG[0][2] = {0, 1.762e-01, 1.118e-01, 1.679e-04 };
2227  slewingParamsLG[0][3] = {0, 1.361e-02, -2.685e-02, -4.168e-02 };
2228 
2229  slewingParamsLG[1][0] = {0, 1.962e-01, -5.025e-03, -2.001e-02 };
2230  slewingParamsLG[1][1] = {0, 3.258e-01, 1.229e-02, -2.925e-02 };
2231  slewingParamsLG[1][2] = {0, 1.393e-01, 8.113e-02, -2.594e-03 };
2232  slewingParamsLG[1][3] = {0, 1.939e-01, 2.188e-02, -5.579e-02 };
2233 
2234  m_zdcDataAnalyzer_40MHz.reset (new ZDCDataAnalyzer(MakeMessageFunction(), 7, 25, 0, "FermiExp", peak2ndDerivMinSamples,
2235  peak2ndDerivMinThresholdsHG, peak2ndDerivMinThresholdsLG, m_lowGainMode));
2236 
2237  m_zdcDataAnalyzer_40MHz->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
2238  m_zdcDataAnalyzer_40MHz->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
2239  m_zdcDataAnalyzer_40MHz->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
2240  m_zdcDataAnalyzer_40MHz->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
2241  slewingParamsHG, slewingParamsLG);
2242 
2243  std::array<std::array<std::vector<float>, 4>, 2> moduleHGNonLinCorr, moduleLGNonLinCorr;
2244  moduleHGNonLinCorr[0][0] = { -3.76800e-02, 4.63597e-02};
2245  moduleHGNonLinCorr[0][1] = { -1.02185e-01, -1.17548e-01};
2246  moduleHGNonLinCorr[0][2] = { -8.78451e-02, -1.52174e-01};
2247  moduleHGNonLinCorr[0][3] = { -1.04835e-01, -1.96514e-01};
2248  moduleHGNonLinCorr[1][0] = { -6.83115e-02, 3.57802e-02};
2249  moduleHGNonLinCorr[1][1] = { -1.08162e-01, -1.91413e-01};
2250  moduleHGNonLinCorr[1][2] = { -7.82514e-02, -1.21218e-01};
2251  moduleHGNonLinCorr[1][3] = { -2.34354e-02, -2.52033e-01};
2252 
2253  moduleLGNonLinCorr = {{ {{{0},
2254  {0},
2255  {0},
2256  {0}}},
2257  {{{0},
2258  {0},
2259  {0},
2260  {0}}} }};
2261 
2262  if (m_doNonLinCorr) m_zdcDataAnalyzer_40MHz->SetNonlinCorrParams(500, 1000, moduleHGNonLinCorr, moduleLGNonLinCorr);
2263  m_zdcDataAnalyzer_40MHz->SetSaveFitFunc(false);
2264 
2265 }
2266 
2268 {
2269  // We have a complete configuration and so we override all of the default parameters
2270  //
2271 
2272  m_peak2ndDerivMinSamples = {{{{3, 2, 3, 2}},
2273  {{2, 2, 2, 2}}
2274  }
2275  };
2276 
2277  m_peak2ndDerivMinThresholdsHG = {{{{ -8, -8, -8, -8}},
2278  {{ -8, -8, -8, -8}}
2279  }
2280  };
2281 
2282  m_peak2ndDerivMinThresholdsLG = {{{{ -4, -4, -4, -4}},
2283  {{ -4, -4, -4, -4}}
2284  }
2285  };
2286 
2287  ZDCDataAnalyzer::ZDCModuleFloatArray HGOverFlowADC = {{{{800, 800, 800, 800}}, {{800, 800, 800, 800}}}};
2288  ZDCDataAnalyzer::ZDCModuleFloatArray HGUnderFlowADC = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2289  ZDCDataAnalyzer::ZDCModuleFloatArray LGOverFlowADC = {{{{950, 950, 950, 950}}, {{950, 950, 950, 950}}}};
2290 
2291  // Set Tau and nominal timing offsets
2292  ZDCDataAnalyzer::ZDCModuleBoolArray fixTau1Arr{}, fixTau2Arr{};
2293 
2294  bool fixTau1 = true;
2295  bool fixTau2 = true;
2296 
2297  for (size_t side : {0, 1}) {
2298  for (size_t module : {0, 1, 2, 3}) {
2299  fixTau1Arr[side][module] = fixTau1;
2300  fixTau2Arr[side][module] = fixTau2;
2301  }
2302  }
2303 
2304  ZDCDataAnalyzer::ZDCModuleFloatArray tau1 = {{{{3.9, 3.4, 4.1, 4.2}},
2305  {{4.2, 3.6, 3.3, 3.4}}
2306  }
2307  };
2308 
2309  ZDCDataAnalyzer::ZDCModuleFloatArray tau2 = {{{{20.0, 20.4, 18.9, 20.8}},
2310  {{19.1, 21.9, 22.6, 23.4}}
2311  }
2312  };
2313 
2314  ZDCDataAnalyzer::ZDCModuleFloatArray t0HG = {{{{44.24, 40.35, 49.3, 36.0}},
2315  {{36.0, 31.1, 40.75, 30.5}}
2316  }
2317  };
2318 
2319  ZDCDataAnalyzer::ZDCModuleFloatArray t0LG = {{{{42.65, 38.5, 47.4, 34}},
2320  {{33.7, 29.9, 39.0, 29.3}}
2321  }
2322  };
2323 
2324  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutHG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2325  ZDCDataAnalyzer::ZDCModuleFloatArray chisqDivAmpCutLG = {{{{10, 10, 10, 10}}, {{10, 10, 10, 10}}}};
2326  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowHG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
2327  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighHG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
2328  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutLowLG = {{{{ -6, -5, -5, -5}}, {{ -5, -5, -5, -5}}}};
2329  ZDCDataAnalyzer::ZDCModuleFloatArray DeltaT0CutHighLG = {{{{8, 8, 8, 11}}, {{8, 10, 8, 12}}}};
2330 
2331  std::array<std::array<std::vector<float>, 4>, 2> slewingParamsHG, slewingParamsLG;
2332 
2333  slewingParamsHG[0][0] = {0, -6.5e-2, 2.85e-2, -2.83e-3};
2334  slewingParamsHG[0][1] = {0, -5.5e-2, 5.13e-2, 5.6e-3};
2335  slewingParamsHG[0][2] = {0, -1.45e-3, 9.3e-2, 3.9e-3};
2336  slewingParamsHG[0][3] = {0, -2.36e-2, 8.3e-2, 1.1e-3};
2337 
2338  slewingParamsHG[1][0] = {0, -6.5e-2, 4.84e-2, -3.7e-3};
2339  slewingParamsHG[1][1] = {0, 1.34e-2, 6.57e-2, 5.37e-3};
2340  slewingParamsHG[1][2] = {0, -5.37e-2, 3.49e-2, 3.8e-3};
2341  slewingParamsHG[1][3] = {0, -3.3e-2, 3.9e-2, 2.2e-3};
2342 
2343  slewingParamsLG[0][0] = {0, -9.6e-2, 4.39e-2, 2.93e-3 };
2344  slewingParamsLG[0][1] = {0, -5.0e-2, 14.9e-2, 20.6e-3 };
2345  slewingParamsLG[0][2] = {0, -4.4e-2, 5.3e-2, 0, };
2346  slewingParamsLG[0][3] = {0, -9.90e-2, 4.08e-2, 0, };
2347 
2348  slewingParamsLG[1][0] = {0, -8.7e-2, 4.2e-2, -3.2e-3 };
2349  slewingParamsLG[1][1] = {0, -3.26e-2, 3.84e-2, -2.32e-3};
2350  slewingParamsLG[1][2] = {0, -26.8e-2, -2.64e-2, -5.3e-3 };
2351  slewingParamsLG[1][3] = {0, -13.2e-2, 0.45e-2, -2.4e-3 };
2352 
2353 
2356 
2357  m_zdcDataAnalyzer_80MHz->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
2358  m_zdcDataAnalyzer_80MHz->SetTauT0Values(fixTau1Arr, fixTau2Arr, tau1, tau2, t0HG, t0LG);
2359  m_zdcDataAnalyzer_80MHz->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG, DeltaT0CutLowHG, DeltaT0CutHighHG, DeltaT0CutLowLG, DeltaT0CutHighLG);
2360  m_zdcDataAnalyzer_80MHz->SetTimingCorrParams(ZDCPulseAnalyzer::TimingCorrLin, 500, 100,
2361  slewingParamsHG, slewingParamsLG);
2362 
2363  std::array<std::array<std::vector<float>, 4>, 2> moduleHGNonLinCorr, moduleLGNonLinCorr;
2364  moduleHGNonLinCorr[0][0] = { -3.76800e-02, 4.63597e-02};
2365  moduleHGNonLinCorr[0][1] = { -1.02185e-01, -1.17548e-01};
2366  moduleHGNonLinCorr[0][2] = { -8.78451e-02, -1.52174e-01};
2367  moduleHGNonLinCorr[0][3] = { -1.04835e-01, -1.96514e-01};
2368  moduleHGNonLinCorr[1][0] = { -6.83115e-02, 3.57802e-02};
2369  moduleHGNonLinCorr[1][1] = { -1.08162e-01, -1.91413e-01};
2370  moduleHGNonLinCorr[1][2] = { -7.82514e-02, -1.21218e-01};
2371  moduleHGNonLinCorr[1][3] = { -2.34354e-02, -2.52033e-01};
2372 
2373  moduleLGNonLinCorr = {{ {{{0},
2374  {0},
2375  {0},
2376  {0}}},
2377  {{{0},
2378  {0},
2379  {0},
2380  {0}}} }};
2381 
2382  if (m_doNonLinCorr) m_zdcDataAnalyzer_80MHz->SetNonlinCorrParams(500, 1000, moduleHGNonLinCorr, moduleLGNonLinCorr);
2383  m_zdcDataAnalyzer_80MHz->SetSaveFitFunc(false);
2384 }
2385 
2387 {
2388  m_tf1SincInterp.reset (new TF1("SincInterp", ZDC::SincInterp, -5., 160., 8));
2389  m_tf1SincInterp->SetNpx(300);
2390 
2391  // Set up calibrations
2392  //
2393  std::string filename = PathResolverFindCalibFile( "ZdcAnalysis/ZdcAnalysisConfig.conf" );
2394  TEnv env(filename.c_str());
2395 
2396  m_zdcEnergyCalibFileName = std::string(env.GetValue("ZdcEnergyCalibFileName", "ZdcCalibrations_v1.root"));
2397  ATH_MSG_INFO("ZDC energy calibration filename " << m_zdcEnergyCalibFileName);
2398  m_zdcTimeCalibFileName = std::string(env.GetValue("ZdcTimeCalibFileName", "ZdcTimeCalibrations_v1.root"));
2399  ATH_MSG_INFO("ZDC time calibration filename " << m_zdcTimeCalibFileName);
2400  m_zdcTriggerEffParamsFileName = std::string(env.GetValue("ZdcTriggerEffFileName", "ZdcTriggerEffParameters_v6.root"));
2401  ATH_MSG_INFO("ZDC trigger efficiencies filename " << m_zdcTriggerEffParamsFileName);
2402 
2403 
2404  if (m_forceCalibRun > -1) {
2405  ATH_MSG_DEBUG("CAREFUL: forcing calibration run/LB =" << m_forceCalibRun << "/" << m_forceCalibLB);
2406 
2407  if (m_forceCalibLB < 0) {
2408  ATH_MSG_ERROR("Invalid settings: Forced run > 0 but lumi block < 0");
2409  return StatusCode::FAILURE;
2410  }
2411  }
2412 
2413  // Use configuration to direct initialization
2414  //
2415  if (m_configuration == "default") {
2417  }
2418  else if (m_configuration == "PbPb2015") {
2419  initialize80MHz();
2420  initialize40MHz();
2421 
2423  }
2424  else if (m_configuration == "pPb2016") {
2426  }
2427  else if (m_configuration == "PbPb2018") {
2429  }
2430  else if (m_configuration == "PbPb2015G4") {
2432  }
2433  else if (m_configuration == "LHCf2022") {
2435  }
2436  else if (m_configuration == "pp2023") {
2438  }
2439  else if (m_configuration == "pp2024") {
2441  }
2442  else if (m_configuration == "PbPb2023") {
2444  }
2445  else if (m_configuration == "PbPb2024") {
2447  }
2448  else if (m_configuration == "OONeNe2025") {
2450  }
2451  else if (m_configuration == "pO2025") {
2453  }
2454  else if (m_configuration == "pO2025B") {
2456  }
2457  else if (m_configuration == "Injectorpp2024") {
2459  }
2460  else if (m_configuration == "InjectorPbPb2024") {
2462  }
2463  else if (m_configuration == "InjectorpOOONeNe2025") {
2465  }
2466  else if (m_configuration == "MonteCarloPbPb2023") {
2468  }
2469  else {
2470  ATH_MSG_ERROR("Unknown configuration: " << m_configuration);
2471  return StatusCode::FAILURE;
2472  }
2473 
2474  // If an aux suffix is provided, prepend it with "_" so we don't have to do so at each use
2475  //
2476 
2477  ATH_MSG_INFO("Configuration: " << m_configuration);
2478  ATH_MSG_DEBUG("FlipEMDelay: " << m_flipEMDelay);
2479  ATH_MSG_DEBUG("LowGainMode: " << m_lowGainMode);
2480 
2481  ATH_MSG_DEBUG("Using Combined delayed and undelayed samples: " << m_combineDelay);
2482 
2483  ATH_MSG_DEBUG("WriteAux: " << m_writeAux);
2484  ATH_MSG_DEBUG("AuxSuffix: " << m_auxSuffix);
2485  ATH_MSG_DEBUG("DoCalib: " << m_doCalib);
2486  ATH_MSG_DEBUG("ForceCalibRun: " << m_forceCalibRun);
2487  ATH_MSG_DEBUG("ForceCalibLB: " << m_forceCalibLB);
2488  ATH_MSG_DEBUG("NumSampl: " << m_numSample);
2489  ATH_MSG_DEBUG("DeltaTSample: " << m_deltaTSample);
2490  ATH_MSG_DEBUG("Presample: " << m_presample);
2491  ATH_MSG_DEBUG("PeakSample: " << m_peakSample);
2492  ATH_MSG_DEBUG("Peak2ndDerivThresh: " << m_Peak2ndDerivThresh);
2493 
2494  if (m_combineDelay) ATH_MSG_DEBUG("DelayDeltaT: " << m_delayDeltaT);
2495 
2496  ATH_MSG_DEBUG("T0: " << m_t0);
2497  ATH_MSG_DEBUG("Tau1: " << m_tau1);
2498  ATH_MSG_DEBUG("Tau2: " << m_tau2);
2499  ATH_MSG_DEBUG("FixTau1: " << m_fixTau1);
2500  ATH_MSG_DEBUG("FixTau2: " << m_fixTau2);
2501  ATH_MSG_DEBUG("DeltaTCut: " << m_deltaTCut);
2502  ATH_MSG_DEBUG("ChisqRatioCut: " << m_ChisqRatioCut);
2503 
2505 
2506  // Initialize decorations
2507 
2509  ATH_CHECK( m_zdcModuleAmplitude.initialize());
2511  ATH_CHECK( m_zdcModuleCalibEnergy.initialize());
2513  ATH_CHECK( m_zdcModuleCalibTime.initialize());
2515  ATH_CHECK( m_zdcModuleStatus.initialize());
2517  ATH_CHECK( m_zdcModuleTime.initialize());
2519  ATH_CHECK( m_zdcModuleChisq.initialize());
2521  ATH_CHECK( m_zdcModuleAmpNoNonLin.initialize());
2523  ATH_CHECK( m_zdcModuleFitAmp.initialize());
2525  ATH_CHECK( m_zdcModuleFitAmpError.initialize());
2527  ATH_CHECK( m_zdcModuleFitT0.initialize());
2529  ATH_CHECK( m_zdcModuleBkgdMaxFraction.initialize());
2531  ATH_CHECK( m_zdcModulePreSampleAmp.initialize());
2533  ATH_CHECK( m_zdcModulePresample.initialize());
2535  ATH_CHECK( m_zdcModuleMinDeriv2nd.initialize());
2537  ATH_CHECK( m_zdcModuleMaxADC.initialize());
2538 
2540  ATH_CHECK( m_zdcModuleMaxADCHG.initialize());
2542  ATH_CHECK( m_zdcModuleMaxADCLG.initialize());
2543 
2544  // LG refit data
2545  //
2547  ATH_CHECK(m_zdcModuleFitAmpLGRefit.initialize());
2549  ATH_CHECK(m_zdcModuleAmpLGRefit.initialize());
2551  ATH_CHECK(m_zdcModuleAmpCorrLGRefit.initialize());
2553  ATH_CHECK(m_zdcModuleT0LGRefit.initialize());
2555  ATH_CHECK(m_zdcModuleT0SubLGRefit.initialize());
2557  ATH_CHECK( m_zdcModuleChisqLGRefit.initialize());
2558 
2559  // ZDC per-calorimeter data
2560  //
2562  ATH_CHECK( m_zdcSumUncalibSum.initialize());
2564  ATH_CHECK( m_zdcSumUncalibSumErr.initialize());
2566  ATH_CHECK( m_zdcSumCalibEnergy.initialize());
2568  ATH_CHECK( m_zdcSumCalibEnergyErr.initialize());
2570  ATH_CHECK( m_zdcSumNLCalibEnergy.initialize());
2572  ATH_CHECK( m_zdcSumNLCalibEnergyErr.initialize());
2574  ATH_CHECK( m_zdcSumFinalEnergy.initialize());
2576  ATH_CHECK( m_zdcSumAverageTime.initialize());
2578  ATH_CHECK( m_zdcSumStatus.initialize());
2580  ATH_CHECK( m_zdcSumModuleMask.initialize());
2581 
2582  if (m_writeAux && m_auxSuffix != "") {
2583  ATH_MSG_DEBUG("suffix string = " << m_auxSuffix);
2584  }
2585 
2586  m_init = true;
2587 
2588  return StatusCode::SUCCESS;
2589 }
2590 
2592 {
2593 
2594 }
2595 
2597 {
2598  ATH_MSG_DEBUG("Setting up new run " << runNumber);
2599 
2600  // We do nothing for the default configuration
2601  //
2602  if (m_configuration != "default") {
2603  if (m_configuration == "PbPb2015") {
2604  //
2605  // Two periods, 40 MHz and 80 MHz readout
2606  //
2609  }
2610  }
2611 
2612  return StatusCode::SUCCESS;
2613 }
2614 
2615 
2617 {
2618 
2619  if (moduleContainer.size()==0) return StatusCode::SUCCESS; // if no modules, do nothing
2620 
2622  if (!eventInfo.isValid()) return StatusCode::FAILURE;
2623 
2624  // Check for decoding errors and bail out if ZDC error found
2626  if (zdcErr)
2627  {
2628  ATH_MSG_WARNING("ZDC decoding error found - abandoning ZDC reco!");
2629  return StatusCode::SUCCESS;
2630  }
2631 
2632  // check for new run number, if new, possibly update configuration and/or calibrations
2633  //
2634  unsigned int thisRunNumber = eventInfo->runNumber();
2635  if (thisRunNumber != m_runNumber) {
2636  ATH_MSG_DEBUG("ZDC analysis tool will be configured for run " << thisRunNumber);
2637 
2638  ATH_CHECK(configureNewRun(thisRunNumber)); // ALWAYS check methods that return StatusCode
2639 
2640  ATH_MSG_DEBUG("Setting up calibrations");
2641 
2642  if (m_doFADCCorr)
2643  {
2644  unsigned int calibRunNumber = thisRunNumber;
2645  if (m_forceCalibRun > -1) calibRunNumber = m_forceCalibRun;
2646  try
2647  {
2648  setFADCCorrections(calibRunNumber);
2649  }
2650  catch(std::runtime_error&)
2651  {
2652  m_doFADCCorr = false;
2653  }
2654  }
2655 
2656  if (m_doCalib) {
2657  //
2658  // Check for calibration override
2659  //
2660  unsigned int calibRunNumber = thisRunNumber;
2661  if (m_forceCalibRun > -1) calibRunNumber = m_forceCalibRun;
2662  try
2663  {
2664  setEnergyCalibrations(calibRunNumber);
2665  }
2666  catch(std::runtime_error&)
2667  {
2668  m_doCalib = false;
2669  }
2670 
2671  if (m_doTrigEff) initializeTriggerEffs(calibRunNumber); // if energy calibrations fail to load, then so will trigger efficiencies
2672  if (m_doTimeCalib) setTimeCalibrations(calibRunNumber);
2673  }
2674 
2675  m_runNumber = thisRunNumber;
2676  }
2677 
2678  m_lumiBlock = eventInfo->lumiBlock();
2679 
2680  unsigned int calibLumiBlock = m_lumiBlock;
2681  if (m_doCalib) {
2682  if (m_forceCalibRun > 0) calibLumiBlock = m_forceCalibLB;
2683  }
2684 
2685  ATH_MSG_DEBUG("Starting event processing");
2686  ATH_MSG_DEBUG("LB=" << calibLumiBlock);
2687 
2688  m_zdcDataAnalyzer->StartEvent(calibLumiBlock);
2689 
2690  static const SG::ConstAccessor<std::vector<uint16_t> > g0dataAcc ("g0data");
2691  static const SG::ConstAccessor<std::vector<uint16_t> > g1dataAcc ("g1data");
2692 
2693  const std::vector<unsigned short>* adcUndelayLG = 0;
2694  const std::vector<unsigned short>* adcUndelayHG = 0;
2695 
2696  const std::vector<unsigned short>* adcDelayLG = 0;
2697  const std::vector<unsigned short>* adcDelayHG = 0;
2698 
2699  ATH_MSG_DEBUG("Processing modules");
2700  for (const auto zdcModule : moduleContainer)
2701  {
2702  int side = -1;
2703  if (zdcModule->zdcSide() == -1) side = 0;
2704  else if (zdcModule->zdcSide() == 1) side = 1;
2705  else {
2706  // Invalid side
2707  //
2708  ATH_MSG_WARNING("Invalid side value found for module number: " << zdcModule->zdcModule() << ", side value = " << side);
2709  continue;
2710  }
2711  // Ignore MC only modules
2712  if(zdcModule->zdcModule() > 4) continue;
2713 
2714  if (zdcModule->zdcType() == 0) {
2715  //
2716  // This is ZDC data
2717  //
2718  if (m_LHCRun==3) // no delay channels, so we drop the index
2719  {
2720  adcUndelayLG = &g0dataAcc(*zdcModule); // g0
2721  adcUndelayHG = &g1dataAcc(*zdcModule); // g1
2722  }
2723  else if (m_LHCRun==2)
2724  {
2725 
2726 
2727  static const SG::ConstAccessor<std::vector<uint16_t> > g0d1dataAcc ("g0d1data");
2728  static const SG::ConstAccessor<std::vector<uint16_t> > g1d1dataAcc ("g1d1data");
2729  static const SG::ConstAccessor<std::vector<uint16_t> > g0d0dataAcc ("g0d0data");
2730  static const SG::ConstAccessor<std::vector<uint16_t> > g1d0dataAcc ("g1d0data");
2731 
2732  if (zdcModule->zdcModule() == 0 && m_flipEMDelay) // flip delay/non-delay for 2015 ONLY
2733  {
2734  adcUndelayLG = &g0d1dataAcc(*zdcModule); // g0d1
2735  adcUndelayHG = &g1d1dataAcc(*zdcModule); // g1d1
2736  adcDelayLG = &g0d0dataAcc(*zdcModule); // g0d0
2737  adcDelayHG = &g1d0dataAcc(*zdcModule); // g1d0
2738  }
2739  else // nominal configuation
2740  {
2741  adcUndelayLG = &g0d0dataAcc(*zdcModule); // g0d0
2742  adcUndelayHG = &g1d0dataAcc(*zdcModule); // g1d0
2743  adcDelayLG = &g0d1dataAcc(*zdcModule); // g0d1
2744  adcDelayHG = &g1d1dataAcc(*zdcModule); // g1d1
2745  }
2746  }
2747  else
2748  {
2749  ATH_MSG_WARNING("Unknown LHC Run " << m_LHCRun);
2750  return StatusCode::FAILURE;
2751  }
2752 
2753  // Why were these static? to optimize processing time
2754  std::vector<float> HGUndelADCSamples(m_numSample);
2755  std::vector<float> LGUndelADCSamples(m_numSample);
2756 
2757  if (LGUndelADCSamples.size() < adcUndelayLG->size()) {
2758  LGUndelADCSamples.resize(adcUndelayLG->size());
2759  }
2760 
2761  if (HGUndelADCSamples.size() < adcUndelayHG->size()) {
2762  HGUndelADCSamples.resize(adcUndelayHG->size());
2763  }
2764 
2765  std::copy(adcUndelayLG->begin(), adcUndelayLG->end(), LGUndelADCSamples.begin());
2766  std::copy(adcUndelayHG->begin(), adcUndelayHG->end(), HGUndelADCSamples.begin());
2767 
2768  int side = (zdcModule->zdcSide() == -1) ? 0 : 1 ;
2769 
2770  if (!m_combineDelay) {
2771  m_zdcDataAnalyzer->LoadAndAnalyzeData(side, zdcModule->zdcModule(), HGUndelADCSamples, LGUndelADCSamples);
2772  }
2773  else {
2774  std::vector<float> HGDelayADCSamples(m_numSample);
2775  std::vector<float> LGDelayADCSamples(m_numSample);
2776  if (adcDelayLG and adcDelayHG){
2777  std::copy(adcDelayLG->begin(), adcDelayLG->end(), LGDelayADCSamples.begin());
2778  std::copy(adcDelayHG->begin(), adcDelayHG->end(), HGDelayADCSamples.begin());
2779  }else{
2780  ATH_MSG_ERROR("adcDelayLG or adcDelayHG pointers are null");
2781  return StatusCode::FAILURE;
2782  }
2783  // If the delayed channels actually come earlier (as in the pPb in 2016), we invert the meaning of delayed and undelayed
2784  // see the initialization sections for similar inversion on the sign of the pedestal difference
2785  //
2786 
2787  m_zdcDataAnalyzer->LoadAndAnalyzeData(side, zdcModule->zdcModule(),
2788  HGUndelADCSamples, LGUndelADCSamples,
2789  HGDelayADCSamples, LGDelayADCSamples);
2790  }
2791  }
2792  }
2793 
2794  ATH_MSG_DEBUG("Finishing event processing");
2795 
2796  m_zdcDataAnalyzer->FinishEvent();
2797 
2798  ATH_MSG_DEBUG("Adding variables with suffix=" + m_auxSuffix);
2799 
2817 
2824 
2825  // CalibTime
2826  // Status
2827  // Time
2828  // Chisq
2829  // AmpNoNonLin
2830  // FitAmp
2831  // FitAmpError
2832  // FitT0
2833  // BkgdMaxFraction
2834  // PreSampleAmp
2835  // Presample
2836  // MinDeriv2nd
2837  // MaxADC
2838 
2839  for (const auto zdcModule : moduleContainer)
2840  {
2841  int side = (zdcModule->zdcSide() == -1) ? 0 : 1 ;
2842  int mod = zdcModule->zdcModule();
2843  // Ignore MC only modules
2844  if(mod > 4) continue;
2845 
2846  if (zdcModule->zdcType() == 0) {
2847  // this is the main ZDC
2848  if (m_writeAux) {
2849  float calibEnergy = m_zdcDataAnalyzer->GetModuleCalibAmplitude(side, mod);
2850  zdcModuleCalibEnergy(*zdcModule) = calibEnergy;
2851  zdcModuleCalibTime(*zdcModule) = m_zdcDataAnalyzer->GetModuleCalibTime(side, mod);
2852 
2853  zdcModuleAmplitude(*zdcModule) = m_zdcDataAnalyzer->GetModuleAmplitude(side, mod);
2854  zdcModuleStatus(*zdcModule) = m_zdcDataAnalyzer->GetModuleStatus(side, mod);
2855  zdcModuleTime(*zdcModule) = m_zdcDataAnalyzer->GetModuleTime(side, mod);
2856 
2857  const ZDCPulseAnalyzer* pulseAna_p = m_zdcDataAnalyzer->GetPulseAnalyzer(side, mod);
2858  zdcModuleChisq(*zdcModule) = pulseAna_p->GetChisq();
2859  zdcModuleAmpNoNonLin(*zdcModule) = pulseAna_p->GetAmpNoNonLin();
2860  zdcModuleFitAmp(*zdcModule) = pulseAna_p->GetFitAmplitude();
2861  zdcModuleFitAmpError(*zdcModule) = pulseAna_p->GetAmpError();
2862  zdcModuleFitT0(*zdcModule) = pulseAna_p->GetFitT0();
2863  zdcModuleBkgdMaxFraction(*zdcModule) = pulseAna_p->GetBkgdMaxFraction();
2864  zdcModulePreSampleAmp(*zdcModule) = pulseAna_p->GetPreSampleAmp();
2865  zdcModulePresample(*zdcModule) = pulseAna_p->getPresample();
2866  zdcModuleMinDeriv2nd(*zdcModule) = pulseAna_p->GetMinDeriv2nd();
2867  zdcModuleMaxADC(*zdcModule) = pulseAna_p->getMaxADCSub();
2868  zdcModuleMaxADCHG(*zdcModule) = pulseAna_p->getMaxADCHG();
2869  zdcModuleMaxADCLG(*zdcModule) = pulseAna_p->getMaxADCLG();
2870 
2871  zdcModuleAmpLGRefit(*zdcModule) = pulseAna_p->getRefitLGAmp();
2872  zdcModuleFitAmpLGRefit(*zdcModule) = pulseAna_p->getRefitLGFitAmp();
2873  zdcModuleAmpCorrLGRefit(*zdcModule) = pulseAna_p->getRefitLGAmpCorr();
2874  zdcModuleT0LGRefit(*zdcModule) = pulseAna_p->getRefitLGTime();
2875  zdcModuleT0SubLGRefit(*zdcModule) = pulseAna_p->getRefitLGTimeSub();
2876  zdcModuleChisqLGRefit(*zdcModule) = pulseAna_p->getRefitLGChisq();
2877  }
2878  //ATH_MSG_DEBUG ("side = " << side << " module=" << zdcModule->zdcModule() << " CalibEnergy=" << zdcModule->auxdecor<float>("CalibEnergy")
2879  // << " should be " << m_zdcDataAnalyzer->GetModuleCalibAmplitude(side, mod));
2880  }
2881  }
2882 
2883  // Output sum information
2884  // In Run 3 - we have to assume the container already exists (since it is needed to store the per-side trigger info)
2885  // reprocessing will add new variables with the suffix
2886 
2897 
2898  for (const auto zdc_sum: moduleSumContainer)
2899  {
2900  ATH_MSG_DEBUG("Extracting ZDC side " << zdc_sum->zdcSide());
2901 
2902  if (zdc_sum->zdcSide()==0) continue; // skip new global sum
2903 
2904  int iside = (zdc_sum->zdcSide()==-1) ? 0 : 1;
2905 
2906  float uncalibSum = getUncalibModuleSum(iside);
2907  zdcSumUncalibSum(*zdc_sum) = uncalibSum;
2908  float uncalibSumErr = getUncalibModuleSumErr(iside);
2909  zdcSumUncalibSumErr(*zdc_sum) = uncalibSumErr;
2910 
2911  float calibEnergy = getCalibModuleSum(iside);
2912  zdcSumCalibEnergy(*zdc_sum) = calibEnergy;
2913  float calibEnergyErr = getCalibModuleSumErr(iside);
2914  zdcSumCalibEnergyErr(*zdc_sum) = calibEnergyErr;
2915 
2916  float nlcalibEnergy = getNLCalibModuleSum(iside);
2917  zdcSumNLCalibEnergy(*zdc_sum) = nlcalibEnergy;
2918  float nlcalibEnergyErr = getNLCalibModuleSumErr(iside);
2919  zdcSumNLCalibEnergyErr(*zdc_sum) = nlcalibEnergyErr;
2920 
2921  float finalEnergy = calibEnergy;
2922  zdcSumFinalEnergy(*zdc_sum) = finalEnergy;
2923  zdcSumAverageTime(*zdc_sum) = getAverageTime(iside);
2924  zdcSumStatus(*zdc_sum) = !sideFailed(iside);
2925  zdcSumModuleMask(*zdc_sum) = (getModuleMask() >> (4 * iside)) & 0xF;
2926  }
2927 
2928  return StatusCode::SUCCESS;
2929 }
2930 
2932 {
2933 
2934  char name[128];
2935 
2936  std::string filename;
2937  if (m_LHCRun==3)
2938  {
2939  filename = PathResolverFindCalibFile( ("ZdcAnalysis/ZdcCalib_Run"+TString::Itoa(runNumber,10)+".root").Data() );
2940  }
2941  else if (m_LHCRun==2)
2942  {
2943  filename = PathResolverFindCalibFile( ("ZdcAnalysis/" + m_zdcEnergyCalibFileName).c_str() );
2944  }
2945  else
2946  {
2947  ATH_MSG_WARNING("No LHC Run defined, so no calibration allowed");
2948  return;
2949  }
2950 
2951  ATH_MSG_INFO("Opening energy calibration file " << filename);
2952  std::unique_ptr<TFile> fCalib (TFile::Open(filename.c_str(), "READ"));
2953 
2954  if (fCalib == nullptr || fCalib->IsZombie())
2955  {
2956  ATH_MSG_INFO ("failed to open file: " << filename);
2957  throw std::runtime_error ("failed to open file " + filename);
2958  }
2959 
2960  std::array<std::array<std::unique_ptr<TSpline>, 4>, 2> splines;
2961 
2962  // "m_calibVersion", called CalibVersion when settings parameters in python, is a directory within the run-based calibration file
2963  TString calibVersion;
2964  if (m_calibVersion != "") calibVersion = m_calibVersion + "/";
2965 
2966  for (int iside = 0; iside < 2; iside++)
2967  {
2968  for (int imod = 0; imod < 4; imod++)
2969  {
2970  sprintf(name, "ZDC_Ecalib_run%u_s%d_m%d", runNumber, iside, imod);
2971  ATH_MSG_DEBUG("Searching for spline " << name);
2972  TSpline3* s = (TSpline3*) fCalib->GetObjectChecked(calibVersion+TString(name), "TSpline3");
2973  if (!s && m_doCalib)
2974  {
2975  ATH_MSG_WARNING("No calibrations for run " << runNumber);
2976  m_doCalib = false;
2977  }
2978 
2979  if (s)
2980  {
2981  splines[iside][imod].reset (s);
2982  }
2983  else
2984  {
2985  ATH_MSG_WARNING("No spline " << name);
2986  }
2987  }
2988  }
2989  fCalib->Close();
2990 
2991  if (m_doCalib) m_zdcDataAnalyzer->LoadEnergyCalibrations(splines);
2992 
2993  return;
2994 }
2995 
2997 {
2998  std::string filename;
2999 
3000  if (m_LHCRun==3)
3001  {
3002  filename = PathResolverFindCalibFile( ("ZdcAnalysis/ZdcCalib_Run"+TString::Itoa(runNumber,10)+".root").Data() );
3003  }
3004  else if (m_LHCRun==2)
3005  {
3007  }
3008  else
3009  {
3010  ATH_MSG_WARNING("No LHC Run defined, so no time calibration allowed");
3011  return;
3012  }
3013 
3014  char name[128] = {0};
3015  ATH_MSG_INFO("Opening time calibration file " << filename);
3016  std::unique_ptr<TFile> fCalib (TFile::Open(filename.c_str(), "READ"));
3017 
3018  // "m_calibVersion", called CalibVersion when settings parameters in python, is a directory within the run-based calibration file
3019  TString calibVersion = "";
3020  if (m_calibVersion != "") calibVersion = m_calibVersion + "/";
3021 
3022  if (fCalib && !fCalib->IsZombie())
3023  {
3024  bool success = true;
3025  std::array<std::array<std::unique_ptr<TSpline>, 4>, 2> T0HGOffsetSplines;
3026  std::array<std::array<std::unique_ptr<TSpline>, 4>, 2> T0LGOffsetSplines;
3027  std::unique_ptr<TSpline3> spline;
3028  for (int iside = 0; iside < 2; iside++)
3029  {
3030  for (int imod = 0; imod < 4; imod++)
3031  {
3032  sprintf(name, "ZDC_T0calib_run%u_HG_s%d_m%d", runNumber, iside, imod);
3033  spline.reset (static_cast<TSpline3*>(fCalib->GetObjectChecked(calibVersion+TString(name), "TSpline3")));
3034  if (spline)
3035  {
3036  T0HGOffsetSplines[iside][imod] = std::move (spline);
3037  }
3038  else
3039  {
3040  ATH_MSG_WARNING("No time calib. spline " << calibVersion+name);
3041  success = false;
3042  }
3043 
3044  sprintf(name, "ZDC_T0calib_run%u_LG_s%d_m%d", runNumber, iside, imod);
3045  spline.reset (static_cast<TSpline3*>(fCalib->GetObjectChecked(calibVersion+TString(name), "TSpline3")));
3046  if (spline)
3047  {
3048  T0LGOffsetSplines[iside][imod] = std::move (spline);
3049  }
3050  else
3051  {
3052  ATH_MSG_WARNING("No time calib. spline " << calibVersion+name);
3053  success = false;
3054  }
3055  }
3056  }
3057 
3058  if (success)
3059  m_zdcDataAnalyzer->LoadT0Calibrations(T0HGOffsetSplines, T0LGOffsetSplines);
3060  else
3061  ATH_MSG_WARNING("Time calibration failed - no T0 offsets loaded " << calibVersion+name);
3062 
3063  fCalib->Close();
3064  }
3065  else
3066  {
3067  ATH_MSG_WARNING("No time calibration file " << filename);
3068  }
3069 }
3070 
3072 {
3073  std::string filename;
3074 
3075  if (m_LHCRun==3) {
3076  std::string runString;
3077 
3078  if (runNumber == 0) runString = "ZdcFADCCorr_" + m_configuration + "_default.root";
3079  else runString = ("ZdcFADCCorr_Run"+TString::Itoa(runNumber,10)+".root").Data();
3080 
3081  filename = PathResolverFindCalibFile("ZdcAnalysis/" + runString );
3082  }
3083  else {
3084  ATH_MSG_WARNING("setFADCCorrections: FADC corrections not implemented for Run 2");
3085  return;
3086  }
3087 
3088  if (filename.empty())
3089  {
3090  ATH_MSG_INFO("FADC correction requested but no calibration file found");
3091  m_doFADCCorr = false;
3092  return;
3093  }
3094 
3095  ATH_MSG_INFO("Opening FADC corrections file " << filename);
3096  std::unique_ptr<TFile> fFADCCorr(TFile::Open(filename.c_str(), "READ"));
3097 
3098  if (!fFADCCorr->IsOpen()) {
3099  ATH_MSG_INFO ("setFADCCorrections: failed to open file: " << filename);
3100  throw std::runtime_error ("ZdcAnalysisTool failed to open FADCCorrections file " + filename);
3101  }
3102 
3103  // Attempt to read histograms with corrections from file
3104  //
3105  bool readSuccess = true;
3106  std::array<std::array<std::unique_ptr<const TH1>, 4>, 2> histogramsHG;
3107  std::array<std::array<std::unique_ptr<const TH1>, 4>, 2> histogramsLG;
3108 
3109  for (size_t side : {0, 1}) {
3110  for (int module : {0, 1, 2, 3}) {
3111  std::string histNameHG = "ZDC_FADCCorr_s" + std::to_string(side) + "_m" + std::to_string(module)+"_HG";
3112  std::string histNameLG = "ZDC_FADCCorr_s" + std::to_string(side) + "_m" + std::to_string(module)+"_LG";
3113 
3114  ATH_MSG_DEBUG("setFADCCorrections: Searching for histograms HG and LG: " << histNameHG << ", " << histNameLG);
3115 
3116  TH1* histHG_ptr = static_cast<TH1*>(fFADCCorr->GetObjectChecked(histNameHG.c_str(), "TH1"));
3117  TH1* histLG_ptr = static_cast<TH1*>(fFADCCorr->GetObjectChecked(histNameLG.c_str(), "TH1"));
3118 
3119  if (!histHG_ptr || !histLG_ptr) {
3120  std::string errMsg = "setFADCCorrections: unable to read FADC correction histogram(s) ";
3121  if (!histHG_ptr) errMsg += histNameHG + " ";
3122  if (!histLG_ptr) errMsg += histNameLG;
3123 
3124  ATH_MSG_ERROR(errMsg);
3125  readSuccess = false;
3126  break;
3127  }
3128  else {
3129  //
3130  // Check for valid range (Lion uses -0.5 to 4095.5)
3131  //
3132 
3133  if ( std::abs(histHG_ptr->GetXaxis()->GetXmin()+0.5) > 1e-3 || std::abs(histHG_ptr->GetXaxis()->GetXmax() - 4095.5) > 1e-3) {
3134  ATH_MSG_ERROR("setFADCCorrections: invalid axis range for HG FADC corrections in histogram with name " << histNameHG);
3135  readSuccess = false;
3136  break;
3137  }
3138  if (std::abs(histLG_ptr->GetXaxis()->GetXmin()+0.5) > 1e-3 || std::abs(histLG_ptr->GetXaxis()->GetXmax() - 4095.5) > 1e-3) {
3139  ATH_MSG_ERROR("setFADCCorrections: invalid axis range for HG FADC corrections in histogram with name " << histNameLG);
3140  readSuccess = false;
3141  break;
3142  }
3143 
3144  histogramsHG[side][module].reset(histHG_ptr);
3145  histogramsLG[side][module].reset(histLG_ptr);
3146  }
3147  }
3148  }
3149 
3150  fFADCCorr->Close();
3151 
3152  if (readSuccess) {
3153  m_zdcDataAnalyzer->enableFADCCorrections(m_doFADCCorrPerSample, histogramsHG, histogramsLG);
3154  }
3155  else {
3156  ATH_MSG_ERROR("setFADCCorrections: due to at least one error, FADC corrections are not implemented");
3157  m_doFADCCorr = false;
3158  }
3159 
3160  return;
3161 }
3162 
3163 
3165 {
3166  if (!m_init)
3167  {
3168  ATH_MSG_WARNING("Tool not initialized!");
3169  return StatusCode::FAILURE;
3170  }
3171  m_eventReady = false;
3172  ATH_MSG_DEBUG ("Trying to retrieve " << m_zdcModuleContainerName);
3173 
3174  m_zdcModules = 0;
3176 
3177  m_zdcSums = 0;
3179 
3180  m_eventReady = true;
3181 
3183 
3184  return StatusCode::SUCCESS;
3185 }
3186 
3187 bool ZdcAnalysisTool::sigprocMaxFinder(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual)
3188 {
3189  size_t nsamp = adc.size();
3190  float presamp = adc.at(0);
3191  unsigned short max_adc = 0;
3192  int max_index = -1;
3193  for (size_t i = 0; i < nsamp; i++)
3194  {
3195  if (adc[i] > max_adc)
3196  {
3197  max_adc = adc[i];
3198  max_index = i;
3199  }
3200  }
3201  amp = max_adc - presamp;
3202  time = max_index * deltaT;
3203  qual = 1.;
3204 
3205  if (max_index == -1)
3206  {
3207  qual = 0.;
3208  return false;
3209  }
3210 
3211  return true;
3212 }
3213 
3214 bool ZdcAnalysisTool::sigprocSincInterp(const std::vector<unsigned short>& adc, float deltaT, float& amp, float& time, float& qual)
3215 {
3216  size_t nsamp = adc.size();
3217  float presamp = adc.at(0);
3218  m_tf1SincInterp->SetParameter(0, deltaT);
3219  for (size_t i = 0; i < nsamp; i++)
3220  {
3221  m_tf1SincInterp->SetParameter(i + 1, adc.at(i) - presamp);
3222  }
3223  amp = m_tf1SincInterp->GetMaximum();
3224  time = m_tf1SincInterp->GetMaximumX();
3225  qual = 1.;
3226  return true;
3227 }
3228 
3230 {
3231  if (!m_zdcDataAnalyzer) return 0;
3232  return m_zdcDataAnalyzer->GetModuleSum(side);
3233 }
3234 
3236 {
3237  if (!m_zdcDataAnalyzer) return 0;
3238  return m_zdcDataAnalyzer->GetCalibModuleSum(side);
3239 }
3240 
3242 {
3243  if (!m_zdcDataAnalyzer) return 0;
3244  return m_zdcDataAnalyzer->GetCalibModuleSumErr(side);
3245 }
3246 
3248 {
3249  if (!m_zdcDataAnalyzer) return 0;
3250  return m_zdcDataAnalyzer->GetNLcalibModuleSum(side);
3251 }
3252 
3254 {
3255  if (!m_zdcDataAnalyzer) return 0;
3256  return m_zdcDataAnalyzer->GetNLcalibModuleSumErr(side);
3257 }
3258 
3260 {
3261  if (!m_zdcDataAnalyzer) return 0;
3262  return m_zdcDataAnalyzer->GetModuleSum(side);
3263 }
3264 
3266 {
3267  if (!m_zdcDataAnalyzer) return 0;
3268  return m_zdcDataAnalyzer->GetModuleSumErr(side);
3269 }
3270 
3272 {
3273  if (!m_zdcDataAnalyzer) return 0;
3274  return m_zdcDataAnalyzer->GetAverageTime(side);
3275 }
3276 
3278 {
3279  if (!m_zdcDataAnalyzer) return 0;
3280  return m_zdcDataAnalyzer->SideFailed(side);
3281 }
3282 
3284 {
3285  if (!m_zdcDataAnalyzer) return 0;
3286  return m_zdcDataAnalyzer->GetModuleMask();
3287 }
3288 
3290 {
3291  if (!m_doTrigEff) return -1;
3292 
3293  m_zdcTriggerEfficiency->UpdatelumiBlock(m_lumiBlock);
3294  float adcSum = getModuleSum(side);
3295  double eff = m_zdcTriggerEfficiency->GetEfficiency(side, adcSum);
3296  return eff;
3297 }
3298 
3300 {
3301  if (!m_doCalib) return -1;
3302 
3303  m_zdcTriggerEfficiency->UpdatelumiBlock(m_lumiBlock);
3304  float adcSum = getModuleSum(side);
3305  std::pair<double, double> eff_pair = m_zdcTriggerEfficiency->GetEfficiencyAndError(msg(), side, adcSum);
3306  return eff_pair.second;
3307 }
3308 
3309 
3310 } // namespace ZDC
ZDC::ZdcAnalysisTool::m_zdcTriggerEffParamsFileName
std::string m_zdcTriggerEffParamsFileName
Definition: ZdcAnalysisTool.h:139
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:223
WriteHandle.h
Handle class for recording to StoreGate.
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ZDC::ZdcAnalysisTool::MakeMessageFunction
ZDCMsg::MessageFunctionPtr MakeMessageFunction()
Definition: ZdcAnalysisTool.h:80
ZDC::ZdcAnalysisTool::m_zdcModuleContainerName
std::string m_zdcModuleContainerName
Definition: ZdcAnalysisTool.h:155
ZDC::ZdcAnalysisTool::initializeInjectorpp2024
std::unique_ptr< ZDCDataAnalyzer > initializeInjectorpp2024()
Definition: ZdcAnalysisTool.cxx:1318
ZDCPulseAnalyzer::getRefitLGAmp
float getRefitLGAmp() const
Definition: ZDCPulseAnalyzer.h:601
ZDC::ZdcAnalysisTool::m_zdcSumNLCalibEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumNLCalibEnergy
Definition: ZdcAnalysisTool.h:240
ZDC::ZdcAnalysisTool::m_doFADCCorr
bool m_doFADCCorr
Definition: ZdcAnalysisTool.h:165
ZDC::ZdcAnalysisTool::m_peak2ndDerivMinSamples
ZDCDataAnalyzer::ZDCModuleIntArray m_peak2ndDerivMinSamples
Definition: ZdcAnalysisTool.h:196
ZDC::ZdcAnalysisTool::m_runNumber
unsigned int m_runNumber
Definition: ZdcAnalysisTool.h:145
ZDC::ZdcAnalysisTool::m_Peak2ndDerivThresh
float m_Peak2ndDerivThresh
Definition: ZdcAnalysisTool.h:178
ZDC::ZdcAnalysisTool::initializeInjectorpOOONeNe2025
std::unique_ptr< ZDCDataAnalyzer > initializeInjectorpOOONeNe2025()
Definition: ZdcAnalysisTool.cxx:1535
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:213
ZDC::ZdcAnalysisTool::m_zdcModules
const xAOD::ZdcModuleContainer * m_zdcModules
Definition: ZdcAnalysisTool.h:156
ZDC::ZdcAnalysisTool::reprocessZdc
StatusCode reprocessZdc() override
Definition: ZdcAnalysisTool.cxx:3164
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:208
ZDC::ZdcAnalysisTool::m_peak2ndDerivMinThresholdsLG
ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsLG
Definition: ZdcAnalysisTool.h:198
ZDCPulseAnalyzer::getMaxADCLG
float getMaxADCLG() const
Definition: ZDCPulseAnalyzer.h:639
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
ZDC::ZdcAnalysisTool::m_doTrigEff
bool m_doTrigEff
Definition: ZdcAnalysisTool.h:163
ZDC::ZdcAnalysisTool::m_ChisqRatioCut
float m_ChisqRatioCut
Definition: ZdcAnalysisTool.h:186
ZDC::ZdcAnalysisTool::m_LHCRun
int m_LHCRun
Definition: ZdcAnalysisTool.h:188
ZDCDataAnalyzer::ZDCModuleFloatArray
std::array< std::array< float, 4 >, 2 > ZDCModuleFloatArray
Definition: ZDCDataAnalyzer.h:22
ZDCPulseAnalyzer::GetAmpError
float GetAmpError() const
Definition: ZDCPulseAnalyzer.h:598
ZDC::ZdcAnalysisTool::m_fixTau1
bool m_fixTau1
Definition: ZdcAnalysisTool.h:183
ZDCPulseAnalyzer::getRefitLGTime
float getRefitLGTime() const
Definition: ZDCPulseAnalyzer.h:625
ZDC::ZdcAnalysisTool::m_zdcModuleFitAmp
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmp
Definition: ZdcAnalysisTool.h:215
ZDCPulseAnalyzer::GetAmpNoNonLin
float GetAmpNoNonLin() const
Definition: ZDCPulseAnalyzer.h:596
ZDC::ZdcAnalysisTool::getUncalibModuleSumErr
float getUncalibModuleSumErr(int side)
Definition: ZdcAnalysisTool.cxx:3265
asg
Definition: DataHandleTestTool.h:28
ZDC::ZdcAnalysisTool::m_doTimeCalib
bool m_doTimeCalib
Definition: ZdcAnalysisTool.h:164
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:214
ZDC::ZdcAnalysisTool::initializepO2025B
std::unique_ptr< ZDCDataAnalyzer > initializepO2025B()
Definition: ZdcAnalysisTool.cxx:1151
ZDC::ZdcAnalysisTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: ZdcAnalysisTool.cxx:2386
ZDC::ZdcAnalysisTool::initializepp2024
std::unique_ptr< ZDCDataAnalyzer > initializepp2024()
Definition: ZdcAnalysisTool.cxx:379
ZDC::ZdcAnalysisTool::m_zdcAnalysisConfigPath
std::string m_zdcAnalysisConfigPath
Definition: ZdcAnalysisTool.h:136
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:151
ZDC::ZdcAnalysisTool::m_presample
unsigned int m_presample
Definition: ZdcAnalysisTool.h:176
ZDC::ZdcAnalysisTool::m_zdcSumModuleMask
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumModuleMask
Definition: ZdcAnalysisTool.h:246
ZDCPulseAnalyzer
Definition: ZDCPulseAnalyzer.h:22
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:3289
ZDC::ZdcAnalysisTool::m_zdcModuleStatus
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleStatus
Definition: ZdcAnalysisTool.h:211
ZDC::ZdcAnalysisTool::m_zdcSumAverageTime
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumAverageTime
Definition: ZdcAnalysisTool.h:244
m_name
std::string m_name
Definition: ColumnarPhysliteTest.cxx:62
ZDCPulseAnalyzer::getRefitLGTimeSub
float getRefitLGTimeSub() const
Definition: ZDCPulseAnalyzer.h:631
ZDC::ZdcAnalysisTool::m_tf1SincInterp
std::unique_ptr< TF1 > m_tf1SincInterp
Definition: ZdcAnalysisTool.h:149
ZDC::ZdcAnalysisTool::m_tau1
float m_tau1
Definition: ZdcAnalysisTool.h:181
ZDC::ZdcAnalysisTool::m_lowGainMode
unsigned int m_lowGainMode
Definition: ZdcAnalysisTool.h:160
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:186
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:296
ZDC::ZdcAnalysisTool::setFADCCorrections
void setFADCCorrections(unsigned int runNumber=0)
Definition: ZdcAnalysisTool.cxx:3071
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:245
ZdcModuleAuxContainer.h
ZDC::ZdcAnalysisTool::m_zdcModuleAmplitude
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmplitude
Definition: ZdcAnalysisTool.h:207
ZDC::ZdcAnalysisTool::sideFailed
bool sideFailed(int side)
Definition: ZdcAnalysisTool.cxx:3277
ZDC::ZdcAnalysisTool::getModuleSum
float getModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:3229
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:242
python.PyAthena.module
module
Definition: PyAthena.py:131
ZDC::ZdcAnalysisTool::m_lumiBlock
unsigned int m_lumiBlock
Definition: ZdcAnalysisTool.h:146
ZDCPulseAnalyzer::TimingCorrLog
@ TimingCorrLog
Definition: ZDCPulseAnalyzer.h:57
ZDC::ZdcAnalysisTool::setEnergyCalibrations
void setEnergyCalibrations(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:2931
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:180
ZDC::ZdcAnalysisTool::m_doNonLinCorr
bool m_doNonLinCorr
Definition: ZdcAnalysisTool.h:166
ZDC::ZdcAnalysisTool::m_init
bool m_init
Definition: ZdcAnalysisTool.h:134
ZDCPulseAnalyzer::getPresample
float getPresample() const
Definition: ZDCPulseAnalyzer.h:637
ZDCPulseAnalyzer::getMaxADCHG
float getMaxADCHG() const
Definition: ZDCPulseAnalyzer.h:638
ZDC::ZdcAnalysisTool::getCalibModuleSumErr
float getCalibModuleSumErr(int side)
Definition: ZdcAnalysisTool.cxx:3241
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:236
ZDCDataAnalyzer::SetNoiseSigmas
void SetNoiseSigmas(const ZDCModuleFloatArray &noiseSigmasHG, const ZDCModuleFloatArray &noiseSigmasLG)
Definition: ZDCDataAnalyzer.cxx:248
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
ZDCPulseAnalyzer::getRefitLGFitAmp
float getRefitLGFitAmp() const
Definition: ZDCPulseAnalyzer.h:607
ZDCDataAnalyzer::SetNLcalibParams
void SetNLcalibParams(std::array< std::array< std::array< float, 6 >, 3 >, 2 > &nlcalibParams)
Definition: ZDCDataAnalyzer.cxx:335
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:1444
ZDC::ZdcAnalysisTool::m_combineDelay
bool m_combineDelay
Definition: ZdcAnalysisTool.h:161
ZDC::ZdcAnalysisTool::m_numSample
unsigned int m_numSample
Definition: ZdcAnalysisTool.h:174
ZDC::ZdcAnalysisTool::m_zdcSumNLCalibEnergyErr
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumNLCalibEnergyErr
Definition: ZdcAnalysisTool.h:241
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:1908
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
ZDC::ZdcAnalysisTool::m_forceCalibLB
int m_forceCalibLB
Definition: ZdcAnalysisTool.h:169
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::getNLCalibModuleSum
float getNLCalibModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:3247
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer_80MHz
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer_80MHz
Definition: ZdcAnalysisTool.h:194
ZDC::ZdcAnalysisTool::m_zdcModuleChisqLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleChisqLGRefit
Definition: ZdcAnalysisTool.h:233
ZDC::ZdcAnalysisTool::getNLCalibModuleSumErr
float getNLCalibModuleSumErr(int side)
Definition: ZdcAnalysisTool.cxx:3253
ZDCDataAnalyzer::SetADCOverUnderflowValues
void SetADCOverUnderflowValues(const ZDCModuleFloatArray &HGOverflowADC, const ZDCModuleFloatArray &HGUnderflowADC, const ZDCModuleFloatArray &LGOverflowADC)
Definition: ZDCDataAnalyzer.cxx:286
file
TFile * file
Definition: tile_monitor.h:29
ZDC::ZdcAnalysisTool::m_zdcModuleMaxADC
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADC
Definition: ZdcAnalysisTool.h:222
ZDCPulseAnalyzer::LGModeForceLG
@ LGModeForceLG
Definition: ZDCPulseAnalyzer.h:53
ZDC::ZdcAnalysisTool::m_zdcModuleFitT0
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitT0
Definition: ZdcAnalysisTool.h:217
ZDC::ZdcAnalysisTool::recoZdcModules
StatusCode recoZdcModules(const xAOD::ZdcModuleContainer &moduleContainer, const xAOD::ZdcModuleContainer &moduleSumContainer) override
Definition: ZdcAnalysisTool.cxx:2616
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ZDC::ZdcAnalysisTool::getModuleMask
unsigned int getModuleMask()
Definition: ZdcAnalysisTool.cxx:3283
ZDCPulseAnalyzer::getMaxADCSub
float getMaxADCSub() const
Definition: ZDCPulseAnalyzer.h:643
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:57
ZDCDataAnalyzer::SetFitMinMaxAmpValues
void SetFitMinMaxAmpValues(const ZDCModuleFloatArray &minAmpHG, const ZDCModuleFloatArray &minAmpLG, const ZDCModuleFloatArray &maxAmpHG, const ZDCModuleFloatArray &maxAmpLG)
Definition: ZDCDataAnalyzer.cxx:265
ZDC::ZdcAnalysisTool::m_zdcModuleT0SubLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleT0SubLGRefit
Definition: ZdcAnalysisTool.h:232
ZDC::ZdcAnalysisTool::m_zdcModuleMinDeriv2nd
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMinDeriv2nd
Definition: ZdcAnalysisTool.h:221
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:236
ZDC::ZdcAnalysisTool::m_zdcModuleBkgdMaxFraction
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleBkgdMaxFraction
Definition: ZdcAnalysisTool.h:218
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:157
ZDC::ZdcAnalysisTool::m_zdcDataAnalyzer
std::shared_ptr< ZDCDataAnalyzer > m_zdcDataAnalyzer
Definition: ZdcAnalysisTool.h:192
ZDC::ZdcAnalysisTool::setTimeCalibrations
void setTimeCalibrations(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:2996
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition: EventInfo_v1.h:338
ZDC::ZdcAnalysisTool::m_tau2
float m_tau2
Definition: ZdcAnalysisTool.h:182
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:239
ZDCDataAnalyzer::enableDelayed
void enableDelayed(float deltaT, const ZDCModuleFloatArray &undelayedDelayedPedestalDiff)
Definition: ZDCDataAnalyzer.cxx:113
ZDC::ZdcAnalysisTool::m_calibVersion
std::string m_calibVersion
Definition: ZdcAnalysisTool.h:170
ZDCDataAnalyzer::enablePostExclusion
void enablePostExclusion(unsigned int maxSamplesExcl, const ZDCModuleIntArray &HGADCThresh, const ZDCModuleIntArray &LGADCThresh)
Definition: ZDCDataAnalyzer.cxx:157
ZDC::ZdcAnalysisTool::m_zdcModuleT0LGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleT0LGRefit
Definition: ZdcAnalysisTool.h:231
ZDC::ZdcAnalysisTool::m_zdcModuleAmpLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpLGRefit
Definition: ZdcAnalysisTool.h:229
ZDC::ZdcAnalysisTool::m_writeAux
bool m_writeAux
Definition: ZdcAnalysisTool.h:141
ZDC::ZdcAnalysisTool::m_configuration
std::string m_configuration
Definition: ZdcAnalysisTool.h:135
PathResolver.h
ZDC::ZdcAnalysisTool::m_doFADCCorrPerSample
bool m_doFADCCorrPerSample
Definition: ZdcAnalysisTool.h:167
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
ZDC::ZdcAnalysisTool::m_forceCalibRun
int m_forceCalibRun
Definition: ZdcAnalysisTool.h:168
ZDC::ZdcAnalysisTool::m_deltaTCut
float m_deltaTCut
Definition: ZdcAnalysisTool.h:185
ZDCTriggerEfficiency
Definition: ZDCTriggerEfficiency.h:17
ReadHandle.h
Handle class for reading from StoreGate.
ZDC::ZdcAnalysisTool::m_zdcModuleCalibTime
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibTime
Definition: ZdcAnalysisTool.h:210
ZDC::ZdcAnalysisTool::m_zdcSums
const xAOD::ZdcModuleContainer * m_zdcSums
Definition: ZdcAnalysisTool.h:158
ZDC::ZdcAnalysisTool::getTriggerEfficiencyUncertainty
double getTriggerEfficiencyUncertainty(int side)
Definition: ZdcAnalysisTool.cxx:3299
ZDCDataAnalyzer::enablePreExclusion
void enablePreExclusion(unsigned int maxSamplesExcl, const ZDCModuleIntArray &HGADCThresh, const ZDCModuleIntArray &LGADCThresh)
Definition: ZDCDataAnalyzer.cxx:139
ZDCPulseAnalyzer::GetFitAmplitude
float GetFitAmplitude() const
Definition: ZDCPulseAnalyzer.h:581
ZDC::ZdcAnalysisTool::initializeLHCf2022
std::unique_ptr< ZDCDataAnalyzer > initializeLHCf2022()
Definition: ZdcAnalysisTool.cxx:201
ZDCPulseAnalyzer::getRefitLGChisq
float getRefitLGChisq() const
Definition: ZDCPulseAnalyzer.h:619
EventInfo.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:283
ZDCPulseAnalyzer::GetMinDeriv2nd
float GetMinDeriv2nd() const
Definition: ZDCPulseAnalyzer.h:670
ZDC::ZdcAnalysisTool::m_zdcTriggerEfficiency
std::shared_ptr< ZDCTriggerEfficiency > m_zdcTriggerEfficiency
Definition: ZdcAnalysisTool.h:201
ZDC::ZdcAnalysisTool::initializepO2025
std::unique_ptr< ZDCDataAnalyzer > initializepO2025()
Definition: ZdcAnalysisTool.cxx:984
ZDCPulseAnalyzer::GetFitT0
float GetFitT0() const
Definition: ZDCPulseAnalyzer.h:582
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:322
ZDC::ZdcAnalysisTool::m_zdcModuleFitAmpError
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmpError
Definition: ZdcAnalysisTool.h:216
ZDC::ZdcAnalysisTool::getAverageTime
float getAverageTime(int side)
Definition: ZdcAnalysisTool.cxx:3271
ZDC::ZdcAnalysisTool::m_zdcModulePresample
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModulePresample
Definition: ZdcAnalysisTool.h:220
ZDCPulseAnalyzer::GetBkgdMaxFraction
float GetBkgdMaxFraction() const
Definition: ZDCPulseAnalyzer.h:676
ZDCDataAnalyzer::disableModule
bool disableModule(size_t side, size_t module)
Definition: ZDCDataAnalyzer.cxx:96
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:212
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
ZDC::ZdcAnalysisTool::configureNewRun
StatusCode configureNewRun(unsigned int runNumber)
Definition: ZdcAnalysisTool.cxx:2596
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:3187
ZDC::ZdcAnalysisTool::m_peak2ndDerivMinThresholdsHG
ZDCDataAnalyzer::ZDCModuleFloatArray m_peak2ndDerivMinThresholdsHG
Definition: ZdcAnalysisTool.h:197
ZDC::ZdcAnalysisTool::initializeDefault
std::unique_ptr< ZDCDataAnalyzer > initializeDefault()
Definition: ZdcAnalysisTool.cxx:1782
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:193
ZDCPulseAnalyzer::getRefitLGAmpCorr
float getRefitLGAmpCorr() const
Definition: ZDCPulseAnalyzer.h:613
ZDCDataAnalyzer::SetFitTimeMax
void SetFitTimeMax(float tmax)
Definition: ZDCDataAnalyzer.cxx:222
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
ZDC::ZdcAnalysisTool::m_deltaTSample
float m_deltaTSample
Definition: ZdcAnalysisTool.h:175
ZDC::ZdcAnalysisTool::initializeDecorations
void initializeDecorations()
Definition: ZdcAnalysisTool.cxx:2591
ZDCPulseAnalyzer::LGModeRefitLG
@ LGModeRefitLG
Definition: ZDCPulseAnalyzer.h:54
ZDC::ZdcAnalysisTool::initializeMonteCarloPbPb2023
std::unique_ptr< ZDCDataAnalyzer > initializeMonteCarloPbPb2023()
Definition: ZdcAnalysisTool.cxx:1626
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:237
ZDC::ZdcAnalysisTool::m_zdcTimeCalibFileName
std::string m_zdcTimeCalibFileName
Definition: ZdcAnalysisTool.h:138
ZDC::ZdcAnalysisTool::m_peakSample
unsigned int m_peakSample
Definition: ZdcAnalysisTool.h:177
ZDC::ZdcAnalysisTool::m_zdcModuleFitAmpLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleFitAmpLGRefit
Definition: ZdcAnalysisTool.h:228
beamspotman.qual
qual
Definition: beamspotman.py:479
ZDC::ZdcAnalysisTool::getCalibModuleSum
float getCalibModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:3235
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
ZDC::ZdcAnalysisTool::initialize80MHz
void initialize80MHz()
Definition: ZdcAnalysisTool.cxx:2267
ZDCDataAnalyzer::enableRepass
void enableRepass(const ZDCModuleFloatArray &peak2ndDerivMinRepassHG, const ZDCModuleFloatArray &peak2ndDerivMinRepassLG)
Definition: ZDCDataAnalyzer.cxx:176
calibdata.copy
bool copy
Definition: calibdata.py:26
ZDC::ZdcAnalysisTool::initializePbPb2018
std::unique_ptr< ZDCDataAnalyzer > initializePbPb2018()
Definition: ZdcAnalysisTool.cxx:2020
ZDC::ZdcAnalysisTool::m_flipEMDelay
bool m_flipEMDelay
Definition: ZdcAnalysisTool.h:159
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:219
ZDCDataAnalyzer::SetPeak2ndDerivMinTolerances
void SetPeak2ndDerivMinTolerances(size_t tolerance)
Definition: ZDCDataAnalyzer.cxx:213
ZDCPulseAnalyzer::GetChisq
float GetChisq() const
Definition: ZDCPulseAnalyzer.h:586
ZDC::ZdcAnalysisTool::initializePbPb2015G4
std::unique_ptr< ZDCDataAnalyzer > initializePbPb2015G4()
Definition: ZdcAnalysisTool.cxx:1845
ZDC::ZdcAnalysisTool::m_zdcEnergyCalibFileName
std::string m_zdcEnergyCalibFileName
Definition: ZdcAnalysisTool.h:137
ZDC::ZdcAnalysisTool::m_t0
float m_t0
Definition: ZdcAnalysisTool.h:179
ZDC::ZdcAnalysisTool::m_zdcModuleAmpCorrLGRefit
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleAmpCorrLGRefit
Definition: ZdcAnalysisTool.h:230
ZDC::ZdcAnalysisTool::sigprocSincInterp
bool sigprocSincInterp(const std::vector< unsigned short > &adc, float deltaT, float &amp, float &time, float &qual)
Definition: ZdcAnalysisTool.cxx:3214
python.DataFormatRates.env
env
Definition: DataFormatRates.py:32
ZDC::ZdcAnalysisTool::ZdcAnalysisTool
ZdcAnalysisTool(const std::string &name)
Definition: ZdcAnalysisTool.cxx:24
ZDC::ZdcAnalysisTool::initializeOONeNe2025
std::unique_ptr< ZDCDataAnalyzer > initializeOONeNe2025()
Definition: ZdcAnalysisTool.cxx:804
ZDCDataAnalyzer::SetSaveFitFunc
void SetSaveFitFunc(bool save)
Definition: ZDCDataAnalyzer.cxx:231
ZDC::ZdcAnalysisTool::m_doCalib
bool m_doCalib
Definition: ZdcAnalysisTool.h:162
ZDCDataAnalyzer::SetGainFactorsHGLG
void SetGainFactorsHGLG(float gainFactorHG, float gainFactorLG)
Definition: ZDCDataAnalyzer.cxx:195
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:309
ZDC::ZdcAnalysisTool::m_auxSuffix
std::string m_auxSuffix
Definition: ZdcAnalysisTool.h:142
ZdcEventInfo.h
Define enumerations for event-level ZDC data.
ZDC::ZdcAnalysisTool::initialize40MHz
void initialize40MHz()
Definition: ZdcAnalysisTool.cxx:2147
ZDC::ZdcAnalysisTool::m_fixTau2
bool m_fixTau2
Definition: ZdcAnalysisTool.h:184
ZDC::ZdcAnalysisTool::m_zdcSumCalibEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumCalibEnergy
Definition: ZdcAnalysisTool.h:238
ZDC::ZdcAnalysisTool::m_name
std::string m_name
Definition: ZdcAnalysisTool.h:133
ZDC::ZdcAnalysisTool::m_eventReady
bool m_eventReady
Definition: ZdcAnalysisTool.h:144
ZDC::ZdcAnalysisTool::m_zdcModuleMaxADCLG
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleMaxADCLG
Definition: ZdcAnalysisTool.h:224
ZDCPulseAnalyzer::GetPreSampleAmp
float GetPreSampleAmp() const
Definition: ZDCPulseAnalyzer.h:675
ZDCDataAnalyzer::SetModuleAmpFractionLG
void SetModuleAmpFractionLG(const ZDCDataAnalyzer::ZDCModuleFloatArray &moduleAmpFractionLG)
Definition: ZDCDataAnalyzer.cxx:257
ZDC::ZdcAnalysisTool::getUncalibModuleSum
float getUncalibModuleSum(int side)
Definition: ZdcAnalysisTool.cxx:3259