ATLAS Offline Software
TileCalCellMonAlg.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 '''
6 @file TileCalCellMonAlg.py
7 @brief Python configuration of TileCalCellMonAlg algorithm for the Run III
8 '''
9 
10 from __future__ import print_function
11 
12 def TileCalCellMonAlgConfig(flags, **kwargs):
13  ''' Function to configure TileCalCellMonAlg algorithm in the monitoring system.'''
14 
15  kwargs.setdefault('MonGroupName', 'TileEventFiter')
16  kwargs.setdefault('useBeamBackgroundRemoval', False)
17  kwargs.setdefault('useLArNoisyAlg', False)
18  kwargs.setdefault('useLArCollisionFilterTool', False)
19 
20  if not (flags.Common.isOnline == 'online' or flags.Input.isMC):
21  kwargs.setdefault('useReadyFilterTool', True)
22  kwargs.setdefault('useBadLBTool', False) # FIXME: when new LArBadLBFilterTool config is ready
23  else:
24  kwargs.setdefault('useReadyFilterTool', False)
25  kwargs.setdefault('useBadLBTool', False)
26 
27  from AthenaCommon.SystemOfUnits import MeV
28  kwargs.setdefault('EnergyThreshold', 300.0 * MeV)
29 
30  from AthenaMonitoring import AthMonitorCfgHelper
31  helper = AthMonitorCfgHelper(flags,'TileCalMonCfg')
32 
33  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
34  cfg = LArGMCfg(flags)
35 
36  from TileGeoModel.TileGMConfig import TileGMCfg
37  cfg.merge(TileGMCfg(flags))
38 
39  from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
40  cfg.merge(CaloNoiseCondAlgCfg(flags))
41 
42  if kwargs['useLArCollisionFilterTool']:
43  from LArCellRec.LArCollisionTimeConfig import LArCollisionTimeCfg
44  cfg.merge(LArCollisionTimeCfg(flags))
45 
46  if kwargs['useReadyFilterTool'] and 'ReadyFilterTool' not in kwargs:
47  from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
48  readyFilterTool = cfg.popToolsAndMerge(AtlasReadyFilterCfg(flags))
49  kwargs['ReadyFilterTool'] = readyFilterTool
50 
51  from AthenaConfiguration.ComponentFactory import CompFactory
52  tileCalCellMonAlg = helper.addAlgorithm(CompFactory.TileCalCellMonAlg, 'TileCalCellMonAlg')
53 
54  for k, v in kwargs.items():
55  setattr(tileCalCellMonAlg, k, v)
56 
57  binLabels = ["TotalEvents", "ATLAS Ready", "with Good LAr LB", "with No LAr Collision",
58  "with No Beam Background", "with No Trigger Filter","with No LArError"]
59 
60  if not tileCalCellMonAlg.useReadyFilterTool:
61  binLabels[1] = "ATLAS Ready-OFF"
62  if not tileCalCellMonAlg.useBadLBTool:
63  binLabels[2] = "Good LAr LB-OFF"
64  if not tileCalCellMonAlg.useLArCollisionFilterTool:
65  binLabels[3] = "LAr collision-OFF"
66  if not tileCalCellMonAlg.useBeamBackgroundRemoval:
67  binLabels[4] = "Beam backgr.-OFF"
68  if not tileCalCellMonAlg.useLArNoisyAlg:
69  binLabels[5] = "LAr Error Veto-OFF"
70 
71  topPath = '/CaloMonitoring/TileCellMon_NoTrigSel/General/'
72  tileFilterGroup = helper.addGroup(tileCalCellMonAlg, tileCalCellMonAlg.MonGroupName, topPath)
73 
74  from CaloMonitoring.CaloMonAlgBase import CaloBaseHistConfig
75  CaloBaseHistConfig(tileFilterGroup, 'Summary/', binLabels)
76 
77  # 1) Configure histogram with TileCalCellMonAlg algorithm execution time
78  executeTimeGroup = helper.addGroup(tileCalCellMonAlg, 'TileCalCellMonExecuteTime', topPath)
79  executeTimeGroup.defineHistogram('TIME_execute', path = 'Summary', type='TH1F',
80  title = 'Time for execute TileCalCellMonAlg algorithm;time [#mus]',
81  xbins = 100, xmin = 0, xmax = 100000)
82 
83  # 2) Configure histograms with occupancy maps over threshold (4 noise sigma) per Tile sample
84  samplesWithoutE = ['A', 'BC', 'D', '']
85  noiseEtaPhiArray = helper.addArray([len(samplesWithoutE)], tileCalCellMonAlg, 'CellsNoiseXEtaVSPhi', topPath = topPath)
86  for postfix, tool in noiseEtaPhiArray.Tools.items():
87  sample = samplesWithoutE[int( postfix.split('_')[1] )]
88  title = ('Number of Tile Cells %s' % sample) + ' with E > 4 sigma (DB);#eta;#phi'
89  name = 'eta,phi;CellsNoiseXEtaVSPhi' + (sample + 'cells' if sample else '')
90  tool.defineHistogram(name, title = title, type = 'TH2F',
91  xbins = 17, xmin = -1.7, xmax = 1.7,
92  ybins = 64, ymin = -3.14, ymax = 3.14)
93 
94  # 3) Configure histogram with number of 4 sigma seeds per Tile hash ID
95  noiseHashGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXNoiseXHash', topPath)
96  noiseHashGroup.defineHistogram('hash;CellsXNoiseXHash', path = '', type='TH1F',
97  title = 'Number of 4 sigma seeds per hash;Tile Cell Hash ID;Events',
98  xbins = 5184, xmin = -0.5, xmax = 5183.5)
99 
100  # 4) Configure histogram with Tile cell energy/noise (DB) ratio
101  noiseHashGroup = helper.addGroup(tileCalCellMonAlg, 'CellsNoiseTile', topPath)
102  noiseHashGroup.defineHistogram('noise;CellsNoiseTile', path = '', type='TH1F',
103  title = 'Energy/Noise (DB) of TileCal;Cell Energy / sigma (DB);Events',
104  xbins = 200, xmin = -10.0, xmax = 10.0)
105 
106  # 5) Configure histogram with mean Tile cell noise (DB) vs eta
107  noiseEtaGroup = helper.addGroup(tileCalCellMonAlg, 'CellsNoiseXEta', topPath)
108  noiseEtaGroup.defineHistogram('eta,noise;CellsNoiseXEta', path = '', type='TProfile',
109  title = 'Tile Cell noise #sigma (DB) vs #eta;#eta;Mean Cell noise (DB) [MeV]',
110  xbins = 17, xmin = -1.7, xmax = 1.7)
111 
112  # 6) Configure histogram with mean Tile cell noise (DB) vs phi
113  noisePhiGroup = helper.addGroup(tileCalCellMonAlg, 'CellsNoiseXPhi', topPath)
114  noisePhiGroup.defineHistogram('phi,noise;CellsNoiseXPhi', path = '', type='TProfile',
115  title = 'Tile Cell noise #sigma (DB) vs #phi;#phi;Mean Cell noise (DB) [MeV]',
116  xbins = 64, xmin = -3.14, xmax = 3.14)
117 
118  # 7) Configure histogram with number of Tile cell over threshold
119  nCellsGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXN', topPath)
120  nCellsGroup.defineHistogram('nCells;CellsXN', path = '', type='TH1F',
121  title = 'Number of Tile Cells over threshold;Number of Tile Cells; Events',
122  xbins = 250, xmin = 0, xmax = 500)
123 
124  # 8) Configure histogram with Tile cell energy in GeV
125  energyGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXE', topPath)
126  energyGroup.defineHistogram('energy;CellsXE', path = '', type='TH1F',
127  title = 'Energy of Tile Cells;Tile Cell Energy [GeV]; Events',
128  xbins = 50, xmin = 0, xmax = 20)
129 
130  # 9) Configure histogram with mean Tile cell energy in GeV vs eta
131  energyEtaGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXEta', topPath)
132  energyEtaGroup.defineHistogram('eta,energy;CellsXEta', path = '', type='TProfile',
133  title = 'Tile Cell Energy vs #eta;#eta;Mean Cell Energy [GeV]',
134  xbins = 17, xmin = -1.7, xmax = 1.7)
135 
136  # 10) Configure histogram with mean Tile cell energy in GeV vs phi
137  energyPhiGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXPhi', topPath)
138  energyPhiGroup.defineHistogram('phi,energy;CellsXPhi', path = '', type='TProfile',
139  title = 'Tile Cell Energy vs #phi;#phi;Mean Cell Energy [GeV]',
140  xbins = 64, xmin = -3.14, xmax = 3.14)
141 
142  # 11) Configure histogram with mean Tile cell energy in GeV vs tower
143  energyTowerGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXTower', topPath)
144  energyTowerGroup.defineHistogram('tower,energy;CellsXTower', path = '', type='TProfile',
145  title = 'Tile Cell Energy vs tower;Tower;Mean Cell Energy [GeV]',
146  xbins = 18, xmin = 0, xmax = 18)
147 
148  # 12) Configure histogram with occupancy map over threshold vs eta and phi
149  occupEtaPhiGroup = helper.addGroup(tileCalCellMonAlg, 'CellsXEtaVSPhi', topPath)
150  occupEtaPhiTitle = ('Number of Tile Cell above threshold %s MeV;#eta;#phi' % kwargs['EnergyThreshold'])
151  occupEtaPhiGroup.defineHistogram('eta,phi;CellsXEtaVSPhi', path = '', type='TH2F', title = occupEtaPhiTitle,
152  xbins = 17, xmin = -1.7, xmax = 1.7, ybins = 64, ymin = -3.14, ymax = 3.14)
153 
154  # 13) Configure histograms with mean Tile cell energy vs module per sample
155  samples = ['A', 'BC', 'D', 'E']
156  energyModuleArray = helper.addArray([len(samples)], tileCalCellMonAlg, 'CellsXModule', topPath = topPath)
157  for postfix, tool in energyModuleArray.Tools.items():
158  sampleIdx = int( postfix.split('_')[1] )
159  sample = samples[sampleIdx]
160  title = ('Tile Sampling %s' % sample) + ';Module;Mean Cell Energy [GeV]'
161  name = 'module,energy;CellsXModuleS' + str(sampleIdx + 1)
162  tool.defineHistogram(name, title = title, type = 'TProfile',
163  xbins = 64, xmin = 1, xmax = 65)
164 
165 
166  accumalator = helper.result()
167  cfg.merge(accumalator)
168  return cfg
169 
170 
171 if __name__=='__main__':
172 
173  # Set the Athena configuration flags
174  from AthenaConfiguration.AllConfigFlags import initConfigFlags
175  from AthenaConfiguration.TestDefaults import defaultTestFiles
176  flags = initConfigFlags()
177  flags.Input.Files = defaultTestFiles.ESD
178  flags.Output.HISTFileName = 'TileCalCellMonOutput.root'
179  flags.DQ.enableLumiAccess = False
180  flags.DQ.useTrigger = False
181  flags.lock()
182 
183  # Initialize configuration object, add accumulator, merge, and run.
184  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
185  cfg = MainServicesCfg(flags)
186 
187  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
188  cfg.merge(PoolReadCfg(flags))
189 
190  cfg.merge(TileCalCellMonAlgConfig(flags))
191 
192  flags.dump()
193  cfg.printConfig(withDetails = True, summariseProps = True)
194 
195  cfg.store( open('TileCalCellMonAlg.pkl','wb') )
196 
197  sc = cfg.run(3)
198 
199  import sys
200  # Success should be 0
201  sys.exit(not sc.isSuccess())
SystemOfUnits
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloMonAlgBase.CaloBaseHistConfig
def CaloBaseHistConfig(group, histpath, binlabels)
Definition: CaloMonAlgBase.py:5
python.CaloNoiseCondAlgConfig.CaloNoiseCondAlgCfg
def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise")
Definition: CaloNoiseCondAlgConfig.py:11
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.AtlasReadyFilterConfig.AtlasReadyFilterCfg
def AtlasReadyFilterCfg(flags)
Definition: AtlasReadyFilterConfig.py:10
Trk::open
@ open
Definition: BinningType.h:40
LArCollisionTimeConfig.LArCollisionTimeCfg
def LArCollisionTimeCfg(configFlags, cutIteration=False)
Definition: LArCollisionTimeConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
TileCalCellMonAlg.TileCalCellMonAlgConfig
def TileCalCellMonAlgConfig(flags, **kwargs)
Definition: TileCalCellMonAlg.py:12
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7