ATLAS Offline Software
Loading...
Searching...
No Matches
PPMSimBSMonitorAlgorithm.py
Go to the documentation of this file.
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3#
4import sys
5
6
8 '''Function to configure LVL1 PPM Sim algorithm in the monitoring system.'''
9
10 # get the component factory - used for getting the algorithms
11 from AthenaConfiguration.ComponentFactory import CompFactory
12 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
13 result = ComponentAccumulator()
14
15 # use L1Calo's special MonitoringCfgHelper
16 from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
17 helper = L1CaloMonitorCfgHelper(flags,CompFactory.PPMSimBSMonitorAlgorithm,'PPMSimBSMonAlg')
18
19 # get any algorithms
20 PPMSimBSMonAlg = helper.alg
21
22 # import tools
23 from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg # Needed for L1TTIDTools (ATR-21865)
24 helper.result().merge(DetDescrCnvSvcCfg(flags))
25
26 from TrigT1CaloCondSvc.L1CaloCondConfig import L1CaloCondAlgCfg
27 helper.result().merge(L1CaloCondAlgCfg(flags,Physics=True, Calib1=False, Calib2=False))
28
29 from TrigConfxAOD.TrigConfxAODConfig import getxAODConfigSvc
30 helper.result().getPrimaryAndMerge(getxAODConfigSvc(flags))
31
32 # add any steering
33 groupName = 'PPMSimBSMonitor' # the monitoring group name is also used for the package name
34 PPMSimBSMonAlg.PackageName = groupName
35
36 # Histogram paths
37 histPath_dev = 'Developer/PPMSimBSMonAlg/Simulation'
38 histPath_exp = 'Expert/PpmTrex/Simulation'
39
40 # Trigger tower plots: eta-phi granularity
41 etabins = [-4.9,-4.475,-4.050,-3.625,-3.2,-3.1,-2.9,
42 -2.7,-2.5,-2.4,-2.3,-2.2,-2.1,-2.0,-1.9,
43 -1.8,-1.7,-1.6,-1.5,-1.4,-1.3,-1.2,-1.1,
44 -1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,
45 -0.2,-0.1,0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,
46 0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,
47 1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.7,2.9,
48 3.1,3.2,3.625,4.050,4.475,4.9]
49
50 phibins = 64
51 phimin = 0
52
53
56
57 histPath = histPath_exp+'/BcidSim'
58 group_names = {"peakf": "Peakfinder", "satBcid": "SaturatedBCID"}
59 mismatch_map= {"NonZeroMatches": "Data/Simulation Non-Zero Matches", "ZeroMatches": "Data/Simulation Zero Matches", "DataNoSim":"Data but no Simulation", "SimNoData":"Simulation but no Data"}
60
61 # Eta-phi maps
62 for names in group_names:
63 for elem in mismatch_map:
64 helper.defineHistogram('etaTT_2D,phiTT_2D;ppm_2d_etaPhi_tt_'+names+'_'+elem,
65 fillGroup='group_Mismatch_{0}_{1}'.format(names, elem),
66 title='PPM '+group_names[names]+' ' + mismatch_map[elem],
67 type='TH2D', path=histPath,
68 hanConfig={
69 "description": 'PPM '+group_names[names]+' ' + mismatch_map[elem]
70 },
71 xbins=etabins, ybins=phibins, ymin=phimin, ymax=phibins,
72 opt='kAlwaysCreate')
73
74
75
76
79
80 histPath = histPath_exp+'/LutSim'
81 lut_map = { "SimEqData": "Data/Simulation Non-zero Matches", "SimNeData": "Data/Simulation Non-zero Mismatches", "SimNoData": "Simulation but no Data", "DataNoSim": "Data but no Simulation" }
82 group_names_lut = {"lutCp": ["CP", histPath], "lutJep": ["JEP", histPath] }
83
84 # EM layer
85 # MW 20/02/2025: removed kAlwaysCreate for EM which is powered off as of 2025
86 histPath = histPath_dev+'/LutSim'
87 for names in group_names_lut:
88 for elem in lut_map:
89 helper.defineHistogram('etaTT_2D,phiTT_2D;ppm_em_2d_etaPhi_tt_'+names+'_'+elem,
90 fillGroup='groupLUT{0}_EM_{1}'.format(group_names_lut[names][0],elem),
91 title='PPM LUT-'+group_names_lut[names][0]+' EM ' + lut_map[elem],
92 type='TH2D', path=histPath,
93 xbins=etabins, ybins=phibins, ymin=phimin, ymax=phibins,
94 opt='')
95
96 # HAD layer
97 histPath = histPath_exp+'/LutSim'
98 for names in group_names_lut:
99 for elem in lut_map:
100 helper.defineHistogram('etaTT_2D,phiTT_2D;ppm_had_2d_etaPhi_tt_'+names+'_'+elem,
101 fillGroup='groupLUT{0}_HAD_{1}'.format(group_names_lut[names][0],elem),
102 title='PPM LUT-'+group_names_lut[names][0]+' HAD ' + lut_map[elem],
103 type='TH2D', path=histPath,
104 hanConfig={
105 "description": 'PPM LUT-'+group_names_lut[names][0]+' HAD ' + lut_map[elem]
106 },
107 xbins=etabins, ybins=phibins, ymin=phimin, ymax=phibins,
108 opt='kAlwaysCreate')
109
110
113
114 # Mismatch errors
115 nCrates = 8
116 nModulesPerCrate = 16
117
118 y = 2 * (nModulesPerCrate + 16 * (nCrates % 2) )
119 yErrorLabels = []
120 crate_map= [ "cr0cr1", "cr2cr3", "cr4cr5", "cr6cr7"]
121
122 for elem in crate_map:
123 # kAlwaysCreate only for crates 6 and 7 (others switched off as of 2025)
124 yErrorLabels = BinErrors(y, elem)
125 helper.defineHistogram('eventMonitor,y_2D;ppm_2d_LUT_MismatchEvents_'+ elem,
126 fillGroup='group_Error_{}'.format(elem),
127 title='PPM LUT Mismatch Event Numbers;Events with Error/Mismatch;Crate/Module',
128 type='TH2I', path=histPath_exp,
129 hanConfig={
130 "display" : "SetGridx,SetGridy",
131 "algorithm" : "Histogram_Empty",
132 "description" : "PPM LUT Mismatch Event Numbers."
133 },
134 xbins=10,xmin=0, xmax=10,
135 ybins=y, ymin=0, ymax=y,ylabels=yErrorLabels,
136 opt='kAlwaysCreate' if elem == 'cr6cr7' else '')
137
138 # Finish up
139 acc = helper.result()
140 result.merge(acc)
141 return result
142
143def BinErrors(y, crs):
144
145 cr0 = crs.split("cr")[1]
146 cr1 = crs.split("cr")[2]
147
148
149 yErrorLabels = []
150 for i in range(0, int(y/2)):
151 yErrorLabels.append(str(cr0)+'/'+str(i))
152 for i in range(0, int(y/2)):
153 yErrorLabels.append(str(cr1)+'/'+str(i))
154
155 return yErrorLabels
156
157
158
159
160
161if __name__=='__main__':
162
163
164 from AthenaConfiguration.AllConfigFlags import initConfigFlags
165
166 flags = initConfigFlags()
167 flags.Exec.MaxEvents = 10
168 flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2022-02'
169 flags.Input.Files = ["/eos/atlas/atlastier0/rucio/data22_13p6TeV/express_express/00423433/data22_13p6TeV.00423433.express_express.recon.ESD.x653/data22_13p6TeV.00423433.express_express.recon.ESD.x653._lb0015._SFO-ALL._0001.2"]
170
171 flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1.root'
172
173
174 flags.lock()
175
176 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
177 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
178 acc = MainServicesCfg(flags)
179 acc.merge(PoolReadCfg(flags))
180
181
182 PPMSimBSMonitorCfg = PPMSimBSMonitoringConfig(flags)
183 acc.merge(PPMSimBSMonitorCfg)
184
185
186 acc.printConfig(withDetails=True, summariseProps = True)
187
188 sys.exit(acc.run().isFailure())
Definition merge.py:1