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