ATLAS Offline Software
TileMuonFitMonitorAlgorithm.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 TileMuonFitMonitorAlgorithm.py
6 @brief Python configuration of TileMuonFitMonitorAlgorithm algorithm for the Run III
7 '''
8 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory import CompFactory
10 
11 def TileMuonFitMonitoringConfig(flags, **kwargs):
12 
13  ''' Function to configure TileMuonFitMonitorAlgorithm algorithm in the monitoring system.'''
14 
15  # Define one top-level monitoring algorithm. The new configuration
16  # framework uses a component accumulator.
17 
18  result = ComponentAccumulator()
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,'TileMuonFitMonitoring')
24 
25  # Adding an TileMuonFitMonitorAlgorithm algorithm to the helper
26  TileMuonFitMonitorAlgorithm=CompFactory.TileMuonFitMonitorAlgorithm
27  tileMuonFitMonAlg = helper.addAlgorithm(TileMuonFitMonitorAlgorithm, 'TileMuonFitMonAlg')
28 
29  tileMuonFitMonAlg.TriggerChain = ''
30 
31  # L1Trigger Type Bits:
32  # bit0_RNDM, bit1_ZeroBias, bit2_L1Cal, bit3_Muon,
33  # bit4_RPC, bit5_FTK, bit6_CTP, bit7_Calib, AnyPhysTrig
34  kwargs.setdefault('fillHistogramsForL1Triggers', ['AnyPhysTrig', 'bit7_Calib'])
35  l1Triggers = kwargs['fillHistogramsForL1Triggers']
36 
37  for k, v in kwargs.items():
38  setattr(tileMuonFitMonAlg, k, v)
39 
40  run = str(flags.Input.RunNumbers[0])
41 
42  # 1) Configure histogram with TileMuonFitMonAlg algorithm execution time
43  executeTimeGroup = helper.addGroup(tileMuonFitMonAlg, 'TileMuonFitMonExecuteTime', 'Tile/')
44  executeTimeGroup.defineHistogram('TIME_execute', path = 'MuonFit', type='TH1F',
45  title = 'Time for execute TileMuonFitMonAlg algorithm;time [#mus]',
46  xbins = 100, xmin = 0, xmax = 10000)
47 
48 
49  from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
50  from TileMonitoring.TileMonitoringCfgHelper import addTile2DHistogramsArray
51 
52  # 2) Configure histograms with Tile MuonFit position at y=0
53  addTile2DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitPosition',
54  xvalue = 'zPosition', yvalue = 'xPosition',
55  title = 'Tile MuonFit position at y=0;z [mm];x [mm]', path = 'Tile/MuonFit',
56  xbins = 69, xmin = -6900, xmax = 6900., ybins = 44, ymin = -4400., ymax = 4400.,
57  type='TH2D', run = run, triggers = l1Triggers)
58 
59  # 3) Configure histograms with Tile MuonFit sinus of the angle in the y-z plane vs position
60  addTile2DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitPosDirectionTheta',
61  xvalue = 'zPosition', yvalue = 'theta', path = 'Tile/MuonFit',
62  title = 'Tile MuonFit vertical axis component;z [mm];sin(#theta)',
63  xbins = 49, xmin = -4900, xmax = 4900., ybins = 50, ymin = -0., ymax = 1.,
64  type='TH2D', run = run, triggers = l1Triggers)
65 
66  from TileMonitoring.TileMonitoringCfgHelper import addTile1DHistogramsArray
67 
68  # 4) Configure histograms with number of Tile MuonFits reconstructed
69  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitNum', xvalue = 'nMuons',
70  title = 'Number of Tile MuonFit reconstructed', path = 'Tile/MuonFit',
71  xbins = 10, xmin = -0.5, xmax = 9.5, type = 'TH1F', run = run,
72  triggers = l1Triggers, perPartition = False)
73 
74  # 5) Configure histograms with number of Tile cells per MuonFit track
75  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitNCells', xvalue = 'nCells',
76  title = 'Number of Tile cells per MuonFit track', path = 'Tile/MuonFit',
77  xbins = 10, xmin = -0.5, xmax = 9.5, type = 'TH1F', run = run,
78  triggers = l1Triggers, perPartition = False)
79 
80  # 6) Configure histograms with Tile MuonFit total energy
81  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitEnergy', xvalue = 'energy',
82  title = 'Tile MuonFit total energy;Muon energy [MeV]', path = 'Tile/MuonFit',
83  xbins = 50, xmin = 0., xmax = 10000., type = 'TH1F', run = run,
84  triggers = l1Triggers, perPartition = False)
85 
86  # 7) Configure histograms with Tile MuonFit time at y=0 plane
87  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitTime', xvalue = 'time',
88  title = 'Tile MuonFit time at y=0 plane;Muon time [ns]', path = 'Tile/MuonFit',
89  xbins = 49, xmin = -73.5, xmax = 73.5, type = 'TH1F', run = run,
90  triggers = l1Triggers, perPartition = False)
91 
92  # 8) Configure histograms with Tile MuonFit path
93  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitPath', xvalue = 'path',
94  title = 'Tile MuonFit total path length;Muon path length [mm]', path = 'Tile/MuonFit',
95  xbins = 50, xmin = 0., xmax = 10000., type = 'TH1F', run = run,
96  triggers = l1Triggers, perPartition = False)
97 
98  # 9) Configure histograms with Tile MuonFit energy density
99  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitEneDensity', xvalue = 'eneDensity',
100  title = 'Tile MuonFit energy density;Muon energy loss [MeV/mm]', path = 'Tile/MuonFit',
101  xbins = 50, xmin = 0., xmax = 10., type = 'TH1F', run = run,
102  triggers = l1Triggers, perPartition = False)
103 
104  # 10) Configure histograms with Tile MuonFit sinus of the angle in the x-y plane
105  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitDirectionPhi', xvalue = 'phi',
106  title = 'Tile MuonFit sinus of the angle in the x-y plane;sin(#phi)', path = 'Tile/MuonFit',
107  xbins = 100, xmin = -1., xmax = 1., type = 'TH1F', run = run,
108  triggers = l1Triggers, perPartition = False)
109 
110  # 11) Configure histograms with Tile MuonFit sinus of the angle in the y-z plane
111  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitDirectionTheta', xvalue = 'theta',
112  title = 'Tile MuonFit sinus of the angle in the y-z plane;sin(#theta)', path = 'Tile/MuonFit',
113  xbins = 50, xmin = 0., xmax = 1., type = 'TH1F', run = run,
114  triggers = l1Triggers, perPartition = False)
115 
116  # 12) Configure histograms with Tile MuonFit sinus of the angle in the y-z plane
117  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitPositionTime', xvalue = 'zPosition', value = 'time',
118  title = 'Tile MuonFit average time vs z position at y=0 plane;z [mm]; t [ns]', path = 'Tile/MuonFit',
119  xbins = 79, xmin = -7900., xmax = 7900., type = 'TProfile', run = run,
120  triggers = l1Triggers, perPartition = False)
121 
122  from TileMonitoring.TileMonitoringCfgHelper import getPartitionName
123 
124  # 13) Configure histograms with Tile MuonFit partition time
125  partitionLabels = [getPartitionName(ros) for ros in range(1, Tile.MAX_ROS)]
126  addTile1DHistogramsArray(helper, tileMuonFitMonAlg, name = 'TileMuonFitPartitionTime', xvalue = 'partition', value = 'time',
127  title = 'Tile MuonFit average time vs partition at y=0 plane;; t [ns]', path = 'Tile/MuonFit',
128  xbins = Tile.MAX_ROS - 1, xmin = -0.5, xmax = Tile.MAX_ROS - 1.5, xlabels = partitionLabels,
129  type = 'TProfile', run = run, triggers = l1Triggers, perPartition = False)
130 
131 
132  accumalator = helper.result()
133  result.merge(accumalator)
134  return result
135 
136 if __name__=='__main__':
137 
138  # Setup logs
139  from AthenaCommon.Logging import log
140  from AthenaCommon.Constants import INFO
141  log.setLevel(INFO)
142 
143  # Set the Athena configuration flags
144  from AthenaConfiguration.AllConfigFlags import initConfigFlags
145  from AthenaConfiguration.TestDefaults import defaultTestFiles
146  flags = initConfigFlags()
147  flags.Input.Files = defaultTestFiles.ESD
148  flags.Output.HISTFileName = 'TileMuonFitMonitorOutput.root'
149  flags.DQ.useTrigger = False
150  flags.DQ.enableLumiAccess = False
151  flags.Exec.MaxEvents = 3
152  flags.fillFromArgs()
153  flags.lock()
154 
155  # Initialize configuration object, add accumulator, merge, and run.
156  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
157  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
158  cfg = MainServicesCfg(flags)
159  cfg.merge(PoolReadCfg(flags))
160 
161  from TileCosmicAlgs.TileMuonFitterConfig import TileMuonFitterCfg
162  cfg.merge(TileMuonFitterCfg(flags))
163 
164  l1Triggers = ['bit0_RNDM', 'bit1_ZeroBias', 'bit2_L1Cal', 'bit3_Muon',
165  'bit4_RPC', 'bit5_FTK', 'bit6_CTP', 'bit7_Calib', 'AnyPhysTrig']
166 
167  cfg.merge( TileMuonFitMonitoringConfig(flags,
168  fillHistogramsForL1Triggers = l1Triggers) )
169 
170  cfg.printConfig(withDetails = True, summariseProps = True)
171  flags.dump()
172 
173  cfg.store( open('TileMuonFitMonitorAlgorithm.pkl','wb') )
174 
175  sc = cfg.run()
176 
177  import sys
178  # Success should be 0
179  sys.exit(not sc.isSuccess())
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
TileMuonFitMonitorAlgorithm.TileMuonFitMonitoringConfig
def TileMuonFitMonitoringConfig(flags, **kwargs)
Definition: TileMuonFitMonitorAlgorithm.py:11
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:256
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
TileMonitoringCfgHelper.getPartitionName
def getPartitionName(ros)
Definition: TileMonitoringCfgHelper.py:40
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileMuonFitterConfig.TileMuonFitterCfg
def TileMuonFitterCfg(flags, **kwargs)
Definition: TileMuonFitterConfig.py:12
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69