Commit 6957c4b8 authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Graeme Stewart
Browse files

Do not write out TopoSeededCluster when they do not run (egammaRec-07-01-53)

	* Tag egammaRec-07-01-53
	* Do not write out TopoSeededCluster when they do not run

2016-09-11 Christos Anastopoulos  <Christos.Anastopoulos@cern.ch>

	* Cleanup the flags , and more comments
	* Tag egammaRec-07-01-52
parent 907ab64f
......@@ -14,26 +14,32 @@ from egammaRec.Factories import AlgFactory, FcnWrapper
from egammaRec import egammaRecFlags as egRecFlags
egammaRecFlags = egRecFlags.jobproperties.egammaRecFlags
#Some handy flags
def doSuperclusters():
return egammaRecFlags.doSuperclusters()
def doBremFinding():
return egammaRecFlags.doBremFinding()
return DetFlags.detdescr.ID_on() and egammaRecFlags.doBremFinding()
def doConversions() :
return DetFlags.detdescr.ID_on() and egammaRecFlags.doConversions()
################
# Import the tool factories
from egammaTools.egammaToolsFactories import \
EMBremCollectionBuilder, EMTrackMatchBuilder,\
EMVertexBuilder, EMConversionBuilder, EGammaAmbiguityTool,\
EMClusterTool, EMFourMomBuilder, EMShowerBuilder, egammaOQFlagsBuilder, \
ElectronPIDBuilder, PhotonPIDBuilder
# Extra tool when we do the superclustering approach
if doSuperclusters() :
from egammaTools.egammaToolsFactories import \
egammaTopoClusterCopier, electronSuperClusterBuilder, photonSuperClusterBuilder,\
egammaTopoClusterMap
def doConversions() :
return DetFlags.detdescr.ID_on() and egammaRecFlags.doConversions()
egammaTopoClusterCopier, electronSuperClusterBuilder, photonSuperClusterBuilder
#
#Topo seeded fixed size clusters, related configurations
#Create and return the TopoSeededCollection
def getTopoSeededCollectionName():
if egammaRecFlags.doTopoCaloSeeded():
from CaloRec import CaloRecFlags
......@@ -44,10 +50,12 @@ def getTopoSeededCollectionName():
return theCaloClusterTopoEMFixedSizeGetter.outputKey()
else:
return ""
def doTopoCaloSeeded():
return egammaRecFlags.doTopoCaloSeeded() and getTopoSeededCollectionName()
return egammaRecFlags.doTopoCaloSeeded() and not egammaRecFlags.doSuperclusters() and getTopoSeededCollectionName()
#
#
#The tools used to add properties
def egammaDecorationTools():
"Return a list with the tools that decorate both electrons and photons"
return [EMClusterTool(), EMFourMomBuilder(), EMShowerBuilder(), egammaOQFlagsBuilder()]
......@@ -59,6 +67,7 @@ def electronDecorationTools():
def photonDecorationTools():
"Return a list with the tools that decorate only photons"
return [ PhotonPIDBuilder() ]
#
class egammaGetter ( Configured ) :
......
......@@ -15,14 +15,16 @@ from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer
from AthenaCommon.JobProperties import jobproperties
class Enabled(JobProperty):
""" govern all algorithms
""" jobproperty to disable/enable the egamma algorithms as a group (container) in one go.
Can enable/disable the full egamma
"""
statusOn=True
allowedTypes=['bool']
StoredValue=True
class egammaRecFlagsJobProperty(JobProperty):
""" special flag classing with job properties.egammaRecFlags.Enabled
""" special flag . Subclass which has get_value depending on job properties.egammaRecFlags.Enabled
so properties inheriting from can be disabled in batch
"""
def get_Value(self):
return self.statusOn and self.StoredValue and jobproperties.egammaRecFlags.Enabled()
......@@ -62,20 +64,6 @@ class doConversions (JobProperty):
allowedTypes=['bool']
StoredValue=True
class doShowerBuilding (JobProperty):
""" switch for Shower Building
"""
statusOn=True
allowedTypes=['bool']
StoredValue=True
class doAODRender (JobProperty):
""" switch for egamma AOD render algorithm
"""
statusOn=True
allowedTypes=['bool']
StoredValue=False
class useBremTracks (JobProperty):
""" switch using brem tracks
"""
......@@ -90,14 +78,6 @@ class cellContainerName (JobProperty):
allowedTypes=['str']
StoredValue=''
class makeNewConvContainer (JobProperty):
""" make a new conversion vertex container in conversion builder to be able to add single-track vertices built there
"""
statusOn=True
allowedTypes=['bool']
StoredValue=True
class doSwitchTRTGas (JobProperty):
""" switch using Xenon gas in TRT
"""
......@@ -105,39 +85,35 @@ class doSwitchTRTGas (JobProperty):
allowedTypes=['bool']
StoredValue=True
#New switch for turning off/on electron supercluster building.
class doSuperclusters (egammaRecFlagsJobProperty):
""" switch for supercluster TopoCalo algorithm
""" switch to enable/disable the supercluster based algorithm
"""
statusOn=True
allowedTypes=['bool']
StoredValue=True
class inputTopoClusterCollection (JobProperty):
"""Name of input cluster container for superclustering
"""Name of input cluster container from which the topological cluster to be used during superclustering
are selected
"""
statusOn=True
allowedTypes=['str']
StoredValue='CaloTopoCluster'
class egammaTopoClusterCollection (JobProperty):
"""Name of input cluster container for superclustering
"""Name of cluster container containing the selected topological clusters
used during superclustering
"""
statusOn=True
allowedTypes=['str']
StoredValue='egammaTopoCluster'
class doBremFinding (egammaRecFlagsJobProperty):
""" switch to use GSF-based brem finder in superclustering
""" switch to use GSF-based brem finder during the search of satellites for superclustering
"""
statusOn=True
allowedTypes=['bool']
StoredValue=True
#
#
# Defines a sub-container for the algorithm switches
class egammaRecFlags(JobPropertyContainer):
""" egamma information """
StoredValue=False
class clusterCorrectionVersion (JobProperty):
"""Version of calo cluster corrections used for calibration.
......@@ -147,12 +123,15 @@ class clusterCorrectionVersion (JobProperty):
StoredValue='v12phiflip_noecorrnogap'
# Defines a sub-container holding the jobProperties for egamma
class egammaRecFlags(JobPropertyContainer):
""" egamma information """
# add the egammaRec flags container to the top container
jobproperties.add_Container(egammaRecFlags)
# I want always the following flags in the container
_list_Egamma=[Enabled,doEgammaCaloSeeded,doEgammaForwardSeeded,doAODRender,doConversions,doShowerBuilding,doTopoCaloSeeded,useBremTracks,makeNewConvContainer,cellContainerName,doSwitchTRTGas,doEgammaTruthAssociation, clusterCorrectionVersion, doSuperclusters, inputTopoClusterCollection, egammaTopoClusterCollection, doBremFinding]
# I want always the following flags in the container
_list_Egamma=[Enabled,doEgammaCaloSeeded,doEgammaForwardSeeded,doConversions,doTopoCaloSeeded,useBremTracks,cellContainerName,doSwitchTRTGas,doEgammaTruthAssociation, clusterCorrectionVersion, doSuperclusters, inputTopoClusterCollection, egammaTopoClusterCollection, doBremFinding]
for j in _list_Egamma:
jobproperties.egammaRecFlags.add_JobProperty(j)
......
__doc__ = "Add containers to ESD/AOD ItemList using the definitions from egammaKeys"
from egammaRec.egammaRecFlags import jobproperties
from egammaRec import egammaKeys
from egammaRec.egammaKeys import egammaKeysDict
from AthenaCommon.Logging import logging
from RecExConfig.RecFlags import rec
logEgammaOutputItemList_jobOptions = logging.getLogger( 'py:egammaOutputItemList_jobOptions' )
from egammaRec import egammaRecFlags as egRecFlags
egammaRecFlags = egRecFlags.jobproperties.egammaRecFlags
def getItem(cType, cKey):
"getItem(cType, cKey) -> Return item to be added to the output list: <cType>#<cKey>"
......@@ -33,8 +34,12 @@ def addAuxContainer(outputList, cType, cKey, auxOption=''):
# List for of keys to be written to AOD.
# All egammaKeys.outputs but EgammaRec and TopoSeededCellLink
AOD_outputs = [i for i,j in egammaKeysDict.outputs.items() \
if i not in ('EgammaRec', 'TopoSeededCellLink','FwdClusterCellLink')]
AOD_outputs = [i for i,j in egammaKeysDict.outputs.items()
if i not in ('EgammaRec', 'TopoSeededCellLink','FwdClusterCellLink','TopoSeededCluster')]
#Check if we want the topo seeded
if egammaRecFlags.doTopoCaloSeeded() and not egammaRecFlags.doSuperclusters():
AOD_outputs.append('TopoSeededCluster')
# Define egammaAODList in the proper format (<type>#<key><option>),
# including aux containers
......@@ -58,14 +63,20 @@ for _ in AOD_outputs:
# List for ESD: same as AOD but for tracks and links from topo-seeded clusters to cells
egammaESDList = list(egammaAODList)
egammaESDList.append( getItem(egammaKeys.outputTrackType(), egammaKeys.outputTrackKey()) )
egammaESDList.append( getItem(egammaKeys.outputTopoSeededCellLinkType(), egammaKeys.outputTopoSeededCellLinkKey()) )
egammaESDList.append( getItem(egammaKeys.outputFwdClusterCellLinkType(), egammaKeys.outputFwdClusterCellLinkKey()) )
#Check if we want the topo seeded
if egammaRecFlags.doTopoCaloSeeded() and not egammaRecFlags.doSuperclusters():
egammaESDList.append( getItem(egammaKeys.outputTopoSeededCellLinkType(), egammaKeys.outputTopoSeededCellLinkKey()))
# Remove auxOption from TopoSeeded and Forward Clusters ==> keep cellLink
for index, item in enumerate(egammaESDList):
if egammaKeys.outputTopoSeededClusterKey() + 'Aux' in item:
egammaESDList[index] = getAuxItem( egammaKeys.outputTopoSeededClusterType(), egammaKeys.outputTopoSeededClusterKey() )
egammaESDList[index] = getAuxItem( egammaKeys.outputTopoSeededClusterType(), egammaKeys.outputTopoSeededClusterKey() )
if egammaKeys.outputFwdClusterKey() + 'Aux' in item:
egammaESDList[index] = getAuxItem( egammaKeys.outputFwdClusterType(), egammaKeys.outputFwdClusterKey() )
logEgammaOutputItemList_jobOptions = logging.getLogger( 'py:egammaOutputItemList_jobOptions' )
logEgammaOutputItemList_jobOptions.info('egammaESDList: %s', egammaESDList)
logEgammaOutputItemList_jobOptions.info('egammaAODList: %s', egammaAODList)
......@@ -12,6 +12,8 @@ from egammaRec.egammaKeys import egammaKeysDict
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
###############Print Egamma JobProperties#############
jobproperties.egammaRecFlags.print_JobProperties()
#####################################################################
# Run calo-based (egamma) algorithm, includes topo-seeded
# It requires either to read ESD
......
......@@ -523,7 +523,7 @@ StatusCode topoEgammaBuilder::execute()
//For ambiguity. Probably we could mark in one pass , for now naive solution
//These should be the CaloCalTopo links for the clustes. the 0 should be the seed (always there)
const static SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::CaloClusterContainer > > > caloClusterLinks("constituentClusterLinks");
static const SG::AuxElement::Accessor < std::vector< ElementLink< xAOD::CaloClusterContainer > > > caloClusterLinks("constituentClusterLinks");
ATH_MSG_DEBUG("Build "<< electronSuperRecs->size() << " electron Super Clusters");
ATH_MSG_DEBUG("Build "<< photonSuperRecs->size() << " photon Super Clusters");
......@@ -615,7 +615,7 @@ StatusCode topoEgammaBuilder::execute()
//-----------------------------------------------------------------
//Set the ambiguity link
///Needs the same logic as the ambiguity after building the objects (make sure they are all valid)
const static SG::AuxElement::Accessor<ElementLink<xAOD::EgammaContainer> > ELink ("ambiguityLink");
static const SG::AuxElement::Accessor<ElementLink<xAOD::EgammaContainer> > ELink ("ambiguityLink");
ElementLink<xAOD::EgammaContainer> dummylink;
for (size_t photonIndex=0; photonIndex < photonContainer->size() ; ++photonIndex) {
......@@ -729,7 +729,7 @@ bool topoEgammaBuilder::getElectron(const egammaRec* egRec,
electronContainer->push_back( electron );
electron->setAuthor( author );
const static SG::AuxElement::Accessor<uint8_t> acc("ambiguityType");
static const SG::AuxElement::Accessor<uint8_t> acc("ambiguityType");
acc(*electron) = type;
std::vector< ElementLink< xAOD::CaloClusterContainer > > clusterLinks;
......
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