CMS 3D CMS Logo

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.

Author
N. Amapane - INFN Torino

Definition at line 18 of file GeneralBinFinderInPhi.h.

Member Typedef Documentation

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

Definition at line 21 of file GeneralBinFinderInPhi.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file GeneralBinFinderInPhi.h.

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

Construct from an already initialized PhiBorderFinder.

Definition at line 26 of file GeneralBinFinderInPhi.h.

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

26  {
28  theBins=bf.phiBins();
29  theNbins=theBins.size();
30  }
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 33 of file GeneralBinFinderInPhi.h.

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

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

Definition at line 44 of file GeneralBinFinderInPhi.h.

44 {};

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

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

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

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

References createfilelist::int, and GeneralBinFinderInPhi< T >::theNbins.

79  {
80  int ind = i % (int)theNbins;
81  return (ind < 0) ? ind+theNbins : ind;
82  }
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 85 of file GeneralBinFinderInPhi.h.

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

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

Definition at line 96 of file GeneralBinFinderInPhi.h.

References Geom::twoPi().

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

97  {
98  return (phi > 0) ? phi : phi + Geom::twoPi();
99  }
constexpr double twoPi()
Definition: Pi.h:32

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