Commit 644ceb20 authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

egammaAlgs more tests and fixes

parent 1a3873e3
......@@ -30,6 +30,10 @@ atlas_add_test( egammaRecBuilderConfig_test
SCRIPT python -m egammaAlgs.egammaRecBuilderConfig
POST_EXEC_SCRIPT nopost.sh)
atlas_add_test( egammaSuperClusterBuilderConfig_test
SCRIPT python -m egammaAlgs.egammaSuperClusterBuilderConfig
POST_EXEC_SCRIPT nopost.sh)
atlas_add_test( EMGSFCaloExtensionBuilderConfig_test
SCRIPT python -m egammaAlgs.EMGSFCaloExtensionBuilderConfig
POST_EXEC_SCRIPT nopost.sh)
......@@ -42,6 +46,11 @@ atlas_add_test( egammaTopoClusterCopierConfig_test
SCRIPT python -m egammaAlgs.egammaTopoClusterCopierConfig
POST_EXEC_SCRIPT nopost.sh)
atlas_add_test( topoEgammaBuilderConfig_test
SCRIPT python -m egammaAlgs.topoEgammaBuilderConfig
POST_EXEC_SCRIPT nopost.sh)
atlas_add_test( egammaTrackSlimmerConfig_test
SCRIPT python -m egammaAlgs.egammaTrackSlimmerConfig
POST_EXEC_SCRIPT nopost.sh)
......@@ -28,16 +28,16 @@ def EMGSFCaloExtensionBuilderCfg(
name="PerigeeCaloExtensionTool",
ParticleType="electron",
StartFromPerigee=True)
kwargs["PerigeeCaloExtensionTool"] = perigeeCaloExtrapAcc.popPrivateTools()
acc.merge(perigeeCaloExtrapAcc)
kwargs["PerigeeCaloExtensionTool"] = acc.popToolsAndMerge(
perigeeCaloExtrapAcc)
if "LastCaloExtensionTool" not in kwargs:
lastCaloExtrapAcc = ParticleCaloExtensionToolCfg(
flags,
name="LastCaloExtensionTool",
ParticleType="electron")
kwargs["LastCaloExtensionTool"] = lastCaloExtrapAcc.popPrivateTools()
acc.merge(lastCaloExtrapAcc)
kwargs["LastCaloExtensionTool"] = acc.popToolsAndMerge(
lastCaloExtrapAcc)
kwargs.setdefault(
"GFFTrkPartContainerName",
......
......@@ -23,13 +23,11 @@ def egammaRecBuilderCfg(
acc = ComponentAccumulator()
if "TrackMatchBuilderTool" not in kwargs:
emtrkmatch = EMTrackMatchBuilderCfg(flags)
kwargs["TrackMatchBuilderTool"] = emtrkmatch.popPrivateTools()
acc.merge(emtrkmatch)
kwargs["TrackMatchBuilderTool"] = acc.popToolsAndMerge(emtrkmatch)
if "ConversionBuilderTool" not in kwargs:
emcnv = EMConversionBuilderCfg(flags)
kwargs["ConversionBuilderTool"] = emcnv.popPrivateTools()
acc.merge(emcnv)
kwargs["ConversionBuilderTool"] = acc.popToolsAndMerge(emcnv)
kwargs.setdefault(
"egammaRecContainer",
......
......@@ -32,8 +32,7 @@ def egammaSelectedTrackCopyCfg(
if "ExtrapolationTool" not in kwargs:
extraptool = EMExtrapolationToolsCfg(
flags, name="EMExtrapolationTools")
kwargs["ExtrapolationTool"] = extraptool.popPrivateTools()
acc.merge(extraptool)
kwargs["ExtrapolationTool"] = acc.popToolsAndMerge(extraptool)
if "ExtrapolationToolCommonCache" not in kwargs:
from egammaTrackTools.egammaTrackToolsConfig import (
......
......@@ -5,37 +5,35 @@ builders with default configuration"""
from AthenaCommon.Logging import logging
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
from egammaTools.EMTrackMatchBuilderConfig import EMTrackMatchBuilderCfg
from egammaTools.EMConversionBuilderConfig import EMConversionBuilderCfg
from egammaTools.egammaMVACalibConfig import egammaMVASvcCfg
from egammaTools.egammaSwToolConfig import egammaSwToolCfg
from egammaMVACalib.egammaMVACalibConfig import egammaMVASvcCfg
from egammaCaloTools.egammaCaloToolsConf import egammaCheckEnergyDepositTool
def electronSuperClusterBuilderCfg(flags, name='electronSuperClusterBuilder', **kwargs):
from egammaAlgs.egammaAlgsConf import electronSuperClusterBuilder
electronSuperClusterBuilder = CompFactory.electronSuperClusterBuilder
mlog = logging.getLogger(name)
mlog.debug('Start configuration')
acc = ComponentAccumulator()
if "MVACalibSvc" not in kwargs:
mvacal = egammaMVASvcCfg(flags)
kwargs["MVACalibSvc"] = mvacal.popPrivateTools()
acc.merge(mvacal)
if "TrackMatchBuilderTool" not in kwargs:
emtrkmatch = EMTrackMatchBuilderCfg(flags)
kwargs["TrackMatchBuilderTool"] = emtrkmatch.popPrivateTools()
acc.merge(emtrkmatch)
kwargs["TrackMatchBuilderTool"] = acc.popToolsAndMerge(emtrkmatch)
if "ClusterCorrectionTool" not in kwargs:
egswtool = egammaSwToolCfg(flags)
kwargs["ClusterCorrectionTool"] = egswtool.popPrivateTools()
acc.merge(egswtool)
kwargs["ClusterCorrectionTool"] = acc.popToolsAndMerge(egswtool)
if "MVACalibSvc" not in kwargs:
mvacal = egammaMVASvcCfg(flags)
kwargs["MVACalibSvc"] = acc.popToolsAndMerge(mvacal)
kwargs.setdefault(
"InputEgammaRecContainerName",
......@@ -47,7 +45,7 @@ def electronSuperClusterBuilderCfg(flags, name='electronSuperClusterBuilder', **
"egammaCheckEnergyDepositTool",
egammaCheckEnergyDepositTool())
kwargs.setdefault("EtThresholdCut", 1000)
print(kwargs)
elscAlg = electronSuperClusterBuilder(name, **kwargs)
acc.addEventAlgo(elscAlg)
......@@ -59,27 +57,24 @@ def photonSuperClusterBuilderCfg(
name='photonSuperClusterBuilder',
**kwargs):
from egammaAlgs.egammaAlgsConf import photonSuperClusterBuilder
photonSuperClusterBuilder = CompFactory.photonSuperClusterBuilder
mlog = logging.getLogger(name)
mlog.debug('Start configuration')
acc = ComponentAccumulator()
if "MVACalibSvc" not in kwargs:
mvacal = egammaMVASvcCfg(flags)
kwargs["MVACalibSvc"] = mvacal.popPrivateTools()
acc.merge(mvacal)
if "ConversionBuilderTool" not in kwargs:
emcnv = EMConversionBuilderCfg(flags)
kwargs["ConversionBuilderTool"] = emcnv.popPrivateTools()
acc.merge(emcnv)
kwargs["ConversionBuilderTool"] = acc.popToolsAndMerge(emcnv)
if "ClusterCorrectionTool" not in kwargs:
egswtool = egammaSwToolCfg(flags)
kwargs["ClusterCorrectionTool"] = egswtool.popPrivateTools()
acc.merge(egswtool)
kwargs["ClusterCorrectionTool"] = acc.popToolsAndMerge(egswtool)
if "MVACalibSvc" not in kwargs:
mvacal = egammaMVASvcCfg(flags)
kwargs["MVACalibSvc"] = acc.popToolsAndMerge(mvacal)
kwargs.setdefault(
"InputEgammaRecContainerName",
......@@ -95,3 +90,31 @@ def photonSuperClusterBuilderCfg(
acc.addEventAlgo(phscAlg)
return acc
if __name__ == "__main__":
from AthenaCommon.Configurable import Configurable
Configurable.configurableRun3Behavior = True
from AthenaConfiguration.AllConfigFlags import ConfigFlags as flags
from AthenaConfiguration.TestDefaults import defaultTestFiles
from AthenaConfiguration.ComponentAccumulator import printProperties
from AthenaConfiguration.MainServicesConfig import MainServicesCfg
flags.Input.Files = defaultTestFiles.RDO
acc = MainServicesCfg(flags)
acc.merge(electronSuperClusterBuilderCfg(flags))
mlog = logging.getLogger("egammaSuperClusterBuilderConfigTest")
mlog.info("Configuring electronSuperClusterBuilder: ")
printProperties(mlog,
acc.getEventAlgo("electronSuperClusterBuilder"),
nestLevel=1,
printDefaults=True)
acc.merge(photonSuperClusterBuilderCfg(flags))
mlog.info("Configuring photonSuperClusterBuilder: ")
printProperties(mlog,
acc.getEventAlgo("photonSuperClusterBuilder"),
nestLevel=1,
printDefaults=True)
with open("egammasuperclusterbuilder.pkl", "wb") as f:
acc.store(f)
......@@ -34,8 +34,33 @@ def topoEgammaBuilderCfg(flags, name='topoEgammaBuilder', **kwargs):
kwargs.setdefault(
"AmbiguityTool",
EGammaAmbiguityTool())
kwargs.setdefault(
"isTruth",
flags.Input.isMC
)
topoegAlg = xAODEgammaBuilder(flags, **kwargs)
topoegAlg = xAODEgammaBuilder(name, **kwargs)
acc.addEventAlgo(topoegAlg)
return acc
if __name__ == "__main__":
from AthenaCommon.Configurable import Configurable
Configurable.configurableRun3Behavior = True
from AthenaConfiguration.AllConfigFlags import ConfigFlags as flags
from AthenaConfiguration.TestDefaults import defaultTestFiles
from AthenaConfiguration.ComponentAccumulator import printProperties
from AthenaConfiguration.MainServicesConfig import MainServicesCfg
flags.Input.Files = defaultTestFiles.RDO
acc = MainServicesCfg(flags)
acc.merge(topoEgammaBuilderCfg(flags))
mlog = logging.getLogger("topoEgammaBuilderConfigTest")
mlog.info("Configuring topoEgammaBuilder: ")
printProperties(mlog,
acc.getEventAlgo("topoEgammaBuilder"),
nestLevel=1,
printDefaults=True)
with open("topoegammabuilder.pkl", "wb") as f:
acc.store(f)
......@@ -2,6 +2,7 @@
# this is based on MuonConfigFlags as a guide
import unittest
from AthenaConfiguration.AthConfigFlags import AthConfigFlags
......@@ -13,8 +14,9 @@ def createEgammaConfigFlags():
# do standard cluster-based egamma algorithm
egcf.addFlag("Egamma.doCaloSeeded", True)
egcf.addFlag("Egamma.doSuperclusters", True) # if true, do superculsers, false is SW
egcf.addFlag("Egamma.doTopoSeeded", True) # if doing SW, also add toposeeded electrons
# if true, do superculsers
egcf.addFlag("Egamma.doSuperclusters", True)
# do forward egamma
egcf.addFlag("Egamma.doForwardSeeded", True)
......@@ -29,8 +31,10 @@ def createEgammaConfigFlags():
egcf.addFlag("Egamma.doConversionBuilding", True)
# The cluster corrections/calib
egcf.addFlag("Egamma.Calib.ClusterCorrectionVersion", 'v12phiflip_noecorrnogap')
egcf.addFlag("Egamma.Calib.SuperClusterCorrectionVersion", 'v12phiflip_supercluster')
egcf.addFlag("Egamma.Calib.ClusterCorrectionVersion",
'v12phiflip_noecorrnogap')
egcf.addFlag("Egamma.Calib.SuperClusterCorrectionVersion",
'v12phiflip_supercluster')
egcf.addFlag("Egamma.Calib.MVAVersion", 'egammaMVACalib/offline/v7')
##################################################
......@@ -39,64 +43,67 @@ def createEgammaConfigFlags():
# one idea is to make the keys have tuples with type, name, etc
##################################################
def _cellContainer(prevFlags):
if "AllCalo" in prevFlags.Input.Collections:
# if have all the cells in input file, return it
return "AllCalo"
elif "AODCellContainer" in prevFlags.Input.Collections:
# do we have the AOD cells?
return "AODCellContainer"
else:
# assume they will be created
return "AllCalo"
egcf.addFlag("Egamma.Keys.Input.CaloCells", lambda prevFlags: _cellContainer(prevFlags))
egcf.addFlag("Egamma.Keys.Input.TopoClusters", 'CaloTopoClusters') # input topoclusters
egcf.addFlag("Egamma.Keys.Input.CaloCells", 'AllCalo')
egcf.addFlag("Egamma.Keys.Input.TopoClusters",
'CaloTopoClusters') # input topoclusters
egcf.addFlag("Egamma.Keys.Input.TruthParticles", 'TruthParticles')
egcf.addFlag("Egamma.Keys.Input.TruthEvents", 'TruthEvents')
egcf.addFlag("Egamma.Keys.Input.TrackParticles", 'InDetTrackParticles') # input to GSF
egcf.addFlag("Egamma.Keys.Input.TrackParticles",
'InDetTrackParticles') # input to GSF
# the topoclusters selected for egamma from the input topoclusters
egcf.addFlag("Egamma.Keys.Internal.EgammaTopoClusters", 'egammaTopoClusters')
egcf.addFlag("Egamma.Keys.Internal.EgammaTopoClusters",
'egammaTopoClusters')
egcf.addFlag("Egamma.Keys.Internal.EgammaRecs", 'egammaRecCollection')
egcf.addFlag("Egamma.Keys.Internal.PhotonSuperRecs", 'PhotonSuperRecCollection')
egcf.addFlag("Egamma.Keys.Internal.ElectronSuperRecs", 'ElectronSuperRecCollection')
egcf.addFlag("Egamma.Keys.Internal.PhotonSuperRecs",
'PhotonSuperRecCollection')
egcf.addFlag("Egamma.Keys.Internal.ElectronSuperRecs",
'ElectronSuperRecCollection')
# These are the clusters that are used to determine which cells to write out to AOD
egcf.addFlag("Egamma.Keys.Output.EgammaLargeClusters", 'egamma711Clusters')
egcf.addFlag("Egamma.Keys.Output.EgammaLargeClustersSuppESD", '')
# don't define SuppAOD because the whole container is suppressed
egcf.addFlag("Egamma.Keys.Output.ConversionVertices", 'GSFConversionVertices')
egcf.addFlag("Egamma.Keys.Output.ConversionVerticesSuppESD", '-vxTrackAtVertex')
egcf.addFlag("Egamma.Keys.Output.ConversionVerticesSuppAOD", '-vxTrackAtVertex')
egcf.addFlag("Egamma.Keys.Output.ConversionVertices",
'GSFConversionVertices')
egcf.addFlag("Egamma.Keys.Output.ConversionVerticesSuppESD",
'-vxTrackAtVertex')
egcf.addFlag("Egamma.Keys.Output.ConversionVerticesSuppAOD",
'-vxTrackAtVertex')
egcf.addFlag("Egamma.Keys.Output.CaloClusters", 'egammaClusters')
egcf.addFlag("Egamma.Keys.Output.CaloClustersSuppESD", '')
egcf.addFlag("Egamma.Keys.Output.CaloClustersSuppAOD", '')
egcf.addFlag("Egamma.Keys.Output.TopoSeededClusters", 'egammaTopoSeededClusters')
egcf.addFlag("Egamma.Keys.Output.TopoSeededClusters",
'egammaTopoSeededClusters')
egcf.addFlag("Egamma.Keys.Output.TopoSeededClustersSuppESD", '')
egcf.addFlag("Egamma.Keys.Output.TopoSeededClustersSuppAOD", '-CellLink')
egcf.addFlag("Egamma.Keys.Output.Electrons", 'Electrons')
egcf.addFlag("Egamma.Keys.Output.ElectronsSuppESD", '')
egcf.addFlag("Egamma.Keys.Output.ElectronsSuppAOD",
'-e033.-e011.-e333.-e335.-e337.-e377.-EgammaCovarianceMatrix.-isEMLHLoose.-isEMLHTight.-isEMLHMedium.-isEMLoose.-isEMMultiLepton.-isEMMedium.-isEMTight')
"-e033.-e011.-e333.-e335.-e337.-e377."
"-EgammaCovarianceMatrix.-isEMLHLoose.-isEMLHTight.-isEMLHMedium."
"-isEMLoose.-isEMMedium.-isEMTight")
egcf.addFlag("Egamma.Keys.Input.ForwardTopoClusters", 'CaloCalTopoClusters')
egcf.addFlag("Egamma.Keys.Input.ForwardTopoClusters",
'CaloCalTopoClusters')
egcf.addFlag("Egamma.Keys.Output.ForwardElectrons", 'ForwardElectrons')
egcf.addFlag("Egamma.Keys.Output.ForwardElectronsSuppESD", '')
egcf.addFlag("Egamma.Keys.Output.ForwardElectronsSuppAOD",
'-isEMTight.-isEMMedium.-isEMLoose')
egcf.addFlag("Egamma.Keys.Output.ForwardClusters", 'ForwardElectronClusters')
egcf.addFlag("Egamma.Keys.Output.ForwardClusters",
'ForwardElectronClusters')
egcf.addFlag("Egamma.Keys.Output.ForwardClustersSuppESD", '-SisterCluster')
egcf.addFlag("Egamma.Keys.Output.ForwardClustersSuppAOD",
'-SisterCluster')
# These are the clusters that are used to determine which cells to write out to AOD
egcf.addFlag("Egamma.Keys.Output.EgammaLargeFWDClusters", 'egamma66FWDClusters')
egcf.addFlag("Egamma.Keys.Output.EgammaLargeFWDClusters",
'egamma66FWDClusters')
egcf.addFlag("Egamma.Keys.Output.EgammaLargeFWDClustersSuppESD", '')
# don't define SuppAOD because the whole container is suppressed
......@@ -122,7 +129,7 @@ def createEgammaConfigFlags():
# self test
import unittest
class TestEgammaConfigFlags(unittest.TestCase):
......@@ -131,6 +138,7 @@ class TestEgammaConfigFlags(unittest.TestCase):
self.assertEqual(flags.Egamma.Keys.Output.Photons, "Photons")
self.assertEqual(flags._get("Egamma.Keys.Output.Photons"), "Photons")
if __name__ == "__main__":
unittest.main()
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