ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CaloTowerSeg::SubSegIterator< TOWER_ITERATOR > Class Template Reference

Iterator over a rectangular window of towers. More...

#include <CaloTowerSeg.h>

Inheritance diagram for CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >:
Collaboration diagram for CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >:

Public Member Functions

 SubSegIterator (const TOWER_ITERATOR &it, size_t nphi, size_t nphi_skip, size_t phipos)
 Constructor. More...
 
SubSegIteratoroperator++ ()
 Advance to the next tower in the window. More...
 
size_t itower () const
 The tower index to which the iterator is referring. More...
 

Static Public Member Functions

static SubSegIterator make (TOWER_ITERATOR beg, const SubSeg &subseg)
 Construct a new iterator for iterating over a window. More...
 

Private Attributes

size_t m_nphi
 
size_t m_nphi_skip
 
size_t m_phipos
 
size_t m_phipos2
 
size_t m_itower
 

Detailed Description

template<class TOWER_ITERATOR>
class CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >

Iterator over a rectangular window of towers.

This is based on an existing iterator over all towers, TOWER_ITERATOR. This iterator should supply operator++ and operator+=.

There is no end iterator defined; you need to count the iterations up to the size of the window.

This is a little complicated; we need to take phi wrapping into account too.

Here's some bad ascii art to help illustrate:

       *...............*
       * ! ! ! ! ! ! ! *
       *...*******.....*
       * ! *0|1|2* ! ! *        phi ->
       *...*-----*.....*
       * ! *3|4|5* ! ! *    eta
       *...*******.....*     |
       * ! ! ! ! ! ! ! *     v
       ***.........*****
       *2* ! ! ! ! *0|1*
       *-*.........*****
       *5* ! ! ! ! *3|4*
       ***.........*****
       *               *

Consider the upper window first. We initialize the base TOWER_ITERATOR pointing at the proper tower. Then m_phipos counts the phi index within the window; here from 0 to 2. When m_phipos reaches the window size, m_nphi, then we need go to the next row. We add m_nphi_skip to the tower iterator, reset the entries iterator appropriately, and reset m_phipos to 0.

For the case of phi-wrapping, this mostly still works: we just need to initialize m_phipos appropriately. In the example here of the lower window, m_phipos should start at 2. Then we apply the skip when we go across to the right half of the window, and we just wrap around at the right edge; here, we go from the tower numbered 1 to 5.

But this means that in this case, we don't visit the towers in order, so we need some way of getting the tower number within the window from the iterator, so that we can apply the mapping to the correct tower. That's done by m_itower and m_phipos2. m_phipos2 is similar to m_phipos, except that it always starts at 0. Thus, then m_phipos reaches m_nphi, we need to skip; when m_phipos2 reaches m_nphi, we're shifting down to the next eta row.

Definition at line 335 of file CaloTowerSeg.h.

Constructor & Destructor Documentation

◆ SubSegIterator()

template<class TOWER_ITERATOR >
CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::SubSegIterator ( const TOWER_ITERATOR &  it,
size_t  nphi,
size_t  nphi_skip,
size_t  phipos 
)

Constructor.

Parameters
itIterator of the starting tower.
entryIterator of the corresponding starting entry.
storeThe CaloTowerStore within which we're iterating.
nphiThe phi size of the window.
nphi_skipThe number of towers to skip to go from the right edge of the window to the left. Should be (phi-size of store) - (phi-size of window) + 1
phiposThe starting phi position for the iteration. Should be 0 if there's no phi wrapping. Otherwise, it's the phi index (0-based) of the window tower at the left side of the store.

Definition at line 652 of file CaloTowerSeg.h.

657  : TOWER_ITERATOR (it),
658  m_nphi (nphi),
659  m_nphi_skip (nphi_skip),
660  m_phipos (phipos),
661  m_phipos2 (0),
662  m_itower (0)
663 {
664 }

Member Function Documentation

◆ itower()

template<class TOWER_ITERATOR >
size_t CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::itower ( ) const
inline

The tower index to which the iterator is referring.

This is the index within the window. 0-based.

Definition at line 710 of file CaloTowerSeg.h.

711 {
712  return m_itower + m_phipos;
713 }

◆ make()

template<class TOWER_ITERATOR >
CaloTowerSeg::SubSegIterator< TOWER_ITERATOR > CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::make ( TOWER_ITERATOR  beg,
const SubSeg subseg 
)
static

Construct a new iterator for iterating over a window.

Parameters
begTower iterator pointing at the start of the segmentation within which this window is defined.
subsegThe window over which we want to iterate.

Definition at line 608 of file CaloTowerSeg.h.

610 {
611  const CaloTowerSeg& parent = subseg.parent();
612  size_t itower;
613  size_t phipos;
614 
615  if (subseg.phimax() < subseg.phimin()) {
616  // phi wraparound case
617  itower = parent.etaphi (subseg.etamin(), 1);
618  phipos = subseg.nphi() - subseg.phimax();
619  }
620  else {
621  // no phi wrapping
622  itower = parent.etaphi (subseg.etamin(), subseg.phimin());
623  phipos = 0;
624  }
625 
626  beg += itower;
627  return SubSegIterator (beg,
628  subseg.nphi(),
629  parent.nphi() - subseg.nphi() + 1,
630  phipos);
631 }

◆ operator++()

template<class TOWER_ITERATOR >
CaloTowerSeg::SubSegIterator< TOWER_ITERATOR > & CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::operator++ ( )
inline

Advance to the next tower in the window.

Note: The iteration may not visit the towers in index order. Use itower() to find the index of the tower to which the iterator is currently referring.

Definition at line 677 of file CaloTowerSeg.h.

678 {
679  // Advance phi position.
680  ++m_phipos;
681  if (m_phipos < m_nphi) {
682  // Not to the gap yet; just advance underlying iterator.
684  }
685  else {
686  // At the gap. Skip ahead by the size of the gap,
687  // and reset the phi position.
688  m_phipos = 0;
689  TOWER_ITERATOR::operator+= (m_nphi_skip);
690  }
691 
692  // Bump the tower index counter when we wrap around in phi.
693  if (++m_phipos2 >= m_nphi) {
694  m_phipos2 = 0;
695  m_itower += m_nphi;
696  }
697 
698  return *this;
699 }

Member Data Documentation

◆ m_itower

template<class TOWER_ITERATOR >
size_t CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::m_itower
private

Definition at line 394 of file CaloTowerSeg.h.

◆ m_nphi

template<class TOWER_ITERATOR >
size_t CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::m_nphi
private

Definition at line 390 of file CaloTowerSeg.h.

◆ m_nphi_skip

template<class TOWER_ITERATOR >
size_t CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::m_nphi_skip
private

Definition at line 391 of file CaloTowerSeg.h.

◆ m_phipos

template<class TOWER_ITERATOR >
size_t CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::m_phipos
private

Definition at line 392 of file CaloTowerSeg.h.

◆ m_phipos2

template<class TOWER_ITERATOR >
size_t CaloTowerSeg::SubSegIterator< TOWER_ITERATOR >::m_phipos2
private

Definition at line 393 of file CaloTowerSeg.h.


The documentation for this class was generated from the following file:
CaloTowerSeg::SubSeg::phimin
index_t phimin() const
Lower phi index.
Definition: CaloTowerSeg.h:560
CaloTowerSeg::SubSeg::parent
const CaloTowerSeg & parent() const
Definition: CaloTowerSeg.h:258
CaloTowerSeg::SubSegIterator::m_phipos2
size_t m_phipos2
Definition: CaloTowerSeg.h:393
skel.it
it
Definition: skel.GENtoEVGEN.py:423
CaloTowerSeg::SubSeg::etamin
index_t etamin() const
Lower eta index.
Definition: CaloTowerSeg.h:538
CaloTowerSeg::SubSegIterator::m_itower
size_t m_itower
Definition: CaloTowerSeg.h:394
CaloTowerSeg::SubSegIterator::m_phipos
size_t m_phipos
Definition: CaloTowerSeg.h:392
CaloTowerSeg::nphi
index_t nphi() const
Retrieve number of bins.
Definition: CaloTowerSeg.h:428
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CaloTowerSeg::SubSegIterator::itower
size_t itower() const
The tower index to which the iterator is referring.
Definition: CaloTowerSeg.h:710
CaloTowerSeg::SubSegIterator::m_nphi
size_t m_nphi
Definition: CaloTowerSeg.h:390
LVL1TGCTrigger::operator++
TGCHBChip operator++(TGCHBChip &rs, int)
Definition: TGCHighPtBoard.h:28
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
CaloTowerSeg::SubSeg::phimax
index_t phimax() const
Upper phi index (inclusive). phimax<phimin indicates phi wraparound.
Definition: CaloTowerSeg.h:571
CaloTowerSeg::SubSegIterator::m_nphi_skip
size_t m_nphi_skip
Definition: CaloTowerSeg.h:391
CaloTowerSeg
Data object stores CaloTower segmentation.
Definition: CaloTowerSeg.h:37
CaloTowerSeg::SubSegIterator::SubSegIterator
SubSegIterator(const TOWER_ITERATOR &it, size_t nphi, size_t nphi_skip, size_t phipos)
Constructor.
Definition: CaloTowerSeg.h:653
CaloTowerSeg::subseg
SubSeg subseg(double eta, double deta, double phi, double dphi) const
Return a window within the current segmentation.
Definition: CaloTowerSeg.cxx:23
CaloTowerSeg::SubSeg::nphi
size_t nphi() const
The number of towers in the phi direction in this window.
Definition: CaloTowerSeg.cxx:72