CMS 3D CMS Logo

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)

Definition at line 3 of file RBorderFinder.cc.

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

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 }
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
virtual RBorderFinder::~RBorderFinder ( )
inlinevirtual

Definition at line 30 of file RBorderFinder.h.

30 {};

Member Function Documentation

int RBorderFinder::binIndex ( int  i) const
inlineprivate

Definition at line 56 of file RBorderFinder.h.

References SiStripPI::max, and min().

56  {
57  return std::min( std::max( i, 0), theNbins-1);
58  }
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 36 of file RBorderFinder.h.

References isROverlapping_.

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

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

Returns true if the Dets are periodic in R.

Definition at line 33 of file RBorderFinder.h.

References isRPeriodic_.

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

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

The centers of the Dets.

Definition at line 43 of file RBorderFinder.h.

References theRBins.

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

43 { return theRBins; }
std::vector< double > theRBins
Definition: RBorderFinder.h:54
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 40 of file RBorderFinder.h.

References theRBorders.

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

40 { return theRBorders; }
std::vector< double > theRBorders
Definition: RBorderFinder.h:53

Member Data Documentation

bool RBorderFinder::isROverlapping_
private

Definition at line 52 of file RBorderFinder.h.

Referenced by isROverlapping(), and RBorderFinder().

bool RBorderFinder::isRPeriodic_
private

Definition at line 51 of file RBorderFinder.h.

Referenced by isRPeriodic(), and RBorderFinder().

int RBorderFinder::theNbins
private

Definition at line 50 of file RBorderFinder.h.

Referenced by RBorderFinder().

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

Definition at line 54 of file RBorderFinder.h.

Referenced by RBins(), and RBorderFinder().

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

Definition at line 53 of file RBorderFinder.h.

Referenced by RBorderFinder(), and RBorders().