CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 24 of file RBorderFinder.h.

Definition at line 25 of file RBorderFinder.h.

Constructor & Destructor Documentation

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

Definition at line 3 of file RBorderFinder.cc.

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

4  : theNbins(utheDets.size()), isRPeriodic_(false), isROverlapping_(false) {
5  std::vector<const Det*> theDets = utheDets;
6  precomputed_value_sort(theDets.begin(), theDets.end(), DetR());
7 
8  std::vector<ConstReferenceCountingPointer<BoundDisk> > disks(theNbins);
9  for (int i = 0; i < theNbins; i++) {
10  disks[i] = dynamic_cast<const BoundDisk*>(&(theDets[i]->surface()));
11  if (disks[i] == nullptr) {
12  throw cms::Exception("UnexpectedState") << "RBorderFinder: implemented for BoundDisks only";
13  }
14  }
15 
16  if (theNbins == 1) { // Trivial case
17  isRPeriodic_ = true; // meaningless in this case
18  theRBorders.push_back(disks.front()->innerRadius());
19  theRBins.push_back((disks.front()->outerRadius() + disks.front()->innerRadius()));
20  // std::cout << "RBorderFinder: theNbins " << theNbins << std::endl
21  // << " C: " << theRBins[0]
22  // << " Border: " << theRBorders[0] << std::endl;
23  } else { // More than 1 bin
24  double step = (disks.back()->innerRadius() - disks.front()->innerRadius()) / (theNbins - 1);
25  std::vector<double> spread;
26  std::vector<std::pair<double, double> > REdge;
27  REdge.reserve(theNbins);
28  theRBorders.reserve(theNbins);
29  theRBins.reserve(theNbins);
30  spread.reserve(theNbins);
31 
32  for (int i = 0; i < theNbins; i++) {
33  theRBins.push_back((disks[i]->outerRadius() + disks[i]->innerRadius()) / 2.);
34  spread.push_back(theRBins.back() - (theRBins[0] + i * step));
35  REdge.push_back(std::pair<double, double>(disks[i]->innerRadius(), disks[i]->outerRadius()));
36  }
37 
38  theRBorders.push_back(REdge[0].first);
39  for (int i = 1; i < theNbins; i++) {
40  // Average borders of previous and next bins
41  double br = (REdge[(i - 1)].second + REdge[i].first) / 2.;
42  theRBorders.push_back(br);
43  }
44 
45  for (int i = 1; i < theNbins; i++) {
46  if (REdge[i].first - REdge[i - 1].second < 0) {
47  isROverlapping_ = true;
48  break;
49  }
50  }
51 
52  double rms = stat_RMS(spread);
53  if (rms < 0.01 * step) {
54  isRPeriodic_ = true;
55  }
56  }
57 
58  //Check that everything is proper
59  if ((int)theRBorders.size() != theNbins || (int)theRBins.size() != theNbins)
60  throw cms::Exception("UnexpectedState") << "RBorderFinder consistency error";
61 }
tuple disks
Definition: alignBH_cfg.py:13
U second(std::pair< T, U > const &p)
bool isROverlapping_
Definition: RBorderFinder.h:50
double stat_RMS(const CONT &cont)
Definition: simple_stat.h:23
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
std::vector< double > theRBorders
Definition: RBorderFinder.h:51
geomsort::ExtractR< Det, float > DetR
Definition: RBorderFinder.h:25
step
Definition: StallMonitor.cc:94
std::vector< double > theRBins
Definition: RBorderFinder.h:52
virtual RBorderFinder::~RBorderFinder ( )
inlinevirtual

Definition at line 29 of file RBorderFinder.h.

29 {};

Member Function Documentation

int RBorderFinder::binIndex ( int  i) const
inlineprivate

Definition at line 54 of file RBorderFinder.h.

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

54 { return std::min(std::max(i, 0), theNbins - 1); }
T min(T a, T b)
Definition: MathUtil.h:58
bool RBorderFinder::isROverlapping ( ) const
inline

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

Definition at line 35 of file RBorderFinder.h.

References isROverlapping_.

Referenced by MTDRingForwardLayer::MTDRingForwardLayer(), and MuRingForwardLayer::MuRingForwardLayer().

35 { return isROverlapping_; }
bool isROverlapping_
Definition: RBorderFinder.h:50
bool RBorderFinder::isRPeriodic ( ) const
inline

Returns true if the Dets are periodic in R.

Definition at line 32 of file RBorderFinder.h.

References isRPeriodic_.

Referenced by MTDRingForwardLayer::MTDRingForwardLayer(), and MuRingForwardLayer::MuRingForwardLayer().

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

The centers of the Dets.

Definition at line 42 of file RBorderFinder.h.

References theRBins.

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

42 { return theRBins; }
std::vector< double > theRBins
Definition: RBorderFinder.h:52
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 39 of file RBorderFinder.h.

References theRBorders.

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

39 { return theRBorders; }
std::vector< double > theRBorders
Definition: RBorderFinder.h:51

Member Data Documentation

bool RBorderFinder::isROverlapping_
private

Definition at line 50 of file RBorderFinder.h.

Referenced by isROverlapping(), and RBorderFinder().

bool RBorderFinder::isRPeriodic_
private

Definition at line 49 of file RBorderFinder.h.

Referenced by isRPeriodic(), and RBorderFinder().

int RBorderFinder::theNbins
private

Definition at line 48 of file RBorderFinder.h.

Referenced by binIndex(), and RBorderFinder().

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

Definition at line 52 of file RBorderFinder.h.

Referenced by RBins(), and RBorderFinder().

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

Definition at line 51 of file RBorderFinder.h.

Referenced by RBorderFinder(), and RBorders().