From ec28df8521cf5df73a6fcc29bc66c92d8209f5f3 Mon Sep 17 00:00:00 2001 From: Mark Hodgkinson <m.hodgkinson@sheffield.ac.uk> Date: Thu, 27 Sep 2018 11:57:24 +0100 Subject: [PATCH] Migrate eflowRecCluster such that each CaloCluster it is based on is copied in the eflowRecCluster constructor, rather than on demand later on. --- .../eflowRec/eflowRec/eflowRecCluster.h | 6 ++--- .../eflowRec/src/PFClusterSelectorTool.cxx | 2 +- .../eflowRec/src/eflowRecCluster.cxx | 26 ++++++++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/eflowRecCluster.h b/Reconstruction/eflowRec/eflowRec/eflowRecCluster.h index 8f8d3b41b21..6be4e7200d7 100644 --- a/Reconstruction/eflowRec/eflowRec/eflowRecCluster.h +++ b/Reconstruction/eflowRec/eflowRec/eflowRecCluster.h @@ -32,12 +32,12 @@ This class extends the information about a xAOD::CaloCluster. It includes an ele */ class eflowRecCluster { public: - eflowRecCluster(const ElementLink<xAOD::CaloClusterContainer>& clusElementLink); + eflowRecCluster(const ElementLink<xAOD::CaloClusterContainer>& clusElementLink, xAOD::CaloClusterContainer& newClusContainer); eflowRecCluster(const eflowRecCluster& originalEflowRecCluster); eflowRecCluster& operator=(const eflowRecCluster& originalEflowRecCluster); virtual ~eflowRecCluster(); - const xAOD::CaloCluster* getCluster() const { return m_cluster; } + xAOD::CaloCluster* getCluster() const { return m_cluster; } xAOD::CaloCluster* getClusterForModification(xAOD::CaloClusterContainer* container); ElementLink<xAOD::CaloClusterContainer> getClusElementLink() const { return m_clusElementLink; } @@ -66,7 +66,7 @@ private: enum CalorimeterType { CALORIMETER_START = 0, UNASSIGNED = CALORIMETER_START, ECAL = 1, HCAL = 2, FCAL = 3, UNKNOWN = 4, CALORIMETER_END = 5}; int m_clusterId; - const xAOD::CaloCluster* m_cluster; + xAOD::CaloCluster* m_cluster; ElementLink<xAOD::CaloClusterContainer> m_originalClusElementLink; ElementLink<xAOD::CaloClusterContainer> m_clusElementLink; bool m_isTouchable; diff --git a/Reconstruction/eflowRec/src/PFClusterSelectorTool.cxx b/Reconstruction/eflowRec/src/PFClusterSelectorTool.cxx index 00a81a032fc..ccf170f4898 100644 --- a/Reconstruction/eflowRec/src/PFClusterSelectorTool.cxx +++ b/Reconstruction/eflowRec/src/PFClusterSelectorTool.cxx @@ -33,7 +33,7 @@ StatusCode PFClusterSelectorTool::execute(eflowRecClusterContainer& theEFlowRecC unsigned int nClusters = caloClustersReadHandle->size(); for (unsigned int iCluster = 0; iCluster < nClusters; ++iCluster) { /* Create the eflowRecCluster and put it in the container */ - std::unique_ptr<eflowRecCluster> thisEFRecCluster = std::make_unique<eflowRecCluster>(ElementLink<xAOD::CaloClusterContainer>(*caloClustersReadHandle, iCluster)); + std::unique_ptr<eflowRecCluster> thisEFRecCluster = std::make_unique<eflowRecCluster>(ElementLink<xAOD::CaloClusterContainer>(*caloClustersReadHandle, iCluster), theCaloClusterContainer); if (caloCalClustersReadHandle.isValid()){ std::map<IdentifierHash,double> cellsWeightMap; diff --git a/Reconstruction/eflowRec/src/eflowRecCluster.cxx b/Reconstruction/eflowRec/src/eflowRecCluster.cxx index 9cfcf34144a..9f08028ef5e 100644 --- a/Reconstruction/eflowRec/src/eflowRecCluster.cxx +++ b/Reconstruction/eflowRec/src/eflowRecCluster.cxx @@ -14,8 +14,24 @@ #include "eflowRec/eflowTrackClusterLink.h" #include "xAODCaloEvent/CaloClusterKineHelper.h" -eflowRecCluster::eflowRecCluster(const ElementLink<xAOD::CaloClusterContainer>& clusElementLink) : - m_clusterId(-1), m_cluster(*clusElementLink),m_originalClusElementLink(clusElementLink), m_clusElementLink(clusElementLink), m_isTouchable(false),m_calorimeterType(UNASSIGNED) , m_matchCluster(nullptr) { +eflowRecCluster::eflowRecCluster(const ElementLink<xAOD::CaloClusterContainer>& clusElementLink, xAOD::CaloClusterContainer& newClusContainer) : + m_clusterId(-1), m_originalClusElementLink(clusElementLink), m_isTouchable(false),m_calorimeterType(UNASSIGNED) , m_matchCluster(nullptr) { + const xAOD::CaloCluster* originalCluster = *clusElementLink; + m_cluster = new xAOD::CaloCluster(); + newClusContainer.push_back(m_cluster); + + const CaloClusterCellLink* theOldCellLinks = originalCluster->getCellLinks(); + + CaloClusterCellLink *newLinks = new CaloClusterCellLink(*theOldCellLinks); + m_cluster->addCellLink(newLinks); + m_cluster->setClusterSize(xAOD::CaloCluster::Topo_420); + CaloClusterKineHelper::calculateKine(m_cluster,true,true); + + m_cluster->setRawE(m_cluster->calE()); + m_cluster->setRawEta(m_cluster->calEta()); + m_cluster->setRawPhi(m_cluster->calPhi()); + m_cluster->setRawM(m_cluster->calM()); + m_matchCluster = std::make_unique<eflowMatchCluster>(this); } @@ -70,11 +86,7 @@ void eflowRecCluster::replaceClusterByCopyInContainer(xAOD::CaloClusterContainer } xAOD::CaloCluster* eflowRecCluster::getClusterForModification(xAOD::CaloClusterContainer* container) { - if (!m_isTouchable){ - replaceClusterByCopyInContainer(container); - m_isTouchable = true; - } - return const_cast<xAOD::CaloCluster*>(getCluster()); + return getCluster(); } bool eflowRecCluster::isEOverPFail(bool consistencySigmaCut, bool useGoldenMode) { -- GitLab