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

int binIndex (T phi) const override
 
int binIndex (int i) const override
 Returns an index in the valid range, modulo Nbins. More...
 
T binPosition (int ind) const override
 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...
 
 ~GeneralBinFinderInPhi () override
 
- 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 20 of file GeneralBinFinderInPhi.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file GeneralBinFinderInPhi.h.

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

Construct from an already initialized PhiBorderFinder.

Definition at line 25 of file GeneralBinFinderInPhi.h.

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

25  {
26  theBorders = bf.phiBorders();
27  theBins = bf.phiBins();
28  theNbins = theBins.size();
29  }
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 32 of file GeneralBinFinderInPhi.h.

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

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

Definition at line 41 of file GeneralBinFinderInPhi.h.

41 {};

Member Function Documentation

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

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

Implements BaseBinFinder< T >.

Definition at line 45 of file GeneralBinFinderInPhi.h.

References geometryDiff::epsilon, Exception, mps_fire::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().

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

Returns an index in the valid range, modulo Nbins.

Implements BaseBinFinder< T >.

Definition at line 74 of file GeneralBinFinderInPhi.h.

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

74  {
75  int ind = i % (int)theNbins;
76  return (ind < 0) ? ind + theNbins : ind;
77  }
template<class T>
T GeneralBinFinderInPhi< T >::binPosition ( int  ind) const
inlineoverridevirtual

the middle of the bin in radians

Implements BaseBinFinder< T >.

Definition at line 80 of file GeneralBinFinderInPhi.h.

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

80 { return theBins[binIndex(ind)]; }
int binIndex(T phi) const override
template<class T>
T GeneralBinFinderInPhi< T >::positiveRange ( T  phi) const
inlineprivate

Definition at line 88 of file GeneralBinFinderInPhi.h.

References Geom::twoPi().

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

88 { return (phi > 0) ? phi : phi + Geom::twoPi(); }
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