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
RBorderFinder Class Reference

#include <RBorderFinder.h>

Public Types

typedef ForwardDetRing Det
 
typedef geomsort::ExtractR
< Det, float > 
DetR
 

Public Member Functions

bool isROverlapping () const
 Returns true if any 2 of the Det overlap in R. More...
 
bool isRPeriodic () const
 Returns true if the Dets are periodic in R. More...
 
std::vector< double > RBins () const
 The centers of the Dets. More...
 
 RBorderFinder (const std::vector< const Det * > &utheDets)
 
std::vector< double > RBorders () const
 
virtual ~RBorderFinder ()
 

Private Member Functions

int binIndex (int i) const
 

Private Attributes

bool isROverlapping_
 
bool isRPeriodic_
 
int theNbins
 
std::vector< double > theRBins
 
std::vector< double > theRBorders
 

Detailed Description

Find the R binning of a list of detector according to several definitions.

Author
N. Amapane - INFN Torino

Definition at line 22 of file RBorderFinder.h.

Member Typedef Documentation

Definition at line 25 of file RBorderFinder.h.

Definition at line 26 of file RBorderFinder.h.

Constructor & Destructor Documentation

RBorderFinder::RBorderFinder ( const std::vector< const Det * > &  utheDets)
inline

Definition at line 28 of file RBorderFinder.h.

References beamvalidation::br, alignBH_cfg::disks, edm::hlt::Exception, first, i, isROverlapping_, isRPeriodic_, precomputed_value_sort(), plotscripts::rms(), edm::second(), stat_RMS(), relval_parameters_module::step, theNbins, theRBins, and theRBorders.

29  : theNbins(utheDets.size()), isRPeriodic_(false), isROverlapping_(false)
30  {
31  std::vector<const Det*> theDets = utheDets;
32  precomputed_value_sort(theDets.begin(), theDets.end(), DetR());
33 
34  std::vector<ConstReferenceCountingPointer<BoundDisk> > disks(theNbins);
35  for ( int i = 0; i < theNbins; i++ ) {
36  disks[i] =
37  dynamic_cast<const BoundDisk*> (&(theDets[i]->surface()));
38  if (disks[i]==0) {
39  throw cms::Exception("UnexpectedState") << "RBorderFinder: implemented for BoundDisks only";
40  }
41  }
42 
43 
44  if (theNbins==1) { // Trivial case
45  isRPeriodic_ = true; // meaningless in this case
46  theRBorders.push_back(disks.front()->innerRadius());
47  theRBins.push_back((disks.front()->outerRadius()+disks.front()->innerRadius()));
48 // std::cout << "RBorderFinder: theNbins " << theNbins << std::endl
49 // << " C: " << theRBins[0]
50 // << " Border: " << theRBorders[0] << std::endl;
51  } else { // More than 1 bin
52  double step = (disks.back()->innerRadius() -
53  disks.front()->innerRadius())/(theNbins-1);
54  std::vector<double> spread;
55  std::vector<std::pair<double,double> > REdge;
56  REdge.reserve(theNbins);
57  theRBorders.reserve(theNbins);
58  theRBins.reserve(theNbins);
59  spread.reserve(theNbins);
60 
61  for ( int i = 0; i < theNbins; i++ ) {
62  theRBins.push_back((disks[i]->outerRadius()+disks[i]->innerRadius())/2.);
63  spread.push_back(theRBins.back() - (theRBins[0] + i*step));
64  REdge.push_back(std::pair<double,double>(disks[i]->innerRadius(),
65  disks[i]->outerRadius()));
66  }
67 
68  theRBorders.push_back(REdge[0].first);
69  for (int i = 1; i < theNbins; i++) {
70  // Average borders of previous and next bins
71  double br = (REdge[(i-1)].second + REdge[i].first)/2.;
72  theRBorders.push_back(br);
73  }
74 
75  for (int i = 1; i < theNbins; i++) {
76  if (REdge[i].first - REdge[i-1].second < 0) {
77  isROverlapping_ = true;
78  break;
79  }
80  }
81 
82  double rms = stat_RMS(spread);
83  if ( rms < 0.01*step) {
84  isRPeriodic_ = true;
85  }
86 
87 // std::cout << "RBorderFinder: theNbins " << theNbins
88 // << " step: " << step << " RMS " << rms << std::endl;
89 // for (int idbg = 0; idbg < theNbins; idbg++) {
90 // std::cout << "L: " << REdge[idbg].first
91 // << " C: " << theRBins[idbg]
92 // << " R: " << REdge[idbg].second
93 // << " Border: " << theRBorders[idbg]
94 // << " SP: " << spread[idbg] << std::endl;
95 // }
96  }
97 
98  //Check that everything is proper
99  if ((int)theRBorders.size() != theNbins || (int)theRBins.size() != theNbins)
100  throw cms::Exception("UnexpectedState") << "RBorderFinder consistency error";
101 }
int i
Definition: DBlmapReader.cc:9
tuple disks
Definition: alignBH_cfg.py:13
geomsort::ExtractR< Det, float > DetR
Definition: RBorderFinder.h:26
U second(std::pair< T, U > const &p)
double stat_RMS(const CONT &cont)
Definition: simple_stat.h:20
bool first
Definition: L1TdeRCT.cc:79
std::vector< double > theRBorders
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
std::vector< double > theRBins
virtual RBorderFinder::~RBorderFinder ( )
inlinevirtual

Definition at line 156 of file RBorderFinder.h.

156 {};

Member Function Documentation

int RBorderFinder::binIndex ( int  i) const
inlineprivate

Definition at line 182 of file RBorderFinder.h.

References max(), bookConverter::min, and theNbins.

182  {
183  return std::min( std::max( i, 0), theNbins-1);
184  }
int i
Definition: DBlmapReader.cc:9
const T & max(const T &a, const T &b)
bool RBorderFinder::isROverlapping ( ) const
inline

Returns true if any 2 of the Det overlap in R.

Definition at line 162 of file RBorderFinder.h.

References isROverlapping_.

Referenced by MuRingForwardLayer::MuRingForwardLayer().

162 { return isROverlapping_; }
bool RBorderFinder::isRPeriodic ( ) const
inline

Returns true if the Dets are periodic in R.

Definition at line 159 of file RBorderFinder.h.

References isRPeriodic_.

Referenced by MuRingForwardLayer::MuRingForwardLayer().

159 { return isRPeriodic_; }
std::vector<double> RBorderFinder::RBins ( ) const
inline

The centers of the Dets.

Definition at line 169 of file RBorderFinder.h.

References theRBins.

Referenced by GeneralBinFinderInR< T >::GeneralBinFinderInR().

169 { return theRBins; }
std::vector< double > theRBins
std::vector<double> RBorderFinder::RBorders ( ) const
inline

The borders, defined for each det as the middle between its lower edge and the previous Det's upper edge.

Definition at line 166 of file RBorderFinder.h.

References theRBorders.

Referenced by GeneralBinFinderInR< T >::GeneralBinFinderInR().

166 { return theRBorders; }
std::vector< double > theRBorders

Member Data Documentation

bool RBorderFinder::isROverlapping_
private

Definition at line 178 of file RBorderFinder.h.

Referenced by isROverlapping(), and RBorderFinder().

bool RBorderFinder::isRPeriodic_
private

Definition at line 177 of file RBorderFinder.h.

Referenced by isRPeriodic(), and RBorderFinder().

int RBorderFinder::theNbins
private

Definition at line 176 of file RBorderFinder.h.

Referenced by binIndex(), and RBorderFinder().

std::vector<double> RBorderFinder::theRBins
private

Definition at line 180 of file RBorderFinder.h.

Referenced by RBins(), and RBorderFinder().

std::vector<double> RBorderFinder::theRBorders
private

Definition at line 179 of file RBorderFinder.h.

Referenced by RBorderFinder(), and RBorders().