ATLAS Offline Software
TileRODMonitorAlgorithm.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 @file TileRODMonitorAlgorithm.py
6 @brief Python configuration of TileRODMonitorAlgorithm algorithm for the Run III
7 '''
8 
9 def TileRODMonitoringConfig(flags, **kwargs):
10  ''' Function to configure TileRODMonitorAlgorithm algorithm in the monitoring system.'''
11 
12  # Define one top-level monitoring algorithm. The new configuration
13  # framework uses a component accumulator.
14  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
15  result = ComponentAccumulator()
16 
17  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
18  result.merge( TileDQstatusAlgCfg(flags) )
19 
20  from TileGeoModel.TileGMConfig import TileGMCfg
21  result.merge(TileGMCfg(flags))
22 
23  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
24  result.merge( TileCablingSvcCfg(flags) )
25 
26  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
27  result.merge( TileBadChannelsCondAlgCfg(flags, **kwargs) )
28 
29  kwargs.setdefault('CheckDCS', flags.Tile.useDCS)
30  if kwargs['CheckDCS']:
31  from TileConditions.TileDCSConfig import TileDCSCondAlgCfg
32  result.merge( TileDCSCondAlgCfg(flags) )
33 
34  from AthenaConfiguration.ComponentFactory import CompFactory
35 
36  kwargs.setdefault('fillRODFragmentSizeHistograms', True)
37  fillRODFragmentSizeHistograms = kwargs['fillRODFragmentSizeHistograms']
38  if fillRODFragmentSizeHistograms:
39  result.addService(CompFactory.ROBDataProviderSvc())
40 
41  # The following class will make a sequence, configure algorithms, and link
42  # them to GenericMonitoringTools
43  from AthenaMonitoring import AthMonitorCfgHelper
44  helper = AthMonitorCfgHelper(flags,'TileRODMonitoring')
45 
46  # Adding an TileRODMonitorAlgorithm algorithm to the helper
47  tileRODMonAlg = helper.addAlgorithm(CompFactory.TileRODMonitorAlgorithm, 'TileRODMonAlg')
48 
49  # L1Trigger Type Bits:
50  # bit0_RNDM, bit1_ZeroBias, bit2_L1Cal, bit3_Muon,
51  # bit4_RPC, bit5_FTK, bit6_CTP, bit7_Calib, AnyPhysTrig
52  kwargs.setdefault('fillHistogramsForL1Triggers', ['AnyPhysTrig', 'bit7_Calib'])
53  l1Triggers = kwargs['fillHistogramsForL1Triggers']
54 
55  kwargs.setdefault('EnergyThreshold', 300.)
56  energyThreshold = kwargs['EnergyThreshold']
57 
58  kwargs.setdefault('TileRawChannelContainer', flags.Tile.RawChannelContainer)
59  kwargs.setdefault('NumberOfROBFragmets', 32)
60  nROBs = kwargs['NumberOfROBFragmets']
61 
62  for k, v in kwargs.items():
63  setattr(tileRODMonAlg, k, v)
64 
65  run = str(flags.Input.RunNumbers[0])
66 
67  # Configure histogram with TileRODMonAlg algorithm execution time
68  executeTimeGroup = helper.addGroup(tileRODMonAlg, 'TileRODMonExecuteTime', 'Tile/')
69  executeTimeGroup.defineHistogram('TIME_execute', path = 'ROD', type='TH1F',
70  title = 'Time for execute TileRODMonAlg algorithm;time [#ms]',
71  xbins = 100, xmin = 0, xmax = 100000)
72 
73 
74  from TileMonitoring.TileMonitoringCfgHelper import addTile1DHistogramsArray
75 
76  # Configure histograms with relative difference between Tile DSP and offline energies
77  titleEnergyDiff = 'Relative difference between E_{DSP} and E_{OFFLINE}'
78  titleEnergyDiff += ';(E_{DSP}- E_{OFFLINE})/E_{OFFLINE}'
79  addTile1DHistogramsArray(helper, tileRODMonAlg, name = 'TileDspEnergyDiff',
80  xvalue = 'energyDiff', title = titleEnergyDiff, path = 'Tile/ROD',
81  xbins = 41, xmin = -0.205, xmax = 0.205, type = 'TH1D', run = run,
82  triggers = l1Triggers, perPartition = True)
83 
84  # Configure histograms with difference between Tile DSP and offline times
85  titleTimeDiff = 'Difference between t_{DSP} and t_{OFFLINE}'
86  titleTimeDiff += ';t_{DSP}- t_{OFFLINE} [ns]'
87  addTile1DHistogramsArray(helper, tileRODMonAlg, name = 'TileDspTimeDiff',
88  xvalue = 'timeDiff', title = titleTimeDiff, path = 'Tile/ROD',
89  xbins = 101, xmin = -50.5, xmax = 50.5, type = 'TH1D', run = run,
90  triggers = l1Triggers, perPartition = True)
91 
92  # Configure histograms with difference between Tile DSP and offline times vs offline time
93  titleTimeDiffVsTime = 'Difference between t_{DSP} and t_{OFFLINE}'
94  titleTimeDiffVsTime += ';t_{OFFLINE} [ns];t_{DSP}- t_{OFFLINE} [ns]'
95  addTile1DHistogramsArray(helper, tileRODMonAlg, name = 'TileDspTimeDiffVsTime',
96  xvalue = 'time', value = 'timeDiff', title = titleTimeDiffVsTime,
97  path = 'Tile/ROD', xbins = 51, xmin = -25.5, xmax = 25.5,
98  type = 'TProfile', run = run, triggers = l1Triggers, perPartition = True)
99 
100  # Configure histograms with difference between Tile DSP and offline times vs offline energy
101  titleTimeDiffVsEnergy = 'Difference between t_{DSP} and t_{OFFLINE}'
102  titleTimeDiffVsEnergy += ';E_{OFFLINE} [MeV];t_{DSP}- t_{OFFLINE}'
103  addTile1DHistogramsArray(helper, tileRODMonAlg, name = 'TileDspTimeDiffVsEnergy',
104  xvalue = 'energy', value = 'timeDiff', title = titleTimeDiffVsEnergy,
105  path = 'Tile/ROD', xbins = 75, xmin = energyThreshold, xmax = 15000.,
106  type = 'TProfile', run = run, triggers = l1Triggers, perPartition = True)
107 
108 
109  from TileMonitoring.TileMonitoringCfgHelper import addTile2DHistogramsArray
110 
111  # Configure histograms with relative difference between Tile DSP and offline energies vs offline time
112  titleEnergyDiffVsTime = 'Relative difference between E_{DSP} and E_{OFFLINE}'
113  titleEnergyDiffVsTime += ';t_{DSP} [ns];(E_{DSP}- E_{OFFLINE})/E_{OFFLINE}'
114  addTile2DHistogramsArray(helper, tileRODMonAlg, name = 'TileDspEnergyDiffVsTime',
115  xvalue = 'time', yvalue = 'energyDiff',
116  title = titleEnergyDiffVsTime, path = 'Tile/ROD',
117  xbins = 51, xmin = -25.5, xmax = 25.5,
118  ybins = 30, ymin = -0.35, ymax = 0.1,
119  type = 'TH2D', run = run, triggers = l1Triggers, perPartition = True)
120 
121  # Configure histograms with relative difference between Tile DSP and offline energies vs offline energy
122  titleEnergyDiffVsEnergy = 'Relative difference between E_{DSP} and E_{OFFLINE}'
123  titleEnergyDiffVsEnergy += ';E_{OFFLINE} [MeV];(E_{DSP}- E_{OFFLINE})/E_{OFFLINE}'
124  addTile2DHistogramsArray(helper, tileRODMonAlg, name = 'TileDspEnergyDiffVsEnergy',
125  xvalue = 'energy', yvalue = 'energyDiff',
126  title = titleEnergyDiffVsEnergy, path = 'Tile/ROD',
127  xbins = 75, xmin = energyThreshold, xmax = 15000.,
128  ybins = 82, ymin = -0.205, ymax = 0.205,
129  type = 'TH2D', run = run, triggers = l1Triggers, perPartition = True)
130 
131 
132  from TileMonitoring.TileMonitoringCfgHelper import addTileModuleChannelMapsArray
133 
134  # Configure histograms with everagy Tile channel time per partition
135  titleChanTime = ('Tile DSP Channel Time (t_{DSP}) [ns], E_{ch} > %s MeV' % energyThreshold)
136  addTileModuleChannelMapsArray(helper, tileRODMonAlg, name = 'TileDspChannelTime', type = 'TProfile2D',
137  value = 'time', title = titleChanTime, path = 'Tile/ROD',
138  run = run, triggers = l1Triggers, separator = '_')
139 
140 
141  if fillRODFragmentSizeHistograms:
142  # Configure histogram with all Tile ROD fragments size vs luminosity block
143  titleAllRodFragSize = 'All Tile ROD fragments size vs luminosity block;LumiBlock;# words'
144  addTile1DHistogramsArray(helper, tileRODMonAlg, name = 'TileRodFragmentSizeLB',
145  xvalue = 'lumiBlock', value = 'allRodFragsSize',
146  title = titleAllRodFragSize, path = 'Tile/ROD',
147  xbins = 1000, xmin = -0.5, xmax = 999.5,
148  type = 'TProfile', run = run, triggers = l1Triggers,
149  perPartition = False, opt = 'kAddBinsDynamically', merge = 'merge')
150 
151  from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
152  from TileMonitoring.TileMonitoringCfgHelper import getPartitionName
153 
154  # Configure histogram with Tile ROD fragment size vs fragment number and partition
155  titleRodFragSize = 'Tile ROD fragment size [word]; Fragment;'
156  partitionLabels = [getPartitionName(ros) for ros in range(1, Tile.MAX_ROS)]
157  addTile2DHistogramsArray(helper, tileRODMonAlg, name = 'TileRodFragmentMapSize',
158  xvalue = 'fragment', yvalue = 'partition', value = 'rodFragSize',
159  title = titleRodFragSize, path = 'Tile/ROD',
160  xbins = nROBs, xmin = -0.5, xmax = nROBs - 0.5,
161  ybins = Tile.MAX_ROS - 1, ymin = 0.5, ymax = Tile.MAX_ROS - 0.5,
162  type = 'TProfile2D', run = run, triggers = l1Triggers, ylabels = partitionLabels)
163 
164 
165  accumalator = helper.result()
166  result.merge(accumalator)
167  return result
168 
169 if __name__=='__main__':
170 
171  # Setup logs
172  from AthenaCommon.Logging import log
173  from AthenaCommon.Constants import INFO
174  log.setLevel(INFO)
175 
176  # Set the Athena configuration flags
177  from AthenaConfiguration.AllConfigFlags import initConfigFlags
178  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
179  flags = initConfigFlags()
180  flags.Input.Files = defaultTestFiles.RAW_RUN2
181  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
182  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
183  flags.Output.HISTFileName = 'TileRODMonitorOutput.root'
184  flags.DQ.useTrigger = False
185  flags.DQ.enableLumiAccess = False
186  flags.Tile.doOptATLAS = True
187  flags.Exec.MaxEvents = 3
188  flags.fillFromArgs()
189  flags.lock()
190 
191  # Initialize configuration object, add accumulator, merge, and run.
192  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
193  cfg = MainServicesCfg(flags)
194 
195  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
196  cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
197 
198  from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg
199  cfg.merge( TileRawChannelMakerCfg(flags) )
200 
201  cfg.merge( TileRODMonitoringConfig(flags) )
202 
203  cfg.printConfig(withDetails = True, summariseProps = True)
204  flags.dump()
205 
206  cfg.store( open('TileRODMonitorAlgorithm.pkl','wb') )
207 
208  sc = cfg.run()
209 
210  import sys
211  # Success should be 0
212  sys.exit(not sc.isSuccess())
TileMonitoringCfgHelper.addTileModuleChannelMapsArray
def addTileModuleChannelMapsArray(helper, algorithm, name, title, path, weight='', subDirectory=False, type='TH2D', value='', run='', triggers=[], perGain=False, separator='_')
Definition: TileMonitoringCfgHelper.py:370
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileMonitoringCfgHelper.addTile2DHistogramsArray
def addTile2DHistogramsArray(helper, algorithm, name='', xvalue='', yvalue='', value='', title='', path='', weight='', xbins=0, xmin=0., xmax=0., ybins=0, ymin=0., ymax=0., type='TH2D', run='', triggers=[], xlabels=(), ylabels=(), opt='', subDirectory=False, perPartition=False, perSample=False, perGain=False, allPartitions=False, separator='_', merge=None)
Definition: TileMonitoringCfgHelper.py:300
TileRODMonitorAlgorithm.TileRODMonitoringConfig
def TileRODMonitoringConfig(flags, **kwargs)
Definition: TileRODMonitorAlgorithm.py:9
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
TileMonitoringCfgHelper.addTile1DHistogramsArray
def addTile1DHistogramsArray(helper, algorithm, name='', xvalue='', value='', title='', path='', weight='', xbins=0, xmin=0., xmax=0., type='TH1D', run='', triggers=[], subDirectory=False, perPartition=True, perSample=False, opt='', perGain=False, xlabels=(), allPartitions=False, separator='_', merge=None)
Definition: TileMonitoringCfgHelper.py:536
python.TileBadChannelsConfig.TileBadChannelsCondAlgCfg
def TileBadChannelsCondAlgCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:10
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
TileMonitoringCfgHelper.getPartitionName
def getPartitionName(ros)
Definition: TileMonitoringCfgHelper.py:40
python.TileDCSConfig.TileDCSCondAlgCfg
def TileDCSCondAlgCfg(flags, **kwargs)
Definition: TileDCSConfig.py:8
Trk::open
@ open
Definition: BinningType.h:40
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
TileRawChannelMakerConfig.TileRawChannelMakerCfg
def TileRawChannelMakerCfg(flags, **kwargs)
Definition: TileRawChannelMakerConfig.py:10
str
Definition: BTagTrackIpAccessor.cxx:11
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7