ATLAS Offline Software
CaloTopoSplitterHashCluster.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------
6 // File and Version Information:
7 //
8 // Description: see CaloTopoSplitterHashCluster.h
9 //
10 // Environment:
11 // Software developed for the ATLAS Detector at CERN LHC
12 //
13 // Author List:
14 // Sven Menke
15 //
16 //-----------------------------------------------------------------------
17 
18 //-----------------------
19 // This Class's Header --
20 //-----------------------
23 
24 
25 //-----------
26 // Methods --
27 //-----------
28 
30 {
31  if ( !m_parentCluster ) {
35  }
36 
37  Base::add(hashCell);
38  m_hasValidEnergy = false;
39  m_centroid.reset();
40 }
41 
43 {
45  {
48  if (iter != m_members.end())
49  m_members.erase (iter);
50  }
51 
52  float ratio = cell->getSignedRatio();
53  if ( ratio >= m_maxRatio ) {
54  for(iterator iter = begin(); iter!= end(); ++iter)
55  {
56  float myRatio = iter->getSignedRatio();
57  if ( iter == m_members.begin() || myRatio > m_maxRatio )
58  m_maxRatio = myRatio;
59  }
60  }
61  m_hasValidEnergy = false;
62  m_centroid.reset();
63 }
64 
67 {
68  if ( !m_parentCluster) {
71  }
72 
73  Base::add(rClus);
74  m_hasValidEnergy = false;
75  m_centroid.reset();
76 }
77 
79 {
80  if ( !m_hasValidEnergy)
81  this->calcEnergy();
82  return m_energy;
83 }
84 
85 const HepGeom::Vector3D<double> & CaloTopoSplitterHashCluster::getCentroid()
86 {
87  if ( !m_centroid)
88  this->calcCentroid();
89  return m_centroid.value();
90 }
91 
93 {
94  if ( ! m_members.empty() ) {
95  m_energy = 0;
96  for( iterator iter=begin(); iter!= end(); ++iter)
97  {
98  CaloTopoSplitterClusterCell *pClusCell = *iter;
100  float myWeight = itrCell.weight();//pClusCell->getParentCluster()->getCellWeight(itrCell);
101  if ( pClusCell->getShared() ) {
102  if ( pClusCell->getCaloTopoTmpHashCluster() == this )
103  myWeight *= pClusCell->getSharedWeight();
104  else
105  myWeight *= (1.-pClusCell->getSharedWeight());
106  }
107  m_energy += myWeight*itrCell->e();
108  }
109  }
110  m_hasValidEnergy = true;
111 }
112 
114 {
115  m_centroid.emplace(0,0,0);
116 
117  if ( !m_members.empty() ) {
118  double thisAbsEng,absEng = 0;
119 
120  for( iterator iter = begin(); iter != end(); ++iter)
121  {
122  CaloTopoSplitterClusterCell *pClusCell = *iter;
123  xAOD::CaloCluster::cell_iterator itrCell = pClusCell->getCellIterator();
124  float myWeight = itrCell.weight();//pClusCell->getParentCluster()->getCellWeight(itrCell);
125  if ( pClusCell->getShared() ) {
126  if ( pClusCell->getCaloTopoTmpHashCluster() == this )
127  myWeight *= pClusCell->getSharedWeight();
128  else
129  myWeight *= (1.-pClusCell->getSharedWeight());
130  }
131 
132  thisAbsEng = fabs(myWeight*itrCell->e());
133  absEng += thisAbsEng;
134  HepGeom::Vector3D<double> thisPos(itrCell->x(), itrCell->y(), itrCell->z());
135  m_centroid.value() += thisAbsEng*thisPos;
136  }
137  if ( absEng > 0 )
138  m_centroid.value() *= (1./absEng);
139  }
140 }
141 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloTopoTmpHashCell::getCaloTopoTmpClusterCell
const T * getCaloTopoTmpClusterCell() const
Definition: CaloTopoTmpHashCell.h:59
CaloTopoSplitterHashCluster::m_energy
float m_energy
Definition: CaloTopoSplitterHashCluster.h:43
CaloTopoSplitterHashCluster::getEnergy
float getEnergy()
Definition: CaloTopoSplitterHashCluster.cxx:78
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CaloTopoTmpHashCell
Definition: CaloTopoTmpHashCell.h:22
CaloCell::y
float y() const
get y (through CaloDetDescrElement)
Definition: CaloCell.h:420
CaloTopoSplitterHashCluster::getCentroid
const HepGeom::Vector3D< double > & getCentroid()
Definition: CaloTopoSplitterHashCluster.cxx:85
CaloTopoSplitterHashCluster::calcEnergy
void calcEnergy()
Definition: CaloTopoSplitterHashCluster.cxx:92
CaloTopoSplitterHashCluster
Definition: CaloTopoSplitterHashCluster.h:34
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
CaloTopoTmpHashClusterBase< CaloTopoSplitterClusterCell >::begin
iterator begin()
Definition: CaloTopoTmpHashClusterBase.h:92
CaloTopoSplitterClusterCell::getParentClusterIndex
size_t getParentClusterIndex() const
Definition: CaloTopoSplitterClusterCell.h:80
CxxUtils::pointer_list::end
iterator end()
Iterator at the end of the container.
CaloTopoSplitterClusterCell
Definition: CaloTopoSplitterClusterCell.h:29
CaloTopoSplitterHashCluster::m_parentClusterIndex
size_t m_parentClusterIndex
Definition: CaloTopoSplitterHashCluster.h:42
CaloTopoSplitterHashCluster::add
void add(HashCell &hashCell)
Definition: CaloTopoSplitterHashCluster.cxx:29
CxxUtils::pointer_list::begin
iterator begin()
Iterator at the beginning of the container.
CaloTopoSplitterClusterCell::getShared
bool getShared() const
Definition: CaloTopoSplitterClusterCell.h:85
CaloTopoTmpHashClusterBase< CaloTopoSplitterClusterCell >::add
void add(HashCell &hashCell)
Definition: CaloTopoTmpHashClusterBase.h:116
CaloTopoTmpHashClusterBase< CaloTopoSplitterClusterCell >::end
iterator end()
Definition: CaloTopoTmpHashClusterBase.h:97
CxxUtils::pointer_list::erase
void erase(iterator it)
Erase one element. O(n)
CaloTopoSplitterHashCluster::m_hasValidEnergy
bool m_hasValidEnergy
Definition: CaloTopoSplitterHashCluster.h:44
CaloTopoSplitterHashCluster::m_centroid
std::optional< HepGeom::Vector3D< double > > m_centroid
Definition: CaloTopoSplitterHashCluster.h:46
CxxUtils::pointer_list::iterator
Forward iterator over the list.
Definition: pointer_list.h:281
CaloTopoSplitterClusterCell::getSharedWeight
const float & getSharedWeight()
Definition: CaloTopoSplitterClusterCell.h:111
CaloTopoTmpHashClusterBase< CaloTopoSplitterClusterCell >::m_maxRatio
float m_maxRatio
Definition: CaloTopoTmpHashClusterBase.h:39
CaloTopoSplitterClusterCell::getCellIterator
const xAOD::CaloCluster::cell_iterator & getCellIterator() const
Definition: CaloTopoSplitterClusterCell.h:75
python.compareTCTs.ratio
ratio
Definition: compareTCTs.py:295
CaloTopoSplitterHashCluster::calcCentroid
void calcCentroid()
Definition: CaloTopoSplitterHashCluster.cxx:113
CaloTopoSplitterClusterCell.h
CaloCell::z
float z() const
get z (through CaloDetDescrElement)
Definition: CaloCell.h:427
CaloTopoSplitterClusterCell::getParentCluster
const xAOD::CaloCluster * getParentCluster() const
Definition: CaloTopoSplitterClusterCell.h:70
CaloCell::x
float x() const
get x (through CaloDetDescrElement)
Definition: CaloCell.h:413
CaloTopoSplitterHashCluster.h
CaloTopoSplitterHashCluster::m_parentCluster
const xAOD::CaloCluster * m_parentCluster
Definition: CaloTopoSplitterHashCluster.h:41
CxxUtils::pointer_list_base::empty
bool empty() const
Test to see if the container is empty.
CaloTopoSplitterClusterCell::getCaloTopoTmpHashCluster
const CaloTopoSplitterHashCluster * getCaloTopoTmpHashCluster() const
Definition: CaloTopoSplitterClusterCell.h:121
CaloTopoTmpHashClusterBase< CaloTopoSplitterClusterCell >::m_members
pointer_list m_members
Definition: CaloTopoTmpHashClusterBase.h:38
CaloTopoSplitterHashCluster::remove
void remove(const HashCell &hashCell)
Definition: CaloTopoSplitterHashCluster.cxx:42