CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RBorderFinder.cc
Go to the documentation of this file.
2 
3 RBorderFinder::RBorderFinder(const std::vector<const Det*>& utheDets)
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 }
RBorderFinder(const std::vector< const Det * > &utheDets)
Definition: RBorderFinder.cc:3
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
tuple size
Write out results.
std::vector< double > theRBins
Definition: RBorderFinder.h:52