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 def create_log_bins(min_value, max_value, num_bins):
19  # Calculate the logarithmic bin edges
20  log_min = np.log10(min_value)
21  log_max = np.log10(max_value)
22  log_bin_edges = np.linspace(log_min, log_max, num_bins + 1)
23  bin_edges = [10 ** edge for edge in log_bin_edges]
24 
25  return bin_edges
26 
27 
28 def ZdcMonitoringConfig(inputFlags):
29 
30  from AthenaMonitoring import AthMonitorCfgHelper
31  helper = AthMonitorCfgHelper(inputFlags,'ZdcAthMonitorCfg')
32 
33  from AthenaConfiguration.ComponentFactory import CompFactory
34  zdcMonAlg = helper.addAlgorithm(CompFactory.ZdcMonitorAlgorithm,'ZdcMonAlg')
35 
36  from ZdcRec.ZdcRecConfig import SetConfigTag
37  config = SetConfigTag(inputFlags)
38  print ('ZdcMonitorAlgorithm.py: Running with config tag ', config)
39 
40  # Edit properties of a algorithm
41  zdcMonAlg.EnableTrigger = inputFlags.DQ.useTrigger # added for online: enable trigger if we are running in ATLAS partition (DQ.useTrigger flag not set offline)
42  zdcMonAlg.CalInfoOn = inputFlags.Input.TriggerStream == 'physics_MinBias' or inputFlags.Input.TriggerStream == 'express_express' # turn calorimeter info on if input triggerstream (autoconfigured from input file) is physics_MinBias or express_express
43  zdcMonAlg.IsOnline = inputFlags.Common.isOnline # if running online select a subset of histograms & use coarser binnings
44  zdcMonAlg.IsInjectedPulse = inputFlags.Input.TriggerStream == 'calibration_ZDCInjCalib' or inputFlags.Input.TriggerStream == 'calibration_DcmDummyProcessor'
45  zdcMonAlg.IsStandalone = inputFlags.Input.TriggerStream == 'calibration_DcmDummyProcessor'
46  zdcMonAlg.IsPPMode = 'pp' in config
47 
48  zdcMonAlg.EnableZDC = inputFlags.Detector.EnableZDC_ZDC
49  zdcMonAlg.EnableZDCPhysics = zdcMonAlg.EnableZDC and not zdcMonAlg.IsInjectedPulse # no physical pulse (neutrons) for injector pulse
50  zdcMonAlg.EnableRPD = inputFlags.Detector.EnableZDC_RPD and not zdcMonAlg.IsInjectedPulse
51  zdcMonAlg.EnableRPDAmp = zdcMonAlg.EnableRPD
52  zdcMonAlg.EnableCentroid = zdcMonAlg.EnableRPD
53 
54  print ("ZdcMonitorAlgorithm.py: IsInjectedPulse? ",zdcMonAlg.IsInjectedPulse)
55  print ("ZdcMonitorAlgorithm.py: IsPPMode? ",zdcMonAlg.IsPPMode)
56 
57 # --------------------------------------------------------------------------------------------------
58  # Configure histograms
59 
60  # (potentially run-type dependent) range settings
61  lumi_block_max = 2000
62  n_lumi_block_bins_coarse = 200
63  bcid_max = 3564
64  n_energy_bins_default = 200
65  n_fpga_bins = 204
66  n_time_centroid_bins_default = 100
67  n_module_amp_coarse_bins = 100
68  n_module_amp_fine_bins = 200
69  n_mod_fraction_bins_default = 100
70 
71  n_HG_LG_amp_ratio_bins = 120
72  n_HG_LG_time_diff_bins = 50
73 
74  module_chisq_min = 0.1
75  module_chisq_max = 800000
76  module_chisq_nbins = 80
77  module_chisq_over_amp_min = 0.01
78  module_chisq_over_amp_max = 5000
79  module_chisq_over_amp_nbins = 80
80 
81  # to ensure the logarithmic binning in C++ algorithm agrees with python
82  # so that the inverse-bin-width weight calculation is correct
83  zdcMonAlg.ZDCModuleChisqHistMinValue = module_chisq_min
84  zdcMonAlg.ZDCModuleChisqHistMaxvalue = module_chisq_max
85  zdcMonAlg.ZDCModuleChisqHistNumBins = module_chisq_nbins
86  zdcMonAlg.ZDCModuleChisqOverAmpHistMinValue = module_chisq_over_amp_min
87  zdcMonAlg.ZDCModuleChisqOverAmpHistMaxvalue = module_chisq_over_amp_max
88  zdcMonAlg.ZDCModuleChisqOverAmpHistNumBins = module_chisq_over_amp_nbins
89 
90 
91  pulse_voltage_max = 2.5
92  module_FPGA_max_ADC = 4096. # For zoomed-in HG monitoring
93  amp_LG_refit_max_ADC = module_FPGA_max_ADC if zdcMonAlg.IsPPMode else module_FPGA_max_ADC / 10.
94 
95  if config == "LHCf2022":
96  print ("looking at 2022 lhcf data")
97  energy_sum_xmax = 3000
98  energy_sum_zoomin_xmax = 3000
99  uncalib_amp_sum_zoomin_xmax = 3000
100  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
101  x_centroid_min = -500 #small amplitude sum --> large range for x, y position
102  x_centroid_max = 500
103  y_centroid_min = -50
104  y_centroid_max = 750
105  zdc_amp_sum_xmax = 3000
106  rpd_channel_amp_min = - 200.
107  rpd_amp_sum_xmax = 3000
108  rpd_max_adc_sum_xmax = 3000
109  module_amp_xmax = 2000
110  rpd_sum_adc_max = 5000
111  module_calib_amp_xmax = 5000
112  module_amp_1Nmonitor_xmax = 2000 #about 5N / 4 * 2.7TeV
113  module_calib_amp_1Nmonitor_xmax = 5000 #about 5N / 4 * 2.7TeV
114 
115  elif config == "pp2023" or config == "pp2024" or config == "Injectorpp2024":
116  print ("looking at pp reference run")
117  energy_sum_xmax = 5000
118  energy_sum_zoomin_xmax = 5000
119  uncalib_amp_sum_zoomin_xmax = 5000
120  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
121  x_centroid_min = -500 #small amplitude sum --> large range for x, y position
122  x_centroid_max = 500
123  y_centroid_min = -50
124  y_centroid_max = 750
125  zdc_amp_sum_xmax = 5000
126  rpd_channel_amp_min = - 200.
127  rpd_amp_sum_xmax = 5000
128  rpd_max_adc_sum_xmax = 5000
129  module_amp_xmax = 4096
130  rpd_sum_adc_max = 5000.
131  module_calib_amp_xmax = 5000
132  module_amp_1Nmonitor_xmax = 2000 #about 5N / 4 * 2.7TeV
133  module_calib_amp_1Nmonitor_xmax = 5000 #about 5N / 4 * 2.7TeV
134 
135 
136  elif config == "PbPb2023" or config == "PbPb2024" or config == "InjectorPbPb2024":
137  print ("looking at pbpb run")
138  energy_sum_xmax = 200000.0
139  energy_sum_zoomin_xmax = 13000.0
140  uncalib_amp_sum_zoomin_xmax = 6000.0
141  time_in_data_buffer = 75. #75 ns (3 BCID's) in buffer
142  x_centroid_min = -20 #small amplitude sum --> large range for x, y position
143  x_centroid_max = 20
144  y_centroid_min = -20
145  y_centroid_max = 20
146  zdc_amp_sum_xmax = 163840.0
147  rpd_channel_amp_min = - 2000.
148  rpd_amp_sum_xmax = 245760.0 #not the full range but a reasonable value
149  rpd_max_adc_sum_xmax = 40960.0
150  module_amp_xmax = 40960.0
151  rpd_sum_adc_max = 25000.
152  module_calib_amp_xmax = 100000.0 #about the full dynamic range: 160 N / 4 * 2.5TeV
153  module_amp_1Nmonitor_xmax = 1250.0 #about 5N / 4 * 2.7TeV
154  module_calib_amp_1Nmonitor_xmax = 3400.0 #about 5N / 4 * 2.7TeV
155 
156 
157  hg_lg_amp_ratio_min_loose = 0.6 if zdcMonAlg.IsPPMode else 0.06
158  hg_lg_amp_ratio_min_nominal = 0.7 if zdcMonAlg.IsPPMode else 0.07
159  hg_lg_amp_ratio_min_tight = 0.9 if zdcMonAlg.IsPPMode else 0.09
160  hg_lg_amp_ratio_max_loose = 1.4 if zdcMonAlg.IsPPMode else 0.14
161  hg_lg_amp_ratio_max_nominal = 1.3 if zdcMonAlg.IsPPMode else 0.13
162  hg_lg_amp_ratio_max_tight = 1.2 if zdcMonAlg.IsPPMode else 0.12
163 
164  # #bins for RPD channel amplitude, including negative values - determined by the ratio between the negative amplitude range & positive amplitude range
165  rpd_sub_amp_min = - module_amp_xmax / 4.
166  rpd_sub_amp_max = module_amp_xmax / 2.
167  n_rpd_amp_bins_full_range = int((abs(rpd_channel_amp_min) + rpd_sum_adc_max) / rpd_sum_adc_max * n_energy_bins_default)
168  n_rpd_sub_amp_bins = int((abs(rpd_sub_amp_min) + rpd_sub_amp_max) / rpd_sub_amp_max * n_energy_bins_default)
169 
170 # --------------------------------------------------------------------------------------------------
171 # ----------------------------------- General ZDC observables -----------------------------------
172 # --------- Event-level observables / decoding error monitoring / A-C side correlations ---------
173 # --------------------------------------------------------------------------------------------------
174 
175  genZdcMonTool = helper.addGroup(zdcMonAlg, 'genZdcMonTool', topPath = 'ZDC')
176 
177  nDecodingErrorBits = 3
178 
179  genZdcMonTool.defineHistogram('decodingErrorBits',title=';;Events',
180  path='/EXPERT/Global/DecodingErrors',
181  xbins=nDecodingErrorBits,xmin=0.0,xmax=nDecodingErrorBits,opt='kVec',
182  xlabels=['No Decoding Error', 'ZDC Decoding Error', 'RPD Decoding Error'])
183 
184  if (zdcMonAlg.EnableZDCPhysics):
185  genZdcMonTool.defineHistogram('zdcEnergySumA, zdcEnergySumC', type='TH2F', title=';E_{ZDC,A} [GeV];E_{ZDC,C} [GeV]',
186  path='/EXPERT/Global/SideACCorr',
187  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
188  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_xmax)
189 
190  if (zdcMonAlg.EnableCentroid):
191  genZdcMonTool.defineHistogram('rpdCosDeltaReactionPlaneAngle', title=';Cos (#Delta #phi_{AorC});Events',
192  path='/EXPERT/Global/ReactionPlane',
193  cutmask='bothHasCentroid', # only require both sides to have centroid
194  xbins=n_time_centroid_bins_default,xmin=-1,xmax=1)
195  if (not zdcMonAlg.IsOnline):
196  genZdcMonTool.defineHistogram('rpdCosDeltaReactionPlaneAngle;rpdCosDeltaReactionPlaneAngle_requireValid', title=';Cos (#Delta #phi_{AorC});Events',
197  path='/EXPERT/Global/ReactionPlane',
198  cutmask='bothReactionPlaneAngleValid', # require centroid calculation on both sides to be valid
199  xbins=n_time_centroid_bins_default,xmin=-1,xmax=1)
200 
201  # FCal E_T vs ZDC E_T
202  # to be run on min bias stream
203  if (zdcMonAlg.CalInfoOn):
204  genZdcMonTool.defineHistogram('fcalEtA, fcalEtC', type='TH2F', title=';E_{FCal, A} [GeV];E_{FCal, C} [GeV]',
205  path='/EXPERT/Global/SideACCorr',
206  xbins=n_energy_bins_default,xmin=0.0,xmax=5000,
207  ybins=n_energy_bins_default,ymin=0.0,ymax=5000)
208 
209 # --------------------------------------------------------------------------------------------------
210  sides = ["C","A"]
211  modules = ["0","1","2","3"]
212  channels = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"]
213 
214  nZdcStatusBits = 18
215  nRpdStatusBits = 15
216  nRpdCentroidStatusBits = 21
217 
218 # --------------------------------------------------------------------------------------------------
219 # ---------------------------------- Per-ZDC-arm/side observables ----------------------------------
220 # --------------------------------------------------------------------------------------------------
221 
222  if (zdcMonAlg.EnableZDCPhysics or zdcMonAlg.EnableRPDAmp or zdcMonAlg.EnableCentroid):
223 
224  zdcSideMonToolArr = helper.addArray([sides],zdcMonAlg,'ZdcSideMonitor', topPath = 'ZDC')
225 
226 
227  # ---------------------------- Calorimeter per-arm variables ----------------------------
228  # ---------------------------- Calorimeter energy/amplitude sum ----------------------------
229  if (zdcMonAlg.EnableZDCPhysics):
230  zdcSideMonToolArr.defineHistogram('zdcEnergySum',title='ZDC Side {0} Energy Sum;Side {0} Energy [GeV];Events',
231  path='/EXPERT/ZDC/PerArm/Energy',
232  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax) # 2.5TeV * 80 neutrons
233  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_wTrigSelec',title='ZDC Side {0} Energy Sum (few neutrons, require opposite-side trigger);Side {0} Energy[GeV];Events',
234  path='/SHIFT/ZDC/PerArm/Energy',
235  cutmask = 'passTrigOppSide',
236  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_zoomin_xmax) # 2.5TeV * 8 neutrons
237  zdcSideMonToolArr.defineHistogram('zdcEnergySum;zdcEnergySum_zoomin_noTrigSelec',title='ZDC Side {0} Energy Sum (few neutrons, no trigger selection);Side {0} Energy[GeV];Events',
238  path='/SHIFT/ZDC/PerArm/Energy',
239  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_zoomin_xmax) # 2.5TeV * 8 neutrons
240 
241  zdcSideMonToolArr.defineHistogram('zdcUncalibSum',title='ZDC Side {0} Uncalibrated Sum;[ADC];Events',
242  path='/EXPERT/ZDC/PerArm/UncalibAmp',
243  xbins=n_energy_bins_default,xmin=0.0,xmax=zdc_amp_sum_xmax)
244 
245  # ---------------------------- Calorimeter energy/amplitude sum: LB dependence ----------------------------
246  if (not zdcMonAlg.IsOnline): # offline - use fine LB binnings
247  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_noTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
248  path='/EXPERT/ZDC/PerArm/Energy',
249  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
250  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
251  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_wTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
252  path='/EXPERT/ZDC/PerArm/Energy',
253  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
254  cutmask = 'passTrigOppSide',
255  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
256  else: # online - use coarse LB binnings
257  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_noTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
258  path='/EXPERT/ZDC/PerArm/Energy',
259  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
260  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
261  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcEnergySum;zdcEnergySum_vs_lb_wTrig', type='TH2F', title=';lumi block;Side {0} Energy [GeV]',
262  path='/EXPERT/ZDC/PerArm/Energy',
263  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
264  cutmask = 'passTrigOppSide',
265  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
266 
267  if (not zdcMonAlg.IsOnline): #only offline
268  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcUncalibSum;zdcUncalibSum_vs_lb_noTrig', type='TH2F', title=';lumi block;ZDC Side {0} Uncalibrated Sum [ADC]',
269  path='/EXPERT/ZDC/PerArm/UncalibAmp',
270  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
271  ybins=n_energy_bins_default,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
272  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcUncalibSum;zdcUncalibSum_vs_lb_wTrig', type='TH2F', title=';lumi block;ZDC Side {0} Uncalibrated Sum [ADC]',
273  path='/EXPERT/ZDC/PerArm/UncalibAmp',
274  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
275  cutmask = 'passTrigOppSide',
276  ybins=n_energy_bins_default,ymin=0.0,ymax=uncalib_amp_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
277 
278  # ---------------------------- Calorimeter energy/amplitude sum: BCID dependence ----------------------------
279  if (not zdcMonAlg.IsOnline): #only offline
280  zdcSideMonToolArr.defineHistogram('bcid, zdcEnergySum;zdcEnergySum_vs_bcid_noTrig', type='TH2F', title=';BCID;Side {0} Energy [GeV]',
281  path='/EXPERT/ZDC/PerArm/Energy',
282  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
283  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
284  zdcSideMonToolArr.defineHistogram('bcid, zdcEnergySum;zdcEnergySum_vs_bcid_wTrig', type='TH2F', title=';BCID;Side {0} Energy [GeV]',
285  path='/EXPERT/ZDC/PerArm/Energy',
286  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
287  cutmask = 'passTrigOppSide',
288  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_zoomin_xmax) # for lumi dependence, only focus on the few-neutron peaks
289 
290  if (zdcMonAlg.CalInfoOn):
291  zdcSideMonToolArr.defineHistogram('fcalEt, zdcEnergySum', type='TH2F', title=';Side {0} FCal Energy [GeV];Side {0} ZDC Energy [GeV]',
292  path='/EXPERT/ZDC/PerArm/ZDCFcalCorr',
293  xbins=n_energy_bins_default,xmin=0.0,xmax=5000,
294  ybins=n_energy_bins_default,ymin=0.0,ymax=energy_sum_xmax)
295 
296  # ---------------------------- Calorimeter average time & LB dependence ----------------------------
297 
298  zdcSideMonToolArr.defineHistogram('zdcAvgTime',title='ZDC Side Average Time;t[ns];Events', cutmask = 'zdcModuleMask',
299  path='/EXPERT/ZDC/PerArm/AvgTime',
300  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
301 
302  if (not zdcMonAlg.IsOnline): #only offline
303  zdcSideMonToolArr.defineHistogram('lumiBlock, zdcAvgTime;zdcAvgTime_vs_lb', type='TH2F', title=';ZDC Side Average Time versus Lumi block;lumi block;t[ns]',
304  path='/EXPERT/ZDC/PerArm/AvgTime',
305  cutmask = 'zdcModuleMask',
306  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
307  ybins=n_time_centroid_bins_default,ymin=-10.0,ymax=10.0)
308 
309  # ---------------------------- RPD (centroid-related) per-arm variables ----------------------------
310  # ---------------------------- centroid status ----------------------------
311  zdcSideMonToolArr.defineHistogram('centroidStatusBits',title=';;Events',
312  path='/EXPERT/RPD/PerArm/Centroid',
313  xbins=nRpdCentroidStatusBits,xmin=0.0,xmax=nRpdCentroidStatusBits,opt='kVec',
314  xlabels=['ValidBit', 'HasCentroidBit', 'ZDCInvalidBit', 'InsufficientZDCEnergyBit', 'ExcessiveZDCEnergyBit', 'EMInvalidBit', 'InsufficientEMEnergyBit', 'ExcessiveEMEnergyBit', 'RPDInvalidBit', 'PileupBit', 'ExcessivePileupBit', 'ZeroSumBit', 'ExcessiveSubtrUnderflowBit', 'Row0ValidBit', 'Row1ValidBit', 'Row2ValidBit', 'Row3ValidBit', 'Col0ValidBit', 'Col1ValidBit', 'Col2ValidBit', 'Col3ValidBit'])
315 
316  zdcSideMonToolArr.defineHistogram('centroidValidBitFloat;centroidValidBit_RequireMinZDCEnergy',title='Centroid valid bit;;Events',
317  path='/SHIFT/RPD/PerArm/Centroid',
318  cutmask='passMinZDCEnergyCutForCentroidValidEvaluation',
319  xbins=2,xmin=0,xmax=2,
320  xlabels=['Valid','Invalid'])
321 
322  # ---------------------------- x, y centroid & reaction plane angle requiring centroid ValidBit ----------------------------
323  zdcSideMonToolArr.defineHistogram('xCentroid',title=';Centroid x position [mm];Events',
324  path='/SHIFT/RPD/PerArm/Centroid',
325  cutmask='centroidValid',
326  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max)
327 
328  zdcSideMonToolArr.defineHistogram('yCentroid',title=';Centroid y position [mm];Events',
329  path='/SHIFT/RPD/PerArm/Centroid',
330  cutmask='centroidValid',
331  xbins=n_time_centroid_bins_default,xmin=y_centroid_min,xmax=y_centroid_max)
332 
333  zdcSideMonToolArr.defineHistogram('xCentroid, yCentroid',type='TH2F',title=';Centroid x position [mm];Centroid y position [mm]',
334  path='/EXPERT/RPD/PerArm/Centroid',
335  cutmask='centroidValid',
336  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max,
337  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
338 
339  zdcSideMonToolArr.defineHistogram('ReactionPlaneAngle',title=';Reaction Plane Angle;Events',
340  path='/EXPERT/RPD/PerArm/ReactionPlane',
341  cutmask='centroidValid',
342  xbins=64,xmin=-3.141593,xmax=3.141593)
343 
344  # ---------------------------- x, y centroid & reaction plane angle requiring only HasCentroidBit ----------------------------
345 
346  if (not zdcMonAlg.IsOnline): #only offline
347  zdcSideMonToolArr.defineHistogram('xCentroid, yCentroid;yCentroid_vs_xCentroid_requireOnlyHasCentroidBit',type='TH2F',title=';Centroid x position [mm];Centroid y position [mm]',
348  path='/EXPERT/RPD/PerArm/Centroid',
349  xbins=n_time_centroid_bins_default,xmin=x_centroid_min,xmax=x_centroid_max,
350  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
351  zdcSideMonToolArr.defineHistogram('ReactionPlaneAngle;ReactionPlaneAngle_requireOnlyHasCentroidBit',title=';Reaction Plane Angle;Events',
352  path='/EXPERT/RPD/PerArm/ReactionPlane',
353  xbins=64,xmin=-3.141593,xmax=3.141593)
354 
355 
356  # ---------------------------- Centroid LB dependence ----------------------------
357  if (not zdcMonAlg.IsOnline): #only offline
358  zdcSideMonToolArr.defineHistogram('lumiBlock, xCentroid;xCentroid_vs_lb_requireOnlyHasCentroidBit', type='TH2F', title=';lumi block;Centroid x position [mm]',
359  path='/EXPERT/RPD/PerArm/CentroidLBdep',
360  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
361  ybins=n_time_centroid_bins_default,ymin=x_centroid_min,ymax=x_centroid_max)
362  zdcSideMonToolArr.defineHistogram('lumiBlock, yCentroid;yCentroid_vs_lb_requireOnlyHasCentroidBit', type='TH2F', title=';lumi block;Centroid y position [mm]',
363  path='/EXPERT/RPD/PerArm/CentroidLBdep',
364  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
365  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
366 
367  zdcSideMonToolArr.defineHistogram('lumiBlock, xCentroid;xCentroid_vs_lb', type='TH2F', title=';lumi block;Centroid x position [mm]',
368  path='/EXPERT/RPD/PerArm/CentroidLBdep',
369  cutmask='centroidValid',
370  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
371  ybins=n_time_centroid_bins_default,ymin=x_centroid_min,ymax=x_centroid_max)
372  zdcSideMonToolArr.defineHistogram('lumiBlock, yCentroid;yCentroid_vs_lb', type='TH2F', title=';lumi block;Centroid y position [mm]',
373  path='/EXPERT/RPD/PerArm/CentroidLBdep',
374  cutmask='centroidValid',
375  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
376  ybins=n_time_centroid_bins_default,ymin=y_centroid_min,ymax=y_centroid_max)
377 
378  # ---------------------------- ZDC-RPD correlations ----------------------------
379  zdcSideMonToolArr.defineHistogram('zdcEnergySum, rpdMaxADCSum', type='TH2F', title=';E ZDC side [TeV];RPD Max ADC Sum (AorC) [ADC counts]',
380  path='/EXPERT/ZdcRpdPerSideCorr',
381  cutmask='RPDSideValid',
382  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
383  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_max_adc_sum_xmax) # try a value for now
384  zdcSideMonToolArr.defineHistogram('zdcEnergySum, rpdAmplitudeCalibSum', type='TH2F', title=';E ZDC side [GeV];RPD Calib Amp Sum (AorC) [ADC counts]',
385  path='/EXPERT/ZdcRpdPerSideCorr',
386  cutmask='RPDSideValid',
387  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
388  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_amp_sum_xmax) # try a value for now
389  zdcSideMonToolArr.defineHistogram('zdcEMModuleEnergySameSide, rpdAmplitudeCalibSum', type='TH2F', title=';E EM module AorC [GeV];RPD Calib Amp Sum (AorC) [ADC counts]',
390  path='/EXPERT/ZdcRpdPerSideCorr',
391  cutmask='RPDSideValid',
392  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)
393  ybins=n_energy_bins_default,ymin=0.0,ymax=rpd_amp_sum_xmax) # try a value for now
394 
395 # --------------------------------------------------------------------------------------------------
396 # ------------------------------------- ZDC-module observables -------------------------------------
397 # --------------------------------------------------------------------------------------------------
398 
399 
400  zdcModuleMonToolArr = helper.addArray([sides,modules],zdcMonAlg,'ZdcModuleMonitor', topPath = 'ZDC')
401 
402  # ---------------------------- ZDC-module status ----------------------------
403 
404  zdcModuleMonToolArr.defineHistogram('zdcStatusBits',title=';;Events',
405  path='/SHIFT/ZDC/ZdcModule/ModuleStatusBits',
406  xbins=nZdcStatusBits,xmin=0.0,xmax=nZdcStatusBits,opt='kVec',
407  xlabels=['PulseBit', 'LowGainBit', 'FailBit', 'HGOverflowBit', 'HGUnderflowBit', 'PSHGOverUnderflowBit', 'LGOverflowBit', 'LGUnderflowBit', 'PrePulseBit', 'PostPulseBit', 'FitFailedBit', 'BadChisqBit', 'BadT0Bit', 'ExcludeEarlyLGBit', 'ExcludeLateLGBit', 'preExpTailBit', 'FitMinAmpBit', 'RepassPulseBit'])
408 
409  # ---------------------------- ZDC-module amplitudes & amplitude fractions ----------------------------
410 
411  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp',title=';Module Amplitude [ADC Counts];Events',
412  path='/SHIFT/ZDC/ZdcModule/ModuleAmp',
413  xbins=n_fpga_bins * 2,xmin=0.0,xmax=module_amp_xmax)
414 
415  zdcModuleMonToolArr.defineHistogram('zdcModuleMaxADC',title=';Module Max ADC;Events',
416  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADC',
417  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax)
418 
419 
420  if (not zdcMonAlg.IsPPMode): # for PP mode data, LG never filled
421  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_LG',title=';Module Amplitude LG [ADC Counts];Events',
422  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
423  cutmask='zdcModuleLG', # require to use LG
424  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax)
425 
426  if (zdcMonAlg.IsInjectedPulse):
427  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit',title=';LG-Refit Amplitude [ADC Counts];Events',
428  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
429  cutmask='zdcModuleHGValid',
430  xbins=n_fpga_bins,xmin=0.0,xmax=amp_LG_refit_max_ADC)
431 
432  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse): # only offline
433  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_halfrange',title=';Module Amplitude [ADC Counts];Events',
434  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
435  xbins=n_fpga_bins,xmin=0.0,xmax=module_amp_xmax / 2.)
436 
437  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp;zdcModuleAmp_HG',title=';Module Amplitude HG [ADC Counts];Events',
438  path='/EXPERT/ZDC/ZdcModule/ModuleAmp',
439  cutmask='zdcModuleHGValid',
440  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC)
441 
442  if (zdcMonAlg.IsInjectedPulse):
443  zdcModuleMonToolArr.defineHistogram('zdcModuleMaxADC;zdcModuleMaxADC_HG',title=';Module Max ADC HG;Events',
444  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADC',
445  cutmask='zdcModuleHGValid',
446  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC)
447  zdcModuleMonToolArr.defineHistogram('zdcModuleMaxADC,zdcModuleAmpToMaxADCRatio;zdcModuleAmpToMaxADCRatio_vs_zdcModuleMaxADC_profile',type='TProfile',title=';Module Max ADC HG;Avg Amp/Max ADC',
448  path='/EXPERT/ZDC/ZdcModule/ModuleMaxADC',
449  cutmask='zdcModuleHGValid',
450  xbins=n_fpga_bins,xmin=0.0,xmax=module_FPGA_max_ADC)
451 
452  # ---------------------------- ZDC-module amplitude fractions & correlations with energy deposits ----------------------------
453 
454  if (zdcMonAlg.IsInjectedPulse): # no real energy deposit --> do not require minimum ZDC energy
455  zdcModuleMonToolArr.defineHistogram('zdcModuleFract',title=';Module Amplitude Fraction;Events',
456  path='/SHIFT/ZDC/ZdcModule/ModuleFraction',
457  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
458  else:
459  zdcModuleMonToolArr.defineHistogram('zdcModuleFract;zdcModuleFract_above_cut',title=';Module Amplitude Fraction;Events',
460  path='/SHIFT/ZDC/ZdcModule/ModuleFraction',
461  cutmask='zdcEnergyAboveModuleFractCut',
462  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
463  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_fullrange', type='TH2F', title=';ZDC Energy Sum Current Side [GeV];Module Amplitude Fraction',
464  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
465  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax,
466  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
467  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_profile', type='TProfile', title=';ZDC Energy Sum Current Side [GeV];Module Amplitude Fraction',
468  path='/EXPERT/ZDC/ZdcModule/ModuleFractioVsEnergyn',
469  xbins=n_energy_bins_default,xmin=0.0,xmax=energy_sum_xmax)
470  zdcModuleMonToolArr.defineHistogram('zdcEnergySumCurrentSide, zdcModuleFract;zdcModuleFract_vs_zdcEnergySum_zoomedin', type='TH2F', title=';Amplitude Sum Current Side [ADC Counts];Module Amplitude Fraction',
471  path='/EXPERT/ZDC/ZdcModule/ModuleFractionVsEnergy',
472  xbins=n_energy_bins_default,xmin=0.0,xmax=10000,
473  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
474  if (not zdcMonAlg.IsOnline): # only offline
475  zdcModuleMonToolArr.defineHistogram('zdcModuleFract',title=';Module Amplitude Fraction;Events',
476  path='/EXPERT/ZDC/ZdcModule/ModuleFraction',
477  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
478  zdcModuleMonToolArr.defineHistogram('zdcModuleFract;zdcModuleFract_above20N',title=';Module Amplitude Fraction;Events',
479  path='/EXPERT/ZDC/ZdcModule/ModuleFraction',
480  cutmask='zdcAbove20NCurrentSide',
481  xbins=n_mod_fraction_bins_default,xmin=0.0,xmax=1.)
482 
483  if (not zdcMonAlg.IsInjectedPulse):
484  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibAmp',title=';Module Calibrated Amplitude [GeV];Events',
485  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmp',
486  xbins=2*n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax) # 2.5TeV * 40
487 
488  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
489  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibAmp;zdcModuleCalibAmp_halfrange',title=';Module Calibrated Amplitude [GeV];Events',
490  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmp',
491  xbins=2*n_energy_bins_default,xmin=0.0,xmax=module_calib_amp_xmax / 2.) # 2.5TeV * 40
492 
493  # ---------------------------- ZDC-module reco amplitude versus input voltage ----------------------------
494  if (zdcMonAlg.IsInjectedPulse):
495  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleAmp', type='TH2F', title=';Pulse amp [V];Signal Amp [ADC Counts]',
496  path='/EXPERT/ZDC/ZdcModule/ModuleAmpVsInputVoltage',
497  xbins=n_energy_bins_default,xmin=0.0,xmax=pulse_voltage_max,
498  ybins=n_fpga_bins,ymin=0.0,ymax=module_FPGA_max_ADC)
499 
500  zdcModuleMonToolArr.defineHistogram('injectedPulseInputVoltage,zdcModuleAmp;zdcModuleAmp_vs_injectedPulseInputVoltage_profile', type='TProfile', title=';Pulse amp [V];Signal Amp [ADC Counts]',
501  path='/EXPERT/ZDC/ZdcModule/ModuleAmpVsInputVoltage',
502  xbins=n_energy_bins_default,xmin=0.0,xmax=pulse_voltage_max)
503 
504  # ---------------------------- ZDC-module times ----------------------------
505 
506  zdcModuleMonToolArr.defineHistogram('zdcModuleTime',title=';Module Time [ns];Events',
507  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
508  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
509 
510  if (not zdcMonAlg.IsPPMode): # for PP mode, LG never filled
511  zdcModuleMonToolArr.defineHistogram('zdcModuleTime;zdcModuleTime_LG',title=';Module Time [ns];Events',
512  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
513  cutmask='zdcModuleLG',
514  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
515 
516  zdcModuleMonToolArr.defineHistogram('zdcModuleTime;zdcModuleTime_HG',title=';Module Time [ns];Events',
517  path='/SHIFT/ZDC/ZdcModule/ModuleTime',
518  cutmask='zdcModuleHG',
519  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
520 
521  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0',title=';Module FitT0 [ns];Events',
522  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
523  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
524 
525  if (not zdcMonAlg.IsPPMode): # for PP mode, LG never filled
526  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0;zdcModuleFitT0_LG',title=';Module FitT0 LG [ns];Events',
527  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
528  cutmask='zdcModuleLG',
529  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
530 
531  zdcModuleMonToolArr.defineHistogram('zdcModuleFitT0;zdcModuleFitT0_HG',title=';Module FitT0 HG [ns];Events',
532  path='/EXPERT/ZDC/ZdcModule/ModuleFitT0',
533  cutmask='zdcModuleHG',
534  xbins=n_time_centroid_bins_default,xmin=0.0,xmax=time_in_data_buffer)
535 
536 
537  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
538  zdcModuleMonToolArr.defineHistogram('zdcModuleCalibTime',title=';Module Calibrated Time [ns];Events',
539  path='/EXPERT/ZDC/ZdcModule/ModuleCalibTime',
540  xbins=n_time_centroid_bins_default,xmin=-10.0,xmax=10.0)
541 
542  # ---------------------------- ZDC-module pulse-fitting chi squares (pulse fitting goodness) ----------------------------
543 
544  zdcModuleMonToolArr.defineHistogram('zdcModuleChisq',title=';Module Chi-square;Events',
545  path='/EXPERT/ZDC/ZdcModule/ModuleChisq',
546  weight='zdcModuleChisqEventWeight',
547  xbins=create_log_bins(module_chisq_min, module_chisq_max, module_chisq_nbins))
548  zdcModuleMonToolArr.defineHistogram('zdcModuleChisqOverAmp',title=';Module Chi-square / Amplitude;Events',
549  path='/SHIFT/ZDC/ZdcModule/ModuleChisq',
550  weight='zdcModuleChisqOverAmpEventWeight',
551  xbins=create_log_bins(module_chisq_over_amp_min, module_chisq_over_amp_max, module_chisq_over_amp_nbins))
552  if (not zdcMonAlg.IsOnline):
553  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleChisqOverAmp',type='TH2F',title=';Module Amplitude [ADC Counts];Module Chi-square / Amplitude',
554  path='/EXPERT/ZDC/ZdcModule/ModuleChisq',
555  weight='zdcModuleChisqOverAmpEventWeight',
556  xbins=n_energy_bins_default,xmin=0.0,xmax=module_amp_xmax / 2.,
557  ybins=create_log_bins(module_chisq_over_amp_min, module_chisq_over_amp_max, module_chisq_over_amp_nbins))
558 
559 
560  # ---------------------------- LG & HG comparisons ----------------------------
561  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGAmpRatio',title=';Module Amplitude [ADC Counts];Events',
562  path='/SHIFT/ZDC/ZdcModule/ModuleHGLGCompr',
563  cutmask='zdcModuleHGValid',
564  xbins=n_HG_LG_amp_ratio_bins,xmin=hg_lg_amp_ratio_min_loose,xmax=hg_lg_amp_ratio_max_loose)
565 
566  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';ZDC HG Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
567  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
568  cutmask='zdcModuleHGValid',
569  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC,
570  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
571 
572  zdcModuleMonToolArr.defineHistogram('zdcModuleAmp, zdcModuleHGtoLGAmpRatio;zdcModuleHGtoLGAmpRatio_vs_zdcModuleAmp_profile', type='TProfile', title=';ZDC HG Amplitude [ADC Counts];Average HG-to-LG Amplitude Raio;Events',
573  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
574  cutmask='zdcModuleHGValid',
575  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=module_FPGA_max_ADC)
576 
577  if (not zdcMonAlg.IsOnline):
578  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';ZDC LG-Refit Amplitude [ADC Counts];HG-to-LG Amplitude Raio;Events',
579  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
580  cutmask='zdcModuleHGValid',
581  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=amp_LG_refit_max_ADC,
582  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_nominal,ymax=hg_lg_amp_ratio_max_nominal)
583  zdcModuleMonToolArr.defineHistogram('zdcModuleAmpLGRefit, zdcModuleHGtoLGAmpRatio;zdcModuleHGtoLGAmpRatio_vs_zdcModuleAmpLGRefit_profile', type='TProfile', title=';ZDC LG-Refit Amplitude [ADC Counts];Average HG-to-LG Amplitude Raio;Events',
584  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
585  cutmask='zdcModuleHGValid',
586  xbins=n_module_amp_fine_bins, xmin=0.0, xmax=amp_LG_refit_max_ADC)
587 
588  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGT0Diff',title=';HG-LG T0 Difference [ns];Events',
589  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
590  cutmask='zdcModuleHGValid',
591  xbins=n_HG_LG_time_diff_bins,xmin=-10.0,xmax=10.0)
592 
593  zdcModuleMonToolArr.defineHistogram('zdcModuleHGtoLGT0Diff, zdcModuleHGtoLGAmpRatio', type='TH2F', title=';HG-LG T0 Difference [ns];HG-to-LG Amplitude Raio;Events',
594  path='/EXPERT/ZDC/ZdcModule/ModuleHGLGCompr',
595  cutmask='zdcModuleHGValid',
596  xbins=n_HG_LG_time_diff_bins,xmin=2.0,xmax=4.0, # zoomed in to see potential correlations
597  ybins=n_HG_LG_amp_ratio_bins,ymin=hg_lg_amp_ratio_min_tight,ymax=hg_lg_amp_ratio_max_tight)
598 
599 
600  # ---------------------------- LB and BCID-dep ZDC-module-level observables ----------------------------
601  # ---------------------------- ZDC-module amplitudes ----------------------------
602 
603  if (not zdcMonAlg.IsInjectedPulse):
604  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleCalibAmp;zdcModuleCalibAmp_vs_lb', type='TH2F', title=';lumi block;Module Calib Amplitude',
605  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmpLBdep',
606  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
607  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_calib_amp_1Nmonitor_xmax)
608  if (not zdcMonAlg.IsOnline):
609  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleAmp;zdcModuleAmp_vs_lb', type='TH2F', title=';lumi block;Module Amplitude [ADC counts]',
610  path='/EXPERT/ZDC/ZdcModule/ModuleAmpLBdep',
611  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
612  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_amp_1Nmonitor_xmax)
613  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleFract;zdcModuleFract_above20N_vs_lb', type='TH2F',title=';lumi block;Module Amplitude Fraction',
614  path='/EXPERT/ZDC/ZdcModule/ModuleFractionLBdep',
615  cutmask='zdcAbove20NCurrentSide',
616  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
617  ybins=n_mod_fraction_bins_default,ymin=0.0,ymax=1.)
618 
619  if (not zdcMonAlg.IsOnline and not zdcMonAlg.IsInjectedPulse):
620  zdcModuleMonToolArr.defineHistogram('bcid, zdcModuleCalibAmp', type='TH2F', title=';BCID;Module Calib Amplitude',
621  path='/EXPERT/ZDC/ZdcModule/ModuleCalibAmpBCIDdep',
622  xbins=bcid_max,xmin=0.0,xmax=bcid_max,
623  ybins=n_module_amp_coarse_bins, ymin=0.0, ymax=module_calib_amp_1Nmonitor_xmax)
624 
625  # ---------------------------- ZDC-module times ----------------------------
626 
627  if (not zdcMonAlg.IsOnline): #offline - fine binnings
628  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
629  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
630  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
631  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
632  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
633  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
634  cutmask='zdcModuleLG',
635  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
636  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
637  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
638  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
639  cutmask='zdcModuleHG',
640  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
641  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
642  else: #online - coarse binnings
643  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
644  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
645  cutmask='zdcModuleLG',
646  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
647  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
648  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb', type='TH2F', title=';lumi block;Module Time [ns]',
649  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
650  cutmask='zdcModuleHG',
651  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
652  ybins=n_time_centroid_bins_default, ymin=-10.0, ymax=10.0)
653 
654  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_LG_vs_lb_profile', type='TProfile', title=';lumi block;Module Time [ns]',
655  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
656  cutmask='zdcModuleLG',
657  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max)
658  zdcModuleMonToolArr.defineHistogram('lumiBlock, zdcModuleTime;zdcModuleTime_HG_vs_lb_profile', type='TProfile', title=';lumi block;Module Time [ns]',
659  path='/EXPERT/ZDC/ZdcModule/ModuleTimeLBdep',
660  cutmask='zdcModuleHG',
661  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max)
662 
663 # --------------------------------------------------------------------------------------------------
664 # ------------------------------------ RPD-channel observables -------------------------------------
665 # --------------------------------------------------------------------------------------------------
666 
667  if (zdcMonAlg.EnableRPDAmp):
668 
669  rpdChannelMonToolArr = helper.addArray([sides,channels],zdcMonAlg,'RpdChannelMonitor', topPath = 'ZDC')
670 
671  # ---------------------------- amplitudes ----------------------------
672  rpdChannelMonToolArr.defineHistogram('RPDChannelAmplitudeCalib', title=';RPD Channel Calibrated Amplitude;Events',
673  path='/SHIFT/RPD/RPDChannel/CalibAmp',
674  cutmask='RPDChannelValid',
675  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
676  rpdChannelMonToolArr.defineHistogram('RPDChannelMaxADC', title=';Max ADC [ADC Counts];Events',
677  path='/EXPERT/RPD/RPDChannel/MaxADC',
678  cutmask='RPDChannelValid',
679  xbins=n_energy_bins_default,xmin=0.0,xmax=4096.0)
680 
681  if (not zdcMonAlg.IsOnline):
682  rpdChannelMonToolArr.defineHistogram('RPDChannelSubAmp', title=';RPD Channel Subtracted Amplitude;Events',
683  path='/EXPERT/RPD/RPDChannel/SubAmp',
684  cutmask='RPDChannelCentroidValid',
685  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
686 
687  # max ADC versus sum ADC
688  if (not zdcMonAlg.IsOnline):
689  rpdChannelMonToolArr.defineHistogram('RPDChannelAmplitudeCalib,RPDChannelMaxADC', type='TH2F', title=';Sum ADC [ADC Counts];Max ADC [ADC Counts]',
690  path='/EXPERT/RPD/RPDChannel/MaxADCVsSumADC',
691  cutmask='RPDChannelValid',
692  xbins=n_rpd_amp_bins_full_range,xmin=rpd_channel_amp_min,xmax=rpd_sum_adc_max, #change to xmax=20000 for zoomed in
693  ybins=n_energy_bins_default,ymin=0.0,ymax=4096.0) # change to ymax=3000.0 for zoomed in
694  # ---------------------------- timing (max sample) ----------------------------
695  rpdChannelMonToolArr.defineHistogram('RPDChannelMaxSample', title=';Max Sample;Events',
696  path='/EXPERT/RPD/RPDChannel/MaxSample',
697  cutmask='RPDChannelValid',
698  xbins=24,xmin=0.0,xmax=24.)
699 
700 
701  # ---------------------------- status bits ----------------------------
702  rpdChannelMonToolArr.defineHistogram('RPDStatusBits',title=';;Events',
703  path='/EXPERT/RPD/RPDChannel/StatusBits',
704  xbins=nRpdStatusBits,xmin=0,xmax=nRpdStatusBits,opt='kVec',
705  xlabels=['ValidBit', 'OutOfTimePileupBit', 'OverflowBit', 'PrePulseBit', 'PostPulseBit', 'NoPulseBit', 'BadAvgBaselineSubtrBit', 'InsufficientPileupFitPointsBit', 'PileupStretchedExpFitFailBit', 'PileupStretchedExpGrowthBit', 'PileupBadStretchedExpSubtrBit', 'PileupExpFitFailBit', 'PileupExpGrowthBit', 'PileupBadExpSubtrBit', 'PileupStretchedExpPulseLike'])
706 
707  rpdChannelMonToolArr.defineHistogram('RPDChannelValidBitFloat;RPDChannelValidBit',title='RPD Channel valid bit;;Events',
708  path='/SHIFT/RPD/RPDChannel/StatusBits',
709  xbins=2,xmin=0,xmax=2,
710  xlabels=['Valid','Invalid'])
711 
712  # ---------------------------- LB dependence ----------------------------
713  if (not zdcMonAlg.IsOnline): #offline
714  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelAmplitudeCalib;RPDChannelAmplitudeCalib_vs_lb', type='TH2F', title=';lumi block;RPD Channel Calibrated Amplitude',
715  path='/EXPERT/RPD/RPDChannel/CalibAmpLBdep',
716  cutmask='RPDChannelValid',
717  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
718  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
719  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelMaxADC;RPDChannelMaxADC_vs_lb', type='TH2F', title=';lumi block;Max ADC [ADC Counts]',
720  path='/EXPERT/RPD/RPDChannel/MaxADCLBdep',
721  cutmask='RPDChannelValid',
722  xbins=lumi_block_max,xmin=0.0,xmax=lumi_block_max,
723  ybins=n_energy_bins_default,ymin=0.0,ymax=4096.0)
724  else: #online
725  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelAmplitudeCalib;RPDChannelAmplitudeCalib_vs_lb', type='TH2F', title=';lumi block;RPD Channel Calibrated Amplitude',
726  path='/EXPERT/RPD/RPDChannel/CalibAmpLBdep',
727  cutmask='RPDChannelValid',
728  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
729  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
730  rpdChannelMonToolArr.defineHistogram('lumiBlock, RPDChannelMaxADC;RPDChannelMaxADC_vs_lb', type='TH2F', title=';lumi block;Max ADC [ADC Counts]',
731  path='/EXPERT/RPD/RPDChannel/MaxADCLBdep',
732  cutmask='RPDChannelValid',
733  xbins=n_lumi_block_bins_coarse,xmin=0.0,xmax=lumi_block_max,
734  ybins=n_energy_bins_default,ymin=0.0,ymax=4096.0)
735 
736 
737 
742  return helper.result()
743 
744  # # Otherwise, merge with result object and return
745  # acc = helper.result()
746  # result.merge(acc)
747  # return result
748 
749 if __name__=='__main__':
750  # Setup logs
751  from AthenaCommon.Logging import log
752  from AthenaCommon.Constants import WARNING
753  log.setLevel(WARNING)
754 
755  # Set the Athena configuration flags
756  from AthenaConfiguration.AllConfigFlags import initConfigFlags
757  flags = initConfigFlags()
758  directory = ''
759  inputfile = 'AOD.pool.root'
760  flags.Input.Files = [directory+inputfile]
761  # flags.Input.isMC = False
762  parser = flags.getArgumentParser()
763  parser.add_argument('--datasetTag',default="HI2023",help="dataset tag")
764  parser.add_argument('--runNumber',default=None,help="specify to select a run number")
765  parser.add_argument('--streamTag',default="ZDCCalib",help="ZDCCalib or MinBias")
766  parser.add_argument('--outputHISTFile',default=None,help="specify output HIST file name")
767  args = flags.fillFromArgs(parser=parser)
768 
769  flags.DQ.useTrigger = False if flags.Input.isMC else True # isMC is autoconfigured from the input file; if MC: turn trigger off
770  if args.runNumber is not None: # streamTag has default but runNumber doesn't
771  flags.Output.HISTFileName = f'ZdcMonitorOutput_{args.datasetTag}_{args.streamTag}_{args.runNumber}.root'
772  else:
773  flags.Output.HISTFileName = f'ZdcMonitorOutput_{args.datasetTag}_{args.streamTag}.root'
774 
775  if args.outputHISTFile is not None: # overwrite the output HIST file name to be match the name set in the grid job
776  flags.Output.HISTFileName = f'{args.outputHISTFile}'
777  flags.lock()
778 
779  print('Output', flags.Output.HISTFileName)
780  # Initialize configuration object, add accumulator, merge, and run.
781  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
782  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
783  cfg = MainServicesCfg(flags)
784  cfg.merge(PoolReadCfg(flags))
785 
786  zdcMonitorAcc = ZdcMonitoringConfig(flags)
787  cfg.merge(zdcMonitorAcc)
788 
789  # If you want to turn on more detailed messages ...
790  # zdcMonitorAcc.getEventAlgo('ZdcMonAlg').OutputLevel = 2 # DEBUG
791  # If you want fewer messages ...
792  # zdcMonitorAcc.getEventAlgo('ZdcMonAlg').OutputLevel = 4 # WARNING
793  cfg.printConfig(withDetails=False) # set True for exhaustive info
794 
795  cfg.run() #use cfg.run(20) to only run on first 20 events
ZdcMonitorAlgorithm.create_log_bins
def create_log_bins(min_value, max_value, num_bins)
Definition: ZdcMonitorAlgorithm.py:18
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
ZdcMonitorAlgorithm.ZdcMonitoringConfig
def ZdcMonitoringConfig(inputFlags)
Definition: ZdcMonitorAlgorithm.py:28
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.ZdcRecConfig.SetConfigTag
def SetConfigTag(flags)
Definition: ZdcRecConfig.py:52
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69