CMS 3D CMS Logo

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