CMS 3D CMS Logo

PhiBorderFinder.cc
Go to the documentation of this file.
2 
3 PhiBorderFinder::PhiBorderFinder(const std::vector<const Det*>& utheDets)
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 }
PhiBorderFinder::isPhiPeriodic_
bool isPhiPeriodic_
Definition: PhiBorderFinder.h:56
PhiBorderFinder::thePhiBorders
std::vector< double > thePhiBorders
Definition: PhiBorderFinder.h:58
Geom::Phi::value
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
mps_fire.i
i
Definition: mps_fire.py:428
PhiBorderFinder::DetPhi
geomsort::ExtractPhi< Det, float > DetPhi
Definition: PhiBorderFinder.h:30
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
funct::false
false
Definition: Factorize.h:29
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::PhiBorderFinder
PhiBorderFinder(const std::vector< const Det * > &utheDets)
Definition: PhiBorderFinder.cc:3
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:222
PhiBorderFinder.h
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
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
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:224
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40