ATLAS Offline Software
Loading...
Searching...
No Matches
Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef CALOEVENT_CALOTOWERCONTAINER_H
8#define CALOEVENT_CALOTOWERCONTAINER_H
9/********************************************************************
10
11NAME: CaloTowerContainer.h
12PACKAGE: offline/Calorimeter/CaloRec
13
14AUTHORS: H. Ma, S. Rajagopalan
15CREATED: Oct, 2000
16 Originally it is LArTowerContainer in LArClusterRec
17 Moved to CaloRec package on Feb 5, 2001
18
19PURPOSE: container class for CaloTower objects.
20 Baseclass: ObjectVector<CaloTower>.
21 The tower objects are stored as CaloTower in DataVector
22 In addition to providing iterators over all towers,
23 the towers (and their et and energy) can be accessed with
24 index (ieta,iphi), or in real (eta,phi) space.
25
26 There are two ways of using this container. In standard usage,
27 the towers are in a strict rectangular grid as defined
28 by the CaloTowerSeg object passed to the constructor.
29 In this case, the container itself creates all the contained
30 towers. Clients should not attempt to modify the container
31 itself.
32
33 For efficiency, all the contained towers are either stored
34 in a single vector or in a DataPool (depending on whether
35 or not CALOTOWERCONTAINER_USES_DATAPOOL is defined).
36 In the former case, the DataVector elements are then
37 set to point into that vector.
38
39 The other usage is simply as a list of towers (this is provided
40 for the use of trigger software). In this case, the default
41 constructor must be used, and the ownership mode should
42 be set to VIEW_ELEMENTS. The only operations that modify
43 the container that are supported are insert(), push_back(),
44 and clear().
45
46
47UPDATE: MAY-11-01
48 add CLID
49
50********************************************************************/
51
52// If CALOTOWERCONTAINER_USES_DATAPOOL is set, then CaloTowers
53// will be allocated from a DataPool.
54// Otherwise, they will be allocated in an internal vector.
55//
56// This needs to be disabled for Hive
57
58#define CALOTOWERCONTAINER_USES_DATAPOOL
59
60// INCLUDE HEADER FILES:
63
65
66#include "CaloEvent/CaloTower.h"
70
71#include "boost/iterator/iterator_adaptor.hpp"
72#include <utility>
73#include <vector>
74
75
76class CaloTowerContainer : public DataVector<CaloTower>
77{
78public:
80
82 typedef size_t index_t;
83
85 // Constructors/Destructor //
87
105 CaloTowerContainer(const CaloTowerSeg& tseg, bool noTowers = false);
106
109
112
114 void swap (CaloTowerContainer& other);
115
118
119
121 // Initialization //
123
128 void init();
129
130
132 // Tower Information //
134
143 void setCalo(const CaloCell_ID::SUBCALO& nCalo);
151 size_t getCalos(std::vector<CaloCell_ID::SUBCALO>& theCalos) const;
153 size_t getNumberOfCalos() const;
154
156 double etamin() const;
158 double phimin() const;
160 double deta() const;
162 double dphi() const;
164 size_t neta() const;
166 size_t nphi() const;
167
169 const CaloTowerSeg& towerseg() const;
170
172 // Kinematics //
174
182 double et(double theEta, double thePhi) const;
190 double et(index_t etaIndex, index_t phiIndex) const;
195 double et(int etaIndex, int phiIndex) const
196 { return et((index_t)etaIndex,(index_t)phiIndex); } // temp fix!
197
205 double e(double theEta, double thePhi) const
206 { return this->energy(theEta,thePhi); }
207
214 double e(index_t etaIndex, index_t phiIndex) const
215 { return this->energy(etaIndex,phiIndex); }
216
220 double e(int etaIndex, int phiIndex) const
221 { return this->energy(etaIndex,phiIndex); }
222
230 double energy(double theEta, double thePhi) const;
238 double energy(index_t etaIndex, index_t phiIndex) const;
243 double energy(int etaIndex, int phiIndex) const
244 { return energy((index_t)etaIndex,(index_t)phiIndex); }
245
247 // Container Management //
249
256 index_t getTowerIndex(const CaloTower* aTower) const;
265 index_t getTowerIndex(index_t etaIndex, index_t phiIndex) const;
274 index_t getTowerIndex(double theEta, double thePhi) const;
281 index_t getTowerEtaIndex(const CaloTower* aTower) const;
289 index_t getTowerEtaIndex(double theEta) const;
296 index_t getTowerEtaIndex(index_t towerIndex) const;
303 index_t getTowerPhiIndex(const CaloTower* aTower) const;
311 index_t getTowerPhiIndex(double thePhi) const;
318 index_t getTowerPhiIndex(index_t towerIndex) const;
319
331 bool getTowerIndices(const CaloTower* aTower,
332 index_t& indexEta,
333 index_t& indexPhi) const;
348 bool getTowerIndices(double theEta, double thePhi,
349 index_t& indexEta,
350 index_t& indexPhi) const;
351
366 const CaloTower* getTower(index_t eta, index_t phi) const;
373 { return this->getTower(index_t(eta), index_t(phi)); }
374
379 const CaloTower* getTower(int eta, int phi) const
380 { return this->getTower(index_t(eta), index_t(phi)); }
381
389 CaloTower* getTower(double eta, double phi);
395 const CaloTower* getTower(double eta, double phi) const;
396
404 {
405 return theIndex < this->size()
406 ? (this->operator[])(theIndex)
407 : (CaloTower*)0;
408 }
409
413 const CaloTower* getTower( index_t theIndex ) const
414 {
415 return theIndex < this->size()
416 ? (this->operator[])(theIndex)
417 : (const CaloTower*)0;
418 }
419
421 index_t flagOutOfRange() const;
428 bool isOutOfRange(index_t anIndex) const;
429
430
431public:
432 //***********************************************************************
433 // We don't want to allow clients to change pointers in the container.
434 // So change DataVector operations that return lvalues to return
435 // instead rvalues.
436
437 using Base::operator[];
439
440 using Base::at;
442
443 using Base::front;
444 CaloTower* front ();
445
446 using Base::back;
447 CaloTower* back ();
448
449
460 : public boost::iterator_adaptor<iterator,
461 Base::iterator,
462 Base::value_type,
463 Base::iterator::iterator_category,
464 // Reference
465 Base::value_type>
466 {
467 private:
468 // Shorthand for the base class type.
469 typedef boost::iterator_adaptor<iterator,
472 Base::iterator::iterator_category,
475
476 public:
479
480 operator const_iterator() const
481 { return const_iterator (this->base()); }
482 };
483
484
485 typedef std::reverse_iterator<iterator> reverse_iterator;
486
487
488 using Base::begin;
489 using Base::end;
490 iterator begin();
491 iterator end();
492
493 using Base::rbegin;
494 using Base::rend;
497
498
499 //***********************************************************************
500 // We'll be disallowing most operations that modify the container.
501 // However, these operations are needed by trigger code.
502 // They are only allowed when the segmentation is null and
503 // the ownership policy is set to @c VIEW_ELEMENTS.
504
505 void insert(iterator position, iterator first, iterator last);
507 void push_back(value_type pElem);
508
509
510private:
512
513
518
520 std::vector<unsigned int> m_caloRegions;
521
522#ifndef CALOTOWERCONTAINER_USES_DATAPOOL
524 std::vector<CaloTower> m_towers;
525
526 void setTowers();
527#endif
528
530 static const index_t m_outOfRange = static_cast<index_t>(-1);
531
532
533private:
534 // Hide methods from DataVector that modify the container.
535 template <class InputIterator>
536 void assign(InputIterator first, InputIterator last);
538 template <class InputIterator>
539 void insert(iterator position, InputIterator first, InputIterator last);
542 void sort();
543 template <class COMPARE>
544 void sort(COMPARE comp);
548 void pop_back();
549 void clear();
550};
551
554
556// Inline Functions //
558
559// included calorimeter
561{
562 return m_caloRegions.size();
563}
564
565// tower binning
566inline double CaloTowerContainer::etamin() const
567{
568 return m_towerSeg.etamin();
569}
570inline double CaloTowerContainer::deta() const
571{
572 return m_towerSeg.deta();
573}
574inline size_t CaloTowerContainer::neta() const
575{
576 return m_towerSeg.neta();
577}
578inline double CaloTowerContainer::phimin() const
579{
580 return m_towerSeg.phimin();
581}
582
583inline double CaloTowerContainer::dphi() const
584{
585 return m_towerSeg.dphi();
586}
587inline size_t CaloTowerContainer::nphi() const
588{
589 return m_towerSeg.nphi();
590}
592{
593 return m_towerSeg;
594}
595
596// tower indices
599{
600 return aTower != 0
601 ? this->getTowerIndex(aTower->eta(),aTower->phi())
602 : m_outOfRange;
603}
606{
607 return m_towerSeg.etaphi(etaIndex,phiIndex);
608}
610CaloTowerContainer::getTowerIndex(double theEta, double thePhi) const
611{
612 return this->getTowerIndex(this->getTowerEtaIndex(theEta),
613 this->getTowerPhiIndex(thePhi));
614}
617{
618 return aTower != 0
619 ? this->getTowerEtaIndex(aTower->eta())
620 : m_outOfRange;
621}
624{
625 return m_towerSeg.etaIndex(theEta);
626}
629{
630 return m_towerSeg.etaIndex(combinedIndex);
631}
634{
635 return aTower != 0
636 ? this->getTowerPhiIndex(aTower->phi())
637 : m_outOfRange;
638}
641{
642 return m_towerSeg.phiIndex(thePhi);
643}
646{
647 return m_towerSeg.phiIndex(combinedIndex);
648}
649
650// useful help
656{
657 return anIndex >= this->size() || anIndex == m_outOfRange;
658}
659
664
666{
667 return Base::at(n);
668}
669
671{
672 return Base::front();
673}
674
676{
677 return Base::back();
678}
679
684
689
694
699
700
722#endif
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define SG_BASE(D, B)
Declare that class D derives from class B.
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
An STL vector of pointers that by default owns its pointed-to elements.
static Double_t sz
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
Iterator class for which the reference type is not an lvalue.
boost::iterator_adaptor< iterator, Base::iterator, Base::value_type, Base::iterator::iterator_category, Base::value_type > iterator_adaptor_
Storable container class for CaloTower.
double e(double theEta, double thePhi) const
Return the tower energy at a given grid position.
double et(double theEta, double thePhi) const
Return the tower transverse energy at a given grid position.
double et(int etaIndex, int phiIndex) const
Return the tower transverse energy at a given grid position.
CaloTowerContainer()
Default constructor.
const CaloTower * getTower(index_t theIndex) const
Returns a const pointer to a tower with a given combined index.
size_t getNumberOfCalos() const
Returns the number of included calorimeters.
void assign(InputIterator first, InputIterator last)
double e(index_t etaIndex, index_t phiIndex) const
Return the tower energy at a given grid position.
void resize(size_type sz)
index_t getTowerIndex(const CaloTower *aTower) const
Returns the combined index of a tower on the grid.
void swapElement(size_type index, value_type newElem, reference oldElem)
CaloTowerContainer & operator=(const CaloTowerContainer &other)
Assignment.
void insert(iterator position, InputIterator first, InputIterator last)
double energy(double theEta, double thePhi) const
Return the tower energy at a given grid position.
CaloTower * getTower(index_t eta, index_t phi)
Returns a pointer to a tower with given indices.
const CaloTower * getTower(int eta, int phi) const
Returns a const pointer to a tower with given indices.
CaloTower * getTower(int eta, int phi)
Returns a pointer to a tower with given indices.
bool isOutOfRange(index_t anIndex) const
Checks if an index is out of range.
double phimin() const
Return lower value range boundary.
CaloTower * getTower(index_t theIndex)
Returns a pointer to a tower with a given combined index.
double etamin() const
Return lower value range boundary.
void setCalo(const CaloCell_ID::SUBCALO &nCalo)
Adds a calorimeter index to the tower.
iterator erase(iterator position)
size_t getCalos(std::vector< CaloCell_ID::SUBCALO > &theCalos) const
Retrieve the list of used calorimeters.
iterator insert(iterator position, value_type pElem)
double energy(int etaIndex, int phiIndex) const
Return the tower energy at a given grid position.
static const index_t m_outOfRange
Index overflow indicator.
void init()
Initializes the CaloTowerContainer.
index_t getTowerEtaIndex(const CaloTower *aTower) const
Returns the index for a given tower.
std::vector< unsigned int > m_caloRegions
Vector of calorimeter regions contributing to the tower signals.
virtual ~CaloTowerContainer()
Destructor.
double e(int etaIndex, int phiIndex) const
Return the tower energy at a given grid position.
void reserve(size_type n)
index_t flagOutOfRange() const
Returns the index out-of-range indicator.
void swap(CaloTowerContainer &other)
Swap.
index_t getTowerPhiIndex(const CaloTower *aTower) const
Returns the index for a given tower.
void insert(iterator position, iterator first, iterator last)
iterator erase(iterator first, iterator last)
void push_back(value_type pElem)
bool getTowerIndices(const CaloTower *aTower, index_t &indexEta, index_t &indexPhi) const
Returns both and indices for a given tower.
const CaloTowerSeg & towerseg() const
Return a copy of the attached CaloTowerSeg.
void sort(COMPARE comp)
Data object stores CaloTower segmentation.
Data class for calorimeter cell towers.
virtual double phi() const override final
get phi data member
virtual double eta() const override final
get eta data member
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const CaloTower * operator[](size_type n) const
const CaloTower * back() const
typename DataVectorBase< CaloTower >::Base::size_type size_type
Definition DataVector.h:814
const_reverse_iterator rend() const noexcept
const CaloTower * at(size_type n) const
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
const_iterator end() const noexcept
const_reverse_iterator rbegin() const noexcept
const_iterator begin() const noexcept
const CaloTower * front() const
size_type size() const noexcept
std::string base
Definition hcg.cxx:81
OwnershipPolicy
Definition index.py:1