ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterCopier.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: CaloClusterCopier.h
8PACKAGE: offline/Calorimeter/CaloRec
9
10AUTHORS: D. Rousseau, copied from LArClusterCopier from H. Ma
11CREATED: Sep 2005
12 See header file.
13
14********************************************************************/
15
16#include "CaloClusterCopier.h"
21
23
24
25// -------------------------------------------------------------
26// Constructor
27// -------------------------------------------------------------
29 const std::string& name,
30 const IInterface* parent):
31 AthAlgTool(type, name, parent),
32 m_clustersKey(""),
33 m_copyCells(true),m_useClusterPosition(false),m_etCut(-1.), m_clusterSize(xAOD::CaloCluster_v1::CSize_Unknown)
34{
35 declareInterface<CaloClusterCollectionProcessor> (this);
36 declareProperty("ClustersName",m_clustersKey);
37 declareProperty("CopyCells",m_copyCells);
38 declareProperty("UseClusterPosition",m_useClusterPosition);
39 declareProperty("etCut",m_etCut);
40}
41
42// -------------------------------------------------------------
43// Destructor
44// -------------------------------------------------------------
46= default;
47
49
50 ATH_MSG_INFO( " Careful: CaloClusterCopier only copy eta0 phi0" );
51
52 if (!m_copyCells){
53 ATH_MSG_INFO( " Do not copy cells " );
54 // ATH_MSG_ERROR( " CopyCell=False : Possibility to copy cluster without cells not implemented yet. Ignored." );
55
56 } else {
57 ATH_MSG_WARNING( " Copy of cluster with cells not well tested " );
58 }
59 ATH_CHECK(m_clustersKey.initialize());
60
61 return StatusCode::SUCCESS;
62
63}
64
65StatusCode
66CaloClusterCopier::execute(const EventContext& ctx,
67 xAOD::CaloClusterContainer* clusColl) const
68{
69 ATH_MSG_DEBUG("Executing CaloClusterCopier");
71
72 xAOD::CaloClusterContainer::const_iterator it = inputContainer->begin();
73 xAOD::CaloClusterContainer::const_iterator it_e = inputContainer->end();
74 for(; it!=it_e;++it) {
75 const xAOD::CaloCluster* old = *it;
76 if (m_etCut < 0 || std::fabs(old->et()) > m_etCut) {
77 // make the cluster
78 xAOD::CaloCluster* cluster_ptr = CaloClusterStoreHelper::makeCluster(clusColl,old->getCellLinks()->getCellContainer());
80 cluster_ptr->setEta0(old->eta());
81 cluster_ptr->setPhi0(old->phi());
82 } else {
83 cluster_ptr->setEta0(old->eta0());
84 cluster_ptr->setPhi0(old->phi0());
85 }
86
87 cluster_ptr->setClusterSize(m_clusterSize);
88
89 if (m_copyCells){
90 //Copy constructor for cell-link object??
91 //CaloClusterCellLink* links=new CaloClusterCellLink(oldCellLinks->getCellContainer());
92 //cluster_ptr->addCellLink(links);
93 // get all the cells
94 xAOD::CaloCluster::const_cell_iterator it_cell=old->cell_begin();
95 xAOD::CaloCluster::const_cell_iterator it_cell_e=old->cell_end();
96 // put the cell in cluster
97 int nhit = 0;
98 for(; it_cell!=it_cell_e; ++it_cell) {
99 cluster_ptr->addCell(it_cell.index(),1.0);
100 ++nhit;
101 }
102 //update kine!
103 CaloClusterKineHelper::calculateKine(cluster_ptr,false,true); //No weight at this point!
104 ATH_MSG_DEBUG(" Number of cells = " <<nhit);
105 }// end if m_copyCells
106 }//end if et cut
107 }//end loop over input clusters
108
109 ATH_MSG_DEBUG("Done with copying clusters, number of clusters= " << clusColl->size());
110 return StatusCode::SUCCESS;
111}
112
113
115
116 if(name()=="LArgamClusterMaker.larClusterCopier"){
118 }else if(name()=="LAr35ClusterMaker.larClusterCopier35"){
120 }else if(name()=="LAr37ClusterMaker.larClusterCopier37"){
122 }else if(name()=="LArgamClusterMaker.larClusterCopiergam"){
124 }else if(name()=="LArgam35ClusterMaker.larClusterCopiergam35"){
126 }else if(name()=="LArgam37ClusterMaker.larClusterCopiergam37"){
128 }else if (name()=="EMTopo35ClusterMaker.TopoEMCopier35") {
130 }
131
132 ATH_MSG_DEBUG("Name, Cluster size = " << name() << " " << m_clusterSize);
133
134}
135//xAOD::CaloCluster_v1::
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *) const override
Execute on an entire collection of clusters.
CaloClusterCopier(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clustersKey
virtual StatusCode initialize() override
xAOD::CaloCluster::ClusterSize m_clusterSize
virtual ~CaloClusterCopier() override
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
size_type size() const noexcept
Returns the number of elements in the collection.
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly const version)
void setClusterSize(const ClusterSize)
Get cluster size.
void setPhi0(flt_t)
Set raw of cluster seed.
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.