Commit 69d3c838 authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

egammaTools python tidy

parent 658b3eef
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# default configuration of the EMPIDBuilder
from ROOT import LikeEnum
from ROOT import egammaPID
from AthenaCommon.Logging import logging
import traceback
from ElectronPhotonSelectorTools.ElectronIsEMSelectorMapping import electronPIDmenu
from ElectronPhotonSelectorTools.PhotonIsEMSelectorMapping import photonPIDmenu
# import base class
from egammaTools.egammaToolsConf import EMPIDBuilder
# Eventually we need to get rid of this
import cppyy
cppyy.loadDictionary('ElectronPhotonSelectorToolsDict')
......@@ -24,41 +21,41 @@ class EMPIDBuilderElectronBase (EMPIDBuilder):
mlog = logging.getLogger(name+'::__init__')
mlog.debug("entering")
# Electron Selectors
try:
# Cut based
from ElectronPhotonSelectorTools.ConfiguredAsgElectronIsEMSelectors import ConfiguredAsgElectronIsEMSelector
LooseElectronSelector = ConfiguredAsgElectronIsEMSelector(
"LooseElectronSelector", egammaPID.ElectronIDLoosePP)
MediumElectronSelector = ConfiguredAsgElectronIsEMSelector(
"MediumElectronSelector", egammaPID.ElectronIDMediumPP)
TightElectronSelector = ConfiguredAsgElectronIsEMSelector(
"TightElectronSelector", egammaPID.ElectronIDTightPP)
# Likelihood
from ElectronPhotonSelectorTools.ConfiguredAsgElectronLikelihoodTools import ConfiguredAsgElectronLikelihoodTool
LooseLHSelector = ConfiguredAsgElectronLikelihoodTool(
"LooseLHSelector", LikeEnum.Loose)
LooseLHSelector.primaryVertexContainer = "PrimaryVertices"
MediumLHSelector = ConfiguredAsgElectronLikelihoodTool(
"MediumLHSelector", LikeEnum.Medium)
MediumLHSelector.primaryVertexContainer = "PrimaryVertices"
TightLHSelector = ConfiguredAsgElectronLikelihoodTool(
"TightLHSelector", LikeEnum.Tight)
TightLHSelector.primaryVertexContainer = "PrimaryVertices"
# Multi Lepton
from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronMultiLeptonSelector
MultiLeptonSelector = AsgElectronMultiLeptonSelector(
"MultiLeptonSelector")
except:
mlog.error("could not get configure tools")
traceback.print_exc()
return False
# Cut based
from ElectronPhotonSelectorTools.ConfiguredAsgElectronIsEMSelectors \
import ConfiguredAsgElectronIsEMSelector
LooseElectronSelector = ConfiguredAsgElectronIsEMSelector(
"LooseElectronSelector", egammaPID.ElectronIDLoosePP)
MediumElectronSelector = ConfiguredAsgElectronIsEMSelector(
"MediumElectronSelector", egammaPID.ElectronIDMediumPP)
TightElectronSelector = ConfiguredAsgElectronIsEMSelector(
"TightElectronSelector", egammaPID.ElectronIDTightPP)
# Likelihood
from ElectronPhotonSelectorTools.ConfiguredAsgElectronLikelihoodTools \
import ConfiguredAsgElectronLikelihoodTool
LooseLHSelector = ConfiguredAsgElectronLikelihoodTool(
"LooseLHSelector", LikeEnum.Loose)
LooseLHSelector.primaryVertexContainer = "PrimaryVertices"
MediumLHSelector = ConfiguredAsgElectronLikelihoodTool(
"MediumLHSelector", LikeEnum.Medium)
MediumLHSelector.primaryVertexContainer = "PrimaryVertices"
TightLHSelector = ConfiguredAsgElectronLikelihoodTool(
"TightLHSelector", LikeEnum.Tight)
TightLHSelector.primaryVertexContainer = "PrimaryVertices"
# Multi Lepton
from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf \
import AsgElectronMultiLeptonSelector
MultiLeptonSelector = AsgElectronMultiLeptonSelector(
"MultiLeptonSelector")
self.electronIsEMselectors = [
LooseElectronSelector, MediumElectronSelector, TightElectronSelector]
LooseElectronSelector,
MediumElectronSelector,
TightElectronSelector]
self.electronIsEMselectorResultNames = ["Loose", "Medium", "Tight"]
self.electronLHselectors = [
LooseLHSelector, MediumLHSelector, TightLHSelector]
......@@ -77,17 +74,13 @@ class EMPIDBuilderPhotonBase (EMPIDBuilder):
mlog.debug("entering")
# photon Selectors
try:
from ElectronPhotonSelectorTools.ConfiguredAsgPhotonIsEMSelectors import ConfiguredAsgPhotonIsEMSelector
LoosePhotonSelector = ConfiguredAsgPhotonIsEMSelector(
"LoosePhotonSelector", egammaPID.PhotonIDLoose)
TightPhotonSelector = ConfiguredAsgPhotonIsEMSelector(
"TightPhotonSelector", egammaPID.PhotonIDTight)
except:
mlog.error("could not get configure tools")
traceback.print_exc()
return False
from ElectronPhotonSelectorTools.ConfiguredAsgPhotonIsEMSelectors \
import ConfiguredAsgPhotonIsEMSelector
LoosePhotonSelector = ConfiguredAsgPhotonIsEMSelector(
"LoosePhotonSelector", egammaPID.PhotonIDLoose)
TightPhotonSelector = ConfiguredAsgPhotonIsEMSelector(
"TightPhotonSelector", egammaPID.PhotonIDTight)
self.photonIsEMselectors = [LoosePhotonSelector, TightPhotonSelector]
self.photonIsEMselectorResultNames = ["Loose", "Tight"]
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
__doc__ = "ToolFactory to instantiate all EMShowerBuilder with default configuration"
__doc__ = """ToolFactory to instantiate all EMShowerBuilder
with default configuration"""
__author__ = "Bruno Lenzi"
from AthenaCommon.Constants import INFO # OutputLevel
from egammaTools import egammaToolsConf
from egammaRec.Factories import ToolFactory, getPropertyValue
from egammaRec.Factories import ToolFactory
from egammaRec import egammaKeys
from egammaCaloTools.egammaCaloToolsFactories import egammaShowerShape, \
egammaIso
from egammaCaloTools.egammaCaloToolsFactories import (
egammaShowerShape, egammaIso)
from CaloIdentifier import SUBCALO
from CaloIdentifier import SUBCALO
from RecExConfig.RecFlags import rec
# TODO: not needed ?
# from CaloDetDescr.CaloDepthToolBase import CaloDepthToolFactory
# theCaloDepthTool=CaloDepthToolFactory(depth='showerdefault')
EMShowerBuilder = ToolFactory( egammaToolsConf.EMShowerBuilder,
CellsName = egammaKeys.caloCellKey(),
CaloNums = [SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.TILE],
ShowerShapeTool = egammaShowerShape,
HadronicLeakageTool = egammaIso,
Print = False)
EMShowerBuilder = ToolFactory(
egammaToolsConf.EMShowerBuilder,
CellsName=egammaKeys.caloCellKey(),
CaloNums=[SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.TILE],
ShowerShapeTool=egammaShowerShape,
HadronicLeakageTool=egammaIso,
Print=False)
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
__doc__ = "ToolFactory to instantiate EMTrackMatchBuilder with default configuration"
__doc__ = """ToolFactory to instantiate
EMTrackMatchBuilder with default configuration"""
__author__ = "Bruno Lenzi"
from egammaTools import egammaToolsConf
from egammaRec.Factories import FcnWrapper, ToolFactory
from egammaRec.Factories import ToolFactory
from egammaRec import egammaKeys
from RecExConfig.RecFlags import rec
from AthenaCommon.BeamFlags import jobproperties
from egammaTrackTools.egammaTrackToolsFactories import EMExtrapolationTools, EMExtrapolationToolsCache
from egammaTrackTools.egammaTrackToolsFactories import (
EMExtrapolationToolsCache)
EMTrackMatchBuilder = ToolFactory( egammaToolsConf.EMTrackMatchBuilder,
TrackParticlesName = egammaKeys.outputTrackParticleKey(),
ExtrapolationTool = EMExtrapolationToolsCache,
broadDeltaEta = 0.1, #candidate match is done in 2 times this so +- 0.2
broadDeltaPhi = 0.15, #candidate match is done in 2 times this so +- 0.3
useCandidateMatch = True,
useScoring = True,
SecondPassRescale = True,
UseRescaleMetric = True,
isCosmics = (jobproperties.Beam.beamType()=="cosmics")
EMTrackMatchBuilder = ToolFactory(
egammaToolsConf.EMTrackMatchBuilder,
TrackParticlesName=egammaKeys.outputTrackParticleKey(),
ExtrapolationTool=EMExtrapolationToolsCache,
broadDeltaEta=0.1, # candidate match is done in 2 times this so +- 0.2
broadDeltaPhi=0.15, # candidate match is done in 2 times this so +- 0.3
useCandidateMatch=True,
useScoring=True,
SecondPassRescale=True,
UseRescaleMetric=True,
isCosmics=(jobproperties.Beam.beamType() == "cosmics")
)
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from egammaTools import egammaToolsConf
from egammaRec.Factories import FcnWrapper, ToolFactory
from egammaRec.Factories import ToolFactory
from egammaRec import egammaKeys
from CaloTools.CaloToolsConf import CaloAffectedTool
egammaOQFlagsBuilder = ToolFactory( egammaToolsConf.egammaOQFlagsBuilder,
QCellCut = 4000.,
QCellHECCut = 60000.,
QCellSporCut = 4000.,
LArQCut = 0.8,
TCut = 10.,
TCutVsE = 2.,
RcellCut = 0.8,
CellsName = egammaKeys.caloCellKey(),
affectedTool = CaloAffectedTool())
egammaOQFlagsBuilder = ToolFactory(
egammaToolsConf.egammaOQFlagsBuilder,
QCellCut=4000.,
QCellHECCut=60000.,
QCellSporCut=4000.,
LArQCut=0.8,
TCut=10.,
TCutVsE=2.,
RcellCut=0.8,
CellsName=egammaKeys.caloCellKey(),
affectedTool=CaloAffectedTool())
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
__doc__ = "ToolFactories to instantiate all egammaTools with default configuration"
__doc__ = """ToolFactories to instantiate
all egammaTools with default configuration"""
__author__ = "Bruno Lenzi"
from ROOT import egammaPID
import cppyy
from ElectronPhotonSelectorTools.ConfiguredAsgForwardElectronIsEMSelectors import ConfiguredAsgForwardElectronIsEMSelector
from ElectronPhotonSelectorTools.ConfiguredAsgForwardElectronIsEMSelectors \
import ConfiguredAsgForwardElectronIsEMSelector
from .EMPIDBuilderBase import EMPIDBuilderPhotonBase
from .EMPIDBuilderBase import EMPIDBuilderElectronBase
from ElectronPhotonSelectorTools import ElectronPhotonSelectorToolsConf
......@@ -14,7 +17,7 @@ from egammaMVACalib.egammaMVACalibFactories import egammaMVASvc
from egammaTools import egammaToolsConf
from egammaRec.Factories import ToolFactory
from egammaRec.Factories import ToolFactory
from egammaRec import egammaKeys
# to set jobproperties.egammaRecFlags
from egammaRec.egammaRecFlags import jobproperties
......@@ -24,8 +27,10 @@ import six
def configureClusterCorrections(swTool):
"Add attributes ClusterCorrectionToolsXX to egammaSwTool object"
from CaloClusterCorrection.CaloSwCorrections import make_CaloSwCorrections, rfac, etaoff_b1, etaoff_e1, \
etaoff_b2, etaoff_e2, phioff_b2, phioff_e2, update, time, listBadChannel
from CaloClusterCorrection.CaloSwCorrections import (
make_CaloSwCorrections, rfac, etaoff_b1, etaoff_e1,
etaoff_b2, etaoff_e2, phioff_b2, phioff_e2, update,
time, listBadChannel)
from CaloRec.CaloRecMakers import _process_tools
clusterTypes = dict(
......@@ -37,9 +42,11 @@ def configureClusterCorrections(swTool):
x = 'ClusterCorrectionTools' + attrName
if not hasattr(swTool, x) or getattr(swTool, x):
continue
y = make_CaloSwCorrections(clName, suffix='EG',
version=jobproperties.egammaRecFlags.clusterCorrectionVersion(),
cells_name=egammaKeys.caloCellKey())
y = make_CaloSwCorrections(
clName,
suffix='EG',
version=jobproperties.egammaRecFlags.clusterCorrectionVersion(),
cells_name=egammaKeys.caloCellKey())
setattr(swTool, x, _process_tools(swTool, y))
# Super cluster position only corrections
......@@ -49,22 +56,23 @@ def configureClusterCorrections(swTool):
if not hasattr(swTool, n) or getattr(swTool, n):
continue
setattr(swTool, n, _process_tools(swTool,
make_CaloSwCorrections(
clName,
suffix='EGSuperCluster',
corrlist=[
[rfac, 'v5'],
[etaoff_b1, 'v5'],
[etaoff_e1, 'v5'],
[etaoff_b2, 'v5'],
[etaoff_e2, 'v5'],
[phioff_b2, 'v5data'],
[phioff_e2, 'v5data'],
[update],
[time],
[listBadChannel]],
cells_name=egammaKeys.caloCellKey())))
setattr(swTool, n, _process_tools(
swTool,
make_CaloSwCorrections(
clName,
suffix='EGSuperCluster',
corrlist=[
[rfac, 'v5'],
[etaoff_b1, 'v5'],
[etaoff_e1, 'v5'],
[etaoff_b2, 'v5'],
[etaoff_e2, 'v5'],
[phioff_b2, 'v5data'],
[phioff_e2, 'v5data'],
[update],
[time],
[listBadChannel]],
cells_name=egammaKeys.caloCellKey())))
# End of super cluster position only corrections
......@@ -111,6 +119,7 @@ PhotonPIDBuilder = ToolFactory(
# ForwardElectron Selectors
# Eventually we want to get rid of cppyy here
cppyy.loadDictionary('ElectronPhotonSelectorToolsDict')
LooseForwardElectronSelector = ToolFactory(
......@@ -129,6 +138,6 @@ TightForwardElectronSelector = ToolFactory(
# -------------------------
# Import the factories that are not defined here
from .EMShowerBuilder import EMShowerBuilder
from .EMTrackMatchBuilder import EMTrackMatchBuilder
from .egammaOQFlagsBuilder import egammaOQFlagsBuilder
from .EMTrackMatchBuilder import EMTrackMatchBuilder
\ No newline at end of file
from .EMShowerBuilder import EMShowerBuilder
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment