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",
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='SimulationReadyMismatch',
45  title='Mismatched Simulation-Ready Events;LB;Signature;Events',
46  xbins=1,xmin=0,xmax=1,
47  ylabels=["gJ","gLJ","jJ","jTAU","jEM","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","jEM","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("LBN,locIdx;h_"+sig+"_mismatchesEmulated_posLbnMap", title = "Mismatched " + sig + " [EmulatedTower evts];LB;Position (Module:Proc:Eta:Phi);TOBs",
73  fillGroup = sig + "_mismatches", cutmask='IsEmulatedTowers',
74  path = "Expert/Sim",
75  hanConfig={
76  "algorithm":"Histogram_Empty",
77  "display":"SetPalette(87)",
78  "description":"Location of mismatched " + sig + " TOBs in events with EmulatedTower simput. Discuss mismatches with expert, they may be caused by LATOME readout issues if there are LAr Mismatches in Input/eFEX folder. N.B. this plot is only created if there are mismatches."},
79  type="TH2I",
80  xbins=1,xmin=0,xmax=1,
81  ybins=1,ymin=0,ymax=1,
82  opt=['kAddBinsDynamically'])
83  helper.defineHistogram('LBNString,Signature;h_mismatched_DataTowerEvts',
84  fillGroup="mismatches",
85  type='TH2I', cutmask='IsDataTowers',
86  title='Mismatched DataTower Events;LB:FirstEvtNum;Signature;Events',
87  xbins=1,xmin=0,xmax=1,
88  ybins=1,ymin=0,ymax=1,
89  opt=['kCanRebin','kAlwaysCreate'],merge='merge')
90  helper.defineHistogram('LBN,Signature;h_mismatched_EmulatedTowerEvts',
91  fillGroup="mismatches",
92  type='TH2I', cutmask='IsEmulatedTowers',
93  title='Mismatched EmulatedTower Events;LB;Signature;Events',
94  xbins=1,xmin=0,xmax=1,
95  ybins=1,ymin=0,ymax=1,
96  opt=['kCanRebin','kAlwaysCreate','kAddBinsDynamically'],merge='merge')
97  helper.defineTree('LBN,SignatureEvtType,LBNString,EventNumber,EventType,timeSince,timeUntil,dataEtas,dataPhis,dataWord0s,simEtas,simPhis,simWord0s;mismatched',
98  "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>",
99  title="mismatched (including events with LATOME readout and OTF masking issues);LBN;Signature",
100  fillGroup="mismatches")
101 
102 
103  result.merge(helper.result())
104  return result
105 
106 
107 if __name__=='__main__':
108  # set input file and config options
109  from AthenaConfiguration.AllConfigFlags import initConfigFlags
110  flags = initConfigFlags()
111  import glob
112 
113  # MCs processed adding L1_eEMRoI
114  inputs = glob.glob('/eos/user/t/thompson/ATLAS/LVL1_mon/MC_ESD/l1calo.361024.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ4W.eFex_gFex_2022-01-13T2101.root')
115 
116  flags.Input.Files = inputs
117  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1_MC.root'
118 
119  flags.Exec.MaxEvents=10
120 
121  flags.lock()
122  flags.dump() # print all the configs
123 
124  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
125  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
126  cfg = MainServicesCfg(flags)
127  cfg.merge(PoolReadCfg(flags))
128 
129  EfexSimMonitorCfg = EfexSimMonitoringConfig(flags)
130  cfg.merge(EfexSimMonitorCfg)
131 
132  cfg.run()
133 
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:312
python.LArBadChannelConfig.LArMaskedSCCfg
def LArMaskedSCCfg(configFlags)
Definition: LArBadChannelConfig.py:63
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71