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