ATLAS Offline Software
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 
7 NAME: CaloClusterCopier.h
8 PACKAGE: offline/Calorimeter/CaloRec
9 
10 AUTHORS: D. Rousseau, copied from LArClusterCopier from H. Ma
11 CREATED: 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):
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  }
60 
61  return StatusCode::SUCCESS;
62 
63 }
64 
66 CaloClusterCopier::execute(const EventContext& ctx,
67  xAOD::CaloClusterContainer* clusColl) const
68 {
69  ATH_MSG_DEBUG("Executing CaloClusterCopier");
71 
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::
CaloClusterStoreHelper::makeCluster
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
Definition: CaloClusterStoreHelper.cxx:13
CaloClusterCopier::execute
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *) const override
Execute on an entire collection of clusters.
Definition: CaloClusterCopier.cxx:66
CaloClusterKineHelper.h
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloClusterCopier::~CaloClusterCopier
virtual ~CaloClusterCopier() override
CaloClusterCopier::CaloClusterCopier
CaloClusterCopier(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CaloClusterCopier.cxx:28
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloClusterCopier::m_clustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clustersKey
Definition: CaloClusterCopier.h:71
skel.it
it
Definition: skel.GENtoEVGEN.py:423
xAOD::CaloCluster_v1::SW_55gam
@ SW_55gam
Definition: CaloCluster_v1.h:92
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::CaloCluster_v1::setEta0
void setEta0(flt_t)
xAOD::CaloCluster_v1::SW_37gam
@ SW_37gam
Definition: CaloCluster_v1.h:94
CaloClusterCopier::m_etCut
float m_etCut
Definition: CaloClusterCopier.h:74
xAOD::CaloCluster_v1::SW_37ele
@ SW_37ele
Definition: CaloCluster_v1.h:90
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
CaloClusterCopier.h
xAOD::CaloCluster_v1::setPhi0
void setPhi0(flt_t)
Set raw of cluster seed.
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::CaloCluster_v1::SW_35gam
@ SW_35gam
Definition: CaloCluster_v1.h:93
CaloClusterCopier::initialize
virtual StatusCode initialize() override
Definition: CaloClusterCopier.cxx:48
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CaloClusterCopier::m_clusterSize
xAOD::CaloCluster::ClusterSize m_clusterSize
Definition: CaloClusterCopier.h:75
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloClusterCopier::m_copyCells
bool m_copyCells
Definition: CaloClusterCopier.h:72
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CaloClusterCopier::m_useClusterPosition
bool m_useClusterPosition
Definition: CaloClusterCopier.h:73
CaloClusterCopier::getClusterSize
void getClusterSize()
Definition: CaloClusterCopier.cxx:114
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
errorcheck.h
Helpers for checking error return status codes and reporting errors.
xAOD::CaloCluster_v1::SW_55ele
@ SW_55ele
Definition: CaloCluster_v1.h:88
CaloClusterStoreHelper.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::CaloCluster_v1::setClusterSize
void setClusterSize(const ClusterSize)
Get cluster size.
Definition: CaloCluster_v1.cxx:369
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::CaloCluster_v1::addCell
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
Definition: CaloCluster_v1.h:771
CaloClusterContainer.h
CaloClusterKineHelper::calculateKine
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.
Definition: CaloClusterKineHelper.cxx:223
xAOD::CaloCluster_v1::SW_35ele
@ SW_35ele
Definition: CaloCluster_v1.h:89
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.