Commit 841eb36d authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Vakhtang Tsulaia
Browse files

EMClusterTool rm some legacy unused options and relevant code paths

parent 4feef5e1
......@@ -222,7 +222,7 @@ topoEgammaBuilder::execute(const EventContext& ctx) const
}
// Calibration
if (m_clusterTool->contExecute(ctx, *calodetdescrmgr, electrons, photons)
if (m_clusterTool->contExecute(ctx,electrons, photons)
.isFailure()) {
ATH_MSG_ERROR("Problem executing the " << m_clusterTool << " tool");
return StatusCode::FAILURE;
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EGAMMAINTERFACES_IEMCLUSTERTOOL_H
......@@ -33,7 +33,6 @@ class IEMClusterTool : virtual public IAlgTool {
virtual StatusCode initialize() = 0;
/** @brief execute on containers */
virtual StatusCode contExecute(const EventContext& ctx,
const CaloDetDescrManager& cmgr,
xAOD::ElectronContainer* electronContainer,
xAOD::PhotonContainer* photonContainer) const = 0;
......
......@@ -83,8 +83,6 @@ LRTphotonSuperClusterBuilder = photonSuperClusterBuilder.copy(
LRTEMClusterTool = EMClusterTool.copy(
name='LRTEMClusterTool',
OutputClusterContainerName="LRT"+egammaKeys.outputClusterKey(),
OutputTopoSeededClusterContainerName='LRT' +
egammaKeys.outputTopoSeededClusterKey(),
)
LRTtopoEgammaBuilder = topoEgammaBuilder.copy(
......
......@@ -69,15 +69,10 @@ def configureSuperClusterCorrections(swTool):
cells_name=egammaKeys.caloCellKey())))
def configureClusterCorrections(swTool):
"Add attributes ClusterCorrectionToolsXX to egammaSwTool object"
configureFixedSizeClusterCorrections(swTool)
if jobproperties.egammaRecFlags.doSuperclusters():
configureSuperClusterCorrections(swTool)
# At the end we could keep only one version of the tools
# below
egammaSwTool = ToolFactory(egammaToolsConf.egammaSwTool,
postInit=[configureClusterCorrections])
postInit=[configureSuperClusterCorrections])
egammaSwSuperClusterTool = ToolFactory(
......@@ -88,9 +83,6 @@ egammaSwSuperClusterTool = ToolFactory(
EMClusterTool = ToolFactory(
egammaToolsConf.EMClusterTool,
OutputClusterContainerName=egammaKeys.outputClusterKey(),
OutputTopoSeededClusterContainerName=egammaKeys.outputTopoSeededClusterKey(),
ClusterCorrectionTool=egammaSwTool,
doSuperCluster=jobproperties.egammaRecFlags.doSuperclusters(),
MVACalibSvc=egammaMVASvc
)
......
......@@ -5,7 +5,6 @@
#include "EMClusterTool.h"
#include "CaloEvent/CaloClusterCellLink.h"
#include "GaudiKernel/EventContext.h"
#include "StoreGate/StoreGateSvc.h"
#include "xAODCaloEvent/CaloCluster.h"
#include "xAODCaloEvent/CaloClusterAuxContainer.h"
#include "xAODEgamma/EgammaxAODHelpers.h"
......@@ -23,8 +22,6 @@ EMClusterTool::EMClusterTool(const std::string& type,
const std::string& name,
const IInterface* parent)
: AthAlgTool(type, name, parent)
, m_caloCellDetPos{}
, m_doTopoSeededContainer(false)
{
declareInterface<IEMClusterTool>(this);
}
......@@ -41,20 +38,6 @@ EMClusterTool::initialize()
m_outputClusterContainerKey.key() + "_links";
ATH_CHECK(m_outputClusterContainerCellLinkKey.initialize());
m_doTopoSeededContainer = (m_outputTopoSeededClusterContainerKey.key() !=
m_outputClusterContainerKey.key() &&
!m_doSuperClusters);
ATH_CHECK(
m_outputTopoSeededClusterContainerKey.initialize(m_doTopoSeededContainer));
m_outputTopoSeededClusterContainerCellLinkKey =
m_outputTopoSeededClusterContainerKey.key() + "_links";
ATH_CHECK(m_outputTopoSeededClusterContainerCellLinkKey.initialize(
m_doTopoSeededContainer));
// Get the cluster correction tool
ATH_CHECK(m_clusterCorrectionTool.retrieve());
// Get the cluster correction tool
ATH_CHECK(m_MVACalibSvc.retrieve());
......@@ -65,7 +48,6 @@ EMClusterTool::initialize()
StatusCode
EMClusterTool::contExecute(const EventContext& ctx,
const CaloDetDescrManager& mgr,
xAOD::ElectronContainer* electronContainer,
xAOD::PhotonContainer* photonContainer) const
{
......@@ -84,52 +66,17 @@ EMClusterTool::contExecute(const EventContext& ctx,
ATH_CHECK(outputClusterContainerCellLink.record(
std::make_unique<CaloClusterCellLinkContainer>()));
// Create output cluster container for topo-seeded clusters and register in
// StoreGate Only if they differ from the main output cluster container and if
// we do not do supercluster
SG::WriteHandle<xAOD::CaloClusterContainer> outputTopoSeededClusterContainer;
SG::WriteHandle<CaloClusterCellLinkContainer>
outputTopoSeededClusterContainerCellLink;
if (m_doTopoSeededContainer) {
outputTopoSeededClusterContainer =
SG::WriteHandle<xAOD::CaloClusterContainer>(
m_outputTopoSeededClusterContainerKey, ctx);
ATH_CHECK(outputTopoSeededClusterContainer.record(
std::make_unique<xAOD::CaloClusterContainer>(),
std::make_unique<xAOD::CaloClusterAuxContainer>()));
outputTopoSeededClusterContainerCellLink =
SG::WriteHandle<CaloClusterCellLinkContainer>(
m_outputTopoSeededClusterContainerCellLinkKey, ctx);
ATH_CHECK(outputTopoSeededClusterContainerCellLink.record(
std::make_unique<CaloClusterCellLinkContainer>()));
}
// Loop over electrons and create new clusters
xAOD::EgammaParameters::EgammaType egType = xAOD::EgammaParameters::electron;
if (electronContainer) {
for (auto electron : *electronContainer) {
setNewCluster(ctx, mgr, electron, outputClusterContainer.ptr(), egType);
setNewCluster(ctx, electron, outputClusterContainer.ptr());
}
}
if (photonContainer) {
// Loop over photons and create new clusters
for (auto photon : *photonContainer) {
egType = (xAOD::EgammaHelpers::isConvertedPhoton(photon)
? xAOD::EgammaParameters::convertedPhoton
: xAOD::EgammaParameters::unconvertedPhoton);
if (!m_doTopoSeededContainer ||
!photon->author(xAOD::EgammaParameters::AuthorCaloTopo35)) {
setNewCluster(ctx, mgr, photon, outputClusterContainer.ptr(), egType);
} else {
setNewCluster(
ctx, mgr, photon, outputTopoSeededClusterContainer.ptr(), egType);
}
setNewCluster(ctx, photon, outputClusterContainer.ptr());
}
}
// Now finalize the cluster: based on code in
......@@ -138,44 +85,24 @@ EMClusterTool::contExecute(const EventContext& ctx,
cl->setLink(outputClusterContainerCellLink.ptr(), ctx);
}
if (m_doTopoSeededContainer) {
for (xAOD::CaloCluster* cl : *outputTopoSeededClusterContainer) {
cl->setLink(outputTopoSeededClusterContainerCellLink.ptr(), ctx);
}
}
return StatusCode::SUCCESS;
}
void
EMClusterTool::setNewCluster(const EventContext& ctx,
const CaloDetDescrManager& mgr,
xAOD::Egamma* eg,
xAOD::CaloClusterContainer* outputClusterContainer,
xAOD::EgammaParameters::EgammaType egType) const
EMClusterTool::setNewCluster(
const EventContext& ctx,
xAOD::Egamma* eg,
xAOD::CaloClusterContainer* outputClusterContainer) const
{
if (!eg) {
return;
}
if (!eg->caloCluster()) {
ATH_MSG_DEBUG("egamma object does not have a cluster associated");
return;
}
using ClusterLink_t = ElementLink<xAOD::CaloClusterContainer>;
xAOD::CaloCluster* cluster = nullptr;
// Special Case for topo seeded photons.
if (eg->author(xAOD::EgammaParameters::AuthorCaloTopo35)) {
cluster = new xAOD::CaloCluster(*(eg->caloCluster()));
fillPositionsInCalo(cluster, mgr);
} // Doing superClusters
else if (m_doSuperClusters) {
// copy over for super clusters
cluster = makeNewSuperCluster(*(eg->caloCluster()), eg);
} else {
cluster = makeNewCluster(ctx, *(eg->caloCluster()), mgr, eg, egType);
}
xAOD::CaloCluster* cluster = makeNewSuperCluster(*(eg->caloCluster()), eg);
outputClusterContainer->push_back(cluster);
......@@ -185,129 +112,15 @@ EMClusterTool::setNewCluster(const EventContext& ctx,
eg->setCaloClusterLinks(clusterLinks);
}
xAOD::CaloCluster*
EMClusterTool::makeNewCluster(const EventContext& ctx,
const xAOD::CaloCluster& cluster,
const CaloDetDescrManager& mgr,
xAOD::Egamma* eg,
xAOD::EgammaParameters::EgammaType egType) const
{
// Create new cluster based on an existing one
// const CaloCluster* cluster : input cluster
// protection against cluster not in barrel nor endcap
if (!cluster.inBarrel() && !cluster.inEndcap()) {
ATH_MSG_ERROR("Cluster neither in barrel nor in endcap, Skipping cluster");
return nullptr;
}
if (static_cast<int>(egType) < 0 ||
egType >= xAOD::EgammaParameters::NumberOfEgammaTypes) {
ATH_MSG_WARNING("Invalid egamma type");
return nullptr;
}
bool isBarrel = xAOD::EgammaHelpers::isBarrel(&cluster);
xAOD::CaloCluster::ClusterSize cluSize = xAOD::CaloCluster::CSize_Unknown;
switch (egType) {
case xAOD::EgammaParameters::electron: {
cluSize =
isBarrel ? xAOD::CaloCluster::SW_37ele : xAOD::CaloCluster::SW_55ele;
break;
}
case xAOD::EgammaParameters::convertedPhoton: {
cluSize = isBarrel ? xAOD::CaloCluster::SW_37Econv
: xAOD::CaloCluster::SW_55Econv;
break;
}
default: {
cluSize =
(isBarrel ? xAOD::CaloCluster::SW_37gam : xAOD::CaloCluster::SW_55gam);
}
}
xAOD::CaloCluster* newCluster = makeNewCluster(ctx, cluster, mgr, cluSize);
if (newCluster && m_MVACalibSvc->execute(*newCluster, *eg).isFailure()) {
ATH_MSG_ERROR("Problem executing MVA cluster tool");
}
return newCluster;
}
xAOD::CaloCluster*
EMClusterTool::makeNewCluster(
const EventContext& ctx,
const xAOD::CaloCluster& cluster,
const CaloDetDescrManager& mgr,
const xAOD::CaloCluster::ClusterSize& cluSize) const
{
xAOD::CaloCluster* newClus = CaloClusterStoreHelper::makeCluster(
cluster.getCellLinks()->getCellContainer(),
cluster.eta0(),
cluster.phi0(),
cluSize);
if (newClus) {
if (m_clusterCorrectionTool->execute(ctx, newClus).isFailure()) {
ATH_MSG_ERROR("Problem executing cluster correction tool");
}
fillPositionsInCalo(newClus, mgr);
// Fill the raw state using the cluster with correct size but not MVA
newClus->setRawE(newClus->calE());
newClus->setRawEta(newClus->calEta());
newClus->setRawPhi(newClus->calPhi());
// Fill the Alt state using the 3x5 cluster
newClus->setAltE(cluster.calE());
newClus->setAltEta(cluster.calEta());
newClus->setAltPhi(cluster.calPhi());
} else {
ATH_MSG_ERROR("Null newClus");
}
return newClus;
}
xAOD::CaloCluster*
EMClusterTool::makeNewSuperCluster(const xAOD::CaloCluster& cluster,
xAOD::Egamma* eg) const
{
//
xAOD::CaloCluster* newClus = new xAOD::CaloCluster(cluster);
if (m_applySuperClusters) {
if (newClus && m_MVACalibSvc->execute(*newClus, *eg).isFailure()) {
ATH_MSG_ERROR("Problem executing MVA cluster tool");
}
if (newClus && m_MVACalibSvc->execute(*newClus, *eg).isFailure()) {
ATH_MSG_ERROR("Problem executing MVA cluster tool");
}
return newClus;
}
void
EMClusterTool::fillPositionsInCalo(xAOD::CaloCluster* cluster,
const CaloDetDescrManager& mgr) const
{
bool isBarrel = xAOD::EgammaHelpers::isBarrel(cluster);
CaloCell_ID::CaloSample sample =
isBarrel ? CaloCell_ID::EMB2 : CaloCell_ID::EME2;
// eta and phi of the cluster in the calorimeter frame
double eta;
double phi;
m_caloCellDetPos.getDetPosition(
mgr, sample, cluster->eta(), cluster->phi(), eta, phi);
cluster->insertMoment(xAOD::CaloCluster::ETACALOFRAME, eta);
cluster->insertMoment(xAOD::CaloCluster::PHICALOFRAME, phi);
// eta in the second sampling
m_caloCellDetPos.getDetPosition(
mgr, sample, cluster->etaBE(2), cluster->phiBE(2), eta, phi);
cluster->insertMoment(xAOD::CaloCluster::ETA2CALOFRAME, eta);
cluster->insertMoment(xAOD::CaloCluster::PHI2CALOFRAME, phi);
// eta in the first sampling
sample = isBarrel ? CaloCell_ID::EMB1 : CaloCell_ID::EME1;
m_caloCellDetPos.getDetPosition(
mgr, sample, cluster->etaBE(1), cluster->phiBE(1), eta, phi);
cluster->insertMoment(xAOD::CaloCluster::ETA1CALOFRAME, eta);
cluster->insertMoment(xAOD::CaloCluster::PHI1CALOFRAME, phi);
}
......@@ -8,14 +8,13 @@
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/EventContext.h"
#include "GaudiKernel/ToolHandle.h"
#include "egammaBaseTool.h"
#include "egammaInterfaces/IEMClusterTool.h"
#include "EgammaAnalysisInterfaces/IegammaMVASvc.h"
#include "egammaInterfaces/IegammaSwTool.h"
#include "StoreGate/WriteHandleKey.h"
#include "xAODCaloEvent/CaloCluster.h" // cannot use CaloClusterFwd b/c of ClusterSize
#include "xAODCaloEvent/CaloCluster.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODEgamma/EgammaEnums.h"
#include "xAODEgamma/EgammaFwd.h"
......@@ -26,17 +25,6 @@ class CaloClusterCellLink;
/**
@class EMClusterTool
This tool makes the EM CaloCluster used by egamma objects.
It also defines the cluster size
- in barrel
3*7 for electrons
3*7 for converted photons with Rconv<800mm
3*5 for converted photons with Rconv>800mm
3*5 for unconverted photons
- in end-caps
5*5 for electrons
5*5 for converted photons with Rconv<800mm
5*5 for converted photons with Rconv>800mm
5*5 for unconverted photons
and applies the right cluster corrections depending on classification as
electron, unconverted photon or converted photon
......@@ -65,7 +53,6 @@ public:
/** @brief execute on container */
virtual StatusCode contExecute(
const EventContext& ctx,
const CaloDetDescrManager& mgr,
xAOD::ElectronContainer* electronContainer,
xAOD::PhotonContainer* photonContainer) const override final;
......@@ -73,42 +60,12 @@ private:
/** @brief Set new cluster to the egamma object, decorate the new cluster
* with a link to the old one **/
void setNewCluster(const EventContext& ctx,
const CaloDetDescrManager& mgr,
xAOD::Egamma* eg,
xAOD::CaloClusterContainer* outputClusterContainer,
xAOD::EgammaParameters::EgammaType egType) const;
/** @brief creation of new cluster based on existing one
* Return a new cluster using the seed eta0, phi0 from the existing one,
* applying cluster corrections and MVA calibration (requires the egamma
* object). The cluster size depends on the given EgammaType
*/
xAOD::CaloCluster* makeNewCluster(const EventContext&,
const xAOD::CaloCluster&,
const CaloDetDescrManager& mgr,
xAOD::Egamma* eg,
xAOD::EgammaParameters::EgammaType) const;
/** @brief creation of new cluster based on existing one
* Return a new cluster with the given size using the seed eta0, phi0 from the
* existing cluster and applying cluster corrections.
* If doDecorate is true, copy the cal to the raw signal state
* and set the raw one to the cal e,eta,phi from the existing cluster
*/
xAOD::CaloCluster* makeNewCluster(
const EventContext& ctx,
const xAOD::CaloCluster&,
const CaloDetDescrManager& mgr,
const xAOD::CaloCluster::ClusterSize&) const;
xAOD::CaloClusterContainer* outputClusterContainer) const;
/** @brief creation of new super cluster based on existing one */
xAOD::CaloCluster* makeNewSuperCluster(const xAOD::CaloCluster& cluster,
xAOD::Egamma* eg) const;
/** @brief build extra positions in calo frame*/
void fillPositionsInCalo(xAOD::CaloCluster* cluster,
const CaloDetDescrManager& mgr) const;
/** @brief Key of the output cluster container **/
SG::WriteHandleKey<xAOD::CaloClusterContainer> m_outputClusterContainerKey{
this,
......@@ -128,60 +85,11 @@ private:
"from associated container"
};
/** @brief Key of the output cluster container for topo-seeded clusters **/
SG::WriteHandleKey<xAOD::CaloClusterContainer>
m_outputTopoSeededClusterContainerKey{
this,
"OutputTopoSeededClusterContainerName",
""
"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; 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,
"MVACalibSvc",
"egammaMVASvc",
"calibration service" };
/** @brief Tool to handle cluster corrections */
ToolHandle<IegammaSwTool> m_clusterCorrectionTool{
this,
"ClusterCorrectionTool",
"egammaSwTool/egammaswtool",
"tool that applies cluster corrections"
};
/** @brief do super clusters **/
Gaudi::Property<bool> m_doSuperClusters{ this,
"doSuperCluster",
true,
"Do Super Cluster Reco" };
/** @brief flag to protect against applying the MVA to super Clusters **/
Gaudi::Property<bool> m_applySuperClusters{
this,
"applyMVAToSuperCluster",
true,
"Protection to not do anything for superClusters"
};
/** @brief Position in Calo frame**/
const CaloCellDetPos m_caloCellDetPos;
// derived variable (not set by JOs)
bool m_doTopoSeededContainer;
};
#endif // EGAMMATOOLS_EMCLUSTERTOOL_H
......@@ -21,7 +21,7 @@ from CaloIdentifier import SUBCALO
# Egamma imports
from egammaRec.Factories import ToolFactory, AlgFactory
from egammaTools.egammaToolsFactories import egammaToolsConf, egammaSwSuperClusterTool, egammaMVASvc, EMFourMomBuilder, PhotonPIDBuilder, ElectronPIDBuilder
from egammaTools.egammaToolsFactories import egammaToolsConf, egammaMVASvc, EMFourMomBuilder, PhotonPIDBuilder, ElectronPIDBuilder
from egammaTrackTools.egammaTrackToolsFactories import EMExtrapolationTools
......@@ -103,9 +103,6 @@ TrigEgammaOQFlagsBuilder = ToolFactory( egammaToolsConf.egammaOQFlagsBuilder,
TrigEMClusterTool = ToolFactory(egammaToolsConf.EMClusterTool,
name = 'TrigEMClusterTool',
OutputClusterContainerName = TrigEgammaKeys.TrigEMClusterToolOutputContainer,
OutputTopoSeededClusterContainerName = TrigEgammaKeys.outputTopoSeededClusterKey,
ClusterCorrectionTool = egammaSwSuperClusterTool,
doSuperCluster = True,
MVACalibSvc = egammaMVASvc
)
from xAODPrimitives.xAODIso import xAODIso as isoPar
......
......@@ -203,12 +203,8 @@ def _precisionElectronSeq(flags, doIDperf=False):
def TrigEMClusterToolCfg(flags):
acc = ComponentAccumulator()
from egammaMVACalib.egammaMVACalibConfig import egammaMVASvcCfg
from egammaTools.egammaSwToolConfig import egammaSwToolCfg
tool = CompFactory.EMClusterTool('TrigEMClusterTool',
OutputClusterContainerName = TrigEgammaKeys.TrigEMClusterToolOutputContainer,
OutputTopoSeededClusterContainerName = TrigEgammaKeys.outputTopoSeededClusterKey,
ClusterCorrectionTool = acc.popToolsAndMerge(egammaSwToolCfg(flags)),
doSuperCluster = True,
MVACalibSvc = acc.getPrimaryAndMerge(egammaMVASvcCfg(flags))
)
acc.setPrivateTools(tool)
......
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