ATLAS Offline Software
Loading...
Searching...
No Matches
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
5template<class NAV>
6CaloCompositeCellBase<NAV>::CaloCompositeCellBase() : NAV()
7{ }
8
9template<class NAV>
10CaloCompositeCellBase<NAV>::~CaloCompositeCellBase()
11{ }
12
13template<class NAV>
14void
15CaloCompositeCellBase<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
41template<class NAV>
42void
43CaloCompositeCellBase<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
52template<class NAV>
53void
54CaloCompositeCellBase<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
65template<class NAV>
66void
67CaloCompositeCellBase<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
77template<class NAV>
78void
79CaloCompositeCellBase<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
86template<class NAV>
87void
88CaloCompositeCellBase<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
96template<class NAV>
97void
98CaloCompositeCellBase<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
107template<class NAV>
108void
109CaloCompositeCellBase<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
120template<class NAV>
121void
122CaloCompositeCellBase<NAV>::removeCell(const CaloCellContainer* pContainer,
123 size_t& iCell)
124{
125 this->removeCell((pContainer->operator[])(iCell));
126}
127
128template<class NAV>
129void
130CaloCompositeCellBase<NAV>::removeCells()
131{
132 this->removeAll();
133}
134
135template<class NAV>
136double
137CaloCompositeCellBase<NAV>::getCellWeight(const CaloCell* pCell) const
138{
139 // from Navigable
140 return this->getParameter(pCell);
141}
142
143template<class NAV>
144double
145CaloCompositeCellBase<NAV>::getCellWeight(const CaloCellContainer* pContainer,
146 size_t& iCell) const
147{
148 // from Navigable
149 return this->getParameter(pContainer,iCell);
150}
151
152template<class NAV>
153double
154CaloCompositeCellBase<NAV>::getCellWeight(cell_iterator& cellIter) const
155{
156 return this->getParameter(cellIter);
157}
158
159template<class NAV>
160const CaloCellContainer*
161CaloCompositeCellBase<NAV>::getCellContainer(const CaloCell* pCell) const
162{
163 return this->getContainer(pCell);
164}
165
166template<class NAV>
167const CaloCellContainer*
168CaloCompositeCellBase<NAV>::getCellContainer(cell_iterator& cellIter) const
169{
170 return this->getContainer(cellIter);
171}
172
173template<class NAV>
174bool CaloCompositeCellBase<NAV>::getCellIndex(const CaloCell* pCell,
175 size_t& iCell) const
176{
177 return this->getIndex(pCell,iCell);
178}
179
180template<class NAV>
181bool CaloCompositeCellBase<NAV>::getCellIndex(cell_iterator& cellIter,
182 size_t& iCell) const
183{
184 return this->getIndex(cellIter,iCell);
185}
186
187template<class NAV>
188typename CaloCompositeCellBase<NAV>::cell_iterator
189CaloCompositeCellBase<NAV>::cell_begin() const
190{
191 return this->begin();
192}
193
194template<class NAV>
195typename CaloCompositeCellBase<NAV>::cell_iterator
196CaloCompositeCellBase<NAV>::cell_end() const
197{
198 return this->end();
199}
200
201template<class NAV>
202unsigned int CaloCompositeCellBase<NAV>::getNumberOfCells() const
203{
204 return this->nCells();
205}