ATLAS Offline Software
ZdcMonitorAlgorithm.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 '''@file ZdcMonitorAlgorithm.py
7 @author Y. Guo
8 @date 2023-08-01
9 @brief python configuration for ZDC monitoring under the Run III DQ framework
10  will be run in the ZDC calibration stream & physics MinBias stream
11  see https://acode-browser1.usatlas.bnl.gov/lxr/source/athenAControl/AthenaMonitoring/python/ExampleMonitorAlgorithm.py
12  for details of structure of monitoring-configuration files
13 @reference https://twiki.cern.ch/twiki/bin/view/Atlas/DQRun3FrameworkTutorial
14 '''
15 
16 import numpy as np
17 
18 module_FPGA_max_ADC = 4096
19 nominal_lg_gain_factor = 10
20 nominal_lg_max_ADC = module_FPGA_max_ADC * nominal_lg_gain_factor
21 
22 
23 
24 def create_log_bins(min_value, max_value, num_bins):
25  # Calculate the logarithmic bin edges
26  log_min = np.log10(min_value)
27  log_max = np.log10(max_value)
28  log_bin_edges = np.linspace(log_min, log_max, num_bins + 1)
29  bin_edges = [10 ** edge for edge in log_bin_edges]
30 
31  return bin_edges
32 
34 
35  # Define min, max, and step size for each range
36  min1, max1, step1 = 0.0005 - 0.000001, 0.0025 - 0.000001, 0.00005
37  min2, max2, step2 = 0.0025 - 0.000001, 0.01 - 0.000001, 0.00025
38  min3, max3, step3 = 0.01 - 0.000001, 0.3 - 0.000001, 0.0025
39  min4, max4, step4 = 0.3 - 0.000001, 0.675 - 0.000001, 0.0125
40  min5, max5, step5 = 0.675 - 0.000001, 2.500001, 0.025
41 
42  # Generate each range using the defined variables
43  range1 = np.arange(min1, max1, step1)
44  range2 = np.arange(min2, max2, step2)
45  range3 = np.arange(min3, max3, step3)
46  range4 = np.arange(min4, max4, step4)
47  range5 = np.arange(min5, max5, step5)
48 
49  # Concatenate the ranges into a single array
50  vinj_bins_array = np.concatenate((np.array([0.]), range1, range2, range3, range4, range5))
51 
52  return vinj_bins_array.tolist()
53 
55 
56  # Define min, max, and step size for each range
57  min1, max1, step1 = 0, 280, 4 # up to the tail of 10mV
58  min2, max2, step2 = 280, module_FPGA_max_ADC+1, 8
59 
60  # Generate each range using the defined variables
61  range1 = np.arange(min1, max1, step1)
62  range2 = np.arange(min2, max2, step2)
63 
64  # Concatenate the ranges into a single array
65  hg_amp_inj_bins_array = np.concatenate((range1, range2))
66 
67  return hg_amp_inj_bins_array.tolist()
68 
70 
71  # Define min, max, and step size for each range
72  min1, max1, step1 = 0, 28, 0.4 # up to the tail of 10mV
73  min2, max2, step2 = 28, 800, 0.8 # roughly correspond to 300mV - can fine tune with ntuple
74  min3, max3, step3 = 800, module_FPGA_max_ADC+1, 8
75 
76 
77  # Generate each range using the defined variables
78  range1 = np.arange(min1, max1, step1)
79  range2 = np.arange(min2, max2, step2)
80  range3 = np.arange(min3, max3, step3)
81 
82  # Concatenate the ranges into a single array
83  lg_amp_inj_bins_array = np.concatenate((range1, range2, range3))
84 
85  return lg_amp_inj_bins_array.tolist()
86 
87 def ZdcMonitoringConfig(inputFlags):
88 
89  from AthenaMonitoring import AthMonitorCfgHelper
90  helper = AthMonitorCfgHelper(inputFlags,'ZdcAthMonitorCfg')
91 
92  from AthenaConfiguration.ComponentFactory import CompFactory
93  zdcMonAlg = helper.addAlgorithm(CompFactory.ZdcMonitorAlgorithm,'ZdcMonAlg')
94 
95  from ZdcRec.ZdcRecConfig import SetConfigTag
96  config = SetConfigTag(inputFlags)
97  print ('ZdcMonitorAlgorithm.py: Running with config tag ', config)
98 
99  # Edit properties of a algorithm
100  zdcMonAlg.EnableZDCSingleSideTriggers = inputFlags.DQ.useTrigger and inputFlags.Input.TriggerStream == 'calibration_ZDCCalib' # added for online: enable trigger if we are running in ATLAS partition (DQ.useTrigger flag not set offline)
101  zdcMonAlg.CalInfoOn = inputFlags.Input.TriggerStream == 'physics_MinBias' or inputFlags.Input.TriggerStream == 'express_express' or inputFlags.Input.TriggerStream == 'physics_UCC' # turn calorimeter info on if input triggerstream (autoconfigured from input file) is physics_MinBias / express_express / physics_UCC
102  zdcMonAlg.EnableUCCTriggers = inputFlags.DQ.useTrigger and inputFlags.Input.TriggerStream == 'physics_UCC'
103  zdcMonAlg.IsOnline = inputFlags.Common.isOnline # if running online select a subset of histograms & use coarser binnings
104  zdcMonAlg.IsInjectedPulse = inputFlags.Input.TriggerStream == 'calibration_ZDCInjCalib' or inputFlags.Input.TriggerStream == 'calibration_DcmDummyProcessor'
105  zdcMonAlg.IsStandalone = inputFlags.Input.TriggerStream == 'calibration_DcmDummyProcessor'
106  zdcMonAlg.IsPPMode = 'pp' in config
107 
108  zdcMonAlg.RunNumber = inputFlags.Input.RunNumbers[0] if len(inputFlags.Input.RunNumbers) > 0 else 0
109  if (len(inputFlags.Input.RunNumbers) == 0):
110  print ('ZdcMonitorAlgorithm.py: WARNING the list in the input flag Input.RunNumbers is empty - run number not set! Likely to use default pulser setting')
111  elif (len(inputFlags.Input.RunNumbers) > 1):
112  print ('ZdcMonitorAlgorithm.py: WARNING the list in the input flag Input.RunNumbers has more than one element - retrieving pulser-setting configuration using the first run number! May cause misconfiguration for the other run numbers')
113 
114  zdcMonAlg.EnableZDC = inputFlags.Detector.EnableZDC_ZDC
115  zdcMonAlg.EnableZDCPhysics = zdcMonAlg.EnableZDC and not zdcMonAlg.IsInjectedPulse # no physical pulse (neutrons) for injector pulse
116  zdcMonAlg.EnableRPD = inputFlags.Detector.EnableZDC_RPD and not zdcMonAlg.IsInjectedPulse
117  zdcMonAlg.EnableRPDAmp = zdcMonAlg.EnableRPD
118  zdcMonAlg.EnableCentroid = zdcMonAlg.EnableRPD
119 
120  print ("ZdcMonitorAlgorithm.py: IsInjectedPulse? ",zdcMonAlg.IsInjectedPulse)
121  print ("ZdcMonitorAlgorithm.py: IsPPMode? ",zdcMonAlg.IsPPMode)
122 
123 # --------------------------------------------------------------------------------------------------
124  # Configure histograms
125 
126  # (potentially run-type dependent) range settings
127  lumi_block_max = 2000
128  n_lumi_block_bins_coarse = 400
129  bcid_max = 3564
130  n_energy_bins_default = 200
131  n_fpga_bins = 204
132  n_time_centroid_bins_default = 100
133  n_module_amp_coarse_bins = 100
134  n_module_amp_fine_bins = 200
135  n_mod_fraction_bins_default = 100
136 
137  n_HG_LG_amp_ratio_bins = 120
138  n_HG_LG_time_diff_bins = 50
139 
140  module_chisq_min = 0.1
141  module_chisq_max = 800000
142  module_chisq_nbins = 80
143  module_chisq_over_amp_min = 0.01
144  module_chisq_over_amp_max = 3000
145  module_chisq_over_amp_nbins = 80
146  module_chisq_over_amp_linear_max = 50
147  module_chisq_over_amp_linear_nbins = 200
148 
149 
150  # to ensure the logarithmic binning in C++ algorithm agrees with python
151  # so that the inverse-bin-width weight calculation is correct
152  zdcMonAlg.ZDCModuleChisqHistMinValue = module_chisq_min
153  zdcMonAlg.ZDCModuleChisqHistMaxvalue = module_chisq_max
154  zdcMonAlg.ZDCModuleChisqHistNumBins = module_chisq_nbins
155  zdcMonAlg.ZDCModuleChisqOverAmpHistMinValue = module_chisq_over_amp_min
156  zdcMonAlg.ZDCModuleChisqOverAmpHistMaxvalue = module_chisq_over_amp_max
157  zdcMonAlg.ZDCModuleChisqOverAmpHistNumBins = module_chisq_over_amp_nbins
158 
159  zdcMonAlg.EnergyCutForModuleFractMonitor = 402 if zdcMonAlg.IsPPMode else 13400
160  zdcMonAlg.triggerSideA = "L1_ZDC_PP_A" if zdcMonAlg.IsPPMode else "L1_ZDC_A"
161  zdcMonAlg.triggerSideC = "L1_ZDC_PP_C" if zdcMonAlg.IsPPMode else "L1_ZDC_C"
162 
163  amp_LG_refit_max_ADC = module_FPGA_max_ADC
164 
165  fCal_single_side_min = -0.2
166  fCal_single_side_max = 2.8
167  fCal_sum_min = -0.5
168  fCal_sum_max = 5.5
169  fCal_single_side_nbins = 240
170  fCal_sum_nbins = 240
171 
172  energy_sum_zoomin_nbins = 200
173  energy_sum_1n_nbins = 350
174  energy_sum_1n_xmin = 1000.
175  energy_sum_1n_xmax = 4500.
176 
177  if config == "LHCf2022":
178  print ("looking at 2022 lhcf data")
179  energy_sum_xmax = 3000
180  energy_sum_two_sides_xmax_TeV = 10.0
181  energy_sum_single_side_xmax_TeV = 5.0
182  energy_sum_zoomin_xmax = 3000
183  uncalib_amp_sum_zoomin_xmax = module_FPGA_max_ADC
184  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
185  x_centroid_min = -500 #small amplitude sum --> large range for x, y position
186  x_centroid_max = 500
187  y_centroid_min = -50
188  y_centroid_max = 750
189  zdc_amp_sum_xmax = 3000
190  rpd_channel_amp_min = - 200.
191  rpd_amp_sum_xmax = 3000
192  rpd_max_adc_sum_xmax = 3000
193  module_amp_xmax = 2000
194  rpd_sum_adc_max = 5000
195  module_calib_amp_xmax = 5000
196  module_amp_1Nmonitor_xmax = 2000 #about 5N / 4 * 2.7TeV
197  module_calib_amp_1Nmonitor_xmax = 5000 #about 5N / 4 * 2.7TeV
198 
199  elif config == "pp2023" or config == "pp2024" or config == "Injectorpp2024":
200  print ("looking at pp reference run")
201  energy_sum_xmax = 5000
202  energy_sum_two_sides_xmax_TeV = 10.0
203  energy_sum_single_side_xmax_TeV = 5.0
204  energy_sum_zoomin_xmax = 5000
205  uncalib_amp_sum_zoomin_xmax = module_FPGA_max_ADC
206  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
207  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
208  x_centroid_max = 20
209  y_centroid_min = -20
210  y_centroid_max = 120
211  zdc_amp_sum_xmax = 5000
212  rpd_channel_amp_min = - 200.
213  rpd_amp_sum_xmax = 5000
214  rpd_max_adc_sum_xmax = 5000
215  module_amp_xmax = module_FPGA_max_ADC
216  rpd_sum_adc_max = 5000.
217  module_calib_amp_xmax = 5000
218  module_amp_1Nmonitor_xmax = 2000 #about 5N / 4 * 2.7TeV
219  module_calib_amp_1Nmonitor_xmax = 5000 #about 5N / 4 * 2.7TeV
220 
221  elif config == "PbPb2023" or config == "PbPb2024" or config == "InjectorPbPb2024":
222  print ("looking at pbpb run")
223  energy_sum_xmax = 200000.0
224  energy_sum_two_sides_xmax_TeV = 400.0
225  energy_sum_single_side_xmax_TeV = 200.0
226  energy_sum_zoomin_xmax = 13000.0
227  uncalib_amp_sum_zoomin_xmax = 7200.0
228  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
229  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
230  x_centroid_max = 20
231  y_centroid_min = -20
232  y_centroid_max = 60
233  zdc_amp_sum_xmax = 163840.0
234  rpd_channel_amp_min = - 2000.
235  rpd_amp_sum_xmax = 245760.0 #not the full range but a reasonable value
236  rpd_max_adc_sum_xmax = 40960.0
237  module_amp_xmax = nominal_lg_max_ADC
238  rpd_sum_adc_max = 25000.
239  module_calib_amp_xmax = 100000.0 #about the full dynamic range: 160 N / 4 * 2.5TeV
240  module_amp_1Nmonitor_xmax = 1250.0 #about 5N / 4 * 2.7TeV
241  module_calib_amp_1Nmonitor_xmax = 3400.0 #about 5N / 4 * 2.7TeV
242 
243 
244  hg_lg_amp_ratio_min_nominal = 0.6
245  hg_lg_amp_ratio_min_tight = 0.9
246  hg_lg_amp_ratio_max_nominal = 1.4
247  hg_lg_amp_ratio_max_tight = 1.2
248 
249  # #bins for RPD channel amplitude, including negative values - determined by the ratio between the negative amplitude range & positive amplitude range
250  rpd_sub_amp_min = - module_amp_xmax / 4.
251  rpd_sub_amp_max = module_amp_xmax / 2.
252  n_rpd_amp_bins_full_range = int((abs(rpd_channel_amp_min) + rpd_sum_adc_max) / rpd_sum_adc_max * n_energy_bins_default)
253  n_rpd_sub_amp_bins = int((abs(rpd_sub_amp_min) + rpd_sub_amp_max) / rpd_sub_amp_max * n_energy_bins_default)
254 
255 # --------------------------------------------------------------------------------------------------
256 # ----------------------------------- General ZDC observables -----------------------------------
257 # --------- Event-level observables / decoding error monitoring / A-C side correlations ---------
258 # --------------------------------------------------------------------------------------------------
259 
260  genZdcMonTool = helper.addGroup(zdcMonAlg, 'genZdcMonTool', topPath = 'ZDC')
261 
262  nDecodingErrorBits = 3
263  nUCCTrigBits = 7
264 
265  genZdcMonTool.defineHistogram('decodingErrorBits',title=';;Events',
266  path='/EXPERT/Global/DecodingErrors',
267  opt='kVec',
268  xbins=nDecodingErrorBits,xmin=0.0,xmax=nDecodingErrorBits,
269  xlabels=['No Decoding Error', 'ZDC Decoding Error', 'RPD Decoding Error'])
270 
271  genZdcMonTool.defineHistogram('uccTrigBits',title=';;Events',
272  path='/EXPERT/Global/UCCTrigs',
273  opt='kVec',
274  xbins=nUCCTrigBits,xmin=0.0,xmax=nUCCTrigBits,
275  xlabels=['UCC Trig Enabled', 'Pass HELT50', 'Pass HELT35', 'Pass HELT25', 'Pass HELT20', 'Pass HELT15', 'UCC Trig Disabled'])
276 
277  if (zdcMonAlg.EnableCentroid):
278  genZdcMonTool.defineHistogram('rpdCosDeltaReactionPlaneAngle', title=';Cos (#Delta #phi_{AorC});Events',
279  path='/EXPERT/Global/ReactionPlane',
280  cutmask='bothHasCentroid', # only require both sides to have centroid
281  xbins=n_time_centroid_bins_default,xmin=-1,xmax=1)
282  if (not zdcMonAlg.IsOnline):
283  genZdcMonTool.defineHistogram('rpdCosDeltaReactionPlaneAngle;rpdCosDeltaReactionPlaneAngle_requireValid', title=';Cos (#Delta #phi_{AorC});Events',
284  path='/EXPERT/Global/ReactionPlane',
285  cutmask='bothReactionPlaneAngleValid', # require centroid calculation on both sides to be valid
286  xbins=n_time_centroid_bins_default,xmin=-1,xmax=1)
287 
288  if (zdcMonAlg.EnableZDCPhysics):
289  genZdcMonTool.defineHistogram('zdcEnergySumA, zdcEnergySumC', type='TH2F', title=';E_{ZDC,A} [GeV];E_{ZDC,C} [GeV]',
290  path='/EXPERT/Global/SideACCorr',
291  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
292  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_xmax)
293 
294  # FCal E_T vs ZDC E_T
295  # to be run on min bias stream
296  if (zdcMonAlg.CalInfoOn):
297  genZdcMonTool.defineHistogram('fcalEtA, fcalEtC', type='TH2F', title=';E_{FCal, A} [GeV];E_{FCal, C} [GeV]',
298  path='/EXPERT/Global/SideACCorr',
299  xbins=fCal_single_side_nbins,xmin=fCal_single_side_min,xmax=fCal_single_side_max,
300  ybins=fCal_single_side_nbins,ymin=fCal_single_side_min,ymax=fCal_single_side_max)
301 
302  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
303  path = '/EXPERT/Global/ZDCFcalCorr',
304  opt='kAlwaysCreate',
305  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
306  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
307 
308  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
309  path = '/EXPERT/Global/ZDCHEFcalCorr',
310  opt='kAlwaysCreate',
311  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
312  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
313 
314  if (zdcMonAlg.EnableUCCTriggers):
315  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT15', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
316  path = '/EXPERT/Global/ZDCFcalCorr',
317  cutmask = 'passUCCTrig_HELT15',
318  opt='kAlwaysCreate',
319  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
320  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
321  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT20', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
322  path = '/EXPERT/Global/ZDCFcalCorr',
323  cutmask = 'passUCCTrig_HELT20',
324  opt='kAlwaysCreate',
325  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
326  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
327  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT25', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
328  path = '/EXPERT/Global/ZDCFcalCorr',
329  cutmask = 'passUCCTrig_HELT25',
330  opt='kAlwaysCreate',
331  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
332  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
333  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT35', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
334  path = '/EXPERT/Global/ZDCFcalCorr',
335  cutmask = 'passUCCTrig_HELT35',
336  opt='kAlwaysCreate',
337  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
338  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
339  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT50', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
340  path = '/EXPERT/Global/ZDCFcalCorr',
341  cutmask = 'passUCCTrig_HELT50',
342  opt='kAlwaysCreate',
343  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
344  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
345 
346  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT15', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
347  path = '/EXPERT/Global/ZDCHEFcalCorr',
348  cutmask = 'passUCCTrig_HELT15',
349  opt='kAlwaysCreate',
350  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
351  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
352  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT20', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
353  path = '/EXPERT/Global/ZDCHEFcalCorr',
354  cutmask = 'passUCCTrig_HELT20',
355  opt='kAlwaysCreate',
356  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
357  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
358  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT25', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
359  path = '/EXPERT/Global/ZDCHEFcalCorr',
360  cutmask = 'passUCCTrig_HELT25',
361  opt='kAlwaysCreate',
362  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
363  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
364  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT35', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
365  path = '/EXPERT/Global/ZDCHEFcalCorr',
366  cutmask = 'passUCCTrig_HELT35',
367  opt='kAlwaysCreate',
368  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
369  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
370  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT50', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
371  path = '/EXPERT/Global/ZDCHEFcalCorr',
372  cutmask = 'passUCCTrig_HELT50',
373  opt='kAlwaysCreate',
374  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
375  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
376 
377 # --------------------------------------------------------------------------------------------------
378  sides = ["C","A"]
379  modules = ["0","1","2","3"]
380  channels = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"]
381 
382  nZdcStatusBits = 18
383  nRpdStatusBits = 15
384  nRpdCentroidStatusBits = 21
385 
386 # --------------------------------------------------------------------------------------------------
387 # ---------------------------------- Per-ZDC-arm/side observables ----------------------------------
388 # --------------------------------------------------------------------------------------------------
389 
390  if (zdcMonAlg.EnableZDCPhysics or zdcMonAlg.EnableRPDAmp or zdcMonAlg.EnableCentroid):
391 
392  zdcSideMonToolArr = helper.addArray([sides],zdcMonAlg,'ZdcSideMonitor', topPath = 'ZDC')
393 
394 
395  # ---------------------------- Calorimeter per-arm variables ----------------------------
396  # ---------------------------- Calorimeter energy/amplitude sum ----------------------------
397  if (zdcMonAlg.EnableZDCPhysics):
398  zdcSideMonToolArr.defineHistogram('zdcEnergySum',title='ZDC Side {0} Energy Sum;Side {0} Energy [GeV];Events',
399  path = '/EXPERT/ZDC/PerArm/Energy',
400  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax) # 2.5TeV * 80 neutrons
401 
402  # --------------------- calibrated energy sum in the 1-to-4n-range ---------------------
403  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_noTrigSelec',title='ZDC Side {0} Energy Sum (1-to-4n, no trigger selection);Side {0} Energy[GeV];Events',
404  path = '/SHIFT/ZDC/PerArm/Energy',
405  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
406 
407  if (zdcMonAlg.EnableZDCSingleSideTriggers):
408  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_wTrigSelec',title='ZDC Side {0} Energy Sum (1-to-4n, require opposite-side trigger);Side {0} Energy[GeV];Events',
409  path = '/SHIFT/ZDC/PerArm/Energy',
410  cutmask = 'passTrigOppSide',
411  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
412 
413  # --------------------- uncalibrated amplitude sum in the 1-to-4n-range ---------------------
414  zdcSideMonToolArr.defineHistogram('zdcUncalibSum;zdcUncalibSum_zoomin_noTrigSelec',title='ZDC Side {0} Uncalibrated Amplitude Sum (1-to-4n, no trigger selection);Side {0} Amp Sum [ADC];Events',
415  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
416  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=uncalib_amp_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
417 
418  if (zdcMonAlg.EnableZDCSingleSideTriggers):
419  zdcSideMonToolArr.defineHistogram('zdcUncalibSum;zdcUncalibSum_zoomin_wTrigSelec',title='ZDC Side {0} Uncalibrated Amplitude Sum (1-to-4n, require opposite-side trigger);Side {0} Amp Sum [ADC];Events',
420  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
421  cutmask = 'passTrigOppSide',
422  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=uncalib_amp_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
423 
424  # --------------------- uncalibrated amplitude sum in the full range ---------------------
425  zdcSideMonToolArr.defineHistogram('zdcUncalibSum',title='ZDC Side {0} Uncalibrated Sum;[ADC];Events',
426  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
427  xbins=n_energy_bins_default,xmin=0.0,xmax=zdc_amp_sum_xmax)
428 
429  # ---------------------------- Calorimeter energy/amplitude sum: LB dependence ----------------------------
430  if (not zdcMonAlg.IsOnline): # offline - use fine LB binnings
431  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_noTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
432  path = '/EXPERT/ZDC/PerArm/Energy',
433  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
434  ybins=energy_sum_zoomin_nbins,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
435  if (zdcMonAlg.EnableZDCSingleSideTriggers):
436  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_wTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
437  path = '/EXPERT/ZDC/PerArm/Energy',
438  cutmask = 'passTrigOppSide',
439  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
440  ybins=energy_sum_zoomin_nbins,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
441  else: # online - use coarse LB binnings
442  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_1n_noTrigSelec',title='ZDC Side {0} Energy Sum (1n range, no trigger selection);Side {0} Energy[GeV];Events',
443  path = '/SHIFT/ZDC/PerArm/Energy',
444  xbins=energy_sum_1n_nbins,xmin=energy_sum_1n_xmin,xmax=energy_sum_1n_xmax)
445 
446  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_1n_vs_lb_noTrig', type='TH2F', title=';lumi block;Side {0} Energy (1n range) [GeV]',
447  path = '/EXPERT/ZDC/PerArm/Energy',
448  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
449  ybins=energy_sum_1n_nbins,ymin=energy_sum_1n_xmin,ymax=energy_sum_1n_xmax)
450 
451  if (not zdcMonAlg.IsOnline): #only offline
452  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcUncalibSum;zdcUncalibSum_vs_lb_noTrig', type='TH2F', title=';lumi block;ZDC Side {0} Uncalibrated Sum [ADC]',
453  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
454  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
455  ybins=n_energy_bins_default,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
456  if (zdcMonAlg.EnableZDCSingleSideTriggers):
457  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcUncalibSum;zdcUncalibSum_vs_lb_wTrig', type='TH2F', title=';lumi block;ZDC Side {0} Uncalibrated Sum [ADC]',
458  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
459  cutmask = 'passTrigOppSide',
460  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
461  ybins=n_energy_bins_default,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
462 
463  # ---------------------------- Calorimeter energy/amplitude sum: BCID dependence ----------------------------
464  if (not zdcMonAlg.IsOnline): #only offline
465  zdcSideMonToolArr.defineHistogram('bcid, zdcEnergySum;zdcEnergySum_vs_bcid_noTrig', type='TH2F', title=';BCID;Side {0} Energy [GeV]',
466  path = '/EXPERT/ZDC/PerArm/Energy',
467  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
468  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
469  if (zdcMonAlg.EnableZDCSingleSideTriggers):
470  zdcSideMonToolArr.defineHistogram('bcid, zdcEnergySum;zdcEnergySum_vs_bcid_wTrig', type='TH2F', title=';BCID;Side {0} Energy [GeV]',
471  path = '/EXPERT/ZDC/PerArm/Energy',
472  cutmask = 'passTrigOppSide',
473  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
474  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
475 
476  if (zdcMonAlg.CalInfoOn):
477  zdcSideMonToolArr.defineHistogram('fCalEt, zdcEnergySumTeV;zdcEnergySum_vs_fCalEt_single_side', type='TH2F', title=';Side {0} FCal Energy [TeV];Side {0} ZDC Energy [TeV]',
478  path = '/EXPERT/ZDC/PerArm/ZDCFcalCorr',
479  opt='kAlwaysCreate',
480  xbins=fCal_single_side_nbins,xmin=fCal_single_side_min,xmax=fCal_single_side_max,
481  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_single_side_xmax_TeV)
482 
483 
484  # ---------------------------- Calorimeter average time & LB dependence ----------------------------
485 
486  zdcSideMonToolArr.defineHistogram('zdcAvgTime',title='ZDC Side Average Time;t[ns];Events',
487  path = '/EXPERT/ZDC/PerArm/AvgTime',
488  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
489 
490  if (not zdcMonAlg.IsOnline): #only offline
491  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcAvgTime;zdcAvgTime_vs_lb', type='TH2F', title=';ZDC Side Average Time versus Lumi block;lumi block;t[ns]',
492  path = '/EXPERT/ZDC/PerArm/AvgTime',
493  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
494  ybins=n_time_centroid_bins_default,ymin=-10.0,ymax=10.0)
495 
496  # ---------------------------- RPD (centroid-related) per-arm variables ----------------------------
497  # ---------------------------- centroid status ----------------------------
498  zdcSideMonToolArr.defineHistogram('centroidStatusBits',title=';;Events',
499  path='/EXPERT/RPD/PerArm/Centroid',
500  xbins=nRpdCentroidStatusBits,xmin=0.0,xmax=nRpdCentroidStatusBits,opt='kVec',
501  xlabels=['ValidBit', 'HasCentroidBit', 'ZDCInvalidBit', 'InsufficientZDCEnergyBit', 'ExcessiveZDCEnergyBit', 'EMInvalidBit', 'InsufficientEMEnergyBit', 'ExcessiveEMEnergyBit', 'RPDInvalidBit', 'PileupBit', 'ExcessivePileupBit', 'ZeroSumBit', 'ExcessiveSubtrUnderflowBit', 'Row0ValidBit', 'Row1ValidBit', 'Row2ValidBit', 'Row3ValidBit', 'Col0ValidBit', 'Col1ValidBit', 'Col2ValidBit', 'Col3ValidBit'])
502 
503  zdcSideMonToolArr.defineHistogram('centroidValidBitFloat;centroidValidBit_RequireMinZDCEnergy',title='Centroid valid bit;;Events',
504  path='/SHIFT/RPD/PerArm/Centroid',
505  cutmask='passMinZDCEnergyCutForCentroidValidEvaluation',
506  xbins=2,xmin=0,xmax=2,
507  xlabels=['Valid','Invalid'])
508 
509  # ---------------------------- x, y centroid & reaction plane angle requiring centroid ValidBit ----------------------------
510  zdcSideMonToolArr.defineHistogram('xCentroid',title=';Centroid x position [mm];Events',
511  path='/SHIFT/RPD/PerArm/Centroid',
512  cutmask='centroidValid',
513  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max)
514 
515  zdcSideMonToolArr.defineHistogram('yCentroid',title=';Centroid y position [mm];Events',
516  path='/SHIFT/RPD/PerArm/Centroid',
517  cutmask='centroidValid',
518  xbins=n_time_centroid_bins_default*2,xmin=y_centroid_min,xmax=y_centroid_max)
519 
520  zdcSideMonToolArr.defineHistogram('xCentroid, yCentroid',type='TH2F',title=';Centroid x position [mm];Centroid y position [mm]',
521  path='/EXPERT/RPD/PerArm/Centroid',
522  cutmask='centroidValid',
523  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max,
524  ybins=n_time_centroid_bins_default*2,ymin=y_centroid_min,ymax=y_centroid_max)
525 
526  zdcSideMonToolArr.defineHistogram('ReactionPlaneAngle',title=';Reaction Plane Angle;Events',
527  path='/EXPERT/RPD/PerArm/ReactionPlane',
528  cutmask='centroidValid',
529  xbins=64,xmin=-3.141593,xmax=3.141593)
530 
531  # ---------------------------- x, y centroid & reaction plane angle requiring only HasCentroidBit ----------------------------
532 
533  if (not zdcMonAlg.IsOnline): #only offline
534  zdcSideMonToolArr.defineHistogram('xCentroid, yCentroid;yCentroid_vs_xCentroid_requireOnlyHasCentroidBit',type='TH2F',title=';Centroid x position [mm];Centroid y position [mm]',
535  path='/EXPERT/RPD/PerArm/Centroid',
536  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max,
537  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
538  zdcSideMonToolArr.defineHistogram('ReactionPlaneAngle;ReactionPlaneAngle_requireOnlyHasCentroidBit',title=';Reaction Plane Angle;Events',
539  path='/EXPERT/RPD/PerArm/ReactionPlane',
540  xbins=64,xmin=-3.141593,xmax=3.141593)
541 
542 
543  # ---------------------------- Centroid LB dependence ----------------------------
544  if (not zdcMonAlg.IsOnline): #only offline
545  zdcSideMonToolArr.defineHistogram('lumiBlock, xCentroid;xCentroid_vs_lb_requireOnlyHasCentroidBit', type='TH2F', title=';lumi block;Centroid x position [mm]',
546  path='/EXPERT/RPD/PerArm/CentroidLBdep',
547  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
548  ybins=n_time_centroid_bins_default,ymin=x_centroid_min,ymax=x_centroid_max)
549  zdcSideMonToolArr.defineHistogram('lumiBlock, yCentroid;yCentroid_vs_lb_requireOnlyHasCentroidBit', type='TH2F', title=';lumi block;Centroid y position [mm]',
550  path='/EXPERT/RPD/PerArm/CentroidLBdep',
551  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
552  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
553 
554  zdcSideMonToolArr.defineHistogram('lumiBlock, xCentroid;xCentroid_vs_lb', type='TH2F', title=';lumi block;Centroid x position [mm]',
555  path='/EXPERT/RPD/PerArm/CentroidLBdep',
556  cutmask='centroidValid',
557  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
558  ybins=n_time_centroid_bins_default,ymin=x_centroid_min,ymax=x_centroid_max)
559  zdcSideMonToolArr.defineHistogram('lumiBlock, yCentroid;yCentroid_vs_lb', type='TH2F', title=';lumi block;Centroid y position [mm]',
560  path='/EXPERT/RPD/PerArm/CentroidLBdep',
561  cutmask='centroidValid',
562  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
563  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
564 
565  # ---------------------------- ZDC-RPD correlations ----------------------------
566  zdcSideMonToolArr.defineHistogram('zdcEnergySum, rpdMaxADCSum', type='TH2F', title=';E ZDC side [TeV];RPD Max ADC Sum (AorC) [ADC counts]',
567  path='/EXPERT/ZdcRpdPerSideCorr',
568  cutmask='RPDSideValid',
569  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
570  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_max_adc_sum_xmax) # try a value for now
571  zdcSideMonToolArr.defineHistogram('zdcEnergySum, rpdAmplitudeCalibSum', type='TH2F', title=';E ZDC side [GeV];RPD Calib Amp Sum (AorC) [ADC counts]',
572  path='/EXPERT/ZdcRpdPerSideCorr',
573  cutmask='RPDSideValid',
574  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
575  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_amp_sum_xmax) # try a value for now
576  zdcSideMonToolArr.defineHistogram('zdcEMModuleEnergy, rpdAmplitudeCalibSum', type='TH2F', title=';E EM module AorC [GeV];RPD Calib Amp Sum (AorC) [ADC counts]',
577  path='/EXPERT/ZdcRpdPerSideCorr',
578  cutmask='RPDSideValid',
579  xbins=n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax / 2., # divide by 2 to make a more zoomed-in plot (not full range)
580  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_amp_sum_xmax) # try a value for now
581 
582 # --------------------------------------------------------------------------------------------------
583 # ------------------------------------- ZDC-module observables -------------------------------------
584 # --------------------------------------------------------------------------------------------------
585 
586 
587  zdcModuleMonToolArr = helper.addArray([sides,modules],zdcMonAlg,'ZdcModuleMonitor', topPath = 'ZDC')
588 
589  # ---------------------------- ZDC-module status ----------------------------
590 
591  zdcModuleMonToolArr.defineHistogram('zdcStatusBits',title=';;Events',
592  path='/SHIFT/ZDC/ZdcModule/ModuleStatusBits',
593  xbins=nZdcStatusBits,xmin=0.0,xmax=nZdcStatusBits,opt='kVec',
594  xlabels=['PulseBit', 'LowGainBit', 'FailBit', 'HGOverflowBit', 'HGUnderflowBit', 'PSHGOverUnderflowBit', 'LGOverflowBit', 'LGUnderflowBit', 'PrePulseBit', 'PostPulseBit', 'FitFailedBit', 'BadChisqBit', 'BadT0Bit', 'ExcludeEarlyLGBit', 'ExcludeLateLGBit', 'preExpTailBit', 'FitMinAmpBit', 'RepassPulseBit'])
595 
596  # ---------------------------- ZDC-module amplitudes & amplitude fractions ----------------------------
597 
598  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp',title=';Module Amplitude [ADC Counts];Events',
599  path='/SHIFT/ZDC/ZdcModule/ModuleAmp',
600  xbins=n_fpga_bins * 2,xmin=0.0,xmax=module_amp_xmax)
601 
602  zdcModuleMonToolArr.defineHistogram('zdcModuleMaxADC',title=';Module Max ADC;Events',
603  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADC',
604  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax)
605 
606 
607  if (not zdcMonAlg.IsPPMode): # for PP mode data, LG never filled
608  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_HG',title=';Module Amplitude HG [ADC Counts];Events',
609  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
610  cutmask='zdcModuleHG',
611  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC)
612 
613  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_LG',title=';Module Amplitude LG [ADC Counts];Events',
614  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
615  cutmask='zdcModuleLG', # require to use LG
616  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax)
617 
618  if (zdcMonAlg.IsInjectedPulse):
619  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit',title=';LG-Refit Amplitude [ADC Counts];Events',
620  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
621  cutmask='zdcModuleHG',
622  xbins=n_fpga_bins,xmin=0.0,xmax=amp_LG_refit_max_ADC)
623 
624  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse): # only offline
625  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_halfrange',title=';Module Amplitude [ADC Counts];Events',
626  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
627  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax / 2.)
628 
629 
630  if (zdcMonAlg.IsInjectedPulse or not zdcMonAlg.IsOnline):
631  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_HG_profile',type='TProfile',title=';Module Max ADC HG [ADC];Avg Amp/Max ADC',
632  path='/EXPERT/ZDC/ZdcModule/ModuleAmpToMaxADCRatio',
633  cutmask='zdcModuleHG',
634  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC)
635 
636  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_HG',type='TH2F',title=';Module Max ADC HG [ADC];Avg Amp/Max ADC',
637  path='/EXPERT/ZDC/ZdcModule/ModuleAmpToMaxADCRatio',
638  cutmask='zdcModuleHG',
639  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC,
640  ybins=100,ymin=0.0,ymax=2.)
641 
642  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_LG_profile',type='TProfile',title=';Module Max ADC LG [ADC];Avg Amp/Max ADC',
643  path='/EXPERT/ZDC/ZdcModule/ModuleAmpToMaxADCRatio',
644  cutmask='zdcModuleLG',
645  xbins=n_fpga_bins,xmin=0.0,xmax=nominal_lg_max_ADC) #max ADC has no LG gain factor
646 
647  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_LG',type='TH2F',title=';Module Max ADC LG [ADC];Avg Amp/Max ADC',
648  path='/EXPERT/ZDC/ZdcModule/ModuleAmpToMaxADCRatio',
649  cutmask='zdcModuleLG',
650  xbins=n_fpga_bins,xmin=0.0,xmax=nominal_lg_max_ADC, #max ADC has no LG gain factor
651  ybins=100,ymin=0.0,ymax=2./nominal_lg_gain_factor)
652 
653  # ---------------------------- ZDC-module amplitude fractions & correlations with energy deposits ----------------------------
654 
655  if (zdcMonAlg.IsInjectedPulse): # no real energy deposit --> do not require minimum ZDC energy
656  zdcModuleMonToolArr.defineHistogram('zdcModuleFract',title=';Module Amplitude Fraction;Events',
657  path='/SHIFT/ZDC/ZdcModule/ModuleFraction',
658  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
659  else:
660  zdcModuleMonToolArr.defineHistogram('zdcModuleFract;zdcModuleFract_above_cut',title=';Module Amplitude Fraction;Events',
661  path='/SHIFT/ZDC/ZdcModule/ModuleFraction',
662  cutmask='zdcEnergyAboveModuleFractCut',
663  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
664  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_fullrange', type='TH2F', title=';ZDC Energy Sum Current Side [GeV];Module Amplitude Fraction',
665  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
666  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
667  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
668  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_profile', type='TProfile', title=';ZDC Energy Sum Current Side [GeV];Module Amplitude Fraction',
669  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
670  cutmask='zdcModuleFractionValid',
671  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax)
672  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_zoomedin', type='TH2F', title=';Amplitude Sum Current Side [ADC Counts];Module Amplitude Fraction',
673  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
674  xbins=n_energy_bins_default,xmin=0.0,xmax=10000,
675  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
676  if (not zdcMonAlg.IsOnline): # only offline
677  zdcModuleMonToolArr.defineHistogram('zdcModuleFract',title=';Module Amplitude Fraction;Events',
678  path='/EXPERT/ZDC/ZdcModule/ModuleFraction',
679  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
680  zdcModuleMonToolArr.defineHistogram('zdcModuleFract;zdcModuleFract_above20N',title=';Module Amplitude Fraction;Events',
681  path='/EXPERT/ZDC/ZdcModule/ModuleFraction',
682  cutmask='zdcAbove20NCurrentSide',
683  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
684 
685  if (not zdcMonAlg.IsInjectedPulse):
686  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibAmp',title=';Module Calibrated Amplitude [GeV];Events',
687  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmp',
688  xbins=2*n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax) # 2.5TeV * 40
689 
690  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
691  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibAmp;zdcModuleCalibAmp_halfrange',title=';Module Calibrated Amplitude [GeV];Events',
692  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmp',
693  xbins=2*n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax / 2.) # 2.5TeV * 40
694 
695  # ---------------------------- ZDC-module reco amplitude versus input voltage ----------------------------
696  if (zdcMonAlg.IsInjectedPulse):
697  # ---------------------------- HG response ----------------------------
698  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleFitAmp;zdcModuleAmpHG_vs_injectedPulseInputVoltage', type='TH2F', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
699  cutmask='zdcHGInjPulseValid',
700  path='/EXPERT/ZDC/ZdcModule/ModuleAmpHGVsInputVoltage',
701  xbins=create_vinj_bins(),
703 
704  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleFitAmp;zdcModuleAmpHG_vs_injectedPulseInputVoltage_profile', type='TProfile', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
705  cutmask='zdcHGInjPulseValid',
706  path='/EXPERT/ZDC/ZdcModule/ModuleAmpHGVsInputVoltage',
707  xbins=create_vinj_bins())
708 
709  # ---------------------------- HG response max ADC ----------------------------
710 
711  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleMaxADCHG', type='TH2F', title=';Pulse amp [V];Max ADC HG',
712  cutmask='zdcHGInjPulseValid',
713  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADCHGVsInputVoltage',
714  xbins=create_vinj_bins(),
716 
717  # ---------------------------- LG response ----------------------------
718  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleLGFitAmp;zdcModuleAmpLG_vs_injectedPulseInputVoltage', type='TH2F', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
719  cutmask='zdcLGInjPulseValid',
720  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLGVsInputVoltage',
721  xbins=create_vinj_bins(),
723 
724  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleLGFitAmp;zdcModuleAmpLG_vs_injectedPulseInputVoltage_profile', type='TProfile', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
725  cutmask='zdcLGInjPulseValid',
726  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLGVsInputVoltage',
727  xbins=create_vinj_bins())
728 
729  # ---------------------------- LG response max ADC ----------------------------
730 
731  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleMaxADCLG;zdcModuleMaxADCLG_vs_injectedPulseInputVoltage', type='TH2F', title=';Pulse amp [V];Max ADC LG',
732  cutmask='zdcLGInjPulseValid',
733  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADCLGVsInputVoltage',
734  xbins=create_vinj_bins(),
735  ybins=create_hg_fit_amp_inj_bins()) # maxADC has no LG gain factor multiplied
736 
737  # ---------------------------- ZDC-module times ----------------------------
738 
739  zdcModuleMonToolArr.defineHistogram('zdcModuleTime',title=';Module Time [ns];Events',
740  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
741  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
742 
743  if (not zdcMonAlg.IsPPMode): # for PP mode, LG never filled
744  zdcModuleMonToolArr.defineHistogram('zdcModuleTime;zdcModuleTime_LG',title=';Module Time [ns];Events',
745  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
746  cutmask='zdcModuleLG',
747  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
748 
749  zdcModuleMonToolArr.defineHistogram('zdcModuleTime;zdcModuleTime_HG',title=';Module Time [ns];Events',
750  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
751  cutmask='zdcModuleHG',
752  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
753 
754  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0',title=';Module FitT0 [ns];Events',
755  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
756  xbins=200,xmin=0.0,xmax=time_in_data_buffer)
757 
758  if (not zdcMonAlg.IsPPMode): # for PP mode, LG never filled
759  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0;zdcModuleFitT0_LG',title=';Module FitT0 LG [ns];Events',
760  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
761  cutmask='zdcModuleLG',
762  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
763 
764  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0;zdcModuleFitT0_HG',title=';Module FitT0 HG [ns];Events',
765  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
766  cutmask='zdcModuleHG',
767  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
768 
769 
770  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
771  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibTime',title=';Module Calibrated Time [ns];Events',
772  path='/EXPERT/ZDC/ZdcModule/ModuleCalibTime',
773  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
774 
775  # ---------------------------- ZDC-module pulse-fitting chi squares (pulse fitting goodness) ----------------------------
776 
777  zdcModuleMonToolArr.defineHistogram('zdcModuleChisq',title=';Module Chi-square;Events',
778  path='/EXPERT/ZDC/ZdcModule/ModuleChisq',
779  weight='zdcModuleChisqEventWeight',
780  xbins=create_log_bins(module_chisq_min, module_chisq_max, module_chisq_nbins))
781  zdcModuleMonToolArr.defineHistogram('zdcModuleChisqOverAmp',title=';Module Chi-square / Amplitude;Events',
782  path='/SHIFT/ZDC/ZdcModule/ModuleChisq',
783  weight='zdcModuleChisqOverAmpEventWeight',
784  xbins=create_log_bins(module_chisq_over_amp_min, module_chisq_over_amp_max, module_chisq_over_amp_nbins))
785  zdcModuleMonToolArr.defineHistogram('zdcModuleChisqOverAmp;zdcModuleChisqOverAmp_linear',title=';Module Chi-square / Amplitude;Events',
786  path='/SHIFT/ZDC/ZdcModule/ModuleChisq',
787  xbins=module_chisq_over_amp_linear_nbins,xmin=0.,xmax=module_chisq_over_amp_linear_max)
788 
789  if (not zdcMonAlg.IsOnline):
790  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleChisqOverAmp',type='TH2F',title=';Module Amplitude [ADC Counts];Module Chi-square / Amplitude',
791  path='/EXPERT/ZDC/ZdcModule/ModuleChisq',
792  weight='zdcModuleChisqOverAmpEventWeight',
793  xbins=n_energy_bins_default,xmin=0.0,xmax=module_amp_xmax / 2.,
794  ybins=create_log_bins(module_chisq_over_amp_min, module_chisq_over_amp_max, module_chisq_over_amp_nbins))
795 
796 
797  # ---------------------------- LG & HG comparisons ----------------------------
798  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGAmpRatio',title=';HG-to-LG Amplitude Raio;Events',
799  path='/SHIFT/ZDC/ZdcModule/ModuleHGLGCompr',
800  cutmask='zdcModuleHG',
801  xbins=n_HG_LG_amp_ratio_bins,xmin=hg_lg_amp_ratio_min_nominal,xmax=hg_lg_amp_ratio_max_nominal)
802 
803  if (not zdcMonAlg.IsInjectedPulse):
804  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGAmpRatioNoNonlinCorr',title=';HG-to-LG Amplitude Raio;Events',
805  path='/SHIFT/ZDC/ZdcModule/ModuleHGLGComprNoNonlinCorr',
806  cutmask='zdcModuleHG',
807  xbins=n_HG_LG_amp_ratio_bins,xmin=hg_lg_amp_ratio_min_nominal,xmax=hg_lg_amp_ratio_max_nominal)
808 
809  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';ZDC HG Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
810  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
811  cutmask='zdcModuleHG',
812  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC,
813  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
814 
815  if (not zdcMonAlg.IsInjectedPulse):
816  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatioNoNonlinCorr', type='TH2F', title=';ZDC HG Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
817  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGComprNoNonlinCorr',
818  cutmask='zdcModuleHG',
819  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC,
820  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
821 
822  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatio;zdcModuleHGtoLGAmpRatio_vs_zdcModuleAmp_profile', type='TProfile', title=';ZDC HG Amplitude [ADC Counts];Average HG-to-LG Amplitude Raio;Events',
823  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
824  cutmask='zdcModuleHG',
825  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC)
826 
827  if (not zdcMonAlg.IsOnline):
828  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';ZDC LG-Refit Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
829  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
830  cutmask='zdcModuleHG',
831  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=amp_LG_refit_max_ADC,
832  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
833  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit, zdcModuleHGtoLGAmpRatio;zdcModuleHGtoLGAmpRatio_vs_zdcModuleAmpLGRefit_profile', type='TProfile', title=';ZDC LG-Refit Amplitude [ADC Counts];Average HG-to-LG Amplitude Raio;Events',
834  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
835  cutmask='zdcModuleHG',
836  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=amp_LG_refit_max_ADC)
837 
838  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGT0Diff',title=';HG-LG T0 Difference [ns];Events',
839  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
840  cutmask='zdcModuleHG',
841  xbins=n_HG_LG_time_diff_bins,xmin=-10.0,xmax=10.0)
842 
843  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGT0Diff, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';HG-LG T0 Difference [ns];HG-to-LG Amplitude Raio;Events',
844  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
845  cutmask='zdcModuleHG',
846  xbins=n_HG_LG_time_diff_bins,xmin=2.0,xmax=4.0, # zoomed in to see potential correlations
847  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_tight,ymax=hg_lg_amp_ratio_max_tight)
848 
849 
850  # ---------------------------- LB and BCID-dep ZDC-module-level observables ----------------------------
851  # ---------------------------- ZDC-module amplitudes ----------------------------
852 
853  if (not zdcMonAlg.IsInjectedPulse):
854  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleCalibAmp;zdcModuleCalibAmp_vs_lb', type='TH2F', title=';lumi block;Module Calib Amplitude',
855  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmpLBdep',
856  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
857  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_calib_amp_1Nmonitor_xmax)
858  if (not zdcMonAlg.IsOnline):
859  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleAmp;zdcModuleAmp_vs_lb', type='TH2F', title=';lumi block;Module Amplitude [ADC counts]',
860  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLBdep',
861  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
862  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_amp_1Nmonitor_xmax)
863  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleFract;zdcModuleFract_above20N_vs_lb', type='TH2F',title=';lumi block;Module Amplitude Fraction',
864  path='/EXPERT/ZDC/ZdcModule/ModuleFractionLBdep',
865  cutmask='zdcAbove20NCurrentSide',
866  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
867  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
868 
869  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
870  zdcModuleMonToolArr.defineHistogram('bcid, zdcModuleCalibAmp', type='TH2F', title=';BCID;Module Calib Amplitude',
871  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmpBCIDdep',
872  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
873  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_calib_amp_1Nmonitor_xmax)
874 
875  # ---------------------------- ZDC-module times ----------------------------
876 
877  if (not zdcMonAlg.IsOnline): #offline - fine binnings
878  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
879  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
880  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
881  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
882  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
883  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
884  cutmask='zdcModuleLG',
885  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
886  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
887  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
888  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
889  cutmask='zdcModuleHG',
890  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
891  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
892  else: #online - coarse binnings
893  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
894  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
895  cutmask='zdcModuleLG',
896  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
897  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
898  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
899  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
900  cutmask='zdcModuleHG',
901  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
902  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
903 
904  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb_profile', type='TProfile', title=';lumi block;Module Time [ns]',
905  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
906  cutmask='zdcModuleLGTimeValid',
907  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max)
908  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb_profile', type='TProfile', title=';lumi block;Module Time [ns]',
909  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
910  cutmask='zdcModuleHGTimeValid',
911  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max)
912 
913 # --------------------------------------------------------------------------------------------------
914 # ------------------------------------ RPD-channel observables -------------------------------------
915 # --------------------------------------------------------------------------------------------------
916 
917  if (zdcMonAlg.EnableRPDAmp):
918 
919  rpdChannelMonToolArr = helper.addArray([sides,channels],zdcMonAlg,'RpdChannelMonitor', topPath = 'ZDC')
920 
921  # ---------------------------- amplitudes ----------------------------
922  rpdChannelMonToolArr.defineHistogram('RPDChannelAmplitudeCalib', title=';RPD Channel Calibrated Amplitude;Events',
923  path='/SHIFT/RPD/RPDChannel/CalibAmp',
924  cutmask='RPDChannelValid',
925  xbins=n_rpd_amp_bins_full_range,xmin=rpd_channel_amp_min,xmax=rpd_sum_adc_max) # NOT energy calibration - calibration factor is 1 for now
926  rpdChannelMonToolArr.defineHistogram('RPDChannelMaxADC', title=';Max ADC [ADC Counts];Events',
927  path='/EXPERT/RPD/RPDChannel/MaxADC',
928  cutmask='RPDChannelValid',
929  xbins=n_energy_bins_default,xmin=0.0,xmax=module_FPGA_max_ADC)
930 
931  if (not zdcMonAlg.IsOnline):
932  rpdChannelMonToolArr.defineHistogram('RPDChannelSubAmp', title=';RPD Channel Subtracted Amplitude;Events',
933  path='/EXPERT/RPD/RPDChannel/SubAmp',
934  cutmask='RPDChannelCentroidValid',
935  xbins=n_rpd_sub_amp_bins,xmin=rpd_sub_amp_min,xmax=rpd_sub_amp_max) # NOT energy calibration - calibration factor is 1 for now
936 
937  # max ADC versus sum ADC
938  if (not zdcMonAlg.IsOnline):
939  rpdChannelMonToolArr.defineHistogram('RPDChannelAmplitudeCalib,RPDChannelMaxADC', type='TH2F', title=';Sum ADC [ADC Counts];Max ADC [ADC Counts]',
940  path='/EXPERT/RPD/RPDChannel/MaxADCVsSumADC',
941  cutmask='RPDChannelValid',
942  xbins=n_rpd_amp_bins_full_range,xmin=rpd_channel_amp_min,xmax=rpd_sum_adc_max, #change to xmax=20000 for zoomed in
943  ybins=n_energy_bins_default,ymin=0.0,ymax=module_FPGA_max_ADC) # change to ymax=3000.0 for zoomed in
944  # ---------------------------- timing (max sample) ----------------------------
945  rpdChannelMonToolArr.defineHistogram('RPDChannelMaxSample', title=';Max Sample;Events',
946  path='/EXPERT/RPD/RPDChannel/MaxSample',
947  cutmask='RPDChannelValid',
948  xbins=24,xmin=0.0,xmax=24.)
949 
950 
951  # ---------------------------- status bits ----------------------------
952  rpdChannelMonToolArr.defineHistogram('RPDStatusBits',title=';;Events',
953  path='/EXPERT/RPD/RPDChannel/StatusBits',
954  xbins=nRpdStatusBits,xmin=0,xmax=nRpdStatusBits,opt='kVec',
955  xlabels=['ValidBit', 'OutOfTimePileupBit', 'OverflowBit', 'PrePulseBit', 'PostPulseBit', 'NoPulseBit', 'BadAvgBaselineSubtrBit', 'InsufficientPileupFitPointsBit', 'PileupStretchedExpFitFailBit', 'PileupStretchedExpGrowthBit', 'PileupBadStretchedExpSubtrBit', 'PileupExpFitFailBit', 'PileupExpGrowthBit', 'PileupBadExpSubtrBit', 'PileupStretchedExpPulseLike'])
956 
957  rpdChannelMonToolArr.defineHistogram('RPDChannelValidBitFloat;RPDChannelValidBit',title='RPD Channel valid bit;;Events',
958  path='/SHIFT/RPD/RPDChannel/StatusBits',
959  xbins=2,xmin=0,xmax=2,
960  xlabels=['Valid','Invalid'])
961 
962  # ---------------------------- LB dependence ----------------------------
963  if (not zdcMonAlg.IsOnline): #offline
964  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelAmplitudeCalib;RPDChannelAmplitudeCalib_vs_lb', type='TH2F', title=';lumi block;RPD Channel Calibrated Amplitude',
965  path='/EXPERT/RPD/RPDChannel/CalibAmpLBdep',
966  cutmask='RPDChannelValid',
967  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
968  ybins=n_rpd_amp_bins_full_range,ymin=rpd_channel_amp_min,ymax=rpd_sum_adc_max) # NOT energy calibration - calibration factor is 1 for now
969  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelMaxADC;RPDChannelMaxADC_vs_lb', type='TH2F', title=';lumi block;Max ADC [ADC Counts]',
970  path='/EXPERT/RPD/RPDChannel/MaxADCLBdep',
971  cutmask='RPDChannelValid',
972  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
973  ybins=n_energy_bins_default,ymin=0.0,ymax=module_FPGA_max_ADC)
974  else: #online
975  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelAmplitudeCalib;RPDChannelAmplitudeCalib_vs_lb', type='TH2F', title=';lumi block;RPD Channel Calibrated Amplitude',
976  path='/EXPERT/RPD/RPDChannel/CalibAmpLBdep',
977  cutmask='RPDChannelValid',
978  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
979  ybins=n_rpd_amp_bins_full_range,ymin=rpd_channel_amp_min,ymax=rpd_sum_adc_max) # NOT energy calibration - calibration factor is 1 for now
980  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelMaxADC;RPDChannelMaxADC_vs_lb', type='TH2F', title=';lumi block;Max ADC [ADC Counts]',
981  path='/EXPERT/RPD/RPDChannel/MaxADCLBdep',
982  cutmask='RPDChannelValid',
983  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
984  ybins=n_energy_bins_default,ymin=0.0,ymax=module_FPGA_max_ADC)
985 
986 
987 
992  return helper.result()
993 
994  # # Otherwise, merge with result object and return
995  # acc = helper.result()
996  # result.merge(acc)
997  # return result
998 
999 if __name__=='__main__':
1000  # Setup logs
1001  from AthenaCommon.Logging import log
1002  from AthenaCommon.Constants import WARNING
1003  log.setLevel(WARNING)
1004 
1005  # Set the Athena configuration flags
1006  from AthenaConfiguration.AllConfigFlags import initConfigFlags
1008  directory = ''
1009  inputfile = 'AOD.pool.root'
1010  flags.Input.Files = [directory+inputfile]
1011  # flags.Input.isMC = False
1012  parser = flags.getArgumentParser()
1013  parser.add_argument('--datasetTag',default="HI2023",help="dataset tag")
1014  parser.add_argument('--runNumber',default=None,help="specify to select a run number")
1015  parser.add_argument('--streamTag',default="ZDCCalib",help="ZDCCalib or MinBias")
1016  parser.add_argument('--outputHISTFile',default=None,help="specify output HIST file name")
1017  args = flags.fillFromArgs(parser=parser)
1018 
1019  flags.DQ.useTrigger = False if flags.Input.isMC else True # isMC is autoconfigured from the input file; if MC: turn trigger off
1020  if args.runNumber is not None: # streamTag has default but runNumber doesn't
1021  flags.Output.HISTFileName = f'ZdcMonitorOutput_{args.datasetTag}_{args.streamTag}_{args.runNumber}.root'
1022  else:
1023  flags.Output.HISTFileName = f'ZdcMonitorOutput_{args.datasetTag}_{args.streamTag}.root'
1024 
1025  if args.outputHISTFile is not None: # overwrite the output HIST file name to be match the name set in the grid job
1026  flags.Output.HISTFileName = f'{args.outputHISTFile}'
1027  flags.lock()
1028 
1029  print('Output', flags.Output.HISTFileName)
1030  # Initialize configuration object, add accumulator, merge, and run.
1031  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
1032  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
1033  cfg = MainServicesCfg(flags)
1034  cfg.merge(PoolReadCfg(flags))
1035 
1036  zdcMonitorAcc = ZdcMonitoringConfig(flags)
1037  cfg.merge(zdcMonitorAcc)
1038 
1039  # If you want to turn on more detailed messages ...
1040  # zdcMonitorAcc.getEventAlgo('ZdcMonAlg').OutputLevel = 2 # DEBUG
1041  # If you want fewer messages ...
1042  # zdcMonitorAcc.getEventAlgo('ZdcMonAlg').OutputLevel = 4 # WARNING
1043  cfg.printConfig(withDetails=False) # set True for exhaustive info
1044 
1045  cfg.run() #use cfg.run(20) to only run on first 20 events
ZdcMonitorAlgorithm.create_hg_fit_amp_inj_bins
def create_hg_fit_amp_inj_bins()
Definition: ZdcMonitorAlgorithm.py:54
ZdcMonitorAlgorithm.create_log_bins
def create_log_bins(min_value, max_value, num_bins)
Definition: ZdcMonitorAlgorithm.py:24
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ZdcMonitorAlgorithm.create_vinj_bins
def create_vinj_bins()
Definition: ZdcMonitorAlgorithm.py:33
ZdcMonitorAlgorithm.create_lg_fit_amp_inj_bins
def create_lg_fit_amp_inj_bins()
Definition: ZdcMonitorAlgorithm.py:69
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
ZdcMonitorAlgorithm.ZdcMonitoringConfig
def ZdcMonitoringConfig(inputFlags)
Definition: ZdcMonitorAlgorithm.py:87
python.ZdcRecConfig.SetConfigTag
def SetConfigTag(flags)
Definition: ZdcRecConfig.py:54
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69