Skip to content
Snippets Groups Projects
Commit d28cf905 authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'feature/TCClinkingtoFE' into 'master'

TrackCaloCluster links to Muons/Electrons/Photons

See merge request atlas/athena!44717
parents 3e2c18fb bec3532b
No related branches found
No related tags found
No related merge requests found
......@@ -135,7 +135,8 @@ def setupTrackCaloAssoc(configFlags, caloClusterName="CaloCalTopoClusters",track
TrackVertexAssoTool=setupTrackVertexAssocTool(), # will associate trks from PV0 only
VertexContainerName = "PrimaryVertices" if onlyPV0Tracks else "",
AssociatedClusterDecorKey = decorKey("AssoClusters"),
OutputLevel=2)
# OutputLevel=2
)
components.addEventAlgo( trackParticleClusterAssociation )
......@@ -205,26 +206,26 @@ def runTCCReconstruction(configFlags, caloClusterName="CaloCalTopoClusters",trac
FEContainerName=""
if(doNeutral):
FEContainerName="JetETMissNeutralFlowElements"
FEContainerName="JetETMissNeutralParticleFlowObjects"
neutraloutputTCCName=outputTCCName+"Neutral"
neutraltccAlg = CompFactory.TrackCaloClusterAlg(name = "TrackCaloClusterAlg_neutral",
OutputTCCName = neutraloutputTCCName,
TCCInfo = "TCCInfo",
TCCTools = tccTools,
OutputLevel = 2,
#OutputLevel
AppendToTCCName = FEContainerName
)
components.addEventAlgo(neutraltccAlg)
if(doCharged):
FEContainerName="JetETMissChargedFlowElements"
FEContainerName="JetETMissChargedParticleFlowObjects"
chargedoutputTCCName=outputTCCName+"Charged"
chargedtccAlg = CompFactory.TrackCaloClusterAlg(name = "TrackCaloClusterAlg_charged",
OutputTCCName = chargedoutputTCCName,
TCCInfo = "TCCInfo",
TCCTools = tccTools,
OutputLevel = 2,
#OutputLevel = 2,
AppendToTCCName = FEContainerName
)
components.addEventAlgo(chargedtccAlg)
......
......@@ -62,11 +62,13 @@ private:
SG::WriteDecorHandleKey<xAOD::ElectronContainer> m_electronChargedFEWriteDecorKey{this,"ElectronChargedFEDecorKey","Electrons.chargedFELinks","Output key for electron link to charged FE"};
/** The write key for adding electron element link decorations to Neutral Flow Elements */
SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_neutralFEElectronWriteDecorKey{this,"NeutralFEElectronDecorKey","JetETMissNeutralParticleFlowObjects.FE_ElectronLinks","Output key for link from charged FE to electron"};
/** The write key for adding electron element link decorations to Charged Flow Elements */
SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_chargedFEElectronWriteDecorKey{this,"ChargedFEElectronDecorKey","JetETMissChargedParticleFlowObjects.FE_ElectronLinks","Output key for link from charged FE to electron"};
/** The write key for adding Neutral Flow Element element link decorations to photons */
SG::WriteDecorHandleKey<xAOD::PhotonContainer> m_photonNeutralFEWriteDecorKey{this,"PhotonNeutralFEDecorKey","Photons.neutralFELinks","Output key for photon link to neutral FE"};
/** The write key for adding Charged Flow Element element link decorations to photons */
......
......@@ -176,7 +176,7 @@ def getNeutralFlowElementCreatorAlgorithm(inputFlags,neutralFlowElementOutputNam
return FlowElementNeutralCreatorAlgorithm
def getEGamFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_FE_cont_name="",AODTest=False):
def getEGamFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_FE_cont_name="",AODTest=False,doTCC=False):
PFEGamFlowElementLinkerAlgorithmFactory=CompFactory.PFEGamFlowElementAssoc
PFEGamFlowElementLinkerAlgorithm=PFEGamFlowElementLinkerAlgorithmFactory("PFEGamFlowElementAssoc")
......@@ -202,7 +202,6 @@ def getEGamFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_
EL_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey)
PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey=EL_CFE_Link.replace("FELinks","CustomFELinks")
NFE_EL_Link=str(PFEGamFlowElementLinkerAlgorithm.NeutralFEElectronDecorKey)
PFEGamFlowElementLinkerAlgorithm.NeutralFEElectronDecorKey=NFE_EL_Link.replace("FE","CustomFE")
......@@ -222,11 +221,41 @@ def getEGamFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_
CFE_PH_Link=str(PFEGamFlowElementLinkerAlgorithm.ChargedFEPhotonDecorKey)
PFEGamFlowElementLinkerAlgorithm.ChargedFEPhotonDecorKey=CFE_PH_Link.replace("FE","CustomFE")
if(doTCC):
# ReadHandles to change
PFEGamFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer="TrackCaloClustersNeutral"
PFEGamFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer="TrackCaloClustersCharged"
#Now to change the writeHandles
# first the Electron -> FE links
EL_NFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronNeutralFEDecorKey)
PFEGamFlowElementLinkerAlgorithm.ElectronNeutralFEDecorKey=EL_NFE_Link.replace("FELinks","TCCLinks")
EL_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey)
PFEGamFlowElementLinkerAlgorithm.ElectronChargedFEDecorKey=EL_CFE_Link.replace("FELinks","TCCLinks")
#then the converse case (FE -> Electron)
PFEGamFlowElementLinkerAlgorithm.ChargedFEElectronDecorKey="TrackCaloClustersCharged.TCC_ElectronLinks"
PFEGamFlowElementLinkerAlgorithm.NeutralFEElectronDecorKey="TrackCaloClustersNeutral.TCC_ElectronLinks"
# first the Photon -> FE links
PH_NFE_Link=str(PFEGamFlowElementLinkerAlgorithm.PhotonNeutralFEDecorKey)
PFEGamFlowElementLinkerAlgorithm.PhotonNeutralFEDecorKey=PH_NFE_Link.replace("FELinks","TCCLinks")
PH_CFE_Link=str(PFEGamFlowElementLinkerAlgorithm.PhotonChargedFEDecorKey)
PFEGamFlowElementLinkerAlgorithm.PhotonChargedFEDecorKey=PH_CFE_Link.replace("FELinks","TCCLinks")
#then the converse case (FE -> Photons)
PFEGamFlowElementLinkerAlgorithm.ChargedFEPhotonDecorKey="TrackCaloClustersCharged.TCC_PhotonLinks"
PFEGamFlowElementLinkerAlgorithm.NeutralFEPhotonDecorKey="TrackCaloClustersNeutral.TCC_PhotonLinks"
return PFEGamFlowElementLinkerAlgorithm
def getMuonFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_FE_cont_name="",LinkNeutralFEClusters=True,useMuonTopoClusters=False,AODTest=False):
def getMuonFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_FE_cont_name="",LinkNeutralFEClusters=True,useMuonTopoClusters=False,AODTest=False,doTCC=False):
PFMuonFlowElementLinkerAlgorithmFactory=CompFactory.PFMuonFlowElementAssoc
PFMuonFlowElementLinkerAlgorithm=PFMuonFlowElementLinkerAlgorithmFactory("PFMuonFlowElementAssoc")
......@@ -239,37 +268,71 @@ def getMuonFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_
#update the readhandle
PFMuonFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer=neutral_FE_cont_name
#update the write handle for the link
if(charged_FE_cont_name!=""):
PFMuonFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer=charged_FE_cont_name
PFMuonFlowElementLinkerAlgorithm.m_LinkNeutralFEClusters=LinkNeutralFEClusters
PFMuonFlowElementLinkerAlgorithm.m_UseMuonTopoClusters=useMuonTopoClusters
#prototype on AOD with the linkers already defined - so need to rename the output links to something besides their default name.
if(AODTest):
# use same Gaudi trick to rename the container input name.
# use same Gaudi trick to rename the container input name.
MuonFELink=str(PFMuonFlowElementLinkerAlgorithm.MuonContainer_chargedFELinks)
PFMuonFlowElementLinkerAlgorithm.MuonContainer_chargedFELinks=MuonFELink.replace("FELinks","CustomFELinks")
PFMuonFlowElementLinkerAlgorithm.MuonContainer_neutralFELinks=str(PFMuonFlowElementLinkerAlgorithm.MuonContainer_neutralFELinks).replace("FELinks","CustomFELinks")
PFMuonFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer_FE_MuonLinks=str(PFMuonFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer_FE_MuonLinks).replace("MuonLinks","CustomMuonLinks")
PFMuonFlowElementLinkerAlgorithm.JetETMissChargedFlowElements_FE_MuonLinks=str(PFMuonFlowElementLinkerAlgorithm.JetETMissChargedFlowElements_FE_MuonLinks).replace("MuonLinks","CustomMuonLinks")
# and because debug info is also written, need to rename each handle for this too.... - might want to change this in future/re-work it so that a rename -> no debug info saved by default.
PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_FE_efrac_matched_muon=str(PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_FE_efrac_matched_muon).replace("FE","CustomFE")
PFMuonFlowElementLinkerAlgorithm.MuonContainer_muon_efrac_matched_FE=str(PFMuonFlowElementLinkerAlgorithm.MuonContainer_muon_efrac_matched_FE).replace("FE","CustomFE")
PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_nMatchedMuons=str(PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_nMatchedMuons).replace("FE","CustomFE")
#Track Calo cluster (TCC) specific configuration. Input is differently named FE container, and in the AOD step specifically
if(doTCC):
#input containers are TrackCaloClustersCharged and TrackCaloClustersNeutral, so rename them
#service_key="StoreGateSvc+"
service_key=""
PFMuonFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer=service_key+"TrackCaloClustersCharged"
PFMuonFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer=service_key+"TrackCaloClustersNeutral"
#Output
#rename the FE_MuonLinks as TCC_MuonLinks
#rename output containers
PFMuonFlowElementLinkerAlgorithm.MuonContainer_chargedFELinks=service_key+"Muons.chargedTCCLinks"
PFMuonFlowElementLinkerAlgorithm.MuonContainer_neutralFELinks=service_key+"Muons.neutralTCCLinks"
PFMuonFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer_FE_MuonLinks=service_key+"TrackCaloClustersNeutral.TCC_MuonLinks"
PFMuonFlowElementLinkerAlgorithm.JetETMissChargedFlowElements_FE_MuonLinks=service_key+"TrackCaloClustersCharged.TCC_MuonLinks"
# several variables relating to Neutral Flow Elements/TCCs to Muons for debug. perhaps at some point these should be removed by default
PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_nMatchedMuons="TrackCaloClustersNeutral.TCC_nMatchedMuons"
PFMuonFlowElementLinkerAlgorithm.FlowElementContainer_FE_efrac_matched_muon="TrackCaloClustersNeutral.TCC_efrac_matched_muon"
PFMuonFlowElementLinkerAlgorithm.MuonContainer_muon_efrac_matched_FE="Muons.muon_efrac_matched_TCC"
# this is because the algorithm adds this debug container which we don't need
PFMuonFlowElementLinkerAlgorithm.MuonContainer_ClusterInfo_deltaR="Muons.deltaR_muon_clus_TCCalg"
if(LinkNeutralFEClusters):
if (doTCC or AODTest):
# since the cells are deleted on AOD, if you try to run the link between NFE and Muon on AOD, it will crash. Terminate to catch this.
# This is a known bug to rectify soon
from AthenaCommon.Logging import logging
msg=logging.getLogger("PFCfg.py::getMuonFlowElementAssocAlgorithm")
msg.error("Neutral FE from AOD configured to be linked with Muon. This link will fail due to missing CaloCells in the AOD")
msg.info("Terminating job")
exit(0)
return PFMuonFlowElementLinkerAlgorithm
return PFMuonFlowElementLinkerAlgorithm
def getTauFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_FE_cont_name="",AODTest=False) :
def getTauFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_FE_cont_name="",AODTest=False,doTCC=False) :
PFTauFlowElementLinkerAlgorithmFactory=CompFactory.PFTauFlowElementAssoc
PFTauFlowElementLinkerAlgorithm=PFTauFlowElementLinkerAlgorithmFactory("PFTauFlowElementAssoc")
......@@ -280,10 +343,10 @@ def getTauFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_F
#setting algorithm.SpecificContainerName="myNewContainerName" changes parameter "myContainerName"
#(also applies to ReadHandles)
if(neutral_FE_cont_name!=""):
PFTauFlowElementLinkerAlgorithm.JetEtMissNeutralFlowElementContainer=neutral_FE_cont_name
PFTauFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer=neutral_FE_cont_name
if(charged_FE_cont_name!=""):
PFTauFlowElementLinkerAlgorithm.JetEtMissChargedFlowElementContainer=charged_FE_cont_name
PFTauFlowElementLinkerAlgorithm.JetETMissChargedFlowElementContainer=charged_FE_cont_name
if(AODTest):
TAU_NFE_Link=str(PFTauFlowElementLinkerAlgorithm.TauNeutralFEDecorKey)
......@@ -298,4 +361,17 @@ def getTauFlowElementAssocAlgorithm(inputFlags,neutral_FE_cont_name="",charged_F
CFE_TAU_Link=str(PFTauFlowElementLinkerAlgorithm.ChargedFETauDecorKey)
PFTauFlowElementLinkerAlgorithm.ChargedFETauDecorKey=CFE_TAU_Link.replace("FE","CustomFE")
if(doTCC):
PFTauFlowElementLinkerAlgorithm.JetETMissNeutralFlowElementContainer="TrackCaloClustersNeutral"
PFTauFlowElementLinkerAlgorithm.JetETMissChargedFlowElementContainer="TrackCaloClustersCharged"
PFTauFlowElementLinkerAlgorithm.TauNeutralFEDecorKey="TauJets.neutralTCCLinks"
PFTauFlowElementLinkerAlgorithm.TauChargedFEDecorKey="TauJets.chargedTCCLinks"
PFTauFlowElementLinkerAlgorithm.NeutralFETauDecorKey="TrackCaloClustersNeutral.TCC_TauLinks"
PFTauFlowElementLinkerAlgorithm.ChargedFETauDecorKey="TrackCaloClustersCharged.TCC_TauLinks"
return PFTauFlowElementLinkerAlgorithm
......@@ -140,6 +140,10 @@ def PFCfg(inputFlags,**kwargs):
result.addEventAlgo(getChargedFlowElementCreatorAlgorithm(inputFlags,""))
result.addEventAlgo(getNeutralFlowElementCreatorAlgorithm(inputFlags,""))
from eflowRec.PFCfg import getMuonFlowElementAssocAlgorithm,getEGamFlowElementAssocAlgorithm
result.addEventAlgo(getMuonFlowElementAssocAlgorithm(inputFlags))
result.addEventAlgo(getEGamFlowElementAssocAlgorithm(inputFlags))
return result
if __name__=="__main__":
......
#Matt A's custom python accumulator for R22
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
from pprint import pprint
def MyAlgConfigNeutral(inputFlags,**kwargs,):
# this is based on the PFRun3Config, so parts of it are gonna be used as is
result=ComponentAccumulator()
StoreGateSvc=CompFactory.StoreGateSvc
result.addService(StoreGateSvc("DetectorStore"))
from TrackCaloClusterRecTools.TrackCaloClusterConfig import runTCCReconstruction
TCCReco=runTCCReconstruction(inputFlags, outputTCCName="TrackCaloClusters",doNeutral=True,doCharged=False,doCombined=False)
result.merge(TCCReco)
StoreGateSvc.Dump = True
return result
def MyAlgConfigCharged(inputFlags,**kwargs,):
# this is based on the PFRun3Config, so parts of it are gonna be used as is
result=ComponentAccumulator()
StoreGateSvc=CompFactory.StoreGateSvc
result.addService(StoreGateSvc("DetectorStore"))
from TrackCaloClusterRecTools.TrackCaloClusterConfig import runTCCReconstruction
TCCReco=runTCCReconstruction(inputFlags, outputTCCName="TrackCaloClusters",doNeutral=False,doCharged=True,doCombined=False)
result.merge(TCCReco)
StoreGateSvc.Dump = True
return result
def LinkerAlgConfig(inputFlags,**kwargs):
#link El/Phot/Muon to TrackCaloClusters
CA=ComponentAccumulator()
StoreGateSvc=CompFactory.StoreGateSvc
CA.addService(StoreGateSvc("DetectorStore"))
from eflowRec.PFCfg import getEGamFlowElementAssocAlgorithm
from eflowRec.PFCfg import getMuonFlowElementAssocAlgorithm
CA.addEventAlgo(getEGamFlowElementAssocAlgorithm(inputFlags,AODTest=False,doTCC=True))
CA.addEventAlgo(getMuonFlowElementAssocAlgorithm(inputFlags,LinkNeutralFEClusters=False,useMuonTopoClusters=True,AODTest=False,doTCC=True))
return CA
def TauLinkerConfig(inputFlags, **kwargs):
#separate linker, can merge to main one for no loss of generality
TauLinkerCA=ComponentAccumulator()
# add Storegate
StoreGateSvc=CompFactory.StoreGateSvc
TauLinkerCA.addService(StoreGateSvc("DetectorStore"))
from eflowRec.PFCfg import getTauFlowElementAssocAlgorithm
TauLinkerCA.addEventAlgo(getTauFlowElementAssocAlgorithm(inputFlags,doTCC=True))
return TauLinkerCA
if __name__=="__main__":
#the "standard" main loop for Athena R22
from AthenaCommon.Configurable import Configurable
Configurable.configurableRun3Behavior = True
from AthenaConfiguration.AllConfigFlags import ConfigFlags as cfgFlags
cfgFlags.Input.isMC=True
cfgFlags.Input.Format="AOD"
cfgFlags.Input.Files=["/scratch/anthony/GPF_CODE/TCC_STUDIES/CustomAlg/myAOD.root"]
cfgFlags.Output.AODFileName="/scratch/anthony/GPF_CODE/TCC_STUDIES/CustomAlg/output_AOD.root"
cfgFlags.Exec.MaxEvents=20
cfgFlags.Output.doWriteAOD=True
cfgFlags.Common.ProductionStep=""
cfgFlags.dump()
cfgFlags.lock()
from AthenaConfiguration.MainServicesConfig import MainServicesCfg
cfg=MainServicesCfg(cfgFlags)
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
inputList=["xAOD::TrackParticleContainer#InDetTrackParticles", "xAOD::TrackParticleAuxContainer#InDetTrackParticlesAux."]
inputList.append("xAOD::FlowElementContainer#JetETMissChargedParticleFlowObjects")
inputList.append("xAOD::FlowElementContainer#JetETMissNeutralParticleFlowObjects")
inputList.append("xAOD::FlowElementAuxContainer#JetETMissNeutralParticleFlowObjectsAux.")
inputList.append("xAOD::FlowElementAuxContainer#JetETMissChargedParticleFlowObjectsAux.")
inputList.append("xAOD::FlowElementContainer#TrackCaloClustersCharged")
inputList.append("xAOD::FlowElementAuxContainer#TrackCaloClustersChargedAux.")
inputList.append("xAOD::FlowElementContainer#TrackCaloClustersNeutral")
inputList.append("xAOD::FlowElementAuxContainer#TrackCaloClustersNeutralAux.")
inputList.append("xAOD::MuonContainer#Muons")
inputList.append("xAOD::MuonAuxContainer#*")
inputList.append("xAOD::PhotonContainer#Photons")
inputList.append("xAOD::PhotonAuxContainer#*")
inputList.append("xAOD::ElectronContainer#Electrons")
inputList.append("xAOD::ElectronAuxContainer#*")
inputList.append("xAOD::TauJetContainer#*")
inputList.append("xAOD::TauJetAuxContainer#*")
cfg.merge(OutputStreamCfg(cfgFlags,"AOD",ItemList=inputList))
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
cfg.merge(PoolReadCfg(cfgFlags))
cfg.merge(MyAlgConfigNeutral(cfgFlags))
cfg.merge(MyAlgConfigCharged(cfgFlags))
cfg.merge(LinkerAlgConfig(cfgFlags)) # El/Phot/Muon linkers
#cfg.merge(TauLinkerConfig(cfgFlags)) # Doesn't yet work because of "passTauThinning" attrib not saved at AOD
print("MASTER CA CONFIG")
print(cfg)
cfg.printConfig()
cfg.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment