ATLAS Offline Software
TileClusterMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 '''
5 @file TileClusterMonitorAlgorithm.py
6 @brief Python configuration of TileClusterMonitorAlgorithm algorithm for the Run III
7 '''
8 def TileClusterMonitoringConfig(flags, **kwargs):
9 
10  ''' Function to configure TileClusterMonitorAlgorithm 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 TileMonitoring.TileTopoClusterConfig import TileTopoClusterCfg
18  result.merge( TileTopoClusterCfg(flags) )
19 
20  # The following class will make a sequence, configure algorithms, and link
21  # them to GenericMonitoringTools
22  from AthenaMonitoring import AthMonitorCfgHelper
23  helper = AthMonitorCfgHelper(flags,'TileClusterMonitoring')
24 
25  # Adding an TileCellMonitorAlgorithm algorithm to the helper
26  from AthenaConfiguration.ComponentFactory import CompFactory
27  tileClusterMonAlg = helper.addAlgorithm(CompFactory.TileClusterMonitorAlgorithm, 'TileClusterMonAlg')
28 
29  tileClusterMonAlg.TriggerChain = ''
30 
31  # from AthenaCommon.SystemOfUnits import MeV
32  #kwargs.setdefault('EnergyThreshold', 50.0 * MeV)
33 
34  # L1Trigger Type Bits:
35  # bit0_RNDM, bit1_ZeroBias, bit2_L1Cal, bit3_Muon,
36  # bit4_RPC, bit5_FTK, bit6_CTP, bit7_Calib, AnyPhysTrig
37  kwargs.setdefault('fillHistogramsForL1Triggers', ['AnyPhysTrig', 'bit7_Calib'])
38  l1Triggers = kwargs['fillHistogramsForL1Triggers']
39 
40  kwargs.setdefault('fillTimingHistograms', flags.Common.isOnline)
41  fillTimingHistograms = kwargs['fillTimingHistograms']
42 
43  for k, v in kwargs.items():
44  setattr(tileClusterMonAlg, k, v)
45 
46  run = str(flags.Input.RunNumbers[0])
47 
48  # 1) Configure histogram with TileClusterMonAlg algorithm execution time
49  executeTimeGroup = helper.addGroup(tileClusterMonAlg, 'TileClusterMonExecuteTime', 'Tile/')
50  executeTimeGroup.defineHistogram('TIME_execute', path = 'Cluster', type='TH1F',
51  title = 'Time for execute TileClusterMonAlg algorithm;time [#mus]',
52  xbins = 100, xmin = 0, xmax = 1000)
53 
54 
55  from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
56 
57 
58  from TileMonitoring.TileMonitoringCfgHelper import addTileEtaPhiMapsArray
59 
60  # ) Configure histograms with most energetic Tile tower position
61  addTileEtaPhiMapsArray(helper, tileClusterMonAlg, name = 'TileClusterEtaPhi', type='TH2D',
62  title = 'Most energetic Tile Cluster position', path = 'Tile/Cluster',
63  run = run, triggers = l1Triggers, perSample = False)
64 
65  # ) Configure histograms with most energetic Tile tower position
66  addTileEtaPhiMapsArray(helper, tileClusterMonAlg, name = 'TileAllClusterEtaPhi', type='TH2D',
67  title = 'All Tile Cluster position', path = 'Tile/Cluster',
68  run = run, triggers = l1Triggers, perSample = False)
69 
70  # ) Configure histograms with most energetic Tile tower position
71  addTileEtaPhiMapsArray(helper, tileClusterMonAlg, name = 'TileAllClusterEneEtaPhi', type='TProfile2D',
72  value = 'energy', title = 'All Tile Cluster everage energy [MeV]',
73  path = 'Tile/Cluster', run = run, triggers = l1Triggers, perSample = False)
74 
75 
76  # ) Configure histograms with position correlation of Tile cluster opposite to most energetic cluster
77  addTileEtaPhiMapsArray(helper, tileClusterMonAlg, name = 'TileClusterEtaPhiDiff', type='TH2D',
78  title = 'Position correlation of Tile Cluster opposite to most energetic cluster',
79  path = 'Tile/Cluster', run = run, triggers = l1Triggers, perSample = False,
80  etaTitle = '#Delta #eta', etabins = 21, etamin = -2.025, etamax = 2.025,
81  phiTitle = '#Delta #phi', phibins = Tile.MAX_DRAWER, phimin = 0.0, phimax = 6.4)
82 
83 
84  from TileMonitoring.TileMonitoringCfgHelper import addTile1DHistogramsArray
85 
86  # ) Configure histograms with all Tile towers energy per partition
87  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterEnergy', xvalue = 'energy',
88  title = 'Energy in most energetic Tile Cluster [MeV]', path = 'Tile/Cluster',
89  xbins = 80, xmin = 0., xmax = 20000., type = 'TH1D', run = run,
90  triggers = l1Triggers, perPartition = True, perSample = False,
91  perGain = False, subDirectory = True, allPartitions = True)
92 
93  # ) Configure histograms with Et in most energetic Tile tower per partition
94  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterEt', xvalue = 'et',
95  title = 'E_{T} [MeV] in most energetic Tile Cluster', path = 'Tile/Cluster',
96  xbins = 80, xmin = 0., xmax = 20000., type = 'TH1D', run = run,
97  triggers = l1Triggers, perPartition = False, perSample = False,
98  perGain = False, subDirectory = False, allPartitions = False)
99 
100  # ) Configure histograms with all Tile towers energy per partition
101  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterNCells', xvalue = 'nCells',
102  title = 'Number of cells in most energetic Tile Cluster', path = 'Tile/Cluster',
103  xbins = 100, xmin = 0., xmax = 100., type = 'TH1D', run = run,
104  triggers = l1Triggers, perPartition = False, perSample = False,
105  perGain = False, subDirectory = False, allPartitions = False)
106 
107 
108  # ) Configure histograms with all Tile towers energy per partition
109  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileAllClusterEnergy', xvalue = 'energy',
110  title = 'All Tile Cluster Energy [MeV]', path = 'Tile/Cluster',
111  xbins = 80, xmin = 0., xmax = 20000., type = 'TH1D', run = run,
112  triggers = l1Triggers, perPartition = False, perSample = False,
113  perGain = False, subDirectory = False, allPartitions = False)
114 
115  # ) Configure histograms with all Tile towers energy per partition
116  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileNClusters', xvalue = 'nClusters',
117  title = 'Number of Tile Clusters', path = 'Tile/Cluster',
118  xbins = 200, xmin = 0., xmax = 200., type = 'TH1D', run = run,
119  triggers = l1Triggers, perPartition = False, perSample = False,
120  perGain = False, subDirectory = False, allPartitions = False)
121 
122  # ) Configure histograms with all Tile towers energy per partition
123  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterSumPx', xvalue = 'sumPx',
124  title = 'Tile Clusters SumPx [MeV]', path = 'Tile/Cluster',
125  xbins = 101, xmin = -10000., xmax = 10000., type = 'TH1D', run = run,
126  triggers = l1Triggers, perPartition = False, perSample = False,
127  perGain = False, subDirectory = False, allPartitions = False)
128 
129  # ) Configure histograms with all Tile towers energy per partition
130  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterSumPy', xvalue = 'sumPy',
131  title = 'Tile Clusters SumPy [MeV]', path = 'Tile/Cluster',
132  xbins = 101, xmin = -10000., xmax = 10000., type = 'TH1D', run = run,
133  triggers = l1Triggers, perPartition = False, perSample = False,
134  perGain = False, subDirectory = False, allPartitions = False)
135 
136  # ) Configure histograms with all Tile towers energy per partition
137  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterSumEt', xvalue = 'sumEt',
138  title = 'Tile Clusters SumEt [MeV]', path = 'Tile/Cluster',
139  xbins = 100, xmin = 0., xmax = 20000., type = 'TH1D', run = run,
140  triggers = l1Triggers, perPartition = False, perSample = False,
141  perGain = False, subDirectory = False, allPartitions = False)
142 
143  # ) Configure histograms with all Tile towers energy per partition
144  timeDiffTitle = 'Tile time correlation of cluster opposite to most energetic cluster; Time difference [ns]'
145  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterTimeDiff', xvalue = 'timeDiff',
146  title = timeDiffTitle, path = 'Tile/Cluster', xbins = 200, xmin = -100., xmax = 100.,
147  type = 'TH1D', run = run, triggers = l1Triggers, perPartition = False, perSample = False,
148  perGain = False, subDirectory = False, allPartitions = False)
149 
150  # ) Configure histograms with all Tile towers energy per partition
151  eneDiffTitle = 'Tile energy correlation of cluster opposite to most energetic cluster; Time energy [MeV]'
152  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TileClusterEneDiff', xvalue = 'energyDiff',
153  title = eneDiffTitle, path = 'Tile/Cluster', xbins = 200, xmin = -10000., xmax = 10000.,
154  type = 'TH1D', run = run, triggers = l1Triggers, perPartition = False, perSample = False,
155  perGain = False, subDirectory = False, allPartitions = False)
156 
157 
158  if fillTimingHistograms:
159  # ) Configure histograms with Tile partition time vs lumiBlock per partition
160  titlePartitionTime = 'Tile partition time vs luminosity block;LumiBlock;t[ns]'
161  addTile1DHistogramsArray(helper, tileClusterMonAlg, name = 'TilePartitionTimeLB', opt = 'kAddBinsDynamically',
162  xvalue = 'lumiBlock', value = 'time', title = titlePartitionTime, path = 'Tile/Cluster',
163  xbins = 1000, xmin = -0.5, xmax = 999.5, type='TProfile', run = run, triggers = [],
164  subDirectory = False, perPartition = True, perSample = False, perGain = False, allPartitions = True)
165 
166 
167  accumalator = helper.result()
168  result.merge(accumalator)
169  return result
170 
171 if __name__=='__main__':
172 
173  # Setup logs
174  from AthenaCommon.Logging import log
175  from AthenaCommon.Constants import INFO
176  log.setLevel(INFO)
177 
178  # Set the Athena configuration flags
179  from AthenaConfiguration.AllConfigFlags import initConfigFlags
180  from AthenaConfiguration.TestDefaults import defaultTestFiles
181  flags = initConfigFlags()
182  flags.Input.Files = defaultTestFiles.ESD
183  flags.Output.HISTFileName = 'TileClusterMonitorOutput.root'
184  flags.DQ.useTrigger = False
185  flags.DQ.enableLumiAccess = False
186  flags.Exec.MaxEvents = 3
187  flags.fillFromArgs()
188  flags.lock()
189 
190  # Initialize configuration object, add accumulator, merge, and run.
191  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
192  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
193  cfg = MainServicesCfg(flags)
194  cfg.merge(PoolReadCfg(flags))
195 
196  l1Triggers = ['bit0_RNDM', 'bit1_ZeroBias', 'bit2_L1Cal', 'bit3_Muon',
197  'bit4_RPC', 'bit5_FTK', 'bit6_CTP', 'bit7_Calib', 'AnyPhysTrig']
198 
199  cfg.merge( TileClusterMonitoringConfig(flags,
200  fillTimingHistograms = True,
201  fillHistogramsForL1Triggers = l1Triggers) )
202 
203  cfg.printConfig(withDetails = True, summariseProps = True)
204  flags.dump()
205 
206  cfg.store( open('TileClusterMonitorAlgorithm.pkl','wb') )
207 
208  sc = cfg.run()
209 
210  import sys
211  # Success should be 0
212  sys.exit(not sc.isSuccess())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileClusterMonitorAlgorithm.TileClusterMonitoringConfig
def TileClusterMonitoringConfig(flags, **kwargs)
Definition: TileClusterMonitorAlgorithm.py:8
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.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
TileMonitoringCfgHelper.addTileEtaPhiMapsArray
def addTileEtaPhiMapsArray(helper, algorithm, name, title, path, weight='', type='TH2D', value='', run='', triggers=[], perSample=True, perGain=False, separator='_', etaTitle='#eta', etabins=21, etamin=-2.025, etamax=2.025, phiTitle='#phi', phibins=Tile.MAX_DRAWER, phimin=-3.15, phimax=3.15)
Definition: TileMonitoringCfgHelper.py:501
TileTopoClusterConfig.TileTopoClusterCfg
def TileTopoClusterCfg(flags, **kwargs)
Definition: TileTopoClusterConfig.py:11
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69