ATLAS Offline Software
GfexInputMonitorAlgorithm.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 GfexInput algorithm in the monitoring system.'''
6 
7  # get the component factory - used for getting the algorithms
8  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9  result = ComponentAccumulator()
10 
11  # for input monitoring we will require the emulated gFexTowers (built from supercells)
12  from L1CaloFEXAlgos.FexEmulatedTowersConfig import gFexEmulatedTowersCfg
13  result.merge(gFexEmulatedTowersCfg(flags,name="L1_gFexEmulatedTowers"))
14 
15 
16  # use L1Calo's special MonitoringCfgHelper
17  from AthenaConfiguration.ComponentFactory import CompFactory
18  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
19  helper = L1CaloMonitorCfgHelper(flags,CompFactory.GfexInputMonitorAlgorithm,'GfexInputMonAlg')
20 
21  # add any steering
22  groupName = 'GfexInputMonitor' # the monitoring group name is also used for the package name
23  helper.alg.PackageName = groupName
24 
25 
26  # path to the expert area for gFex Monitoring Plots
27  trigPath = 'Expert/Inputs/gFEX'
28 
29 
30  import numpy as np
31  eta_bins= [-4.9, -4.1,-3.5,-3.25,-3.2,-3.1,-2.9,-2.7,-2.5]
32  for eta in np.arange (-2.2,2.2,0.2):
33  eta_bins.append(eta)
34  eta_bins+= [2.2,2.5,2.7,2.9,3.1,3.25,3.3,3.5,4.1,4.9]
35 
36  helper.defineDQAlgorithm("Gfex_Tower_etaPhiMapFilled",
37  hanConfig={"libname":"libdqm_summaries.so","name":"Bins_Equal_Threshold","BinThreshold":"0."},
38  thresholdConfig={"NBins":[0,32*40]}, # 0 bins expected to be empty
39  )
40 
41 
42  helper.defineTree('LBN,Error,EventNumber,TowerId,TowerEta,TowerPhi,TowerEt,RefTowerEt,TowerSaturationflag,RefTowerSat;errors',
43  "lbn/I:error/string:eventNumber/l:id/i:eta/F:phi/F:et/I:ref_et/I:sat/B:ref_sat/B",
44  title="errors tree;LBN;Error",fillGroup="errors")
45 
46  # histograms of gFex tower variables
47  helper.defineHistogram('LBN,NGfexTowers;h_LBN_vs_nGfexTowers', title='Number of gFex towers in each event with Et > 10 GeV (MLE > 1662);LBN; gTowers per event; Number of events',
48  fillGroup = "highEtgTowers",
49  type='TH2D',
50  path=f'{trigPath}/detail',
51  hanConfig={"description":"The y value gives the number of gTowers with Et > 10 GeV; the z value gives the number of events"},
52  xbins=1,xmin=0,xmax=1,
53  ybins=1,ymin=0,ymax=1,
54  opt=['kAddBinsDynamically']
55  )
56 
57  helper.defineHistogram('TowerEta,TowerPhi;h_HotTower_EtaPhiMap', title='gFex Tower Eta vs Phi (gTowerEt > 2 GeV (MLE > 1342)) ;#eta;#phi; Number of gTowers',
58  fillGroup = "highEtgTowers",
59  type='TH2F',
60  path=trigPath,
61  hanConfig={
62  "algorithm": "Gfex_Tower_etaPhiMapFilled",
63  "description":"Look for hot spots with unusual high statistics; Check <a href='./detail/h_HotTowers_posVsLBN'>detail plot</a> to get timeseries for each location", "display":"SetPalette(55),Draw=COL1Z"},
64  xbins=eta_bins, ybins=32,ymin=-3.2,ymax=3.2)
65 
66 
67 
68  helper.defineHistogram('LBN,binNumber;h_HotTowers_posVsLBN',title='gFex Towers with Et > 2GeV (MLE > 1342);LB;32(x-1)+y',
69  path=f"{trigPath}/detail",
70  fillGroup = "highEtgTowers",
71  hanConfig={"description":"x and y correspond to axis bin numbers on <a href='../h_HotTower_EtaPhiMap'/>eta-phi plot</a>. Use this plot to check if hotspot/coldspots affected whole or part of run: turn on Projection X1 to see 1D hist of individual locations"},
72  type='TH2I',
73  xbins=1,xmin=0,xmax=10,
74  ybins=40*32,ymin=0.5,ymax=40*32+0.5,
75  opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
76 
77  helper.defineHistogram('TowerEta,TowerPhi,TowerEt;h_HotTower_HeatMap', title='gFex Tower Average Et Distribution (gTowerEt > 2 GeV (MLE > 1342)) ;#eta;#phi;averageEt(MLE)',
78  fillGroup = "highEtgTowers",
79  type='TProfile2D',
80  xbins=eta_bins, ybins=32,ymin=-3.2,ymax=3.2)
81 
82 
83 
84 
85  helper.defineHistogram('TowerEta,TowerPhi;h_ColdTower_EtaPhiMap', title='gFex Tower Eta vs Phi (gTower Et < - 2 GeV (MLE < 1182) ;#eta;#phi;Number of gTowers',
86  fillGroup = "lowEtgTowers",
87  type='TH2F',
88  path=trigPath,
89  hanConfig={
90  "algorithm": "Gfex_Tower_etaPhiMapFilled",
91  "description":"Look for cold spots with unusual high statistics; Check <a href='./detail/h_ColdTowers_posVsLBN'>detail plot</a> to get timeseries for each location ", "display":"SetPalette(55),Draw=COL1Z"},
92  xbins=eta_bins, ybins=32,ymin=-3.2,ymax=3.2)
93 
94  helper.defineHistogram('LBN,binNumber;h_ColdTowers_posVsLBN',title='gFex Towers with Et < -2GeV (MLE < 1182);LB;32(x-1)+y',
95  path=f"{trigPath}/detail",
96  fillGroup = "lowEtgTowers",
97  hanConfig={"description":"x and y correspond to axis bin numbers on <a href='../h_ColdTower_EtaPhiMap'/>eta-phi plot</a>. Use this plot to check if hotspot/coldspots affected whole or part of run: turn on Projection X1 to see 1D hist of individual locations"},
98  type='TH2I',
99  xbins=1,xmin=0,xmax=10,
100  ybins=40*32,ymin=0.5,ymax=40*32+0.5,
101  opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
102 
103  helper.defineHistogram('TowerEta,TowerPhi,TowerEt;h_ColdTower_HeatMap', title='gFex Tower Average Et Distribution (gTower Et < - 2 GeV (MLE < 1182)) ;#eta;#phi;averageEt (MLE)',
104  fillGroup = "lowEtgTowers",
105  type='TProfile2D',
106  xbins=eta_bins, ybins=32,ymin=-3.2,ymax=3.2)
107 
108 
109  helper.defineHistogram('TowerEt;h_TowerEt', title='gFex Tower Et ; Et (MLE)',
110  fillGroup = "gTowers",
111  type='TH1I',
112  xbins= 2000 , xmin=500, xmax=2500.0)
113 
114 
115  helper.defineHistogram('TowerEta,TowerPhi,TowerEt;h_SaturatedTower_HeatMap', title='gFex Tower Average Et Distribution for Saturated gTower ;#eta;#phi;averageEt (MLE)',
116  fillGroup = "SatgTowers",
117  type='TProfile2D',
118  xbins=eta_bins, ybins=32,ymin=-3.2,ymax=3.2)
119 
120 
121 
122  acc = helper.result()
123  result.merge(acc)
124  return result
125 
126 if __name__=='__main__':
127  # set input file and config options
128  from AthenaConfiguration.AllConfigFlags import initConfigFlags
129  import glob
130 
131  inputs = glob.glob('/eos/atlas/atlastier0/rucio/data18_13TeV/physics_Main/00354311/data18_13TeV.00354311.physics_Main.recon.ESD.f1129/data18_13TeV.00354311.physics_Main.recon.ESD.f1129._lb0013._SFO-8._0001.1')
132 
133  flags = initConfigFlags()
134  flags.Input.Files = inputs
135  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1_MC.root'
136 
137  flags.lock()
138  flags.dump() # print all the configs
139 
140  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
141  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
142  cfg = MainServicesCfg(flags)
143  cfg.merge(PoolReadCfg(flags))
144 
145  GfexInputMonitorCfg = GfexInputMonitoringConfig(flags)
146  cfg.merge(GfexInputMonitorCfg)
147 
148  # options - print all details of algorithms, very short summary
149  cfg.printConfig(withDetails=False, summariseProps = True)
150 
151  nevents=10
152  cfg.run(nevents)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
GfexInputMonitorAlgorithm.GfexInputMonitoringConfig
def GfexInputMonitoringConfig(flags)
Definition: GfexInputMonitorAlgorithm.py:4
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
FexEmulatedTowersConfig.gFexEmulatedTowersCfg
def gFexEmulatedTowersCfg(flags, name="L1_gFexEmulatedTowers", writeKey="L1_gFexEmulatedTowers")
Definition: FexEmulatedTowersConfig.py:9
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71