ATLAS Offline Software
CaloEnergyCluster.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 #include "Navigation/Navigable.h"
7 
8 #include "FourMom/P4EEtaPhiM.h"
9 
11 
12 #include "CaloEvent/CaloCell.h"
15 
16 #include <iostream>
17 
20  , P4EEtaPhiM(0.,0.,0.,0.)
21  , m_status(CaloRecoStatus())
22 { }
23 
25 
26 void
28  const CaloCell* /*const_cell_ptr*/ theCell,
29  double weight)
30 {
31  // cell already in collection
32  if ( this->contains(theCell) )
33  {
34  // update weight
35  double newWeight = weight + this->getCellWeight(theCell);
36  // reweight the cell
37  this->reweightCell(theCell,newWeight);
38  }
39  else
40  {
41  // from Navigable base
42  this->insertElement(theContainer,theCell,weight);
43  // update kinematics
44  this->updateKine(theCell,weight);
45  }
46 }
47 
48 void
50  index_type theIndex,
51  double weight)
52 {
53  if ((int)theIndex < 0) abort();
54 
55  // cell already in collection
56  if ( this->contains(theContainer,theIndex) )
57  {
58  // try
59  // {
60  // // std::cout << "Replace CaloCell @"
61  // // << (theContainer->operator[])(theIndex)
62  // // << " index " << theIndex
63  // // << " with energy "
64  // // << ((theContainer->operator[])(theIndex))->e()
65  // // << std::endl;
66  // // update weight
67  double newWeight =
68  weight + this->getCellWeight(theContainer,theIndex);
69  // change weight
70  this->reweightCell(theContainer,theIndex,newWeight);
71  // } catch(...) {
72  // std::cout << " Object ["
73  // << (typeid(*this)).name()
74  // << "] failed to insert cell @"
75  // << (theContainer->operator[])(theIndex)
76  // << " in container @"
77  // << theContainer
78  // << " with index <"
79  // << theIndex
80  // << ">" << std::endl;
81  // this->dumpStore();
82  // }
83  }
84  else
85  {
86  // from Navigable base
87  // try
88  // {
89  this->insertElement(theContainer,theIndex,weight);
90  // std::cout << "Insert CaloCell @"
91  // << (theContainer->operator[])(theIndex)
92  // << " index " << theIndex
93  // << " with energy "
94  // << ((theContainer->operator[])(theIndex))->e()
95  // << std::endl;
96  // update kinematics
97  this->updateKine((theContainer->operator[])(theIndex),weight);
98  // } catch(...) {
99  // std::cout << " Object ["
100  // << (typeid(*this)).name()
101  // << "] failed to insert cell @"
102  // << (theContainer->operator[])(theIndex)
103  // << " in container @"
104  // << theContainer
105  // << " with index <"
106  // << theIndex
107  // << ">" << std::endl;
108  // this->dumpStore();
109  }
110  // this->dumpStore();
111 }
112 
113 void
115  index_type theIndex,
116  double weight,
117  size_t size_hint)
118 {
119  if ((int)theIndex < 0) abort();
120  this->insertElement(theContainer,theIndex,weight,size_hint);
121  this->updateKine((theContainer->operator[])(theIndex),weight);
122 }
123 
124 void
126  index_type theIndex,
127  double weight,
128  size_t size_hint)
129 {
130  if ((int)theIndex < 0) abort();
131  this->insertElement(theContainer,theIndex,weight,size_hint);
132 }
133 
134 
135 void
137  index_type theIndex,
138  IProxyDict* sg,
139  double weight,
140  size_t size_hint)
141 {
142  if ((int)theIndex < 0) abort();
143  this->insertElement(theContainer,theIndex,sg,weight,size_hint);
144 }
145 
146 
147 void
149  index_type theIndex,
150  double weight,
151  size_t size_hint)
152 {
153  if ((int)theIndex < 0) abort();
154  ElementLink<CaloCellContainer> el (theContainer, theIndex);
155  this->insertElement(el,weight,size_hint);
156 }
157 
158 
159 void
160 CaloEnergyCluster::removeCell(/*CaloCellContainer::const_reference*/
161  const CaloCell* theCell)
162 {
163  if ( this->contains(theCell) )
164  {
165  // update kinematics
166  this->updateKine(theCell,
167  -(this->getCellWeight(theCell)));
168  // from Navigable base
169  this->remove(theCell);
170  }
171 }
172 
173 void
175  index_type& theIndex)
176 {
177  if ( this->contains(theContainer,theIndex) )
178  {
179  // update kinematics
180  this->updateKine((*theContainer)[theIndex],
181  -(this->getCellWeight(theContainer,theIndex)));
182 
183  // from Navigable
184  this->remove(theContainer,theIndex);
185  }
186 }
187 
188 void
190 {
191  this->removeAll();
192 }
193 
194 void
196 {
197  double adjWeight = weight - this->getCellWeight(pCell);
198  this->reweight(pCell,weight);
199  this->updateKine(pCell,adjWeight);
200 }
201 
202 void
204  index_type& refIndex,
205  double weight)
206 {
207  this->reweightCell((pContainer->operator[])(refIndex),weight);
208  // double adjWeight = weight - this->getCellWeight(pContainer,refIndex);
209  // this->reweight(pContainer,refIndex,weight);
210  // this->updateKine((pContainer->operator[])(refIndex),adjWeight);
211 }
212 
213 void
215 {
216  // keep this implementation separated (faster!)
217  double adjWeight = weight - this->getCellWeight(cellIter);
218  this->reweight(cellIter,weight);
219  this->updateKine(*cellIter,adjWeight);
220 }
221 
222 double
223 CaloEnergyCluster::getCellWeight(/*CaloCellContainer::const_reference*/
224  const CaloCell* theCell) const
225 {
226  // from Navigable
227  return this->contains(theCell)
228  ? this->getParameter(theCell)
229  : 0.;
230 }
231 
232 double
234  index_type& theIndex) const
235 {
236  // from Navigable
237  return this->contains(theContainer,theIndex)
238  ? this->getParameter(theContainer,theIndex)
239  : 0.;
240 }
241 
242 double
244 {
245  return this->getParameter(iterCell);
246 }
247 
248 const CaloCellContainer*
249 CaloEnergyCluster::getCellContainer(/*CaloCellContainer::const_reference*/
250  const CaloCell*
251  theCell) const
252 {
253  return this->getContainer(theCell);
254 }
255 
256 bool
258  index_type& theIndex) const
259 {
260  // from Navigable
261  return this->getIndex(theCell,theIndex);
262 }
263 
264 unsigned int
266 {
267  return this->size();
268 }
269 
271 {
272  return this->begin();
273 }
274 
276 {
277  return this->end();
278 }
279 
281  recStatus)
282 {
283  m_status = recStatus;
284 }
285 
287 {
288  return m_status;
289 }
CaloEnergyCluster::cell_begin
cell_iterator cell_begin() const
Retrieve a STL-type begin() iterator for the cell store.
Definition: CaloEnergyCluster.cxx:270
CaloEnergyCluster::updateKine
virtual void updateKine(const CaloCell *theCell, double weight)=0
Interface to kinematic update implementation.
CaloEnergyCluster::cell_iterator
Navigable< CaloCellContainer, double >::object_iter cell_iterator
Iterator type for cell store.
Definition: CaloEnergyCluster.h:43
Navigable< CaloCellContainer, double >::getIndex
bool getIndex(const constituent_type *aConstituent, external_index_type &theIndex) const
CaloEnergyCluster::cell_end
cell_iterator cell_end() const
Retrieve a STL-type end() iterator for the cell store.
Definition: CaloEnergyCluster.cxx:275
CaloRecoStatus::StatusIndicator
StatusIndicator
reconstruction status word
Definition: CaloRecoStatus.h:37
CaloEnergyCluster::getCellContainer
const CaloCellContainer * getCellContainer(const CaloCell *theCell) const
Retrieve the pointer to the original cell container for a given cell.
Definition: CaloEnergyCluster.cxx:249
CaloEnergyCluster::getRecoStatus
const CaloRecoStatus & getRecoStatus() const
Retrieve the reconstruction status.
Definition: CaloEnergyCluster.cxx:286
Navigable< CaloCellContainer, double >::removeAll
bool removeAll()
Definition: Navigable.h:237
CaloEnergyCluster::CaloEnergyCluster
CaloEnergyCluster()
Default constructor.
Definition: CaloEnergyCluster.cxx:18
CaloEnergyCluster::getCellWeight
double getCellWeight(const CaloCell *theCell) const
Retrieve the kinematic weight of a given cell.
Definition: CaloEnergyCluster.cxx:223
P4EEtaPhiM
Definition: P4EEtaPhiM.h:25
CaloEnergyCluster::removeCells
void removeCells()
Remove all cells without kinematic update.
Definition: CaloEnergyCluster.cxx:189
Navigable< CaloCellContainer, double >::insertElement
void insertElement(const CaloCellContainer *objectContainer, const constituent_type *constituentObject, const double &objectParameter=double(), size_t sizeHint=0)
CaloCell.h
Navigable< CaloCellContainer, double >::begin
virtual object_iter begin() const
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
Navigable< CaloCellContainer, double >::contains
bool contains(const constituent_type *aConstituent) const
CaloEnergyCluster::addUniqueCellNoKine
void addUniqueCellNoKine(const CaloCellContainer *theContainer, index_type theIndex, double weight, size_t size_hint=0)
Add a cell (very fast)
Definition: CaloEnergyCluster.cxx:125
Navigable< CaloCellContainer, double >::end
virtual object_iter end() const
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
CaloEnergyCluster.h
CaloEnergyCluster::m_status
CaloRecoStatus m_status
Calorimeter reconstruction status.
Definition: CaloEnergyCluster.h:325
Navigable< CaloCellContainer, double >::remove
bool remove(const constituent_type *aConstituent)
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Navigable< CaloCellContainer, double >::reweight
void reweight(const constituent_type *constituentObject, const double &objectParameter=double())
CaloEnergyCluster::addCell
void addCell(const CaloCellContainer *theContainer, const CaloCell *theCell, double weight)
Add a cell with global kinematic update (slow)
Definition: CaloEnergyCluster.cxx:27
CaloEnergyCluster::addUniqueCell
virtual void addUniqueCell(const CaloCellContainer *theContainer, index_type theIndex, double weight, size_t size_hint=0)
Add a cell with global kinematic update (fast)
Definition: CaloEnergyCluster.cxx:114
CaloEnergyCluster::reweightCell
void reweightCell(const CaloCell *theCell, double weight)
Reweight a cell with kinematic update.
Definition: CaloEnergyCluster.cxx:195
P4EEtaPhiM.h
CaloRecoStatus.h
Navigable< CaloCellContainer, double >::getContainer
const CaloCellContainer * getContainer(const constituent_type *aConstituent) const
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloEnergyCluster::~CaloEnergyCluster
virtual ~CaloEnergyCluster()
Destructor.
Navigable
Navigable template generalization to handle navigation.
Definition: Navigable.h:93
Navigable< CaloCellContainer, double >::getParameter
double getParameter(const constituent_type *aConstituent) const
Navigable.h
Navigable< CaloCellContainer, double >::size
virtual unsigned int size() const
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloEnergyCluster::index_type
Navigable< CaloCellContainer, double >::external_index_type index_type
Index type for CaloCellContainer.
Definition: CaloEnergyCluster.h:37
CaloEnergyCluster::getCellIndex
bool getCellIndex(const CaloCell *theCell, index_type &theIndex) const
Retrieve the index of a given cell in the cell container.
Definition: CaloEnergyCluster.cxx:257
CaloEnergyCluster::getNumberOfCells
unsigned int getNumberOfCells() const
Return the number of cells in the store.
Definition: CaloEnergyCluster.cxx:265
CaloEnergyCluster::removeCell
void removeCell(const CaloCell *theCell)
Remove a cell with kinematic update.
Definition: CaloEnergyCluster.cxx:160
CaloRecoStatus
reconstruction status indicator
Definition: CaloRecoStatus.h:12
CaloEnergyCluster::setRecoStatus
void setRecoStatus(CaloRecoStatus::StatusIndicator recStatus)
Set the reconstruction status.
Definition: CaloEnergyCluster.cxx:280