ATLAS Offline Software
GfexSimMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 def GfexSimMonitoringConfig(flags, UseOfflineCopy = True):
5  '''Function to configure LVL1 Gfex simulation comparison algorithm in the monitoring system.'''
6 
7  # use L1Calo's special MonitoringCfgHelper
8  from AthenaConfiguration.ComponentFactory import CompFactory
9  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
10  helper = L1CaloMonitorCfgHelper(flags,CompFactory.GfexSimMonitorAlgorithm,'GfexSimMonAlg')
11 
12  helper.defineDQAlgorithm("L1CaloMismatchRate",
13  hanConfig={"libname":"libdqm_summaries.so","name":"Bins_GreaterThan_Threshold","BinThreshold":"0.9"}, # counts bins with value>0.9
14  thresholdConfig={"NBins":[0,10]}, # warn if any high rate, error if more than 10 bins anywhere.
15  )
16 
17  helper.defineHistogram('LBN,Signature;h_mismatched_SimReady',
18  fillGroup="mismatches_count",
19  paths=['Shifter/Sim'],
20  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)"},
21  type='TH2I', cutmask='SimulationReady',
22  title='Mismatched Simulation-Ready Events;LB;Signature;Events',
23  xbins=1,xmin=0,xmax=1,
24  ylabels=["gJ","gLJ","jJ","jTAU","jXE","jTE","eTAU","eEM"],
25  opt=['kAddBinsDynamically','kCanRebin','kAlwaysCreate'],merge='merge')
26  helper.defineHistogram('LBN,Signature,tobMismatched;h_mismatched_SimReadyRate',
27  fillGroup="mismatches",
28  paths=['Expert/Sim'],
29  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)"},
30  type='TProfile2D', cutmask='SimulationReady',
31  title='Mismatched Rate for Simulation-Ready Signatures;LB;Signature;Event Rate (%)',
32  xbins=1,xmin=0,xmax=1,
33  ylabels=["gJ","gLJ","jJ","jTAU","jXE","jTE","eTAU","eEM"],
34  opt=['kAddBinsDynamically','kCanRebin','kAlwaysCreate'],merge='merge')
35  helper.defineHistogram('EventType,Signature,tobMismatched;h_simSummary',title='Sim-HW Mismatches (percentage);Event Type;Signature',
36  fillGroup="mismatches",
37  path='Expert/Sim/detail', # place summary plot in the detail path in Expert audience
38  hanConfig={"display":"SetPalette(87),Draw=COLZTEXT"},
39  type='TProfile2D',
40  xlabels=["DataTowers","EmulatedTowers"],
41  ymin=0,ymax=len(L1CaloMonitorCfgHelper.SIGNATURES),ylabels=L1CaloMonitorCfgHelper.SIGNATURES,
42  opt=['kCanRebin','kAlwaysCreate'],merge="merge")
43 
44  for sig in ["gJ","gLJ"]:
45  helper.defineHistogram("LBN,locIdx;h_"+sig+"_mismatches_posLbnMap", title = "Mismatched " + sig + " [DataTower evts];LB;Position (iEta:iPhi);TOBs",
46  fillGroup = "mismatches"+ sig,
47  type="TH2I",
48  path="Expert/Sim/detail",
49  hanConfig={
50  "display":"SetPalette(87)",
51  "description":"Location of mismatched " + sig + " TOBs. Use this plot to identify any localized gFEX issues. N.B. this plot is only created if there are mismatches."},
52  xbins=1,xmin=0,xmax=1,
53  ybins=1,ymin=0,ymax=1,
54  opt=['kAddBinsDynamically'])
55 
56 
57  helper.defineTree('LBN,Signature,LBNString,EventNumber,dataEtas,dataPhis,dataWord0s,simEtas,simPhis,simWord0s;mismatched',
58  "lbn/l:Signature/string:lbnString/string:eventNumber/l:dataEtas/vector<float>:dataPhis/vector<float>:dataWord0s/vector<unsigned int>:simEtas/vector<float>:simPhis/vector<float>:simWord0s/vector<unsigned int>",
59  title="mismatched;LBN;Signature",fillGroup="mismatches")
60 
61  return helper.result()
62 
63 
64 if __name__=='__main__':
65  # set input file and config options
66  from AthenaConfiguration.AllConfigFlags import initConfigFlags
67  import glob
68 
69  import argparse
70  parser = argparse.ArgumentParser(prog='python -m TrigT1CaloMonitoring.GfexSimMonitorAlgorithm',
71  description="""Used to run gFEX Monitoring\n\n
72  Example: python -m TrigT1CaloMonitoring.GfexSimMonitorAlgorithm --filesInput file.root.\n
73  Overwrite inputs using standard athena opts --filesInput, evtMax etc. see athena --help""")
74  parser.add_argument('--evtMax',type=int,default=-1,help="number of events")
75  parser.add_argument('--filesInput',nargs='+',help="input files",required=True)
76  parser.add_argument('--skipEvents',type=int,default=0,help="number of events to skip")
77  args = parser.parse_args()
78 
79 
80  flags = initConfigFlags()
81  flags.Trigger.triggerConfig='DB'
82  flags.Input.Files = [file for x in args.filesInput for file in glob.glob(x)]
83  flags.Output.HISTFileName = 'gFexSimData_Monitoring.root'
84 
85  flags.Exec.MaxEvents = args.evtMax
86  flags.Exec.SkipEvents = args.skipEvents
87 
88  flags.lock()
89 
90  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
91  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
92  cfg = MainServicesCfg(flags)
93  cfg.merge(PoolReadCfg(flags))
94 
95  GfexSimMonitorCfg = GfexSimMonitoringConfig(flags)
96  cfg.merge(GfexSimMonitorCfg)
97 
98  from TrigT1CaloMonitoring.GfexInputMonitorAlgorithm import GfexInputMonitoringConfig
99  GfexInputMonitorCfg = GfexInputMonitoringConfig(flags)
100  cfg.merge(GfexInputMonitorCfg)
101 
102  cfg.run()
GfexSimMonitorAlgorithm.GfexSimMonitoringConfig
def GfexSimMonitoringConfig(flags, UseOfflineCopy=True)
Definition: GfexSimMonitorAlgorithm.py:4
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:259
GfexInputMonitorAlgorithm.GfexInputMonitoringConfig
def GfexInputMonitoringConfig(flags)
Definition: GfexInputMonitorAlgorithm.py:4
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69