ATLAS Offline Software
EfexSimMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
5  '''Function to configure LVL1 Efex simulation comparison algorithm in the monitoring system.'''
6 
7 
8  # get the component factory - used for merging the algorithm results
9  from AthenaConfiguration.ComponentFactory import CompFactory
10  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
11  result = ComponentAccumulator()
12 
13  # uncomment if you want to see all the flags
14  #flags.dump() # print all the configs
15 
16  # sim monitoring requires knowing how close to a LAr masking the event is, add MaskedSCCondAlg
17  from LArBadChannelTool.LArBadChannelConfig import LArMaskedSCCfg
18  result.merge( LArMaskedSCCfg(flags) )
19 
20  # use L1Calo's special MonitoringCfgHelper
21  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
22  helper = L1CaloMonitorCfgHelper(flags,CompFactory.EfexSimMonitorAlgorithm,'EfexSimMonAlg')
23 
24  # treat every event as not being fexInput if not decoding fex inputs
25  if not flags.Trigger.L1.doCaloInputs: helper.alg.eFexTowerContainer=""
26 
27  helper.defineDQAlgorithm("L1CaloMismatchRate",
28  hanConfig={"libname":"libdqm_summaries.so","name":"Bins_GreaterThan_Threshold","BinThreshold":"0.9"}, # counts bins with value>0.9
29  thresholdConfig={"NBins":[0,10]}, # warn if any high rate, error if more than 10 bins anywhere.
30  )
31 
32  helper.defineHistogram('EventType,Signature,tobMismatched;h_simSummary',title='Sim-HW Mismatches (percentage);Event Type;Signature',
33  fillGroup="mismatches",
34  path='Expert/Sim/detail', # place summary plot in the detail path in Expert audience
35  hanConfig={"display":"SetPalette(87),Draw=COLZTEXT"},
36  type='TProfile2D',
37  xlabels=["DataTowers","EmulatedTowers"],
38  ymin=0,ymax=len(L1CaloMonitorCfgHelper.SIGNATURES),ylabels=L1CaloMonitorCfgHelper.SIGNATURES,
39  opt=['kCanRebin','kAlwaysCreate'],merge="merge")
40  helper.defineHistogram('LBN,Signature;h_mismatched_SimReady',
41  fillGroup="mismatches_count",
42  paths=['Shifter/Sim'],
43  hanConfig={"algorithm":"Histogram_Empty","description":"Number of events with a mismatch, per LB (x-axis), per signature (y-axis) for signatures that are deemed simulation-ready","display":"SetPalette(55)"},
44  type='TH2I', cutmask='SimulationReady',
45  title='Mismatched Simulation-Ready Events;LB;Signature;Events',
46  xbins=1,xmin=0,xmax=1,
47  ylabels=["gJ","gLJ","jJ","jTAU","jXE","jTE","eTAU","eEM"],
48  opt=['kAddBinsDynamically','kCanRebin','kAlwaysCreate'],merge='merge')
49  helper.defineHistogram('LBN,Signature,tobMismatched;h_mismatched_SimReadyRate',
50  fillGroup="mismatches",
51  paths=['Expert/Sim'],
52  hanConfig={"algorithm":"L1CaloMismatchRate","description":"Mismatch rate, per LB (x-axis), per signature (y-axis) for signatures that are deemed simulation-ready - should not be high rate (see DQ algo)","display":"SetPalette(55)"},
53  type='TProfile2D', cutmask='SimulationReady',
54  title='Mismatched Rate for Simulation-Ready Signatures;LB;Signature;Event Rate (%)',
55  xbins=1,xmin=0,xmax=1,
56  ylabels=["gJ","gLJ","jJ","jTAU","jXE","jTE","eTAU","eEM"],
57  opt=['kAddBinsDynamically','kCanRebin','kAlwaysCreate'],merge='merge')
58  # when there are mismatches, would be useful to know where they occurred (might be a single module gone bad)
59  # so register a location-vs-lbn histogram
60  for sig in ["eEM","eTAU"]:
61  helper.defineHistogram("LBN,locIdx;h_"+sig+"_mismatches_posLbnMap", title = "Mismatched " + sig + " [DataTower evts];LB;Position (Module:Proc:Eta:Phi);TOBs",
62  fillGroup = sig + "_mismatches", cutmask='SimulationReady',
63  path = "Expert/Sim",
64  hanConfig={
65  "algorithm":"Histogram_Empty",
66  "display":"SetPalette(87)",
67  "description":"Location of mismatched " + sig + " TOBs in simulation-ready events. Use this plot to identify any localized eFEX issues. N.B. this plot is only created if there are mismatches."},
68  type="TH2I",
69  xbins=1,xmin=0,xmax=1,
70  ybins=1,ymin=0,ymax=1,
71  opt=['kAddBinsDynamically'])
72  helper.defineHistogram('LBNString,Signature;h_mismatched_DataTowerEvts',
73  fillGroup="mismatches",
74  type='TH2I', cutmask='IsDataTowers',
75  title='Mismatched DataTower Events;LB:FirstEvtNum;Signature;Events',
76  xbins=1,xmin=0,xmax=1,
77  ybins=1,ymin=0,ymax=1,
78  opt=['kCanRebin','kAlwaysCreate'],merge='merge')
79  helper.defineHistogram('LBN,Signature;h_mismatched_EmulatedTowerEvts',
80  fillGroup="mismatches",
81  type='TH2I', cutmask='IsEmulatedTowers',
82  title='Mismatched EmulatedTower Events;LB;Signature;Events',
83  xbins=1,xmin=0,xmax=1,
84  ybins=1,ymin=0,ymax=1,
85  opt=['kCanRebin','kAlwaysCreate','kAddBinsDynamically'],merge='merge')
86  helper.defineTree('LBN,Signature,LBNString,EventNumber,EventType,timeSince,timeUntil,dataEtas,dataPhis,dataWord0s,simEtas,simPhis,simWord0s;mismatched',
87  "lbn/l:Signature/string:lbnString/string:eventNumber/l:EventType/string:timeSince/I:timeUntil/I:dataEtas/vector<float>:dataPhis/vector<float>:dataWord0s/vector<unsigned int>:simEtas/vector<float>:simPhis/vector<float>:simWord0s/vector<unsigned int>",
88  title="mismatched;LBN;Signature",fillGroup="mismatches")
89 
90 
91  result.merge(helper.result())
92  return result
93 
94 
95 if __name__=='__main__':
96  # set input file and config options
97  from AthenaConfiguration.AllConfigFlags import initConfigFlags
98  flags = initConfigFlags()
99  import glob
100 
101  # MCs processed adding L1_eEMRoI
102  inputs = glob.glob('/eos/user/t/thompson/ATLAS/LVL1_mon/MC_ESD/l1calo.361024.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ4W.eFex_gFex_2022-01-13T2101.root')
103 
104  flags.Input.Files = inputs
105  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1_MC.root'
106 
107  flags.Exec.MaxEvents=10
108 
109  flags.lock()
110  flags.dump() # print all the configs
111 
112  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
113  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
114  cfg = MainServicesCfg(flags)
115  cfg.merge(PoolReadCfg(flags))
116 
117  EfexSimMonitorCfg = EfexSimMonitoringConfig(flags)
118  cfg.merge(EfexSimMonitorCfg)
119 
120  cfg.run()
121 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
EfexSimMonitorAlgorithm.EfexSimMonitoringConfig
def EfexSimMonitoringConfig(flags)
Definition: EfexSimMonitorAlgorithm.py:4
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.LArBadChannelConfig.LArMaskedSCCfg
def LArMaskedSCCfg(configFlags)
Definition: LArBadChannelConfig.py:59
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69