CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

RBorderFinder Class Reference

#include <RBorderFinder.h>

List of all members.

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.
bool isRPeriodic () const
 Returns true if the Dets are periodic in R.
std::vector< double > RBins () const
 The centers of the Dets.
 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 beamvalidation::br, alignBH_cfg::disks, Exception, first, i, isROverlapping_, isRPeriodic_, precomputed_value_sort(), plotscripts::rms(), edm::second(), stat_RMS(), launcher::step, theNbins, theRBins, and theRBorders.

    : theNbins(theDets.size()), isRPeriodic_(false), isROverlapping_(false)
  {
    precomputed_value_sort(theDets.begin(), theDets.end(), DetR());

    std::vector<ConstReferenceCountingPointer<BoundDisk> > disks(theNbins);
    for ( int i = 0; i < theNbins; i++ ) {
      disks[i] = 
        dynamic_cast<const BoundDisk*> (&(theDets[i]->surface()));
      if (disks[i]==0) {
        throw cms::Exception("UnexpectedState") << "RBorderFinder: implemented for BoundDisks only";
      }
    }


    if (theNbins==1) { // Trivial case
      isRPeriodic_ = true; // meaningless in this case
      theRBorders.push_back(disks.front()->innerRadius());
      theRBins.push_back((disks.front()->outerRadius()+disks.front()->innerRadius()));
//       std::cout << "RBorderFinder:  theNbins " << theNbins << std::endl
//              << " C: " << theRBins[0]
//              << " Border: " << theRBorders[0] << std::endl;
    } else { // More than 1 bin
      double step = (disks.back()->innerRadius() -
                     disks.front()->innerRadius())/(theNbins-1);
      std::vector<double> spread;
      std::vector<std::pair<double,double> > REdge;
      REdge.reserve(theNbins);
      theRBorders.reserve(theNbins);
      theRBins.reserve(theNbins);
      spread.reserve(theNbins);
    
      for ( int i = 0; i < theNbins; i++ ) {
        theRBins.push_back((disks[i]->outerRadius()+disks[i]->innerRadius())/2.);
        spread.push_back(theRBins.back() - (theRBins[0] + i*step));
        REdge.push_back(std::pair<double,double>(disks[i]->innerRadius(),
                                                 disks[i]->outerRadius()));
      }
      
      theRBorders.push_back(REdge[0].first);
      for (int i = 1; i < theNbins; i++) {
        // Average borders of previous and next bins
        double br = (REdge[(i-1)].second + REdge[i].first)/2.;
        theRBorders.push_back(br);
      }
      
      for (int i = 1; i < theNbins; i++) {
        if (REdge[i].first - REdge[i-1].second < 0) {
          isROverlapping_ = true;
          break;
        }
      }
    
      double rms = stat_RMS(spread); 
      if ( rms < 0.01*step) { 
        isRPeriodic_ = true;
      }
    
//       std::cout << "RBorderFinder:  theNbins " << theNbins
//              << " step: " << step << " RMS " << rms << std::endl;
//       for (int idbg = 0; idbg < theNbins; idbg++) {
//      std::cout << "L: " << REdge[idbg].first
//                << " C: " << theRBins[idbg]
//                << " R: " << REdge[idbg].second
//                << " Border: " << theRBorders[idbg]
//                << " SP: " << spread[idbg] << std::endl;
//       }
    }

    //Check that everything is proper
    if ((int)theRBorders.size() != theNbins || (int)theRBins.size() != theNbins) 
      throw cms::Exception("UnexpectedState") << "RBorderFinder consistency error";
}
virtual RBorderFinder::~RBorderFinder ( ) [inline, virtual]

Definition at line 157 of file RBorderFinder.h.

{};

Member Function Documentation

int RBorderFinder::binIndex ( int  i) const [inline, private]

Definition at line 183 of file RBorderFinder.h.

References max(), min, and theNbins.

                                    {
    return std::min( std::max( i, 0), theNbins-1);
  }
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().

{ 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().

{ 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().

{ return 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().

{ return theRBorders; }

Member Data Documentation

Definition at line 179 of file RBorderFinder.h.

Referenced by isROverlapping(), and RBorderFinder().

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().