ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | Friends | List of all members
CaloTowerSeg Class Reference

Data object stores CaloTower segmentation. More...

#include <CaloTowerSeg.h>

Collaboration diagram for CaloTowerSeg:

Classes

class  SubSeg
 A rectangular window within the segmentation. More...
 
class  SubSegIterator
 Iterator over a rectangular window of towers. More...
 

Public Types

typedef size_t index_t
 Type for eta, phi indices. More...
 

Public Member Functions

 CaloTowerSeg ()
 Default constructor. More...
 
 CaloTowerSeg (index_t neta, index_t nphi, double etamin, double etamax, double phimin=s_range.phi_min(), double phimax=s_range.phi_max())
 Constructor. More...
 
 ~CaloTowerSeg ()
 Destructor. More...
 
index_t neta () const
 Retrieve number of \( \eta \) bins. More...
 
index_t nphi () const
 Retrieve number of \( \varphi \) bins. More...
 
double deta () const
 Retrieve bin size \( \Delta \eta \). More...
 
double dphi () const
 Retrieve bin size \( \Delta \varphi \). More...
 
double etamin () const
 Retrieve lower boundary \( \eta \) value range. More...
 
double etamax () const
 Retrieve upper boundary \( \eta \) value range. More...
 
double phimin () const
 Retrieve lower boundary \( \varphi \) value range. More...
 
double phimax () const
 Retrieve upper boundary \( \varphi \) value range. More...
 
bool inbound (index_t etaInd, index_t phiInd) const
 Check index range in \( \eta \) and \( \varphi \). More...
 
bool inbound (double etaVal, double phiVal) const
 Check value range in \( \eta \) and \( \varphi \). More...
 
index_t etaphi (index_t etaInd, index_t phiInd) const
 Returns combined continous index from \( \eta \), \( \varphi \) indices. More...
 
double eta (index_t etaInd) const
 Returns \( \eta \) value for a given \( \eta \) index. More...
 
index_t etaIndex (double etaVal) const
 Returns \( \eta \) index for a given \( \eta \) value. More...
 
index_t etaIndex (index_t comInd) const
 Returns \( \eta \) index for a given combined index. More...
 
double phi (index_t phiInd) const
 Returns \( \varphi \) value for a given \( \varphi \) index. More...
 
index_t phiIndex (double phiVal) const
 Returns \( \varphi \) index for a given \( \varphi \) value. More...
 
index_t phiIndex (index_t comInd) const
 Returns \( \varphi \) index for a given combined index. More...
 
SubSeg subseg (double eta, double deta, double phi, double dphi) const
 Return a window within the current segmentation. More...
 

Static Public Attributes

static const index_t outOfRange = static_cast<index_t> (-1)
 Used to flag out-of-range indices. More...
 

Private Attributes

index_t m_neta
 Number of \( \eta \) bins. More...
 
index_t m_nphi
 Number of \( \varphi \) bins. More...
 
double m_etamin
 Lower boundary \( \eta \) value range. More...
 
double m_etamax
 Upper boundary \( \eta \) value range. More...
 
double m_phimin
 Lower boundary \( \varphi \) value range. More...
 
double m_phimax
 Upper boundary \( \varphi \) value range. More...
 
double m_deta
 Bin size \( \Delta \eta \). More...
 
double m_dphi
 Bin size \( \Delta \varphi \). More...
 

Static Private Attributes

static const CaloPhiRange s_range
 

Friends

class CaloTowerSegCnv_p1
 

Detailed Description

Data object stores CaloTower segmentation.

Author
S. Rajagopalan srini.nosp@m.r@bn.nosp@m.l.gov
P. Loch loch@.nosp@m.phys.nosp@m.ics.a.nosp@m.rizo.nosp@m.na.ed.nosp@m.u
Date
April 1, 2005
Version
2

The CaloTowerSeg class generates an object which stores the tower segmentation in reguar \( \Delta \eta \times \Delta \varphi \) bins. The bin index convention is \( i \in [1,n] \), where \( n \) is the number of bins for a given variable. In addition a continously running index \( k \) is providing by combining the \( \eta \) and \( \varphi \) indices, with \( k \in [0,N-1] \). \( N \) is total number of bins (sum of the numbers of \( \eta \) and \( \varphi \) bins).

Definition at line 36 of file CaloTowerSeg.h.

Member Typedef Documentation

◆ index_t

typedef size_t CaloTowerSeg::index_t

Type for eta, phi indices.

Definition at line 59 of file CaloTowerSeg.h.

Constructor & Destructor Documentation

◆ CaloTowerSeg() [1/2]

CaloTowerSeg::CaloTowerSeg ( )
inline

Default constructor.

Instantiates useless empty tower grid.

Definition at line 69 of file CaloTowerSeg.h.

77  :

◆ CaloTowerSeg() [2/2]

CaloTowerSeg::CaloTowerSeg ( index_t  neta,
index_t  nphi,
double  etamin,
double  etamax,
double  phimin = s_range.phi_min(),
double  phimax = s_range.phi_max() 
)
inline

Constructor.

Parameters
netainput number of \( \eta \) bins
nphiinput number of \( \varphi \) bins
etamininput lower boundary \( \eta \) value range
etamaxinput upper boundary \( \eta \) value range
phimininput lower boundary \( \varphi \) value range
phimaxinput upper boundary \( \varphi \) value range

\( \varphi \) by default covers the full circle. CaloPhiRange::phi_min() and CaloPhiRange::phi_max() are used to implement the correct \( \varphi \) range convention.

May have phimin > phimax for the case of wraparound.

Only regular (equidistant) bins are supported in both directions.

Definition at line 93 of file CaloTowerSeg.h.

202  {

◆ ~CaloTowerSeg()

CaloTowerSeg::~CaloTowerSeg ( )
inline

Destructor.

Definition at line 105 of file CaloTowerSeg.h.

202  {

Member Function Documentation

◆ deta()

double CaloTowerSeg::deta ( ) const
inline

Retrieve bin size \( \Delta \eta \).

Definition at line 433 of file CaloTowerSeg.h.

434 {
435  return m_deta;
436 }

◆ dphi()

double CaloTowerSeg::dphi ( ) const
inline

Retrieve bin size \( \Delta \varphi \).

Definition at line 438 of file CaloTowerSeg.h.

439 {
440  return m_dphi;
441 }

◆ eta()

double CaloTowerSeg::eta ( index_t  etaInd) const
inline

Returns \( \eta \) value for a given \( \eta \) index.

Parameters
etaIndinput \( \eta \) index

Can return \( \eta \) value outside of allowed value range if index out of range (no internal check).

Definition at line 516 of file CaloTowerSeg.h.

517 {
518  return m_etamin + (etaInd-0.5) * m_deta ;
519 }

◆ etaIndex() [1/2]

CaloTowerSeg::index_t CaloTowerSeg::etaIndex ( double  etaVal) const
inline

Returns \( \eta \) index for a given \( \eta \) value.

Parameters
etaValinput \( \eta \) value

Returns size_t(-1) in case of \( \eta \) being out of allowed value range.

Definition at line 489 of file CaloTowerSeg.h.

490 {
491  return ( etaVal >= m_etamin && etaVal <= m_etamax )
492  ? (index_t)floor( ( etaVal - m_etamin ) / m_deta ) + 1
493  : outOfRange;
494 }

◆ etaIndex() [2/2]

CaloTowerSeg::index_t CaloTowerSeg::etaIndex ( index_t  comInd) const
inline

Returns \( \eta \) index for a given combined index.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
comIndinput combined index

Can return an invalid \( \eta \) index if comInd is invalid.

Definition at line 495 of file CaloTowerSeg.h.

496 {
497  return (index_t)(comInd/m_nphi) + 1;
498 }

◆ etamax()

double CaloTowerSeg::etamax ( ) const
inline

Retrieve upper boundary \( \eta \) value range.

Definition at line 448 of file CaloTowerSeg.h.

449 {
450  return m_etamax;
451 }

◆ etamin()

double CaloTowerSeg::etamin ( ) const
inline

Retrieve lower boundary \( \eta \) value range.

Definition at line 443 of file CaloTowerSeg.h.

444 {
445  return m_etamin;
446 }

◆ etaphi()

size_t CaloTowerSeg::etaphi ( index_t  etaInd,
index_t  phiInd 
) const
inline

Returns combined continous index from \( \eta \), \( \varphi \) indices.

Parameters
etaIndinput \( \eta \) index
phiIndinput \( \varphi \) index

Calculates a common running index from \(\eta\) and \(\phi\) . Returns size_t(-1) if input outside of allowed index ranges.

Definition at line 481 of file CaloTowerSeg.h.

482 {
483  return this->inbound(etaInd,phiInd)
484  ? (etaInd-1) * m_nphi + (phiInd-1)
485  : outOfRange;
486 }

◆ inbound() [1/2]

bool CaloTowerSeg::inbound ( double  etaVal,
double  phiVal 
) const
inline

Check value range in \( \eta \) and \( \varphi \).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
etaValinput \( \eta \) coordinate
phiValinput \( \varphi \) coordinate

Returns true when both eta and phi are inside their respective allowed value ranges.

Definition at line 470 of file CaloTowerSeg.h.

471 {
472  if ( ! ( etaVal >= m_etamin && etaVal <= m_etamax ) ) return false;
473  if (m_phimax > m_phimin)
474  return phiVal >= m_phimin && phiVal <= m_phimax;
475  else
476  return phiVal <= m_phimax || phiVal >= m_phimin;
477 }

◆ inbound() [2/2]

bool CaloTowerSeg::inbound ( index_t  etaInd,
index_t  phiInd 
) const
inline

Check index range in \( \eta \) and \( \varphi \).

Parameters
etaIndinput \( \eta \) index
phiIndinput \( \varphi \) index

Returns true when both eta and phi are within their respective allowed index ranges.

Definition at line 463 of file CaloTowerSeg.h.

464 {
465  return
466  etaInd >= 1 && etaInd <= m_neta &&
467  phiInd >= 1 && phiInd <= m_nphi;
468 }

◆ neta()

CaloTowerSeg::index_t CaloTowerSeg::neta ( ) const
inline

Retrieve number of \( \eta \) bins.

Definition at line 423 of file CaloTowerSeg.h.

424 {
425  return m_neta;
426 }

◆ nphi()

CaloTowerSeg::index_t CaloTowerSeg::nphi ( ) const
inline

Retrieve number of \( \varphi \) bins.

Definition at line 428 of file CaloTowerSeg.h.

429 {
430  return m_nphi;
431 }

◆ phi()

double CaloTowerSeg::phi ( index_t  phiInd) const
inline

Returns \( \varphi \) value for a given \( \varphi \) index.

Parameters
phiIndinput \( \varphi \) index

Can return \( \varphi \) value outside of allowed value range if index out of range (no internal check).

Definition at line 521 of file CaloTowerSeg.h.

522 {
523  double ret = m_phimin + (phiInd-0.5) * m_dphi;
524  if (m_phimin > m_phimax)
525  ret = s_range.fix (ret);
526  return ret;
527 }

◆ phiIndex() [1/2]

CaloTowerSeg::index_t CaloTowerSeg::phiIndex ( double  phiVal) const
inline

Returns \( \varphi \) index for a given \( \varphi \) value.

Parameters
phiValinput \( \varphi \) value

Returns size_t(-1) in case of \( \varphi \) being out of allowed value range.

Definition at line 499 of file CaloTowerSeg.h.

500 {
501  if (m_phimax > m_phimin)
502  return ( phiVal >= m_phimin && phiVal <= m_phimax )
503  ? (index_t)floor( ( phiVal - m_phimin ) / m_dphi ) + 1
504  : outOfRange;
505  else
506  return ( phiVal >= m_phimin || phiVal <= m_phimax )
507  ? (index_t)floor( s_range.diff ( phiVal, m_phimin ) / m_dphi ) + 1
508  : outOfRange;
509 }

◆ phiIndex() [2/2]

CaloTowerSeg::index_t CaloTowerSeg::phiIndex ( index_t  comInd) const
inline

Returns \( \varphi \) index for a given combined index.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
comIndinput combined index

Can return an invalid \( \varphi \) index if comInd is invalid.

Definition at line 510 of file CaloTowerSeg.h.

511 {
512  return (index_t)(comInd % m_nphi) + 1;
513 }

◆ phimax()

double CaloTowerSeg::phimax ( ) const
inline

Retrieve upper boundary \( \varphi \) value range.

Definition at line 458 of file CaloTowerSeg.h.

459 {
460  return m_phimax;
461 }

◆ phimin()

double CaloTowerSeg::phimin ( ) const
inline

Retrieve lower boundary \( \varphi \) value range.

Definition at line 453 of file CaloTowerSeg.h.

454 {
455  return m_phimin;
456 }

◆ subseg()

CaloTowerSeg::SubSeg CaloTowerSeg::subseg ( double  eta,
double  deta,
double  phi,
double  dphi 
) const

Return a window within the current segmentation.

The window is centered at eta/phi with half-widths deta/dphi.

Definition at line 23 of file CaloTowerSeg.cxx.

25 {
26  using index_t = SubSeg::index_t;
27 
28  index_t etamin = this->etaIndex (eta - deta + 0.001);
29  if (etamin == CaloTowerSeg::outOfRange)
30  etamin = 1;
31 
32  index_t etamax = this->etaIndex (eta + deta - 0.001);
33  if (etamax == CaloTowerSeg::outOfRange)
34  etamax = this->neta();
35 
36  index_t phimin = this->phiIndex (CaloPhiRange::fix (phi - dphi + 0.001));
37  if (phimin == CaloTowerSeg::outOfRange)
38  phimin = this->phiIndex (this->phimin());
39 
40  index_t phimax = this->phiIndex (CaloPhiRange::fix (phi + dphi - 0.001));
41  if (phimax == CaloTowerSeg::outOfRange)
42  phimax = this->phiIndex (this->phimax() - this->dphi()/2);
43 
44  return SubSeg (*this, etamin, etamax, phimin, phimax);
45 }

Friends And Related Function Documentation

◆ CaloTowerSegCnv_p1

friend class CaloTowerSegCnv_p1
friend

Definition at line 407 of file CaloTowerSeg.h.

Member Data Documentation

◆ m_deta

double CaloTowerSeg::m_deta
private

Bin size \( \Delta \eta \).

Definition at line 429 of file CaloTowerSeg.h.

◆ m_dphi

double CaloTowerSeg::m_dphi
private

Bin size \( \Delta \varphi \).

Definition at line 431 of file CaloTowerSeg.h.

◆ m_etamax

double CaloTowerSeg::m_etamax
private

Upper boundary \( \eta \) value range.

Definition at line 422 of file CaloTowerSeg.h.

◆ m_etamin

double CaloTowerSeg::m_etamin
private

Lower boundary \( \eta \) value range.

Definition at line 420 of file CaloTowerSeg.h.

◆ m_neta

index_t CaloTowerSeg::m_neta
private

Number of \( \eta \) bins.

Definition at line 415 of file CaloTowerSeg.h.

◆ m_nphi

index_t CaloTowerSeg::m_nphi
private

Number of \( \varphi \) bins.

Definition at line 417 of file CaloTowerSeg.h.

◆ m_phimax

double CaloTowerSeg::m_phimax
private

Upper boundary \( \varphi \) value range.

Definition at line 426 of file CaloTowerSeg.h.

◆ m_phimin

double CaloTowerSeg::m_phimin
private

Lower boundary \( \varphi \) value range.

Definition at line 424 of file CaloTowerSeg.h.

◆ outOfRange

const index_t CaloTowerSeg::outOfRange = static_cast<index_t> (-1)
static

Used to flag out-of-range indices.

Definition at line 62 of file CaloTowerSeg.h.

◆ s_range

const CaloPhiRange CaloTowerSeg::s_range
staticprivate

Definition at line 435 of file CaloTowerSeg.h.


The documentation for this class was generated from the following files:
CaloTowerSeg::inbound
bool inbound(index_t etaInd, index_t phiInd) const
Check index range in and .
Definition: CaloTowerSeg.h:463
CaloTowerSeg::eta
double eta(index_t etaInd) const
Returns value for a given index.
Definition: CaloTowerSeg.h:516
CaloTowerSeg::m_etamin
double m_etamin
Lower boundary value range.
Definition: CaloTowerSeg.h:420
CaloTowerSeg::neta
index_t neta() const
Retrieve number of bins.
Definition: CaloTowerSeg.h:423
CaloTowerSeg::m_etamax
double m_etamax
Upper boundary value range.
Definition: CaloTowerSeg.h:422
CaloTowerSeg::SubSeg::index_t
CaloTowerSeg::index_t index_t
Definition: CaloTowerSeg.h:222
CaloTowerSeg::deta
double deta() const
Retrieve bin size .
Definition: CaloTowerSeg.h:433
CaloTowerSeg::nphi
index_t nphi() const
Retrieve number of bins.
Definition: CaloTowerSeg.h:428
CaloTowerSeg::m_dphi
double m_dphi
Bin size .
Definition: CaloTowerSeg.h:431
CaloTowerSeg::phimin
double phimin() const
Retrieve lower boundary value range.
Definition: CaloTowerSeg.h:453
CaloTowerSeg::m_deta
double m_deta
Bin size .
Definition: CaloTowerSeg.h:429
CaloTowerSeg::dphi
double dphi() const
Retrieve bin size .
Definition: CaloTowerSeg.h:438
CaloTowerSeg::phi
double phi(index_t phiInd) const
Returns value for a given index.
Definition: CaloTowerSeg.h:521
CaloTowerSeg::index_t
size_t index_t
Type for eta, phi indices.
Definition: CaloTowerSeg.h:59
CaloTowerSeg::phimax
double phimax() const
Retrieve upper boundary value range.
Definition: CaloTowerSeg.h:458
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
CaloTowerSeg::m_nphi
index_t m_nphi
Number of bins.
Definition: CaloTowerSeg.h:417
CaloTowerSeg::etamax
double etamax() const
Retrieve upper boundary value range.
Definition: CaloTowerSeg.h:448
CaloTowerSeg::phiIndex
index_t phiIndex(double phiVal) const
Returns index for a given value.
Definition: CaloTowerSeg.h:499
CaloTowerSeg::etamin
double etamin() const
Retrieve lower boundary value range.
Definition: CaloTowerSeg.h:443
CaloTowerSeg::s_range
static const CaloPhiRange s_range
Definition: CaloTowerSeg.h:435
CaloTowerSeg::outOfRange
static const index_t outOfRange
Used to flag out-of-range indices.
Definition: CaloTowerSeg.h:62
CaloTowerSeg::m_phimax
double m_phimax
Upper boundary value range.
Definition: CaloTowerSeg.h:426
CaloTowerSeg::etaIndex
index_t etaIndex(double etaVal) const
Returns index for a given value.
Definition: CaloTowerSeg.h:489
CaloTowerSeg::m_phimin
double m_phimin
Lower boundary value range.
Definition: CaloTowerSeg.h:424
CaloPhiRange::diff
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Definition: CaloPhiRange.cxx:22
CaloTowerSeg::m_neta
index_t m_neta
Number of bins.
Definition: CaloTowerSeg.h:415