12 if vxContName2 == vxContName1 :
return vxContName1
13 if "" in [vxContName1, vxContName2] :
return vxContName1
or vxContName2
14 raise Exception(
" Error : incompatible VertexContainerName of 2 instance of TrackParticleClusterAssociationAlg : '{}' and '{}'".format(vxContName1, vxContName2))
33def setupTrackCaloAssoc(flags, caloClusterName="CaloCalTopoClusters",detectorEtaName="default",trackParticleName="InDetTrackParticles", assocPostfix = "TCC", onlyPV0Tracks=False):
34 """ Schedule a TrackParticleClusterAssociationAlg in the top sequence, taking as input clusters and tracks defined
35 by the keys caloClusterName and trackParticleName.
37 onlyPV0Tracks : calculate associated clusters only for PV0 tracks. Avoids unnecessary calculation (used in the UFO case).
38 (IMPORTANT CaloExtensionBuilderAlg does extrapolate all tracks : if too much time consuming, it needs a new option to mask non-PV0 tracks)
43 components = ComponentAccumulator()
45 from TrackToCalo.CaloExtensionBuilderAlgCfg
import CaloExtensionBuilderAlgCfg
47 caloExtAlg.TrkPartContainerName = trackParticleName
49 components.merge(caloExtAlg)
51 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig
import TTVAToolCfg
52 TrackVertexAssoTool = components.popToolsAndMerge(
53 TTVAToolCfg(flags,
"tvaTool", WorkingPoint=
"Nonprompt_All_MaxWeight"))
55 trackParticleClusterAssociation = CompFactory.TrackParticleClusterAssociationAlg(
56 "TrackParticleClusterAssociationAlg"+assocPostfix,
58 TrackParticleContainerName = trackParticleName,
60 CaloExtensionName = (caloExtAlg.getEventAlgos()[0]).ParticleCache,
61 CaloClusterLocation = caloClusterName,
62 DetectorEtaName = detectorEtaName
if detectorEtaName.lower() !=
"default" else (
"DetectorEta" if "Origin" in caloClusterName
else ""),
63 TrackVertexAssoTool=TrackVertexAssoTool,
64 VertexContainerName =
"PrimaryVertices" if onlyPV0Tracks
else "",
66 AssociatedClusterDecorKey =
"AssoClusters"+assocPostfix,
67 UseCovariance = flags.UFO.UseCov,
68 DeltaR = flags.UFO.dR,
73 components.addEventAlgo( trackParticleClusterAssociation )
78def runTCCReconstruction(flags, caloClusterName="CaloCalTopoClusters", detectorEtaName = "default", trackParticleName="InDetTrackParticles",
79 assocPostfix="TCC", doCombined=False, doCharged=False, doNeutral=True, outputTCCName="TrackCaloClusters"):
81 Create a TrackCaloCluster collection from clusters and tracks (caloClusterName and trackParticleName).
82 Depending on options, the collection contains combined, neutral and/or charged TCC.
83 This functions schedules 2 TCC specific algs :
84 * a TrackCaloClusterInfoAlg to build the TrackCaloClusterInfo object
85 * a TrackCaloClusterAlg to build the TCC
88 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
92 components = ComponentAccumulator()
95 setupTrackCaloAssoc(flags, caloClusterName, detectorEtaName, trackParticleName, assocPostfix, onlyPV0Tracks=
False)
100 tccInfoAlg = CompFactory.TrackCaloClusterInfoAlg(
102 TCCInfoName =
"TCCInfo",
103 InputTracks = trackParticleName,
104 InputClusters = caloClusterName,
105 VertexContainer =
"PrimaryVertices",
106 AssoClustersDecor = decorKey(
"AssoClusters"),
109 components.addEventAlgo( tccInfoAlg)
116 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig
import TTVAToolCfg
118 TrackVertexAssoTool = components.popToolsAndMerge(
119 TTVAToolCfg(flags,
"tvaTool",WorkingPoint=
"Nonprompt_All_MaxWeight")),
120 AssoClustersDecor=decorKey(
"AssoClusters"),
124 tccCombined = CompFactory.TCCCombinedTool(
"TCCcombined", **commonArgs)
125 tccTools.append(tccCombined)
127 tccCharged = CompFactory.TCCChargedTool(
"TCCCharged", **commonArgs )
128 tccTools.append(tccCharged)
130 tccNeutral = CompFactory.TCCNeutralTool(
"TCCNeutral", **commonArgs )
131 tccTools.append(tccNeutral)
133 tccAlg = CompFactory.TrackCaloClusterAlg(name =
"TrackCaloClusterAlg",
134 OutputTCCName = outputTCCName,
139 components.addEventAlgo(tccAlg)
144def runUFOReconstruction(flags, constits, caloClusterName="CaloCalTopoClusters", detectorEtaName = "default", assocPostfix="UFO", inputFEcontainerkey=""):
146 """Create a UFO collection from PFlow and tracks (PFO retrieved from PFOPrefix and tracks directly from trackParticleName).
147 This functions schedules 2 UFO specific algs :
148 * a TrackCaloClusterInfoUFOAlg to build the TrackCaloClusterInfo object
149 * a TrackCaloClusterAlg to build the UFO
151 from JetRecConfig.JetDefinition
import JetDefinition
152 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
153 components=ComponentAccumulator()
155 if isinstance(constits, JetDefinition):
157 constits = jdef.inputdef
158 trackParticleName = jdef._contextDic[
'Tracks']
160 trackParticleName =
"InDetTrackParticles"
162 pfoVariant= constits.label.split(
"PFlow")[-1]
169 setupTrackCaloAssoc(flags, caloClusterName, detectorEtaName, trackParticleName, assocPostfix, onlyPV0Tracks=
False)
173 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig
import TTVAToolCfg
175 TrackVertexAssoTool = components.popToolsAndMerge(
176 TTVAToolCfg(flags,
"tvaTool",WorkingPoint=
"Nonprompt_All_MaxWeight")),
177 AssoClustersDecor=decorKey(
"AssoClusters"),
181 inputFEcontainerkey = inputFEcontainerkey
or constits.containername
184 UFOInfoAlg = CompFactory.TrackCaloClusterInfoUFOAlg(f
"UFOInfoAlg{pfoVariant}",
185 TCCInfoName = pfoVariant+
"UFOInfo",
186 InputTracks = trackParticleName,
187 InputClusters = caloClusterName,
188 VertexContainer =
"PrimaryVertices",
189 InputPFO=inputFEcontainerkey,
190 OriginPFO=
'originalObjectLink',
196 components.addEventAlgo( UFOInfoAlg)
198 tccUFO = CompFactory.UFOTool(f
"UFOtool{pfoVariant}",
199 ClusterECut = UFOInfoAlg.ClusterECut,
200 InputPFO=inputFEcontainerkey,
201 OriginPFO=
'originalObjectLink',
205 UFOAlg = CompFactory.TrackCaloClusterAlg(name = f
"TrackCaloClusterAlgUFO{pfoVariant}",
206 OutputTCCName = f
"UFO{pfoVariant}",
207 TCCInfo = UFOInfoAlg.TCCInfoName ,
208 TCCTools = [tccUFO,],
213 components.addEventAlgo( UFOAlg)
runTCCReconstruction(flags, caloClusterName="CaloCalTopoClusters", detectorEtaName="default", trackParticleName="InDetTrackParticles", assocPostfix="TCC", doCombined=False, doCharged=False, doNeutral=True, outputTCCName="TrackCaloClusters")