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):
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 = 0.0
343 TopoMaker.NeighborThresholdOnEorAbsEinSigma = 2.0
344 TopoMaker.SeedThresholdOnEorAbsEinSigma = 4.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 CaloTopoClusterCfg(flags, cellsname="AllCalo", clustersname=None, clustersnapname="CaloTopoClusters"):
409 """
410 Configures topo clustering
411
412 If output writing is enabled (ESD,AOD) the topo clusters are added to them
413 """
414 doLCCalib = flags.Calo.TopoCluster.doTopoClusterLocalCalib
415 if clustersname is None:
416 clustersname = "CaloCalTopoClusters" if doLCCalib else "CaloTopoClusters"
417
418
419 if clustersname=="CaloTopoClusters" and doLCCalib is True:
420 raise RuntimeError("Inconsistent arguments: Name must not be 'CaloTopoClusters' if doLCCalib is True")
421
422 result=ComponentAccumulator()
423
424 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
425 from TileGeoModel.TileGMConfig import TileGMCfg
426 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
427 # Schedule total noise cond alg
428 result.merge(CaloNoiseCondAlgCfg(flags,"totalNoise"))
429 # Schedule electronic noise cond alg (needed for LC weights)
430 result.merge(CaloNoiseCondAlgCfg(flags,"electronicNoise"))
431
432 CaloClusterMaker, CaloClusterSnapshot=CompFactory.getComps("CaloClusterMaker","CaloClusterSnapshot",)
433
434 result.merge(LArGMCfg(flags))
435
436 result.merge(TileGMCfg(flags))
437
438 TopoMaker = result.popToolsAndMerge( CaloTopoClusterToolCfg(flags, cellsname=cellsname))
439 TopoSplitter = result.popToolsAndMerge( CaloTopoClusterSplitterToolCfg(flags) )
440 #
441 # the following options are not set, since these are the default
442 # values
443 #
444 # NeighborOption = "super3D",
445 # NumberOfCellsCut = 4,
446 # EnergyCut = 500*MeV,
447
448 CaloTopoCluster=CaloClusterMaker(clustersname+"Maker")
449 CaloTopoCluster.ClustersOutputName=clustersname
450
451 CaloTopoCluster.ClusterMakerTools = [TopoMaker, TopoSplitter]
452
453 from CaloBadChannelTool.CaloBadChanToolConfig import CaloBadChanToolCfg
454 caloBadChanTool = result.popToolsAndMerge( CaloBadChanToolCfg(flags) )
455 CaloClusterBadChannelList=CompFactory.CaloClusterBadChannelList
456 BadChannelListCorr = CaloClusterBadChannelList(badChannelTool = caloBadChanTool)
457 CaloTopoCluster.ClusterCorrectionTools += [BadChannelListCorr]
458
459 momentsMaker=result.popToolsAndMerge(getTopoMoments(flags))
460 CaloTopoCluster.ClusterCorrectionTools += [momentsMaker]
461
462
463 if flags.Calo.TopoCluster.doCalibHitMoments:
464 calibHitsMomentsMaker=getTopoCalibMoments(flags)
465 CaloTopoCluster.ClusterCorrectionTools += [calibHitsMomentsMaker]
466 caloCalibTruthMapMaker = CaloCalibClusterTruthMapMakerTool(flags)
467 caloCalibDecorator = CaloCalibHitDecoratorTool(flags)
468 caloCalibDecorator.CaloClusterWriteDecorHandleKey_NLeadingTruthParticles = (
469 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible"
470 )
471 caloCalibDecoratorFullEnergy = CaloCalibHitDecoratorFullEnergyTool(flags)
472 caloCalibDecoratorFullEnergy.CaloClusterWriteDecorHandleKey_NLeadingTruthParticles = (
473 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full"
474 )
475 caloCalibDecoratorOOC = CaloCalibHitDecoratorToolOOC(flags)
476 caloCalibDecoratorOOC.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesL = (
477 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L"
478 )
479 caloCalibDecoratorOOC.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesT = (
480 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T"
481 )
482
483 caloCalibDecoratorDM = CaloCalibHitDecoratorToolDM(flags)
484 caloCalibDecoratorDM.CaloClusterWriteDecorHandleKey_NLeadingTruthParticlesDM = (
485 clustersname + "." + flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM"
486 )
487
488 CaloTopoCluster.ClusterCorrectionTools += [
489 caloCalibTruthMapMaker,
490 caloCalibDecorator,
491 caloCalibDecoratorFullEnergy,
492 caloCalibDecoratorOOC,
493 caloCalibDecoratorDM,
494 ]
495
496
497
498 if doLCCalib:
499 theCaloClusterSnapshot=CaloClusterSnapshot(OutputName=clustersnapname,SetCrossLinks=True,FinalClusterContainerName=clustersname)
500 CaloTopoCluster.ClusterCorrectionTools += [theCaloClusterSnapshot]
501 #if not clustersname:
502 CaloTopoCluster.ClusterCorrectionTools += getTopoClusterLocalCalibTools(flags)
503
504 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
505 result.merge(caloTopoCoolFolderCfg(flags))
506
507
508 result.addEventAlgo(CaloTopoCluster,primary=True)
509
510 if CaloTopoCluster.ClustersOutputName in flags.Calo.TopoCluster.skipWriteList:
511 # don't add these clusters to ESD and AOD
512 return result
513
514
515 #Output config:
516 AODMoments=[ "SECOND_R"
517 ,"SECOND_LAMBDA"
518 ,"CENTER_MAG"
519 ,"CENTER_LAMBDA"
520 ,"FIRST_ENG_DENS"
521 ,"ENG_FRAC_MAX"
522 ,"ISOLATION"
523 ,"ENG_BAD_CELLS"
524 ,"N_BAD_CELLS"
525 ,"BADLARQ_FRAC"
526 ,"ENG_POS"
527 ,"SIGNIFICANCE"
528 ,"AVG_LAR_Q"
529 ,"AVG_TILE_Q"
530 ,"EM_PROBABILITY"
531 ,"BadChannelList"
532 ,"SECOND_TIME"
533 ,"NCELL_SAMPLING"]
534
535 if flags.Calo.TopoCluster.writeExtendedClusterMoments:
536 AODMoments += ["LATERAL"
537 ,"LONGITUDINAL"
538 ,"CELL_SIGNIFICANCE"
539 ,"PTD"
540 ,"MASS"]
541
542 if flags.Reco.EnableHI:
543 AODMoments += ["CELL_SIG_SAMPLING"]
544
545 if flags.Calo.TopoCluster.writeCalibHitClusterMoments:
546 AODMoments += ["ENG_CALIB_TOT"
547 ,"ENG_CALIB_OUT_L"
548 ,"ENG_CALIB_OUT_T"
549 ,"ENG_CALIB_EMB0"
550 ,"ENG_CALIB_EME0"
551 ,"ENG_CALIB_TILEG3"
552 ,"ENG_CALIB_DEAD_TOT"
553 ,"ENG_CALIB_DEAD_EMB0"
554 ,"ENG_CALIB_DEAD_TILE0"
555 ,"ENG_CALIB_DEAD_TILEG3"
556 ,"ENG_CALIB_DEAD_EME0"
557 ,"ENG_CALIB_DEAD_HEC0"
558 ,"ENG_CALIB_DEAD_FCAL"
559 ,"ENG_CALIB_DEAD_LEAKAGE"
560 ,"ENG_CALIB_DEAD_UNCLASS"
561 ,"ENG_CALIB_FRAC_EM"
562 ,"ENG_CALIB_FRAC_HAD"
563 ,"ENG_CALIB_FRAC_REST"]
564
565
566 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
567 toESD = [f"xAOD::CaloClusterContainer#{CaloTopoCluster.ClustersOutputName}",
568 f"xAOD::CaloClusterAuxContainer#{CaloTopoCluster.ClustersOutputName}Aux.-sigmaWidth",
569 f"CaloClusterCellLinkContainer#{CaloTopoCluster.ClustersOutputName}_links"]
570 toAOD = [f"xAOD::CaloClusterContainer#{CaloTopoCluster.ClustersOutputName}",
571 f"CaloClusterCellLinkContainer#{CaloTopoCluster.ClustersOutputName}_links"]
572
573 AODMoments.append("CellLink") #Add data-link to cell-link container
574 if flags.Calo.TopoCluster.addCalibrationHitDecoration: #Add calib hit deco if requried
575 AODMoments += [
576 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Visible",
577 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_Full",
578 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_L",
579 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_OOC_T",
580 flags.Calo.TopoCluster.CalibrationHitDecorationName + "_DM",
581 ]
582
583 if flags.Calo.TopoCluster.addCPData:
584 AODMoments += ["ClusterWidthEta","ClusterWidthPhi"]
585
586 auxItems = f"xAOD::CaloClusterAuxContainer#{CaloTopoCluster.ClustersOutputName}Aux."
587 auxItems+= ".".join(AODMoments)
588
589 toAOD.append(auxItems)
590
591 result.merge(addToESD(flags, toESD))
592 result.merge(addToAOD(flags, toAOD))
593
594 return result
595
596def addSnapshot(topomaker, corrName,contName):
597 from AthenaCommon.Logging import logging
598 mlog = logging.getLogger('CaloTopoClusterConfig:addSnapshot')
599 corrTools=topomaker.ClusterCorrectionTools
600 newCorrTools=[]
601 found=False
602 for t in corrTools:
603 newCorrTools.append(t)
604 if (t.getName()==corrName):
605 newSnapshot=CompFactory.CaloClusterSnapshot("Snapshot_"+corrName,OutputName=contName,FinalClusterContainerName=topomaker.ClustersOutputName)
606 newCorrTools.append(newSnapshot)
607 found=True
608 if not found:
609 mlog.error("Did not find cluster correction tool %s", corrName)
610 else:
611 mlog.info("Added cluster snapshot after correction tool %s", corrName)
612 topomaker.ClusterCorrectionTools = newCorrTools
613 topomaker.ClusterCorrectionTools += [newSnapshot]
614 return
615
616# Run with python -m CaloRec.CaloTopoClusterConfig
618 if flags is None:
619 from AthenaConfiguration.AllConfigFlags import initConfigFlags
620 flags = initConfigFlags()
621 from AthenaConfiguration.TestDefaults import defaultTestFiles
622 flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
623 flags.Output.ESDFileName="esdOut.pool.root"
624 flags.Exec.MaxEvents = 10
625 flags.fillFromArgs()
626 flags.lock()
627
628 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
629 cfg = MainServicesCfg(flags)
630
631 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
632 cfg.merge(PoolReadCfg(flags))
633
634 topoAcc = CaloTopoClusterCfg(flags)
635 #topoAcc = CaloTopoClusterCfg(flags)
636 topoAlg = topoAcc.getPrimary()
637 topoAlg.ClustersOutputName = "CaloCalTopoClustersNew"
638 cfg.merge(topoAcc)
639
640
641 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
642 cfg.merge(OutputStreamCfg(flags,"xAOD", ItemList = ["xAOD::CaloClusterContainer#CaloCalTopoClusters*",
643 "xAOD::CaloClusterAuxContainer#*CaloCalTopoClusters*Aux.",
644 ]))
645
646 ThinNegativeEnergyCaloClustersAlg=CompFactory.ThinNegativeEnergyCaloClustersAlg
647 theNegativeEnergyCaloClustersThinner = ThinNegativeEnergyCaloClustersAlg(
648 "ThinNegativeEnergyCaloClustersAlg",
649 CaloClustersKey=topoAlg.ClustersOutputName,
650 ThinNegativeEnergyCaloClusters = True,
651 StreamName = 'StreamAOD'
652 )
653 cfg.addEventAlgo(theNegativeEnergyCaloClustersThinner,"AthAlgSeq")
654
655 cfg.addEventAlgo(CompFactory.ClusterDumper("TopoDumper",ContainerName=topoAlg.ClustersOutputName,FileName="TopoClusters.txt",
656 ReducedPrecision=True),sequenceName="AthAlgSeq")
657
658 return cfg.run().isSuccess()
659
660if __name__=="__main__":
661
662 import sys, subprocess
664 if stat==0:
665 print ("Executing returned StatusCode FAILURE")
666 sys.exit(-1)
667
668 else:
669 from AthenaCommon.Utils.unixtools import find_datafile
670 import os
671 refFile=find_datafile("CaloRec/CaloRec-00-00-01/TopoClusters.txt.ref",pathlist=os.getenv("DATAPATH").split(":"))
672 if not refFile or refFile=="":
673 print ("Did not find reference file!")
674 sys.exit(-1)
675 print ("Comparing output with reference file ", refFile)
676 stat=subprocess.check_call(["diff","TopoClusters.txt",refFile])
677 if stat!=0:
678 print ("Output difference found")
679 sys.exit(-1)
680 else:
681 print("Output indentical to reference")
682
683 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
CaloCalibHitDecoratorToolDM(flags, name="CaloCalibClusterDecoratorToolDM", **kwargs)
CaloCalibHitDecoratorFullEnergyTool(flags, name="CaloCalibClusterDecoratorTool_Full", **kwargs)
CaloCalibHitDecoratorTool(flags, name="CaloCalibClusterDecoratorTool", **kwargs)
CaloTopoClusterCfg(flags, cellsname="AllCalo", clustersname=None, clustersnapname="CaloTopoClusters")
CaloCalibClusterTruthMapMakerTool(flags, name="CaloCalibClusterTruthMapMakerTool", **kwargs)
addSnapshot(topomaker, corrName, contName)
CaloCalibHitDecoratorToolOOC(flags, name="CaloCalibClusterDecoratorToolOOC", **kwargs)