ATLAS Offline Software
Loading...
Searching...
No Matches
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.
SubSegIteratoroperator++ ()
 Advance to the next tower in the window.
size_t itower () const
 The tower index to which the iterator is referring.

Static Public Member Functions

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

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 317 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 655 of file CaloTowerSeg.h.

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 713 of file CaloTowerSeg.h.

714{
715 return m_itower + m_phipos;
716}

◆ 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 // Should never happen, but check explicitly to prevent a coverity warning.
627 if (itower == outOfRange) std::abort();
628
629 beg += itower;
630 return SubSegIterator (beg,
631 subseg.nphi(),
632 parent.nphi() - subseg.nphi() + 1,
633 phipos);
634}
size_t itower() const
The tower index to which the iterator is referring.
SubSegIterator(const TOWER_ITERATOR &it, size_t nphi, size_t nphi_skip, size_t phipos)
Constructor.

◆ 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 680 of file CaloTowerSeg.h.

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

Member Data Documentation

◆ m_itower

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

Definition at line 376 of file CaloTowerSeg.h.

◆ m_nphi

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

Definition at line 372 of file CaloTowerSeg.h.

◆ m_nphi_skip

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

Definition at line 373 of file CaloTowerSeg.h.

◆ m_phipos

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

Definition at line 374 of file CaloTowerSeg.h.

◆ m_phipos2

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

Definition at line 375 of file CaloTowerSeg.h.


The documentation for this class was generated from the following file: