ATLAS Offline Software
TrigHIMonitoringMT.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('TrigHIMonitoringMT')
12 
13 
14 def split_num(l1: str):
15  head = l1.rstrip('0123456789')
16  tail = l1[len(head):]
17  return head.replace('j', ''), int(tail)
18 
19 
20 def ranges_from_chain(chain):
21  _, l1 = chain.split('L1')
22 
23  # Extract (Vj)TE items and separate numbers from them, e.g.: 'VjTE200' -> {'VTE': 200}
24  l1_te_items = dict(map(split_num, filter(lambda x: 'TE' in x, l1.split('_'))))
25 
26  xmax = l1_te_items.pop('VTE', 20e3 if 'hi_ucc' in chain else 100) * 1.2
27  # TODO: xmin from (j)TE?
28 
29  xbins = xmax if 'hi_ucc' not in chain else 240
30  if xbins < 50:
31  xbins *= 2
32 
33  ranges = {'xbins': int(xbins), 'xmin': 0., 'xmax': xmax}
34  ranges_fwd = {'xbins': int(xbins), 'xmin': 0., 'xmax': xmax / 3.}
35 
36  return ranges, ranges_fwd
37 
38 
39 def TrigHIMonCfg(flags):
40  from AthenaMonitoring import AthMonitorCfgHelper
41  monConfig = AthMonitorCfgHelper(flags, 'HLTHeavyIonMonitoring')
42 
43  from AthenaConfiguration.ComponentFactory import CompFactory
44  alg = monConfig.addAlgorithm(CompFactory.HLTHeavyIonMonAlg, 'HLTHeavyIonMonAlgo')
45 
46  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
47  monAccess = getHLTMonitoringAccess(flags)
48  hiChains = getMinBiasChains(monAccess, '(hi_Fgap|hi_ucc).*(TE)')
49 
50  # For testing use all chains
51  # from TrigConfigSvc.TriggerConfigAccess import getHLTMenuAccess
52  # hiChains = [(c, 'Expert') for c in getHLTMenuAccess(flags) if ('hi_Fgap' in c or 'hi_ucc' in c) and 'TE' in c]
53 
54  log.info(f'Monitoring {len(hiChains)} MinBias heavy-ion chains')
55  log.debug([name for name, _ in hiChains])
56 
57  alg.triggerListMon = [name for name, _ in hiChains]
58 
59  for chain, group in hiChains:
60  hiSumETGroup = monConfig.addGroup(alg, f'{chain}_sumEt', topPath=f'HLT/MinBiasMon/{group}/SumEt/{chain}/')
61 
62  # 1D histograms
63  ranges, ranges_fwd = ranges_from_chain(chain)
64  hiSumETGroup.defineHistogram('sum_L1TE', title='TE sum from legacy L1;L1 Legacy E_{T} [GeV];Events', **ranges)
65  hiSumETGroup.defineHistogram('sum_L1jTE', title='TE sum from jFex L1;L1 jFEX E_{T} [GeV];Events', **ranges)
66  hiSumETGroup.defineHistogram('sum_L1FWDAjTE', title='FwdTE sum from jFex L1 (side A);L1 jFEX FWD_{A} E_{T} [GeV];Events', **ranges_fwd)
67  hiSumETGroup.defineHistogram('sum_L1FWDCjTE', title='FwdTE sum from jFex L1 (side C);L1 jFEX FWD_{C} E_{T} [GeV];Events', **ranges_fwd)
68  hiSumETGroup.defineHistogram('sum_FCalAEt', title='FCal sum from HLT (side A);HLT FCal_{A} E_{T} [GeV];Events', **ranges_fwd)
69  hiSumETGroup.defineHistogram('sum_FCalCEt', title='FCal sum from HLT (side C);HLT FCal_{C} E_{T} [GeV];Events', **ranges_fwd)
70 
71  # 2D histograms
72  ranges |= {'ybins': ranges['xbins'], 'ymin': ranges['xmin'], 'ymax': ranges['xmax']}
73  ranges_fwd |= {'ybins': ranges_fwd['xbins'], 'ymin': ranges_fwd['xmin'], 'ymax': ranges_fwd['xmax']}
74  hiSumETGroup.defineHistogram('sum_L1TE,sum_L1jTE', type='TH2F', title='Legacy vs Phase-I TE;L1 Legacy E_{T} [GeV];L1 jFEX E_{T} [GeV];Events', **ranges)
75  hiSumETGroup.defineHistogram('sum_L1FWDAjTE,sum_L1FWDCjTE', type='TH2F', title='FwdTE A-C side corr.;L1 jFEX FWD_{A} E_{T} [GeV];L1 jFEX FWD_{C} E_{T} [GeV];Events', **ranges_fwd)
76  hiSumETGroup.defineHistogram('sum_FCalAEt,sum_FCalCEt', type='TH2F', title='FCal sum A-C side corr.;HLT FCal_{A} E_{T} [GeV];HLT FCal_{C} E_{T} [GeV];Events', **ranges_fwd)
77  hiSumETGroup.defineHistogram('sum_L1FWDAjTE,sum_FCalAEt', type='TH2F', title='FwdTE vs FCal, A side;L1 jFEX FWD_{A} E_{T} [GeV];HLT FCal_{A} E_{T} [GeV];Events', **ranges_fwd)
78  hiSumETGroup.defineHistogram('sum_L1FWDCjTE,sum_FCalCEt', type='TH2F', title='FwdTE vs FCal, C side;L1 jFEX FWD_{C} E_{T} [GeV];HLT FCal_{C} E_{T} [GeV];Events', **ranges_fwd)
79 
80  return monConfig.result()
81 
82 
83 if __name__ == "__main__":
84  # Set the Athena configuration flags
85  from AthenaConfiguration.AllConfigFlags import initConfigFlags
86  flags = initConfigFlags()
87  flags.DQ.Environment = "AOD"
88  flags.Concurrency.NumConcurrentEvents = 5
89 
90  flags.Output.HISTFileName = "TestHIMonitorOutput.root"
91  flags.fillFromArgs()
92  from AthenaCommon.Logging import logging
93  log = logging.getLogger(__name__)
94  log.info("Input %s", str(flags.Input.Files))
95  flags.lock()
96 
97  # Initialize configuration object, add accumulator, merge, and run.
98  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
99  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
100 
101  cfg = MainServicesCfg(flags)
102 
103  cfg.merge(PoolReadCfg(flags))
104  cfg.merge(TrigHIMonCfg(flags))
105 
106  # from AthenaCommon.Constants import DEBUG
107  # cfg.getEventAlgo("HLTHeavyIonMonitoring").OutputLevel = DEBUG
108  cfg.printConfig(withDetails=True)
109  with open("cfg.pkl", "wb") as f:
110  cfg.store(f)
111 
112  cfg.run()
113  # to run:
114  # python -m TrigMinBiasMonitoring.TrigHIMonitoringMT --filesInput=...
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.TriggerConfigAccess.getHLTMonitoringAccess
HLTMonitoringAccess getHLTMonitoringAccess(flags=None)
Definition: TriggerConfigAccess.py:256
covarianceTool.filter
filter
Definition: covarianceTool.py:514
TrigHIMonitoringMT.TrigHIMonCfg
def TrigHIMonCfg(flags)
Definition: TrigHIMonitoringMT.py:39
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
TrigHIMonitoringMT.ranges_from_chain
def ranges_from_chain(chain)
Definition: TrigHIMonitoringMT.py:20
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
str
Definition: BTagTrackIpAccessor.cxx:11
TrigHIMonitoringMT.split_num
def split_num(str l1)
Definition: TrigHIMonitoringMT.py:14
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69