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 (std::vector< const Det * > theDets)
 
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.

Date:
2007/03/07 13:20:54
Revision:
1.5
Author
N. Amapane - INFN Torino

Definition at line 24 of file RBorderFinder.h.

Member Typedef Documentation

Definition at line 27 of file RBorderFinder.h.

Definition at line 28 of file RBorderFinder.h.

Constructor & Destructor Documentation

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

Definition at line 30 of file RBorderFinder.h.

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

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

157 {};

Member Function Documentation

int RBorderFinder::binIndex ( int  i) const
inlineprivate

Definition at line 183 of file RBorderFinder.h.

References max(), min, and theNbins.

183  {
184  return std::min( std::max( i, 0), theNbins-1);
185  }
int i
Definition: DBlmapReader.cc:9
#define min(a, b)
Definition: mlp_lapack.h:161
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 163 of file RBorderFinder.h.

References isROverlapping_.

Referenced by MuRingForwardLayer::MuRingForwardLayer().

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

Returns true if the Dets are periodic in R.

Definition at line 160 of file RBorderFinder.h.

References isRPeriodic_.

Referenced by MuRingForwardLayer::MuRingForwardLayer().

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

The centers of the Dets.

Definition at line 170 of file RBorderFinder.h.

References theRBins.

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

170 { 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 167 of file RBorderFinder.h.

References theRBorders.

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

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

Member Data Documentation

bool RBorderFinder::isROverlapping_
private

Definition at line 179 of file RBorderFinder.h.

Referenced by isROverlapping(), and RBorderFinder().

bool RBorderFinder::isRPeriodic_
private

Definition at line 178 of file RBorderFinder.h.

Referenced by isRPeriodic(), and RBorderFinder().

int RBorderFinder::theNbins
private

Definition at line 177 of file RBorderFinder.h.

Referenced by binIndex(), and RBorderFinder().

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

Definition at line 181 of file RBorderFinder.h.

Referenced by RBins(), and RBorderFinder().

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

Definition at line 180 of file RBorderFinder.h.

Referenced by RBorderFinder(), and RBorders().