ATLAS Offline Software
ZdcMonitorAlgorithm.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2025 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 
20 def create_log_bins(min_value, max_value, num_bins):
21  # Calculate the logarithmic bin edges
22  log_min = np.log10(min_value)
23  log_max = np.log10(max_value)
24  log_bin_edges = np.linspace(log_min, log_max, num_bins + 1)
25  bin_edges = [10 ** edge for edge in log_bin_edges]
26 
27  return bin_edges
28 
30 
31  # Define min, max, and step size for each range
32  min1, max1, step1 = 0.0005 - 0.000001, 0.0025 - 0.000001, 0.00005
33  min2, max2, step2 = 0.0025 - 0.000001, 0.01 - 0.000001, 0.00025
34  min3, max3, step3 = 0.01 - 0.000001, 0.3 - 0.000001, 0.0025
35  min4, max4, step4 = 0.3 - 0.000001, 0.675 - 0.000001, 0.0125
36  min5, max5, step5 = 0.675 - 0.000001, 2.500001, 0.025
37 
38  # Generate each range using the defined variables
39  range1 = np.arange(min1, max1, step1)
40  range2 = np.arange(min2, max2, step2)
41  range3 = np.arange(min3, max3, step3)
42  range4 = np.arange(min4, max4, step4)
43  range5 = np.arange(min5, max5, step5)
44 
45  # Concatenate the ranges into a single array
46  vinj_bins_array = np.concatenate((np.array([0.]), range1, range2, range3, range4, range5))
47 
48  return vinj_bins_array.tolist()
49 
51 
52  # Define min, max, and step size for each range
53  min1, max1, step1 = 0, 280, 4 # up to the tail of 10mV
54  min2, max2, step2 = 280, module_FPGA_max_ADC+1, 8
55 
56  # Generate each range using the defined variables
57  range1 = np.arange(min1, max1, step1)
58  range2 = np.arange(min2, max2, step2)
59 
60  # Concatenate the ranges into a single array
61  hg_amp_inj_bins_array = np.concatenate((range1, range2))
62 
63  return hg_amp_inj_bins_array.tolist()
64 
66 
67  # Define min, max, and step size for each range
68  min1, max1, step1 = 0, 28, 0.4 # up to the tail of 10mV
69  min2, max2, step2 = 28, 800, 0.8 # roughly correspond to 300mV - can fine tune with ntuple
70  min3, max3, step3 = 800, module_FPGA_max_ADC+1, 8
71 
72 
73  # Generate each range using the defined variables
74  range1 = np.arange(min1, max1, step1)
75  range2 = np.arange(min2, max2, step2)
76  range3 = np.arange(min3, max3, step3)
77 
78  # Concatenate the ranges into a single array
79  lg_amp_inj_bins_array = np.concatenate((range1, range2, range3))
80 
81  return lg_amp_inj_bins_array.tolist()
82 
83 def ZdcMonitoringConfig(inputFlags):
84 
85  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
86  result = ComponentAccumulator()
87 
88  from AthenaMonitoring import AthMonitorCfgHelper
89  helper = AthMonitorCfgHelper(inputFlags,'ZdcAthMonitorCfg')
90 
91  from AthenaConfiguration.ComponentFactory import CompFactory
92  zdcMonAlg = helper.addAlgorithm(CompFactory.ZdcMonitorAlgorithm,'ZdcMonAlg')
93 
94  from ZdcRec.ZdcRecConfig import SetConfigTag
95  config = SetConfigTag(inputFlags)
96  print ('ZdcMonitorAlgorithm.py: Running with config tag ', config)
97 
98  # Edit properties of a algorithm
99  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)
100  zdcMonAlg.CalInfoOn = 'physics_' in inputFlags.Input.TriggerStream or inputFlags.Input.TriggerStream == 'express_express' # turn calorimeter info on if input triggerstream (autoconfigured from input file) is physics_MinBias / express_express / physics_UCC
101  zdcMonAlg.EnableUCCTriggers = inputFlags.DQ.useTrigger and inputFlags.Input.TriggerStream == 'physics_UCC'
102  zdcMonAlg.IsOnline = inputFlags.Common.isOnline # if running online select a subset of histograms & use coarser binnings
103  zdcMonAlg.IsInjectedPulse = inputFlags.Input.TriggerStream == 'calibration_ZDCInjCalib' or inputFlags.Input.TriggerStream == 'calibration_DcmDummyProcessor'
104  zdcMonAlg.IsStandalone = inputFlags.Input.TriggerStream == 'calibration_DcmDummyProcessor'
105  zdcMonAlg.IsCommRun = 'comm' in inputFlags.Input.ProjectName
106 
107  if zdcMonAlg.IsInjectedPulse and not zdcMonAlg.IsCommRun:
108  from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
109  zdcMonAlg.FilterTools.append(result.popToolsAndMerge(AtlasReadyFilterCfg(inputFlags))) # assumes that your ComponentAccumulator is "cfg"
110 
111  zdcMonAlg.IsPEBStream = 'calibration_' in inputFlags.Input.TriggerStream
112  zdcMonAlg.IsPPMode = 'pp' in config
113  zdcMonAlg.IspOMode = 'pO' in config
114  zdcMonAlg.IsOOMode = 'OO' in config
115  zdcMonAlg.EnableOOpOTriggers = (zdcMonAlg.IspOMode or zdcMonAlg.IsOOMode) and inputFlags.DQ.useTrigger and ('physics_' in inputFlags.Input.TriggerStream or inputFlags.Input.TriggerStream == 'calibration_ZDCCalib')
116 
117  phys_stream_trig_map = {
118  "physics_MinBias": ['HLT_mb_sptrk_L1TRT_FILLED', 'HLT_mb_sptrk_L1jTE10', 'HLT_mb_sptrk_L1ZDC_OR', 'HLT_mb_sptrk_L1ZDC_LOR', 'HLT_noalg_L1ZDC_OR_EMPTY', 'HLT_noalg_L1ZDC_OR_UNPAIRED_NONISO', 'HLT_noalg_L1ZDC_LOR_EMPTY', 'HLT_noalg_L1ZDC_LOR_UNPAIRED_NONISO'],
119  "physics_UPC": ["L1_ZDC_XOR_jTE10_VjTE200", "L1_TRT_VjTE50", "L1_1ZDC_NZDC_jTE10_VjTE200", "L1_5ZDC_A_5ZDC_C_jTE5_VjTE200", "HLT_noalg_L1TRT_VjTE50"],
120  "physics_PC": ["HLT_mb_sptrk_L1ZDC_A_C_VTE50", "L1_ZDC_A_C_VTE50", "HLT_noalg_pc_L1TE50_VTE600.0ETA49", "L1_TE50_VTE600.0ETA49"], #Run2; ["HLT_noalg_L1jTE50_VjTE600", "HLT_mb_sptrk_pc_L1ZDC_A_C_VjTE50", "L1_jTE50_VjTE600", "L1_ZDC_A_C_VjTE50"] for #Run3
121  "physics_Standby": ["HLT_noalg_L1Standby"]
122  }
123 
124  OOpOTriggerChains = phys_stream_trig_map.get(inputFlags.Input.TriggerStream, [])
125 
126  OOpOCTPIDtoL1TriggerStreamMap = {
127  "calibration_ZDCCalib": {
128  331: "L1_ZDC_OR",
129  345: "L1_ZDC_LOR",
130  200: "L1_ZDC_A_C"
131  },
132  "physics_MinBias": {
133  120: 'L1_jTE10',
134  },
135  "physics_Standby": {
136  331: "L1_ZDC_OR",
137  345: "L1_ZDC_LOR",
138  1: "L1_TRT_FILLED",
139  121: "L1_jTE20"
140  }
141  }
142 
143  OOpOCTPIDtoL1TriggerMap = OOpOCTPIDtoL1TriggerStreamMap.get(inputFlags.Input.TriggerStream, {})
144  OOpOL1TriggerChainsFromCTP = list(OOpOCTPIDtoL1TriggerMap.values())
145  OOpOTriggerChains += OOpOL1TriggerChainsFromCTP
146 
147  zdcMonAlg.OOpOTriggers = OOpOTriggerChains
148  zdcMonAlg.OOpOL1TriggerFromCTPIDMap = OOpOCTPIDtoL1TriggerMap
149 
150  zdcMonAlg.RunNumber = inputFlags.Input.RunNumbers[0] if len(inputFlags.Input.RunNumbers) > 0 else 0
151  if (len(inputFlags.Input.RunNumbers) == 0):
152  print ('ZdcMonitorAlgorithm.py: WARNING the list in the input flag Input.RunNumbers is empty - run number not set! Likely to use default pulser setting')
153  elif (len(inputFlags.Input.RunNumbers) > 1):
154  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')
155 
156  zdcMonAlg.EnableZDC = inputFlags.Detector.EnableZDC_ZDC
157  zdcMonAlg.EnableZDCPhysics = zdcMonAlg.EnableZDC and not zdcMonAlg.IsInjectedPulse # no physical pulse (neutrons) for injector pulse
158  zdcMonAlg.EnableRPD = inputFlags.Detector.EnableZDC_RPD and not zdcMonAlg.IsInjectedPulse
159  zdcMonAlg.EnableRPDAmp = zdcMonAlg.EnableRPD
160  zdcMonAlg.EnableCentroid = zdcMonAlg.EnableRPD
161 
162  print ("ZdcMonitorAlgorithm.py: IsInjectedPulse? ",zdcMonAlg.IsInjectedPulse)
163  print ("ZdcMonitorAlgorithm.py: IsPPMode? ",zdcMonAlg.IsPPMode)
164  print ("ZdcMonitorAlgorithm.py: IspOMode? ",zdcMonAlg.IspOMode)
165  print ("ZdcMonitorAlgorithm.py: IsOOMode? ",zdcMonAlg.IsOOMode)
166  print ("ZdcMonitorAlgorithm.py: EnableOOpOTriggers? ",zdcMonAlg.EnableOOpOTriggers)
167 
168 # --------------------------------------------------------------------------------------------------
169  # Configure histograms
170 
171  # (potentially run-type dependent) range settings
172  lumi_block_max = 2000
173  n_lumi_block_bins_coarse = 400
174  bcid_max = 3564
175  n_energy_bins_default = 200
176  n_fpga_bins = 204
177  n_time_centroid_bins_default = 100
178  n_module_amp_coarse_bins = 100
179  n_module_amp_fine_bins = 200
180  n_mod_fraction_bins_default = 100
181 
182  n_HG_LG_amp_ratio_bins = 120
183  n_HG_LG_time_diff_bins = 50
184 
185  module_chisq_min = 0.1
186  module_chisq_max = 800000
187  module_chisq_nbins = 80
188  module_chisq_over_amp_min = 0.01
189  module_chisq_over_amp_max = 3000
190  module_chisq_over_amp_nbins = 80
191  module_chisq_over_amp_linear_max = 50
192  module_chisq_over_amp_linear_nbins = 200
193 
194 
195  # to ensure the logarithmic binning in C++ algorithm agrees with python
196  # so that the inverse-bin-width weight calculation is correct
197  zdcMonAlg.ZDCModuleChisqHistMinValue = module_chisq_min
198  zdcMonAlg.ZDCModuleChisqHistMaxvalue = module_chisq_max
199  zdcMonAlg.ZDCModuleChisqHistNumBins = module_chisq_nbins
200  zdcMonAlg.ZDCModuleChisqOverAmpHistMinValue = module_chisq_over_amp_min
201  zdcMonAlg.ZDCModuleChisqOverAmpHistMaxvalue = module_chisq_over_amp_max
202  zdcMonAlg.ZDCModuleChisqOverAmpHistNumBins = module_chisq_over_amp_nbins
203 
204  zdcMonAlg.EnergyCutForModuleFractMonitor = 400 if zdcMonAlg.IsPPMode or zdcMonAlg.IspOMode or zdcMonAlg.IsOOMode else 13400
205  zdcMonAlg.triggerSideA = "L1_ZDC_PP_A" if zdcMonAlg.IsPPMode else "L1_ZDC_A"
206  zdcMonAlg.triggerSideC = "L1_ZDC_PP_C" if zdcMonAlg.IsPPMode else "L1_ZDC_C"
207 # --------------------------------------------------------------------------------------------------
208  if (zdcMonAlg.IsInjectedPulse):
209  from ZdcMonitoring.ZdcInjPulserVoltageReader import load_voltage_steps
210  voltage_values_list = []
211  voltage_strs_list = []
212  load_voltage_steps(zdcMonAlg.RunNumber, voltage_values_list, voltage_strs_list)
213 
214  if len(voltage_values_list) == 0:
215  voltage_values_list = [0.]
216  voltage_strs_list = ["0.00000"]
217 
218  zdcMonAlg.InjPulseVoltageSteps = voltage_values_list
219  zdcMonAlg.InjPulseVoltageStepsStr = voltage_strs_list
220 
221 # --------------------------------------------------------------------------------------------------
222  amp_LG_refit_max_ADC = module_FPGA_max_ADC
223 
224  fCal_single_side_min = -0.2
225  fCal_single_side_max = 2.8
226  fCal_sum_min = -0.5
227  fCal_sum_max = 5.5
228  fCal_single_side_nbins = 240
229  fCal_sum_nbins = 240
230 
231  total_Et_sum_min = -0.5
232  total_Et_sum_max = 5.5
233  total_Et_sum_nbins = 240
234 
235  uncalib_sum_zoomin_nbins = 100
236  energy_sum_zoomin_nbins = 200
237  energy_sum_1n_nbins = 350
238  energy_sum_1n_xmin = 1000.
239  energy_sum_1n_xmax = 4500.
240 
241 
242  if "PbPb" in config or "Injector" in config:
243  print ("looking at pbpb / injected-pulse data")
244  energy_sum_xmax = 200000.0
245  energy_sum_two_sides_xmax_TeV = 400.0
246  energy_sum_single_side_xmax_TeV = 200.0
247  energy_sum_zoomin_xmax = 13000.0
248  uncalib_amp_sum_zoomin_xmax = 7200.0
249  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
250  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
251  x_centroid_max = 20
252  y_centroid_min = -20
253  y_centroid_max = 60
254  zdc_amp_sum_xmax = 163840.0
255  rpd_channel_amp_min = - 2000.
256  rpd_amp_sum_xmax = 245760.0 #not the full range but a reasonable value
257  rpd_max_adc_sum_xmax = 40960.0
258  rpd_sum_adc_max = 25000.
259  lg_gain_factor = 10
260  module_calib_amp_xmax = 100000.0 #about the full dynamic range: 160 N / 4 * 2.5TeV
261  module_amp_1Nmonitor_xmax = 1250.0 #about 5N / 4 * 2.7TeV
262  module_calib_amp_1Nmonitor_xmax = 3400.0 #about 5N / 4 * 2.7TeV
263 
264  elif config == "LHCf2022":
265  print ("looking at 2022 lhcf data")
266  energy_sum_xmax = 3000
267  energy_sum_two_sides_xmax_TeV = 10.0
268  energy_sum_single_side_xmax_TeV = 5.0
269  energy_sum_zoomin_xmax = 3000
270  uncalib_amp_sum_zoomin_xmax = module_FPGA_max_ADC
271  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
272  x_centroid_min = -500 #small amplitude sum --> large range for x, y position
273  x_centroid_max = 500
274  y_centroid_min = -50
275  y_centroid_max = 750
276  zdc_amp_sum_xmax = 3000
277  rpd_channel_amp_min = - 200.
278  rpd_amp_sum_xmax = 3000
279  rpd_max_adc_sum_xmax = 3000
280  rpd_sum_adc_max = 5000
281  lg_gain_factor = 1
282  module_calib_amp_xmax = 5000
283  module_amp_1Nmonitor_xmax = 2000 #about 5N / 4 * 2.7TeV
284  module_calib_amp_1Nmonitor_xmax = 5000 #about 5N / 4 * 2.7TeV
285 
286  elif zdcMonAlg.IsPPMode:
287  print ("looking at pp data")
288  energy_sum_xmax = 5000
289  energy_sum_two_sides_xmax_TeV = 10.0
290  energy_sum_single_side_xmax_TeV = 5.0
291  energy_sum_zoomin_xmax = 5000
292  uncalib_amp_sum_zoomin_xmax = module_FPGA_max_ADC
293  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
294  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
295  x_centroid_max = 20
296  y_centroid_min = -20
297  y_centroid_max = 120
298  zdc_amp_sum_xmax = 5000
299  rpd_channel_amp_min = - 200.
300  rpd_amp_sum_xmax = 5000
301  rpd_max_adc_sum_xmax = 5000
302  rpd_sum_adc_max = 5000.
303  lg_gain_factor = 1
304  module_calib_amp_xmax = 5000
305  module_amp_1Nmonitor_xmax = 2000 #about 5N / 4 * 2.7TeV
306  module_calib_amp_1Nmonitor_xmax = 5000 #about 5N / 4 * 2.7TeV
307  elif zdcMonAlg.IsOOMode:
308  print ("looking at OO data")
309  energy_sum_xmax = 10000.
310  energy_sum_two_sides_xmax_TeV = 40.
311  energy_sum_single_side_xmax_TeV = 20.0
312  energy_sum_zoomin_xmax = 13000.0 #4.85N (tail of 4N)
313  uncalib_amp_sum_zoomin_xmax = 7200.0 #tail of 4N
314  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
315  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
316  x_centroid_max = 20
317  y_centroid_min = -20
318  y_centroid_max = 60
319  zdc_amp_sum_xmax = 50000.0
320  rpd_channel_amp_min = - 2000.
321  rpd_amp_sum_xmax = 245760.0
322  rpd_max_adc_sum_xmax = 40960.0
323  rpd_sum_adc_max = 25000.
324  lg_gain_factor = 4
325  module_calib_amp_xmax = 13400.0 #20N / 4 * 2680.
326  module_amp_1Nmonitor_xmax = 1250.0 #about 5N / 4 * 2.7TeV
327  module_calib_amp_1Nmonitor_xmax = 3400.0 #about 5N / 4 * 2.7TeV
328  fCal_single_side_min = -0.02 # overwrite FCal binning
329  fCal_single_side_max = 0.43
330  fCal_sum_min = -0.03
331  fCal_sum_max = 0.72
332  fCal_single_side_nbins = 90
333  fCal_sum_nbins = 150
334  total_Et_sum_min = -0.1 # overwrite total ET binning
335  total_Et_sum_max = 1.5
336  total_Et_sum_nbins = 160
337 
338  elif zdcMonAlg.IspOMode:
339  print ("looking at pO data")
340  energy_sum_xmax = 30000.
341  energy_sum_two_sides_xmax_TeV = 40. #22.4N per side
342  energy_sum_single_side_xmax_TeV = 20.0
343  energy_sum_zoomin_xmax = 13000.0 #4.85N (tail of 4N)
344  uncalib_amp_sum_zoomin_xmax = 7200.0 #tail of 4N
345  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
346  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
347  x_centroid_max = 20
348  y_centroid_min = -20
349  y_centroid_max = 60
350  zdc_amp_sum_xmax = 50000.0
351  rpd_channel_amp_min = - 2000.
352  rpd_amp_sum_xmax = 245760.0
353  rpd_max_adc_sum_xmax = 40960.0
354  rpd_sum_adc_max = 25000.
355  lg_gain_factor = 4
356  module_calib_amp_xmax = 13400.0 #20N / 4 * 2680.
357  module_amp_1Nmonitor_xmax = 1250.0 #about 5N / 4 * 2.7TeV
358  module_calib_amp_1Nmonitor_xmax = 3400.0 #about 5N / 4 * 2.7TeV
359  fCal_single_side_min = -0.05 # overwrite FCal binning
360  fCal_single_side_max = 0.2
361  fCal_sum_min = -0.05
362  fCal_sum_max = 0.35
363  fCal_single_side_nbins = 100
364  fCal_sum_nbins = 100
365  total_Et_sum_min = -0.1 # overwrite total ET binning
366  total_Et_sum_max = 0.5
367  total_Et_sum_nbins = 120
368  else:
369  import sys
370  print("ZdcMonitorAlgorithm ERROR: Invalid configuration! Config tag is", config)
371  sys.exit(1)
372 
373 
374  lg_max_ADC = module_FPGA_max_ADC * lg_gain_factor
375  module_amp_xmax = lg_max_ADC
376 
377  hg_lg_amp_ratio_min_nominal = 0.6
378  hg_lg_amp_ratio_min_tight = 0.9
379  hg_lg_amp_ratio_max_nominal = 1.4
380  hg_lg_amp_ratio_max_tight = 1.2
381 
382  # #bins for RPD channel amplitude, including negative values - determined by the ratio between the negative amplitude range & positive amplitude range
383  rpd_sub_amp_min = - module_amp_xmax / 4.
384  rpd_sub_amp_max = module_amp_xmax / 2.
385  n_rpd_amp_bins_full_range = int((abs(rpd_channel_amp_min) + rpd_sum_adc_max) / rpd_sum_adc_max * n_energy_bins_default)
386  n_rpd_sub_amp_bins = int((abs(rpd_sub_amp_min) + rpd_sub_amp_max) / rpd_sub_amp_max * n_energy_bins_default)
387 
388 # --------------------------------------------------------------------------------------------------
389 # ----------------------------------- General ZDC observables -----------------------------------
390 # --------- Event-level observables / decoding error monitoring / A-C side correlations ---------
391 # --------------------------------------------------------------------------------------------------
392 
393  genZdcMonTool = helper.addGroup(zdcMonAlg, 'genZdcMonTool', topPath = 'ZDC')
394 
395  nDecodingErrorBits = 3
396 
397  genZdcMonTool.defineHistogram('decodingErrorBits',title=';;Events',
398  path='/EXPERT/Global/DecodingErrors',
399  opt='kVec',
400  xbins=nDecodingErrorBits,xmin=0.0,xmax=nDecodingErrorBits,
401  xlabels=['No Decoding Error', 'ZDC Decoding Error', 'RPD Decoding Error'])
402 
403  nUCCTrigBits = 7
404 
405  genZdcMonTool.defineHistogram('uccTrigBits',title=';;Events',
406  path='/EXPERT/Global/UCCTrigs',
407  opt='kVec',
408  xbins=nUCCTrigBits,xmin=0.0,xmax=nUCCTrigBits,
409  xlabels=['UCC Trig Enabled', 'Pass HELT50', 'Pass HELT35', 'Pass HELT25', 'Pass HELT20', 'Pass HELT15', 'UCC Trig Disabled'])
410 
411  if zdcMonAlg.EnableOOpOTriggers:
412  OOpOTriggerLabels = ['OOpO Trig Enabled'] + OOpOTriggerChains + ['OOpO Trig Disabled']
413 
414  nOOpOTrigBits = len(OOpOTriggerLabels)
415 
416  genZdcMonTool.defineHistogram('OOpOTrigBits',title=';;Events',
417  path='/EXPERT/Global/OOpOTrigs',
418  opt='kVec',
419  xbins=nOOpOTrigBits,xmin=0.0,xmax=nOOpOTrigBits,
420  xlabels=OOpOTriggerLabels)
421 
422  if (zdcMonAlg.EnableCentroid):
423  genZdcMonTool.defineHistogram('rpdCosDeltaReactionPlaneAngle', title=';Cos (#Delta #phi_{AorC});Events',
424  path='/EXPERT/Global/ReactionPlane',
425  cutmask='bothHasCentroid', # only require both sides to have centroid
426  xbins=n_time_centroid_bins_default,xmin=-1,xmax=1)
427  if (not zdcMonAlg.IsOnline):
428  genZdcMonTool.defineHistogram('rpdCosDeltaReactionPlaneAngle;rpdCosDeltaReactionPlaneAngle_requireValid', title=';Cos (#Delta #phi_{AorC});Events',
429  path='/EXPERT/Global/ReactionPlane',
430  cutmask='bothReactionPlaneAngleValid', # require centroid calculation on both sides to be valid
431  xbins=n_time_centroid_bins_default,xmin=-1,xmax=1)
432 
433  if (zdcMonAlg.EnableZDCPhysics):
434  genZdcMonTool.defineHistogram('zdcEnergySumA, zdcEnergySumC', type='TH2F', title=';E_{ZDC,A} [GeV];E_{ZDC,C} [GeV]',
435  path='/EXPERT/Global/SideACCorr',
436  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
437  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_xmax)
438  if (zdcMonAlg.IspOMode or zdcMonAlg.IsOOMode): #OO mode --> add zoomed-in AC-correlation
439  genZdcMonTool.defineHistogram('zdcEnergySumA, zdcEnergySumC;zdcEnergySumC_vs_zdcEnergySumA_zoomin', type='TH2F', title=';E_{ZDC,A} [GeV];E_{ZDC,C} [GeV]',
440  path='/EXPERT/Global/SideACCorr',
441  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax,
442  ybins=energy_sum_zoomin_nbins,ymin=0.0,ymax=energy_sum_zoomin_xmax)
443  genZdcMonTool.defineHistogram('zdcUncalibSumA, zdcUncalibSumC;zdcUncalibSumC_vs_zdcUncalibSumA_zoomin', type='TH2F', title=';Amp Sum SideA [ADC];Amp Sum SideC [ADC]',
444  path='/EXPERT/Global/SideACCorr',
445  xbins=uncalib_sum_zoomin_nbins,xmin=0.0,xmax=uncalib_amp_sum_zoomin_xmax,
446  ybins=uncalib_sum_zoomin_nbins,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax)
447 
448  if (zdcMonAlg.EnableOOpOTriggers):
449  for oo_po_trig in OOpOTriggerChains:
450  genZdcMonTool.defineHistogram('zdcEnergySumA, zdcEnergySumC;zdcEnergySumC_vs_zdcEnergySumA_pass'+oo_po_trig, type='TH2F', title=';E_{ZDC,A} [GeV];E_{ZDC,C} [GeV]',
451  path='/EXPERT/Global/SideACCorr',
452  cutmask='pass'+oo_po_trig,
453  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
454  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_xmax)
455  genZdcMonTool.defineHistogram('zdcEnergySumA, zdcEnergySumC;zdcEnergySumC_vs_zdcEnergySumA_zoomin_pass'+oo_po_trig, type='TH2F', title=';E_{ZDC,A} [GeV];E_{ZDC,C} [GeV]',
456  path='/EXPERT/Global/SideACCorr',
457  cutmask='pass'+oo_po_trig,
458  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax,
459  ybins=energy_sum_zoomin_nbins,ymin=0.0,ymax=energy_sum_zoomin_xmax)
460  genZdcMonTool.defineHistogram('zdcUncalibSumA, zdcUncalibSumC;zdcUncalibSumC_vs_zdcUncalibSumA_zoomin_pass'+oo_po_trig, type='TH2F', title=';Amp Sum SideA [ADC];Amp Sum SideC [ADC]',
461  path='/EXPERT/Global/SideACCorr',
462  cutmask='pass'+oo_po_trig,
463  xbins=uncalib_sum_zoomin_nbins,xmin=0.0,xmax=uncalib_amp_sum_zoomin_xmax,
464  ybins=uncalib_sum_zoomin_nbins,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax)
465 
466 
467 
468  # FCal E_T vs ZDC E_T
469  # to be run on min bias stream
470  if (zdcMonAlg.CalInfoOn):
471  genZdcMonTool.defineHistogram('fcalEtA, fcalEtC', type='TH2F', title=';E_{FCal, A} [GeV];E_{FCal, C} [GeV]',
472  path='/EXPERT/Global/SideACCorr',
473  xbins=fCal_single_side_nbins,xmin=fCal_single_side_min,xmax=fCal_single_side_max,
474  ybins=fCal_single_side_nbins,ymin=fCal_single_side_min,ymax=fCal_single_side_max)
475 
476  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
477  path = '/EXPERT/Global/ZDCFcalCorr',
478  opt='kAlwaysCreate',
479  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
480  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
481 
482  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt', type='TH2F', title=';FCal Energy [TeV];ZDC Hadronic Energy [TeV]',
483  path = '/EXPERT/Global/ZDCHEFcalCorr',
484  opt='kAlwaysCreate',
485  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
486  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
487 
488  genZdcMonTool.defineHistogram('totalEt24, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_totalEt', type='TH2F', title=';Total Et |#eta| < 2.4 [TeV];ZDC Energy [TeV]',
489  path = '/EXPERT/Global/ZDCTotalEtCorr',
490  opt='kAlwaysCreate',
491  xbins=total_Et_sum_nbins,xmin=total_Et_sum_min,xmax=total_Et_sum_max,
492  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
493 
494 
495  if (zdcMonAlg.EnableOOpOTriggers):
496  for oo_po_trig in OOpOTriggerChains:
497  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_pass'+oo_po_trig, type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
498  path = '/EXPERT/Global/ZDCFcalCorr',
499  cutmask='pass'+oo_po_trig,
500  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
501  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
502  genZdcMonTool.defineHistogram('totalEt24, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_totalEt_pass'+oo_po_trig, type='TH2F', title=';Total Et |#eta| < 2.4 [TeV];ZDC Energy [TeV]',
503  path = '/EXPERT/Global/ZDCTotalEtCorr',
504  cutmask='pass'+oo_po_trig,
505  xbins=total_Et_sum_nbins,xmin=total_Et_sum_min,xmax=total_Et_sum_max,
506  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
507 
508 
509  if (zdcMonAlg.EnableUCCTriggers):
510  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT15', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
511  path = '/EXPERT/Global/ZDCFcalCorr',
512  cutmask = 'passUCCTrig_HELT15',
513  opt='kAlwaysCreate',
514  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
515  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
516  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT20', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
517  path = '/EXPERT/Global/ZDCFcalCorr',
518  cutmask = 'passUCCTrig_HELT20',
519  opt='kAlwaysCreate',
520  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
521  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
522  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT25', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
523  path = '/EXPERT/Global/ZDCFcalCorr',
524  cutmask = 'passUCCTrig_HELT25',
525  opt='kAlwaysCreate',
526  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
527  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
528  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT35', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
529  path = '/EXPERT/Global/ZDCFcalCorr',
530  cutmask = 'passUCCTrig_HELT35',
531  opt='kAlwaysCreate',
532  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
533  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
534  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcEnergySumTwoSidesTeV;zdcEnergySum_vs_fCalEt_passUCCTrig_HELT50', type='TH2F', title=';FCal Energy [TeV];ZDC Energy [TeV]',
535  path = '/EXPERT/Global/ZDCFcalCorr',
536  cutmask = 'passUCCTrig_HELT50',
537  opt='kAlwaysCreate',
538  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
539  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
540 
541  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT15', type='TH2F', title=';FCal Energy [TeV];ZDC Hadronic Energy [TeV]',
542  path = '/EXPERT/Global/ZDCHEFcalCorr',
543  cutmask = 'passUCCTrig_HELT15',
544  opt='kAlwaysCreate',
545  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
546  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
547  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT20', type='TH2F', title=';FCal Energy [TeV];ZDC Hadronic Energy [TeV]',
548  path = '/EXPERT/Global/ZDCHEFcalCorr',
549  cutmask = 'passUCCTrig_HELT20',
550  opt='kAlwaysCreate',
551  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
552  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
553  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT25', type='TH2F', title=';FCal Energy [TeV];ZDC Hadronic Energy [TeV]',
554  path = '/EXPERT/Global/ZDCHEFcalCorr',
555  cutmask = 'passUCCTrig_HELT25',
556  opt='kAlwaysCreate',
557  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
558  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
559  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT35', type='TH2F', title=';FCal Energy [TeV];ZDC Hadronic Energy [TeV]',
560  path = '/EXPERT/Global/ZDCHEFcalCorr',
561  cutmask = 'passUCCTrig_HELT35',
562  opt='kAlwaysCreate',
563  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
564  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
565  genZdcMonTool.defineHistogram('fcalEtSumTwoSides, zdcHadronicEnergySumTwoSidesTeV;zdcHadronicEnergySum_vs_fCalEt_passUCCTrig_HELT50', type='TH2F', title=';FCal Energy [TeV];ZDC Hadronic Energy [TeV]',
566  path = '/EXPERT/Global/ZDCHEFcalCorr',
567  cutmask = 'passUCCTrig_HELT50',
568  opt='kAlwaysCreate',
569  xbins=fCal_sum_nbins,xmin=fCal_sum_min,xmax=fCal_sum_max,
570  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_two_sides_xmax_TeV)
571 
572 # --------------------------------------------------------------------------------------------------
573  sides = ["C","A"]
574  modules = ["0","1","2","3"]
575  channels = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"]
576 
577  nZdcStatusBits = 18
578  nRpdStatusBits = 15
579  nRpdCentroidStatusBits = 21
580 
581 # --------------------------------------------------------------------------------------------------
582 # ---------------------------------- Per-ZDC-arm/side observables ----------------------------------
583 # --------------------------------------------------------------------------------------------------
584 
585  if (zdcMonAlg.EnableZDCPhysics or zdcMonAlg.EnableRPDAmp or zdcMonAlg.EnableCentroid):
586 
587  zdcSideMonToolArr = helper.addArray([sides],zdcMonAlg,'ZdcSideMonitor', topPath = 'ZDC')
588 
589 
590  # ---------------------------- Calorimeter per-arm variables ----------------------------
591  # ---------------------------- Calorimeter energy/amplitude sum ----------------------------
592  if (zdcMonAlg.EnableZDCPhysics):
593  zdcSideMonToolArr.defineHistogram('zdcEnergySum',title='ZDC Side {0} Energy Sum;Side {0} Energy [GeV];Events',
594  path = '/EXPERT/ZDC/PerArm/Energy',
595  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax) # 2.5TeV * 80 neutrons
596 
597  # --------------------- calibrated energy sum in the 1-to-4n-range ---------------------
598  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_noTrigSelec',title='ZDC Side {0} Energy Sum (1-to-4n, no trigger selection);Side {0} Energy[GeV];Events',
599  path = '/SHIFT/ZDC/PerArm/Energy',
600  opt='kAlwaysCreate', # always create for shift-needed histograms
601  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
602  if (zdcMonAlg.EnableOOpOTriggers):
603  for oo_po_trig in OOpOTriggerChains:
604  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_pass'+oo_po_trig,title='ZDC Side {0} Energy Sum (1-to-4n, no trigger selection);Side {0} Energy[GeV];Events',
605  path = '/SHIFT/ZDC/PerArm/Energy',
606  cutmask='pass'+oo_po_trig,
607  opt='kAlwaysCreate', # always create for shift-needed histograms
608  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
609 
610  if (zdcMonAlg.EnableZDCSingleSideTriggers):
611  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_wTrigSelec',title='ZDC Side {0} Energy Sum (1-to-4n, require opposite-side trigger);Side {0} Energy[GeV];Events',
612  path = '/SHIFT/ZDC/PerArm/Energy',
613  opt='kAlwaysCreate', # always create for shift-needed histograms
614  cutmask = 'passTrigOppSide',
615  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=energy_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
616 
617  # --------------------- uncalibrated amplitude sum in the 1-to-4n-range ---------------------
618  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',
619  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
620  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=uncalib_amp_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
621 
622  if (zdcMonAlg.EnableZDCSingleSideTriggers):
623  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',
624  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
625  cutmask = 'passTrigOppSide',
626  xbins=energy_sum_zoomin_nbins,xmin=0.0,xmax=uncalib_amp_sum_zoomin_xmax) # up to the "far end" of 4-neutron peak
627 
628  # --------------------- uncalibrated amplitude sum in the full range ---------------------
629  zdcSideMonToolArr.defineHistogram('zdcUncalibSum',title='ZDC Side {0} Uncalibrated Sum;[ADC];Events',
630  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
631  xbins=n_energy_bins_default,xmin=0.0,xmax=zdc_amp_sum_xmax)
632 
633  # ---------------------------- Calorimeter energy/amplitude sum: LB dependence ----------------------------
634  if (not zdcMonAlg.IsOnline): # offline - use fine LB binnings
635  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_noTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
636  path = '/EXPERT/ZDC/PerArm/Energy',
637  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
638  ybins=energy_sum_zoomin_nbins,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
639  if (zdcMonAlg.EnableZDCSingleSideTriggers):
640  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_wTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
641  path = '/EXPERT/ZDC/PerArm/Energy',
642  cutmask = 'passTrigOppSide',
643  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
644  ybins=energy_sum_zoomin_nbins,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
645  else: # online - use coarse LB binnings
646  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_1n_noTrigSelec',title='ZDC Side {0} Energy Sum (1n range, no trigger selection);Side {0} Energy[GeV];Events',
647  path = '/SHIFT/ZDC/PerArm/Energy',
648  opt='kAlwaysCreate', # always create for shift-needed histograms
649  xbins=energy_sum_1n_nbins,xmin=energy_sum_1n_xmin,xmax=energy_sum_1n_xmax)
650 
651  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_1n_vs_lb_noTrig', type='TH2F', title=';lumi block;Side {0} Energy (1n range) [GeV]',
652  path = '/EXPERT/ZDC/PerArm/Energy',
653  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
654  ybins=energy_sum_1n_nbins,ymin=energy_sum_1n_xmin,ymax=energy_sum_1n_xmax)
655 
656  if (not zdcMonAlg.IsOnline): #only offline
657  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcUncalibSum;zdcUncalibSum_vs_lb_noTrig', type='TH2F', title=';lumi block;ZDC Side {0} Uncalibrated Sum [ADC]',
658  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
659  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
660  ybins=n_energy_bins_default,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
661  if (zdcMonAlg.EnableZDCSingleSideTriggers):
662  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcUncalibSum;zdcUncalibSum_vs_lb_wTrig', type='TH2F', title=';lumi block;ZDC Side {0} Uncalibrated Sum [ADC]',
663  path = '/EXPERT/ZDC/PerArm/UncalibAmp',
664  cutmask = 'passTrigOppSide',
665  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
666  ybins=n_energy_bins_default,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
667 
668  # ---------------------------- Calorimeter energy/amplitude sum: BCID dependence ----------------------------
669  if (not zdcMonAlg.IsOnline): #only offline
670  zdcSideMonToolArr.defineHistogram('bcid, zdcEnergySum;zdcEnergySum_vs_bcid_noTrig', type='TH2F', title=';BCID;Side {0} Energy [GeV]',
671  path = '/EXPERT/ZDC/PerArm/Energy',
672  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
673  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
674  if (zdcMonAlg.EnableZDCSingleSideTriggers):
675  zdcSideMonToolArr.defineHistogram('bcid, zdcEnergySum;zdcEnergySum_vs_bcid_wTrig', type='TH2F', title=';BCID;Side {0} Energy [GeV]',
676  path = '/EXPERT/ZDC/PerArm/Energy',
677  cutmask = 'passTrigOppSide',
678  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
679  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
680 
681  if (zdcMonAlg.CalInfoOn):
682  zdcSideMonToolArr.defineHistogram('fCalEt, zdcEnergySumTeV;zdcEnergySum_vs_fCalEt_single_side', type='TH2F', title=';Side {0} FCal Energy [TeV];Side {0} ZDC Energy [TeV]',
683  path = '/EXPERT/ZDC/PerArm/ZDCFcalCorr',
684  opt='kAlwaysCreate',
685  xbins=fCal_single_side_nbins,xmin=fCal_single_side_min,xmax=fCal_single_side_max,
686  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_single_side_xmax_TeV)
687 
688 
689  # ---------------------------- Calorimeter average time & LB dependence ----------------------------
690 
691  zdcSideMonToolArr.defineHistogram('zdcAvgTime',title='ZDC Side Average Time;t[ns];Events',
692  path = '/EXPERT/ZDC/PerArm/AvgTime',
693  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
694 
695  if (not zdcMonAlg.IsOnline): #only offline
696  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcAvgTime;zdcAvgTime_vs_lb', type='TH2F', title=';ZDC Side Average Time versus Lumi block;lumi block;t[ns]',
697  path = '/EXPERT/ZDC/PerArm/AvgTime',
698  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
699  ybins=n_time_centroid_bins_default,ymin=-10.0,ymax=10.0)
700 
701  # ---------------------------- RPD (centroid-related) per-arm variables ----------------------------
702  # ---------------------------- centroid status ----------------------------
703  zdcSideMonToolArr.defineHistogram('centroidStatusBits',title=';;Events',
704  path='/EXPERT/RPD/PerArm/Centroid',
705  xbins=nRpdCentroidStatusBits,xmin=0.0,xmax=nRpdCentroidStatusBits,
706  opt='kVec',
707  xlabels=['ValidBit', 'HasCentroidBit', 'ZDCInvalidBit', 'InsufficientZDCEnergyBit', 'ExcessiveZDCEnergyBit', 'EMInvalidBit', 'InsufficientEMEnergyBit', 'ExcessiveEMEnergyBit', 'RPDInvalidBit', 'PileupBit', 'ExcessivePileupBit', 'ZeroSumBit', 'ExcessiveSubtrUnderflowBit', 'Row0ValidBit', 'Row1ValidBit', 'Row2ValidBit', 'Row3ValidBit', 'Col0ValidBit', 'Col1ValidBit', 'Col2ValidBit', 'Col3ValidBit'])
708 
709  zdcSideMonToolArr.defineHistogram('centroidValidBitFloat;centroidValidBit_RequireMinZDCEnergy',title='Centroid valid bit;;Events',
710  path='/SHIFT/RPD/PerArm/Centroid',
711  opt='kAlwaysCreate', # always create for shift-needed histograms
712  cutmask='passMinZDCEnergyCutForCentroidValidEvaluation',
713  xbins=2,xmin=0,xmax=2,
714  xlabels=['Valid','Invalid'])
715 
716  # ---------------------------- x, y centroid & reaction plane angle requiring centroid ValidBit ----------------------------
717  zdcSideMonToolArr.defineHistogram('xCentroid',title=';Centroid x position [mm];Events',
718  path='/SHIFT/RPD/PerArm/Centroid',
719  opt='kAlwaysCreate', # always create for shift-needed histograms
720  cutmask='centroidValid',
721  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max)
722 
723  zdcSideMonToolArr.defineHistogram('yCentroid',title=';Centroid y position [mm];Events',
724  path='/SHIFT/RPD/PerArm/Centroid',
725  opt='kAlwaysCreate', # always create for shift-needed histograms
726  cutmask='centroidValid',
727  xbins=n_time_centroid_bins_default*2,xmin=y_centroid_min,xmax=y_centroid_max)
728 
729  zdcSideMonToolArr.defineHistogram('xCentroid, yCentroid',type='TH2F',title=';Centroid x position [mm];Centroid y position [mm]',
730  path='/EXPERT/RPD/PerArm/Centroid',
731  cutmask='centroidValid',
732  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max,
733  ybins=n_time_centroid_bins_default*2,ymin=y_centroid_min,ymax=y_centroid_max)
734 
735  zdcSideMonToolArr.defineHistogram('ReactionPlaneAngle',title=';Reaction Plane Angle;Events',
736  path='/EXPERT/RPD/PerArm/ReactionPlane',
737  cutmask='centroidValid',
738  xbins=64,xmin=-3.141593,xmax=3.141593)
739 
740  # ---------------------------- x, y centroid & reaction plane angle requiring only HasCentroidBit ----------------------------
741 
742  if (not zdcMonAlg.IsOnline): #only offline
743  zdcSideMonToolArr.defineHistogram('xCentroid, yCentroid;yCentroid_vs_xCentroid_requireOnlyHasCentroidBit',type='TH2F',title=';Centroid x position [mm];Centroid y position [mm]',
744  path='/EXPERT/RPD/PerArm/Centroid',
745  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max,
746  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
747  zdcSideMonToolArr.defineHistogram('ReactionPlaneAngle;ReactionPlaneAngle_requireOnlyHasCentroidBit',title=';Reaction Plane Angle;Events',
748  path='/EXPERT/RPD/PerArm/ReactionPlane',
749  xbins=64,xmin=-3.141593,xmax=3.141593)
750 
751 
752  # ---------------------------- Centroid LB dependence ----------------------------
753  if (not zdcMonAlg.IsOnline): #only offline
754  zdcSideMonToolArr.defineHistogram('lumiBlock, xCentroid;xCentroid_vs_lb_requireOnlyHasCentroidBit', type='TH2F', title=';lumi block;Centroid x position [mm]',
755  path='/EXPERT/RPD/PerArm/CentroidLBdep',
756  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
757  ybins=n_time_centroid_bins_default,ymin=x_centroid_min,ymax=x_centroid_max)
758  zdcSideMonToolArr.defineHistogram('lumiBlock, yCentroid;yCentroid_vs_lb_requireOnlyHasCentroidBit', type='TH2F', title=';lumi block;Centroid y position [mm]',
759  path='/EXPERT/RPD/PerArm/CentroidLBdep',
760  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
761  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
762 
763  zdcSideMonToolArr.defineHistogram('lumiBlock, xCentroid;xCentroid_vs_lb', type='TH2F', title=';lumi block;Centroid x position [mm]',
764  path='/EXPERT/RPD/PerArm/CentroidLBdep',
765  cutmask='centroidValid',
766  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
767  ybins=n_time_centroid_bins_default,ymin=x_centroid_min,ymax=x_centroid_max)
768  zdcSideMonToolArr.defineHistogram('lumiBlock, yCentroid;yCentroid_vs_lb', type='TH2F', title=';lumi block;Centroid y position [mm]',
769  path='/EXPERT/RPD/PerArm/CentroidLBdep',
770  cutmask='centroidValid',
771  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
772  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
773 
774  # ---------------------------- ZDC-RPD correlations ----------------------------
775  zdcSideMonToolArr.defineHistogram('zdcEnergySum, rpdMaxADCSum', type='TH2F', title=';E ZDC side [TeV];RPD Max ADC Sum (AorC) [ADC counts]',
776  path='/EXPERT/ZdcRpdPerSideCorr',
777  cutmask='RPDSideValid',
778  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
779  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_max_adc_sum_xmax) # try a value for now
780  zdcSideMonToolArr.defineHistogram('zdcEnergySum, rpdAmplitudeCalibSum', type='TH2F', title=';E ZDC side [GeV];RPD Calib Amp Sum (AorC) [ADC counts]',
781  path='/EXPERT/ZdcRpdPerSideCorr',
782  cutmask='RPDSideValid',
783  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
784  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_amp_sum_xmax) # try a value for now
785  zdcSideMonToolArr.defineHistogram('zdcEMModuleEnergy, rpdAmplitudeCalibSum', type='TH2F', title=';E EM module AorC [GeV];RPD Calib Amp Sum (AorC) [ADC counts]',
786  path='/EXPERT/ZdcRpdPerSideCorr',
787  cutmask='RPDSideValid',
788  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)
789  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_amp_sum_xmax) # try a value for now
790 
791 # --------------------------------------------------------------------------------------------------
792 # ------------------------------------- ZDC-module observables -------------------------------------
793 # --------------------------------------------------------------------------------------------------
794 
795 
796  zdcModuleMonToolArr = helper.addArray([sides,modules],zdcMonAlg,'ZdcModuleMonitor', topPath = 'ZDC')
797 
798  # ---------------------------- ZDC-module status ----------------------------
799 
800  zdcModuleMonToolArr.defineHistogram('zdcStatusBits',title=';;Events',
801  path='/SHIFT/ZDC/ZdcModule/ModuleStatusBits',
802  opt='kAlwaysCreate kVec', # always create for shift-needed histograms
803  xbins=nZdcStatusBits,xmin=0.0,xmax=nZdcStatusBits,
804  xlabels=['PulseBit', 'LowGainBit', 'FailBit', 'HGOverflowBit', 'HGUnderflowBit', 'PSHGOverUnderflowBit', 'LGOverflowBit', 'LGUnderflowBit', 'PrePulseBit', 'PostPulseBit', 'FitFailedBit', 'BadChisqBit', 'BadT0Bit', 'ExcludeEarlyLGBit', 'ExcludeLateLGBit', 'preExpTailBit', 'FitMinAmpBit', 'RepassPulseBit'])
805 
806  # ---------------------------- ZDC-module amplitudes & amplitude fractions ----------------------------
807 
808  if (zdcMonAlg.IsInjectedPulse and zdcMonAlg.IsOnline): # if injcalib && online: impose minimum input-voltage requirement on amplitude histogram for low-amp-percentage DQ check to be meaningful
809  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp',title=';Module Amplitude [ADC Counts];Events',
810  cutmask='zdcInjInputVoltagePassMinThrsh',
811  path='/SHIFT/ZDC/ZdcModule/ModuleAmp',
812  opt='kAlwaysCreate', # always create for shift-needed histograms
813  xbins=n_fpga_bins * 2,xmin=0.0,xmax=module_amp_xmax)
814  else:
815  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp',title=';Module Amplitude [ADC Counts];Events',
816  path='/SHIFT/ZDC/ZdcModule/ModuleAmp',
817  opt='kAlwaysCreate', # always create for shift-needed histograms
818  xbins=n_fpga_bins * 2,xmin=0.0,xmax=module_amp_xmax)
819 
820  zdcModuleMonToolArr.defineHistogram('zdcModuleMaxADC',title=';Module Max ADC;Events',
821  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADC',
822  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax)
823 
824 
825  if (not zdcMonAlg.IsPPMode): # for PP mode data, LG never filled
826  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_HG',title=';Module Amplitude HG [ADC Counts];Events',
827  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
828  cutmask='zdcModuleHG',
829  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC)
830 
831  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_LG',title=';Module Amplitude LG [ADC Counts];Events',
832  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
833  cutmask='zdcModuleLG', # require to use LG
834  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax)
835 
836  if (zdcMonAlg.IsInjectedPulse):
837  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit',title=';LG-Refit Amplitude [ADC Counts];Events',
838  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
839  cutmask='zdcModuleHG',
840  xbins=n_fpga_bins,xmin=0.0,xmax=amp_LG_refit_max_ADC)
841 
842  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse): # only offline
843  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_halfrange',title=';Module Amplitude [ADC Counts];Events',
844  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
845  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax / 2.)
846 
847 
848  # ---------------------------- ZDC-module amplitude to max ADC ratio (debug purpose) ----------------------------
849  if (not zdcMonAlg.IsOnline): # 2D (memory consuming): offline only for calib stream
850  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_HG',type='TH2F',title=';Module Max ADC HG [ADC];Avg Amp/Max ADC',
851  path='/EXPERT/ZDC/ZdcModule/ModuleAmpToMaxADCRatio',
852  cutmask='zdcModuleHG',
853  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC,
854  ybins=100,ymin=0.0,ymax=2.)
855 
856  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_LG',type='TH2F',title=';Module Max ADC LG [ADC];Avg Amp/Max ADC',
857  path='/EXPERT/ZDC/ZdcModule/ModuleAmpToMaxADCRatio',
858  cutmask='zdcModuleLG',
859  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax, #max ADC has no LG gain factor
860  ybins=100,ymin=0.0,ymax=2.)
861 
862  # ---------------------------- ZDC-module amplitude fractions & correlations with energy deposits ----------------------------
863 
864  if (zdcMonAlg.IsInjectedPulse): # no real energy deposit --> do not require minimum ZDC energy
865  zdcModuleMonToolArr.defineHistogram('zdcModuleFract',title=';Module Amplitude Fraction;Events',
866  cutmask='zdcModuleMaskCurSide', # require per-arm module mask: pulses injected, not physical; all four modules must have "good" pulses for energy fraction to be sensible
867  path='/SHIFT/ZDC/ZdcModule/ModuleFraction',
868  opt='kAlwaysCreate', # always create for shift-needed histograms
869  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
870  else:
871  zdcModuleMonToolArr.defineHistogram('zdcModuleFract;zdcModuleFract_above_cut',title=';Module Amplitude Fraction;Events',
872  path='/SHIFT/ZDC/ZdcModule/ModuleFraction',
873  opt='kAlwaysCreate', # always create for shift-needed histograms
874  cutmask='zdcEnergyAboveModuleFractCut',
875  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
876  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_fullrange', type='TH2F', title=';ZDC Energy Sum Current Side [GeV];Module Amplitude Fraction',
877  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
878  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
879  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
880  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_profile', type='TProfile', title=';ZDC Energy Sum Current Side [GeV];Module Amplitude Fraction',
881  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
882  cutmask='zdcModuleFractionValid',
883  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax)
884  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_zoomedin', type='TH2F', title=';Amplitude Sum Current Side [ADC Counts];Module Amplitude Fraction',
885  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
886  xbins=n_energy_bins_default,xmin=0.0,xmax=10000,
887  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
888  if (not zdcMonAlg.IsOnline): # only offline
889  zdcModuleMonToolArr.defineHistogram('zdcModuleFract',title=';Module Amplitude Fraction;Events',
890  path='/EXPERT/ZDC/ZdcModule/ModuleFraction',
891  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
892  zdcModuleMonToolArr.defineHistogram('zdcModuleFract;zdcModuleFract_above20N',title=';Module Amplitude Fraction;Events',
893  path='/EXPERT/ZDC/ZdcModule/ModuleFraction',
894  cutmask='zdcAbove20NCurrentSide',
895  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
896 
897  if (not zdcMonAlg.IsInjectedPulse):
898  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibAmp',title=';Module Calibrated Amplitude [GeV];Events',
899  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmp',
900  xbins=2*n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax) # 2.5TeV * 40
901 
902  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
903  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibAmp;zdcModuleCalibAmp_halfrange',title=';Module Calibrated Amplitude [GeV];Events',
904  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmp',
905  xbins=2*n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax / 2.) # 2.5TeV * 40
906 
907  # ---------------------------- ZDC-module reco amplitude versus input voltage ----------------------------
908  if (zdcMonAlg.IsInjectedPulse):
909  # ---------------------------- HG response ----------------------------
910  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleFitAmp;zdcModuleAmpHG_vs_injectedPulseInputVoltage', type='TH2F', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
911  cutmask='zdcHGInjPulseValid',
912  path='/EXPERT/ZDC/ZdcModule/ModuleAmpHGVsInputVoltage',
913  xbins=create_vinj_bins(),
915 
916  if (zdcMonAlg.IsOnline): # also plot profile online in case 2D-hist scale is wrong by a large factor (e.g, due to attenuator setting)
917  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleFitAmp;zdcModuleAmpHG_vs_injectedPulseInputVoltage_profile', type='TProfile', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
918  cutmask='zdcHGInjPulseValid',
919  path='/EXPERT/ZDC/ZdcModule/ModuleAmpHGVsInputVoltage',
920  xbins=create_vinj_bins())
921  else: # ---------------------------- HG response max ADC (offline only) ----------------------------
922  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleMaxADCHG', type='TH2F', title=';Pulse amp [V];Max ADC HG',
923  cutmask='zdcHGInjPulseValid',
924  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADCHGVsInputVoltage',
925  xbins=create_vinj_bins(),
927 
928  # ---------------------------- LG response ----------------------------
929  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleLGFitAmp;zdcModuleAmpLG_vs_injectedPulseInputVoltage', type='TH2F', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
930  cutmask='zdcLGInjPulseValid',
931  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLGVsInputVoltage',
932  xbins=create_vinj_bins(),
934 
935  if (zdcMonAlg.IsOnline): # also plot profile online in case 2D-hist scale is wrong by a large factor (e.g, due to attenuator setting)
936  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleLGFitAmp;zdcModuleAmpLG_vs_injectedPulseInputVoltage_profile', type='TProfile', title=';Pulse amp [V];Signal Fit Amp [ADC Counts]',
937  cutmask='zdcLGInjPulseValid',
938  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLGVsInputVoltage',
939  xbins=create_vinj_bins())
940  else: # ---------------------------- LG response max ADC (offline only) ----------------------------
941  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleMaxADCLG;zdcModuleMaxADCLG_vs_injectedPulseInputVoltage', type='TH2F', title=';Pulse amp [V];Max ADC LG',
942  cutmask='zdcLGInjPulseValid',
943  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADCLGVsInputVoltage',
944  xbins=create_vinj_bins(),
945  ybins=create_hg_fit_amp_inj_bins()) # maxADC has no LG gain factor multiplied
946 
947  # ---------------------------- HG & LG response binned by the voltage strings ----------------------------
948  if (not zdcMonAlg.IsOnline):
949  zdcModuleMonToolArr.defineHistogram('VoltageIndex, zdcModuleFitAmp', type='TH2F', title=';;Signal Fit Amp [ADC Counts]',
950  path='/EXPERT/ZDC/ZdcModule/ModuleAmpHGVsInputVoltageStr',
951  cutmask='zdcHGInjPulseValid',
952  xbins=len(voltage_strs_list),xmin=0.0,xmax=len(voltage_strs_list),
954  xlabels=voltage_strs_list)
955 
956  zdcModuleMonToolArr.defineHistogram('VoltageIndex, zdcModuleLGFitAmp', type='TH2F', title=';;Signal Fit Amp [ADC Counts]',
957  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLGVsInputVoltageStr',
958  cutmask='zdcLGInjPulseValid',
959  xbins=len(voltage_strs_list),xmin=0.0,xmax=len(voltage_strs_list),
961  xlabels=voltage_strs_list)
962 
963  # ---------------------------- HG & LG response 1D histograms ----------------------------
964  # ---------------------------- only offline ----------------------------
965 
966  if (not zdcMonAlg.IsOnline):
967  zdcModuleSingleVoltageResponseArr = helper.addArray([sides,modules,voltage_strs_list],zdcMonAlg,'LucrodResponseSingleVoltageMonitor', topPath = 'ZDC/EXPERT/ZDC/ZdcModule/LucrodResponseSingleVoltage')
968  zdcModuleSingleVoltageResponseArr.defineHistogram('zdcModuleFitAmp;zdcModuleAmpHG_fixed_vInj', type='TH1F', title=';Signal Fit Amp [ADC Counts];Events',
969  cutmask='zdcHGInjPulseValid',
971 
972  zdcModuleSingleVoltageResponseArr.defineHistogram('zdcModuleLGFitAmp;zdcModuleAmpLG_fixed_vInj', type='TH1F', title=';Signal Fit Amp [ADC Counts];Events',
973  cutmask='zdcLGInjPulseValid',
975 
976  # ---------------------------- ZDC-module times ----------------------------
977 
978  zdcModuleMonToolArr.defineHistogram('zdcModuleTime',title=';Module Time [ns];Events',
979  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
980  opt='kAlwaysCreate', # always create for shift-needed histograms
981  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
982 
983  if (not zdcMonAlg.IsPPMode): # for PP mode, LG never filled
984  zdcModuleMonToolArr.defineHistogram('zdcModuleTime;zdcModuleTime_LG',title=';Module Time [ns];Events',
985  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
986  opt='kAlwaysCreate', # always create for shift-needed histograms
987  cutmask='zdcModuleLG',
988  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
989 
990  zdcModuleMonToolArr.defineHistogram('zdcModuleTime;zdcModuleTime_HG',title=';Module Time [ns];Events',
991  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
992  opt='kAlwaysCreate', # always create for shift-needed histograms
993  cutmask='zdcModuleHG',
994  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
995 
996  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0',title=';Module FitT0 [ns];Events',
997  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
998  xbins=200,xmin=0.0,xmax=time_in_data_buffer)
999 
1000  if (not zdcMonAlg.IsPPMode): # for PP mode, LG never filled
1001  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0;zdcModuleFitT0_LG',title=';Module FitT0 LG [ns];Events',
1002  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
1003  cutmask='zdcModuleLG',
1004  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
1005 
1006  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0;zdcModuleFitT0_HG',title=';Module FitT0 HG [ns];Events',
1007  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
1008  cutmask='zdcModuleHG',
1009  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
1010 
1011 
1012  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
1013  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibTime',title=';Module Calibrated Time [ns];Events',
1014  path='/EXPERT/ZDC/ZdcModule/ModuleCalibTime',
1015  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
1016 
1017  # ---------------------------- ZDC-module pulse-fitting chi squares (pulse fitting goodness) ----------------------------
1018 
1019  zdcModuleMonToolArr.defineHistogram('zdcModuleChisq',title=';Module Chi-square;Events',
1020  path='/EXPERT/ZDC/ZdcModule/ModuleChisq',
1021  weight='zdcModuleChisqEventWeight',
1022  xbins=create_log_bins(module_chisq_min, module_chisq_max, module_chisq_nbins))
1023  zdcModuleMonToolArr.defineHistogram('zdcModuleChisqOverAmp',title=';Module Chi-square / Amplitude;Events',
1024  path='/SHIFT/ZDC/ZdcModule/ModuleChisq',
1025  opt='kAlwaysCreate', # always create for shift-needed histograms
1026  weight='zdcModuleChisqOverAmpEventWeight',
1027  xbins=create_log_bins(module_chisq_over_amp_min, module_chisq_over_amp_max, module_chisq_over_amp_nbins))
1028  zdcModuleMonToolArr.defineHistogram('zdcModuleChisqOverAmp;zdcModuleChisqOverAmp_linear',title=';Module Chi-square / Amplitude;Events',
1029  path='/SHIFT/ZDC/ZdcModule/ModuleChisq',
1030  opt='kAlwaysCreate', # always create for shift-needed histograms
1031  xbins=module_chisq_over_amp_linear_nbins,xmin=0.,xmax=module_chisq_over_amp_linear_max)
1032 
1033  if (not zdcMonAlg.IsOnline):
1034  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleChisqOverAmp',type='TH2F',title=';Module Amplitude [ADC Counts];Module Chi-square / Amplitude',
1035  path='/EXPERT/ZDC/ZdcModule/ModuleChisq',
1036  weight='zdcModuleChisqOverAmpEventWeight',
1037  xbins=n_energy_bins_default,xmin=0.0,xmax=module_amp_xmax / 2.,
1038  ybins=create_log_bins(module_chisq_over_amp_min, module_chisq_over_amp_max, module_chisq_over_amp_nbins))
1039 
1040 
1041  # ---------------------------- LG & HG comparisons ----------------------------
1042  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGAmpRatio',title=';HG-to-LG Amplitude Raio;Events',
1043  path='/SHIFT/ZDC/ZdcModule/ModuleHGLGCompr',
1044  opt='kAlwaysCreate', # always create for shift-needed histograms
1045  cutmask='zdcModuleHG',
1046  xbins=n_HG_LG_amp_ratio_bins,xmin=hg_lg_amp_ratio_min_nominal,xmax=hg_lg_amp_ratio_max_nominal)
1047 
1048  if (not zdcMonAlg.IsInjectedPulse):
1049  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGAmpRatioNoNonlinCorr',title=';HG-to-LG Amplitude Raio;Events',
1050  path='/SHIFT/ZDC/ZdcModule/ModuleHGLGComprNoNonlinCorr',
1051  opt='kAlwaysCreate', # always create for shift-needed histograms
1052  cutmask='zdcModuleHG',
1053  xbins=n_HG_LG_amp_ratio_bins,xmin=hg_lg_amp_ratio_min_nominal,xmax=hg_lg_amp_ratio_max_nominal)
1054 
1055  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';ZDC HG Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
1056  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
1057  cutmask='zdcModuleHG',
1058  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC,
1059  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
1060 
1061  if (not zdcMonAlg.IsInjectedPulse):
1062  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatioNoNonlinCorr', type='TH2F', title=';ZDC HG Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
1063  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGComprNoNonlinCorr',
1064  cutmask='zdcModuleHG',
1065  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC,
1066  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
1067 
1068  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatio;zdcModuleHGtoLGAmpRatio_vs_zdcModuleAmp_profile', type='TProfile', title=';ZDC HG Amplitude [ADC Counts];Average HG-to-LG Amplitude Raio;Events',
1069  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
1070  cutmask='zdcModuleHG',
1071  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC)
1072 
1073  if (not zdcMonAlg.IsOnline):
1074  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';ZDC LG-Refit Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
1075  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
1076  cutmask='zdcModuleHG',
1077  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=amp_LG_refit_max_ADC,
1078  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
1079  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit, zdcModuleHGtoLGAmpRatio;zdcModuleHGtoLGAmpRatio_vs_zdcModuleAmpLGRefit_profile', type='TProfile', title=';ZDC LG-Refit Amplitude [ADC Counts];Average HG-to-LG Amplitude Raio;Events',
1080  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
1081  cutmask='zdcModuleHG',
1082  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=amp_LG_refit_max_ADC)
1083 
1084  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGT0Diff',title=';HG-LG T0 Difference [ns];Events',
1085  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
1086  cutmask='zdcModuleHG',
1087  xbins=n_HG_LG_time_diff_bins,xmin=-10.0,xmax=10.0)
1088 
1089  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGT0Diff, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';HG-LG T0 Difference [ns];HG-to-LG Amplitude Raio;Events',
1090  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
1091  cutmask='zdcModuleHG',
1092  xbins=n_HG_LG_time_diff_bins,xmin=2.0,xmax=4.0, # zoomed in to see potential correlations
1093  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_tight,ymax=hg_lg_amp_ratio_max_tight)
1094 
1095 
1096  # ---------------------------- LB and BCID-dep ZDC-module-level observables ----------------------------
1097  # ---------------------------- ZDC-module amplitudes ----------------------------
1098 
1099  if (not zdcMonAlg.IsInjectedPulse):
1100  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleCalibAmp;zdcModuleCalibAmp_vs_lb', type='TH2F', title=';lumi block;Module Calib Amplitude',
1101  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmpLBdep',
1102  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1103  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_calib_amp_1Nmonitor_xmax)
1104  if (not zdcMonAlg.IsOnline):
1105  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleAmp;zdcModuleAmp_vs_lb', type='TH2F', title=';lumi block;Module Amplitude [ADC counts]',
1106  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLBdep',
1107  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1108  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_amp_1Nmonitor_xmax)
1109  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleFract;zdcModuleFract_above20N_vs_lb', type='TH2F',title=';lumi block;Module Amplitude Fraction',
1110  path='/EXPERT/ZDC/ZdcModule/ModuleFractionLBdep',
1111  cutmask='zdcAbove20NCurrentSide',
1112  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1113  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
1114 
1115  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
1116  zdcModuleMonToolArr.defineHistogram('bcid, zdcModuleCalibAmp', type='TH2F', title=';BCID;Module Calib Amplitude',
1117  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmpBCIDdep',
1118  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
1119  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_calib_amp_1Nmonitor_xmax)
1120 
1121  # ---------------------------- ZDC-module times ----------------------------
1122  if (not zdcMonAlg.IsOnline): #offline - fine binnings
1123  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1124  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1125  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1126  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1127  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1128  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1129  cutmask='zdcModuleLG',
1130  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1131  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1132  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1133  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1134  cutmask='zdcModuleHG',
1135  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1136  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1137  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleCalibTime;zdcModuleCalibTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1138  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1139  cutmask='zdcModuleLG',
1140  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1141  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1142  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleCalibTime;zdcModuleCalibTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1143  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1144  cutmask='zdcModuleHG',
1145  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1146  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1147  else: #online - coarse binnings
1148  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1149  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1150  cutmask='zdcModuleLG',
1151  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
1152  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1153  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
1154  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1155  cutmask='zdcModuleHG',
1156  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
1157  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
1158 
1159  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb_profile', type='TProfile', title=';lumi block;Module Time [ns]',
1160  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1161  cutmask='zdcModuleLGTimeValid',
1162  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max)
1163  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb_profile', type='TProfile', title=';lumi block;Module Time [ns]',
1164  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
1165  cutmask='zdcModuleHGTimeValid',
1166  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max)
1167 
1168 # --------------------------------------------------------------------------------------------------
1169 # ------------------------------------ RPD-channel observables -------------------------------------
1170 # --------------------------------------------------------------------------------------------------
1171 
1172  if (zdcMonAlg.EnableRPDAmp):
1173 
1174  rpdChannelMonToolArr = helper.addArray([sides,channels],zdcMonAlg,'RpdChannelMonitor', topPath = 'ZDC')
1175 
1176  # ---------------------------- amplitudes ----------------------------
1177  rpdChannelMonToolArr.defineHistogram('RPDChannelAmplitudeCalib', title=';RPD Channel Calibrated Amplitude;Events',
1178  path='/SHIFT/RPD/RPDChannel/CalibAmp',
1179  opt='kAlwaysCreate', # always create for shift-needed histograms
1180  cutmask='RPDChannelValid',
1181  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
1182  rpdChannelMonToolArr.defineHistogram('RPDChannelMaxADC', title=';Max ADC [ADC Counts];Events',
1183  path='/EXPERT/RPD/RPDChannel/MaxADC',
1184  cutmask='RPDChannelValid',
1185  xbins=n_energy_bins_default,xmin=0.0,xmax=module_FPGA_max_ADC)
1186 
1187  if (not zdcMonAlg.IsOnline):
1188  rpdChannelMonToolArr.defineHistogram('RPDChannelSubAmp', title=';RPD Channel Subtracted Amplitude;Events',
1189  path='/EXPERT/RPD/RPDChannel/SubAmp',
1190  cutmask='RPDChannelCentroidValid',
1191  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
1192 
1193  # max ADC versus sum ADC
1194  if (not zdcMonAlg.IsOnline):
1195  rpdChannelMonToolArr.defineHistogram('RPDChannelAmplitudeCalib,RPDChannelMaxADC', type='TH2F', title=';Sum ADC [ADC Counts];Max ADC [ADC Counts]',
1196  path='/EXPERT/RPD/RPDChannel/MaxADCVsSumADC',
1197  cutmask='RPDChannelValid',
1198  xbins=n_rpd_amp_bins_full_range,xmin=rpd_channel_amp_min,xmax=rpd_sum_adc_max, #change to xmax=20000 for zoomed in
1199  ybins=n_energy_bins_default,ymin=0.0,ymax=module_FPGA_max_ADC) # change to ymax=3000.0 for zoomed in
1200  # ---------------------------- timing (max sample) ----------------------------
1201  rpdChannelMonToolArr.defineHistogram('RPDChannelMaxSample', title=';Max Sample;Events',
1202  path='/EXPERT/RPD/RPDChannel/MaxSample',
1203  cutmask='RPDChannelValid',
1204  xbins=24,xmin=0.0,xmax=24.)
1205 
1206 
1207  # ---------------------------- status bits ----------------------------
1208  rpdChannelMonToolArr.defineHistogram('RPDStatusBits',title=';;Events',
1209  path='/EXPERT/RPD/RPDChannel/StatusBits',
1210  xbins=nRpdStatusBits,xmin=0,xmax=nRpdStatusBits,
1211  opt='kVec',
1212  xlabels=['ValidBit', 'OutOfTimePileupBit', 'OverflowBit', 'PrePulseBit', 'PostPulseBit', 'NoPulseBit', 'BadAvgBaselineSubtrBit', 'InsufficientPileupFitPointsBit', 'PileupStretchedExpFitFailBit', 'PileupStretchedExpGrowthBit', 'PileupBadStretchedExpSubtrBit', 'PileupExpFitFailBit', 'PileupExpGrowthBit', 'PileupBadExpSubtrBit', 'PileupStretchedExpPulseLike'])
1213 
1214  rpdChannelMonToolArr.defineHistogram('RPDChannelValidBitFloat;RPDChannelValidBit',title='RPD Channel valid bit;;Events',
1215  path='/SHIFT/RPD/RPDChannel/StatusBits',
1216  opt='kAlwaysCreate', # always create for shift-needed histograms
1217  xbins=2,xmin=0,xmax=2,
1218  xlabels=['Valid','Invalid'])
1219 
1220  # ---------------------------- LB dependence ----------------------------
1221  if (not zdcMonAlg.IsOnline): #offline
1222  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelAmplitudeCalib;RPDChannelAmplitudeCalib_vs_lb', type='TH2F', title=';lumi block;RPD Channel Calibrated Amplitude',
1223  path='/EXPERT/RPD/RPDChannel/CalibAmpLBdep',
1224  cutmask='RPDChannelValid',
1225  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1226  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
1227  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelMaxADC;RPDChannelMaxADC_vs_lb', type='TH2F', title=';lumi block;Max ADC [ADC Counts]',
1228  path='/EXPERT/RPD/RPDChannel/MaxADCLBdep',
1229  cutmask='RPDChannelValid',
1230  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
1231  ybins=n_energy_bins_default,ymin=0.0,ymax=module_FPGA_max_ADC)
1232  else: #online
1233  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelAmplitudeCalib;RPDChannelAmplitudeCalib_vs_lb', type='TH2F', title=';lumi block;RPD Channel Calibrated Amplitude',
1234  path='/EXPERT/RPD/RPDChannel/CalibAmpLBdep',
1235  cutmask='RPDChannelValid',
1236  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
1237  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
1238  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelMaxADC;RPDChannelMaxADC_vs_lb', type='TH2F', title=';lumi block;Max ADC [ADC Counts]',
1239  path='/EXPERT/RPD/RPDChannel/MaxADCLBdep',
1240  cutmask='RPDChannelValid',
1241  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
1242  ybins=n_energy_bins_default,ymin=0.0,ymax=module_FPGA_max_ADC)
1243 
1244 
1245 
1249  acc = helper.result()
1250  result.merge(acc)
1251  return result
1252 
1253 if __name__=='__main__':
1254  # Setup logs
1255  from AthenaCommon.Logging import log
1256  from AthenaCommon.Constants import WARNING
1257  log.setLevel(WARNING)
1258 
1259  # Set the Athena configuration flags
1260  from AthenaConfiguration.AllConfigFlags import initConfigFlags
1262  directory = ''
1263  inputfile = 'AOD.pool.root'
1264  flags.Input.Files = [directory+inputfile]
1265  # flags.Input.isMC = False
1266  parser = flags.getArgumentParser()
1267  parser.add_argument('--datasetTag',default="HI2023",help="dataset tag")
1268  parser.add_argument('--runNumber',default=None,help="specify to select a run number")
1269  parser.add_argument('--streamTag',default="ZDCCalib",help="ZDCCalib or MinBias")
1270  parser.add_argument('--outputHISTFile',default=None,help="specify output HIST file name")
1271  args = flags.fillFromArgs(parser=parser)
1272 
1273  flags.DQ.useTrigger = False if flags.Input.isMC else True # isMC is autoconfigured from the input file; if MC: turn trigger off
1274  if args.runNumber is not None: # streamTag has default but runNumber doesn't
1275  flags.Output.HISTFileName = f'ZdcMonitorOutput_{args.datasetTag}_{args.streamTag}_{args.runNumber}.root'
1276  else:
1277  flags.Output.HISTFileName = f'ZdcMonitorOutput_{args.datasetTag}_{args.streamTag}.root'
1278 
1279  if args.outputHISTFile is not None: # overwrite the output HIST file name to be match the name set in the grid job
1280  flags.Output.HISTFileName = f'{args.outputHISTFile}'
1281  flags.lock()
1282 
1283  print('Output', flags.Output.HISTFileName)
1284  # Initialize configuration object, add accumulator, merge, and run.
1285  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
1286  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
1287  cfg = MainServicesCfg(flags)
1288  cfg.merge(PoolReadCfg(flags))
1289 
1290  zdcMonitorAcc = ZdcMonitoringConfig(flags)
1291  cfg.merge(zdcMonitorAcc)
1292 
1293  # If you want to turn on more detailed messages ...
1294  # zdcMonitorAcc.getEventAlgo('ZdcMonAlg').OutputLevel = 2 # DEBUG
1295  # If you want fewer messages ...
1296  # zdcMonitorAcc.getEventAlgo('ZdcMonAlg').OutputLevel = 4 # WARNING
1297  cfg.printConfig(withDetails=False) # set True for exhaustive info
1298 
1299  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:50
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:342
ZdcMonitorAlgorithm.create_log_bins
def create_log_bins(min_value, max_value, num_bins)
Definition: ZdcMonitorAlgorithm.py:20
ZdcMonitorAlgorithm.create_vinj_bins
def create_vinj_bins()
Definition: ZdcMonitorAlgorithm.py:29
ZdcMonitorAlgorithm.create_lg_fit_amp_inj_bins
def create_lg_fit_amp_inj_bins()
Definition: ZdcMonitorAlgorithm.py:65
ZdcInjPulserVoltageReader.load_voltage_steps
def load_voltage_steps(run_number, voltage_values, voltage_strings, file_path="/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/ZdcConditions/INJpulser_combined_2024.json")
Definition: ZdcInjPulserVoltageReader.py:9
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:310
Constants
some useful constants -------------------------------------------------—
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.AtlasReadyFilterConfig.AtlasReadyFilterCfg
def AtlasReadyFilterCfg(flags)
Definition: AtlasReadyFilterConfig.py:10
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
ZdcMonitorAlgorithm.ZdcMonitoringConfig
def ZdcMonitoringConfig(inputFlags)
Definition: ZdcMonitorAlgorithm.py:83
python.ZdcRecConfig.SetConfigTag
def SetConfigTag(flags)
Definition: ZdcRecConfig.py:93
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71