ATLAS Offline Software
CaloCompositeCellBase.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 template<class NAV>
6 CaloCompositeCellBase<NAV>::CaloCompositeCellBase() : NAV()
7 { }
8 
9 template<class NAV>
10 CaloCompositeCellBase<NAV>::~CaloCompositeCellBase()
11 { }
12 
13 template<class NAV>
14 void
15 CaloCompositeCellBase<NAV>::addCell(const CaloCellContainer* pContainer,
16  const CaloCell* pCell,
17  double weight,
18  size_t iCell /*= -1*/)
19 {
20  // cell already in collection
21  if ( this->contains(pCell) )
22  {
23  // update weight
24  double newWeight = weight + this->getCellWeight(pCell);
25  // reweight the cell
26  this->reweightCell(pCell,newWeight);
27  }
28  else
29  {
30  // from Navigable base
31  // Insert by index if available; else by pointer.
32  if (iCell != static_cast<size_t> (-1))
33  this->insertElement(pContainer,iCell,weight);
34  else
35  this->insertElement(pContainer,pCell,weight);
36  // update kinematics
37  this->updateKine(pCell,weight);
38  }
39 }
40 
41 template<class NAV>
42 void
43 CaloCompositeCellBase<NAV>::addCell(const CaloCellContainer* pContainer,
44  size_t& iCell,
45  double weight)
46 {
47  // forward to cell pointer method
48  if ( iCell < pContainer->size() )
49  this->addCell(pContainer,((pContainer->operator[])(iCell)),weight, iCell);
50 }
51 
52 template<class NAV>
53 void
54 CaloCompositeCellBase<NAV>::addUniqueCell(const CaloCellContainer* pContainer,
55  size_t iCell,
56  double weight,
57  size_t size_hint /*= 0*/)
58 {
59  if ( iCell < pContainer->size() ) {
60  this->insertElement(pContainer,iCell,weight,size_hint);
61  this->updateKine((*pContainer)[iCell],weight);
62  }
63 }
64 
65 template<class NAV>
66 void
67 CaloCompositeCellBase<NAV>::addUniqueCellNoKine(const CaloCellContainer* pContainer,
68  size_t iCell,
69  double weight,
70  size_t size_hint /*= 0*/)
71 {
72  if ( iCell < pContainer->size() ) {
73  this->insertElement(pContainer,iCell,weight,size_hint);
74  }
75 }
76 
77 template<class NAV>
78 void
79 CaloCompositeCellBase<NAV>::reweightCell(const CaloCell* pCell,double weight)
80 {
81  double adjWeight = weight - this->getCellWeight(pCell);
82  this->reweight(pCell,weight);
83  this->updateKine(pCell,adjWeight);
84 }
85 
86 template<class NAV>
87 void
88 CaloCompositeCellBase<NAV>::reweightCell(const CaloCellContainer* pContainer,
89  size_t& iCell,
90  double weight)
91 {
92  if ( iCell < pContainer->size() )
93  this->reweightCell((pContainer->operator[])(iCell),weight);
94 }
95 
96 template<class NAV>
97 void
98 CaloCompositeCellBase<NAV>::reweightCell(cell_iterator& cellIter,
99  double weight)
100 {
101  // keep this implementation separated (faster!)
102  double adjWeight = weight - this->getCellWeight(cellIter);
103  this->reweight(cellIter,weight);
104  this->updateKine(*cellIter,adjWeight);
105 }
106 
107 template<class NAV>
108 void
109 CaloCompositeCellBase<NAV>::removeCell(const CaloCell* pCell)
110 {
111  if ( this->contains(pCell) )
112  {
113  // update kinematics
114  this->updateKine(pCell,-(this->getCellWeight(pCell)));
115  // from Navigable base
116  this->remove(pCell);
117  }
118 }
119 
120 template<class NAV>
121 void
122 CaloCompositeCellBase<NAV>::removeCell(const CaloCellContainer* pContainer,
123  size_t& iCell)
124 {
125  this->removeCell((pContainer->operator[])(iCell));
126 }
127 
128 template<class NAV>
129 void
130 CaloCompositeCellBase<NAV>::removeCells()
131 {
132  this->removeAll();
133 }
134 
135 template<class NAV>
136 double
137 CaloCompositeCellBase<NAV>::getCellWeight(const CaloCell* pCell) const
138 {
139  // from Navigable
140  return this->getParameter(pCell);
141 }
142 
143 template<class NAV>
144 double
145 CaloCompositeCellBase<NAV>::getCellWeight(const CaloCellContainer* pContainer,
146  size_t& iCell) const
147 {
148  // from Navigable
149  return this->getParameter(pContainer,iCell);
150 }
151 
152 template<class NAV>
153 double
154 CaloCompositeCellBase<NAV>::getCellWeight(cell_iterator& cellIter) const
155 {
156  return this->getParameter(cellIter);
157 }
158 
159 template<class NAV>
160 const CaloCellContainer*
161 CaloCompositeCellBase<NAV>::getCellContainer(const CaloCell* pCell) const
162 {
163  return this->getContainer(pCell);
164 }
165 
166 template<class NAV>
167 const CaloCellContainer*
168 CaloCompositeCellBase<NAV>::getCellContainer(cell_iterator& cellIter) const
169 {
170  return this->getContainer(cellIter);
171 }
172 
173 template<class NAV>
174 bool CaloCompositeCellBase<NAV>::getCellIndex(const CaloCell* pCell,
175  size_t& iCell) const
176 {
177  return this->getIndex(pCell,iCell);
178 }
179 
180 template<class NAV>
181 bool CaloCompositeCellBase<NAV>::getCellIndex(cell_iterator& cellIter,
182  size_t& iCell) const
183 {
184  return this->getIndex(cellIter,iCell);
185 }
186 
187 template<class NAV>
188 typename CaloCompositeCellBase<NAV>::cell_iterator
189 CaloCompositeCellBase<NAV>::cell_begin() const
190 {
191  return this->begin();
192 }
193 
194 template<class NAV>
195 typename CaloCompositeCellBase<NAV>::cell_iterator
196 CaloCompositeCellBase<NAV>::cell_end() const
197 {
198  return this->end();
199 }
200 
201 template<class NAV>
202 unsigned int CaloCompositeCellBase<NAV>::getNumberOfCells() const
203 {
204  return this->nCells();
205 }