CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

PeriodicBinFinderInPhi< T > Class Template Reference

#include <PeriodicBinFinderInPhi.h>

Inheritance diagram for PeriodicBinFinderInPhi< T >:
BaseBinFinder< T >

List of all members.

Public Member Functions

virtual int binIndex (T phi) const
 returns an index in the valid range for the bin that contains phi
virtual int binIndex (int i) const
 returns an index in the valid range, modulo Nbins
virtual T binPosition (int ind) const
 the middle of the bin in radians
 PeriodicBinFinderInPhi ()
 PeriodicBinFinderInPhi (T firstPhi, int nbins)

Static Public Member Functions

static T pi ()
static T twoPi ()

Private Attributes

int theNbins
T thePhiOffset
T thePhiStep

Detailed Description

template<class T>
class PeriodicBinFinderInPhi< T >

Periodic Bin Finder around a circle for (almost) equidistant bins. Phi is the angle on the circle in radians.

Definition at line 13 of file PeriodicBinFinderInPhi.h.


Constructor & Destructor Documentation

template<class T>
PeriodicBinFinderInPhi< T >::PeriodicBinFinderInPhi ( ) [inline]

Definition at line 16 of file PeriodicBinFinderInPhi.h.

template<class T>
PeriodicBinFinderInPhi< T >::PeriodicBinFinderInPhi ( T  firstPhi,
int  nbins 
) [inline]

Definition at line 18 of file PeriodicBinFinderInPhi.h.

                                                 :
    theNbins( nbins), thePhiStep( twoPi() / nbins),
    thePhiOffset( firstPhi - thePhiStep/2.) {}

Member Function Documentation

template<class T>
virtual int PeriodicBinFinderInPhi< T >::binIndex ( T  phi) const [inline, virtual]

returns an index in the valid range for the bin that contains phi

Implements BaseBinFinder< T >.

Definition at line 23 of file PeriodicBinFinderInPhi.h.

Referenced by MuDetRing::compatibleDets(), TECLayer::computeCrossings(), MagGeometry::findVolume(), and MagBLayer::findVolume().

                                      {
    T tmp = fmod((phi - thePhiOffset), twoPi()) / thePhiStep;
    if ( tmp < 0) tmp += theNbins;
    return std::min( int(tmp), theNbins-1);
  }
template<class T>
virtual int PeriodicBinFinderInPhi< T >::binIndex ( int  i) const [inline, virtual]

returns an index in the valid range, modulo Nbins

Implements BaseBinFinder< T >.

Definition at line 30 of file PeriodicBinFinderInPhi.h.

                                     {
    int ind = i % theNbins;
    return ind < 0 ? ind+theNbins : ind;
  }
template<class T>
virtual T PeriodicBinFinderInPhi< T >::binPosition ( int  ind) const [inline, virtual]

the middle of the bin in radians

Implements BaseBinFinder< T >.

Definition at line 36 of file PeriodicBinFinderInPhi.h.

                                        {
    return thePhiOffset + thePhiStep * ( ind + 0.5);
  }
template<class T>
static T PeriodicBinFinderInPhi< T >::pi ( ) [inline, static]

Definition at line 40 of file PeriodicBinFinderInPhi.h.

Referenced by PeriodicBinFinderInPhi< float >::twoPi().

{ return 3.141592653589793238;}
template<class T>
static T PeriodicBinFinderInPhi< T >::twoPi ( ) [inline, static]

Definition at line 41 of file PeriodicBinFinderInPhi.h.

Referenced by PeriodicBinFinderInPhi< float >::binIndex().

{ return 2.*pi();}

Member Data Documentation

template<class T>
int PeriodicBinFinderInPhi< T >::theNbins [private]

Definition at line 45 of file PeriodicBinFinderInPhi.h.

Referenced by PeriodicBinFinderInPhi< float >::binIndex().

template<class T>
T PeriodicBinFinderInPhi< T >::thePhiOffset [private]
template<class T>
T PeriodicBinFinderInPhi< T >::thePhiStep [private]