ATLAS Offline Software
TileRawChannelMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from TileConfiguration.TileConfigFlags import TileRunType
6 
7 '''
8 @file TileRawChannelMonitorAlgorithm.py
9 @brief Python configuration of TileRawChannelMonitorAlgorithm algorithm for the Run III
10 '''
11 def TileRawChannelMonitoringConfig(flags, overlapHistograms=None, **kwargs):
12 
13  ''' Function to configure TileRawChannelMonitorAlgorithm algorithm in the monitoring system.'''
14 
15  # Define one top-level monitoring algorithm. The new configuration
16  # framework uses a component accumulator.
17  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
18  result = ComponentAccumulator()
19 
20  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
21  result.merge(TileCablingSvcCfg(flags))
22  run3Period = (result.getService('TileCablingSvc').CablingType == 6)
23 
24  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
25  result.merge( TileDQstatusAlgCfg(flags) )
26 
27  from TileGeoModel.TileGMConfig import TileGMCfg
28  result.merge(TileGMCfg(flags))
29 
30  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
31  result.merge( TileInfoLoaderCfg(flags) )
32  is12bit = (result.getService('TileInfoLoader').ADCmax == 4095)
33 
34  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
35  result.merge( TileEMScaleCondAlgCfg(flags) )
36 
37  runType = flags.Tile.RunType
38 
39  kwargs.setdefault('name', 'TileRawChannelMonAlg')
40  kwargs.setdefault('RunType', runType.getIntValue())
41 
42  if 'TileRawChannelContainer' not in kwargs:
43  if flags.Tile.readDigits:
44  if flags.Tile.doOpt2:
45  rawChannelContainer = 'TileRawChannelOpt2'
46  elif flags.Tile.doFit:
47  rawChannelContainer = 'TileRawChannelFit'
48  elif flags.Tile.doOptATLAS:
49  rawChannelContainer = 'TileRawChannelFixed'
50  elif flags.Tile.doOptOF1:
51  rawChannelContainer = 'TileRawChannelOF1'
52  else:
53  # default for simulation
54  rawChannelContainer = 'TileRawChannelCnt'
55 
56  kwargs.setdefault('TileRawChannelContainer', rawChannelContainer)
57 
58  if overlapHistograms is None:
59  overlapHistograms = runType is TileRunType.LAS
60 
61  if 'fillHistogramsForDSP' not in kwargs:
62  # Don't fill DSP histograms for bi gain runs by default
63  fillHistogramsForDSP = runType not in [TileRunType.CIS, TileRunType.PED]
64  kwargs.setdefault('fillHistogramsForDSP', fillHistogramsForDSP)
65 
66  if 'CalibUnit' not in kwargs:
67  # Put everything in PicoCoulomb (1) by default for all run types, but Physics
68  # For Physcs calibrate in CesiumPicoCoulomb (2) for all channels, but MBTS channels,
69  # for which we keep the calibration in PicoCoulombCesium pC for consistency (no Cs calibration is possible)
70  calibUnit = 2 if runType is TileRunType.PHY else 1
71  kwargs.setdefault('CalibUnit', calibUnit)
72 
73  if run3Period:
74  demonstratorFragID = 0x10d # LBA14 is demonstrator in RUN3
75  if 'FragIDsDemonstrators' not in kwargs:
76  kwargs.setdefault('FragIDsDemonstrators', [demonstratorFragID])
77 
78  if 'FragIDsToIgnoreDMUErrors' not in kwargs:
79  kwargs.setdefault('FragIDsToIgnoreDMUErrors', [demonstratorFragID])
80 
81  unit = {1: '[pC]', 2 : '[Cesium pC], but MBTS [pc]'}.get(kwargs['CalibUnit'], "")
82 
83  # The following class will make a sequence, configure algorithms, and link
84  # them to GenericMonitoringTools
85  from AthenaMonitoring import AthMonitorCfgHelper
86  helper = AthMonitorCfgHelper(flags,'TileRawChannelMonitoring')
87 
88  # Adding an TileCellMonitorAlgorithm algorithm to the helper
89  from AthenaConfiguration.ComponentFactory import CompFactory
90  tileRawChannelMonAlg = helper.addAlgorithm(CompFactory.TileRawChannelMonitorAlgorithm, kwargs['name'])
91 
92  for k, v in kwargs.items():
93  setattr(tileRawChannelMonAlg, k, v)
94 
95  run = str(flags.Input.RunNumbers[0])
96 
97  # 1) Configure histogram with TileRawChannelMonAlg algorithm execution time
98  executeTimeGroup = helper.addGroup(tileRawChannelMonAlg, 'TileRawChannelMonExecuteTime', 'Tile/')
99  executeTimeGroup.defineHistogram('TIME_execute', path = 'RawChannel', type='TH1F',
100  title = 'Time for execute TileRawChannelMonAlg algorithm;time [#mus]',
101  xbins = 200, xmin = 0, xmax = 200000)
102 
103 
104  from TileMonitoring.TileMonitoringCfgHelper import addTileChannelHistogramsArray
105 
106  if kwargs['fillHistogramsForDSP']:
107  # Configure histograms with Tile DSP raw channel amplitude per module, channel and gain
108  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelDspAmp',
109  title=f'DSP Amplitude;{unit}', path='Tile/RawChannel', type='TH1I', run=run,
110  xvalue='dsp_amp', xbins=[491,413], xmin=[-50.5,-1.01], xmax=[1049.34,15.51])
111 
112  # Configure histograms with Tile DSP raw channel time per module, channel and gain
113  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelDspTime',
114  title='DSP Time;[ns]', path='Tile/RawChannel', type='TH1I',
115  xvalue='dsp_time', xbins=101, xmin=-100.5, xmax= 100.5, run=run)
116 
117  # Configure histograms with Tile DSP raw channel amplitude difference per module, channel and gain
118  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelAmpDiff',
119  title=f'DSP-OF Amplitude difference;{unit}', path='Tile/RawChannel', type='TH1I',
120  run=run, xvalue='dsp-fit_amp_diff', xbins=404, xmin=-1.01, xmax=1.01)
121 
122  # Configure histograms with Tile DSP raw channel time difference per module, channel and gain
123  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelTimeDiff',
124  title='DSP-OF Time difference;[ns]', path='Tile/RawChannel', type='TH1I',
125  xvalue='dsp-fit_time_diff', xbins=101, xmin=-2.02, xmax=2.02, run=run)
126 
127  # Configure histograms with Tile DSP raw channel quality per module, channel and gain
128  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelDspChi2',
129  title='DSP #chi^{2}', path='Tile/RawChannel', type='TH1I',
130  xvalue='dsp_chi2', xbins=16, xmin=-0.5, xmax=15.5, run=run)
131 
132  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelDspChi2VsAmp', type='TH2F',
133  title=f'DSP #chi^{2} vs Amplitude;{unit}', path='Tile/RawChannel', aliasSuffix='chi2_amp',
134  xvalue='dsp_amp', xbins=[200,150], xmin=[-45.1,-7.0], xmax=[855.1,12.0],
135  yvalue='dsp_chi2', ybins=16, ymin=-0.5, ymax=15.5, run=run)
136 
137  if runType is not TileRunType.CIS:
138 
139  # Configure histograms with Tile raw channel amplitude per module, channel and gain
140  if runType is TileRunType.PED:
141  ampXbins = [101, 101]
142  ampXmin = [-10.1, -0.404]
143  ampXmax = [10.1, 0.404]
144  elif runType is TileRunType.PHY:
145  ampXbins = 206
146  ampXmin = -0.55
147  ampXmax = 20.05
148  elif overlapHistograms:
149  lgXbins = [-50.5 + 1.0 * i for i in range(0, 50) ]
150  lgXbins += [-1.5 + 0.05 * i for i in range(1, 501)]
151  lgXbins += [23.5 + 1.0 * i for i in range(1, 1028)]
152  ampXbins = [lgXbins, 500]
153  ampXmin = [lgXbins[0], -1.5]
154  ampXmax = [lgXbins[len(lgXbins) - 1], 23.5]
155  else:
156  ampXbins = [1101, 826]
157  ampXmin = [-50.5, -1.01]
158  ampXmax = [1050.5, 15.51]
159 
160  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelAmp',
161  title=f'Amplitude;{unit}', path='Tile/RawChannel', type='TH1I',
162  xvalue='amp', xbins=ampXbins, xmin=ampXmin, xmax=ampXmax, run=run)
163 
164  # Configure histograms with Tile raw channel time per module, channel and gain
165  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelTime',
166  title='Time;[ns]', path='Tile/RawChannel', type='TH1I',
167  xvalue='time', xbins=201, xmin=-100.5, xmax= 100.5, run=run)
168 
169  # Configure histograms with Tile raw channel time corrected per module, channel and gain
170  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name='TileRawChannelTimeCorr',
171  title='Time corrected;[ns]', path='Tile/RawChannel', type='TH1I',
172  xvalue='time_corr', xbins=201, xmin=-100.5, xmax= 100.5, run=run)
173 
174  else: # CIS run
175 
176  chargeFactor = 2. if is12bit else 1.
177  adcFactor = 4. if is12bit else 1.
178 
179  chargeXmin = { 5 : [-0.5, -0.0625 * chargeFactor], 100 : [-4., -0.0625 * chargeFactor]}
180  chargeXmax = { 5 : [50.5, 12.5625 * chargeFactor], 100 : [804., 12.5625 * chargeFactor]}
181 
182  if kwargs['CalibUnit'] == 2: # Cesium pC
183  ampYmin = { 5 : [-5.3125, -0.391 * adcFactor], 100 : [-25., -0.391 * adcFactor]}
184  ampYmax = { 5 : [60.3125, 16.02 * adcFactor], 100 : [1025., 16.02 * adcFactor]}
185  else:
186  ampYmin = { 5 : [-5.3125, -25. * adcFactor], 100 : [-25., -25. * adcFactor]}
187  ampYmax = { 5 : [60.3125, 1025. * adcFactor], 100 : [1025., 1025. * adcFactor]}
188 
189  for capacitor in [5, 100]:
190  # Configure histograms with Tile raw channel amplitude vs charge per module, channel and gain
191  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name=f'TileRawChannelAmpVsQ{capacitor}',
192  title=f'Amplitude vs Charge for {capacitor} pF;Charge, [pC];Amplitude, {unit}',
193  path='Tile/RawChannel',type='TH2F', run=run,
194  aliasSuffix=f'amp_vs_q_{capacitor}', xvalue='charge', yvalue='amp',
195  xbins=51, xmin=chargeXmin[capacitor], xmax=chargeXmax[capacitor],
196  ybins=160, ymin=ampYmin[capacitor], ymax=ampYmax[capacitor])
197 
198  # Configure histograms with Tile raw channel time vs injection time per module, channel and gain
199  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name=f'TileRawChannelTimeVsTime{capacitor}',
200  title=f'Time vs Injection Time for {capacitor} pF;Injection Time, [ns];Time, [ns]',
201  path='Tile/RawChannel', type='TH2F', run=run,
202  xvalue='inj_time', yvalue='time', aliasSuffix=f'time_vs_time_{capacitor}',
203  xbins=51, xmin=-0.25, xmax=25.25, ybins=160, ymin=-64., ymax=32.)
204 
205  # Configure histograms with Tile raw channel amplitude over charge per module, channel and gain
206  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name=f'TileRawChannelAmpOverQ{capacitor}',
207  title=f'Amplitude over charge ratio for {capacitor} pF;{unit}/[pC]', path='Tile/RawChannel',
208  type='TH1I', xvalue='amp_ratio', run=run, aliasSuffix=f'amp_ratio_{capacitor}',
209  xbins=101, xmin=-0.01, xmax=2.01)
210 
211  # Configure histograms with Tile raw channel time per module, channel and gain
212  addTileChannelHistogramsArray(helper, tileRawChannelMonAlg, name=f'TileRawChannelTime{capacitor}', run=run,
213  title=f'Time for {capacitor};[ns]', path='Tile/RawChannel', type='TH1I',
214  xvalue='time', xbins=101, xmin=-101, xmax=101, aliasSuffix=f'time_{capacitor}')
215 
216 
217  accumalator = helper.result()
218  result.merge(accumalator)
219  return result
220 
221 if __name__=='__main__':
222 
223  # Setup logs
224  from AthenaCommon.Logging import log
225  from AthenaCommon.Constants import INFO
226  log.setLevel(INFO)
227 
228  # Set the Athena configuration flags
229  from AthenaConfiguration.AllConfigFlags import initConfigFlags
230  from AthenaConfiguration.TestDefaults import defaultTestFiles
231  flags = initConfigFlags()
232  flags.Input.Files = defaultTestFiles.RAW_RUN2
233  flags.Output.HISTFileName = 'TileRawChannelMonitorOutput.root'
234  flags.DQ.useTrigger = False
235  flags.DQ.enableLumiAccess = False
236  flags.Exec.MaxEvents = 3
237  flags.fillFromArgs()
238  flags.lock()
239 
240  # Initialize configuration object, add accumulator, merge, and run.
241  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
242  cfg = MainServicesCfg(flags)
243 
244  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
245  cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False, readBeamElem=True) )
246 
247  cfg.merge( TileRawChannelMonitoringConfig(flags,
248  TileRawChannelContainer='TileRawChannelCnt',
249  fillHistogramsForDSP=True) )
250 
251  flags.dump()
252 
253  cfg.store( open('TileRawChannelMonitorAlgorithm.pkl','wb') )
254 
255  sc = cfg.run()
256 
257  import sys
258  # Success should be 0
259  sys.exit(not sc.isSuccess())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileRawChannelMonitorAlgorithm.TileRawChannelMonitoringConfig
def TileRawChannelMonitoringConfig(flags, overlapHistograms=None, **kwargs)
Definition: TileRawChannelMonitorAlgorithm.py:11
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
python.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
Trk::open
@ open
Definition: BinningType.h:40
TileMonitoringCfgHelper.addTileChannelHistogramsArray
def addTileChannelHistogramsArray(helper, algorithm, name, title, path, xvalue, xbins, xmin, xmax, type='TH1D', yvalue=None, ybins=None, ymin=None, ymax=None, run='', value='', aliasSuffix='')
Definition: TileMonitoringCfgHelper.py:717
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7