diff --git a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py deleted file mode 100644 index 9baab1e9fad5fd68b578ec3cb71337499dc53211..0000000000000000000000000000000000000000 --- a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoAODFixGetter.py +++ /dev/null @@ -1,230 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -from AthenaCommon.Constants import INFO -from AthenaCommon.AppMgr import ToolSvc -from AthenaCommon.Logging import logging -from RecExConfig.RecFlags import rec - -from egammaRec.Factories import ToolFactory, AlgFactory, getPropertyValue - -#--------------------------------------- - -# tool to collect topo clusters in cone -from ParticlesInConeTools.ParticlesInConeToolsConf import xAOD__CaloClustersInConeTool -CaloClustersInConeTool = ToolFactory(xAOD__CaloClustersInConeTool, - CaloClusterLocation = "CaloCalTopoClusters") - -# configuration for ED computation -def configureEDCorrection(tool): - """Configure tools and algorithm for energy density correction - (only if doEnergyDensityCorrection = True)""" - # Return if doEnergyDensityCorrection is false - if not getPropertyValue(tool, 'doEnergyDensityCorrection'): - return - # Set OutputLevel to INFO or higher if tool has it too - OutputLevel = min(getPropertyValue(tool, 'OutputLevel'), INFO) - try: - from AthenaCommon.AppMgr import ToolSvc - from AthenaCommon.AlgSequence import AlgSequence - from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg - from JetRec.JetRecStandard import jtm - topSequence = AlgSequence() - if not hasattr(topSequence,'EDtpIsoVeryForwardAlg'): - tfcc = configEventDensityTool("EDtpIsoVeryForwardTool", - inputlabel = jtm.emget.Label, - radius = 0.5, - AbsRapidityMin = 2.5, - AbsRapidityMax = 4.5, - OutputContainer = "TopoClusterIsoVeryForwardEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tfcc - topSequence += EventDensityAlg("EDtpIsoVeryForwardAlg", EventDensityTool = tfcc) - - except Exception: - print '\nERROR: could not get handle to ED' - raise - -from CaloIdentifier import SUBCALO -from IsolationTool.IsolationToolConf import xAOD__CaloIsolationTool, xAOD__TrackIsolationTool -CaloIsolationTool = ToolFactory(xAOD__CaloIsolationTool,name = "CaloIsolationTool", - postInit = [configureEDCorrection], - CaloFillRectangularClusterTool = None, - ClustersInConeTool = CaloClustersInConeTool, - PFlowObjectsInConeTool = None, - IsoLeakCorrectionTool = None, - saveOnlyRequestedCorrections = True, - EMCaloNums = [], - HadCaloNums = [], - UseEMScale = True, - addCaloExtensionDecoration = False, - OutputLevel = 3) - -TrackIsolationTool = ToolFactory(xAOD__TrackIsolationTool, name = 'TrackIsolationTool') -from AthenaCommon import CfgMgr -tit = CfgMgr.xAOD__TrackIsolationTool('TrackIsolationTool') -tit.TrackSelectionTool.maxZ0SinTheta = 3 -tit.TrackSelectionTool.minPt = 1000 -tit.TrackSelectionTool.CutLevel = "Loose" - -import ROOT, cppyy -# Need to be sure base dict is loaded first. -cppyy.loadDictionary('xAODCoreRflxDict') -cppyy.loadDictionary('xAODPrimitivesDict') -isoPar = ROOT.xAOD.Iso - -# The types to be computed -IsoTypesEg = [ - [ isoPar.ptcone40, - isoPar.ptcone30, - isoPar.ptcone20 ] - ] -IsoTypesFe = [ - [ isoPar.topoetcone20, - isoPar.topoetcone30, - isoPar.topoetcone40 ] - ] -IsoTypesMu = [ - [ isoPar.topoetcone20, - isoPar.topoetcone30, - isoPar.topoetcone40 ] - ] -# And the corrections -IsoCorEg = [ - [ isoPar.coreTrackPtr ] - ] -# -IsoCorFe = [ - [ isoPar.coreCone, isoPar.pileupCorrection ] - ] -# -IsoCorMu = [ - [ isoPar.coreCone, isoPar.pileupCorrection ] - ] - -# - -from IsolationCorrections.IsolationCorrectionsConf import CP__IsolationCorrectionTool as ict -leakTool = ict(name = "LeakageCorrection", - CorrFile = "IsolationCorrections/isolation_ptcorrections_rel20_2.root") # in principle the default -ToolSvc += leakTool - -from IsolationAlgs.IsolationAlgsConf import IsolationBuilder -isoAODFixBuilderElectron = AlgFactory(IsolationBuilder, - name = "IsolationBuilderElectron", - ElectronCollectionContainerName = "Electrons", - PhotonCollectionContainerName = "", - MuonCollectionContainerName = "", - FwdElectronCollectionContainerName = "", - CaloCellIsolationTool = None, - CaloTopoIsolationTool = None, - PFlowIsolationTool = None, - TrackIsolationTool = None, - FeIsoTypes = [[]] , - FeCorTypes = IsoCorFe, - EgIsoTypes = [[]], - EgCorTypes = IsoCorEg, - MuIsoTypes = [[]] , - MuCorTypes = IsoCorMu, - IsAODFix = True, - LeakageTool = leakTool, - IsolateEl = False, - OutputLevel = 3) - -isoAODFixBuilderPhoton = AlgFactory(IsolationBuilder, - name = "IsolationBuilderPhoton", - ElectronCollectionContainerName = "", - PhotonCollectionContainerName = "Photons", - MuonCollectionContainerName = "", - FwdElectronCollectionContainerName = "", - CaloCellIsolationTool = None, - CaloTopoIsolationTool = None, - PFlowIsolationTool = None, - TrackIsolationTool = TrackIsolationTool, - FeIsoTypes = [[]] , - FeCorTypes = IsoCorFe, - EgIsoTypes = IsoTypesEg, - EgCorTypes = IsoCorEg, - MuIsoTypes = [[]] , - MuCorTypes = IsoCorMu, - IsAODFix = True, - LeakageTool = leakTool, - IsolateEl = False, - OutputLevel = 3) - -isoAODFixBuilderMuon = AlgFactory(IsolationBuilder, - name = "IsolationBuilderMuon", - ElectronCollectionContainerName = "", - PhotonCollectionContainerName = "", - MuonCollectionContainerName = "Muons", - FwdElectronCollectionContainerName = "", - CaloCellIsolationTool = None, - CaloTopoIsolationTool = CaloIsolationTool, - PFlowIsolationTool = None, - TrackIsolationTool = None, - FeIsoTypes = [[]] , - FeCorTypes = IsoCorFe, - EgIsoTypes = [[]], - EgCorTypes = IsoCorEg, - MuIsoTypes = IsoTypesMu, - MuCorTypes = IsoCorMu, - CustomConfigurationNameMu = 'Core0p05', - IsAODFix = True, - LeakageTool = None, - IsolateEl = False, - OutputLevel = 3) - - -isoAODFixBuilderFwdElectron = AlgFactory(IsolationBuilder, - name = "IsolationBuilderForwardElectron", - ElectronCollectionContainerName = "", - PhotonCollectionContainerName = "", - MuonCollectionContainerName = "", - FwdElectronCollectionContainerName = "ForwardElectrons", - CaloCellIsolationTool = None, - CaloTopoIsolationTool = CaloIsolationTool, - PFlowIsolationTool = None, - TrackIsolationTool = None, - FeIsoTypes = IsoTypesFe, - FeCorTypes = IsoCorFe, - EgIsoTypes = [[]], - EgCorTypes = IsoCorEg, - MuIsoTypes = [[]], - MuCorTypes = IsoCorMu, - IsAODFix = True, - LeakageTool = None, - IsolateEl = False, - OutputLevel = 3) - - -from RecExConfig.Configured import Configured -class isoAODFixGetter ( Configured ) : - - def __init__(self, intype = ""): - super( isoAODFixGetter, self ).__init__() - self.type = intype - - mlog = logging.getLogger ('isoAODFixGetter.py::configure:') - mlog.info('entering') - - # configure iso here: - try: - if self.type == "Electrons": - self._isoBuilderHandle = isoAODFixBuilderElectron() - elif self.type == "Photons": - self._isoBuilderHandle = isoAODFixBuilderPhoton() - elif self.type == "ForwardElectrons": - self._isoBuilderHandle = isoAODFixBuilderFwdElectron() - elif self.type == "Muons": - self._isoBuilderHandle = isoAODFixBuilderMuon() - else: - mlog.error("wrong object for IsolationBuilder") - except Exception: - mlog.error("could not get handle to IsolationBuilder") - import traceback - print traceback.format_exc() - return False - - def isoBuilderHandle(self): - return self._BuilderHandle - diff --git a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py index f89b0ebaef6cd56455328f1c7ca8fde79bae94c0..428bd4ba42edb0e0f03b30402b0bb9c4620fc250 100644 --- a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py +++ b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.py @@ -60,6 +60,14 @@ from ParticlesInConeTools.ParticlesInConeToolsConf import xAOD__CaloClustersInCo CaloClustersInConeTool = ToolFactory(xAOD__CaloClustersInConeTool, CaloClusterLocation = "CaloCalTopoClusters") +# tool to extrapolate to the calo +import AthenaCommon.CfgMgr as CfgMgr +#this is just regular extrapolator, but in ToolFactory form +from egammaTools.InDetTools import egammaExtrapolator +CaloExtensionTool = ToolFactory (CfgMgr.Trk__ParticleCaloExtensionTool, + Extrapolator = egammaExtrapolator) + + # configuration for ED computation # For the time being, it uses all pflow objects (neutral@EM + charged) for pflow def configureEDCorrection(tool): @@ -172,13 +180,14 @@ CaloIsolationTool = ToolFactory(xAOD__CaloIsolationTool,name = "CaloIsolationToo CaloFillRectangularClusterTool = CaloFillRectangularCluster, ClustersInConeTool = CaloClustersInConeTool, PFlowObjectsInConeTool = PFlowObjectsInConeTool, + ParticleCaloExtensionTool = CaloExtensionTool, IsoLeakCorrectionTool = IsoCorrectionTool, EMCaloNums = [SUBCALO.LAREM], HadCaloNums = [SUBCALO.LARHEC, SUBCALO.TILE], UseEMScale = True) TrackIsolationTool = ToolFactory(xAOD__TrackIsolationTool, name = 'TrackIsolationTool') -from AthenaCommon import CfgMgr +#from AthenaCommon import CfgMgr tit = CfgMgr.xAOD__TrackIsolationTool('TrackIsolationTool') tit.TrackSelectionTool.maxZ0SinTheta = 3 tit.TrackSelectionTool.minPt = 1000 diff --git a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.pyMod b/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.pyMod deleted file mode 100644 index cc7d28de14049aaecbb6c6fd21d90642504f037c..0000000000000000000000000000000000000000 --- a/Reconstruction/RecoAlgs/IsolationAlgs/python/IsoGetter.pyMod +++ /dev/null @@ -1,246 +0,0 @@ -from AthenaCommon.Constants import INFO -from AthenaCommon.AppMgr import ToolSvc -from AthenaCommon.Logging import logging -from RecExConfig.RecFlags import rec - -from egammaRec.Factories import ToolFactory, AlgFactory, getPropertyValue - -#--------------------------------------- -# egamma specifics -from egammaCaloTools.egammaCaloToolsFactories import CaloFillRectangularCluster - -from AthenaCommon.GlobalFlags import globalflags -isMC = not globalflags.DataSource()=='data' -from IsolationCorrections.IsolationCorrectionsConf import CP__IsolationCorrectionTool as ICT -IsoCorrectionTool = ToolFactory(ICT, - name = "NewLeakageCorrTool", - IsMC = isMC) - -doPFlow = False -PFlowObjectsInConeTool = None -from RecExConfig.RecAlgsFlags import recAlgs -if recAlgs.doEFlow() : - - doPFlow = True - - # tool to collect pflow objects in cone - from PFlowUtils.PFlowUtilsConf import CP__RetrievePFOTool as RetrievePFOTool - pfoTool = RetrievePFOTool(); - ToolSvc += pfoTool - - from ParticlesInConeTools.ParticlesInConeToolsConf import xAOD__PFlowObjectsInConeTool - PFlowObjectsInConeTool = ToolFactory(xAOD__PFlowObjectsInConeTool, - name = "PFlowObjectsInConeTool", - RetrievePFOTool = pfoTool) - - from JetRec.JetRecStandard import jtm - from JetRecTools.JetRecToolsConf import PFlowPseudoJetGetter - jtm += PFlowPseudoJetGetter( - name = "emnpflowget", - Label = "EMNPFlow", - OutputContainer = "PseudoJetEMNPFlow", - RetrievePFOTool = jtm.pflowretriever, - InputIsEM = True, - CalibratePFO = False, - SkipNegativeEnergy = True, - UseNeutral = True, - UseCharged = False - ) - -# tool to collect topo clusters in cone -from ParticlesInConeTools.ParticlesInConeToolsConf import xAOD__CaloClustersInConeTool -CaloClustersInConeTool = ToolFactory(xAOD__CaloClustersInConeTool, - CaloClusterLocation = "CaloCalTopoClusters") - -# configuration for ED computation -# For the time being, it uses all pflow objects (neutral@EM + charged) for pflow -def configureEDCorrection(tool): - """Configure tools and algorithm for energy density correction - (only if doEnergyDensityCorrection = True)""" - # Return if doEnergyDensityCorrection is false - if not getPropertyValue(tool, 'doEnergyDensityCorrection'): - return - # Set OutputLevel to INFO or higher if tool has it too - OutputLevel = min(getPropertyValue(tool, 'OutputLevel'), INFO) - try: - from AthenaCommon.AppMgr import ToolSvc - from AthenaCommon.AlgSequence import AlgSequence - from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg - from JetRec.JetRecStandard import jtm - topSequence = AlgSequence() - if not hasattr(topSequence,'EDtpIsoCentralAlg'): - tccc = configEventDensityTool("EDtpIsoCentralTool", jtm.emget, - radius = 0.5, - AbsRapidityMin = 0.0, - AbsRapidityMax = 1.5, - OutputContainer = "TopoClusterIsoCentralEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tccc - topSequence += EventDensityAlg("EDtpIsoCentralAlg", EventDensityTool = tccc) - - if not hasattr(topSequence,'EDtpIsoForwardAlg'): - tfcc = configEventDensityTool("EDtpIsoForwardTool", jtm.emget, - radius = 0.5, - AbsRapidityMin = 1.5, - AbsRapidityMax = 3.0, - OutputContainer = "TopoClusterIsoForwardEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tfcc - topSequence += EventDensityAlg("EDtpIsoForwardAlg", EventDensityTool = tfcc) - - if doPFlow: - if not hasattr(topSequence,'EDpfIsoCentralAlg'): - tcpf = configEventDensityTool("EDpfIsoCentralTool", jtm.empflowget, - radius = 0.5, - AbsRapidityMin = 0.0, - AbsRapidityMax = 1.5, - OutputContainer = "ParticleFlowIsoCentralEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tcpf - topSequence += EventDensityAlg("EDpfIsoCentralAlg", EventDensityTool = tcpf) - - if not hasattr(topSequence,'EDpfIsoForwardAlg'): - tfpf = configEventDensityTool("EDpfIsoForwardTool", jtm.empflowget, - radius = 0.5, - AbsRapidityMin = 1.5, - AbsRapidityMax = 3.0, - OutputContainer = "ParticleFlowIsoForwardEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tfpf - topSequence += EventDensityAlg("EDpfIsoForwardAlg", EventDensityTool = tfpf) - - ## Try a neutral density - if not hasattr(topSequence,'EDnpfIsoCentralAlg'): - tcnpf = configEventDensityTool("EDnpfIsoCentralTool", jtm.emnpflowget, - radius = 0.5, - AbsRapidityMin = 0.0, - AbsRapidityMax = 1.5, - OutputContainer = "NeutralParticleFlowIsoCentralEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tcnpf - topSequence += EventDensityAlg("EDnpfIsoCentralAlg", EventDensityTool = tcnpf) - - if not hasattr(topSequence,'EDnpfIsoForwardAlg'): - tfnpf = configEventDensityTool("EDnpfIsoForwardTool", jtm.emnpflowget, - radius = 0.5, - AbsRapidityMin = 1.5, - AbsRapidityMax = 3.0, - OutputContainer = "NeutralParticleFlowIsoForwardEventShape", - OutputLevel = OutputLevel - ) - ToolSvc += tfnpf - topSequence += EventDensityAlg("EDnpfIsoForwardAlg", EventDensityTool = tfnpf) - - except Exception: - print '\nERROR: could not get handle to ED' - raise - -from CaloIdentifier import SUBCALO -from IsolationTool.IsolationToolConf import xAOD__CaloIsolationTool, xAOD__TrackIsolationTool -CaloIsolationTool = ToolFactory(xAOD__CaloIsolationTool,name = "MyCaloIsolationTool", - postInit = [configureEDCorrection], - CaloFillRectangularClusterTool = CaloFillRectangularCluster, - ClustersInConeTool = CaloClustersInConeTool, - PFlowObjectsInConeTool = PFlowObjectsInConeTool, - IsoLeakCorrectionTool = IsoCorrectionTool, - EMCaloNums = [SUBCALO.LAREM], - HadCaloNums = [SUBCALO.LARHEC, SUBCALO.TILE], - UseEMScale = True, - OutputLevel = 3) - -TrackIsolationTool = ToolFactory(xAOD__TrackIsolationTool, name = 'TrackIsolationTool') -from AthenaCommon import CfgMgr -tit = CfgMgr.xAOD__TrackIsolationTool('TrackIsolationTool') -tit.TrackSelectionTool.maxZ0SinTheta = 3 -tit.TrackSelectionTool.minPt = 1000 -tit.TrackSelectionTool.CutLevel = "TightPrimary" - -import ROOT, cppyy -# Need to be sure base dict is loaded first. -cppyy.loadDictionary('xAODCoreRflxDict') -cppyy.loadDictionary('xAODPrimitivesDict') -isoPar = ROOT.xAOD.Iso - -# In fact the default isolations are the same for eg and muons : prepare the list here -IsoTypes = [ - [ isoPar.etcone40, ## Be carefull : store them in decreasing dR - isoPar.etcone30, - isoPar.etcone20 ], - [ isoPar.topoetcone20, - isoPar.topoetcone30, - isoPar.topoetcone40 ], - [ isoPar.ptcone40, ## these ones will also trigger the ptvarconeXX. Be carefull : store them in decreasing dR - isoPar.ptcone30, - isoPar.ptcone20 ] - ] -if doPFlow: - IsoTypes.append( - [ isoPar.neflowisol20, - isoPar.neflowisol30, - isoPar.neflowisol40 ] ) - -from IsolationAlgs.IsolationAlgsConf import IsolationBuilder -isoBuilder = AlgFactory(IsolationBuilder, - name = "IsolationBuilder", - CaloCellIsolationTool = CaloIsolationTool, - CaloTopoIsolationTool = CaloIsolationTool, - PFlowIsolationTool = CaloIsolationTool, - TrackIsolationTool = TrackIsolationTool, - EgIsoTypes = [[]] if not rec.doEgamma() else IsoTypes, - MuIsoTypes = [[]] if not rec.doMuon() else IsoTypes, - OutputLevel = 3) - -#Customisation -CustomCuts = [ [ 3, 400, 'TightPrimary' ], [ 3, 500, 'TightPrimary' ] , [ 3, 800, 'TightPrimary' ], [ 3, 1200, 'TightPrimary' ], [ 3, 1000, 'Loose' ] ] -for icut in CustomCuts: - - from AthenaCommon.AppMgr import ToolSvc - from AthenaCommon.AlgSequence import AlgSequence - topSequence = AlgSequence() - CustomType = icut[2]+'z0'+str(icut[0])+'mmPt'+str(icut[1])+'MeV' - print 'Building track isolation tool for type ',CustomType - TrackIsolationCustom = xAOD__TrackIsolationTool(name = 'TrackIsolationTool'+CustomType) - TrackIsolationCustom.TrackSelectionTool.maxZ0SinTheta = float(icut[0]) - TrackIsolationCustom.TrackSelectionTool.minPt = float(icut[1]) - TrackIsolationCustom.TrackSelectionTool.CutLevel = icut[2] - ToolSvc += TrackIsolationCustom - isoBuilderCustom = IsolationBuilder( - name = "IsolationBuilder"+CustomType, - CaloCellIsolationTool = None, - CaloTopoIsolationTool = None, - PFlowIsolationTool = None, - TrackIsolationTool = TrackIsolationCustom, - EgIsoTypes = [[]] if not rec.doEgamma() else [[]],#[[isoPar.ptcone40,isoPar.ptcone30,isoPar.ptcone20]], - MuIsoTypes = [[]] if not rec.doMuon() else [[isoPar.ptcone40,isoPar.ptcone30,isoPar.ptcone20]], - CustomConfgurationName = CustomType, - OutputLevel = 3) - topSequence += isoBuilderCustom - - -from RecExConfig.Configured import Configured -class isoGetter ( Configured ) : - - def configure(self): - mlog = logging.getLogger ('isoGetter.py::configure:') - mlog.info('entering') - - # configure iso here: - try: - self._isoBuilderHandle = isoBuilder() - except Exception: - mlog.error("could not get handle to IsolationBuilder") - import traceback - print traceback.format_exc() - return False - - print self._isoBuilderHandle - return True - - def isoBuilderHandle(self): - return self._BuilderHandle -