CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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 >

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. More...
 
virtual T binPosition (int ind) const
 the middle of the bin in radians More...
 
 GeneralBinFinderInPhi ()
 
 GeneralBinFinderInPhi (const PhiBorderFinder &bf)
 Construct from an already initialized PhiBorderFinder. More...
 
 GeneralBinFinderInPhi (std::vector< Det * >::const_iterator first, std::vector< Det * >::const_iterator last)
 Construct from the list of Det*. More...
 
virtual ~GeneralBinFinderInPhi ()
 
- Public Member Functions inherited from BaseBinFinder< T >
 BaseBinFinder ()
 
virtual ~BaseBinFinder ()
 

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 23 of file GeneralBinFinderInPhi.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file GeneralBinFinderInPhi.h.

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

Construct from an already initialized PhiBorderFinder.

Definition at line 28 of file GeneralBinFinderInPhi.h.

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

28  {
30  theBins=bf.phiBins();
31  theNbins=theBins.size();
32  }
const std::vector< double > & phiBorders() const
const std::vector< double > & phiBins() const
The centers of the Dets.
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 35 of file GeneralBinFinderInPhi.h.

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

37  : theNbins( last-first)
38  {
39  std::vector<Det*> dets(first,last);
40  PhiBorderFinder bf(dets);
41  theBorders=bf.phiBorders();
42  theBins=bf.phiBins();
43  theNbins=theBins.size();
44  }
bool first
Definition: L1TdeRCT.cc:94
template<class T >
virtual GeneralBinFinderInPhi< T >::~GeneralBinFinderInPhi ( )
inlinevirtual

Definition at line 46 of file GeneralBinFinderInPhi.h.

46 {};

Member Function Documentation

template<class T >
virtual int GeneralBinFinderInPhi< T >::binIndex ( T  phi) const
inlinevirtual

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

Implements BaseBinFinder< T >.

Definition at line 50 of file GeneralBinFinderInPhi.h.

References epsilon, edm::hlt::Exception, i, LogTrace, metname, GetRecoTauVFromDQM_MC_cff::next, phi, GeneralBinFinderInPhi< T >::positiveRange(), GeneralBinFinderInPhi< T >::theBorders, and GeneralBinFinderInPhi< T >::theNbins.

Referenced by GeneralBinFinderInPhi< T >::binPosition().

50  {
51 
52  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|GeneralBinFinderInPhi";
53 
55  // Assume -pi, pi range in pi (which is the case for Geom::Phi
56 
57  LogTrace(metname) << "GeneralBinFinderInPhi::binIndex,"
58  << " Nbins: "<< theNbins;
59 
60  for (int i = 0; i< theNbins; i++) {
61 
62  T cur = theBorders[i];
63  T next = theBorders[binIndex(i+1)];
64  T phi_ = phi;
65 
66  LogTrace(metname) << "bin: " << i
67  << " border min " << cur << " border max: " << next << " phi: "<< phi_;
68 
69  if ( cur > next ) // we are crossing the pi edge: so move the edge to 0!
70  {
71  cur = positiveRange(cur);
72  next = positiveRange(next);
73  phi_ = positiveRange(phi_);
74  }
75  if (phi_ > cur-epsilon && phi_ < next) return i;
76  }
77  throw cms::Exception("UnexpectedState") << "GeneralBinFinderInPhi::binIndex( T phi) bin not found!";
78  }
int i
Definition: DBlmapReader.cc:9
virtual int binIndex(T phi) const
const std::string metname
#define LogTrace(id)
const double epsilon
long double T
Definition: DDAxes.h:10
template<class T >
virtual int GeneralBinFinderInPhi< T >::binIndex ( int  i) const
inlinevirtual

Returns an index in the valid range, modulo Nbins.

Implements BaseBinFinder< T >.

Definition at line 81 of file GeneralBinFinderInPhi.h.

References GeneralBinFinderInPhi< T >::theNbins.

81  {
82  int ind = i % (int)theNbins;
83  return (ind < 0) ? ind+theNbins : ind;
84  }
int i
Definition: DBlmapReader.cc:9
template<class T >
virtual T GeneralBinFinderInPhi< T >::binPosition ( int  ind) const
inlinevirtual

the middle of the bin in radians

Implements BaseBinFinder< T >.

Definition at line 87 of file GeneralBinFinderInPhi.h.

References GeneralBinFinderInPhi< T >::binIndex(), and GeneralBinFinderInPhi< T >::theBins.

87  {
88  return theBins[binIndex(ind)];
89  }
virtual int binIndex(T phi) const
template<class T >
T GeneralBinFinderInPhi< T >::positiveRange ( T  phi) const
inlineprivate

Definition at line 98 of file GeneralBinFinderInPhi.h.

References Geom::twoPi().

Referenced by GeneralBinFinderInPhi< T >::binIndex().

99  {
100  return (phi > 0) ? phi : phi + Geom::twoPi();
101  }
double twoPi()
Definition: Pi.h:32
Definition: DDAxes.h:10

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