CMS 3D CMS Logo

Public Member Functions | Private Attributes

MagBinFinders::GeneralBinFinderInR< T > Class Template Reference

#include <MagBinFinders.h>

Inheritance diagram for MagBinFinders::GeneralBinFinderInR< T >:
BaseBinFinder< T >

List of all members.

Public Member Functions

virtual int binIndex (T R) const
virtual int binIndex (int i) const
 Returns an index in the valid range.
virtual T binPosition (int ind) const
 The middle of the bin.
 GeneralBinFinderInR ()
 GeneralBinFinderInR (std::vector< T > &borders)

Private Attributes

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

Detailed Description

template<class T>
class MagBinFinders::GeneralBinFinderInR< T >

A R binfinder for a non-periodic group of detectors.

Date:
2008/11/14 10:57:30
Revision:
1.5
Author:
N. Amapane - INFN Torino

Definition at line 29 of file MagBinFinders.h.


Constructor & Destructor Documentation

template<class T>
MagBinFinders::GeneralBinFinderInR< T >::GeneralBinFinderInR ( ) [inline]

Definition at line 32 of file MagBinFinders.h.

: theNbins(0) {}
template<class T>
MagBinFinders::GeneralBinFinderInR< T >::GeneralBinFinderInR ( std::vector< T > &  borders) [inline]

Definition at line 34 of file MagBinFinders.h.

                                             :
    theNbins(borders.size()), 
    theBorders(borders) {
    // FIXME: compute bin positions.
//     for (vector<T>::const_iterator i=theBorders.begin();
//       i<theBorders.end(); ++i) {
//      theBorders.push_back(((*i) + (*(i+1))) / 2.);

//     cout << "GeneralBinFinderInR_ " << theNbins << " " << theBorders.size() << " " << (int) this << endl;
}

Member Function Documentation

template<class T>
virtual int MagBinFinders::GeneralBinFinderInR< T >::binIndex ( T  R) const [inline, virtual]

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

Implements BaseBinFinder< T >.

Definition at line 68 of file MagBinFinders.h.

Referenced by MagBinFinders::GeneralBinFinderInR< double >::binIndex(), MagBinFinders::GeneralBinFinderInR< double >::binPosition(), and MagGeometry::findVolume().

                                   {
    int i;
    for (i = 0; i<theNbins; ++i) {
      if (R < theBorders[i]){ // FIXME: one can be skipped?
         break;
      }
    }
    return binIndex(i-1);
  }
template<class T>
virtual int MagBinFinders::GeneralBinFinderInR< T >::binIndex ( int  i) const [inline, virtual]

Returns an index in the valid range.

Implements BaseBinFinder< T >.

Definition at line 79 of file MagBinFinders.h.

                                     {
    return std::min( std::max( i, 0), theNbins-1);
  }
template<class T>
virtual T MagBinFinders::GeneralBinFinderInR< T >::binPosition ( int  ind) const [inline, virtual]

The middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 84 of file MagBinFinders.h.

                                        {
    return theBins[binIndex(ind)];
  }

Member Data Documentation

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