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 (int i) const override
 Returns an index in the valid range, modulo Nbins. More...
 
int binIndex (T phi) const override
 
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

◆ Det

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

Definition at line 20 of file GeneralBinFinderInPhi.h.

Constructor & Destructor Documentation

◆ GeneralBinFinderInPhi() [1/3]

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

Definition at line 22 of file GeneralBinFinderInPhi.h.

22 : theNbins(0) {}

◆ GeneralBinFinderInPhi() [2/3]

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

◆ GeneralBinFinderInPhi() [3/3]

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.

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  }

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

◆ ~GeneralBinFinderInPhi()

template<class T >
GeneralBinFinderInPhi< T >::~GeneralBinFinderInPhi ( )
inlineoverride

Definition at line 41 of file GeneralBinFinderInPhi.h.

41 {};

Member Function Documentation

◆ binIndex() [1/2]

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.

74  {
75  int ind = i % (int)theNbins;
76  return (ind < 0) ? ind + theNbins : ind;
77  }

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

◆ binIndex() [2/2]

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.

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);
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  }

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().

◆ binPosition()

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.

80 { return theBins[binIndex(ind)]; }

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

◆ positiveRange()

template<class T >
T GeneralBinFinderInPhi< T >::positiveRange ( T  phi) const
inlineprivate

Definition at line 88 of file GeneralBinFinderInPhi.h.

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

References phi, and Geom::twoPi().

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

Member Data Documentation

◆ theBins

template<class T >
std::vector<T> GeneralBinFinderInPhi< T >::theBins
private

◆ theBorders

template<class T >
std::vector<T> GeneralBinFinderInPhi< T >::theBorders
private

◆ theNbins

template<class T >
int GeneralBinFinderInPhi< T >::theNbins
private
mps_fire.i
i
Definition: mps_fire.py:428
PhiBorderFinder
Definition: PhiBorderFinder.h:27
PhiBorderFinder::phiBins
const std::vector< double > & phiBins() const
The centers of the Dets.
Definition: PhiBorderFinder.h:49
GeneralBinFinderInPhi::theBins
std::vector< T > theBins
Definition: GeneralBinFinderInPhi.h:85
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
dqmdumpme.last
last
Definition: dqmdumpme.py:56
PhiBorderFinder::phiBorders
const std::vector< double > & phiBorders() const
Definition: PhiBorderFinder.h:46
GeneralBinFinderInPhi::positiveRange
T positiveRange(T phi) const
Definition: GeneralBinFinderInPhi.h:88
Geom::twoPi
constexpr double twoPi()
Definition: Pi.h:32
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GeneralBinFinderInPhi::theBorders
std::vector< T > theBorders
Definition: GeneralBinFinderInPhi.h:84
createfilelist.int
int
Definition: createfilelist.py:10
DDAxes::phi
GeneralBinFinderInPhi::binIndex
int binIndex(T phi) const override
Definition: GeneralBinFinderInPhi.h:45
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:245
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
GeneralBinFinderInPhi::theNbins
int theNbins
Definition: GeneralBinFinderInPhi.h:83
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40