ATLAS Offline Software
TrigMBTSMonitoringMT.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 @brief Configuration for the MBTS monitoring
7 '''
8 from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
9 from AthenaCommon.Logging import logging
10 
11 from .utils import getMinBiasChains
12 
13 log = logging.getLogger('TrigMBTSMonitoringMT')
14 
15 
16 def TrigMBTS(configFlags):
17  from AthenaMonitoring import AthMonitorCfgHelper
18  monConfig = AthMonitorCfgHelper(configFlags, 'HLTMBTSMonitoringAlgMTflags')
19 
20  from AthenaConfiguration.ComponentFactory import CompFactory
21  alg = monConfig.addAlgorithm(
22  CompFactory.HLTMBTSMonitoringAlgMT, 'HLTMBTSMonitoringAlgMT')
23 
24  monAccess = getHLTMonitoringAccess(configFlags)
25  mbts_chains = getMinBiasChains(monAccess, '(_mbts_)')
26 
27  log.info(f'Monitoring {len(mbts_chains)} MBTS chains')
28  log.debug([name for name, _ in mbts_chains])
29 
30  alg.triggerList = [name for name, _ in mbts_chains]
31  channelLabels = [f'A{i:0>2d}' for i in range(16)]
32  channelLabels += [f'C{i:0>2d}' for i in range(16)]
33 
34  length = len(alg.triggerList)
35  MBTS_countsSideA = 16
36  MBTS_countsSideC = 16
37 
38  mbtsGroup = monConfig.addGroup(alg, 'MBTSall', topPath='HLT/MBTSMon/')
39  mbtsGroup.defineHistogram('TrigCounts', title='Trigger counts;;Event rate',
40  xbins=length, xmin=0, xmax=length, xlabels=list(alg.triggerList))
41 
42  for chain, level in mbts_chains:
43 
44  mbShiftGroup = monConfig.addGroup(alg, chain+'_shifter', topPath=f'HLT/MBTSMon/{level}/{chain}/')
45 
46  mbShiftGroup.defineHistogram('MBTS_A_hits', type='TH1I', title='MBTS hits side A; Entry rate; MBTS side A',
47  xbins=MBTS_countsSideA+1, xmin=-0.5, xmax=MBTS_countsSideA+0.5)
48  mbShiftGroup.defineHistogram('MBTS_C_hits', type='TH1I', title='MBTS hits side C; Entry rate; MBTS side C',
49  xbins=MBTS_countsSideC+1, xmin=-0.5, xmax=MBTS_countsSideC+0.5)
50  mbShiftGroup.defineHistogram('MBTS_A_EWTime,MBTS_C_EWTime', type='TH2I', title='MBTS timing correlation; MBTS side A; MBTS side C',
51  xbins=40, xmin=-80, xmax=80, ybins=40, ymin=-80, ymax=80)
52  mbShiftGroup.defineHistogram('MBTS_A_hits,MBTS_C_hits', type='TH2I', title='MBTS hits correlation; MBTS side A; MBTS side C',
53  xbins=MBTS_countsSideA+1, xmin=-0.5, xmax=MBTS_countsSideA+0.5, ybins=MBTS_countsSideC+1, ymin=-0.5, ymax=MBTS_countsSideC+0.5)
54 
55  mbShiftGroup.defineHistogram(
56  'MBTS_time', type='TH1F', title='MBTS time in all pads; MBTS time [ns]', xbins=100, xmin=-100, xmax=100)
57  mbShiftGroup.defineHistogram(
58  'MBTS_energy', type='TH1F', title='MBTS energy in all pads; MBTS energy [pC]', xbins=100, xmin=0.1, xmax=9.9)
59  mbShiftGroup.defineHistogram('MBTS_channelID;MBTS_counts_per_channel', type='TH1F', title='Counts per MBTS Channel ID; Channel ID; Count',
60  xbins=MBTS_countsSideA+MBTS_countsSideC, xmin=0, xmax=MBTS_countsSideA+MBTS_countsSideC, xlabels=list(channelLabels))
61  mbShiftGroup.defineHistogram('MBTS_channelID,MBTS_time', type='TH2F', title='MBTS time; Channel ID;MBTS time [ns]; Entry rate',
62  xbins=MBTS_countsSideA+MBTS_countsSideC, xmin=0, xmax=MBTS_countsSideA+MBTS_countsSideC, xlabels=list(channelLabels), ybins=100, ymin=-100, ymax=100)
63  mbShiftGroup.defineHistogram('MBTS_channelID,MBTS_time;MBTS_time_zoom_vs_MBTS_channel_ID', type='TH2F', title='MBTS time zoom; Channel ID;MBTS time [ns]; Entry rate',
64  xbins=MBTS_countsSideA+MBTS_countsSideC, xmin=0, xmax=MBTS_countsSideA+MBTS_countsSideC, xlabels=list(channelLabels), ybins=100, ymin=-50, ymax=50)
65  mbShiftGroup.defineHistogram('MBTS_channelID,MBTS_energy', type='TH2F', title='MBTS energy; Channel ID;MBTS energy [pC]; Entry rate',
66  xbins=MBTS_countsSideA+MBTS_countsSideC, xmin=0, xmax=MBTS_countsSideA+MBTS_countsSideC, xlabels=list(channelLabels), ybins=100, ymin=-0.1, ymax=1.9)
67 
68  mbShiftGroup.defineHistogram('MBTS_diff_timeMean', type='TH1F', title='Mean MBTS time difference between sides; MBTS time [ns]',
69  xbins=100, xmin=-100, xmax=100)
70  mbShiftGroup.defineHistogram('MBTS_diff_weightedTimeMean', type='TH1F', title='Energy weighted mean MBTS time difference between sides; MBTS time [ns]',
71  xbins=100, xmin=-100, xmax=100)
72 
73  mbExpGroup = monConfig.addGroup(alg, chain+'_expert',
74  topPath='HLT/MBTSMon/'+chain+'/')
75  mbExpGroup.defineHistogram(
76  'MBTShits', type='TH2F', title='MBTS total hits;# of Hits;Entry Rate', xbins=24, xmin=0, xmax=100)
77 
78  mbExpGroup.defineHistogram('MBTS_A_meanEnergy', type='TH1F',
79  title='Mean MBTS Energy A side passed;MBTS Energy [pC];Entry Rate', xbins=100, xmin=-0.1, xmax=9.9)
80  mbExpGroup.defineHistogram('MBTS_C_meanEnergy', type='TH1F',
81  title='Mean MBTS Energy C side passed;MBTS Energy [pC];Entry Rate', xbins=100, xmin=-0.1, xmax=9.9)
82 
83  mbExpGroup.defineHistogram('MBTS_A_meanTime', type='TH1F',
84  title='Mean MBTS Time A side; MBTS time [ns]', xbins=100, xmin=-100, xmax=100)
85  mbExpGroup.defineHistogram('MBTS_C_meanTime', type='TH1F',
86  title='Mean MBTS Time C side; MBTS time [ns]', xbins=100, xmin=-100, xmax=100)
87 
88  return monConfig.result()
89 
90 
91 if __name__ == '__main__':
92  # Setup logs
93  from AthenaCommon.Constants import DEBUG
94  # Set the Athena configuration flags
95  from AthenaConfiguration.AllConfigFlags import initConfigFlags
96 
97  flags = initConfigFlags()
98  flags.Output.HISTFileName = 'TestMBTSMonitorOutput.root'
99  flags.fillFromArgs()
100  flags.lock()
101 
102  # Initialize configuration object, add accumulator, merge, and run.
103  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
104  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
105  cfg = MainServicesCfg(flags)
106  cfg.merge(PoolReadCfg(flags))
107  cfg.merge(TrigMBTS(flags))
108 
109  cfg.getEventAlgo('HLTMBTSMonitoringAlgMT').OutputLevel = DEBUG # DEBUG
110  cfg.printConfig(withDetails=True) # set True for exhaustive info
111  with open("cfg.pkl", "wb") as f:
112  cfg.store(f)
113 
114  cfg.run() # use cfg.run(20) to only run on first 20 events
115  # to run:
116  # python -m TrigMinBiasMonitoring.TrigMBTSMonitoringMT --filesInput=
python.TriggerConfigAccess.getHLTMonitoringAccess
HLTMonitoringAccess getHLTMonitoringAccess(flags=None)
Definition: TriggerConfigAccess.py:256
TrigMBTSMonitoringMT.TrigMBTS
def TrigMBTS(configFlags)
Definition: TrigMBTSMonitoringMT.py:16
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
utils.getMinBiasChains
def getMinBiasChains(monAccess, wildcard='')
Definition: Trigger/TrigMonitoring/TrigMinBiasMonitoring/python/utils.py:7
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69