ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCaloRecConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon.SystemOfUnits import MeV, deg
4from AthenaCommon.Logging import logging
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
8from AthenaConfiguration.AccumulatorCache import AccumulatorCache
9from TriggerMenuMT.HLT.CommonSequences.FullScanDefs import em_clusters, lc_clusters, fs_towers, fs_cells
10
11from TrigEDMConfig.TriggerEDM import recordable
12
13mlog = logging.getLogger ('TrigCaloRecConfig')
14
15
16def trigCaloClusterMonitoringTool(flags, doMonCells = False, isFullScan = None):
17 """Monitoring tool for TrigCaloClusterMaker"""
18
19 monTool = GenericMonitoringTool(flags, 'MonTool')
20
21 if isFullScan is None:
22 isFullScan = doMonCells
23
24 maxNumberOfClusters = 1200 if isFullScan else 50
25
26 monTool.defineHistogram('container_size', path='EXPERT', type='TH1F', title="Container Size; Number of Clusters; Number of Events", xbins=50, xmin=0.0, xmax=maxNumberOfClusters)
27 monTool.defineHistogram('container_size_by_mu', path='EXPERT', type='TH1F', title="Container Size; Number of Clusters; Number of Events", xbins=50, xmin=0.0, xmax=maxNumberOfClusters/60)
28 monTool.defineHistogram('Et', path='EXPERT', type='TH1F', title="Cluster E_T; E_T [ MeV ] ; Number of Clusters", xbins=135, xmin=-200.0, xmax=2500.0)
29 monTool.defineHistogram('Eta', path='EXPERT', type='TH1F', title="Cluster #eta; #eta ; Number of Clusters", xbins=100, xmin=-2.5, xmax=2.5)
30 monTool.defineHistogram('Phi', path='EXPERT', type='TH1F', title="Cluster #phi; #phi ; Number of Clusters", xbins=64, xmin=-3.2, xmax=3.2)
31 monTool.defineHistogram('Eta,Phi', path='EXPERT', type='TH2F', title="Number of Clusters; #eta ; #phi ; Number of Clusters", xbins=100, xmin=-2.5, xmax=2.5, ybins=128, ymin=-3.2, ymax=3.2)
32 monTool.defineHistogram('clusterSize', path='EXPERT', type='TH1F', title="Cluster Type; Type ; Number of Clusters", xbins=13, xmin=0.5, xmax=13.5)
33 monTool.defineHistogram('signalState', path='EXPERT', type='TH1F', title="Signal State; Signal State ; Number of Clusters", xbins=4, xmin=-1.5, xmax=2.5)
34 monTool.defineHistogram('size', path='EXPERT', type='TH1F', title="Cluster Size; Size [Cells] ; Number of Clusters", xbins=125, xmin=0.0, xmax=250.0)
35 monTool.defineHistogram('N_BAD_CELLS', path='EXPERT', type='TH1F', title="N_BAD_CELLS; N_BAD_CELLS ; Number of Clusters", xbins=250, xmin=0.5, xmax=250.5)
36 monTool.defineHistogram('ENG_FRAC_MAX', path='EXPERT', type='TH1F', title="ENG_FRAC_MAX; ENG_FRAC_MAX ; Number of Clusters", xbins=50, xmin=0.0, xmax=1.1)
37 monTool.defineHistogram('mu', path='EXPERT', type='TH1F', title="mu; mu; Number of Events", xbins=50, xmin=0.0, xmax=100)
38 monTool.defineHistogram('mu,container_size', path='EXPERT', type='TH2F', title="Container Size versus #mu; #mu; cluster container size", xbins=50, xmin=20.0, xmax=70, ybins=50, ymin=0.0, ymax=maxNumberOfClusters)
39
40 if doMonCells:
41 monTool.defineHistogram('count_1thrsigma', path='EXPERT', type='TH1F', title="count_1thrsigma; count_1thresigma; Number of Events", xbins=60, xmin=0.0, xmax=12e3)
42 monTool.defineHistogram('count_2thrsigma', path='EXPERT', type='TH1F', title="count_2thrsigma; count_2thresigma; Number of Events", xbins=60, xmin=0.0, xmax=6e3)
43 monTool.defineHistogram('count_1thrsigma_by_mu2', path='EXPERT', type='TH1F', title="count_1thrsigma_by_mu2; count_1thresigma_by_mu2; Number of Events", xbins=50, xmin=0.0, xmax=10)
44 monTool.defineHistogram('count_2thrsigma_by_mu2', path='EXPERT', type='TH1F', title="count_2thrsigma_by_mu2; count_2thresigma_by_mu2; Number of Events", xbins=50, xmin=0.0, xmax=5)
45 monTool.defineHistogram('mu,count_1thrsigma', path='EXPERT', type='TH2F', title="nCells above 1st thr versus #mu; #mu; nCells", xbins=50, xmin=20.0, xmax=70, ybins=60, ymin=0.0, ymax=12e3)
46 monTool.defineHistogram('mu,count_2thrsigma', path='EXPERT', type='TH2F', title="nCells above 2nd thr versus #mu; #mu; nCells", xbins=50, xmin=20.0, xmax=70, ybins=60, ymin=0.0, ymax=6e3)
47
48 return monTool
49
50def hltCaloGlobalCellMakerCfg(flags, name="HLTCaloGlobalCellMaker", **kwargs):
51 acc = ComponentAccumulator()
52
53 kwargs.setdefault("InputCellKey", "Calo")
54 kwargs.setdefault("OutputCellKey", "OutCalo")
55 kwargs.setdefault("MaxNCellsPerFEB", 30)
56
57 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
58 acc.merge(CaloNoiseCondAlgCfg(flags))
59
60 acc.addEventAlgo(CompFactory.HLTCaloGlobalCellMaker(name, **kwargs))
61 return(acc)
62
63def hltCaloGlobalCellMonitorCfg(flags, name="HLTCaloGlobalCellMonitor", **kwargs):
64 acc = ComponentAccumulator()
65
66 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
67 monTool = GenericMonitoringTool(flags, 'MonTool'+name)
68 monTool.defineHistogram('inputContSize', path='EXPERT', type='TH1F', title="InputContSize; InputContSize; events", xbins=190, xmin=0, xmax=190000)
69 monTool.defineHistogram('outputContSize', path='EXPERT', type='TH1F', title="outputContSize; outputContSize; events", xbins=200, xmin=0, xmax=20000)
70 monTool.defineHistogram('larContSize', path='EXPERT', type='TH1F', title="larContSize; larContSize; events", xbins=190, xmin=0, xmax=190000)
71 monTool.defineHistogram('larAboveSigmaContSize', path='EXPERT', type='TH1F', title="larAboveSigmaContSize; larAboveSigmaContSize; events", xbins=150, xmin=0, xmax=15000)
72 monTool.defineHistogram('CellsPerFEB', path='EXPERT', type='TH1F', title="CellsPerFEB; CellsPerFEB; counts ", xbins=128, xmin=0, xmax=128)
73 monTool.defineHistogram('FEBID,CellsPerFEB', path='EXPERT', type='TH2F', title="CellsPerFEB; CellsPerFEB; FEBID", xbins=1524, xmin=0x38000000, xmax=0x3bc60000, ybins=128, ymin=0, ymax=128)
74 monTool.defineHistogram('layer0', path='EXPERT', type='TH1F', title="layer0; layer0; counts ", xbins=128, xmin=0, xmax=128)
75 monTool.defineHistogram('layer1', path='EXPERT', type='TH1F', title="layer1; layer1; counts ", xbins=128, xmin=0, xmax=128)
76 monTool.defineHistogram('layer2', path='EXPERT', type='TH1F', title="layer2; layer2; counts ", xbins=128, xmin=0, xmax=128)
77 monTool.defineHistogram('layer3', path='EXPERT', type='TH1F', title="layer3; layer3; counts ", xbins=128, xmin=0, xmax=128)
78 monTool.defineHistogram('layer4', path='EXPERT', type='TH1F', title="layer4; layer4; counts ", xbins=128, xmin=0, xmax=128)
79 monTool.defineHistogram('layer5', path='EXPERT', type='TH1F', title="layer5; layer5; counts ", xbins=128, xmin=0, xmax=128)
80 monTool.defineHistogram('layer6', path='EXPERT', type='TH1F', title="layer6; layer6; counts ", xbins=128, xmin=0, xmax=128)
81 monTool.defineHistogram('layer7', path='EXPERT', type='TH1F', title="layer7; layer7; counts ", xbins=128, xmin=0, xmax=128)
82 monTool.defineHistogram('layerIW1', path='EXPERT', type='TH1F', title="layerIW1; layerIW1; counts ", xbins=128, xmin=0, xmax=128)
83 monTool.defineHistogram('layerIW2', path='EXPERT', type='TH1F', title="layerIW2; layerIW2; counts ", xbins=128, xmin=0, xmax=128)
84 monTool.defineHistogram('BCID,layerIW1', path='EXPERT', type='TH2F', title="BCID_vs_layerIW1; BCID; layerIW1; ", xbins=512, xmin=0, xmax=512, ybins=128, ymin=0, ymax=128)
85 monTool.defineHistogram('BCID,layerIW2', path='EXPERT', type='TH2F', title="BCID_vs_layerIW2; BCID; layerIW2;", xbins=512, xmin=0, xmax=512, ybins=128, ymin=0, ymax=128)
86 kwargs.setdefault("MonitoringTool", monTool)
87
88 kwargs.setdefault("MaxNCellsPerFEB", 128 )
89 kwargs.setdefault("NumberOfSigma", 2)
90 acc.addEventAlgo(CompFactory.HLTCaloGlobalCellMonitor(name, **kwargs))
91 return(acc)
92
93@AccumulatorCache
94def hltCaloCellMakerCfg(flags, name=None, roisKey='UNSPECIFIED', CellsName=None, monitorCells=False, doTau=False,sequenceName=None):
95 acc = ComponentAccumulator()
96 from TrigT2CaloCommon.TrigCaloDataAccessConfig import trigCaloDataAccessSvcCfg, CaloDataAccessSvcDependencies
97 acc.merge(trigCaloDataAccessSvcCfg(flags))
98 #choose RoI for fullscan
99 if (roisKey == 'UNSPECIFIED'):
100 from HLTSeeding.HLTSeedingConfig import mapThresholdToL1RoICollection
101 roisKey = mapThresholdToL1RoICollection("FSNOSEED")
102 # choose cells name given parameters
103 cellsFromName = 'CaloCellsFS' if "FS" in name else "CaloCells"
104 cells = cellsFromName if CellsName is None else CellsName
105
106 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
107 monTool = GenericMonitoringTool(flags, 'MonTool')
108 monTool.defineHistogram('Cells_N', path='EXPERT', type='TH1F', title="Cells N; NCells; events",
109 xbins=40, xmin=0, xmax=1600 if monitorCells else 240000)
110 monTool.defineHistogram('TIME_exec', path='EXPERT', type='TH1F', title="Cells time; time [ us ] ; Nruns",
111 xbins=80, xmin=0, xmax=800 if monitorCells else 160000)
112 if monitorCells:
113 monTool.defineHistogram('Cells_eT', path='EXPERT', type='TH1F', title="Cells E_T; E_T [ GeV ] ; Nclusters",
114 xbins=100, xmin=0.0, xmax=100.0)
115 monTool.defineHistogram('Cells_eta', path='EXPERT', type='TH1F', title="Cells #eta; #eta ; Nclusters",
116 xbins=100, xmin=-2.5, xmax=2.5)
117 monTool.defineHistogram('Cells_phi', path='EXPERT', type='TH1F', title="Cells #phi; #phi ; Nclusters",
118 xbins=128, xmin=-3.2, xmax=3.2)
119
120 if sequenceName is not None:
121 from AthenaCommon.CFElements import parOR
122 acc.merge(ComponentAccumulator(parOR(sequenceName)))
123 cellMaker = CompFactory.HLTCaloCellMaker(name,
124 CellsName = cells,
125 TrigDataAccessMT = acc.getService('TrigCaloDataAccessSvc'),
126 ExtraInputs = CaloDataAccessSvcDependencies,
127 RoIs=roisKey,
128 monitorCells = monitorCells,
129 MonTool = monTool,
130 TileCellsInROI = False if not doTau else True)
131 acc.addEventAlgo(cellMaker, primary=True,sequenceName=sequenceName)
132 return acc
133
134@AccumulatorCache
135def hltCaloCellCorrectorCfg(flags,name='HLTCaloCellCorrector', inputEDM='CellsClusters', outputEDM='CorrectedCellsClusters', eventShape='HIEventShape'):
136 acc = ComponentAccumulator()
137 cellCorrector = CompFactory.HLTCaloCellCorrector(name = name,
138 EventShapeCollection = eventShape,
139 InputCellKey = inputEDM,
140 OutputCellKey = outputEDM)
141 acc.addEventAlgo(cellCorrector)
142 return acc
143
144
145@AccumulatorCache
146def hltCaloCellSeedlessMakerCfg(flags, roisKey='UNSPECIFIED',sequenceName=None):
147 acc = ComponentAccumulator()
148 hltCaloCellMakerAcc = hltCaloCellMakerCfg(flags, "CaloCellSeedLessFS",
149 roisKey = roisKey,
150 CellsName ="SeedLessFS",
151 monitorCells=False)
152
153 acc.merge(hltCaloCellMakerAcc,sequenceName=sequenceName)
154
155 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
156 acc.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
157 acc.addCondAlgo(CompFactory.CaloNoiseSigmaDiffCondAlg())
158
159 return acc
160
161
162@AccumulatorCache
163def L0CaloGlobalRoIBuilderCfg(flags,DoNoiseThrRings=True):
164 acc = ComponentAccumulator()
165 from TrigT2CaloEgamma.TrigT2CaloEgammaConfig import RingerReFexConfig
166 nameTool='RingerGlobalFex'
167 nameAlgo='L0CaloGlobalRoIBuilder'
168 nameContCalo='CaloClustersGlobal'
169 nameContRinger='RingerGlobal'
170 if ( DoNoiseThrRings ):
171 nameTool='RingerGlobal2sigFex'
172 nameAlgo='L0CaloGlobalRoI2sigBuilder'
173 nameContCalo='CaloClusters2sigGlobal'
174 nameContRinger='Ringer2sigGlobal'
175 ringer = RingerReFexConfig(flags,name=nameTool,RingerKey='NOTNEEDED',
176 ClustersName=nameContCalo,DoNoiseThrRings=DoNoiseThrRings)
177 from AthenaCommon.CFElements import parOR
178 accSeq = ComponentAccumulator(parOR("HLTBeginSeq"))
179 L0CaloGlobalRoIBuilderAlg = CompFactory.CaloGlobalRoIBuilder(name=nameAlgo,
180 Cells ="SeedLessFS", ClustersName=nameContCalo,
181 RingerKey=nameContRinger,
182 RingerTool=ringer )
183 accSeq.addEventAlgo(L0CaloGlobalRoIBuilderAlg, sequenceName="HLTBeginSeq")
184
185 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
186 acc.merge(CaloNoiseCondAlgCfg(flags))
187 acc.merge(accSeq)
188
189 return acc
190
191def CaloL0RingerPreCfg(flags,DoNoiseThrRings=True):
192 flags.Trigger.ExtraEDMList+= CaloL0RingerPrepareList(DoNoiseThrRings)
193
194def CaloL0RingerPrepareList(DoNoiseThrRings=True):
195 extraEDMList=[]
196 if DoNoiseThrRings :
197 extraEDMList+=[('xAOD::TrigRingerRingsContainer#Ringer2sigGlobal', 'BS ESD AODFULL', 'Calo'), ('xAOD::TrigRingerRingsAuxContainer#Ringer2sigGlobalAux.', 'BS ESD AODFULL', 'Calo'), ('xAOD::TrigEMClusterContainer#CaloClusters2sigGlobal', 'BS ESD AODFULL', 'Calo'), ('xAOD::TrigEMClusterAuxContainer#CaloClusters2sigGlobalAux.', 'BS ESD AODFULL', 'Calo')]
198 else :
199 extraEDMList+=[('xAOD::TrigRingerRingsContainer#RingerGlobal', 'BS ESD AODFULL', 'Calo'), ('xAOD::TrigRingerRingsAuxContainer#RingerGlobalAux.', 'BS ESD AODFULL', 'Calo'), ('xAOD::TrigEMClusterContainer#CaloClustersGlobal', 'BS ESD AODFULL', 'Calo'), ('xAOD::TrigEMClusterAuxContainer#CaloClustersGlobalAux.', 'BS ESD AODFULL', 'Calo')]
200 return extraEDMList
201
202def CaloL0RingerCfg(flags,DoNoiseThrRings=True):
203 from OutputStreamAthenaPool.OutputStreamConfig import addToESD,addToAOD
204 extraContent=CaloL0RingerPrepareList(DoNoiseThrRings)
205 acc = ComponentAccumulator()
206 from AthenaCommon.CFElements import parOR
207 if (flags.Output.doWriteRDO):
208 accSeq = ComponentAccumulator(parOR("HLTBeginSeq"))
209 accSeq.merge(hltCaloCellSeedlessMakerCfg(flags, sequenceName="HLTBeginSeq"))
210 accSeq.merge(L0CaloGlobalRoIBuilderCfg(flags,DoNoiseThrRings=DoNoiseThrRings))
211 acc.merge(accSeq)
212
213 if (flags.Output.doWriteESD or flags.Output.doWriteAOD):
214 if ( flags.Output.doWriteESD ):
215 acc.merge(addToESD(flags, extraContent))
216 if ( flags.Output.doWriteAOD ):
217 acc.merge(addToAOD(flags, extraContent))
218 return acc
219
220
221
222def hltCaloLocalCalib(flags, name = "TrigLocalCalib"):
223 det_version_is_rome = flags.GeoModel.AtlasVersion.startswith("Rome")
224 localCalibTool = CompFactory.CaloLCWeightTool("TrigLCWeight",
225 CorrectionKey="H1ClusterCellWeights",
226 SignalOverNoiseCut=2.0, UseHadProbability=True)
227 trigLCClassify = CompFactory.CaloLCClassificationTool("TrigLCClassify",
228 ClassificationKey="EMFracClassify",
229 UseSpread=False, MaxProbability=0.85 if det_version_is_rome else 0.5,
230 UseNormalizedEnergyDensity=not det_version_is_rome,
231 StoreClassificationProbabilityInAOD=True)
232 tool = CompFactory.CaloClusterLocalCalib( name,
233 ClusterRecoStatus=[1, 2], ClusterClassificationTool=[ trigLCClassify ],
234 LocalCalibTools=[ localCalibTool ])
235 return tool
236
237
238def hltCaloOOCalib(flags, name = "TrigOOCCalib"):
239 localCalibTool = CompFactory.CaloLCOutOfClusterTool("TrigLCOut",
240 CorrectionKey="OOCCorrection",UseEmProbability=False,
241 UseHadProbability=True)
242 tool = CompFactory.CaloClusterLocalCalib( name,
243 ClusterRecoStatus=[1, 2],
244 LocalCalibTools=[ localCalibTool ] )
245 return tool
246
247def hltCaloOOCPi0Calib(flags, name = "TrigOOCPi0Calib" ):
248 localCalibTool = CompFactory.CaloLCOutOfClusterTool("TrigLCOutPi0",
249 CorrectionKey="OOCPi0Correction", UseEmProbability=True,
250 UseHadProbability=False)
251 tool = CompFactory.CaloClusterLocalCalib( name,
252 ClusterRecoStatus=[1, 2],
253 LocalCalibTools=[ localCalibTool ] )
254 return tool
255
256def hltCaloDMCalib(flags, name = "TrigDMCalib" ):
257 localCalibTool = CompFactory.CaloLCDeadMaterialTool("TrigLCDeadMaterial",
258 HadDMCoeffKey="HadDMCoeff2", ClusterRecoStatus=0,
259 WeightModeDM=2,UseHadProbability=True)
260 tool = CompFactory.CaloClusterLocalCalib( name,
261 ClusterRecoStatus=[1, 2],
262 LocalCalibTools=[ localCalibTool ] )
263 return tool
264
265
266
267@AccumulatorCache
268def hltTopoClusterMakerCfg(flags, name, clustersKey="HLT_TopoCaloClustersFS", cellsKey=None, doLC=False, suffix=''):
269 acc = ComponentAccumulator()
270 cellsFromName = 'CaloCellsFS' if "FS" in clustersKey else "CaloCells"
271 cells = cellsFromName if cellsKey is None else cellsKey
272
273 from CaloRec.CaloTopoClusterConfig import (
274 CaloTopoClusterToolCfg,
275 CaloTopoClusterSplitterToolCfg,
276 )
277
278 topoMaker = acc.popToolsAndMerge(CaloTopoClusterToolCfg(flags, cellsname=cells))
279 topoMaker.RestrictPSNeighbors = False
280 listClusterCorrectionTools = []
281 if doLC :
282 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
283 # We need the electronic noise for the LC weights
284 acc.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
285 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
286 acc.merge(caloTopoCoolFolderCfg(flags))
287 listClusterCorrectionTools = [ hltCaloLocalCalib(flags), hltCaloOOCalib(flags),
288 hltCaloOOCPi0Calib(flags), hltCaloDMCalib(flags) ]
289
290 #timing
291 topoMaker.SeedCutsInT = flags.Trigger.Calo.TopoCluster.doTimeCut
292 topoMaker.CutOOTseed = flags.Trigger.Calo.TopoCluster.extendTimeCut and flags.Trigger.Calo.TopoCluster.doTimeCut
293 topoMaker.UseTimeCutUpperLimit = flags.Trigger.Calo.TopoCluster.useUpperLimitForTimeCut
294 topoMaker.TimeCutUpperLimit = flags.Trigger.Calo.TopoCluster.timeCutUpperLimit
295
296 topoSplitter = acc.popToolsAndMerge(CaloTopoClusterSplitterToolCfg(flags))
297
298 topoMoments = CompFactory.CaloClusterMomentsMaker ('TrigTopoMoments')
299 topoMoments.MaxAxisAngle = 20*deg
300 topoMoments.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
301 topoMoments.MinBadLArQuality = 4000
302 topoMoments.MomentsNames = ['FIRST_PHI',
303 'FIRST_ETA',
304 'SECOND_R' ,
305 'SECOND_LAMBDA',
306 'DELTA_PHI',
307 'DELTA_THETA',
308 'DELTA_ALPHA' ,
309 'CENTER_X',
310 'CENTER_Y',
311 'CENTER_Z',
312 'CENTER_MAG',
313 'CENTER_LAMBDA',
314 'LATERAL',
315 'LONGITUDINAL',
316 'FIRST_ENG_DENS',
317 'ENG_FRAC_EM',
318 'ENG_FRAC_MAX',
319 'ENG_FRAC_CORE' ,
320 'FIRST_ENG_DENS',
321 'SECOND_ENG_DENS',
322 'ISOLATION',
323 'ENG_BAD_CELLS',
324 'N_BAD_CELLS',
325 'N_BAD_CELLS_CORR',
326 'BAD_CELLS_CORR_E',
327 'BADLARQ_FRAC',
328 'ENG_POS',
329 'SIGNIFICANCE',
330 'CELL_SIGNIFICANCE',
331 'CELL_SIG_SAMPLING',
332 'AVG_LAR_Q',
333 'AVG_TILE_Q'
334 ]
335
336 clustermakername = name + suffix
337 doMonCells = "FS" in clustermakername
338
339 alg = CompFactory.CaloClusterMaker(
340 clustermakername,
341 ClustersOutputName=clustersKey if "CaloMon" in clustermakername else recordable(clustersKey),
342 ClusterCellLinkOutputName = clustersKey+"_links",
343 ClusterMakerTools = [ topoMaker, topoSplitter, topoMoments],
344 ClusterCorrectionTools = listClusterCorrectionTools,
345 SaveUncalibratedSignalState = True,
346 WriteTriggerSpecificInfo = True)
347
348 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
349 acc.merge(CaloNoiseCondAlgCfg(flags))
350 acc.addEventAlgo(alg, primary=True)
351 monitor = CompFactory.TrigCaloClusterMonitor(name + 'Monitoring' + suffix,
352 CellsName = cells,
353 ClustersName = clustersKey,
354 MonitorCells = doMonCells,
355 MonitoringTool = trigCaloClusterMonitoringTool(flags, doMonCells))
356 acc.addEventAlgo(monitor, primary=False)
357 return acc
358
359
360
361def hltCaloTopoClusterCalibratorCfg(flags, name, clustersin, clustersout, **kwargs):
362 """ Create the LC calibrator """
363 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
364
365 # We need the electronic noise for the LC weights
366 acc = ComponentAccumulator()
367 acc.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
368
369 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
370 acc.merge(caloTopoCoolFolderCfg(flags))
371
372 calibrator = CompFactory.TrigCaloClusterCalibrator(
373 name, InputClusters=clustersin, OutputClusters=clustersout,
374 **kwargs
375 #OutputCellLinks = clustersout+"_cellLinks", **kwargs
376 )
377
378 calibrator.ClusterCorrectionTools = [ hltCaloLocalCalib(flags), hltCaloOOCalib(flags),
379 hltCaloOOCPi0Calib(flags), hltCaloDMCalib(flags) ]
380 #NB: Could we take these from CaloRec.CaloTopoClusterConfig.getTopoClusterLocalCalibTools?
381
382 # Monitoring
383 monTool = GenericMonitoringTool(flags, "MonTool")
384 monTool.defineHistogram('Et', path='EXPERT', type='TH1F',
385 title="Cluster E_T; E_T [ MeV ] ; Number of Clusters",
386 xbins=135, xmin=-200.0, xmax=2500.0)
387 monTool.defineHistogram('Eta', path='EXPERT', type='TH1F',
388 title="Cluster #eta; #eta ; Number of Clusters",
389 xbins=100, xmin=-2.5, xmax=2.5)
390 monTool.defineHistogram('Phi', path='EXPERT', type='TH1F',
391 title="Cluster #phi; #phi ; Number of Clusters",
392 xbins=64, xmin=-3.2, xmax=3.2)
393 monTool.defineHistogram('Eta,Phi', path='EXPERT', type='TH2F',
394 title="Number of Clusters; #eta ; #phi ; Number of Clusters",
395 xbins=100, xmin=-2.5, xmax=2.5, ybins=128, ymin=-3.2, ymax=3.2)
396 calibrator.MonTool = monTool
397
398 acc.addEventAlgo(calibrator, primary=True)
399 return acc
400
401##################### Unifying all cluster reco algs together ##################
402from TriggerMenuMT.HLT.Egamma.TrigEgammaKeys import getTrigEgammaKeys
403
404
405def hltCaloTopoClusteringCfg(
406 flags, namePrefix=None,nameSuffix=None, CellsName=None, monitorCells=False, roisKey="UNSPECIFIED",clustersKey=None, doLCFS=False, doTau = False):
407 if doTau:
408 CellsName = "CaloCellsLC"
409 clustersKeyFromName = "HLT_TopoCaloClustersLC"
410 elif nameSuffix == "FS":
411 clustersKeyFromName = em_clusters
412 else:
413 TrigEgammaKeys = getTrigEgammaKeys(flags)
414 clustersKeyFromName = TrigEgammaKeys.precisionTopoClusterContainer
415
416 clusters = clustersKeyFromName if clustersKey is None else clustersKey
417 acc = ComponentAccumulator()
418 acc.merge(
419 hltCaloCellMakerCfg(flags, namePrefix + "HLTCaloCellMaker"+nameSuffix, roisKey=roisKey, CellsName=CellsName, monitorCells=monitorCells, doTau = doTau)
420 )
421
422 clustermakername_nosuffix = namePrefix + "HLTCaloClusterMaker"
423
424 clustermakername = clustermakername_nosuffix + nameSuffix
425
426 # TODO - Don't use hasFlag here, use another concrete flag instead
427 if flags.hasFlag("CaloRecGPU.GlobalFlags.UseCaloRecGPU") and flags.CaloRecGPU.GlobalFlags.UseCaloRecGPU and "FS" in clustermakername:
428 flags = flags.cloneAndReplace("CaloRecGPU.ActiveConfig", "Trigger.CaloRecGPU.Default", True)
429 from CaloRecGPU.CaloRecGPUConfig import GPUCaloTopoClusterCfg
430
431
432 GPUKernelSvc = CompFactory.GPUKernelSizeOptimizerSvc()
433 acc.addService(GPUKernelSvc)
434
435 gpuhyb = GPUCaloTopoClusterCfg(flags,
436 True,
437 CellsName,
438 clustersname = clusters if "CaloMon" in clustermakername else recordable(clusters),
439 name = clustermakername,
440 ReallyUseGPUTools = not flags.CaloRecGPU.GlobalFlags.UseCPUToolsInstead)
441
442 acc.merge(gpuhyb)
443
444 monitorCells = "FS" in clustermakername
445
446 monitor = CompFactory.TrigCaloClusterMonitor(clustermakername_nosuffix + 'Monitoring' + nameSuffix,
447 CellsName = CellsName,
448 ClustersName = clusters,
449 MonitorCells = monitorCells,
450 MonitoringTool = trigCaloClusterMonitoringTool(flags, monitorCells))
451 acc.addEventAlgo(monitor, primary=False)
452
453 else :
454 calt=hltTopoClusterMakerCfg(flags, clustermakername_nosuffix, cellsKey=CellsName, clustersKey=clusters, doLC=doTau, suffix = nameSuffix)
455 acc.merge(calt)
456 if doLCFS:
457 acc.merge( hltCaloTopoClusterCalibratorCfg(
458 flags,
459 "HLTCaloClusterCalibratorLCFS",
460 clustersin=em_clusters,
461 clustersout=lc_clusters,
462 OutputCellLinks=lc_clusters + "_cellLinks",
463 )
464 )
465 return acc
466
467###################################EgammaSpecific TopoClustering####################################
468@AccumulatorCache
469def egammaTopoClusteringCfg(flags, RoIs):
470 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="RoI", CellsName="CaloCells", monitorCells=True, roisKey=RoIs)
471 return cfg
472
473
474@AccumulatorCache
475def egammaTopoClusteringCfg_LRT(flags, RoIs):
476 TrigEgammaKeys_LRT = getTrigEgammaKeys(flags, name = '_LRT')
477 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="RoI_LRT", CellsName="CaloCells", monitorCells=True, roisKey=RoIs, clustersKey= TrigEgammaKeys_LRT.precisionTopoClusterContainer)
478 return cfg
479
480
481###################################JetMetSpecific TopoClustering####################################
482@AccumulatorCache
483def jetmetTopoClusteringCfg(flags, RoIs):
484 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="FS", CellsName="CaloCellsFS", monitorCells=False, roisKey=RoIs)
485 return cfg
486
487@AccumulatorCache
488def jetmetTopoClusteringCfg_LC(flags, RoIs):
489 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="FS", CellsName="CaloCellsFS", monitorCells=False, roisKey=RoIs, doLCFS=True)
490 return cfg
491
492###################################TauSpecific TopoClustering####################################
493@AccumulatorCache
494def tauTopoClusteringCfg(flags, RoIs):
495 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="Tau", nameSuffix="", CellsName="CaloCellsLC", monitorCells=False, roisKey=RoIs, clustersKey="HLT_TopoCaloClustersLC", doTau= True)
496 return cfg
497
498@AccumulatorCache
499def hltCaloTopoClusteringHICfg(
500 flags, CellsName=None, roisKey="UNSPECIFIED", doLC=False,algSuffix='HIRoI', ion=True):
501 TrigEgammaKeys = getTrigEgammaKeys(flags, ion=ion)
502 eventShape = TrigEgammaKeys.egEventShape
503 clustersKey = TrigEgammaKeys.precisionTopoClusterContainer
504 acc = ComponentAccumulator()
505 acc.merge(hltCaloCellMakerCfg(flags, "HLTCaloCellMaker"+algSuffix, roisKey=roisKey, CellsName=CellsName, monitorCells=True))
506 acc.merge(hltCaloCellCorrectorCfg(flags,name='HLTRoICaloCellCorrector', inputEDM='CaloCells', outputEDM='CorrectedRoICaloCells', eventShape=eventShape))
507 acc.merge(hltTopoClusterMakerCfg(flags, "TrigCaloClusterMaker_topo"+algSuffix, clustersKey=clustersKey,cellsKey="CorrectedRoICaloCells"))
508 return acc
509
510@AccumulatorCache
511def hltHICaloTowerMakerCfg(flags, name, towersKey, cellsKey="CaloCellsFS", RoIs=""):
512 acc = ComponentAccumulator()
513 larcmbtwrbldr = CompFactory.LArTowerBuilderTool("LArCmbTwrBldr",
514 CellContainerName = cellsKey,
515 IncludedCalos = [ "LAREM", "LARHEC" ]
516 )
517
518 fcalcmbtwrbldr = CompFactory.LArFCalTowerBuilderTool("FCalCmbTwrBldr",
519 CellContainerName = cellsKey,
520 MinimumEt = 0.*MeV
521 )
522
523 #input to TileTowerBuilder: cells in TILE
524 tilecmbtwrbldr = CompFactory.TileTowerBuilderTool("TileCmbTwrBldr",
525 CellContainerName = cellsKey,
526 # debugging aid, keep for convenience
527 #DumpTowers = False,
528 #DumpWeightMap = False
529 )
530
531
532
533 alg = CompFactory.TrigCaloTowerMaker(name,
534 Cells=cellsKey,
535 CaloTowers=towersKey,
536 NumberOfPhiTowers=64,
537 NumberOfEtaTowers=100,
538 EtaMin=-5.0,
539 EtaMax=5.0,
540 DeltaEta=1.2,
541 DeltaPhi=1.2,
542 RoIs=RoIs,
543 TowerMakerTools = [ tilecmbtwrbldr, larcmbtwrbldr, fcalcmbtwrbldr ]
544 )
545 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
546 acc.merge(CaloNoiseCondAlgCfg(flags))
547 acc.addEventAlgo(alg, primary=True)
548 return acc
549
550@AccumulatorCache
551def hltHICaloClusterMakerCfg(flags, name, towersKey, cellsKey, clustersKey) :
552 """Function to equip HLT HI cluster builder from towers and cells, adds to output AOD stream"""
553 acc = ComponentAccumulator()
554
555
556 alg=CompFactory.HIClusterMaker(name,
557 InputTowerKey=towersKey,
558 CaloCellContainerKey=cellsKey,
559 OutputContainerKey=clustersKey
560 )
561 acc.addEventAlgo(alg, primary=True)
562 return acc
563
564@AccumulatorCache
565def HICaloTowerCfg(flags):
566 """ Create the towers for heavy ion """
567 acc = ComponentAccumulator()
568 acc.merge(
569 hltCaloCellMakerCfg(flags, "HLTCaloCellMakerFS", roisKey='')
570 )
571 # Then build the towers
572 acc.merge(
573 hltHICaloTowerMakerCfg(
574 flags,
575 "HLTHICaloTowerMakerFS",
576 towersKey=fs_towers,
577 cellsKey=fs_cells,
578 )
579 )
580 # Then build the clusters
581 acc.merge(
582 hltHICaloClusterMakerCfg(
583 flags,
584 "HLTHICaloClusterMakerFS",
585 towersKey=fs_towers,
586 cellsKey=fs_cells,
587 clustersKey = "HLT_HICaloClustersFS"
588 )
589 )
590
591 return acc
592
593
594if __name__ == "__main__":
595 from AthenaConfiguration.TestDefaults import defaultTestFiles, defaultGeometryTags
596 from AthenaConfiguration.AllConfigFlags import initConfigFlags
597
598 flags = initConfigFlags()
599 flags.Input.Files = defaultTestFiles.RAW_RUN3
600 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
601 flags.IOVDb.GlobalTag = "CONDBR2-ES1PA-2022-07"
602 flags.Common.isOnline = True
603 outputContainers = ["CaloCellContainer#SeedLessFS",
604 "xAOD::EventInfo#EventInfo",
605 "xAOD::TrigEMClusterContainer#CaloClustersGlobal",
606 "xAOD::TrigEMClusterAuxContainer#CaloClustersGlobalAux.",
607 "xAOD::TrigRingerRingsContainer#RingerGlobal",
608 "xAOD::TrigRingerRingsAuxContainer#RingerGlobalAux."]
609 flags.Output.ESDFileName='TrigCaloRecCheck'
610
611 flags.fillFromArgs()
612 flags.dump()
613 flags.lock()
614 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
615 cfg = MainServicesCfg(flags)
616
617 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
618 cfg.merge(LArGMCfg(flags))
619 from TileGeoModel.TileGMConfig import TileGMCfg
620 cfg.merge(TileGMCfg(flags))
621
622 from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg
623 cfg.merge(DetDescrCnvSvcCfg(flags))
624
625 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
626 cfg.merge(ByteStreamReadCfg(flags))
627 cfg.getService("ByteStreamCnvSvc").ROD2ROBmap=["-1"]
628
629 storeGateSvc = cfg.getService("StoreGateSvc")
630 storeGateSvc.Dump=True
631 theL0CaloGlobalRoIBuilderCfg = L0CaloGlobalRoIBuilderCfg(flags)
632 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
633
634 from AthenaCommon.CFElements import parOR
635 cfg.addSequence(parOR("HLTBeginSeq"),parentName="AthMasterSeq")
636
637 CAs = [hltCaloCellSeedlessMakerCfg(flags,roisKey=''),
638 theL0CaloGlobalRoIBuilderCfg,
639 hltCaloCellMakerCfg(flags, "SthFS",roisKey=''),
640 hltCaloGlobalCellMakerCfg(flags,InputCellKey="SeedLessFS",OutputCellKey="SeedLessFSGlobal"),
641 hltCaloGlobalCellMonitorCfg(flags,InputCellKey="SeedLessFSGlobal"),
642 hltCaloGlobalCellMonitorCfg(flags,name="HLTCaloGlobalCellMonitor1",InputCellKey="SeedLessFS"),
643 OutputStreamCfg(flags,flags.Output.ESDFileName,ItemList=outputContainers)]
644 #hltTopoClusterMakerCfg(flags, "TrigCaloClusterMaker_topoFS")]
645
646 for ca in CAs:
647 ca.printConfig(withDetails=True, summariseProps=True)
648 #ca.wasMerged()
649 cfg.merge(ca)
650 cfg.run(50)
trigCaloClusterMonitoringTool(flags, doMonCells=False, isFullScan=None)