diff --git a/Reconstruction/eflowRec/eflowRec/eflowRecCluster.h b/Reconstruction/eflowRec/eflowRec/eflowRecCluster.h index 8f8d3b41b210e178e47c08822f64c94160c69092..6be4e7200d7b1102ae4e036758d8371c6452f265 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 00a81a032fc5b05dce3122162b36e7304a73b32b..ccf170f4898c218cb76646c2b9b6e641a959d524 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 9cfcf34144abd87a26876d4f407536a21933821e..9f08028ef5e0d5a5df45f4321d5ed86cc195cc7b 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) {