3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory
import CompFactory
9 from IOVDbSvc.IOVDbSvcConfig
import addFolders
13 "HadCalibration2/CaloEMFrac",
14 "HadCalibration2/H1ClusterCellWeights",
15 "HadCalibration2/CaloOutOfCluster",
16 "HadCalibration2/CaloOutOfClusterPi0",
17 "HadCalibration2/CaloDMCorr2"
19 hadCalibPrefix =
"/CALO/"
20 hadCalibDB =
"CALO_ONL"
22 hadCalibPrefix =
"/CALO/Ofl/"
23 hadCalibDB =
"CALO_OFL"
24 hadCalibFolders = [ hadCalibPrefix + foldername
for foldername
in hadCalibFolders ]
25 result.merge(
addFolders(flags, hadCalibFolders, hadCalibDB, className=
"CaloLocalHadCoeff"))
30 CaloLCClassificationTool, CaloLCWeightTool, CaloLCOutOfClusterTool, CaloLCDeadMaterialTool=CompFactory.getComps(
"CaloLCClassificationTool",
"CaloLCWeightTool",
"CaloLCOutOfClusterTool",
"CaloLCDeadMaterialTool",)
31 CaloClusterLocalCalib=CompFactory.CaloClusterLocalCalib
34 LCClassify.ClassificationKey =
"EMFracClassify"
35 LCClassify.UseSpread =
False
36 LCClassify.MaxProbability = 0.5
38 LCClassify.StoreClassificationProbabilityInAOD =
True
39 LCClassify.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
42 LCWeight.CorrectionKey =
"H1ClusterCellWeights"
43 LCWeight.SignalOverNoiseCut = 2.0
45 LCWeight.UseHadProbability =
True
47 LocalCalib = CaloClusterLocalCalib (
"LocalCalib")
48 LocalCalib.ClusterClassificationTool = [LCClassify]
49 LocalCalib.ClusterRecoStatus = [1,2]
50 LocalCalib.LocalCalibTools = [LCWeight]
51 LocalCalib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
55 LCOut.CorrectionKey =
"OOCCorrection"
56 LCOut.UseEmProbability =
False
57 LCOut.UseHadProbability =
True
59 OOCCalib = CaloClusterLocalCalib (
"OOCCalib")
60 OOCCalib.ClusterRecoStatus = [1,2]
61 OOCCalib.LocalCalibTools = [LCOut]
62 OOCCalib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
65 LCOutPi0.CorrectionKey =
"OOCPi0Correction"
66 LCOutPi0.UseEmProbability =
True
67 LCOutPi0.UseHadProbability =
False
69 OOCPi0Calib = CaloClusterLocalCalib (
"OOCPi0Calib")
70 OOCPi0Calib.ClusterRecoStatus = [1,2]
71 OOCPi0Calib.LocalCalibTools = [LCOutPi0]
73 OOCPi0Calib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
77 LCDeadMaterial.HadDMCoeffKey =
"HadDMCoeff2"
78 LCDeadMaterial.ClusterRecoStatus = 0
79 LCDeadMaterial.WeightModeDM = 2
80 LCDeadMaterial.UseHadProbability =
True
81 LCDeadMaterial.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
83 DMCalib = CaloClusterLocalCalib (
"DMCalib")
84 DMCalib.ClusterRecoStatus = [1,2]
85 DMCalib.LocalCalibTools = [LCDeadMaterial]
87 DMCalib.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
98 CaloClusterMomentsMaker=CompFactory.CaloClusterMomentsMaker
99 TopoMoments = CaloClusterMomentsMaker (
"TopoMoments")
100 TopoMoments.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
102 TopoMoments.MaxAxisAngle = 20*deg
103 TopoMoments.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
104 TopoMoments.MinBadLArQuality = 4000
105 TopoMoments.MomentsNames = [
"FIRST_PHI"
144 if not flags.Common.isOnline:
145 from LArConfiguration.LArElecCalibDBConfig
import LArElecCalibDBCfg
148 TopoMoments.LArHVFraction=CompFactory.LArHVFraction(HVScaleCorrKey=
"LArHVScaleCorr")
150 TopoMoments.LArHVFraction=CompFactory.LArHVFraction(HVScaleCorrKey=
"LArHVScaleCorrRecomputed")
151 TopoMoments.MomentsNames += [
"ENG_BAD_HV_CELLS"
155 TopoMoments.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
157 result.setPrivateTools(TopoMoments)
162 CaloClusterMomentsMaker_DigiHSTruth=CompFactory.CaloClusterMomentsMaker_DigiHSTruth
163 TopoMoments_Truth = CaloClusterMomentsMaker_DigiHSTruth (
"TopoMoments_Truth")
164 TopoMoments_Truth.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
166 TopoMoments_Truth.MaxAxisAngle = 20*deg
167 TopoMoments_Truth.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
168 TopoMoments_Truth.MinBadLArQuality = 4000
169 TopoMoments_Truth.MomentsNames = [
"FIRST_PHI_DigiHSTruth"
170 ,
"FIRST_ETA_DigiHSTruth"
171 ,
"SECOND_R_DigiHSTruth"
172 ,
"SECOND_LAMBDA_DigiHSTruth"
173 ,
"DELTA_PHI_DigiHSTruth"
174 ,
"DELTA_THETA_DigiHSTruth"
175 ,
"DELTA_ALPHA_DigiHSTruth"
176 ,
"CENTER_X_DigiHSTruth"
177 ,
"CENTER_Y_DigiHSTruth"
178 ,
"CENTER_Z_DigiHSTruth"
179 ,
"CENTER_MAG_DigiHSTruth"
180 ,
"CENTER_LAMBDA_DigiHSTruth"
181 ,
"LATERAL_DigiHSTruth"
182 ,
"LONGITUDINAL_DigiHSTruth"
183 ,
"ENG_FRAC_CORE_DigiHSTruth"
184 ,
"FIRST_ENG_DENS_DigiHSTruth"
185 ,
"SECOND_ENG_DENS_DigiHSTruth"
186 ,
"ISOLATION_DigiHSTruth"
187 ,
"BAD_CELLS_CORR_E_DigiHSTruth"
188 ,
"ENG_POS_DigiHSTruth"
189 ,
"SIGNIFICANCE_DigiHSTruth"
190 ,
"CELL_SIGNIFICANCE_DigiHSTruth"
191 ,
"CELL_SIG_SAMPLING_DigiHSTruth"
192 ,
"AVG_LAR_Q_DigiHSTruth"
193 ,
"AVG_TILE_Q_DigiHSTruth"
194 ,
"ENERGY_DigiHSTruth"
198 return TopoMoments_Truth
201 CaloCalibClusterMomentsMaker2=CompFactory.CaloCalibClusterMomentsMaker2
202 TopoCalibMoments = CaloCalibClusterMomentsMaker2 (
"TopoCalibMoments")
203 TopoCalibMoments.MomentsNames = [
"ENG_CALIB_TOT"
209 ,
"ENG_CALIB_DEAD_TOT"
210 ,
"ENG_CALIB_DEAD_EMB0"
211 ,
"ENG_CALIB_DEAD_TILE0"
212 ,
"ENG_CALIB_DEAD_TILEG3"
213 ,
"ENG_CALIB_DEAD_EME0"
214 ,
"ENG_CALIB_DEAD_HEC0"
215 ,
"ENG_CALIB_DEAD_FCAL"
216 ,
"ENG_CALIB_DEAD_LEAKAGE"
217 ,
"ENG_CALIB_DEAD_UNCLASS"
219 ,
"ENG_CALIB_FRAC_HAD"
220 ,
"ENG_CALIB_FRAC_REST"]
222 TopoCalibMoments.CalibrationHitContainerNames = [
"LArCalibrationHitInactive"
223 ,
"LArCalibrationHitActive"
224 ,
"TileCalibHitActiveCell"
225 ,
"TileCalibHitInactiveCell"]
226 TopoCalibMoments.DMCalibrationHitContainerNames = [
"LArCalibrationHitDeadMaterial"
227 ,
"TileCalibHitDeadMaterial"]
228 return TopoCalibMoments
233 TopoMaker = CompFactory.CaloTopoClusterMaker(
"TopoMaker")
235 TopoMaker.CellsName = cellsname
236 TopoMaker.CalorimeterNames=[
"LAREM",
242 TopoMaker.SeedSamplingNames = [
"PreSamplerB",
"EMB1",
"EMB2",
"EMB3",
243 "PreSamplerE",
"EME1",
"EME2",
"EME3",
244 "HEC0",
"HEC1",
"HEC2",
"HEC3",
245 "TileBar0",
"TileBar1",
"TileBar2",
246 "TileExt0",
"TileExt1",
"TileExt2",
247 "TileGap1",
"TileGap2",
"TileGap3",
248 "FCAL0",
"FCAL1",
"FCAL2"]
249 TopoMaker.NeighborOption =
"super3D"
250 TopoMaker.RestrictHECIWandFCalNeighbors =
False
251 TopoMaker.RestrictPSNeighbors =
True
252 TopoMaker.CellThresholdOnEorAbsEinSigma = 0.0
253 TopoMaker.NeighborThresholdOnEorAbsEinSigma = 2.0
254 TopoMaker.SeedThresholdOnEorAbsEinSigma = 4.0
257 TopoMaker.SeedCutsInT = flags.Calo.TopoCluster.doTimeCut
258 TopoMaker.CutOOTseed = flags.Calo.TopoCluster.extendTimeCut
and flags.Calo.TopoCluster.doTimeCut
259 TopoMaker.UseTimeCutUpperLimit = flags.Calo.TopoCluster.useUpperLimitForTimeCut
260 TopoMaker.TimeCutUpperLimit = flags.Calo.TopoCluster.timeCutUpperLimit
261 TopoMaker.XTalkEM2 = flags.Calo.TopoCluster.xtalkEM2
262 TopoMaker.XTalkEM2D = flags.Calo.TopoCluster.xtalkEM2D
263 TopoMaker.XTalkEM2n = flags.Calo.TopoCluster.xtalkEM2n
264 TopoMaker.XTalkEM3 = flags.Calo.TopoCluster.xtalkEM3
265 TopoMaker.XTalkEMEta = flags.Calo.TopoCluster.xtalkEMEta
266 TopoMaker.XTalkDeltaT = flags.Calo.TopoCluster.xtalkDeltaT
267 TopoMaker.XTalk2Eratio1 = flags.Calo.TopoCluster.xtalk2Eratio1
268 TopoMaker.XTalk2Eratio2 = flags.Calo.TopoCluster.xtalk2Eratio2
269 TopoMaker.XTalk3Eratio = flags.Calo.TopoCluster.xtalk3Eratio
270 TopoMaker.XTalkEtaEratio = flags.Calo.TopoCluster.xtalkEtaEratio
271 TopoMaker.XTalk2DEratio = flags.Calo.TopoCluster.xtalk2DEratio
278 TopoMaker.SeedCutsInAbsE =
True
279 TopoMaker.ClusterCutsInAbsEt =
True
280 TopoMaker.ClusterEtorAbsEtCut = 0.0*MeV
282 TopoMaker.TwoGaussianNoise = flags.Calo.TopoCluster.doTwoGaussianNoise
284 TopoMaker.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
286 result.setPrivateTools(TopoMaker)
291 TopoSplitter = CompFactory.CaloTopoClusterSplitter(
"TopoSplitter")
297 TopoSplitter.SamplingNames = [
"EMB2",
"EMB3",
304 TopoSplitter.SecondarySamplingNames = [
"EMB1",
"EME1",
305 "TileBar0",
"TileBar1",
"TileBar2",
306 "TileExt0",
"TileExt1",
"TileExt2",
307 "HEC0",
"HEC1",
"HEC2",
"HEC3",
309 TopoSplitter.ShareBorderCells =
True
310 TopoSplitter.RestrictHECIWandFCalNeighbors =
False
311 TopoSplitter.WeightingOfNegClusters = flags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
313 TopoSplitter.UseGPUCriteria = flags.Calo.TopoCluster.UseGPUCompatibleCriteria
315 result.setPrivateTools(TopoSplitter)
318 def CaloTopoClusterCfg(flags, cellsname="AllCalo", clustersname=None, clustersnapname="CaloTopoClusters"):
320 Configures topo clustering
322 If output writing is enabled (ESD,AOD) the topo clusters are added to them
325 doLCCalib = flags.Calo.TopoCluster.doTopoClusterLocalCalib
327 if clustersname
is None:
328 clustersname =
"CaloCalTopoClusters" if doLCCalib
else "CaloTopoClusters"
331 if clustersname==
"CaloTopoClusters" and doLCCalib
is True:
332 raise RuntimeError(
"Inconsistent arguments: Name must not be 'CaloTopoClusters' if doLCCalib is True")
336 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
337 from TileGeoModel.TileGMConfig
import TileGMCfg
338 from CaloTools.CaloNoiseCondAlgConfig
import CaloNoiseCondAlgCfg
344 CaloClusterMaker, CaloClusterSnapshot=CompFactory.getComps(
"CaloClusterMaker",
"CaloClusterSnapshot",)
361 CaloTopoCluster.ClustersOutputName=clustersname
363 CaloTopoCluster.ClusterMakerTools = [TopoMaker, TopoSplitter]
365 from CaloBadChannelTool.CaloBadChanToolConfig
import CaloBadChanToolCfg
367 CaloClusterBadChannelList=CompFactory.CaloClusterBadChannelList
369 CaloTopoCluster.ClusterCorrectionTools += [BadChannelListCorr]
372 CaloTopoCluster.ClusterCorrectionTools += [momentsMaker]
374 if flags.Calo.TopoCluster.doCalibHitMoments:
376 CaloTopoCluster.ClusterCorrectionTools += [calibHitsMomentsMaker]
379 theCaloClusterSnapshot=
CaloClusterSnapshot(OutputName=clustersnapname,SetCrossLinks=
True,FinalClusterContainerName=clustersname)
380 CaloTopoCluster.ClusterCorrectionTools += [theCaloClusterSnapshot]
384 from CaloRec.CaloTopoClusterConfig
import caloTopoCoolFolderCfg
388 result.addEventAlgo(CaloTopoCluster,primary=
True)
390 if CaloTopoCluster.ClustersOutputName
in flags.Calo.TopoCluster.skipWriteList:
396 AODMoments=[
"SECOND_R"
415 if flags.Calo.TopoCluster.writeExtendedClusterMoments:
416 AODMoments += [
"LATERAL"
422 if flags.Reco.EnableHI:
423 AODMoments += [
"CELL_SIG_SAMPLING"]
425 if flags.Calo.TopoCluster.writeCalibHitClusterMoments:
426 AODMoments += [
"ENG_CALIB_TOT"
432 ,
"ENG_CALIB_DEAD_TOT"
433 ,
"ENG_CALIB_DEAD_EMB0"
434 ,
"ENG_CALIB_DEAD_TILE0"
435 ,
"ENG_CALIB_DEAD_TILEG3"
436 ,
"ENG_CALIB_DEAD_EME0"
437 ,
"ENG_CALIB_DEAD_HEC0"
438 ,
"ENG_CALIB_DEAD_FCAL"
439 ,
"ENG_CALIB_DEAD_LEAKAGE"
440 ,
"ENG_CALIB_DEAD_UNCLASS"
442 ,
"ENG_CALIB_FRAC_HAD"
443 ,
"ENG_CALIB_FRAC_REST"]
446 from OutputStreamAthenaPool.OutputStreamConfig
import addToAOD, addToESD
447 toESD = [f
"xAOD::CaloClusterContainer#{CaloTopoCluster.ClustersOutputName}",
448 f
"xAOD::CaloClusterAuxContainer#{CaloTopoCluster.ClustersOutputName}Aux.-sigmaWidth",
449 f
"CaloClusterCellLinkContainer#{CaloTopoCluster.ClustersOutputName}_links"]
450 toAOD = [f
"xAOD::CaloClusterContainer#{CaloTopoCluster.ClustersOutputName}",
451 f
"CaloClusterCellLinkContainer#{CaloTopoCluster.ClustersOutputName}_links"]
453 AODMoments.append(
"CellLink")
454 if flags.Calo.TopoCluster.addCalibrationHitDecoration:
455 AODMoments.append(flags.Calo.TopoCluster.CalibrationHitDecorationName)
457 if flags.Calo.TopoCluster.addCPData:
458 AODMoments += [
"ClusterWidthEta",
"ClusterWidthPhi"]
460 auxItems = f
"xAOD::CaloClusterAuxContainer#{CaloTopoCluster.ClustersOutputName}Aux."
461 auxItems+=
".".
join(AODMoments)
463 toAOD.append(auxItems)
465 result.merge(
addToESD(flags, toESD))
466 result.merge(
addToAOD(flags, toAOD))
471 from AthenaCommon.Logging
import logging
472 mlog = logging.getLogger(
'CaloTopoClusterConfig:addSnapshot')
473 corrTools=topomaker.ClusterCorrectionTools
477 newCorrTools.append(t)
478 if (t.getName()==corrName):
479 newSnapshot=CompFactory.CaloClusterSnapshot(
"Snapshot_"+corrName,OutputName=contName,FinalClusterContainerName=topomaker.ClustersOutputName)
480 newCorrTools.append(newSnapshot)
483 mlog.error(
"Did not find cluster correction tool %s", corrName)
485 mlog.info(
"Added cluster snapshot after correction tool %s", corrName)
486 topomaker.ClusterCorrectionTools = newCorrTools
487 topomaker.ClusterCorrectionTools += [newSnapshot]
493 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
495 from AthenaConfiguration.TestDefaults
import defaultTestFiles
496 flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
497 flags.Output.ESDFileName=
"esdOut.pool.root"
498 flags.Exec.MaxEvents = 10
503 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
506 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
510 topoAlg = topoAcc.getPrimary()
511 topoAlg.ClustersOutputName =
"CaloCalTopoClustersNew"
514 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
515 cfg.merge(
OutputStreamCfg(flags,
"xAOD", ItemList = [
"xAOD::CaloClusterContainer#CaloCalTopoClusters*",
516 "xAOD::CaloClusterAuxContainer#*CaloCalTopoClusters*Aux.",
519 ThinNegativeEnergyCaloClustersAlg=CompFactory.ThinNegativeEnergyCaloClustersAlg
521 "ThinNegativeEnergyCaloClustersAlg",
522 CaloClustersKey=topoAlg.ClustersOutputName,
523 ThinNegativeEnergyCaloClusters =
True,
524 StreamName =
'StreamAOD'
526 cfg.addEventAlgo(theNegativeEnergyCaloClustersThinner,
"AthAlgSeq")
528 cfg.addEventAlgo(CompFactory.ClusterDumper(
"TopoDumper",ContainerName=topoAlg.ClustersOutputName,FileName=
"NewTopoClusters.txt"),sequenceName=
"AthAlgSeq")
532 if __name__==
"__main__":