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.defineHistogram('EventType,Signature,tobMismatched;h_simSummary',title='Sim-HW Mismatches (percentage);Event Type;Signature',
28  fillGroup="mismatches",
29  path='Expert/Sim/detail', # place summary plot in the detail path in Expert audience
30  hanConfig={"display":"SetPalette(87),Draw=COLZTEXT"},
31  type='TProfile2D',
32  xlabels=["DataTowers","EmulatedTowers"],
33  ymin=0,ymax=len(L1CaloMonitorCfgHelper.SIGNATURES),ylabels=L1CaloMonitorCfgHelper.SIGNATURES,
34  opt=['kCanRebin','kAlwaysCreate'],merge="merge")
35  helper.defineHistogram('LBN,Signature;h_mismatched_SimReady',
36  fillGroup="mismatches",
37  paths=['Shifter/Sim','Expert/Sim'],
38  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"},
39  type='TH2I', cutmask='SimulationReady',
40  title='Mismatched Simulation-Ready Events;LB;Signature;Events',
41  xbins=1,xmin=0,xmax=1,
42  ylabels=["gJ","gLJ","jJ","jTAU","jXE","jTE","eTAU","eEM"],
43  opt=['kAddBinsDynamically','kCanRebin','kAlwaysCreate'],merge='merge')
44  # when there are mismatches, would be useful to know where they occurred (might be a single module gone bad)
45  # so register a location-vs-lbn histogram
46  locIdxs = []
47  for phiOct in range(0,8):
48  for etaIdx in range(-25,25):
49  locIdxs += [str(phiOct) + ":" + str(etaIdx)]
50  for sig in ["eEM","eTAU"]:
51  helper.defineHistogram("LBN,locIdx;h_"+sig+"_mismatches_posLbnMap", title = "Mismatched " + sig + " [DataTower evts];LB;Position (Octant:Eta);TOBs",
52  fillGroup = sig + "_mismatches", cutmask='SimulationReady',
53  path = "Expert/Sim/detail",
54  hanConfig={"description":"Location of mismatched " + sig + " TOBs in simulation-ready events. Use this plot to identify any localized eFEX issues."},
55  type="TH2I",
56  xbins=1,xmin=0,xmax=1, ylabels=locIdxs, opt=['kAddBinsDynamically'])
57  helper.defineHistogram('LBNString,Signature;h_mismatched_DataTowerEvts',
58  fillGroup="mismatches",
59  type='TH2I', cutmask='IsDataTowers',
60  title='Mismatched DataTower Events;LB:FirstEvtNum;Signature;Events',
61  xbins=1,xmin=0,xmax=1,
62  ybins=1,ymin=0,ymax=1,
63  opt=['kCanRebin','kAlwaysCreate'],merge='merge')
64  helper.defineHistogram('LBNString,Signature;h_mismatched_EmulatedTowerEvts',
65  fillGroup="mismatches",
66  type='TH2I', cutmask='IsEmulatedTowers',
67  title='Mismatched EmulatedTower Events;LB:FirstEvtNum;Signature;Events',
68  xbins=1,xmin=0,xmax=1,
69  ybins=1,ymin=0,ymax=1,
70  opt=['kCanRebin','kAlwaysCreate'],merge='merge')
71  helper.defineTree('LBNString,Signature,LBN,EventNumber,EventType,timeSince,timeUntil,dataEtas,dataPhis,dataWord0s,simEtas,simPhis,simWord0s;mismatched',
72  "lbnString/string:Signature/string:lbn/l: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>",
73  title="mismatched;LBN:EvtNum;Signature",fillGroup="mismatches")
74 
75 
76  result.merge(helper.result())
77  return result
78 
79 
80 if __name__=='__main__':
81  # set input file and config options
82  from AthenaConfiguration.AllConfigFlags import initConfigFlags
83  flags = initConfigFlags()
84  import glob
85 
86  # MCs processed adding L1_eEMRoI
87  inputs = glob.glob('/eos/user/t/thompson/ATLAS/LVL1_mon/MC_ESD/l1calo.361024.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ4W.eFex_gFex_2022-01-13T2101.root')
88 
89  flags.Input.Files = inputs
90  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1_MC.root'
91 
92  flags.Exec.MaxEvents=10
93 
94  flags.lock()
95  flags.dump() # print all the configs
96 
97  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
98  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
99  cfg = MainServicesCfg(flags)
100  cfg.merge(PoolReadCfg(flags))
101 
102  EfexSimMonitorCfg = EfexSimMonitoringConfig(flags)
103  cfg.merge(EfexSimMonitorCfg)
104 
105  cfg.run()
106 
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:256
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.LArBadChannelConfig.LArMaskedSCCfg
def LArMaskedSCCfg(configFlags)
Definition: LArBadChannelConfig.py:59
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69