ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTopoClusterConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5from AthenaCommon.SystemOfUnits import MeV
6
7def CaloCalibClusterTruthMapMakerTool(flags, name="CaloCalibClusterTruthMapMakerTool", **kwargs):
8
9 TruthMapMakerTool = CompFactory.CaloCalibClusterTruthMapMakerTool
10 truthMapTool = TruthMapMakerTool()
11
12 return truthMapTool
13
14def CaloCalibHitDecoratorTool(flags, name="CaloCalibClusterDecoratorTool", **kwargs):
15
16 kwargs.setdefault(
17 "CaloClusterWriteDecorHandleKey_NLeadingTruthParticles",
18 "CaloCalTopoClusters." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible"
19 )
20
21
22 TruthAttributerTool = CompFactory.CaloCalibClusterTruthAttributerTool
23 truth_tool = TruthAttributerTool("CaloCalibClusterTruthAttributerTool")
24 DecoratorTool = CompFactory.CaloCalibClusterDecoratorTool
25 decoratorTool = DecoratorTool(name,TruthAttributerTool=truth_tool,**kwargs,ExtraInputs = {('CaloCellContainer','StoreGateSvc+AllCalo')})
26 return decoratorTool
27
28def CaloCalibHitDecoratorFullEnergyTool(flags, name="CaloCalibClusterDecoratorTool_Full", **kwargs):
29
30 kwargs.setdefault(
31 "CaloClusterWriteDecorHandleKey_NLeadingTruthParticles",
32 "CaloCalTopoClusters." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full"
33 )
34 TruthAttributerTool = CompFactory.CaloCalibClusterTruthAttributerTool
35 truth_tool = TruthAttributerTool("CaloCalibClusterTruthAttributerTool")
36 DecoratorTool = CompFactory.CaloCalibClusterDecoratorTool
37 decoratorTool = DecoratorTool(name, TruthAttributerTool=truth_tool, **kwargs,ExtraInputs = {('CaloCellContainer','StoreGateSvc+AllCalo')})
38
39 return decoratorTool
40
41
42def CaloCalibHitDecoratorToolOOC(flags, name="CaloCalibClusterDecoratorToolOOC", **kwargs):
43
44 kwargs.setdefault(
45 "CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesL",
46 "CaloCalTopoClusters." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L",
47 )
48 kwargs.setdefault(
49 "CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesT",
50 "CaloCalTopoClusters." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T",
51 )
52
53 DecoratorTool = CompFactory.CaloCalibClusterDecoratorToolOOC
54 decoratorTool = DecoratorTool(name,**kwargs,ExtraInputs = {('CaloCellContainer','StoreGateSvc+AllCalo')})
55 decoratorTool.CalibrationHitContainerNames = [
56 "LArCalibrationHitInactive",
57 "LArCalibrationHitActive",
58 "TileCalibHitActiveCell",
59 "TileCalibHitInactiveCell"
60 ]
61 return decoratorTool
62
63def CaloCalibHitDecoratorToolDM(flags, name="CaloCalibClusterDecoratorToolDM", **kwargs):
64
65 kwargs.setdefault(
66 "CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesDM",
67 "CaloCalTopoClusters." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM",
68 )
69
70 DecoratorTool = CompFactory.CaloCalibClusterDecoratorToolDM
71 decoratorTool = DecoratorTool(
72 name,
73 **kwargs,
74 ExtraInputs={('CaloCellContainer', 'StoreGateSvc+AllCalo')}
75 )
76
77 decoratorTool.CalibrationHitContainerNames = [
78 "LArCalibrationHitInactive",
79 "LArCalibrationHitActive",
80 "TileCalibHitActiveCell",
81 "TileCalibHitInactiveCell",
82 ]
83
84 decoratorTool.DMCalibrationHitContainerNames = [
85 "LArCalibrationHitDeadMaterial",
86 "TileCalibHitDeadMaterial",
87 ]
88
89 return decoratorTool
90
91
92
93
94
95
96
98 result=ComponentAccumulator()
99 from IOVDbSvc.IOVDbSvcConfig import addFolders
100 # rely on global tag for both MC and data; do not specify folder tags
101 # use CALO_OFL only for GEO>=18
102 hadCalibFolders = [
103 "HadCalibration2/CaloEMFrac",
104 "HadCalibration2/H1ClusterCellWeights",
105 "HadCalibration2/CaloOutOfCluster",
106 "HadCalibration2/CaloOutOfClusterPi0",
107 "HadCalibration2/CaloDMCorr2"
108 ]
109 hadCalibPrefix = "/CALO/"
110 hadCalibDB = "CALO_ONL"
111 if flags.Input.isMC:
112 hadCalibPrefix = "/CALO/Ofl/"
113 hadCalibDB = "CALO_OFL"
114 hadCalibFolders = [ hadCalibPrefix + foldername for foldername in hadCalibFolders ]
115 result.merge(addFolders(flags, hadCalibFolders, hadCalibDB, className="CaloLocalHadCoeff"))
116
117 return result
118
120 CaloLCClassificationTool, CaloLCWeightTool, CaloLCOutOfClusterTool, CaloLCDeadMaterialTool=CompFactory.getComps("CaloLCClassificationTool","CaloLCWeightTool","CaloLCOutOfClusterTool","CaloLCDeadMaterialTool",)
121 CaloClusterLocalCalib=CompFactory.CaloClusterLocalCalib
122 # Local cell weights
123 LCClassify = CaloLCClassificationTool("LCClassify")
124 LCClassify.ClassificationKey = "EMFracClassify"
125 LCClassify.UseSpread = False
126 LCClassify.MaxProbability = 0.5
127 # add the moments EM_PROBABILITY, HAD_WEIGHT, OOC_WEIGHT, DM_WEIGHT to the AOD:
128 LCClassify.StoreClassificationProbabilityInAOD = True
129 LCClassify.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
130
131 LCWeight = CaloLCWeightTool("LCWeight")
132 LCWeight.CorrectionKey = "H1ClusterCellWeights"
133 LCWeight.SignalOverNoiseCut = 2.0
134 # *****
135 LCWeight.UseHadProbability = True
136
137 LocalCalib = CaloClusterLocalCalib ("LocalCalib")
138 LocalCalib.ClusterClassificationTool = [LCClassify]
139 LocalCalib.ClusterRecoStatus = [1,2]
140 LocalCalib.LocalCalibTools = [LCWeight]
141 LocalCalib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
142
143 # Out-of-cluster corrections
144 LCOut = CaloLCOutOfClusterTool("LCOut")
145 LCOut.CorrectionKey = "OOCCorrection"
146 LCOut.UseEmProbability = False
147 LCOut.UseHadProbability = True
148
149 OOCCalib = CaloClusterLocalCalib ("OOCCalib")
150 OOCCalib.ClusterRecoStatus = [1,2]
151 OOCCalib.LocalCalibTools = [LCOut]
152 OOCCalib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
153
154 LCOutPi0 = CaloLCOutOfClusterTool("LCOutPi0")
155 LCOutPi0.CorrectionKey = "OOCPi0Correction"
156 LCOutPi0.UseEmProbability = True
157 LCOutPi0.UseHadProbability = False
158
159 OOCPi0Calib = CaloClusterLocalCalib ("OOCPi0Calib")
160 OOCPi0Calib.ClusterRecoStatus = [1,2]
161 OOCPi0Calib.LocalCalibTools = [LCOutPi0]
162
163 OOCPi0Calib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
164
165 # Dead material corrections
166 LCDeadMaterial = CaloLCDeadMaterialTool("LCDeadMaterial")
167 LCDeadMaterial.HadDMCoeffKey = "HadDMCoeff2"
168 LCDeadMaterial.ClusterRecoStatus = 0
169 LCDeadMaterial.WeightModeDM = 2
170 LCDeadMaterial.UseHadProbability = True
171 LCDeadMaterial.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
172
173 DMCalib = CaloClusterLocalCalib ("DMCalib")
174 DMCalib.ClusterRecoStatus = [1,2]
175 DMCalib.LocalCalibTools = [LCDeadMaterial]
176
177 DMCalib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
178
179 lccalibtools = [
180 LocalCalib,
181 OOCCalib,
182 OOCPi0Calib,
183 DMCalib]
184 return lccalibtools
185
186def getTopoMoments(flags):
187 result=ComponentAccumulator()
188 CaloClusterMomentsMaker=CompFactory.CaloClusterMomentsMaker
189 TopoMoments = CaloClusterMomentsMaker ("TopoMoments")
190 TopoMoments.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
191 from AthenaCommon.SystemOfUnits import deg
192 TopoMoments.MaxAxisAngle = 20*deg
193 TopoMoments.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
194 TopoMoments.MinBadLArQuality = 4000
195 TopoMoments.MomentsNames = ["FIRST_PHI"
196 ,"FIRST_ETA"
197 ,"SECOND_R"
198 ,"SECOND_LAMBDA"
199 ,"DELTA_PHI"
200 ,"DELTA_THETA"
201 ,"DELTA_ALPHA"
202 ,"CENTER_X"
203 ,"CENTER_Y"
204 ,"CENTER_Z"
205 ,"CENTER_MAG"
206 ,"CENTER_LAMBDA"
207 ,"LATERAL"
208 ,"LONGITUDINAL"
209 ,"FIRST_ENG_DENS"
210 ,"ENG_FRAC_EM"
211 ,"ENG_FRAC_MAX"
212 ,"ENG_FRAC_CORE"
213 ,"FIRST_ENG_DENS"
214 ,"SECOND_ENG_DENS"
215 ,"ISOLATION"
216 ,"ENG_BAD_CELLS"
217 ,"N_BAD_CELLS"
218 ,"N_BAD_CELLS_CORR"
219 ,"BAD_CELLS_CORR_E"
220 ,"BADLARQ_FRAC"
221 ,"ENG_POS"
222 ,"SIGNIFICANCE"
223 ,"CELL_SIGNIFICANCE"
224 ,"CELL_SIG_SAMPLING"
225 ,"AVG_LAR_Q"
226 ,"AVG_TILE_Q"
227 ,"PTD"
228 ,"MASS"
229 ,"SECOND_TIME"
230 ,"NCELL_SAMPLING"
231 ]
232
233
234 if not flags.Common.isOnline:
235 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
236 result.merge(LArElecCalibDBCfg(flags,["HVScaleCorr"]))
237 if flags.Input.isMC:
238 TopoMoments.LArHVFraction=CompFactory.LArHVFraction(HVScaleCorrKey="LArHVScaleCorr")
239 else:
240 TopoMoments.LArHVFraction=CompFactory.LArHVFraction(HVScaleCorrKey="LArHVScaleCorrRecomputed")
241 TopoMoments.MomentsNames += ["ENG_BAD_HV_CELLS"
242 ,"N_BAD_HV_CELLS"
243 ]
244
245 TopoMoments.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
246
247 result.setPrivateTools(TopoMoments)
248 return result
249
250# a.k.a. DigiTruth
252 CaloClusterMomentsMaker_DigiHSTruth=CompFactory.CaloClusterMomentsMaker_DigiHSTruth
253 TopoMoments_Truth = CaloClusterMomentsMaker_DigiHSTruth ("TopoMoments_Truth")
254 TopoMoments_Truth.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
255 from AthenaCommon.SystemOfUnits import deg
256 TopoMoments_Truth.MaxAxisAngle = 20*deg
257 TopoMoments_Truth.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
258 TopoMoments_Truth.MinBadLArQuality = 4000
259 TopoMoments_Truth.MomentsNames = ["FIRST_PHI_DigiHSTruth"
260 ,"FIRST_ETA_DigiHSTruth"
261 ,"SECOND_R_DigiHSTruth"
262 ,"SECOND_LAMBDA_DigiHSTruth"
263 ,"DELTA_PHI_DigiHSTruth"
264 ,"DELTA_THETA_DigiHSTruth"
265 ,"DELTA_ALPHA_DigiHSTruth"
266 ,"CENTER_X_DigiHSTruth"
267 ,"CENTER_Y_DigiHSTruth"
268 ,"CENTER_Z_DigiHSTruth"
269 ,"CENTER_MAG_DigiHSTruth"
270 ,"CENTER_LAMBDA_DigiHSTruth"
271 ,"LATERAL_DigiHSTruth"
272 ,"LONGITUDINAL_DigiHSTruth"
273 ,"ENG_FRAC_CORE_DigiHSTruth"
274 ,"FIRST_ENG_DENS_DigiHSTruth"
275 ,"SECOND_ENG_DENS_DigiHSTruth"
276 ,"ISOLATION_DigiHSTruth"
277 ,"BAD_CELLS_CORR_E_DigiHSTruth"
278 ,"ENG_POS_DigiHSTruth"
279 ,"SIGNIFICANCE_DigiHSTruth"
280 ,"CELL_SIGNIFICANCE_DigiHSTruth"
281 ,"CELL_SIG_SAMPLING_DigiHSTruth"
282 ,"AVG_LAR_Q_DigiHSTruth"
283 ,"AVG_TILE_Q_DigiHSTruth"
284 ,"ENERGY_DigiHSTruth"
285 ,"PHI_DigiHSTruth"
286 ,"ETA_DigiHSTruth"
287 ]
288 return TopoMoments_Truth
289
291 CaloCalibClusterMomentsMaker2=CompFactory.CaloCalibClusterMomentsMaker2
292 TopoCalibMoments = CaloCalibClusterMomentsMaker2 ("TopoCalibMoments")
293 TopoCalibMoments.MomentsNames = ["ENG_CALIB_TOT"
294 ,"ENG_CALIB_OUT_L"
295 ,"ENG_CALIB_OUT_T"
296 ,"ENG_CALIB_EMB0"
297 ,"ENG_CALIB_EME0"
298 ,"ENG_CALIB_TILEG3"
299 ,"ENG_CALIB_DEAD_TOT"
300 ,"ENG_CALIB_DEAD_EMB0"
301 ,"ENG_CALIB_DEAD_TILE0"
302 ,"ENG_CALIB_DEAD_TILEG3"
303 ,"ENG_CALIB_DEAD_EME0"
304 ,"ENG_CALIB_DEAD_HEC0"
305 ,"ENG_CALIB_DEAD_FCAL"
306 ,"ENG_CALIB_DEAD_LEAKAGE"
307 ,"ENG_CALIB_DEAD_UNCLASS"
308 ,"ENG_CALIB_FRAC_EM"
309 ,"ENG_CALIB_FRAC_HAD"
310 ,"ENG_CALIB_FRAC_REST"]
311
312 TopoCalibMoments.CalibrationHitContainerNames = ["LArCalibrationHitInactive"
313 ,"LArCalibrationHitActive"
314 ,"TileCalibHitActiveCell"
315 ,"TileCalibHitInactiveCell"]
316 TopoCalibMoments.DMCalibrationHitContainerNames = ["LArCalibrationHitDeadMaterial"
317 ,"TileCalibHitDeadMaterial"]
318 return TopoCalibMoments
319
320def CaloTopoClusterToolCfg(flags, cellsname, cellthresholds=(4,2,0)):
321 result=ComponentAccumulator()
322 # maker tools
323 TopoMaker = CompFactory.CaloTopoClusterMaker("TopoMaker")
324
325 TopoMaker.CellsName = cellsname
326 TopoMaker.CalorimeterNames=["LAREM",
327 "LARHEC",
328 "LARFCAL",
329 "TILE"]
330 # cells from the following samplings will be able to form
331 # seeds. By default no sampling is excluded
332 TopoMaker.SeedSamplingNames = ["PreSamplerB", "EMB1", "EMB2", "EMB3",
333 "PreSamplerE", "EME1", "EME2", "EME3",
334 "HEC0", "HEC1","HEC2", "HEC3",
335 "TileBar0", "TileBar1", "TileBar2",
336 "TileExt0", "TileExt1", "TileExt2",
337 "TileGap1", "TileGap2", "TileGap3",
338 "FCAL0", "FCAL1", "FCAL2"]
339 TopoMaker.NeighborOption = "super3D"
340 TopoMaker.RestrictHECIWandFCalNeighbors = False
341 TopoMaker.RestrictPSNeighbors = True
342 TopoMaker.CellThresholdOnEorAbsEinSigma = cellthresholds[2]
343 TopoMaker.NeighborThresholdOnEorAbsEinSigma = cellthresholds[1]
344 TopoMaker.SeedThresholdOnEorAbsEinSigma = cellthresholds[0]
345
346 #timing
347 TopoMaker.SeedCutsInT = flags.Calo.TopoCluster.doTimeCut
348 TopoMaker.CutOOTseed = flags.Calo.TopoCluster.extendTimeCut and flags.Calo.TopoCluster.doTimeCut
349 TopoMaker.UseTimeCutUpperLimit = flags.Calo.TopoCluster.useUpperLimitForTimeCut
350 TopoMaker.TimeCutUpperLimit = flags.Calo.TopoCluster.timeCutUpperLimit
351 TopoMaker.XTalkEM2 = flags.Calo.TopoCluster.xtalkEM2
352 TopoMaker.XTalkEM2D = flags.Calo.TopoCluster.xtalkEM2D
353 TopoMaker.XTalkEM2n = flags.Calo.TopoCluster.xtalkEM2n
354 TopoMaker.XTalkEM3 = flags.Calo.TopoCluster.xtalkEM3
355 TopoMaker.XTalkEMEta = flags.Calo.TopoCluster.xtalkEMEta
356 TopoMaker.XTalkDeltaT = flags.Calo.TopoCluster.xtalkDeltaT
357 TopoMaker.XTalk2Eratio1 = flags.Calo.TopoCluster.xtalk2Eratio1
358 TopoMaker.XTalk2Eratio2 = flags.Calo.TopoCluster.xtalk2Eratio2
359 TopoMaker.XTalk3Eratio = flags.Calo.TopoCluster.xtalk3Eratio
360 TopoMaker.XTalkEtaEratio = flags.Calo.TopoCluster.xtalkEtaEratio
361 TopoMaker.XTalk2DEratio = flags.Calo.TopoCluster.xtalk2DEratio
362
363 # note E or AbsE
364 #
365 # the following properties must be set to TRUE in order to make double
366 # sided cuts on the seed and the cluster level
367 #
368 TopoMaker.SeedCutsInAbsE = True
369 TopoMaker.ClusterCutsInAbsEt = True
370 TopoMaker.ClusterEtorAbsEtCut = 0.0*MeV
371 # use 2-gaussian or single gaussian noise for TileCal
372 TopoMaker.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
373
374 TopoMaker.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
375
376 result.setPrivateTools(TopoMaker)
377 return result
378
380 result=ComponentAccumulator()
381 TopoSplitter = CompFactory.CaloTopoClusterSplitter("TopoSplitter")
382 # cells from the following samplings will be able to form local
383 # maxima. The excluded samplings are PreSamplerB, EMB1,
384 # PreSamplerE, EME1, all Tile samplings, all HEC samplings and the
385 # two rear FCal samplings.
386 #
387 TopoSplitter.SamplingNames = ["EMB2", "EMB3",
388 "EME2", "EME3",
389 "FCAL0"]
390 # cells from the following samplings will also be able to form
391 # local maxima but only if they are not overlapping in eta and phi
392 # with local maxima in previous samplings from the primary list.
393 #
394 TopoSplitter.SecondarySamplingNames = ["EMB1","EME1",
395 "TileBar0","TileBar1","TileBar2",
396 "TileExt0","TileExt1","TileExt2",
397 "HEC0","HEC1","HEC2","HEC3",
398 "FCAL1","FCAL2"]
399 TopoSplitter.ShareBorderCells = True
400 TopoSplitter.RestrictHECIWandFCalNeighbors = False
401 TopoSplitter.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
402
403 TopoSplitter.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
404
405 result.setPrivateTools(TopoSplitter)
406 return result
407
408def CaloClusterTimingFilterCfg(flags, name="CaloClusterTimingFilter", **kwargs):
409 acc = ComponentAccumulator()
410
411 kwargs.setdefault("MinTime", flags.Calo.TopoCluster.clusterTimingCutLower)
412 kwargs.setdefault("MaxTime", flags.Calo.TopoCluster.clusterTimingCutUpper)
413 kwargs.setdefault("InputClusters", "CaloCalTopoClusters")
414 kwargs.setdefault("OutputClusters", "CaloCalTopoClustersFiltered")
415 kwargs.setdefault("OutputCellLinkName", kwargs["OutputClusters"] + "_links")
416
417 acc.addEventAlgo(CompFactory.CaloClusterTimingFilter(name, **kwargs))
418 return acc
419
421 flags,
422 cellsname="AllCalo",
423 clustersname=None,
424 clustersnapname="CaloTopoClusters",
425 cellthresholds=(4,2,0)
426 ):
427 """
428 Configures topo clustering
429
430 If output writing is enabled (ESD,AOD) the topo clusters are added to them
431 """
432 doLCCalib = flags.Calo.TopoCluster.doTopoClusterLocalCalib
433 if clustersname is None:
434 clustersname = "CaloCalTopoClusters" if doLCCalib else "CaloTopoClusters"
435
436
437 if clustersname=="CaloTopoClusters" and doLCCalib is True:
438 raise RuntimeError("Inconsistent arguments: Name must not be 'CaloTopoClusters' if doLCCalib is True")
439
440 clustersname_final = clustersname
441 if flags.Calo.TopoCluster.applyClusterTimingCut:
442 clustersname = f"{clustersname}BeforeTimingCut"
443
444 result=ComponentAccumulator()
445
446 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
447 from TileGeoModel.TileGMConfig import TileGMCfg
448 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
449 # Schedule total noise cond alg
450 result.merge(CaloNoiseCondAlgCfg(flags,"totalNoise"))
451 # Schedule electronic noise cond alg (needed for LC weights)
452 result.merge(CaloNoiseCondAlgCfg(flags,"electronicNoise"))
453
454 CaloClusterMaker, CaloClusterSnapshot=CompFactory.getComps("CaloClusterMaker","CaloClusterSnapshot",)
455
456 result.merge(LArGMCfg(flags))
457
458 result.merge(TileGMCfg(flags))
459
460 TopoMaker = result.popToolsAndMerge( CaloTopoClusterToolCfg(flags, cellsname=cellsname, cellthresholds=cellthresholds))
461 TopoSplitter = result.popToolsAndMerge( CaloTopoClusterSplitterToolCfg(flags) )
462 #
463 # the following options are not set, since these are the default
464 # values
465 #
466 # NeighborOption = "super3D",
467 # NumberOfCellsCut = 4,
468 # EnergyCut = 500*MeV,
469
470 CaloTopoCluster=CaloClusterMaker(clustersname+"Maker")
471 CaloTopoCluster.ClustersOutputName=clustersname
472
473 CaloTopoCluster.ClusterMakerTools = [TopoMaker, TopoSplitter]
474
475 from CaloBadChannelTool.CaloBadChanToolConfig import CaloBadChanToolCfg
476 caloBadChanTool = result.popToolsAndMerge( CaloBadChanToolCfg(flags) )
477 CaloClusterBadChannelList=CompFactory.CaloClusterBadChannelList
478 BadChannelListCorr = CaloClusterBadChannelList(badChannelTool = caloBadChanTool)
479 CaloTopoCluster.ClusterCorrectionTools += [BadChannelListCorr]
480
481 momentsMaker=result.popToolsAndMerge(getTopoMoments(flags))
482 CaloTopoCluster.ClusterCorrectionTools += [momentsMaker]
483
484
485 if flags.Calo.TopoCluster.doCalibHitMoments:
486 calibHitsMomentsMaker=getTopoCalibMoments(flags)
487 CaloTopoCluster.ClusterCorrectionTools += [calibHitsMomentsMaker]
488 caloCalibTruthMapMaker = CaloCalibClusterTruthMapMakerTool(flags)
489 caloCalibDecorator = CaloCalibHitDecoratorTool(flags)
490 caloCalibDecorator.CaloClusterWriteDecorHandleKey_NLeadingTruthParticles = (
491 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible"
492 )
493 caloCalibDecoratorFullEnergy = CaloCalibHitDecoratorFullEnergyTool(flags)
494 caloCalibDecoratorFullEnergy.CaloClusterWriteDecorHandleKey_NLeadingTruthParticles = (
495 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full"
496 )
497 caloCalibDecoratorOOC = CaloCalibHitDecoratorToolOOC(flags)
498 caloCalibDecoratorOOC.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesL = (
499 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L"
500 )
501 caloCalibDecoratorOOC.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesT = (
502 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T"
503 )
504
505 caloCalibDecoratorDM = CaloCalibHitDecoratorToolDM(flags)
506 caloCalibDecoratorDM.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesDM = (
507 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM"
508 )
509
510 CaloTopoCluster.ClusterCorrectionTools += [
511 caloCalibTruthMapMaker,
512 caloCalibDecorator,
513 caloCalibDecoratorFullEnergy,
514 caloCalibDecoratorOOC,
515 caloCalibDecoratorDM,
516 ]
517
518
519
520 if doLCCalib:
521 theCaloClusterSnapshot=CaloClusterSnapshot(OutputName=clustersnapname,SetCrossLinks=True,FinalClusterContainerName=clustersname)
522 CaloTopoCluster.ClusterCorrectionTools += [theCaloClusterSnapshot]
523 #if not clustersname:
524 CaloTopoCluster.ClusterCorrectionTools += getTopoClusterLocalCalibTools(flags)
525
526 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
527 result.merge(caloTopoCoolFolderCfg(flags))
528
529
530 result.addEventAlgo(CaloTopoCluster,primary=True)
531
532 if flags.Calo.TopoCluster.applyClusterTimingCut:
533 result.merge(CaloClusterTimingFilterCfg(
534 flags,
535 name = f"{clustersname}Filter",
536 InputClusters = clustersname,
537 OutputClusters = clustersname_final,
538 ))
539
540 if clustersname_final in flags.Calo.TopoCluster.skipWriteList:
541 # don't add these clusters to ESD and AOD
542 return result
543
544
545 #Output config:
546 AODMoments=[ "SECOND_R"
547 ,"SECOND_LAMBDA"
548 ,"CENTER_MAG"
549 ,"CENTER_LAMBDA"
550 ,"FIRST_ENG_DENS"
551 ,"ENG_FRAC_MAX"
552 ,"ISOLATION"
553 ,"ENG_BAD_CELLS"
554 ,"N_BAD_CELLS"
555 ,"BADLARQ_FRAC"
556 ,"ENG_POS"
557 ,"SIGNIFICANCE"
558 ,"AVG_LAR_Q"
559 ,"AVG_TILE_Q"
560 ,"EM_PROBABILITY"
561 ,"BadChannelList"
562 ,"SECOND_TIME"
563 ,"NCELL_SAMPLING"]
564
565 if flags.Calo.TopoCluster.writeExtendedClusterMoments:
566 AODMoments += ["LATERAL"
567 ,"LONGITUDINAL"
568 ,"CELL_SIGNIFICANCE"
569 ,"PTD"
570 ,"MASS"]
571
572 if flags.Reco.EnableHI:
573 AODMoments += ["CELL_SIG_SAMPLING"]
574
575 if flags.Calo.TopoCluster.writeCalibHitClusterMoments:
576 AODMoments += ["ENG_CALIB_TOT"
577 ,"ENG_CALIB_OUT_L"
578 ,"ENG_CALIB_OUT_T"
579 ,"ENG_CALIB_EMB0"
580 ,"ENG_CALIB_EME0"
581 ,"ENG_CALIB_TILEG3"
582 ,"ENG_CALIB_DEAD_TOT"
583 ,"ENG_CALIB_DEAD_EMB0"
584 ,"ENG_CALIB_DEAD_TILE0"
585 ,"ENG_CALIB_DEAD_TILEG3"
586 ,"ENG_CALIB_DEAD_EME0"
587 ,"ENG_CALIB_DEAD_HEC0"
588 ,"ENG_CALIB_DEAD_FCAL"
589 ,"ENG_CALIB_DEAD_LEAKAGE"
590 ,"ENG_CALIB_DEAD_UNCLASS"
591 ,"ENG_CALIB_FRAC_EM"
592 ,"ENG_CALIB_FRAC_HAD"
593 ,"ENG_CALIB_FRAC_REST"]
594
595
596 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
597 toESD = [f"xAOD::CaloClusterContainer#{clustersname_final}",
598 f"xAOD::CaloClusterAuxContainer#{clustersname_final}Aux.-sigmaWidth",
599 f"CaloClusterCellLinkContainer#{clustersname_final}_links"]
600 toAOD = [f"xAOD::CaloClusterContainer#{clustersname_final}",
601 f"CaloClusterCellLinkContainer#{clustersname_final}_links"]
602
603 AODMoments.append("CellLink") #Add data-link to cell-link container
604 if flags.Calo.TopoCluster.addCalibrationHitDecoration: #Add calib hit deco if requried
605 AODMoments += [
606 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible",
607 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full",
608 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L",
609 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T",
610 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM",
611 ]
612
613 if flags.Calo.TopoCluster.addCPData:
614 AODMoments += ["ClusterWidthEta","ClusterWidthPhi"]
615
616 auxItems = f"xAOD::CaloClusterAuxContainer#{clustersname_final}Aux."
617 auxItems+= ".".join(AODMoments)
618
619 toAOD.append(auxItems)
620
621 result.merge(addToESD(flags, toESD))
622 result.merge(addToAOD(flags, toAOD))
623
624 return result
625
626def addSnapshot(topomaker, corrName,contName):
627 from AthenaCommon.Logging import logging
628 mlog = logging.getLogger('CaloTopoClusterConfig:addSnapshot')
629 corrTools=topomaker.ClusterCorrectionTools
630 newCorrTools=[]
631 found=False
632 for t in corrTools:
633 newCorrTools.append(t)
634 if (t.getName()==corrName):
635 newSnapshot=CompFactory.CaloClusterSnapshot("Snapshot_"+corrName,OutputName=contName,FinalClusterContainerName=topomaker.ClustersOutputName)
636 newCorrTools.append(newSnapshot)
637 found=True
638 if not found:
639 mlog.error("Did not find cluster correction tool %s", corrName)
640 else:
641 mlog.info("Added cluster snapshot after correction tool %s", corrName)
642 topomaker.ClusterCorrectionTools = newCorrTools
643 topomaker.ClusterCorrectionTools += [newSnapshot]
644 return
645
646# Run with python -m CaloRec.CaloTopoClusterConfig
648 if flags is None:
649 from AthenaConfiguration.AllConfigFlags import initConfigFlags
650 flags = initConfigFlags()
651 from AthenaConfiguration.TestDefaults import defaultTestFiles
652 flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
653 flags.Output.ESDFileName="esdOut.pool.root"
654 flags.Exec.MaxEvents = 10
655 flags.fillFromArgs()
656 flags.lock()
657
658 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
659 cfg = MainServicesCfg(flags)
660
661 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
662 cfg.merge(PoolReadCfg(flags))
663
664 topoAcc = CaloTopoClusterCfg(flags)
665 #topoAcc = CaloTopoClusterCfg(flags)
666 topoAlg = topoAcc.getPrimary()
667 topoAlg.ClustersOutputName = "CaloCalTopoClustersNew"
668 cfg.merge(topoAcc)
669
670
671 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
672 cfg.merge(OutputStreamCfg(flags,"xAOD", ItemList = ["xAOD::CaloClusterContainer#CaloCalTopoClusters*",
673 "xAOD::CaloClusterAuxContainer#*CaloCalTopoClusters*Aux.",
674 ]))
675
676 ThinNegativeEnergyCaloClustersAlg=CompFactory.ThinNegativeEnergyCaloClustersAlg
677 theNegativeEnergyCaloClustersThinner = ThinNegativeEnergyCaloClustersAlg(
678 "ThinNegativeEnergyCaloClustersAlg",
679 CaloClustersKey=topoAlg.ClustersOutputName,
680 ThinNegativeEnergyCaloClusters = True,
681 StreamName = 'StreamAOD'
682 )
683 cfg.addEventAlgo(theNegativeEnergyCaloClustersThinner,"AthAlgSeq")
684
685 cfg.addEventAlgo(CompFactory.ClusterDumper("TopoDumper",ContainerName=topoAlg.ClustersOutputName,FileName="TopoClusters.txt",
686 ReducedPrecision=True),sequenceName="AthAlgSeq")
687
688 return cfg.run().isSuccess()
689
690if __name__=="__main__":
691
692 import sys, subprocess
694 if stat==0:
695 print ("Executing returned StatusCode FAILURE")
696 sys.exit(-1)
697
698 else:
699 from AthenaCommon.Utils.unixtools import find_datafile
700 import os
701 refFile=find_datafile("CaloRec/CaloRec-00-00-01/TopoClusters.txt.ref",pathlist=os.getenv("DATAPATH").split(":"))
702 if not refFile or refFile=="":
703 print ("Did not find reference file!")
704 sys.exit(-1)
705 print ("Comparing output with reference file ", refFile)
706 stat=subprocess.check_call(["diff","TopoClusters.txt",refFile])
707 if stat!=0:
708 print ("Output difference found")
709 sys.exit(-1)
710 else:
711 print("Output indentical to reference")
712
713 sys.exit(0)
void print(char *figname, TCanvas *c1)
Tool creating lookup maps for calibration hit truth information.
Top algorithm to reconstruct CaloCluster objects from CaloCell objects.
classify clusters according to their probability to stem from an em object
dead material correction tool for local hadronic calibration
calculates out-of-cluster corrections based on cluster quantities
calculates hadronic cell weights based on cluster and cell quantities
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179
CaloTopoClusterCfg(flags, cellsname="AllCalo", clustersname=None, clustersnapname="CaloTopoClusters", cellthresholds=(4, 2, 0))
addSnapshot(topomaker, corrName, contName)
CaloCalibClusterTruthMapMakerTool(flags, name="CaloCalibClusterTruthMapMakerTool", **kwargs)
CaloCalibHitDecoratorTool(flags, name="CaloCalibClusterDecoratorTool", **kwargs)
CaloClusterTimingFilterCfg(flags, name="CaloClusterTimingFilter", **kwargs)
CaloCalibHitDecoratorFullEnergyTool(flags, name="CaloCalibClusterDecoratorTool_Full", **kwargs)
CaloCalibHitDecoratorToolOOC(flags, name="CaloCalibClusterDecoratorToolOOC", **kwargs)
CaloTopoClusterToolCfg(flags, cellsname, cellthresholds=(4, 2, 0))
CaloCalibHitDecoratorToolDM(flags, name="CaloCalibClusterDecoratorToolDM", **kwargs)