CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

GeneralBinFinderInPhi< T > Class Template Reference

#include <GeneralBinFinderInPhi.h>

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

List of all members.

Public Types

typedef PhiBorderFinder::Det Det

Public Member Functions

virtual int binIndex (T phi) const
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
 GeneralBinFinderInPhi (const PhiBorderFinder &bf)
 Construct from an already initialized PhiBorderFinder.
 GeneralBinFinderInPhi ()
 GeneralBinFinderInPhi (std::vector< Det * >::const_iterator first, std::vector< Det * >::const_iterator last)
 Construct from the list of Det*.
virtual ~GeneralBinFinderInPhi ()

Private Member Functions

T positiveRange (T phi) const

Private Attributes

std::vector< TtheBins
std::vector< TtheBorders
int theNbins

Detailed Description

template<class T>
class GeneralBinFinderInPhi< T >

A phi bin finder for a non-periodic group of detectors.

Date:
2007/02/18 16:01:46
Revision:
1.5
Author:
N. Amapane - INFN Torino

Definition at line 20 of file GeneralBinFinderInPhi.h.


Member Typedef Documentation

template<class T >
typedef PhiBorderFinder::Det GeneralBinFinderInPhi< T >::Det

Definition at line 24 of file GeneralBinFinderInPhi.h.


Constructor & Destructor Documentation

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

Definition at line 26 of file GeneralBinFinderInPhi.h.

{
template<class T >
GeneralBinFinderInPhi< T >::GeneralBinFinderInPhi ( const PhiBorderFinder bf) [inline]

Construct from an already initialized PhiBorderFinder.

Definition at line 29 of file GeneralBinFinderInPhi.h.

template<class T >
GeneralBinFinderInPhi< T >::GeneralBinFinderInPhi ( std::vector< Det * >::const_iterator  first,
std::vector< Det * >::const_iterator  last 
) [inline]

Construct from the list of Det*.

Definition at line 36 of file GeneralBinFinderInPhi.h.

References PhiBorderFinder::phiBins(), PhiBorderFinder::phiBorders(), GeneralBinFinderInPhi< T >::theBins, GeneralBinFinderInPhi< T >::theBorders, and GeneralBinFinderInPhi< T >::theNbins.

    : theNbins( last-first)
  {
    std::vector<Det*> dets(first,last);
    PhiBorderFinder bf(dets);
    theBorders=bf.phiBorders();
    theBins=bf.phiBins();
    theNbins=theBins.size();
  }

template<class T >
virtual GeneralBinFinderInPhi< T >::~GeneralBinFinderInPhi ( ) [inline, virtual]

Definition at line 47 of file GeneralBinFinderInPhi.h.

{

Member Function Documentation

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

Returns an index in the valid range for the bin that contains AND is closest to phi

Implements BaseBinFinder< T >.

Definition at line 51 of file GeneralBinFinderInPhi.h.

                                : "<< theNbins;

    for (int i = 0; i< theNbins; i++) {

      T cur = theBorders[i];
      T next = theBorders[binIndex(i+1)];
      T phi_ = phi;

      LogTrace(metname) << "bin: " << i 
                        << " border min " << cur << " border max: " << next << " phi: "<< phi_;

      if ( cur > next ) // we are crossing the pi edge: so move the edge to 0!
        {
          cur = positiveRange(cur);
          next = positiveRange(next);
          phi_ = positiveRange(phi_); 
        }
      if (phi_ > cur-epsilon && phi_ < next) return i;
    }
    throw cms::Exception("UnexpectedState") << "GeneralBinFinderInPhi::binIndex( T phi) bin not found!";
  }
  
template<class T >
virtual int GeneralBinFinderInPhi< T >::binIndex ( int  i) const [inline, virtual]

Returns an index in the valid range, modulo Nbins.

Implements BaseBinFinder< T >.

Definition at line 82 of file GeneralBinFinderInPhi.h.

                                    : ind;
  }

template<class T >
virtual T GeneralBinFinderInPhi< T >::binPosition ( int  ind) const [inline, virtual]

the middle of the bin in radians

Implements BaseBinFinder< T >.

Definition at line 88 of file GeneralBinFinderInPhi.h.

       :
  int theNbins;
template<class T >
T GeneralBinFinderInPhi< T >::positiveRange ( T  phi) const [inline, private]

Definition at line 99 of file GeneralBinFinderInPhi.h.

References Geom::twoPi().

  {
    return (phi > 0) ? phi : phi + Geom::twoPi();
  }


Member Data Documentation

template<class T >
std::vector<T> GeneralBinFinderInPhi< T >::theBins [private]
template<class T >
std::vector<T> GeneralBinFinderInPhi< T >::theBorders [private]
template<class T >
int GeneralBinFinderInPhi< T >::theNbins [private]