CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
PhiBorderFinder Class Reference

#include <PhiBorderFinder.h>

Public Types

typedef DetRod Det
 
typedef geomsort::ExtractPhi< Det, float > DetPhi
 

Public Member Functions

bool isPhiOverlapping () const
 Returns true if any 2 of the Det overlap in phi. More...
 
bool isPhiPeriodic () const
 Returns true if the Dets are periodic in phi. More...
 
unsigned int nBins ()
 
const std::vector< double > & phiBins () const
 The centers of the Dets. More...
 
 PhiBorderFinder (const std::vector< const Det * > &utheDets)
 
const std::vector< double > & phiBorders () const
 
virtual ~PhiBorderFinder ()
 

Private Member Functions

int binIndex (int i) const
 
double positiveRange (double phi) const
 

Private Attributes

bool isPhiOverlapping_
 
bool isPhiPeriodic_
 
unsigned int theNbins
 
std::vector< double > thePhiBins
 
std::vector< double > thePhiBorders
 

Detailed Description

Find the phi binning of a list of detector according to several definitions.

Author
N. Amapane - INFN Torino

Definition at line 27 of file PhiBorderFinder.h.

Member Typedef Documentation

◆ Det

Definition at line 29 of file PhiBorderFinder.h.

◆ DetPhi

Definition at line 30 of file PhiBorderFinder.h.

Constructor & Destructor Documentation

◆ PhiBorderFinder()

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

Definition at line 3 of file PhiBorderFinder.cc.

4  : theNbins(utheDets.size()), isPhiPeriodic_(false), isPhiOverlapping_(false) {
5  std::vector<const Det*> theDets = utheDets;
6  precomputed_value_sort(theDets.begin(), theDets.end(), DetPhi());
7 
8  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|PhiBorderFinder";
9 
10  double step = 2. * Geom::pi() / theNbins;
11 
12  LogTrace(metname) << "RecoMuonDetLayers::PhiBorderFinder "
13  << "step w: " << step << " # of bins: " << theNbins;
14 
15  std::vector<double> spread(theNbins);
16  std::vector<std::pair<double, double> > phiEdge;
17  phiEdge.reserve(theNbins);
18  thePhiBorders.reserve(theNbins);
19  thePhiBins.reserve(theNbins);
20  for (unsigned int i = 0; i < theNbins; i++) {
21  thePhiBins.push_back(theDets[i]->position().phi());
22  spread.push_back(theDets[i]->position().phi() - (theDets[0]->position().phi() + i * step));
23 
24  LogTrace(metname) << "bin: " << i << " phi bin: " << thePhiBins[i] << " spread: " << spread[i];
25 
26  ConstReferenceCountingPointer<BoundPlane> plane = dynamic_cast<const BoundPlane*>(&theDets[i]->surface());
27  if (plane == nullptr) {
28  //FIXME
29  throw cms::Exception("UnexpectedState") << ("PhiBorderFinder: det surface is not a BoundPlane");
30  }
31 
32  std::vector<GlobalPoint> dc = BoundingBox().corners(*plane);
33 
34  float phimin(999.), phimax(-999.);
35  for (std::vector<GlobalPoint>::const_iterator pt = dc.begin(); pt != dc.end(); pt++) {
36  float phi = (*pt).phi();
37  // float z = pt->z();
38  if (phi < phimin)
39  phimin = phi;
40  if (phi > phimax)
41  phimax = phi;
42  }
43  if (phimin * phimax < 0. && //Handle pi border:
44  phimax - phimin > Geom::pi()) { //Assume that the Det is on
45  //the shortest side
47  }
48  phiEdge.push_back(std::pair<double, double>(phimin, phimax));
49  }
50 
51  for (unsigned int i = 0; i < theNbins; i++) {
52  // Put the two phi values in the [0,2pi] range
53  double firstPhi = positiveRange(phiEdge[i].first);
54  double secondPhi = positiveRange(phiEdge[binIndex(i - 1)].second);
55 
56  // Reformat them in the [-pi,pi] range
57  Geom::Phi<double> firstEdge(firstPhi);
58  Geom::Phi<double> secondEdge(secondPhi);
59 
60  // Calculate the mean and format the result in the [-pi,pi] range
61  // Get their value in order to perform the mean in the correct way
62  Geom::Phi<double> mean((firstEdge.value() + secondEdge.value()) / 2.);
63 
64  // Special case: at +-pi there is a discontinuity
65  if (phiEdge[i].first * phiEdge[binIndex(i - 1)].second < 0 && fabs(firstPhi - secondPhi) < Geom::pi())
66  mean = Geom::pi() - mean;
67 
68  thePhiBorders.push_back(mean);
69  }
70 
71  for (unsigned int i = 0; i < theNbins; i++) {
72  if (Geom::Phi<double>(phiEdge[i].first) - Geom::Phi<double>(phiEdge[binIndex(i - 1)].second) < 0) {
73  isPhiOverlapping_ = true;
74  break;
75  }
76  }
77 
78  double rms = stat_RMS(spread);
79  if (rms < 0.01 * step) {
80  isPhiPeriodic_ = true;
81  }
82 
83  //Check that everything is proper
84  if (thePhiBorders.size() != theNbins || thePhiBins.size() != theNbins)
85  //FIXME
86  throw cms::Exception("UnexpectedState") << "PhiBorderFinder: consistency error";
87 }

References binIndex(), BoundingBox::corners(), Exception, dqmdumpme::first, mps_fire::i, isPhiOverlapping_, isPhiPeriodic_, LogTrace, SiStripPI::mean, metname, phi, phimax, phimin, Geom::pi(), position, positiveRange(), precomputed_value_sort(), DiDispStaMuonMonitor_cfi::pt, SiStripPI::rms, edm::second(), stat_RMS(), AlCaHLTBitMon_QueryRunRegistry::string, std::swap(), theNbins, thePhiBins, thePhiBorders, and Geom::Phi< T1, Range >::value().

◆ ~PhiBorderFinder()

virtual PhiBorderFinder::~PhiBorderFinder ( )
inlinevirtual

Definition at line 34 of file PhiBorderFinder.h.

34 {};

Member Function Documentation

◆ binIndex()

int PhiBorderFinder::binIndex ( int  i) const
inlineprivate

Definition at line 63 of file PhiBorderFinder.h.

63  {
64  int ind = i % (int)theNbins;
65  return (ind < 0) ? ind + theNbins : ind;
66  }

References mps_fire::i, createfilelist::int, and theNbins.

Referenced by PhiBorderFinder().

◆ isPhiOverlapping()

bool PhiBorderFinder::isPhiOverlapping ( ) const
inline

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

Definition at line 42 of file PhiBorderFinder.h.

42 { return isPhiOverlapping_; }

References isPhiOverlapping_.

Referenced by MTDTrayBarrelLayer::MTDTrayBarrelLayer(), and MuRodBarrelLayer::MuRodBarrelLayer().

◆ isPhiPeriodic()

bool PhiBorderFinder::isPhiPeriodic ( ) const
inline

Returns true if the Dets are periodic in phi.

Definition at line 39 of file PhiBorderFinder.h.

39 { return isPhiPeriodic_; }

References isPhiPeriodic_.

Referenced by MTDTrayBarrelLayer::MTDTrayBarrelLayer(), and MuRodBarrelLayer::MuRodBarrelLayer().

◆ nBins()

unsigned int PhiBorderFinder::nBins ( )
inline

Definition at line 36 of file PhiBorderFinder.h.

36 { return theNbins; }

References theNbins.

◆ phiBins()

const std::vector<double>& PhiBorderFinder::phiBins ( ) const
inline

The centers of the Dets.

Definition at line 49 of file PhiBorderFinder.h.

49 { return thePhiBins; }

References thePhiBins.

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

◆ phiBorders()

const std::vector<double>& PhiBorderFinder::phiBorders ( ) 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 46 of file PhiBorderFinder.h.

46 { return thePhiBorders; }

References thePhiBorders.

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

◆ positiveRange()

double PhiBorderFinder::positiveRange ( double  phi) const
inlineprivate

Definition at line 61 of file PhiBorderFinder.h.

61 { return (phi > 0) ? phi : phi + Geom::twoPi(); }

References phi, and Geom::twoPi().

Referenced by PhiBorderFinder().

Member Data Documentation

◆ isPhiOverlapping_

bool PhiBorderFinder::isPhiOverlapping_
private

Definition at line 57 of file PhiBorderFinder.h.

Referenced by isPhiOverlapping(), and PhiBorderFinder().

◆ isPhiPeriodic_

bool PhiBorderFinder::isPhiPeriodic_
private

Definition at line 56 of file PhiBorderFinder.h.

Referenced by isPhiPeriodic(), and PhiBorderFinder().

◆ theNbins

unsigned int PhiBorderFinder::theNbins
private

Definition at line 55 of file PhiBorderFinder.h.

Referenced by binIndex(), nBins(), and PhiBorderFinder().

◆ thePhiBins

std::vector<double> PhiBorderFinder::thePhiBins
private

Definition at line 59 of file PhiBorderFinder.h.

Referenced by phiBins(), and PhiBorderFinder().

◆ thePhiBorders

std::vector<double> PhiBorderFinder::thePhiBorders
private

Definition at line 58 of file PhiBorderFinder.h.

Referenced by PhiBorderFinder(), and phiBorders().

PhiBorderFinder::isPhiPeriodic_
bool isPhiPeriodic_
Definition: PhiBorderFinder.h:56
PhiBorderFinder::thePhiBorders
std::vector< double > thePhiBorders
Definition: PhiBorderFinder.h:58
mps_fire.i
i
Definition: mps_fire.py:355
PhiBorderFinder::DetPhi
geomsort::ExtractPhi< Det, float > DetPhi
Definition: PhiBorderFinder.h:30
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
step
step
Definition: StallMonitor.cc:94
stat_RMS
double stat_RMS(const CONT &cont)
Definition: simple_stat.h:23
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
PhiBorderFinder::isPhiOverlapping_
bool isPhiOverlapping_
Definition: PhiBorderFinder.h:57
ConstReferenceCountingPointer
Definition: ReferenceCounted.h:67
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
PhiBorderFinder::positiveRange
double positiveRange(double phi) const
Definition: PhiBorderFinder.h:61
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
dqmdumpme.first
first
Definition: dqmdumpme.py:55
BoundingBox
Definition: BoundingBox.h:12
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
Geom::pi
constexpr double pi()
Definition: Pi.h:31
PhiBorderFinder::thePhiBins
std::vector< double > thePhiBins
Definition: PhiBorderFinder.h:59
Geom::twoPi
constexpr double twoPi()
Definition: Pi.h:32
PhiBorderFinder::theNbins
unsigned int theNbins
Definition: PhiBorderFinder.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
createfilelist.int
int
Definition: createfilelist.py:10
Geom::Phi
Definition: Phi.h:52
PhiBorderFinder::binIndex
int binIndex(int i) const
Definition: PhiBorderFinder.h:63
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
DDAxes::phi
Exception
Definition: hltDiff.cc:246
BoundingBox::corners
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:20
cms::Exception
Definition: Exception.h:70
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43