ATLAS Offline Software
CaloClusterNavigable.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOEVENT_CALOCLUSTERNAVIGABLE_H
6 #define CALOEVENT_CALOCLUSTERNAVIGABLE_H
7 
15 #include "AthLinks/ElementLink.h"
16 
17 #include "Navigation/INavigable.h"
18 
20 
21 #include "CaloEvent/CaloCell.h"
23 
24 #include "CaloEvent/CaloCellLink.h"
26 
27 #include <algorithm>
28 
31 
32 
33 class CaloClusterNavigable : virtual public INavigable
34 {
35  public:
36 
39 
42  CaloCellLink* pLink);
43 
46 
48  virtual ~CaloClusterNavigable();
49 
52 
54  void putElement(const CaloCellContainer* pContainer,
55  const CaloCell* pCell,
56  const double& weight=double(1.));
58  void putElement(const CaloCellContainer* pContainer,
59  size_t& iCell,
60  const double& weight=double(1.));
62  void insertElement(const CaloCellContainer* pContainer,
63  const CaloCell* pCell,
64  const double& weight=double(1.));
66  void insertElement(const CaloCellContainer* pContainer,
67  size_t& iCell,
68  const double& weight=double(1.));
70  void insertElement(const CaloCellContainer* pContainer,
71  size_t iCell,
72  const double weight,
73  size_t size_hint);
76  const double weight,
77  size_t size_hint = 0);
78 
80  void reweight(const CaloCell* pCell,const double& weight=double(1.));
81 
83  void reweight(const CaloCellContainer* pContainer, size_t& iCell,
84  const double& weight=double(1.));
85 
87  void reweight(object_iter& cellIter, const double& weight=double(1.));
88 
89 
91  bool remove(const CaloCell* pCell);
92 
94  bool remove(const CaloCellContainer* pContainer,size_t& iCell);
95 
97  bool removeAll();
98 
100  bool contains(const CaloCell* pCell) const;
101 
103  bool contains(const CaloCellContainer* pContainer, size_t& iCell) const;
104 
105  // find constituent
106  // object_iter find(const CaloCell* pCell) const;
107  // object_iter find(const CaloCellContainer* pContainer, size_t& iCell) const;
108 
110  // Access to Constituents //
112 
114  virtual object_iter begin() const;
116  virtual object_iter end() const;
118  virtual unsigned int nCells() const;
119 
121  double getParameter(const CaloCell* pCell) const;
123  double getParameter(const CaloCellContainer* pContainer,size_t& iCell) const;
125  double getParameter(object_iter& cellIter) const;
126 
128  const CaloCellContainer* getContainer(const CaloCell* pCell) const;
130  const CaloCellContainer* getContainer(object_iter cellIter) const;
131 
133  bool getIndex(const CaloCell* pCell,size_t& iCell) const;
135  bool getIndex(object_iter cellIter,size_t& iCell) const;
136 
138  virtual void fillToken(INavigationToken& iToken) const;
140  virtual void fillToken(INavigationToken& iToken,
141  const std::any& rPar) const;
142 
143  virtual bool isCellLinkValid() const ;
144 
145  typedef
147 
149  const cell_link_type& cellLink() const { return m_cellLink; }
150 
152  {
154  }
155 
156 
157 protected:
158 
167 
169  const CaloCellLink* getCellLink() const;
170 
171  bool setCellLink(CaloCellLinkContainer* pLink);
172 
173  bool setLinkStore(CaloCellLink* pLink,bool ownStores=true);
174 
176  const CaloCellLink* getCellLinkPtr() const;
177 
179 
180 
181 private:
183  // CaloCellLink* m_cellLinkPointer;
184 
187 
188 };
189 
190 inline
192  bool ownStores)
193 {
194  m_cellLink.setElement(pLink);
195  m_ownLinkStore = ownStores;
196  // m_cellLinkPointer = pLink;
197  return *m_cellLink != 0;
198 }
199 
200 inline
202  const CaloCell* pCell,
203  const double& weight)
204 {
205  (this->getCellLink())->putElement(pContainer,pCell,weight);
206 }
207 
208 inline
210  size_t& iCell,
211  const double& weight)
212 {
213  (this->getCellLink())->putElement(pContainer,iCell,weight);
214 }
215 
216 inline
218  const CaloCell* pCell,
219  const double& weight)
220 {
221  (this->getCellLink())->insertElement(pContainer,pCell,weight);
222 }
223 
224 inline
226  size_t& iCell,
227  const double& weight)
228 {
229  (this->getCellLink())->insertElement(pContainer,iCell,weight);
230 }
231 
232 inline
234  size_t iCell,
235  const double weight,
236  size_t size_hint)
237 {
238  (this->getCellLink())->insertElement(pContainer,iCell,weight,size_hint);
239 }
240 
241 inline
242 void
244  const double weight,
245  size_t size_hint)
246 {
247  (this->getCellLink())->insertElement(el,weight,size_hint);
248 }
249 
250 inline
251 void CaloClusterNavigable::reweight(const CaloCell* pCell,const double& weight)
252 {
253  (this->getCellLink())->reweight(pCell,weight);
254 }
255 
256 inline
258  size_t& iCell,
259  const double& weight)
260 {
261  (this->getCellLink())->reweight(pContainer,iCell,weight);
262 }
263 
264 inline
265 void CaloClusterNavigable::reweight(object_iter& cellIter,const double& weight)
266 {
267  (this->getCellLink())->reweight(cellIter,weight);
268 }
269 
270 inline
272 {
273  return (this->getCellLink())->remove(pCell);
274 }
275 
276 inline
278  size_t& iCell)
279 {
280  return (this->getCellLink())->remove(pContainer,iCell);
281 }
282 
283 inline
285 {
286  return (this->getCellLink())->removeAll();
287 }
288 
289 inline
290 bool CaloClusterNavigable::contains(const CaloCell* pCell) const
291 {
292  return (this->getCellLink())->contains(pCell);
293 }
294 
295 inline
297  size_t& iCell) const
298 {
299  return (this->getCellLink())->contains(pContainer,iCell);
300 }
301 
302 inline
304 {
305  return (this->getCellLink())->begin();
306 }
307 
308 inline
310 {
311  return (this->getCellLink())->end();
312 }
313 
314 inline
315 unsigned int CaloClusterNavigable::nCells() const
316 {
317 
318  const CaloCellLink* link = this->getCellLinkPtr();
319  if (link)
320  return link->size();
321  else
322  return 0;
323 
324 }
325 
326 inline
328 {
329  return (this->getCellLink())->getParameter(pCell);
330 }
331 
332 inline
334  size_t& iCell) const
335 {
336  return (this->getCellLink())->getParameter(pContainer,iCell);
337 }
338 
339 inline
341 {
342  return (this->getCellLink())->getParameter(cellIter);
343 }
344 
345 inline
346 const CaloCellContainer*
348 {
349  return (this->getCellLink())->getContainer(pCell);
350 }
351 
352 inline
353 const CaloCellContainer*
355 {
356  return (this->getCellLink())->getContainer(cellIter);
357 }
358 
359 inline
360 bool CaloClusterNavigable::getIndex(const CaloCell* pCell,size_t& iCell) const
361 {
362  return (this->getCellLink())->getIndex(pCell,iCell);
363 }
364 
365 inline
366 bool CaloClusterNavigable::getIndex(object_iter cellIter,size_t& iCell) const
367 {
368  return (this->getCellLink())->getIndex(cellIter,iCell);
369 }
370 
371 //inline
372 //CaloClusterNavigable::object_iter
373 //CaloClusterNavigable::find(const CaloCell* pCell) const
374 //{
375 // const CaloCellLink* pLink = this->getCellLink();
376 // return pLink->find(pCell);
377 //}
378 
379 
380 //inline
381 //CaloClusterNavigable::object_iter
382 //CaloClusterNavigable::find(const CaloCellContainer* pContainer,
383 // size_t& iCell) const
384 //{
385 // const CaloCellLink* pLink = this->getCellLink();
386 // return pLink->find(pContainer,iCell);
387 //}
388 
389 inline
391 {
392  if ( this->getCellLink() )
393  (this->getCellLink())->fillToken(iToken);
394 }
395 
396 inline void
398  const std::any& rPar) const
399 {
400  if ( this->getCellLink() )
401  (this->getCellLink())->fillToken(iToken,rPar);
402 }
403 
404 inline bool
406 {
407  if (!pLinkStore)
408  return false;
409 
410  CaloCellLink* pLink = *m_cellLink != 0
411  ? const_cast<CaloCellLink*>(*m_cellLink) : (CaloCellLink*)0;
412 
413  m_ownLinkStore = !pLinkStore->ownElements();
415  pLink,
416  m_cellLink);
417 }
418 
419 //inline const CaloCellLink*
420 //CaloClusterNavigable::getCellLink() const
421 //{
422 // return m_cellLinkPointer != 0 ? m_cellLinkPointer : *m_cellLink;
423 //}
424 
425 inline CaloCellLink*
427 {
428  CaloCellLink* ret;
429  if (m_cellLink.isValid())
430  ret = const_cast<CaloCellLink*>(*m_cellLink);
431  else
432  ret = 0;
433  return ret;
434 
435 }
436 
437 inline const CaloCellLink*
439  const CaloCellLink* ret;
440  if (m_cellLink.isValid())
441  ret = *m_cellLink;
442  else
443  ret = 0;
444  return ret;
445 }
446 
447 
448 inline
450 {
451  return this->getCellLinkPtr() !=0;
452 }
453 
454 
455 #endif
456 
INavigable.h
CaloClusterNavigable::remove
bool remove(const CaloCell *pCell)
remove object from the Navigable
Definition: CaloClusterNavigable.h:271
CaloClusterNavigable::cellLink
const cell_link_type & cellLink() const
Access to underlying link.
Definition: CaloClusterNavigable.h:149
CaloClusterNavigable::removeAll
bool removeAll()
remove all objects from the Navigable
Definition: CaloClusterNavigable.h:284
CaloClusterNavigable::getParameter
double getParameter(const CaloCell *pCell) const
public container access: relational parameter retrieval
Definition: CaloClusterNavigable.h:327
CaloClusterNavigable::resetCellLink
void resetCellLink(const cell_link_type &cellLink)
Definition: CaloClusterNavigable.h:151
CaloClusterLinkTemplate.h
CaloClusterNavigable::getContainer
const CaloCellContainer * getContainer(const CaloCell *pCell) const
public container access: retrieve Container for given object pointer
Definition: CaloClusterNavigable.h:347
CaloClusterNavigable::cell_link_type
CaloClusterLinkTemplate< CaloCellLinkContainer >::link_type cell_link_type
Definition: CaloClusterNavigable.h:146
CaloClusterContainerCnv_p5
Definition: CaloClusterContainerCnv_p5.h:27
CaloCell.h
CaloClusterNavigable::reweight
void reweight(const CaloCell *pCell, const double &weight=double(1.))
re-weight (overwrite old weight)
Definition: CaloClusterNavigable.h:251
CaloClusterNavigable::nCells
virtual unsigned int nCells() const
size of object access
Definition: CaloClusterNavigable.h:315
CaloClusterNavigable::CaloClusterNavigable
CaloClusterNavigable()
default constructor
Definition: CaloClusterNavigable.cxx:15
CaloClusterNavigable::setCellLink
bool setCellLink(CaloCellLinkContainer *pLink)
Definition: CaloClusterNavigable.h:405
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
GeoPrimitives.h
CaloClusterNavigable::m_cellLink
cell_link_type m_cellLink
Local pointer to cell store.
Definition: CaloClusterNavigable.h:186
CaloClusterNavigable::end
virtual object_iter end() const
end iterator for public object access
Definition: CaloClusterNavigable.h:309
CaloClusterContainerCnv_p6
Definition: CaloClusterContainerCnv_p6.h:27
CaloClusterLinkTemplate::setLink
static bool setLink(CONT *pCont, DOBJ *pDat, ELEM &rElm)
Definition: CaloClusterLinkTemplate.h:26
ret
T ret(T t)
Definition: rootspy.cxx:260
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
INavigationToken
Definition: INavigationToken.h:24
CaloClusterNavigable::CaloClusterContainerCnvTestMakeCluster
friend class CaloClusterContainerCnvTestMakeCluster
Definition: CaloClusterNavigable.h:166
INavigable
Definition: INavigable.h:18
CaloClusterNavigable::fillToken
virtual void fillToken(INavigationToken &iToken) const
fill token for navigation
Definition: CaloClusterNavigable.h:390
CaloClusterNavigable::getIndex
bool getIndex(const CaloCell *pCell, size_t &iCell) const
get index of child in original container, given a pointer
Definition: CaloClusterNavigable.h:360
CaloClusterNavigable::begin
virtual object_iter begin() const
begin iterator for public object access
Definition: CaloClusterNavigable.h:303
CaloClusterNavigable::object_iter
CaloCellLink::cell_iterator object_iter
external cell iterator type
Definition: CaloClusterNavigable.h:51
CaloClusterContainerCnv_p3
Definition: CaloClusterContainerCnv_p3.h:29
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloClusterNavigable::putElement
void putElement(const CaloCellContainer *pContainer, const CaloCell *pCell, const double &weight=double(1.))
add element to the Navigable: use pointer
Definition: CaloClusterNavigable.h:201
CaloClusterNavigable
Navigable part of CaloCluster, use CaloCellLink.
Definition: CaloClusterNavigable.h:34
Navigable::size
virtual unsigned int size() const
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloClusterContainerCnv_p7
Definition: CaloClusterContainerCnv_p7.h:28
CaloClusterNavigable::getCellLink
CaloCellLink * getCellLink()
Definition: CaloClusterNavigable.cxx:39
CaloClusterContainerCnv_p2
Definition: CaloClusterContainerCnv_p2.h:32
CaloClusterNavigable::contains
bool contains(const CaloCell *pCell) const
check if constituent is already there
Definition: CaloClusterNavigable.h:290
CaloClusterContainerCnv_p4
Definition: CaloClusterContainerCnv_p4.h:27
CaloClusterNavigable::setLinkStore
bool setLinkStore(CaloCellLink *pLink, bool ownStores=true)
Definition: CaloClusterNavigable.h:191
CaloClusterNavigable::m_ownLinkStore
bool m_ownLinkStore
Definition: CaloClusterNavigable.h:178
CaloClusterNavigable::getCellLinkPtr
CaloCellLink * getCellLinkPtr()
Definition: CaloClusterNavigable.h:426
checker_macros.h
Define macros for attributes used to control the static checker.
CaloClusterNavigable::~CaloClusterNavigable
virtual ~CaloClusterNavigable()
destructor
Definition: CaloClusterNavigable.cxx:34
CaloClusterNavigable::isCellLinkValid
virtual bool isCellLinkValid() const
Definition: CaloClusterNavigable.h:449
CaloClusterNavigable::insertElement
void insertElement(const CaloCellContainer *pContainer, const CaloCell *pCell, const double &weight=double(1.))
insert element without checking if already in store: use element pointer
Definition: CaloClusterNavigable.h:217
CaloClusterLinkTemplate
template class for CaloClusterLink
Definition: CaloClusterLinkTemplate.h:23
CaloClusterStoreHelper
Definition: CaloClusterStoreHelper.h:20