5 '''Function to configure LVL1 JepCmx algorithm in the monitoring system.'''
8 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
9 from AthenaConfiguration.Enums
import Format
10 from AthenaConfiguration.ComponentFactory
import CompFactory
11 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
12 from TrigConfigSvc.TriggerConfigAccess
import getL1MenuAccess
17 from AthenaMonitoring
import AthMonitorCfgHelper
18 helper = AthMonitorCfgHelper(inputFlags,
'JepCmxMonitoringCfg')
22 inputContainsRun3FormatConfigMetadata = (
"metadata_items" in md
and any((
'TriggerMenuJson' in key)
for key
in md[
"metadata_items"].
keys()))
23 if inputFlags.Input.Format
is Format.POOL
and not inputContainsRun3FormatConfigMetadata:
25 return helper.result()
28 JepCmxMonAlg = helper.addAlgorithm(CompFactory.JepCmxMonitorAlgorithm,
'JepCmxMonAlg')
31 groupName =
'JepCmxMonitor'
32 JepCmxMonAlg.PackageName = groupName
34 JepCmxMonAlg.s_crates = crates
36 JepCmxMonAlg.s_modules = modules
38 JepCmxMonAlg.s_tobsPerJem = tobsPerJem
40 JepCmxMonAlg.s_maxTobsPerCmx = maxTobsPerCmx
44 inputPath = trigPath +
'/Input/'
45 outputPath = trigPath +
'/Output/'
46 errorPath = trigPath +
'/Errors/'
47 jetInPath = inputPath +
'Jet/'
48 jetOutPath = outputPath +
'Jet/'
49 energyInPath = inputPath +
'Energy/'
50 energyOutPath = outputPath +
'Energy/'
51 roiPath = outputPath +
'/RoI/'
52 errHardPath = errorPath +
'/Hardware/'
60 NumberOfSummaryBins = 4
69 subStatus_labels = [
'GLinkParity',
'GLinkProtocol',
'BCNMismatch',
'FIFOOverflow',
'ModuleError',
'',
'GLinkDown',
'GLinkTimeout']
70 errSummary_labels = [
'Jet status',
'Energy status',
'Jet parity',
'Energy parity']
73 moduleVsCrate_bins = {
74 'xbins': modules,
'xmin': 0.,
'xmax': modules,
'xlabels':
numberLabels(modules),
75 'ybins': crates,
'ymin': 0.,
'ymax': crates,
'ylabels':
numberLabels(crates)
77 xySums_bins = {
'xbins': nbins,
'xmin': -maxSum,
'xmax': maxSum}
78 etSums_bins = {
'xbins': nbins,
'xmin': 0.,
'xmax': 2*maxSum}
79 energyOverflow_bins = {
80 'xbins': 3,
'xmin': 0.,
'xmax': 3.,
'xlabels': [
'Ex',
'Ey',
'Et'],
81 'ybins': 3,
'ymin': 0.,
'ymax': 3.,
'ylabels': [
'Remote',
'Local',
'Total'],
83 subStatusVsCrate_bins = {
84 'xbins': crates,
'xmin': 0.,
'xmax': crates,
'xlabels':
numberLabels(crates),
85 'ybins': len(subStatus_labels),
'ymin': 0.,
'ymax': len(subStatus_labels),
'ylabels': subStatus_labels
89 myGroup = helper.addGroup(JepCmxMonAlg, groupName, mainDir)
94 myGroup.defineHistogram(
'jetTobEnergyLg;cmx_1d_tob_EnergyLg',
95 title=
'CMX-Jet TOB Energy Large Window Size', type=
'TH1F',
96 path=jetInPath, cutmask=
'',
97 xbins=nbins, xmin=0., xmax=maxLarge)
98 myGroup.defineHistogram(
'jetTobEnergySm;cmx_1d_tob_EnergySm',
99 title=
'CMX-Jet TOB Energy Small Window Size', type=
'TH1F',
100 path=jetInPath, cutmask=
'',
101 xbins=nbins, xmin=0., xmax=maxSmall)
102 myGroup.defineHistogram(
'tobsPerJem;cmx_1d_tob_TOBsPerJEM',
103 title=
'CMX-Jet TOBs per JEM;Number of TOBs', type=
'TH1F',
104 path=jetInPath, cutmask=
'',
105 xbins=tobsPerJem + 1, xmin=1., xmax=tobsPerJem + 2,
107 myGroup.defineHistogram(
'tobsPerCmx;cmx_1d_tob_TOBsPerCMX',
108 title=
'CMX-Jet TOBs per CMX;Number of TOBs', type=
'TH1F',
109 path=jetInPath, cutmask=
'',
110 xbins=maxTobsPerCmx, xmin=0., xmax=maxTobsPerCmx)
111 myGroup.defineHistogram(
'jetTobHitmap_x,jetTobHitmap_y;cmx_2d_tob_Hitmap',
112 title=
'CMX-Jet TOBs Hit Map;Crate/Module;Frame/Local Coord', type=
'TH2F',
113 path=jetInPath, cutmask=
'',
114 xbins=32, xmin=0., xmax=32., ybins=32, ymin=0., ymax=32.,
118 e_subsum_bins = {
'xbins': nbins,
'xmin': 0.,
'xmax': maxSum}
119 myGroup.defineHistogram(
'eSubSumsEx;cmx_1d_energy_SubSumsEx',
120 title=
'CMX E_{x}^{JEM};Ex [GeV]', type=
'TH1F',
121 path=energyInPath, cutmask=
'', **e_subsum_bins)
122 myGroup.defineHistogram(
'eSubSumsEy;cmx_1d_energy_SubSumsEy',
123 title=
'CMX E_{y}^{JEM};Ey [GeV]', type=
'TH1F',
124 path=energyInPath, cutmask=
'', **e_subsum_bins)
125 myGroup.defineHistogram(
'eSubSumsEt;cmx_1d_energy_SubSumsEt',
126 title=
'CMX E_{t}^{JEM};Et [GeV]', type=
'TH1F',
127 path=energyInPath, cutmask=
'', **e_subsum_bins)
132 myGroup.defineHistogram(
'threshTotalMainVals;cmx_1d_thresh_TotalMainHits',
133 title=
'Main Jet Multiplicity per Threshold', type=
'TH1F',
134 path=jetOutPath, cutmask=
'', weight=
'threshTotalMainHits',
135 xbins=len(jetThresholdNames), xmin=0., xmax=len(jetThresholdNames), xlabels=jetThresholdNames)
136 myGroup.defineHistogram(
'threshRoiOverflow;cmx_1d_thresh_RoIOverflow',
137 title=
'CMX-Jet Hits RoI Overflow', type=
'TH1F',
138 path=jetOutPath, cutmask=
'',
139 xbins=3, xmin=0., xmax=3., xlabels=[
'Remote',
'Local',
'Total'])
140 myGroup.defineHistogram(
'topoDataChecksum;cmx_1d_topo_DataChecksum',
141 title=
'CMX-Jet Topo Output Data Checksum Non-zero;Crate', type=
'TH1F',
142 path=jetOutPath, cutmask=
'',
143 xbins=crates, xmin=0., xmax=crates, xlabels=
numberLabels(crates))
144 myGroup.defineHistogram(
'topoJemOccMap_mod,topoJemOccMap_cra;cmx_2d_topo_JEMOccupancyMap',
145 title=
'CMX-Jet Topo JEM Occupancy Maps;Module;Crate', type=
'TH2F',
146 weight=
'topoJemOccMap_hit',
147 path=jetOutPath, cutmask=
'', **moduleVsCrate_bins)
148 myGroup.defineHistogram(
'topoJemOccCount_mod,topoJemOccCount_cra;cmx_2d_topo_JEMOccupancyCounts',
149 title=
'CMX-Jet Topo JEM Occupancy Counts Weighted;Module;Crate', type=
'TH2F',
150 weight=
'topoJemOccCount_hit',
151 path=jetOutPath, cutmask=
'', **moduleVsCrate_bins)
152 myGroup.defineHistogram(
'topoTobsPerJem;cmx_1d_topo_TOBsPerJEM',
153 title=
'CMX-Jet Topo TOBs per JEM;Number of TOBs', type=
'TH1F',
154 path=jetOutPath, cutmask=
'',
156 myGroup.defineHistogram(
'topoTobsPerCmx;cmx_1d_topo_TOBsPerCMX',
157 title=
'CMX-Jet Topo TOBs per CMX;Number of TOBs', type=
'TH1F',
158 path=jetOutPath, cutmask=
'',
159 xbins=maxTobsPerCmx, xmin=0., xmax=maxTobsPerCmx)
161 myGroup.defineHistogram(
'cmxMissingEt_vals;cmx_1d_energy_MissingEtHits',
162 title=
'MissingEt Multiplicity per Threshold Standard', type=
'TH1F',
163 path=energyOutPath, cutmask=
'', weight=
'cmxMissingEt_hits',
164 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
165 myGroup.defineHistogram(
'cmxSumEt_vals;cmx_1d_energy_SumEtHits',
166 title=
'SumEt Multiplicity per Threshold Standard', type=
'TH1F',
167 path=energyOutPath, cutmask=
'', weight=
'cmxSumEt_hits',
168 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
169 myGroup.defineHistogram(
'cmxMissingEtSig_vals;cmx_1d_energy_MissingEtSigHits',
170 title=
'MissingEtSig Multiplicity per Threshold', type=
'TH1F',
171 path=energyOutPath, cutmask=
'', weight=
'cmxMissingEtSig_hits',
172 xbins=len(xsThresholdNames), xmin=0., xmax=len(xsThresholdNames), xlabels=xsThresholdNames)
173 myGroup.defineHistogram(
'cmxMissingEtHitsRes_vals;cmx_1d_energy_MissingEtHitsRes',
174 title=
'MissingEt Multiplicity per Threshold Restricted', type=
'TH1F',
175 path=energyOutPath, cutmask=
'', weight=
'cmxMissingEtHitsRes_hits',
176 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
177 myGroup.defineHistogram(
'cmxSumEtHitsWt_vals;cmx_1d_energy_SumEtHitsWt',
178 title=
'SumEt Multiplicity per Threshold Weighted', type=
'TH1F',
179 path=energyOutPath, cutmask=
'', weight=
'cmxSumEtHitsWt_hits',
180 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
182 myGroup.defineHistogram(
'cmxTotalEx;cmx_1d_energy_TotalEx',
183 title=
'E_{x}^{CMX} Standard;Ex [GeV]', type=
'TH1F',
184 path=energyOutPath, cutmask=
'', **xySums_bins)
185 myGroup.defineHistogram(
'cmxTotalEy;cmx_1d_energy_TotalEy',
186 title=
'E_{y}^{CMX} Standard;Ey [GeV]', type=
'TH1F',
187 path=energyOutPath, cutmask=
'', **xySums_bins)
188 myGroup.defineHistogram(
'cmxTotalEt;cmx_1d_energy_TotalEt',
189 title=
'SumE_{t}^{CMX} Standard;Et [GeV]', type=
'TH1F',
190 path=energyOutPath, cutmask=
'', **etSums_bins)
191 myGroup.defineHistogram(
'cmxTotalExRes;cmx_1d_energy_TotalExRes',
192 title=
'E_{x}^{CMX} Restricted Eta Range;Ex [GeV]', type=
'TH1F',
193 path=energyOutPath, cutmask=
'', **xySums_bins)
194 myGroup.defineHistogram(
'cmxTotalEyRes;cmx_1d_energy_TotalEyRes',
195 title=
'E_{y}^{CMX} Restricted Eta Range;Ey [GeV]', type=
'TH1F',
196 path=energyOutPath, cutmask=
'', **xySums_bins)
197 myGroup.defineHistogram(
'cmxTotalEtRes;cmx_1d_energy_TotalEtRes',
198 title=
'SumE_{t}^{CMX} Restricted Eta Range;Et [GeV]', type=
'TH1F',
199 path=energyOutPath, cutmask=
'', **etSums_bins)
200 myGroup.defineHistogram(
'cmxEnergyOverflowx,cmxEnergyOverflowy,cmxEnergyOverflowz;cmx_2d_energy_Overflow',
201 title=
'CMX Energy Overflow Rates Standard', type=
'TProfile2D',
202 path=energyOutPath, cutmask=
'', **energyOverflow_bins)
203 myGroup.defineHistogram(
'cmxEnergyOverflowResx,cmxEnergyOverflowResy,cmxEnergyOverflowResz;cmx_2d_energy_OverflowRes',
204 title=
'CMX Energy Overflow Rates Restricted Eta Range', type=
'TProfile2D',
205 path=energyOutPath, cutmask=
'', **energyOverflow_bins)
210 myGroup.defineHistogram(
'roiMissingEtHits_var;cmx_1d_roi_MissingEtHits',
211 title=
'MissingEt Multiplicity per Threshold Normal', type=
'TH1F',
212 path=roiPath, cutmask=
'', weight=
'roiMissingEtHits_hit',
213 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
214 myGroup.defineHistogram(
'roiSumEtHits_var;cmx_1d_roi_SumEtHits',
215 title=
'SumEt Multiplicity per Threshold Normal', type=
'TH1F',
216 path=roiPath, cutmask=
'', weight=
'roiSumEtHits_hit',
217 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
218 myGroup.defineHistogram(
'roiMissingEtSigHits_var;cmx_1d_roi_MissingEtSigHits',
219 title=
'MissingEtSig Multiplicity per Threshold', type=
'TH1F',
220 path=roiPath, cutmask=
'', weight=
'roiMissingEtSigHits_hit',
221 xbins=len(xsThresholdNames), xmin=0., xmax=len(xsThresholdNames), xlabels=xsThresholdNames)
222 myGroup.defineHistogram(
'roiMissingEtHitsMask_var;cmx_1d_roi_MissingEtHitsMask',
223 title=
'MissingEt Multiplicity per Threshold Masked', type=
'TH1F',
224 path=roiPath, cutmask=
'', weight=
'roiMissingEtHitsMask_hit',
225 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
226 myGroup.defineHistogram(
'roiSumEtHitsMask_var;cmx_1d_roi_SumEtHitsMask',
227 title=
'SumEt Multiplicity per Threshold Masked', type=
'TH1F',
228 path=roiPath, cutmask=
'', weight=
'roiSumEtHitsMask_hit',
229 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
231 myGroup.defineHistogram(
'cmxRoiEx;cmx_1d_roi_Ex',
232 title=
'E_{x}^{CMX} Normal;Ex [GeV]', type=
'TH1F',
233 path=roiPath, cutmask=
'', **xySums_bins)
234 myGroup.defineHistogram(
'cmxRoiEy;cmx_1d_roi_Ey',
235 title=
'E_{y}^{CMX} Normal;Ey [GeV]', type=
'TH1F',
236 path=roiPath, cutmask=
'', **xySums_bins)
237 myGroup.defineHistogram(
'cmxRoiEt;cmx_1d_roi_Et',
238 title=
'SumE_{t}^{CMX} Normal;Et [GeV]', type=
'TH1F',
239 path=roiPath, cutmask=
'', **etSums_bins)
240 myGroup.defineHistogram(
'cmxRoiExMask;cmx_1d_roi_ExMask',
241 title=
'E_{x}^{CMX} Masked;Ex [GeV]', type=
'TH1F',
242 path=roiPath, cutmask=
'', **xySums_bins)
243 myGroup.defineHistogram(
'cmxRoiEyMask;cmx_1d_roi_EyMask',
244 title=
'E_{y}^{CMX} Masked;Ey [GeV]', type=
'TH1F',
245 path=roiPath, cutmask=
'', **xySums_bins)
246 myGroup.defineHistogram(
'cmxRoiEtMask;cmx_1d_roi_EtMask',
247 title=
'SumE_{t}^{CMX} Masked;Et [GeV]', type=
'TH1F',
248 path=roiPath, cutmask=
'', **etSums_bins)
252 myGroup.defineHistogram(
'cmxThreshStatusErr_bit,cmxThreshStatusErr_crate;cmx_2d_thresh_Status',
253 title=
'Errors from CMX Jet SubStatus Word', type=
'TH2F',
254 path=errHardPath, cutmask=
'', **subStatusVsCrate_bins)
255 myGroup.defineHistogram(
'cmxEnergyStatus_bit,cmxEnergyStatus_cra;cmx_2d_energy_Status',
256 title=
'Errors from CMX Energy SubStatus Word', type=
'TH2F',
257 path=errHardPath, cutmask=
'', **subStatusVsCrate_bins)
258 myGroup.defineHistogram(
'threshParityTobJem,threshParityTobCrate;cmx_2d_thresh_ParityTob',
259 title=
'CMX Jet TOB Parity Errors;Module;Crate', type=
'TH2F',
260 path=errHardPath, cutmask=
'', **moduleVsCrate_bins)
261 myGroup.defineHistogram(
'cmxThreshParityErr;cmx_1d_thresh_ParityRem',
262 title=
'CMX Jet Remote Hit Sums Parity Errors;Cable/Phase', type=
'TH1F',
263 path=errHardPath, cutmask=
'',
264 xbins=4, xmin=0., xmax=4., xlabels=
numberPairs(1,1))
265 myGroup.defineHistogram(
'cmxEnergyParityModx,cmxEnergyParityMody;cmx_2d_energy_ParityMod',
266 title=
'CMX Energy Module Sums Parity Errors;Crate/Module;Type/Phase', type=
'TH2F',
267 path=errHardPath, cutmask=
'',
268 xbins=19, xmin=0., xmax=19., xlabels=
numberPairs(1, 19, step=2),
269 ybins=3, ymin=0., ymax=3., ylabels=[
'Ex/0',
'Ey/1',
'Et/2'])
270 myGroup.defineHistogram(
'cmxParityRem;cmx_1d_energy_ParityRem',
271 title=
'CMX Energy Remote Crate Sums Parity Errors;Cable/Phase', type=
'TH1F',
272 path=errHardPath, cutmask=
'',
273 xbins=4, xmin=0., xmax=4., xlabels=
numberPairs(1, 1))
274 myGroup.defineHistogram(
'cmxTriggeredSlice;cmx_1d_TriggeredSlices',
275 title=
'Comparison of CMX Jet and Energy triggered slice numbers;Difference', type=
'TH1F',
276 path=errHardPath, cutmask=
'',
279 myGroup.defineHistogram(
'cmxErrorSummary;cmx_1d_ErrorSummary',
280 title=
'Error Summary of CMX Jet and Energy', type=
'TH1F',
281 path=errHardPath, cutmask=
'',
282 xbins=NumberOfSummaryBins, xmin=0., xmax=NumberOfSummaryBins, xlabels=errSummary_labels)
284 acc = helper.result()
290 """Generate numeric labels"""
291 return [
str(i + start)
for i
in range(0, num, step)]
294 def numberPairs(firstMax, secondMax, firstMin=0, secondMin=0, step=1, offset=0):
295 """Generate number pair axis labels"""
296 labels = [
''] * firstMax * secondMax
297 numSecond = secondMax - secondMin
298 for first
in range(firstMin, firstMax):
299 bin = offset + first * numSecond
300 for second
in range(secondMin, secondMax, step):
301 labels[bin] =
'{}/{}'.
format(first, second)
307 """Get ordered threshold names from L1 menu for threshold type"""
308 return [name
for name, _
in sorted(menu.thresholds(thresholdType).
items(), key=
lambda x: x[1][
'mapping'])]
311 if __name__==
'__main__':
313 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
316 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')
319 flags.Input.Files = inputs
320 flags.Output.HISTFileName =
'JepCmxMonitorOutput_LVL1.root'
325 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
326 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
331 cfg.merge(JepCmxMonitorCfg)
334 JepCmxMonitorCfg.getEventAlgo(
'JepCmxMonAlg').OutputLevel = 2
336 cfg.printConfig(withDetails=
False, summariseProps =
True)