ATLAS Offline Software
TrigTRTMonitoring.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 @brief Configuration for the heavy-ion part of MinBias monitoring
6 """
7 
8 from .utils import getMinBiasChains
9 from AthenaCommon.Logging import logging
10 
11 log = logging.getLogger('TrigTRTMonitoring')
12 
13 
14 def TrigTRTMonCfg(flags):
15  from AthenaMonitoring import AthMonitorCfgHelper
16  monConfig = AthMonitorCfgHelper(flags, 'TRTMonitoring')
17 
18  from AthenaConfiguration.ComponentFactory import CompFactory
19  alg = monConfig.addAlgorithm(CompFactory.TRTMonitoringAlg, 'TRTMonitoringAlg')
20 
21  from InDetConfig.InDetTrackSelectionToolConfig import InDetTrackSelectionTool_LoosePrimary_Cfg
22  trkSel = monConfig.resobj.popToolsAndMerge(InDetTrackSelectionTool_LoosePrimary_Cfg(flags))
23  alg.TrackSelectionTool = trkSel
24 
25  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
26  monAccess = getHLTMonitoringAccess(flags)
27  chains = getMinBiasChains(monAccess, 'HLT_noalg_L1TRT_FILLED|HLT_mb_excl_1trk5_pt1_hi_FgapAC5_L1TRT_VjTE20|HLT_noalg_L1TRT_VjTE50')
28 
29  ref_chains = ['HLT_mb_sptrk_L1ZDC_XOR_VjTE200', 'HLT_mb_sptrk_L1ZDC_1XOR5_VjTE200', 'HLT_mb_sptrk_L11ZDC_A_1ZDC_C_VjTE200'
30  'HLT_mb_sptrk_hi_FgapC5_L1VjTE200', 'HLT_mb_sptrk_hi_FgapA5_L1VjTE200', 'HLT_noalg_L1RD0_FILLED', 'HLT_mb_sptrk_L1VjTE50']
31 
32  log.info(f'Monitoring {len(chains)} L1TRT chain(s)')
33  log.debug([name for name, _ in chains])
34 
35  alg.triggerList = [name for name, _ in chains]
36  alg.refTriggerList = ref_chains
37 
38  for chain, group in chains:
39  hiTRTGroup = monConfig.addGroup(alg, f'{chain}', topPath=f'HLT/MinBiasMon/{group}/L1TRT/{chain}/')
40 
41  # 1D histograms
42  hiTRTGroup.defineHistogram('n_trk', title='Track multiplicity;N_{trk};Events / 1', xbins=20, xmin=-0.5, xmax=19.5)
43  hiTRTGroup.defineHistogram('lead_trk_pT', title='Leading track p_{T};p_{T}^{lead} [GeV];Events / 100 MeV', xbins=40, xmin=0, xmax=4)
44 
45  # TEfficiency
46  hiTRTGroup.defineHistogram(f'effPassed,n_trk;{chain}_eff_ntrk', type='TEfficiency',
47  title='L1 TRT efficiency;N_{trk};Efficiency', xbins=20, xmin=-0.5, xmax=19.5)
48  hiTRTGroup.defineHistogram(f'effPassed,lead_trk_pT;{chain}_eff_pT', type='TEfficiency',
49  title='L1 TRT efficiency;p_{T}^{lead} [GeV];Efficiency', xbins=40, xmin=0, xmax=4)
50 
51  return monConfig.result()
52 
53 
54 if __name__ == "__main__":
55  # Set the Athena configuration flags
56  from AthenaConfiguration.AllConfigFlags import initConfigFlags
57  flags = initConfigFlags()
58  flags.DQ.Environment = "AOD"
59  flags.Concurrency.NumConcurrentEvents = 5
60 
61  flags.Output.HISTFileName = "TestTRTMonitorOutput.root"
62  flags.fillFromArgs()
63  from AthenaCommon.Logging import logging
64  log = logging.getLogger(__name__)
65  log.info("Input %s", str(flags.Input.Files))
66  flags.lock()
67 
68  # Initialize configuration object, add accumulator, merge, and run.
69  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
70  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
71 
72  cfg = MainServicesCfg(flags)
73 
74  cfg.merge(PoolReadCfg(flags))
75  cfg.merge(TrigTRTMonCfg(flags))
76 
77  from AthenaCommon.Constants import DEBUG
78  cfg.getEventAlgo("TRTMonitoringAlg").OutputLevel = DEBUG
79  cfg.printConfig(withDetails=True)
80  with open("cfg.pkl", "wb") as f:
81  cfg.store(f)
82 
83  cfg.run()
84  # to run:
85  # python -m TrigMinBiasMonitoring.TrigTRTMonitoring --filesInput=...
python.TriggerConfigAccess.getHLTMonitoringAccess
HLTMonitoringAccess getHLTMonitoringAccess(flags=None)
Definition: TriggerConfigAccess.py:256
python.InDetTrackSelectionToolConfig.InDetTrackSelectionTool_LoosePrimary_Cfg
def InDetTrackSelectionTool_LoosePrimary_Cfg(flags, name="InDetTrackSelectionTool_LoosePrimary", **kwargs)
Configs based on CutLevel LoosePrimary #####.
Definition: InDetTrackSelectionToolConfig.py:54
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
Trk::open
@ open
Definition: BinningType.h:40
TrigTRTMonitoring.TrigTRTMonCfg
def TrigTRTMonCfg(flags)
Definition: TrigTRTMonitoring.py:14
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
utils.getMinBiasChains
def getMinBiasChains(monAccess, wildcard='')
Definition: Trigger/TrigMonitoring/TrigMinBiasMonitoring/python/utils.py:7
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69