4def GfexMonitoringConfig(flags):
5 '''Function to configure LVL1 Gfex algorithm in the monitoring system.'''
6 import math
7
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10 result = ComponentAccumulator()
11
12
13
14 from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
15 helper = L1CaloMonitorCfgHelper(flags,CompFactory.GfexMonitorAlgorithm,'GfexMonAlg')
16 GfexMonAlg = helper.alg
17
18
19 groupName = 'GfexMonitor'
20 GfexMonAlg.PackageName = groupName
21
22 GfexMonAlg.gFexJetTobKeyList = ["L1_gFexLRJetRoI", "L1_gFexSRJetRoI"]
23 GfexMonAlg.gFexRhoTobKeyList = ["L1_gFexRhoRoI"]
24 GfexMonAlg.gFexGlobalTobKeyList = ["L1_gScalarEJwoj", "L1_gMETComponentsJwoj", "L1_gMHTComponentsJwoj", "L1_gMSTComponentsJwoj"]
25
26
27 devPath = 'Developer/GfexOutput/'
28 expertPath = 'Expert/Outputs/'
29 globTobVarDict = {"gScalarEJwoj":["gFexMet", "gFexSumEt"], "gMETComponentsJwoj":["METx", "METy"], "gMHTComponentsJwoj":["MHTx", "MHTy"], "gMSTComponentsJwoj":["MSTx", "MSTy"]}
30
31
32
33 keyDirPathMap = {"gFexMet":"gXE/", "gFexSumEt":"gTE/", "METx":"gXE/", "METy":"gXE/", "MHTx":"gMHT/", "MHTy":"gMHT/", "MSTx":"gMST/", "MSTy":"gMST/"}
34
35
36
37 globTobRangeDict = {"gFexMet":[0, 4e5], "gFexSumEt":[0, 2e6], "METx":[-3e5, 3e5], "METy":[-3e5, 3e5], "MHTx":[-3e5, 3e5], "MHTy":[-3e5, 3e5], "MSTx":[-2e5, 2e5], "MSTy":[-2e5, 2e5]}
38
39
40
41
42
43
44 ptCutValuesgLJ = GfexMonAlg.ptCutValuesgLJ
45 ptCutValuesgJ = GfexMonAlg.ptCutValuesgJ
46 gFexJetTobKeyList = GfexMonAlg.gFexJetTobKeyList
47 gFexRhoTobKeyList = GfexMonAlg.gFexRhoTobKeyList
48 gFexGlobalTobKeyList = GfexMonAlg.gFexGlobalTobKeyList
49
50
51 import numpy as np
52 eta_bins = [-4.9, -4.1,-3.5,-3.25,-3.2,-3.1,-2.9,-2.7,-2.5,2.5,2.7,2.9,3.1,3.3,3.25,3.5,4.1,4.9 ]
53 for eta in np.arange (-2.2,2.4,0.2):
54 eta_bins.append(eta)
55
56 eta_bins = sorted(eta_bins)
57
58 nbins_total = 32*40
59
60
61 helper.defineDQAlgorithm("Gfex_etaPhiMapFilled_gJ",
62 hanConfig={"libname":"libdqm_summaries.so","name":"Bins_Equal_Threshold","BinThreshold":"0"},
63 thresholdConfig={"NBins":[0,nbins_total]},
64 )
65
66 helper.defineDQAlgorithm("Gfex_etaPhiMapFilled_gLJ",
67 hanConfig={"libname":"libdqm_summaries.so","name":"Bins_Equal_Threshold","BinThreshold":"0"},
68 thresholdConfig={"NBins":[0,nbins_total]},
69 )
70
71
72 for containerKey in gFexJetTobKeyList:
73 ptCutValues = ptCutValuesgLJ if "LRJet" in containerKey else ptCutValuesgJ
74 for ptCut in ptCutValues:
75
76 ptCutString = "_CutPt{:.0f}".format(ptCut) if (ptCut != -1) else ""
77 containerKey = containerKey.split("+")[-1]
78
79
80 tobTypeStr = "gFex SRJet" if "SRJet" in containerKey else "gFex LRJet"
81
82 ptStrTitle = f" - tobEt [200 MeV Scale]>{ptCut}" if ptCut != -1 else ""
83 gPath = "gJ" if "SRJet" in containerKey else "gLJ"
84
85 helper.defineHistogram(f"{containerKey}Eta{ptCutString};h_{containerKey}Eta{ptCutString}", title="{} #eta{}; #eta; counts".format(tobTypeStr, ptStrTitle), type='TH1F', fillGroup=groupName, path=f"{devPath}{gPath}/", xbins=eta_bins)
86 helper.defineHistogram(f"{containerKey}Phi{ptCutString};h_{containerKey}Phi{ptCutString}", title="{} #phi{}; #phi; counts".format(tobTypeStr, ptStrTitle), type='TH1F', fillGroup=groupName, path=f"{devPath}{gPath}", xbins=32,xmin=-math.pi,xmax=math.pi)
87 helper.defineHistogram(f"{containerKey}Pt{ptCutString};h_{containerKey}Pt{ptCutString}" , title="{} Pt{} ; Pt [MeV] ; counts".format(tobTypeStr, ptStrTitle), type='TH1F', fillGroup=groupName,path=f"{devPath}{gPath}",xbins=100,xmin=-1,xmax=4096)
88
89
90 if gPath == "gJ":
91 helper.defineHistogram(f"{containerKey}Eta{ptCutString},{containerKey}Phi{ptCutString};h_etaphiMap{containerKey}{ptCutString}", title="{} {} #eta vs #phi ; #eta; #phi; Number of TOBs".format(tobTypeStr, ptStrTitle),
92 type='TH2F',fillGroup=groupName, path=f"{expertPath}{gPath}/",
93 hanConfig={
94 "algorithm": "Gfex_etaPhiMapFilled_gJ",
95 "description":f"Inspect for hot/cold spots - check <a href='./detail/h_{containerKey}{ptCutString}_posVsLBN'>detail timeseries</a>",
96 "display":"SetPalette(55),Draw=COL1Z"
97 },
98 opt=['kAlwaysCreate'],
99 xbins=eta_bins,ybins=32,ymin=-3.2,ymax=3.2)
100
101
102 helper.defineHistogram(f"{containerKey}LBN{ptCutString},{containerKey}binNumber{ptCutString};h_{containerKey}{ptCutString}_posVsLBN",title="{} {} LBN vs 32(x-1)+y; LBN; 32(x-1)+y".format(tobTypeStr, ptStrTitle),
103 path=f"{expertPath}{gPath}/detail",
104 fillGroup = groupName,
105 hanConfig={"description":f"x and y correspond to axis bin numbers on <a href='../h_etaphiMap{containerKey}{ptCutString}'/>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"},
106 type='TH2I',
107 xbins=1,xmin=0,xmax=10,
108 ybins=40*32,ymin=0.5,ymax=40*32+0.5,
109 opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
110
111 if (gPath == "gLJ"):
112 helper.defineHistogram(f"{containerKey}Eta{ptCutString},{containerKey}Phi{ptCutString};h_etaphiMap{containerKey}{ptCutString}", title="{} {} #eta vs #phi ; #eta; #phi; Number of TOBs".format(tobTypeStr, ptStrTitle),
113 type='TH2F',fillGroup=groupName, path=f"{expertPath}{gPath}/",
114 hanConfig={
115 "algorithm": "Gfex_etaPhiMapFilled_gLJ",
116 "description":f"Inspect for hot/cold spots - check <a href='./detail/h_{containerKey}{ptCutString}_posVsLBN'>detail timeseries</a>",
117 "display":"SetPalette(55),Draw=COL1Z"
118 },
119 opt=['kAlwaysCreate'],
120 xbins=eta_bins, ybins=32,ymin=-3.2,ymax=3.2)
121
122 helper.defineHistogram(f"{containerKey}LBN{ptCutString},{containerKey}binNumber{ptCutString};h_{containerKey}{ptCutString}_posVsLBN",title="{} {} LBN vs 32(x-1)+y; LBN; 32(x-1)+y".format(tobTypeStr, ptStrTitle),
123 path=f"{expertPath}{gPath}/detail",
124 fillGroup = groupName,
125 hanConfig={"description":f"x and y correspond to axis bin numbers on <a href='../h_etaphiMap{containerKey}{ptCutString}'/>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"},
126 type='TH2I',
127 xbins=1,xmin=0,xmax=10,
128 ybins=40*32,ymin=0.5,ymax=40*32+0.5,
129 opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
130
131
132
133 for containerKey in gFexRhoTobKeyList:
134 helper.defineHistogram(f"{containerKey};h_{containerKey}", title=f"{containerKey}; gFexRho Et [MeV]; counts", fillGroup=groupName, type="TH1F", path=f"{devPath}gRHO", xbins=100,xmin=0,xmax=100000)
135
136
137 for containerKey in gFexGlobalTobKeyList:
138 for key, dictVal in globTobVarDict.items():
139 if key in containerKey:
140 varOne, varTwo = dictVal
141 break
142
143 xminOne, xmaxOne = globTobRangeDict.get(varOne, [0,1e6])
144 xminTwo, xmaxTwo = globTobRangeDict.get(varTwo, [0,1e6])
145
146 helper.defineHistogram("{};h_{}".format(varOne, varOne), title="{}; {} [MeV]; counts".format(varOne, varOne), type="TH1F", fillGroup=groupName, path=devPath+keyDirPathMap.get(varOne, "gFexGlob/"), xbins=100,xmin=xminOne,xmax=xmaxOne)
147 helper.defineHistogram("{};h_{}".format(varTwo, varTwo), title="{}; {} [MeV]; counts".format(varTwo, varTwo), type="TH1F", fillGroup=groupName, path=devPath+keyDirPathMap.get(varTwo, "gFexGlob/"), xbins=100,xmin=xminTwo,xmax=xmaxTwo)
148
149
150 acc = helper.result()
151 result.merge(acc)
152 return result
153