diff --git a/Calorimeter/CaloRec/python/CaloRecFlags.py b/Calorimeter/CaloRec/python/CaloRecFlags.py index bb6f10ecd1022ec247009a4d03861282596929ee..e1625e9cf0f6bda038add93eede98b5065486da6 100644 --- a/Calorimeter/CaloRec/python/CaloRecFlags.py +++ b/Calorimeter/CaloRec/python/CaloRecFlags.py @@ -64,7 +64,7 @@ class doEmCluster(CaloRecFlagsJobProperty): """ statusOn=True allowedTypes=['bool'] - StoredValue=True + StoredValue=False class doCaloCluster(CaloRecFlagsJobProperty): """ switch for combined calo cluster diff --git a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py index 3398941630982fa5e9f9de8e2191ebfdc68a916d..5a47505338b1324071dd815bf2a52a82d1abf82a 100644 --- a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py +++ b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py @@ -1338,8 +1338,7 @@ if ( rec.doAOD() or rec.doWriteAOD()) and not rec.readAOD() : if DetFlags.detdescr.Calo_on() and rec.doAODCaloCells(): try: from CaloRec.CaloCellAODGetter import addClusterToCaloCellAOD - if rec.readESD() or jobproperties.CaloRecFlags.doEmCluster() : - addClusterToCaloCellAOD("LArClusterEM7_11Nocorr") + addClusterToCaloCellAOD("egamma711Clusters") from egammaRec.egammaRecFlags import jobproperties if ( rec.readESD() or jobproperties.egammaRecFlags.Enabled ) and not rec.ScopingLevel()==4 and rec.doEgamma : diff --git a/Reconstruction/egamma/egammaAlgs/CMakeLists.txt b/Reconstruction/egamma/egammaAlgs/CMakeLists.txt index 461310d1c5d40d28a53e199feb912ed6b963df42..938d511d22530ac617032e5e220c0072e66022f5 100644 --- a/Reconstruction/egamma/egammaAlgs/CMakeLists.txt +++ b/Reconstruction/egamma/egammaAlgs/CMakeLists.txt @@ -43,9 +43,10 @@ atlas_add_component( egammaAlgs src/components/*.cxx INCLUDE_DIRS LINK_LIBRARIES AthenaBaseComps EventKernel xAODCaloEvent xAODEgamma xAODTruth GaudiKernel - MCTruthClassifierLib CaloGeoHelpers CaloUtilsLib AthenaKernel StoreGateLib xAODTracking InDetReadoutGeometry - EgammaAnalysisInterfacesLib egammaRecEvent egammaUtils TrkToolInterfaces InDetRecToolInterfaces - FourMomUtils RecoToolInterfaces TrkTrack TrkPseudoMeasurementOnTrack InDetConversionFinderToolsLib TrkCaloExtension) + MCTruthClassifierLib CaloGeoHelpers CaloUtilsLib CaloRecLib AthenaKernel StoreGateLib + xAODTracking InDetReadoutGeometry EgammaAnalysisInterfacesLib egammaRecEvent egammaUtils + TrkToolInterfaces InDetRecToolInterfaces FourMomUtils RecoToolInterfaces TrkTrack + TrkPseudoMeasurementOnTrack InDetConversionFinderToolsLib TrkCaloExtension) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/Reconstruction/egamma/egammaAlgs/python/egammaLargeClusterMakerAlg.py b/Reconstruction/egamma/egammaAlgs/python/egammaLargeClusterMakerAlg.py new file mode 100644 index 0000000000000000000000000000000000000000..36793f5fd1830f7e2518d983e136f224230c480c --- /dev/null +++ b/Reconstruction/egamma/egammaAlgs/python/egammaLargeClusterMakerAlg.py @@ -0,0 +1,23 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +__doc__ = "ToolFactory to instantiate egammaLargeClusterMaker with default configuration" +__author__ = "Jovan Mitrevski" + +from egammaTools.egammaToolsFactories import egammaLargeClusterMakerTool +from CaloRec import CaloRecConf +from egammaRec.Factories import AlgFactory, ToolFactory, FcnWrapper +from egammaRec import egammaKeys +from CaloClusterCorrection.CaloSwCorrections import make_CaloSwCorrections + +def clusMakerTools(): + return [egammaLargeClusterMakerTool()] + +egammaLargeClusterMakerAlg = AlgFactory( CaloRecConf.CaloClusterMaker, + name = "egammaLargeClusterMaker", + SaveUncalibratedSignalState = False, + ClustersOutputName = egammaKeys.EgammaLargeClustersKey(), + ClusterMakerTools = FcnWrapper(clusMakerTools), + ClusterCorrectionTools=make_CaloSwCorrections("ele7_11", + suffix="Nocorr", + version="none", + cells_name=egammaKeys.caloCellKey())) diff --git a/Reconstruction/egamma/egammaAlgs/python/egammaLargeClusterMakerAlgConfig.py b/Reconstruction/egamma/egammaAlgs/python/egammaLargeClusterMakerAlgConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..773d87d05c5fa2c6100b98d29349910ae80bd290 --- /dev/null +++ b/Reconstruction/egamma/egammaAlgs/python/egammaLargeClusterMakerAlgConfig.py @@ -0,0 +1,30 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +__doc__ = "Configure egammaLargeClusterMaker, which chooses cells to store in the AOD" +__author__ = "Jovan Mitrevski" + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from egammaTools.egammaLargeClusterMakerConfig import egammaLargeClusterMakerCfg +from CaloClusterCorrection.CaloSwCorrections import make_CaloSwCorrections +from CaloRec.CaloRecConf import CaloClusterMaker + +def egammaLargeClusterMakerAlgCfg(flags, name = "egammaLargeClusterMaker", **kwargs): + + acc = ComponentAccumulator + + kwargs.setdefault("SaveUncalibratedSignalState", False) + kwargs.setdefault("ClustersOutputName", flags.Egamma.Keys.Output.EgammaLargeClusters) + + if "ClusterMakerTools" not in kwargs: + toolAcc = egammaLargeClusterMakerCfg(flags) + kwargs["ClusterMakerTools"] = [ toolAcc.popPrivateTools() ] + acc.merge(toolAcc) + + kwargs.setdefault("ClusterCorrectionTools", make_CaloSwCorrections("ele7_11", + suffix="Nocorr", + version="none", + cells_name=flags.Egamma.Keys.Input.CaloCells)) + + acc.addEventAlgo(CaloClusterMaker(name, **kwargs)) + return acc + diff --git a/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx b/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx index ed5ccf87a2453ba522f893b9f2f7053205586339..990408a1c8c9a2b52c9a91f8ee889a245cc131c6 100644 --- a/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx +++ b/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx @@ -127,25 +127,28 @@ StatusCode topoEgammaBuilder::execute(){ unsigned int author = xAOD::EgammaParameters::AuthorElectron; xAOD::AmbiguityTool::AmbiguityType type= xAOD::AmbiguityTool::electron; - for (const auto& photonRec : *photonSuperRecs) { - - //See if the same seed (0 element in the constituents) seed also a photon - if(caloClusterLinks(*(electronRec->caloCluster())).at(0)== - caloClusterLinks(*(photonRec->caloCluster())).at(0)){ - ATH_MSG_DEBUG("Running AmbiguityTool for electron"); - - author = m_ambiguityTool->ambiguityResolve(electronRec->caloCluster(), - photonRec->vertex(), - electronRec->trackParticle(), - type); + // get the hottest cell + const xAOD::CaloCluster *const elClus = electronRec->caloCluster(); + const auto elEta0 = elClus->eta0(); + const auto elPhi0 = elClus->phi0(); + for (const auto& photonRec : *photonSuperRecs) { - break; - } + const xAOD::CaloCluster *const phClus = photonRec->caloCluster(); + //See if they have the same hottest cell + if (elEta0 == phClus->eta0() && elPhi0 == phClus->phi0()) { + ATH_MSG_DEBUG("Running AmbiguityTool for electron"); + + author = m_ambiguityTool->ambiguityResolve(elClus, + photonRec->vertex(), + electronRec->trackParticle(), + type); + break; + } } //Fill each electron if (author == xAOD::EgammaParameters::AuthorElectron || - author == xAOD::EgammaParameters::AuthorAmbiguous){ + author == xAOD::EgammaParameters::AuthorAmbiguous){ ATH_MSG_DEBUG("getElectron"); if ( !getElectron(electronRec, electronContainer.ptr(), author,type) ){ return StatusCode::FAILURE; @@ -159,23 +162,29 @@ StatusCode topoEgammaBuilder::execute(){ unsigned int author = xAOD::EgammaParameters::AuthorPhoton; xAOD::AmbiguityTool::AmbiguityType type= xAOD::AmbiguityTool::photon; + // get the hottest cell + const xAOD::CaloCluster *const phClus = photonRec->caloCluster(); + const auto phEta0 = phClus->eta0(); + const auto phPhi0 = phClus->phi0(); + //See if the same seed (0 element in the constituents) seed also an electron for (const auto& electronRec : *electronSuperRecs) { - if(caloClusterLinks(*(photonRec->caloCluster())).at(0) == - caloClusterLinks(*(electronRec->caloCluster())).at(0)){ - ATH_MSG_DEBUG("Running AmbiguityTool for photon"); - - author = m_ambiguityTool->ambiguityResolve(electronRec->caloCluster(), - photonRec->vertex(), - electronRec->trackParticle(), - type); - break; - } + const xAOD::CaloCluster *const elClus = electronRec->caloCluster(); + //See if they have the same hottest cell + if (phEta0 == elClus->eta0() && phPhi0 == elClus->phi0()) { + ATH_MSG_DEBUG("Running AmbiguityTool for photon"); + + author = m_ambiguityTool->ambiguityResolve(elClus, + photonRec->vertex(), + electronRec->trackParticle(), + type); + break; + } } //Fill each photon if (author == xAOD::EgammaParameters::AuthorPhoton || - author == xAOD::EgammaParameters::AuthorAmbiguous){ + author == xAOD::EgammaParameters::AuthorAmbiguous){ ATH_MSG_DEBUG("getPhoton"); if ( !getPhoton(photonRec, photonContainer.ptr(), author,type) ){ return StatusCode::FAILURE; diff --git a/Reconstruction/egamma/egammaConfig/python/egammaConfigFlags.py b/Reconstruction/egamma/egammaConfig/python/egammaConfigFlags.py index 2103787c6b23987cead598cd0ae6323311b61337..16e35e25216338c615d8d5d35bb1e62387e20506 100644 --- a/Reconstruction/egamma/egammaConfig/python/egammaConfigFlags.py +++ b/Reconstruction/egamma/egammaConfig/python/egammaConfigFlags.py @@ -61,6 +61,11 @@ def createEgammaConfigFlags(): 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') diff --git a/Reconstruction/egamma/egammaRec/python/egammaKeys.py b/Reconstruction/egamma/egammaRec/python/egammaKeys.py index 94b33c54e2ad729a21ba11ff89f41d26f8839304..11e0d5d5d19c4c3d9add73aa4d42660aeac92fb3 100644 --- a/Reconstruction/egamma/egammaRec/python/egammaKeys.py +++ b/Reconstruction/egamma/egammaRec/python/egammaKeys.py @@ -22,6 +22,7 @@ class egammaKeysDict: outputs = dict( Conversion = [ 'xAOD::VertexContainer', 'GSFConversionVertices','-vxTrackAtVertex.' , ''], Cluster = [ 'xAOD::CaloClusterContainer', 'egammaClusters', '','' ], + EgammaLargeClusters = [ 'xAOD::CaloClusterContainer', 'egamma711Clusters', '','' ], # not output to AOD TopoSeededCluster = [ 'xAOD::CaloClusterContainer', 'egammaTopoSeededClusters', '','-CellLink' ], Electron = [ 'xAOD::ElectronContainer', 'Electrons', '',ShowerShapesSuppress+ElectronisemSupress ], EgammaRec = [ 'egammaRecContainer', 'egammaRecCollection', '','' ], @@ -38,6 +39,7 @@ class egammaKeysDict: outputs['CellLink'] = ['CaloClusterCellLinkContainer', outputs['Cluster'][1] + '_links', '',''] outputs['TopoSeededCellLink'] = ['CaloClusterCellLinkContainer', outputs['TopoSeededCluster'][1] + '_links', '',''] outputs['FwdClusterCellLink'] = ['CaloClusterCellLinkContainer', outputs['FwdCluster'][1] + '_links', '',''] + outputs['EgammaLargeClustersCellLink'] = ['CaloClusterCellLinkContainer', outputs['EgammaLargeClusters'][1] + '_links', '',''] # # Create methods to return the types and keys in inputs and outputs diff --git a/Reconstruction/egamma/egammaRec/python/topoEgammaGetter.py b/Reconstruction/egamma/egammaRec/python/topoEgammaGetter.py index e20326efefba8e7a7fc633742e467a3ddbc49a68..32bb99f0fdb87a2e6f1dadf633ce7f98e2c015fa 100644 --- a/Reconstruction/egamma/egammaRec/python/topoEgammaGetter.py +++ b/Reconstruction/egamma/egammaRec/python/topoEgammaGetter.py @@ -102,5 +102,16 @@ class topoEgammaGetter ( Configured ) : return False print self._topoEgammaBuilder + # the egammaLargeClusterMaker (Which chooses the cells to store in the AOD) + from egammaAlgs.egammaLargeClusterMakerAlg import egammaLargeClusterMakerAlg + try: + self._egammaLargeClusterMaker = egammaLargeClusterMakerAlg() + except Exception: + mlog.error("could not get handle to egammaLargeClusterMaker") + import traceback + print traceback.format_exc() + return False + print self._egammaLargeClusterMaker + return True diff --git a/Reconstruction/egamma/egammaRec/share/egammaOutputItemList_jobOptions.py b/Reconstruction/egamma/egammaRec/share/egammaOutputItemList_jobOptions.py index d87d9e4bee0086d54b36e141cec0a15a940f1fdc..dcd1159477be20c0ef43d43b19782b0cf099c4a8 100755 --- a/Reconstruction/egamma/egammaRec/share/egammaOutputItemList_jobOptions.py +++ b/Reconstruction/egamma/egammaRec/share/egammaOutputItemList_jobOptions.py @@ -30,6 +30,11 @@ def addAuxContainer(outputList, cType, cKey, auxOptionAll='',auxOptionAOD=''): # 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','PhotonSuperRec','ElectronSuperRec', + 'TopoSeededCellLink','FwdClusterCellLink', + 'EgammaLargeClusters', 'EgammaLargeClustersCellLink')] + +ESD_outputs = [i for i,j in egammaKeysDict.outputs.items() if i not in ('EgammaRec','PhotonSuperRec','ElectronSuperRec', 'TopoSeededCellLink','FwdClusterCellLink')] @@ -49,13 +54,30 @@ for i in AOD_outputs: continue addContainer(egammaAODList, cType, cKey) - addContainer(egammaESDList, cType, cKey) # Add aux containers for xAOD containers if 'xAOD::' in cType: addAuxContainer(egammaAODList, cType, cKey, auxOptionAll, auxOptionAOD) + +for i in ESD_outputs: + cType, cKey, auxOptionAll, auxOptionAOD = egammaKeysDict.outputs[i] + + # Skip truth if doTruth = False + if not rec.doTruth() and 'Truth' in cKey: + continue + + # Skip Trk::Tracks in xAOD + if egammaKeys.outputTrackType() in cType: + continue + + addContainer(egammaESDList, cType, cKey) + + # Add aux containers for xAOD containers + if 'xAOD::' in cType: addAuxContainer(egammaESDList, cType, cKey, auxOptionAll) + + # Add the non xAOD kind of collection in the ESD egammaESDList.append( getItem(egammaKeys.outputTrackType(), egammaKeys.outputTrackKey()) ) egammaESDList.append( getItem(egammaKeys.outputFwdClusterCellLinkType(), egammaKeys.outputFwdClusterCellLinkKey()) ) diff --git a/Reconstruction/egamma/egammaRec/share/egammaRec_jobOptions.py b/Reconstruction/egamma/egammaRec/share/egammaRec_jobOptions.py index 542172a42f99d6abb4d591cb110b5299b5b82f41..0e6d5e508625ae662ecbd5f7969743562863f8f2 100755 --- a/Reconstruction/egamma/egammaRec/share/egammaRec_jobOptions.py +++ b/Reconstruction/egamma/egammaRec/share/egammaRec_jobOptions.py @@ -23,8 +23,8 @@ if not DetFlags.detdescr.ID_on(): jobproperties.egammaRecFlags.doVertexBuilding=False #GSF also is seeded by the LarEMClusters for now. So we need these as well -if not (rec.readESD() or jobproperties.CaloRecFlags.doEmCluster()): - jobproperties.egammaRecFlags.doBremFinding=False +#if not (rec.readESD() or jobproperties.CaloRecFlags.doEmCluster()): +# jobproperties.egammaRecFlags.doBremFinding=False #We can not run Forward without having the TopoClusters if not (rec.readESD() or jobproperties.CaloRecFlags.doCaloTopoCluster()): diff --git a/Reconstruction/egamma/egammaTools/python/egammaLargeClusterMakerConfig.py b/Reconstruction/egamma/egammaTools/python/egammaLargeClusterMakerConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..02ebc32f8e6cb5bdc4588bd97e35ab84db64941b --- /dev/null +++ b/Reconstruction/egamma/egammaTools/python/egammaLargeClusterMakerConfig.py @@ -0,0 +1,19 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +__doc__ = "Configure egammaLargeClusterMaker, which chooses cells to store in the AOD" +__author__ = "Jovan Mitrevski" + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from egammaTools.egammaToolsConf import egammaLargeClusterMaker + +def egammaLargeClusterMakerCfg(flags, **kwargs): + + acc = ComponentAccumulator + + kwargs.setdefault("CellsName", flags.Egamma.Keys.Input.CaloCells) + kwargs.setdefault("InputClusterCollection", flags.Egamma.Keys.Output.CaloClusters) + + acc.setPrivateTools(egammaLargeClusterMaker(**kwargs)) + + return acc + diff --git a/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py b/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py index dcdd4f88f28ed1504859da3bbfba50c4e15151be..bbadaf4a326fd6654bd0755207d6b51489b69535 100644 --- a/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py +++ b/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py @@ -71,6 +71,12 @@ EGammaAmbiguityTool = ToolFactory( ElectronPhotonSelectorToolsConf.EGammaAmbigui EMFourMomBuilder = ToolFactory( egammaToolsConf.EMFourMomBuilder) +egammaLargeClusterMakerTool = ToolFactory( egammaToolsConf.egammaLargeClusterMaker, + name = "egammaLCMakerTool", + InputClusterCollection = egammaKeys.ClusterKey(), + CellsName = egammaKeys.caloCellKey() + ) + # Electron Selectors from EMPIDBuilderBase import EMPIDBuilderElectronBase ElectronPIDBuilder = ToolFactory( EMPIDBuilderElectronBase, name = "ElectronPIDBuilder") diff --git a/Reconstruction/egamma/egammaTools/src/EMClusterTool.h b/Reconstruction/egamma/egammaTools/src/EMClusterTool.h index 0d1e8fbea81980bf329ca360826ab274d480b0de..96ce135e108e114ee4c2b4f076620272afe43acd 100644 --- a/Reconstruction/egamma/egammaTools/src/EMClusterTool.h +++ b/Reconstruction/egamma/egammaTools/src/EMClusterTool.h @@ -97,8 +97,11 @@ class EMClusterTool : public AthAlgTool, virtual public IEMClusterTool { "OutputClusterContainerName", "", "Name of the output cluster container"}; - /** @brief Key of the output cluster container cell links: name taken from containter name **/ - SG::WriteHandleKey<CaloClusterCellLinkContainer> m_outputClusterContainerCellLinkKey; + /** @brief Key of the output cluster container cell links: + name taken from containter name; only dummy configurable **/ + SG::WriteHandleKey<CaloClusterCellLinkContainer> m_outputClusterContainerCellLinkKey {this, + "DoNotSet_OutputClusterContainerLinks", "", + "Key of the output cluster container cell links; Do not set! Name taken from associated container"}; /** @brief Key of the output cluster container for topo-seeded clusters **/ SG::WriteHandleKey<xAOD::CaloClusterContainer> m_outputTopoSeededClusterContainerKey {this, @@ -106,8 +109,10 @@ class EMClusterTool : public AthAlgTool, virtual public IEMClusterTool { "Name of the output cluster container for topo-seeded clusters (can be the same as the other clusters)"}; /** @brief Key of the output cluster container cell links for topo-seeded clusters: - * name taken from containter name */ - SG::WriteHandleKey<CaloClusterCellLinkContainer> m_outputTopoSeededClusterContainerCellLinkKey; + * name taken from containter name; only dummy configurable */ + SG::WriteHandleKey<CaloClusterCellLinkContainer> m_outputTopoSeededClusterContainerCellLinkKey {this, + "DoNotSet_OutputTopoSeededClusterContainerLinks", "", + "Key of the output cluster container cell links for topo-seeded clusters; Do not set! Name taken from associated container"}; /** Handle to the MVA calibration service **/ ServiceHandle<IegammaMVASvc> m_MVACalibSvc {this, diff --git a/Reconstruction/egamma/egammaTools/src/components/egammaTools_entries.cxx b/Reconstruction/egamma/egammaTools/src/components/egammaTools_entries.cxx index 96995ba7a964c8cece45bae468b41f3d839a76be..13cac8478e400735d55f071182bfd835c2c21c52 100644 --- a/Reconstruction/egamma/egammaTools/src/components/egammaTools_entries.cxx +++ b/Reconstruction/egamma/egammaTools/src/components/egammaTools_entries.cxx @@ -6,6 +6,7 @@ #include "../egammaOQFlagsBuilder.h" #include "../EMPIDBuilder.h" #include "../egammaSwTool.h" +#include "../egammaLargeClusterMaker.h" DECLARE_COMPONENT( EMClusterTool ) DECLARE_COMPONENT( EMConversionBuilder ) @@ -15,3 +16,4 @@ DECLARE_COMPONENT( EMTrackMatchBuilder ) DECLARE_COMPONENT( egammaOQFlagsBuilder ) DECLARE_COMPONENT( EMPIDBuilder ) DECLARE_COMPONENT( egammaSwTool ) +DECLARE_COMPONENT( egammaLargeClusterMaker ) diff --git a/Reconstruction/egamma/egammaTools/src/egammaLargeClusterMaker.cxx b/Reconstruction/egamma/egammaTools/src/egammaLargeClusterMaker.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cf5d9da7cc633c4a0c093acb1909140e768a4c94 --- /dev/null +++ b/Reconstruction/egamma/egammaTools/src/egammaLargeClusterMaker.cxx @@ -0,0 +1,132 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "egammaLargeClusterMaker.h" +#include "CaloEvent/CaloCellContainer.h" +#include "CaloEvent/CaloClusterCellLink.h" +#include "xAODCaloEvent/CaloCluster.h" +#include "xAODCaloEvent/CaloClusterAuxContainer.h" +#include "CaloUtils/CaloClusterStoreHelper.h" +//#include "xAODCaloEvent/CaloClusterKineHelper.h" +#include "StoreGate/ReadHandle.h" +#include "StoreGate/WriteHandle.h" +#include "CaloUtils/CaloLayerCalculator.h" +#include "CaloDetDescr/CaloDetDescrManager.h" + + +// ============================================================= +egammaLargeClusterMaker::egammaLargeClusterMaker(const std::string& type, + const std::string& name, + const IInterface* parent) + : AthAlgTool(type, name, parent) +{ + + // declare interface + declareInterface<CaloClusterCollectionProcessor>(this); + +} + +// ============================================================= +StatusCode egammaLargeClusterMaker::initialize() { + + ATH_MSG_DEBUG("Initializing " << name() << "..."); + + ATH_CHECK(m_inputClusterCollection.initialize()); + ATH_CHECK(m_cellsKey.initialize()); + + ATH_CHECK(m_egammaEnergyPositionAllSamples.retrieve()); + + ATH_MSG_DEBUG("Initialization successful"); + + return StatusCode::SUCCESS; +} + +// ========================================================================= +StatusCode egammaLargeClusterMaker::execute(const EventContext& ctx, + xAOD::CaloClusterContainer* collection) const { + + if (!collection) { + ATH_MSG_ERROR("A null collection was passed, which should never happen"); + return StatusCode::FAILURE; + } + + SG::ReadHandle<xAOD::CaloClusterContainer> inputClusters(m_inputClusterCollection, ctx); + // retrieve the cell containers + SG::ReadHandle<CaloCellContainer> cellcoll(m_cellsKey, ctx); + + // The main loop over clusters + for (auto cluster : *inputClusters) { + + // find the center of the cluster, copying the logic of egammaMiddleShape.cxx + + // check if cluster is in barrel or in the end-cap + if(!cluster->inBarrel() && !cluster->inEndcap() ) { + ATH_MSG_DEBUG(" Cluster is neither in Barrel nor in Endcap; skipping "); + continue; + } + + // check if cluster is in barrel or end-cap + bool in_barrel = m_egammaEnergyPositionAllSamples->inBarrel(*cluster,2); + CaloSampling::CaloSample sam=CaloSampling::EMB2; + if (in_barrel) { + sam=CaloSampling::EMB2; + } else { + sam=CaloSampling::EME2; + } + // granularity in (eta,phi) in the pre sampler + // CaloCellList needs both enums: subCalo and CaloSample + auto eta = cluster->etaSample(sam); + auto phi= cluster->phiSample(sam); + + if ((eta==0. && phi==0.) || fabs(eta)>100) { + return StatusCode::SUCCESS; + } + + const CaloDetDescrManager* dd_man = CaloDetDescrManager::instance(); + + // Should get overritten + bool barrel=false; + CaloCell_ID::SUBCALO subcalo=CaloCell_ID::LAREM; + int sampling_or_module=0; + + dd_man->decode_sample(subcalo, barrel, sampling_or_module, + (CaloCell_ID::CaloSample) sam); + + // Get the corresponding grannularities : needs to know where you are + // the easiest is to look for the CaloDetDescrElement + + const CaloDetDescrElement* dde = + dd_man->get_element(CaloCell_ID::LAREM, 0,barrel,eta,phi); + + // if object does not exist then return + if (!dde) { + return StatusCode::SUCCESS; + } + + // local granularity + auto deta = dde->deta(); + auto dphi = dde->dphi(); + + // search the hottest cell around the (eta,phi) + // (eta,phi) are defined as etaSample() and phiSample + // around this position a hot cell is searched for in a window + // (m_neta*m_deta,m_nphi*m_dphi), by default (m_neta,m_nphi)=(7,7) + CaloLayerCalculator calc; + StatusCode sc = calc.fill(cellcoll.ptr(),cluster->etaSample(sam),cluster->phiSample(sam), + m_neta*deta,m_nphi*dphi, (CaloSampling::CaloSample) sam); + if ( sc.isFailure() ) { + ATH_MSG_WARNING("CaloLayerCalculator failed fill "); + } + double etamax = calc.etarmax(); + double phimax = calc.phirmax(); + + // create the new cluster + xAOD::CaloCluster *newCluster = + CaloClusterStoreHelper::makeCluster(collection, cellcoll.ptr()); + newCluster->setEta0(etamax); + newCluster->setPhi0(phimax); + newCluster->setClusterSize(xAOD::CaloCluster::SW_7_11); + } + return StatusCode::SUCCESS; +} diff --git a/Reconstruction/egamma/egammaTools/src/egammaLargeClusterMaker.h b/Reconstruction/egamma/egammaTools/src/egammaLargeClusterMaker.h new file mode 100644 index 0000000000000000000000000000000000000000..4b8a76b0a33c7e363a413a90739c925bcd2048c9 --- /dev/null +++ b/Reconstruction/egamma/egammaTools/src/egammaLargeClusterMaker.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** + @class egammaLargeClusterMaker + This tool takes the EM CaloCluster used by egamma objects + and builds large 7x11 clusters around + + @author J. Mitrevski + @author C. Anastopoulos +*/ + +#ifndef EGAMMATOOLS_EGAMMALARGECLUSTERMAKER_H +#define EGAMMATOOLS_EGAMMALARGECLUSTERMAKER_H + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "xAODCaloEvent/CaloClusterFwd.h" +#include "xAODCaloEvent/CaloClusterContainer.h" + +#include "egammaInterfaces/IegammaEnergyPositionAllSamples.h" +#include "CaloRec/CaloClusterCollectionProcessor.h" +#include "GaudiKernel/ToolHandle.h" + +#include "StoreGate/ReadHandleKey.h" + +class CaloCellContainer; +class CaloClusterCellLink; + +class egammaLargeClusterMaker : public AthAlgTool, virtual public CaloClusterCollectionProcessor { +public: + + /** @bried constructor */ + egammaLargeClusterMaker (const std::string& type, + const std::string& name, + const IInterface* parent); + + using CaloClusterCollectionProcessor::execute; + + /** @brief initialize method */ + virtual StatusCode initialize() override final; + /** @brief execute on container */ + virtual StatusCode execute(const EventContext& ctx, xAOD::CaloClusterContainer* collection) const override final; +private: + + /** @brief tool to calculate sum of energy in all samples */ + ToolHandle<IegammaEnergyPositionAllSamples> m_egammaEnergyPositionAllSamples {this, + "egammaEnergyPositionAllSamplesTool", + "egammaEnergyPositionAllSamples/egammaEnergyPositionAllSamples"}; + + /** @brief The name of the cluster container for electrons and photons */ + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_inputClusterCollection {this, + "InputClusterCollection", "egammaClusters", + "The name of the cluster container for electrons and photons"}; + + /** @brief Cell container*/ + SG::ReadHandleKey<CaloCellContainer> m_cellsKey {this, + "CellsName", "AllCalo", "Names of containers which contain cells"}; + + Gaudi::Property<double> m_neta {this, "Neta", 7.0, + "Number of eta cells in each sampling in which to look for hottest cell"}; + + Gaudi::Property<double> m_nphi {this, "Nphi", 7.0, + "Number of phi cell in each sampling in which to look for hottest cell"}; + + +}; + +#endif // EGAMMATOOLS_EMCLUSTERTOOL_H