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 ,"PTD_DigiHSTruth"
285 ,"MASS_DigiHSTruth"
286 ,"SECOND_TIME_DigiHSTruth"
287 ,"ENERGY_DigiHSTruth"
288 ,"PHI_DigiHSTruth"
289 ,"ETA_DigiHSTruth"
290 ]
291 return TopoMoments_Truth
292
294 CaloCalibClusterMomentsMaker2=CompFactory.CaloCalibClusterMomentsMaker2
295 TopoCalibMoments = CaloCalibClusterMomentsMaker2 ("TopoCalibMoments")
296 TopoCalibMoments.MomentsNames = ["ENG_CALIB_TOT"
297 ,"ENG_CALIB_OUT_L"
298 ,"ENG_CALIB_OUT_T"
299 ,"ENG_CALIB_EMB0"
300 ,"ENG_CALIB_EME0"
301 ,"ENG_CALIB_TILEG3"
302 ,"ENG_CALIB_DEAD_TOT"
303 ,"ENG_CALIB_DEAD_EMB0"
304 ,"ENG_CALIB_DEAD_TILE0"
305 ,"ENG_CALIB_DEAD_TILEG3"
306 ,"ENG_CALIB_DEAD_EME0"
307 ,"ENG_CALIB_DEAD_HEC0"
308 ,"ENG_CALIB_DEAD_FCAL"
309 ,"ENG_CALIB_DEAD_LEAKAGE"
310 ,"ENG_CALIB_DEAD_UNCLASS"
311 ,"ENG_CALIB_FRAC_EM"
312 ,"ENG_CALIB_FRAC_HAD"
313 ,"ENG_CALIB_FRAC_REST"]
314
315 TopoCalibMoments.CalibrationHitContainerNames = ["LArCalibrationHitInactive"
316 ,"LArCalibrationHitActive"
317 ,"TileCalibHitActiveCell"
318 ,"TileCalibHitInactiveCell"]
319 TopoCalibMoments.DMCalibrationHitContainerNames = ["LArCalibrationHitDeadMaterial"
320 ,"TileCalibHitDeadMaterial"]
321 return TopoCalibMoments
322
323def CaloTopoClusterToolCfg(flags, cellsname, cellthresholds=(4,2,0)):
324 result=ComponentAccumulator()
325 # maker tools
326 TopoMaker = CompFactory.CaloTopoClusterMaker("TopoMaker")
327
328 TopoMaker.CellsName = cellsname
329 TopoMaker.CalorimeterNames=["LAREM",
330 "LARHEC",
331 "LARFCAL",
332 "TILE"]
333 # cells from the following samplings will be able to form
334 # seeds. By default no sampling is excluded
335 TopoMaker.SeedSamplingNames = ["PreSamplerB", "EMB1", "EMB2", "EMB3",
336 "PreSamplerE", "EME1", "EME2", "EME3",
337 "HEC0", "HEC1","HEC2", "HEC3",
338 "TileBar0", "TileBar1", "TileBar2",
339 "TileExt0", "TileExt1", "TileExt2",
340 "TileGap1", "TileGap2", "TileGap3",
341 "FCAL0", "FCAL1", "FCAL2"]
342 TopoMaker.NeighborOption = "super3D"
343 TopoMaker.RestrictHECIWandFCalNeighbors = False
344 TopoMaker.RestrictPSNeighbors = True
345 TopoMaker.CellThresholdOnEorAbsEinSigma = cellthresholds[2]
346 TopoMaker.NeighborThresholdOnEorAbsEinSigma = cellthresholds[1]
347 TopoMaker.SeedThresholdOnEorAbsEinSigma = cellthresholds[0]
348
349 #timing
350 TopoMaker.SeedCutsInT = flags.Calo.TopoCluster.doTimeCut
351 TopoMaker.CutOOTseed = flags.Calo.TopoCluster.extendTimeCut and flags.Calo.TopoCluster.doTimeCut
352 TopoMaker.UseTimeCutUpperLimit = flags.Calo.TopoCluster.useUpperLimitForTimeCut
353 TopoMaker.TimeCutUpperLimit = flags.Calo.TopoCluster.timeCutUpperLimit
354 TopoMaker.XTalkEM2 = flags.Calo.TopoCluster.xtalkEM2
355 TopoMaker.XTalkEM2D = flags.Calo.TopoCluster.xtalkEM2D
356 TopoMaker.XTalkEM2n = flags.Calo.TopoCluster.xtalkEM2n
357 TopoMaker.XTalkEM3 = flags.Calo.TopoCluster.xtalkEM3
358 TopoMaker.XTalkEMEta = flags.Calo.TopoCluster.xtalkEMEta
359 TopoMaker.XTalkDeltaT = flags.Calo.TopoCluster.xtalkDeltaT
360 TopoMaker.XTalk2Eratio1 = flags.Calo.TopoCluster.xtalk2Eratio1
361 TopoMaker.XTalk2Eratio2 = flags.Calo.TopoCluster.xtalk2Eratio2
362 TopoMaker.XTalk3Eratio = flags.Calo.TopoCluster.xtalk3Eratio
363 TopoMaker.XTalkEtaEratio = flags.Calo.TopoCluster.xtalkEtaEratio
364 TopoMaker.XTalk2DEratio = flags.Calo.TopoCluster.xtalk2DEratio
365
366 # note E or AbsE
367 #
368 # the following properties must be set to TRUE in order to make double
369 # sided cuts on the seed and the cluster level
370 #
371 TopoMaker.SeedCutsInAbsE = True
372 TopoMaker.ClusterCutsInAbsEt = True
373 TopoMaker.ClusterEtorAbsEtCut = 0.0*MeV
374 # use 2-gaussian or single gaussian noise for TileCal
375 TopoMaker.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
376
377 TopoMaker.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
378
379 result.setPrivateTools(TopoMaker)
380 return result
381
383 result=ComponentAccumulator()
384 TopoSplitter = CompFactory.CaloTopoClusterSplitter("TopoSplitter")
385 # cells from the following samplings will be able to form local
386 # maxima. The excluded samplings are PreSamplerB, EMB1,
387 # PreSamplerE, EME1, all Tile samplings, all HEC samplings and the
388 # two rear FCal samplings.
389 #
390 TopoSplitter.SamplingNames = ["EMB2", "EMB3",
391 "EME2", "EME3",
392 "FCAL0"]
393 # cells from the following samplings will also be able to form
394 # local maxima but only if they are not overlapping in eta and phi
395 # with local maxima in previous samplings from the primary list.
396 #
397 TopoSplitter.SecondarySamplingNames = ["EMB1","EME1",
398 "TileBar0","TileBar1","TileBar2",
399 "TileExt0","TileExt1","TileExt2",
400 "HEC0","HEC1","HEC2","HEC3",
401 "FCAL1","FCAL2"]
402 TopoSplitter.ShareBorderCells = True
403 TopoSplitter.RestrictHECIWandFCalNeighbors = False
404 TopoSplitter.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
405
406 TopoSplitter.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
407
408 result.setPrivateTools(TopoSplitter)
409 return result
410
411def CaloClusterTimingFilterCfg(flags, name="CaloClusterTimingFilter", **kwargs):
412 acc = ComponentAccumulator()
413
414 kwargs.setdefault("MinTime", flags.Calo.TopoCluster.clusterTimingCutLower)
415 kwargs.setdefault("MaxTime", flags.Calo.TopoCluster.clusterTimingCutUpper)
416 kwargs.setdefault("InputClusters", "CaloCalTopoClusters")
417 kwargs.setdefault("OutputClusters", "CaloCalTopoClustersFiltered")
418 kwargs.setdefault("OutputCellLinkName", kwargs["OutputClusters"] + "_links")
419
420 acc.addEventAlgo(CompFactory.CaloClusterTimingFilter(name, **kwargs))
421 return acc
422
424 flags,
425 cellsname="AllCalo",
426 clustersname=None,
427 clustersnapname="CaloTopoClusters",
428 cellthresholds=(4,2,0)
429 ):
430 """
431 Configures topo clustering
432
433 If output writing is enabled (ESD,AOD) the topo clusters are added to them
434 """
435 doLCCalib = flags.Calo.TopoCluster.doTopoClusterLocalCalib
436 if clustersname is None:
437 clustersname = "CaloCalTopoClusters" if doLCCalib else "CaloTopoClusters"
438
439
440 if clustersname=="CaloTopoClusters" and doLCCalib is True:
441 raise RuntimeError("Inconsistent arguments: Name must not be 'CaloTopoClusters' if doLCCalib is True")
442
443 clustersname_final = clustersname
444 if flags.Calo.TopoCluster.applyClusterTimingCut:
445 clustersname = f"{clustersname}BeforeTimingCut"
446
447 result=ComponentAccumulator()
448
449 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
450 from TileGeoModel.TileGMConfig import TileGMCfg
451 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
452 # Schedule total noise cond alg
453 result.merge(CaloNoiseCondAlgCfg(flags,"totalNoise"))
454 # Schedule electronic noise cond alg (needed for LC weights)
455 result.merge(CaloNoiseCondAlgCfg(flags,"electronicNoise"))
456
457 CaloClusterMaker, CaloClusterSnapshot=CompFactory.getComps("CaloClusterMaker","CaloClusterSnapshot",)
458
459 result.merge(LArGMCfg(flags))
460
461 result.merge(TileGMCfg(flags))
462
463 TopoMaker = result.popToolsAndMerge( CaloTopoClusterToolCfg(flags, cellsname=cellsname, cellthresholds=cellthresholds))
464 TopoSplitter = result.popToolsAndMerge( CaloTopoClusterSplitterToolCfg(flags) )
465 #
466 # the following options are not set, since these are the default
467 # values
468 #
469 # NeighborOption = "super3D",
470 # NumberOfCellsCut = 4,
471 # EnergyCut = 500*MeV,
472
473 CaloTopoCluster=CaloClusterMaker(clustersname+"Maker")
474 CaloTopoCluster.ClustersOutputName=clustersname
475
476 CaloTopoCluster.ClusterMakerTools = [TopoMaker, TopoSplitter]
477
478 from CaloBadChannelTool.CaloBadChanToolConfig import CaloBadChanToolCfg
479 caloBadChanTool = result.popToolsAndMerge( CaloBadChanToolCfg(flags) )
480 CaloClusterBadChannelList=CompFactory.CaloClusterBadChannelList
481 BadChannelListCorr = CaloClusterBadChannelList(badChannelTool = caloBadChanTool)
482 CaloTopoCluster.ClusterCorrectionTools += [BadChannelListCorr]
483
484 momentsMaker=result.popToolsAndMerge(getTopoMoments(flags))
485 CaloTopoCluster.ClusterCorrectionTools += [momentsMaker]
486
487
488 if flags.Calo.TopoCluster.doCalibHitMoments:
489 calibHitsMomentsMaker=getTopoCalibMoments(flags)
490 CaloTopoCluster.ClusterCorrectionTools += [calibHitsMomentsMaker]
491 caloCalibTruthMapMaker = CaloCalibClusterTruthMapMakerTool(flags)
492 caloCalibDecorator = CaloCalibHitDecoratorTool(flags)
493 caloCalibDecorator.CaloClusterWriteDecorHandleKey_NLeadingTruthParticles = (
494 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible"
495 )
496 caloCalibDecoratorFullEnergy = CaloCalibHitDecoratorFullEnergyTool(flags)
497 caloCalibDecoratorFullEnergy.CaloClusterWriteDecorHandleKey_NLeadingTruthParticles = (
498 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full"
499 )
500 caloCalibDecoratorOOC = CaloCalibHitDecoratorToolOOC(flags)
501 caloCalibDecoratorOOC.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesL = (
502 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L"
503 )
504 caloCalibDecoratorOOC.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesT = (
505 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T"
506 )
507
508 caloCalibDecoratorDM = CaloCalibHitDecoratorToolDM(flags)
509 caloCalibDecoratorDM.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesDM = (
510 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM"
511 )
512
513 CaloTopoCluster.ClusterCorrectionTools += [
514 caloCalibTruthMapMaker,
515 caloCalibDecorator,
516 caloCalibDecoratorFullEnergy,
517 caloCalibDecoratorOOC,
518 caloCalibDecoratorDM,
519 ]
520
521 if flags.Calo.TopoCluster.doDigiHSTruthMoments:
522 truthMomentMaker=getTopoTruthMoments(flags)
523 CaloTopoCluster.ClusterCorrectionTools += [truthMomentMaker]
524
525 if doLCCalib:
526 theCaloClusterSnapshot=CaloClusterSnapshot(OutputName=clustersnapname,SetCrossLinks=True,FinalClusterContainerName=clustersname)
527 CaloTopoCluster.ClusterCorrectionTools += [theCaloClusterSnapshot]
528 #if not clustersname:
529 CaloTopoCluster.ClusterCorrectionTools += getTopoClusterLocalCalibTools(flags)
530
531 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
532 result.merge(caloTopoCoolFolderCfg(flags))
533
534
535 result.addEventAlgo(CaloTopoCluster,primary=True)
536
537 if flags.Calo.TopoCluster.applyClusterTimingCut:
538 result.merge(CaloClusterTimingFilterCfg(
539 flags,
540 name = f"{clustersname}Filter",
541 InputClusters = clustersname,
542 OutputClusters = clustersname_final,
543 ))
544
545 if clustersname_final in flags.Calo.TopoCluster.skipWriteList:
546 # don't add these clusters to ESD and AOD
547 return result
548
549
550 #Output config:
551 AODMoments=[ "SECOND_R"
552 ,"SECOND_LAMBDA"
553 ,"CENTER_MAG"
554 ,"CENTER_LAMBDA"
555 ,"FIRST_ENG_DENS"
556 ,"ENG_FRAC_MAX"
557 ,"ISOLATION"
558 ,"ENG_BAD_CELLS"
559 ,"N_BAD_CELLS"
560 ,"BADLARQ_FRAC"
561 ,"ENG_POS"
562 ,"SIGNIFICANCE"
563 ,"AVG_LAR_Q"
564 ,"AVG_TILE_Q"
565 ,"EM_PROBABILITY"
566 ,"BadChannelList"
567 ,"SECOND_TIME"
568 ,"NCELL_SAMPLING"]
569
570 if flags.Calo.TopoCluster.writeExtendedClusterMoments:
571 AODMoments += ["LATERAL"
572 ,"LONGITUDINAL"
573 ,"CELL_SIGNIFICANCE"
574 ,"PTD"
575 ,"MASS"]
576
577 if flags.Reco.EnableHI:
578 AODMoments += ["CELL_SIG_SAMPLING"]
579
580 if flags.Calo.TopoCluster.writeCalibHitClusterMoments:
581 AODMoments += ["ENG_CALIB_TOT"
582 ,"ENG_CALIB_OUT_L"
583 ,"ENG_CALIB_OUT_T"
584 ,"ENG_CALIB_EMB0"
585 ,"ENG_CALIB_EME0"
586 ,"ENG_CALIB_TILEG3"
587 ,"ENG_CALIB_DEAD_TOT"
588 ,"ENG_CALIB_DEAD_EMB0"
589 ,"ENG_CALIB_DEAD_TILE0"
590 ,"ENG_CALIB_DEAD_TILEG3"
591 ,"ENG_CALIB_DEAD_EME0"
592 ,"ENG_CALIB_DEAD_HEC0"
593 ,"ENG_CALIB_DEAD_FCAL"
594 ,"ENG_CALIB_DEAD_LEAKAGE"
595 ,"ENG_CALIB_DEAD_UNCLASS"
596 ,"ENG_CALIB_FRAC_EM"
597 ,"ENG_CALIB_FRAC_HAD"
598 ,"ENG_CALIB_FRAC_REST"]
599
600 if flags.Calo.TopoCluster.writeDigiHSTruthMoments:
601 AODMoments += ["FIRST_PHI_DigiHSTruth"
602 ,"FIRST_ETA_DigiHSTruth"
603 ,"SECOND_R_DigiHSTruth"
604 ,"SECOND_LAMBDA_DigiHSTruth"
605 ,"DELTA_PHI_DigiHSTruth"
606 ,"DELTA_THETA_DigiHSTruth"
607 ,"DELTA_ALPHA_DigiHSTruth"
608 ,"CENTER_X_DigiHSTruth"
609 ,"CENTER_Y_DigiHSTruth"
610 ,"CENTER_Z_DigiHSTruth"
611 ,"CENTER_MAG_DigiHSTruth"
612 ,"CENTER_LAMBDA_DigiHSTruth"
613 ,"LATERAL_DigiHSTruth"
614 ,"LONGITUDINAL_DigiHSTruth"
615 ,"ENG_FRAC_CORE_DigiHSTruth"
616 ,"FIRST_ENG_DENS_DigiHSTruth"
617 ,"SECOND_ENG_DENS_DigiHSTruth"
618 ,"ISOLATION_DigiHSTruth"
619 ,"BAD_CELLS_CORR_E_DigiHSTruth"
620 ,"ENG_POS_DigiHSTruth"
621 ,"SIGNIFICANCE_DigiHSTruth"
622 ,"CELL_SIGNIFICANCE_DigiHSTruth"
623 ,"CELL_SIG_SAMPLING_DigiHSTruth"
624 ,"AVG_LAR_Q_DigiHSTruth"
625 ,"AVG_TILE_Q_DigiHSTruth"
626 ,"PTD_DigiHSTruth"
627 ,"MASS_DigiHSTruth"
628 ,"SECOND_TIME_DigiHSTruth"
629 ,"ENERGY_DigiHSTruth"
630 ,"PHI_DigiHSTruth"
631 ,"ETA_DigiHSTruth"]
632
633
634 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
635 toESD = [f"xAOD::CaloClusterContainer#{clustersname_final}",
636 f"xAOD::CaloClusterAuxContainer#{clustersname_final}Aux.-sigmaWidth",
637 f"CaloClusterCellLinkContainer#{clustersname_final}_links"]
638 toAOD = [f"xAOD::CaloClusterContainer#{clustersname_final}",
639 f"CaloClusterCellLinkContainer#{clustersname_final}_links"]
640
641 AODMoments.append("CellLink") #Add data-link to cell-link container
642 if flags.Calo.TopoCluster.addCalibrationHitDecoration: #Add calib hit deco if requried
643 AODMoments += [
644 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible",
645 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full",
646 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L",
647 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T",
648 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM",
649 ]
650
651 if flags.Calo.TopoCluster.addCPData:
652 AODMoments += ["ClusterWidthEta","ClusterWidthPhi"]
653
654 auxItems = f"xAOD::CaloClusterAuxContainer#{clustersname_final}Aux."
655 auxItems+= ".".join(AODMoments)
656
657 if flags.Calo.TopoCluster.writeDigiHSTruthMoments:
658 toAOD.append("CaloCellContainer#AllCalo_DigiHSTruth")
659 toESD.append("CaloCellContainer#AllCalo_DigiHSTruth")
660
661 toAOD.append(auxItems)
662
663 result.merge(addToESD(flags, toESD))
664 result.merge(addToAOD(flags, toAOD))
665
666 return result
667
668def addSnapshot(topomaker, corrName,contName):
669 from AthenaCommon.Logging import logging
670 mlog = logging.getLogger('CaloTopoClusterConfig:addSnapshot')
671 corrTools=topomaker.ClusterCorrectionTools
672 newCorrTools=[]
673 found=False
674 for t in corrTools:
675 newCorrTools.append(t)
676 if (t.getName()==corrName):
677 newSnapshot=CompFactory.CaloClusterSnapshot("Snapshot_"+corrName,OutputName=contName,FinalClusterContainerName=topomaker.ClustersOutputName)
678 newCorrTools.append(newSnapshot)
679 found=True
680 if not found:
681 mlog.error("Did not find cluster correction tool %s", corrName)
682 else:
683 mlog.info("Added cluster snapshot after correction tool %s", corrName)
684 topomaker.ClusterCorrectionTools = newCorrTools
685 topomaker.ClusterCorrectionTools += [newSnapshot]
686 return
687
688# Run with python -m CaloRec.CaloTopoClusterConfig
690 if flags is None:
691 from AthenaConfiguration.AllConfigFlags import initConfigFlags
692 flags = initConfigFlags()
693 from AthenaConfiguration.TestDefaults import defaultTestFiles
694 flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
695 flags.Output.ESDFileName="esdOut.pool.root"
696 flags.Exec.MaxEvents = 10
697 flags.fillFromArgs()
698 flags.lock()
699
700 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
701 cfg = MainServicesCfg(flags)
702
703 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
704 cfg.merge(PoolReadCfg(flags))
705
706 topoAcc = CaloTopoClusterCfg(flags)
707 #topoAcc = CaloTopoClusterCfg(flags)
708 topoAlg = topoAcc.getPrimary()
709 topoAlg.ClustersOutputName = "CaloCalTopoClustersNew"
710 cfg.merge(topoAcc)
711
712
713 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
714 cfg.merge(OutputStreamCfg(flags,"xAOD", ItemList = ["xAOD::CaloClusterContainer#CaloCalTopoClusters*",
715 "xAOD::CaloClusterAuxContainer#*CaloCalTopoClusters*Aux.",
716 ]))
717
718 ThinNegativeEnergyCaloClustersAlg=CompFactory.ThinNegativeEnergyCaloClustersAlg
719 theNegativeEnergyCaloClustersThinner = ThinNegativeEnergyCaloClustersAlg(
720 "ThinNegativeEnergyCaloClustersAlg",
721 CaloClustersKey=topoAlg.ClustersOutputName,
722 ThinNegativeEnergyCaloClusters = True,
723 StreamName = 'StreamAOD'
724 )
725 cfg.addEventAlgo(theNegativeEnergyCaloClustersThinner,"AthAlgSeq")
726
727 cfg.addEventAlgo(CompFactory.ClusterDumper("TopoDumper",ContainerName=topoAlg.ClustersOutputName,FileName="TopoClusters.txt",
728 ReducedPrecision=True),sequenceName="AthAlgSeq")
729
730 return cfg.run().isSuccess()
731
732if __name__=="__main__":
733
734 import sys, subprocess
736 if stat==0:
737 print ("Executing returned StatusCode FAILURE")
738 sys.exit(-1)
739
740 else:
741 from AthenaCommon.Utils.unixtools import find_datafile
742 import os
743 refFile=find_datafile("CaloRec/CaloRec-00-00-01/TopoClusters.txt.ref",pathlist=os.getenv("DATAPATH").split(":"))
744 if not refFile or refFile=="":
745 print ("Did not find reference file!")
746 sys.exit(-1)
747 print ("Comparing output with reference file ", refFile)
748 stat=subprocess.check_call(["diff","TopoClusters.txt",refFile])
749 if stat!=0:
750 print ("Output difference found")
751 sys.exit(-1)
752 else:
753 print("Output indentical to reference")
754
755 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)