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
70 subStatus_labels = [
'GLinkParity',
'GLinkProtocol',
'BCNMismatch',
'FIFOOverflow',
'ModuleError',
'',
'GLinkDown',
'GLinkTimeout']
71 errSummary_labels = [
'Jet status',
'Energy status',
'Jet parity',
'Energy parity']
74 moduleVsCrate_bins = {
75 'xbins': modules,
'xmin': 0.,
'xmax': modules,
'xlabels':
numberLabels(modules),
76 'ybins': crates,
'ymin': 0.,
'ymax': crates,
'ylabels':
numberLabels(crates)
78 xySums_bins = {
'xbins': nbins,
'xmin': -maxSum,
'xmax': maxSum}
79 etSums_bins = {
'xbins': nbins,
'xmin': 0.,
'xmax': 2*maxSum}
80 energyOverflow_bins = {
81 'xbins': 3,
'xmin': 0.,
'xmax': 3.,
'xlabels': [
'Ex',
'Ey',
'Et'],
82 'ybins': 3,
'ymin': 0.,
'ymax': 3.,
'ylabels': [
'Remote',
'Local',
'Total'],
84 subStatusVsCrate_bins = {
85 'xbins': crates,
'xmin': 0.,
'xmax': crates,
'xlabels':
numberLabels(crates),
86 'ybins': len(subStatus_labels),
'ymin': 0.,
'ymax': len(subStatus_labels),
'ylabels': subStatus_labels
90 myGroup = helper.addGroup(JepCmxMonAlg, groupName, mainDir)
95 myGroup.defineHistogram(
'jetTobEnergyLg;cmx_1d_tob_EnergyLg',
96 title=
'CMX-Jet TOB Energy Large Window Size', type=
'TH1F',
97 path=jetInPath, cutmask=
'',
98 xbins=nbins, xmin=0., xmax=maxLarge)
99 myGroup.defineHistogram(
'jetTobEnergySm;cmx_1d_tob_EnergySm',
100 title=
'CMX-Jet TOB Energy Small Window Size', type=
'TH1F',
101 path=jetInPath, cutmask=
'',
102 xbins=nbins, xmin=0., xmax=maxSmall)
103 myGroup.defineHistogram(
'tobsPerJem;cmx_1d_tob_TOBsPerJEM',
104 title=
'CMX-Jet TOBs per JEM;Number of TOBs', type=
'TH1F',
105 path=jetInPath, cutmask=
'',
106 xbins=tobsPerJem + 1, xmin=1., xmax=tobsPerJem + 2,
108 myGroup.defineHistogram(
'tobsPerCmx;cmx_1d_tob_TOBsPerCMX',
109 title=
'CMX-Jet TOBs per CMX;Number of TOBs', type=
'TH1F',
110 path=jetInPath, cutmask=
'',
111 xbins=maxTobsPerCmx, xmin=0., xmax=maxTobsPerCmx)
112 myGroup.defineHistogram(
'jetTobHitmap_x,jetTobHitmap_y;cmx_2d_tob_Hitmap',
113 title=
'CMX-Jet TOBs Hit Map;Crate/Module;Frame/Local Coord', type=
'TH2F',
114 path=jetInPath, cutmask=
'',
115 xbins=32, xmin=0., xmax=32., ybins=32, ymin=0., ymax=32.,
119 e_subsum_bins = {
'xbins': nbins,
'xmin': 0.,
'xmax': maxSum}
120 myGroup.defineHistogram(
'eSubSumsEx;cmx_1d_energy_SubSumsEx',
121 title=
'CMX E_{x}^{JEM};Ex [GeV]', type=
'TH1F',
122 path=energyInPath, cutmask=
'', **e_subsum_bins)
123 myGroup.defineHistogram(
'eSubSumsEy;cmx_1d_energy_SubSumsEy',
124 title=
'CMX E_{y}^{JEM};Ey [GeV]', type=
'TH1F',
125 path=energyInPath, cutmask=
'', **e_subsum_bins)
126 myGroup.defineHistogram(
'eSubSumsEt;cmx_1d_energy_SubSumsEt',
127 title=
'CMX E_{t}^{JEM};Et [GeV]', type=
'TH1F',
128 path=energyInPath, cutmask=
'', **e_subsum_bins)
133 myGroup.defineHistogram(
'threshTotalMainVals;cmx_1d_thresh_TotalMainHits',
134 title=
'Main Jet Multiplicity per Threshold', type=
'TH1F',
135 path=jetOutPath, cutmask=
'', weight=
'threshTotalMainHits',
136 xbins=len(jetThresholdNames), xmin=0., xmax=len(jetThresholdNames), xlabels=jetThresholdNames)
137 myGroup.defineHistogram(
'threshRoiOverflow;cmx_1d_thresh_RoIOverflow',
138 title=
'CMX-Jet Hits RoI Overflow', type=
'TH1F',
139 path=jetOutPath, cutmask=
'',
140 xbins=3, xmin=0., xmax=3., xlabels=[
'Remote',
'Local',
'Total'])
141 myGroup.defineHistogram(
'topoDataChecksum;cmx_1d_topo_DataChecksum',
142 title=
'CMX-Jet Topo Output Data Checksum Non-zero;Crate', type=
'TH1F',
143 path=jetOutPath, cutmask=
'',
144 xbins=crates, xmin=0., xmax=crates, xlabels=
numberLabels(crates))
145 myGroup.defineHistogram(
'topoJemOccMap_mod,topoJemOccMap_cra;cmx_2d_topo_JEMOccupancyMap',
146 title=
'CMX-Jet Topo JEM Occupancy Maps;Module;Crate', type=
'TH2F',
147 weight=
'topoJemOccMap_hit',
148 path=jetOutPath, cutmask=
'', **moduleVsCrate_bins)
149 myGroup.defineHistogram(
'topoJemOccCount_mod,topoJemOccCount_cra;cmx_2d_topo_JEMOccupancyCounts',
150 title=
'CMX-Jet Topo JEM Occupancy Counts Weighted;Module;Crate', type=
'TH2F',
151 weight=
'topoJemOccCount_hit',
152 path=jetOutPath, cutmask=
'', **moduleVsCrate_bins)
153 myGroup.defineHistogram(
'topoTobsPerJem;cmx_1d_topo_TOBsPerJEM',
154 title=
'CMX-Jet Topo TOBs per JEM;Number of TOBs', type=
'TH1F',
155 path=jetOutPath, cutmask=
'',
157 myGroup.defineHistogram(
'topoTobsPerCmx;cmx_1d_topo_TOBsPerCMX',
158 title=
'CMX-Jet Topo TOBs per CMX;Number of TOBs', type=
'TH1F',
159 path=jetOutPath, cutmask=
'',
160 xbins=maxTobsPerCmx, xmin=0., xmax=maxTobsPerCmx)
162 myGroup.defineHistogram(
'cmxMissingEt_vals;cmx_1d_energy_MissingEtHits',
163 title=
'MissingEt Multiplicity per Threshold Standard', type=
'TH1F',
164 path=energyOutPath, cutmask=
'', weight=
'cmxMissingEt_hits',
165 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
166 myGroup.defineHistogram(
'cmxSumEt_vals;cmx_1d_energy_SumEtHits',
167 title=
'SumEt Multiplicity per Threshold Standard', type=
'TH1F',
168 path=energyOutPath, cutmask=
'', weight=
'cmxSumEt_hits',
169 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
170 myGroup.defineHistogram(
'cmxMissingEtSig_vals;cmx_1d_energy_MissingEtSigHits',
171 title=
'MissingEtSig Multiplicity per Threshold', type=
'TH1F',
172 path=energyOutPath, cutmask=
'', weight=
'cmxMissingEtSig_hits',
173 xbins=len(xsThresholdNames), xmin=0., xmax=len(xsThresholdNames), xlabels=xsThresholdNames)
174 myGroup.defineHistogram(
'cmxMissingEtHitsRes_vals;cmx_1d_energy_MissingEtHitsRes',
175 title=
'MissingEt Multiplicity per Threshold Restricted', type=
'TH1F',
176 path=energyOutPath, cutmask=
'', weight=
'cmxMissingEtHitsRes_hits',
177 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
178 myGroup.defineHistogram(
'cmxSumEtHitsWt_vals;cmx_1d_energy_SumEtHitsWt',
179 title=
'SumEt Multiplicity per Threshold Weighted', type=
'TH1F',
180 path=energyOutPath, cutmask=
'', weight=
'cmxSumEtHitsWt_hits',
181 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
183 myGroup.defineHistogram(
'cmxTotalEx;cmx_1d_energy_TotalEx',
184 title=
'E_{x}^{CMX} Standard;Ex [GeV]', type=
'TH1F',
185 path=energyOutPath, cutmask=
'', **xySums_bins)
186 myGroup.defineHistogram(
'cmxTotalEy;cmx_1d_energy_TotalEy',
187 title=
'E_{y}^{CMX} Standard;Ey [GeV]', type=
'TH1F',
188 path=energyOutPath, cutmask=
'', **xySums_bins)
189 myGroup.defineHistogram(
'cmxTotalEt;cmx_1d_energy_TotalEt',
190 title=
'SumE_{t}^{CMX} Standard;Et [GeV]', type=
'TH1F',
191 path=energyOutPath, cutmask=
'', **etSums_bins)
192 myGroup.defineHistogram(
'cmxTotalExRes;cmx_1d_energy_TotalExRes',
193 title=
'E_{x}^{CMX} Restricted Eta Range;Ex [GeV]', type=
'TH1F',
194 path=energyOutPath, cutmask=
'', **xySums_bins)
195 myGroup.defineHistogram(
'cmxTotalEyRes;cmx_1d_energy_TotalEyRes',
196 title=
'E_{y}^{CMX} Restricted Eta Range;Ey [GeV]', type=
'TH1F',
197 path=energyOutPath, cutmask=
'', **xySums_bins)
198 myGroup.defineHistogram(
'cmxTotalEtRes;cmx_1d_energy_TotalEtRes',
199 title=
'SumE_{t}^{CMX} Restricted Eta Range;Et [GeV]', type=
'TH1F',
200 path=energyOutPath, cutmask=
'', **etSums_bins)
201 myGroup.defineHistogram(
'cmxEnergyOverflowx,cmxEnergyOverflowy,cmxEnergyOverflowz;cmx_2d_energy_Overflow',
202 title=
'CMX Energy Overflow Rates Standard', type=
'TProfile2D',
203 path=energyOutPath, cutmask=
'', **energyOverflow_bins)
204 myGroup.defineHistogram(
'cmxEnergyOverflowResx,cmxEnergyOverflowResy,cmxEnergyOverflowResz;cmx_2d_energy_OverflowRes',
205 title=
'CMX Energy Overflow Rates Restricted Eta Range', type=
'TProfile2D',
206 path=energyOutPath, cutmask=
'', **energyOverflow_bins)
211 myGroup.defineHistogram(
'roiMissingEtHits_var;cmx_1d_roi_MissingEtHits',
212 title=
'MissingEt Multiplicity per Threshold Normal', type=
'TH1F',
213 path=roiPath, cutmask=
'', weight=
'roiMissingEtHits_hit',
214 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
215 myGroup.defineHistogram(
'roiSumEtHits_var;cmx_1d_roi_SumEtHits',
216 title=
'SumEt Multiplicity per Threshold Normal', type=
'TH1F',
217 path=roiPath, cutmask=
'', weight=
'roiSumEtHits_hit',
218 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
219 myGroup.defineHistogram(
'roiMissingEtSigHits_var;cmx_1d_roi_MissingEtSigHits',
220 title=
'MissingEtSig Multiplicity per Threshold', type=
'TH1F',
221 path=roiPath, cutmask=
'', weight=
'roiMissingEtSigHits_hit',
222 xbins=len(xsThresholdNames), xmin=0., xmax=len(xsThresholdNames), xlabels=xsThresholdNames)
223 myGroup.defineHistogram(
'roiMissingEtHitsMask_var;cmx_1d_roi_MissingEtHitsMask',
224 title=
'MissingEt Multiplicity per Threshold Masked', type=
'TH1F',
225 path=roiPath, cutmask=
'', weight=
'roiMissingEtHitsMask_hit',
226 xbins=len(xeThresholdNames), xmin=0., xmax=len(xeThresholdNames), xlabels=xeThresholdNames)
227 myGroup.defineHistogram(
'roiSumEtHitsMask_var;cmx_1d_roi_SumEtHitsMask',
228 title=
'SumEt Multiplicity per Threshold Masked', type=
'TH1F',
229 path=roiPath, cutmask=
'', weight=
'roiSumEtHitsMask_hit',
230 xbins=len(teThresholdNames), xmin=0., xmax=len(teThresholdNames), xlabels=teThresholdNames)
232 myGroup.defineHistogram(
'cmxRoiEx;cmx_1d_roi_Ex',
233 title=
'E_{x}^{CMX} Normal;Ex [GeV]', type=
'TH1F',
234 path=roiPath, cutmask=
'', **xySums_bins)
235 myGroup.defineHistogram(
'cmxRoiEy;cmx_1d_roi_Ey',
236 title=
'E_{y}^{CMX} Normal;Ey [GeV]', type=
'TH1F',
237 path=roiPath, cutmask=
'', **xySums_bins)
238 myGroup.defineHistogram(
'cmxRoiEt;cmx_1d_roi_Et',
239 title=
'SumE_{t}^{CMX} Normal;Et [GeV]', type=
'TH1F',
240 path=roiPath, cutmask=
'', **etSums_bins)
241 myGroup.defineHistogram(
'cmxRoiExMask;cmx_1d_roi_ExMask',
242 title=
'E_{x}^{CMX} Masked;Ex [GeV]', type=
'TH1F',
243 path=roiPath, cutmask=
'', **xySums_bins)
244 myGroup.defineHistogram(
'cmxRoiEyMask;cmx_1d_roi_EyMask',
245 title=
'E_{y}^{CMX} Masked;Ey [GeV]', type=
'TH1F',
246 path=roiPath, cutmask=
'', **xySums_bins)
247 myGroup.defineHistogram(
'cmxRoiEtMask;cmx_1d_roi_EtMask',
248 title=
'SumE_{t}^{CMX} Masked;Et [GeV]', type=
'TH1F',
249 path=roiPath, cutmask=
'', **etSums_bins)
253 myGroup.defineHistogram(
'cmxThreshStatusErr_bit,cmxThreshStatusErr_crate;cmx_2d_thresh_Status',
254 title=
'Errors from CMX Jet SubStatus Word', type=
'TH2F',
255 path=errHardPath, cutmask=
'', **subStatusVsCrate_bins)
256 myGroup.defineHistogram(
'cmxEnergyStatus_bit,cmxEnergyStatus_cra;cmx_2d_energy_Status',
257 title=
'Errors from CMX Energy SubStatus Word', type=
'TH2F',
258 path=errHardPath, cutmask=
'', **subStatusVsCrate_bins)
259 myGroup.defineHistogram(
'threshParityTobJem,threshParityTobCrate;cmx_2d_thresh_ParityTob',
260 title=
'CMX Jet TOB Parity Errors;Module;Crate', type=
'TH2F',
261 path=errHardPath, cutmask=
'', **moduleVsCrate_bins)
262 myGroup.defineHistogram(
'cmxThreshParityErr;cmx_1d_thresh_ParityRem',
263 title=
'CMX Jet Remote Hit Sums Parity Errors;Cable/Phase', type=
'TH1F',
264 path=errHardPath, cutmask=
'',
265 xbins=4, xmin=0., xmax=4., xlabels=
numberPairs(1,1))
266 myGroup.defineHistogram(
'cmxEnergyParityModx,cmxEnergyParityMody;cmx_2d_energy_ParityMod',
267 title=
'CMX Energy Module Sums Parity Errors;Crate/Module;Type/Phase', type=
'TH2F',
268 path=errHardPath, cutmask=
'',
269 xbins=19, xmin=0., xmax=19., xlabels=
numberPairs(1, 19, step=2),
270 ybins=3, ymin=0., ymax=3., ylabels=[
'Ex/0',
'Ey/1',
'Et/2'])
271 myGroup.defineHistogram(
'cmxParityRem;cmx_1d_energy_ParityRem',
272 title=
'CMX Energy Remote Crate Sums Parity Errors;Cable/Phase', type=
'TH1F',
273 path=errHardPath, cutmask=
'',
274 xbins=4, xmin=0., xmax=4., xlabels=
numberPairs(1, 1))
275 myGroup.defineHistogram(
'cmxTriggeredSlice;cmx_1d_TriggeredSlices',
276 title=
'Comparison of CMX Jet and Energy triggered slice numbers;Difference', type=
'TH1F',
277 path=errHardPath, cutmask=
'',
280 myGroup.defineHistogram(
'cmxErrorSummary;cmx_1d_ErrorSummary',
281 title=
'Error Summary of CMX Jet and Energy', type=
'TH1F',
282 path=errHardPath, cutmask=
'',
284 NumberOfSummaryBins, xmin=0., xmax=NumberOfSummaryBins, xlabels=errSummary_labels)
286 myGroup.defineHistogram(
';cmx_2d_ErrorEventNumbers',
287 title=
'JEM-CMX Error Event Numbers;Events with Error/Mismatch;',type=
'TH2I',
288 cutmask=
'', path=errHardPath,
289 xbins=EventSamples, xmin=0, xmax=EventSamples, xlabels=
numberLabels(EventSamples, 1),
290 ybins=NumberOfSummaryBins, ymin=0, ymax=NumberOfSummaryBins, ylabels=errSummary_labels)
292 acc = helper.result()
298 """Generate numeric labels"""
299 return [
str(i + start)
for i
in range(0, num, step)]
302 def numberPairs(firstMax, secondMax, firstMin=0, secondMin=0, step=1, offset=0):
303 """Generate number pair axis labels"""
304 labels = [
''] * firstMax * secondMax
305 numSecond = secondMax - secondMin
306 for first
in range(firstMin, firstMax):
307 bin = offset + first * numSecond
308 for second
in range(secondMin, secondMax, step):
309 labels[bin] =
'{}/{}'.
format(first, second)
315 """Get ordered threshold names from L1 menu for threshold type"""
316 return [name
for name, _
in sorted(menu.thresholds(thresholdType).
items(), key=
lambda x: x[1][
'mapping'])]
319 if __name__==
'__main__':
321 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
324 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')
327 flags.Input.Files = inputs
328 flags.Output.HISTFileName =
'JepCmxMonitorOutput_LVL1.root'
333 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
334 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
339 cfg.merge(JepCmxMonitorCfg)
342 JepCmxMonitorCfg.getEventAlgo(
'JepCmxMonAlg').OutputLevel = 2
344 cfg.printConfig(withDetails=
False, summariseProps =
True)