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
11from TrigEDMConfig.TriggerEDM
import recordable
13mlog = logging.getLogger (
'TrigCaloRecConfig')
17 """Monitoring tool for TrigCaloClusterMaker"""
19 monTool = GenericMonitoringTool(flags, 'MonTool')
21 if isFullScan is None:
22 isFullScan = doMonCells
24 maxNumberOfClusters = 1200 if isFullScan else 50
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)
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)
50def hltCaloGlobalCellMakerCfg(flags, name="HLTCaloGlobalCellMaker", **kwargs):
51 acc = ComponentAccumulator()
53 kwargs.setdefault("InputCellKey", "Calo")
54 kwargs.setdefault("OutputCellKey", "OutCalo")
55 kwargs.setdefault("MaxNCellsPerFEB", 30)
57 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
58 acc.merge(CaloNoiseCondAlgCfg(flags))
60 acc.addEventAlgo(CompFactory.HLTCaloGlobalCellMaker(name, **kwargs))
63def hltCaloGlobalCellMonitorCfg(flags, name="HLTCaloGlobalCellMonitor", **kwargs):
64 acc = ComponentAccumulator()
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)
88 kwargs.setdefault("MaxNCellsPerFEB", 128 )
89 kwargs.setdefault("NumberOfSigma", 2)
90 acc.addEventAlgo(CompFactory.HLTCaloGlobalCellMonitor(name, **kwargs))
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
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)
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)
120 if sequenceName is not None:
121 from AthenaCommon.CFElements import parOR
122 acc.merge(ComponentAccumulator(parOR(sequenceName)))
123 cellMaker = CompFactory.HLTCaloCellMaker(name,
125 TrigDataAccessMT = acc.getService('TrigCaloDataAccessSvc'),
126 ExtraInputs = CaloDataAccessSvcDependencies,
128 monitorCells = monitorCells,
130 TileCellsInROI = False if not doTau else True)
131 acc.addEventAlgo(cellMaker, primary=True,sequenceName=sequenceName)
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)
146def hltCaloCellSeedlessMakerCfg(flags, roisKey='UNSPECIFIED',sequenceName=None):
147 acc = ComponentAccumulator()
148 hltCaloCellMakerAcc = hltCaloCellMakerCfg(flags, "CaloCellSeedLessFS",
150 CellsName ="SeedLessFS",
153 acc.merge(hltCaloCellMakerAcc,sequenceName=sequenceName)
155 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
156 acc.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
157 acc.addCondAlgo(CompFactory.CaloNoiseSigmaDiffCondAlg())
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,
183 accSeq.addEventAlgo(L0CaloGlobalRoIBuilderAlg, sequenceName="HLTBeginSeq")
185 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
186 acc.merge(CaloNoiseCondAlgCfg(flags))
191def CaloL0RingerPreCfg(flags,DoNoiseThrRings=True):
192 flags.Trigger.ExtraEDMList+= CaloL0RingerPrepareList(DoNoiseThrRings)
194def CaloL0RingerPrepareList(DoNoiseThrRings=True):
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')]
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')]
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 sequencerName = "L1GlobalSimSeq" if flags.Trigger.L1.doGlobal else "HLTBeginSeq"
209 accSeq = ComponentAccumulator(parOR(sequencerName))
210 accSeq.merge(hltCaloCellSeedlessMakerCfg(flags, roisKey=''), sequenceName=sequencerName)
211 accSeq.merge(L0CaloGlobalRoIBuilderCfg(flags,DoNoiseThrRings=DoNoiseThrRings))
214 if (flags.Output.doWriteESD or flags.Output.doWriteAOD):
215 if ( flags.Output.doWriteESD ):
216 acc.merge(addToESD(flags, extraContent))
217 if ( flags.Output.doWriteAOD ):
218 acc.merge(addToAOD(flags, extraContent))
223def hltCaloLocalCalib(flags, name = "TrigLocalCalib"):
224 det_version_is_rome = flags.GeoModel.AtlasVersion.startswith("Rome")
225 localCalibTool = CompFactory.CaloLCWeightTool("TrigLCWeight",
226 CorrectionKey="H1ClusterCellWeights",
227 SignalOverNoiseCut=2.0, UseHadProbability=True)
228 trigLCClassify = CompFactory.CaloLCClassificationTool("TrigLCClassify",
229 ClassificationKey="EMFracClassify",
230 UseSpread=False, MaxProbability=0.85 if det_version_is_rome else 0.5,
231 UseNormalizedEnergyDensity=not det_version_is_rome,
232 StoreClassificationProbabilityInAOD=True)
233 tool = CompFactory.CaloClusterLocalCalib( name,
234 ClusterRecoStatus=[1, 2], ClusterClassificationTool=[ trigLCClassify ],
235 LocalCalibTools=[ localCalibTool ])
239def hltCaloOOCalib(flags, name = "TrigOOCCalib"):
240 localCalibTool = CompFactory.CaloLCOutOfClusterTool("TrigLCOut",
241 CorrectionKey="OOCCorrection",UseEmProbability=False,
242 UseHadProbability=True)
243 tool = CompFactory.CaloClusterLocalCalib( name,
244 ClusterRecoStatus=[1, 2],
245 LocalCalibTools=[ localCalibTool ] )
248def hltCaloOOCPi0Calib(flags, name = "TrigOOCPi0Calib" ):
249 localCalibTool = CompFactory.CaloLCOutOfClusterTool("TrigLCOutPi0",
250 CorrectionKey="OOCPi0Correction", UseEmProbability=True,
251 UseHadProbability=False)
252 tool = CompFactory.CaloClusterLocalCalib( name,
253 ClusterRecoStatus=[1, 2],
254 LocalCalibTools=[ localCalibTool ] )
257def hltCaloDMCalib(flags, name = "TrigDMCalib" ):
258 localCalibTool = CompFactory.CaloLCDeadMaterialTool("TrigLCDeadMaterial",
259 HadDMCoeffKey="HadDMCoeff2", ClusterRecoStatus=0,
260 WeightModeDM=2,UseHadProbability=True)
261 tool = CompFactory.CaloClusterLocalCalib( name,
262 ClusterRecoStatus=[1, 2],
263 LocalCalibTools=[ localCalibTool ] )
269def hltTopoClusterMakerCfg(flags, name, clustersKey="HLT_TopoCaloClustersFS", cellsKey=None, doLC=False, suffix=''):
270 acc = ComponentAccumulator()
271 cellsFromName = 'CaloCellsFS' if "FS" in clustersKey else "CaloCells"
272 cells = cellsFromName if cellsKey is None else cellsKey
274 from CaloRec.CaloTopoClusterConfig import (
275 CaloTopoClusterToolCfg,
276 CaloTopoClusterSplitterToolCfg,
279 topoMaker = acc.popToolsAndMerge(CaloTopoClusterToolCfg(flags, cellsname=cells))
280 topoMaker.RestrictPSNeighbors = False
281 listClusterCorrectionTools = []
283 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
284 # We need the electronic noise for the LC weights
285 acc.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
286 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
287 acc.merge(caloTopoCoolFolderCfg(flags))
288 listClusterCorrectionTools = [ hltCaloLocalCalib(flags), hltCaloOOCalib(flags),
289 hltCaloOOCPi0Calib(flags), hltCaloDMCalib(flags) ]
292 topoMaker.SeedCutsInT = flags.Trigger.Calo.TopoCluster.doTimeCut
293 topoMaker.CutOOTseed = flags.Trigger.Calo.TopoCluster.extendTimeCut and flags.Trigger.Calo.TopoCluster.doTimeCut
294 topoMaker.UseTimeCutUpperLimit = flags.Trigger.Calo.TopoCluster.useUpperLimitForTimeCut
295 topoMaker.TimeCutUpperLimit = flags.Trigger.Calo.TopoCluster.timeCutUpperLimit
297 topoSplitter = acc.popToolsAndMerge(CaloTopoClusterSplitterToolCfg(flags))
299 topoMoments = CompFactory.CaloClusterMomentsMaker ('TrigTopoMoments')
300 topoMoments.MaxAxisAngle = 20*deg
301 topoMoments.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
302 topoMoments.MinBadLArQuality = 4000
303 topoMoments.MomentsNames = ['FIRST_PHI',
337 clustermakername = name + suffix
338 doMonCells = "FS" in clustermakername
340 clustersKey_final = clustersKey
341 if flags.Trigger.Calo.TopoCluster.applyClusterTimingCut:
342 clustersKey = f"{clustersKey}BeforeTimingCut"
344 alg = CompFactory.CaloClusterMaker(
346 ClustersOutputName=clustersKey if "CaloMon" in clustermakername else recordable(clustersKey),
347 ClusterCellLinkOutputName = clustersKey+"_links",
348 ClusterMakerTools = [ topoMaker, topoSplitter, topoMoments],
349 ClusterCorrectionTools = listClusterCorrectionTools,
350 SaveUncalibratedSignalState = True,
351 WriteTriggerSpecificInfo = True)
353 if flags.Trigger.Calo.TopoCluster.applyClusterTimingCut:
354 from CaloRec.CaloTopoClusterConfig import CaloClusterTimingFilterCfg
355 acc.merge(CaloClusterTimingFilterCfg(flags, name = f"{clustersKey}Filter", InputClusters = clustersKey, OutputClusters = clustersKey_final))
357 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
358 acc.merge(CaloNoiseCondAlgCfg(flags))
359 acc.addEventAlgo(alg, primary=True)
360 monitor = CompFactory.TrigCaloClusterMonitor(name + 'Monitoring' + suffix,
362 ClustersName = clustersKey_final,
363 MonitorCells = doMonCells,
364 MonitoringTool = trigCaloClusterMonitoringTool(flags, doMonCells))
365 acc.addEventAlgo(monitor, primary=False)
370def hltCaloTopoClusterCalibratorCfg(flags, name, clustersin, clustersout, **kwargs):
371 """ Create the LC calibrator """
372 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
374 # We need the electronic noise for the LC weights
375 acc = ComponentAccumulator()
376 acc.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
378 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
379 acc.merge(caloTopoCoolFolderCfg(flags))
381 calibrator = CompFactory.TrigCaloClusterCalibrator(
382 name, InputClusters=clustersin, OutputClusters=clustersout,
384 #OutputCellLinks = clustersout+"_cellLinks", **kwargs
387 calibrator.ClusterCorrectionTools = [ hltCaloLocalCalib(flags), hltCaloOOCalib(flags),
388 hltCaloOOCPi0Calib(flags), hltCaloDMCalib(flags) ]
389 #NB: Could we take these from CaloRec.CaloTopoClusterConfig.getTopoClusterLocalCalibTools?
392 monTool = GenericMonitoringTool(flags, "MonTool")
393 monTool.defineHistogram('Et', path='EXPERT', type='TH1F',
394 title="Cluster E_T; E_T [ MeV ] ; Number of Clusters",
395 xbins=135, xmin=-200.0, xmax=2500.0)
396 monTool.defineHistogram('Eta', path='EXPERT', type='TH1F',
397 title="Cluster #eta; #eta ; Number of Clusters",
398 xbins=100, xmin=-2.5, xmax=2.5)
399 monTool.defineHistogram('Phi', path='EXPERT', type='TH1F',
400 title="Cluster #phi; #phi ; Number of Clusters",
401 xbins=64, xmin=-3.2, xmax=3.2)
402 monTool.defineHistogram('Eta,Phi', path='EXPERT', type='TH2F',
403 title="Number of Clusters; #eta ; #phi ; Number of Clusters",
404 xbins=100, xmin=-2.5, xmax=2.5, ybins=128, ymin=-3.2, ymax=3.2)
405 calibrator.MonTool = monTool
407 acc.addEventAlgo(calibrator, primary=True)
410##################### Unifying all cluster reco algs together ##################
411from TriggerMenuMT.HLT.Egamma.TrigEgammaKeys import getTrigEgammaKeys
414def hltCaloTopoClusteringCfg(
415 flags, namePrefix=None,nameSuffix=None, CellsName=None, monitorCells=False, roisKey="UNSPECIFIED",clustersKey=None, doLCFS=False, doTau = False):
417 CellsName = "CaloCellsLC"
418 clustersKeyFromName = "HLT_TopoCaloClustersLC"
419 elif nameSuffix == "FS":
420 clustersKeyFromName = em_clusters
422 TrigEgammaKeys = getTrigEgammaKeys(flags)
423 clustersKeyFromName = TrigEgammaKeys.precisionTopoClusterContainer
425 clusters = clustersKeyFromName if clustersKey is None else clustersKey
426 acc = ComponentAccumulator()
428 hltCaloCellMakerCfg(flags, namePrefix + "HLTCaloCellMaker"+nameSuffix, roisKey=roisKey, CellsName=CellsName, monitorCells=monitorCells, doTau = doTau)
431 clustermakername_nosuffix = namePrefix + "HLTCaloClusterMaker"
433 clustermakername = clustermakername_nosuffix + nameSuffix
435 # TODO - Don't use hasFlag here, use another concrete flag instead
436 if flags.hasFlag("CaloRecGPU.GlobalFlags.UseCaloRecGPU") and flags.CaloRecGPU.GlobalFlags.UseCaloRecGPU and "FS" in clustermakername:
437 flags = flags.cloneAndReplace("CaloRecGPU.ActiveConfig", "Trigger.CaloRecGPU.Default", True)
438 from CaloRecGPU.CaloRecGPUConfig import GPUCaloTopoClusterCfg
441 GPUKernelSvc = CompFactory.GPUKernelSizeOptimizerSvc()
442 acc.addService(GPUKernelSvc)
444 gpuhyb = GPUCaloTopoClusterCfg(flags,
447 clustersname = clusters if "CaloMon" in clustermakername else recordable(clusters),
448 name = clustermakername,
449 ReallyUseGPUTools = not flags.CaloRecGPU.GlobalFlags.UseCPUToolsInstead)
453 monitorCells = "FS" in clustermakername
455 monitor = CompFactory.TrigCaloClusterMonitor(clustermakername_nosuffix + 'Monitoring' + nameSuffix,
456 CellsName = CellsName,
457 ClustersName = clusters,
458 MonitorCells = monitorCells,
459 MonitoringTool = trigCaloClusterMonitoringTool(flags, monitorCells))
460 acc.addEventAlgo(monitor, primary=False)
463 calt=hltTopoClusterMakerCfg(flags, clustermakername_nosuffix, cellsKey=CellsName, clustersKey=clusters, doLC=doTau, suffix = nameSuffix)
466 acc.merge( hltCaloTopoClusterCalibratorCfg(
468 "HLTCaloClusterCalibratorLCFS",
469 clustersin=em_clusters,
470 clustersout=lc_clusters,
471 OutputCellLinks=lc_clusters + "_cellLinks",
476###################################EgammaSpecific TopoClustering####################################
478def egammaTopoClusteringCfg(flags, RoIs):
479 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="RoI", CellsName="CaloCells", monitorCells=True, roisKey=RoIs)
484def egammaTopoClusteringCfg_LRT(flags, RoIs):
485 TrigEgammaKeys_LRT = getTrigEgammaKeys(flags, name = '_LRT')
486 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="RoI_LRT", CellsName="CaloCells", monitorCells=True, roisKey=RoIs, clustersKey= TrigEgammaKeys_LRT.precisionTopoClusterContainer)
490###################################JetMetSpecific TopoClustering####################################
492def jetmetTopoClusteringCfg(flags, RoIs):
493 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="FS", CellsName="CaloCellsFS", monitorCells=False, roisKey=RoIs)
497def jetmetTopoClusteringCfg_LC(flags, RoIs):
498 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="", nameSuffix="FS", CellsName="CaloCellsFS", monitorCells=False, roisKey=RoIs, doLCFS=True)
501###################################TauSpecific TopoClustering####################################
503def tauTopoClusteringCfg(flags, RoIs):
504 cfg = hltCaloTopoClusteringCfg(flags, namePrefix="Tau", nameSuffix="", CellsName="CaloCellsLC", monitorCells=False, roisKey=RoIs, clustersKey="HLT_TopoCaloClustersLC", doTau= True)
508def hltCaloTopoClusteringHICfg(
509 flags, CellsName=None, roisKey="UNSPECIFIED", doLC=False,algSuffix='HIRoI', ion=True):
510 TrigEgammaKeys = getTrigEgammaKeys(flags, ion=ion)
511 eventShape = TrigEgammaKeys.egEventShape
512 clustersKey = TrigEgammaKeys.precisionTopoClusterContainer
513 acc = ComponentAccumulator()
514 acc.merge(hltCaloCellMakerCfg(flags, "HLTCaloCellMaker"+algSuffix, roisKey=roisKey, CellsName=CellsName, monitorCells=True))
515 acc.merge(hltCaloCellCorrectorCfg(flags,name='HLTRoICaloCellCorrector', inputEDM='CaloCells', outputEDM='CorrectedRoICaloCells', eventShape=eventShape))
516 acc.merge(hltTopoClusterMakerCfg(flags, "TrigCaloClusterMaker_topo"+algSuffix, clustersKey=clustersKey,cellsKey="CorrectedRoICaloCells"))
520def hltHICaloTowerMakerCfg(flags, name, towersKey, cellsKey="CaloCellsFS", RoIs=""):
521 acc = ComponentAccumulator()
522 larcmbtwrbldr = CompFactory.LArTowerBuilderTool("LArCmbTwrBldr",
523 CellContainerName = cellsKey,
524 IncludedCalos = [ "LAREM", "LARHEC" ]
527 fcalcmbtwrbldr = CompFactory.LArFCalTowerBuilderTool("FCalCmbTwrBldr",
528 CellContainerName = cellsKey,
532 #input to TileTowerBuilder: cells in TILE
533 tilecmbtwrbldr = CompFactory.TileTowerBuilderTool("TileCmbTwrBldr",
534 CellContainerName = cellsKey,
535 # debugging aid, keep for convenience
537 #DumpWeightMap = False
542 alg = CompFactory.TrigCaloTowerMaker(name,
544 CaloTowers=towersKey,
545 NumberOfPhiTowers=64,
546 NumberOfEtaTowers=100,
552 TowerMakerTools = [ tilecmbtwrbldr, larcmbtwrbldr, fcalcmbtwrbldr ]
554 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
555 acc.merge(CaloNoiseCondAlgCfg(flags))
556 acc.addEventAlgo(alg, primary=True)
560def hltHICaloClusterMakerCfg(flags, name, towersKey, cellsKey, clustersKey) :
561 """Function to equip HLT HI cluster builder from towers and cells, adds to output AOD stream"""
562 acc = ComponentAccumulator()
565 alg=CompFactory.HIClusterMaker(name,
566 InputTowerKey=towersKey,
567 CaloCellContainerKey=cellsKey,
568 OutputContainerKey=clustersKey
570 acc.addEventAlgo(alg, primary=True)
574def HICaloTowerCfg(flags):
575 """ Create the towers for heavy ion """
576 acc = ComponentAccumulator()
578 hltCaloCellMakerCfg(flags, "HLTCaloCellMakerFS", roisKey='')
580 # Then build the towers
582 hltHICaloTowerMakerCfg(
584 "HLTHICaloTowerMakerFS",
589 # Then build the clusters
591 hltHICaloClusterMakerCfg(
593 "HLTHICaloClusterMakerFS",
596 clustersKey = "HLT_HICaloClustersFS"
603if __name__ == "__main__":
604 from AthenaConfiguration.TestDefaults import defaultTestFiles, defaultGeometryTags
605 from AthenaConfiguration.AllConfigFlags import initConfigFlags
607 flags = initConfigFlags()
608 flags.Input.Files = defaultTestFiles.RAW_RUN3
609 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
610 flags.IOVDb.GlobalTag = "CONDBR2-ES1PA-2022-07"
611 flags.Common.isOnline = True
612 outputContainers = ["CaloCellContainer#SeedLessFS",
613 "xAOD::EventInfo#EventInfo",
614 "xAOD::TrigEMClusterContainer#CaloClustersGlobal",
615 "xAOD::TrigEMClusterAuxContainer#CaloClustersGlobalAux.",
616 "xAOD::TrigRingerRingsContainer#RingerGlobal",
617 "xAOD::TrigRingerRingsAuxContainer#RingerGlobalAux."]
618 flags.Output.ESDFileName='TrigCaloRecCheck'
623 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
624 cfg = MainServicesCfg(flags)
626 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
627 cfg.merge(LArGMCfg(flags))
628 from TileGeoModel.TileGMConfig import TileGMCfg
629 cfg.merge(TileGMCfg(flags))
631 from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg
632 cfg.merge(DetDescrCnvSvcCfg(flags))
634 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
635 cfg.merge(ByteStreamReadCfg(flags))
636 cfg.getService("ByteStreamCnvSvc").ROD2ROBmap=["-1"]
638 storeGateSvc = cfg.getService("StoreGateSvc")
639 storeGateSvc.Dump=True
640 theL0CaloGlobalRoIBuilderCfg = L0CaloGlobalRoIBuilderCfg(flags)
641 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
643 from AthenaCommon.CFElements import parOR
644 cfg.addSequence(parOR("HLTBeginSeq"),parentName="AthMasterSeq")
646 CAs = [hltCaloCellSeedlessMakerCfg(flags,roisKey=''),
647 theL0CaloGlobalRoIBuilderCfg,
648 hltCaloCellMakerCfg(flags, "SthFS",roisKey=''),
649 hltCaloGlobalCellMakerCfg(flags,InputCellKey="SeedLessFS",OutputCellKey="SeedLessFSGlobal"),
650 hltCaloGlobalCellMonitorCfg(flags,InputCellKey="SeedLessFSGlobal"),
651 hltCaloGlobalCellMonitorCfg(flags,name="HLTCaloGlobalCellMonitor1",InputCellKey="SeedLessFS"),
652 OutputStreamCfg(flags,flags.Output.ESDFileName,ItemList=outputContainers)]
653 #hltTopoClusterMakerCfg(flags, "TrigCaloClusterMaker_topoFS")]
656 ca.printConfig(withDetails=True, summariseProps=True)
trigCaloClusterMonitoringTool(flags, doMonCells=False, isFullScan=None)