24def EfexMonitoringHistConfig(flags, eFexAlg):
25 """
26 Book the histograms for the efex monitoring. This is done in a separate method
27 to the algorithm creation (above) because the histograms are based on the list of container keys
28 given to the algorithm, which can be customized by the user before calling this method.
29 """
30 import math
31 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
32 result = ComponentAccumulator()
33
34
35
36 from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
37 helper = L1CaloMonitorCfgHelper(flags,None,'EfexMonitoringCfg')
38 helper.alg = eFexAlg
39
40
41 EfexMonAlg = eFexAlg
42 baseGroupName = EfexMonAlg.PackageName
43
44
45
46 trigPath = f'Developer/{eFexAlg.name}/'
47
48
49 def pathFromKey(key,prefix="Nominal/"):
50 path=prefix
51 if "DAODSim" in key: path = "DAODSim/"
52 elif "ReSim" in key: path = "ReSim/"
53 elif "Sim" in key: path = "Sim/"
54 if "_eEMx" in key: path += "eEMx"
55 elif "_eEM" in key: path += "eEM"
56 elif "_eTaux" in key: path += "eTAUx"
57 elif "_eTau" in key: path += "eTAU"
58 return path
59
60 cut_names = ["LowPtCut", "HiPtCut"]
61 cut_vals = [EfexMonAlg.LowPtCut, EfexMonAlg.HiPtCut]
62
63
64
65
66 locIdxs = []
67 for phiOct in range(0,8):
68 for etaIdx in range(-25,25):
69 locIdxs += [str(phiOct) + ":" + str(etaIdx)]
70
71 for containerKey in (list(EfexMonAlg.eFexEMTobKeyList) + list(EfexMonAlg.eFexTauTobKeyList)):
72 helper.defineHistogram(containerKey + '_nTOBs_nocut;h_n'+containerKey+'_nocut', title='Number of '+containerKey+';Number of '+containerKey+';Events',
73 fillGroup = baseGroupName,
74 path=trigPath+pathFromKey(containerKey)+"NoCut",
75 type='TH1I', xbins=100,xmin=-0.5,xmax=99.5)
76 if "Sim" not in containerKey:
77
78 helper.defineHistogram(f"LBN,{containerKey}_nTOBs_nocut;h_"+containerKey+"_nTOBs", title = "Average # of " + containerKey + " TOBs;LBN",
79 fillGroup = baseGroupName + "_" + containerKey,
80 path=trigPath+pathFromKey(containerKey)+"NoCut",
81 type="TH2I",
82 xbins=1,xmin=0,xmax=1,ybins=20,ymin=-0.5,ymax=19.5, opt=['kAddBinsDynamically'])
83
84
85 commonAlgConfig = {"libname":"libdqm_summaries.so",
86 "name":"L1Calo_BinsDiffFromStripMedian",
87 "PublishDetail":32}
88 hotCuts = {"ColdCut":-7,"WarmCut":9,"HotCut":20}
89
90 commonThresholdConfig = {
91 "NWrongKnown":[0,100],
92 "NDead":[0,2],
93 "NHot":[0,2],
94 "NCold":[0,2],
95 "NWarm":[0,5],
96 "NDeadStrip":[0,0],
97 "NConsecUnlikelyStrip":[2,5],
98 }
99
100 knownAnomalies_eEM = {
101 "KnownDead":"\"49,41;49,42;48,8\"",
102 "KnownCold":"\"48,8;2,18;3,17;4,18;5,17;20,31;21,31;23,26;49,10;11,30;11,44;11,51;15,51;40,12;40,19;40,26;10,17;10,18;10,20;2,50;24,49;14,54;12,20;14,51;16,49;21,46;23,47;31,24;34,40;35,40;36,39;37,39;42,38;46,41;47,47;47,8\"",
103 "KnownWarm":"\"11,26;11,52;21,48;40,21;41,21;42,21;43,21;44,21;45,21;46,21;47,21;50,21\"",
104 "KnownHot":"\"4,5;6,2;13,48;21,48;14,49;27,53;35,13;22,14\""
105
106
107
108
109
110 }
111
112
113 from TrigT1CaloMonitoring.EfexInputMonitorAlgorithm import knownAnomalies_hotHcal
114
115
116 knownAnomalies_eTAU = {
117 "KnownCold":knownAnomalies_eEM[
"KnownDead"][:-1]+
";"+knownAnomalies_hotHcal[
"KnownDead"][1:-1].
replace(
"41,21;",
"")+knownAnomalies_hotHcal[
"KnownCold"][1:-1]+
";48,8;2,18;3,17;4,18;5,17;49,10;10,18;10,20;20,31;21,31;14,51;15,51;23,26;29,7;17,32;14,54;34,6;40,12;40,19;26,20;11,44;24,49;30,15;32,46;29,5;16,49;12,19;12,20;17,3;20,10;22,47;23,47;34,10;34,40;35,40;37,39;40,26;43,59;47,47;47,8\"",
118 "KnownWarm":"\"24,39;41,21;43,21;44,21;47,21\"",
119 "KnownHot":"\"4,5;6,2;11,27;13,48;15,49;21,48;40,24;42,35;18,4\""
120
121
122
123
124 }
125
126 helper.defineDQAlgorithm("Efex_eEM_etaThiMapFilled",
127 hanConfig=commonAlgConfig|hotCuts|knownAnomalies_eEM,
128 thresholdConfig=commonThresholdConfig
129 )
130 helper.defineDQAlgorithm("Efex_eTAU_etaThiMapFilled",
131 hanConfig=commonAlgConfig|hotCuts|knownAnomalies_eTAU,
132 thresholdConfig=commonThresholdConfig
133 )
134
135 helper.defineDQAlgorithm("Efex_eEM_etaPhiLBMapOutliers_Shifter",
136 hanConfig=commonAlgConfig|hotCuts|knownAnomalies_eEM|{"NBinsY":64,"LiveMode":1},
137 thresholdConfig=commonThresholdConfig
138 )
139 helper.defineDQAlgorithm("Efex_eEM_etaPhiLBMapOutliers",
140 hanConfig=commonAlgConfig|hotCuts|knownAnomalies_eEM|{"NBinsY":64,"LiveMode":0},
141 thresholdConfig=commonThresholdConfig
142 )
143 helper.defineDQAlgorithm("Efex_eTAU_etaPhiLBMapOutliers_Shifter",
144 hanConfig=commonAlgConfig|hotCuts|knownAnomalies_eTAU|{"NBinsY":64,"LiveMode":1},
145 thresholdConfig=commonThresholdConfig
146 )
147 helper.defineDQAlgorithm("Efex_eTAU_etaPhiLBMapOutliers",
148 hanConfig=commonAlgConfig|hotCuts|knownAnomalies_eTAU|{"NBinsY":64,"LiveMode":0},
149 thresholdConfig=commonThresholdConfig
150 )
151
152
153
154 for cut_name, cut_val in zip(cut_names, cut_vals):
155 cut_title_addition = '' if (cut_val == 0.0) else ' [Et>=' + '%.1f'%(cut_val/1000) + 'GeV]'
156
157 for containerKey in EfexMonAlg.eFexEMTobKeyList:
158 fillGroup = baseGroupName+'_'+containerKey+'_'+cut_name
159 tobStr = containerKey
160
161 helper.defineHistogram('nEMTOBs;h_nEmTOBs', title='Number of '+tobStr+'s'+cut_title_addition+';EM '+tobStr+'s;Number of EM '+tobStr+'s',
162 fillGroup=fillGroup,
163 type='TH1I', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=10,xmin=0,xmax=10)
164
165 helper.defineHistogram('TOBTransverseEnergy;h_TOBTransverseEnergy', title=tobStr+' ET [MeV]'+cut_title_addition,
166 fillGroup=fillGroup,
167 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=100,xmin=0,xmax=50000)
168
169 helper.defineHistogram('TOBEta;h_TOBEta', title=tobStr+' Eta'+cut_title_addition,
170 fillGroup=fillGroup,
171 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=50,xmin=-2.5,xmax=2.5)
172
173 helper.defineHistogram('TOBPhi;h_TOBPhi', title=tobStr+' Phi'+cut_title_addition,
174 fillGroup=fillGroup,
175 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=64,xmin=-math.pi,xmax=math.pi)
176
177 helper.defineHistogram(f"TOBEta,TOBPhi;h_{containerKey}_{cut_name}_EtaPhiMap", title=tobStr+' Count'+cut_title_addition+';#eta;#phi',
178 fillGroup=fillGroup,
179 hanConfig={"display":"SetPalette(55)",
180 "description":f"Any really significant hot/cold spots (see results for significances) should check over what LBs they occurred, using <a href='./detail/h_{containerKey}_{cut_name}_posVsLBN'>detail timeseries</a>. Any new (unknown) spots, if they occur multiple times in a week, please report","algorithm":"Efex_eEM_etaThiMapFilled"},
181 type='TH2F',
182 path=(("Expert/Outputs/"+pathFromKey(containerKey,"")) if "Sim" not in containerKey and "x" not in containerKey else trigPath+pathFromKey(containerKey)+cut_name),
183 xbins=50,xmin=-2.5,xmax=2.5,ybins=64,ymin=-math.pi,ymax=math.pi,opt=['kAlwaysCreate'])
184
185 if "Sim" not in containerKey and "x" not in containerKey:
186 helper.defineHistogram(f"LBN,binNumber;h_{containerKey}_{cut_name}_posVsLBN", title=tobStr+' Count'+cut_title_addition+';LB;64(x-1)+y',
187 fillGroup=fillGroup,
188 hanConfig={"Expert/algorithm":f"Efex_{pathFromKey(containerKey,'')}_etaPhiLBMapOutliers","Shifter/algorithm":f"Efex_{pathFromKey(containerKey,'')}_etaPhiLBMapOutliers_Shifter",
189 "description":f"Timeseries of TOB counts at each location ... y-axis relates to x and y bin numbers from <a href='../h_{containerKey}_{cut_name}_EtaPhiMap'>eta-phi map</a>. Use Projection X1 for 1D plot"},
190 type='TH2I',
191 paths=["Expert/Outputs/"+pathFromKey(containerKey,"")+"/detail","Shifter/Outputs/"+pathFromKey(containerKey,"")],
192 xbins=1,xmin=0,xmax=10,
193 ybins=64*50,ymin=0.5,ymax=64*50+0.5,opt=['kAddBinsDynamically'])
194
195 helper.defineHistogram('TOBshelfNumber;h_TOBshelfNumber', title=tobStr+' EM Shelf Number'+cut_title_addition,
196 fillGroup=fillGroup,
197 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=2,xmin=0,xmax=2)
198
199 helper.defineHistogram('TOBeFEXNumberSh0;h_TOBeFEXNumberShelf0', title=tobStr+' EM Module Number Shelf 0'+cut_title_addition,
200 fillGroup=fillGroup,
201 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=12,xmin=0,xmax=12)
202
203 helper.defineHistogram('TOBeFEXNumberSh1;h_TOBeFEXNumberShelf1', title=tobStr+' EM Module Number Shelf 1'+cut_title_addition,
204 fillGroup=fillGroup,
205 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=12,xmin=0,xmax=12)
206
207 helper.defineHistogram('TOBfpga;h_TOBfpga', title=tobStr+' EM FPGA'+cut_title_addition,
208 fillGroup=fillGroup,
209 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4)
210
211 helper.defineHistogram('TOBReta;h_TOBReta', title=tobStr+' EM Reta'+cut_title_addition,
212 fillGroup=fillGroup,
213 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name,xbins=250,xmin=0,xmax=1)
214
215 helper.defineHistogram('TOBRhad;h_TOBRhad', title=tobStr+' EM Rhad'+cut_title_addition,
216 fillGroup=fillGroup,
217 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=250,xmin=0,xmax=1)
218
219 helper.defineHistogram('TOBWstot;h_TOBWstot', title=tobStr+' EM Wstot'+cut_title_addition,
220 fillGroup=fillGroup,
221 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=250,xmin=0,xmax=1)
222
223 threshold_labels = ['fail','loose','medium','tight']
224 helper.defineHistogram('TOBReta_threshold;h_TOBReta_threshold', title=tobStr+' EM Reta threshold'+cut_title_addition,
225 fillGroup=fillGroup,
226 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name,xbins=4,xmin=0,xmax=4.0,xlabels=threshold_labels)
227
228 helper.defineHistogram('TOBRhad_threshold;h_TOBRhad_threshold', title=tobStr+' EM Rhad threshold'+cut_title_addition,
229 fillGroup=fillGroup,
230 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4.0,xlabels=threshold_labels)
231
232 helper.defineHistogram('TOBWstot_threshold;h_TOBWstot_threshold', title=tobStr+' EM Wstot threshold'+cut_title_addition,
233 fillGroup=fillGroup,
234 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4.0,xlabels=threshold_labels)
235
236
237 for containerKey in EfexMonAlg.eFexTauTobKeyList:
238 fillGroup = baseGroupName+'_'+containerKey+'_'+cut_name
239 tobStr = containerKey
240
241 helper.defineHistogram('nTauTOBs;h_nTauTOBs', title='Number of '+tobStr+'s'+cut_title_addition+';Tau '+tobStr+'s;Number of Tau '+tobStr+'s',
242 fillGroup = fillGroup,
243 type='TH1I', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=10,xmin=0,xmax=10)
244
245 helper.defineHistogram('tauTOBTransverseEnergy;h_tauTOBTransverseEnergy', title=tobStr+' Tau Transverse Energy [MeV]'+cut_title_addition,
246 fillGroup = fillGroup,
247 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=100,xmin=0,xmax=50000)
248
249 helper.defineHistogram('tauTOBEta;h_tauTOBEta', title=tobStr+' Tau Eta'+cut_title_addition,
250 fillGroup = fillGroup,
251 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=60,xmin=-2.5,xmax=2.5)
252
253 helper.defineHistogram('tauTOBPhi;h_tauTOBPhi', title=tobStr+' Tau Phi'+cut_title_addition,
254 fillGroup = fillGroup,
255 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=100,xmin=-math.pi,xmax=math.pi)
256
257 helper.defineHistogram(f"tauTOBEta,tauTOBPhi;h_{containerKey}_{cut_name}_EtaPhiMap", title='eTAU '+tobStr+' Count'+cut_title_addition+';#eta;#phi',
258 fillGroup = fillGroup,
259 hanConfig={"display":"SetPalette(55)",
260 "description":f"Any really significant hot/cold spots (see results for significances) should check over what LBs they occurred, using <a href='./detail/h_{containerKey}_{cut_name}_posVsLBN'>detail timeseries</a>. Any new (unknown) spots, if they occur multiple times in a week, please report","algorithm":"Efex_eTAU_etaThiMapFilled"},
261 type='TH2F',
262 path=(("Expert/Outputs/"+pathFromKey(containerKey,"")) if "Sim" not in containerKey and "x" not in containerKey else (trigPath+pathFromKey(containerKey)+cut_name)),
263 xbins=50,xmin=-2.5,xmax=2.5,ybins=64,ymin=-math.pi,ymax=math.pi,opt=['kAlwaysCreate'])
264
265 if "Sim" not in containerKey and "x" not in containerKey:
266 helper.defineHistogram(f"LBN,binNumber;h_{containerKey}_{cut_name}_posVsLBN", title='eTAU '+tobStr+' Count'+cut_title_addition+';LB;64(x-1)+y',
267 fillGroup=fillGroup,
268 hanConfig={"Expert/algorithm":f"Efex_{pathFromKey(containerKey,'')}_etaPhiLBMapOutliers","Shifter/algorithm":f"Efex_{pathFromKey(containerKey,'')}_etaPhiLBMapOutliers_Shifter",
269 "description":f"Timeseries of TOB counts at each location ... y-axis relates to x and y bin numbers from <a href='../h_{containerKey}_{cut_name}_EtaPhiMap'>eta-phi map</a>. Use Projection X1 for 1D plot"},
270 type='TH2I',
271 paths=["Expert/Outputs/"+pathFromKey(containerKey,"")+"/detail","Shifter/Outputs/"+pathFromKey(containerKey,"")],
272 xbins=1,xmin=0,xmax=10,
273 ybins=64*50,ymin=0.5,ymax=64*50+0.5,opt=['kAddBinsDynamically'])
274
275 helper.defineHistogram('tauTOBshelfNumber;h_tauTOBshelfNumber', title=tobStr+' Tau Shelf Number'+cut_title_addition,
276 fillGroup = fillGroup,
277 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=2,xmin=0,xmax=2)
278
279 helper.defineHistogram('tauTOBeFEXNumberSh0;h_tauTOBeFEXNumberShelf0', title=tobStr+' Tau Module Number Shelf 0'+cut_title_addition,
280 fillGroup = fillGroup,
281 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=12,xmin=0,xmax=12)
282
283 helper.defineHistogram('tauTOBeFEXNumberSh1;h_tauTOBeFEXNumberShelf1', title=tobStr+' Tau Module Number Shelf 1'+cut_title_addition,
284 fillGroup = fillGroup,
285 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=12,xmin=0,xmax=12)
286
287
288 helper.defineHistogram('tauTOBfpga;h_tauTOBfpga', title=tobStr+' Tau FPGA'+cut_title_addition,
289 fillGroup = fillGroup,
290 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4)
291
292 helper.defineHistogram('tauTOBRcore;h_tauTOBRcore', title=tobStr+' Tau rCore'+cut_title_addition,
293 fillGroup = fillGroup,
294 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=250,xmin=0,xmax=1)
295
296 helper.defineHistogram('tauTOBRhad;h_tauTOBRhad', title=tobStr+' Tau rHad'+cut_title_addition,
297 fillGroup = fillGroup,
298 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=250,xmin=0,xmax=1)
299
300 helper.defineHistogram('tauTOBRcore_threshold;h_tauTOBRcore_threshold', title=tobStr+' Tau rCore threshold'+cut_title_addition,
301 fillGroup = fillGroup,
302 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4.0, xlabels=threshold_labels)
303
304 helper.defineHistogram('tauTOBRhad_threshold;h_tauTOBRhad_threshold', title=tobStr+' Tau rHad threshold'+cut_title_addition,
305 fillGroup = fillGroup,
306 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4.0, xlabels=threshold_labels)
307
308 helper.defineHistogram('tauTOBthree_threshold;h_tauTOBthree_threshold', title=tobStr+' Tau 3 taus threshold'+cut_title_addition,
309 fillGroup = fillGroup,
310 type='TH1F', path=trigPath+pathFromKey(containerKey)+cut_name, xbins=4,xmin=0,xmax=4.0, xlabels=threshold_labels)
311
312 acc = helper.result()
313 result.merge(acc)
314 return result
315
316
std::string replace(std::string s, const std::string &s2, const std::string &s3)