CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecHitsSortedInPhi.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 #include<cassert>
6 
7 
8 
9 RecHitsSortedInPhi::RecHitsSortedInPhi(const std::vector<Hit>& hits, GlobalPoint const & origin, DetLayer const * il) :
10  layer(il),
11  isBarrel(il->isBarrel()),
12  x(hits.size()),y(hits.size()),z(hits.size()),drphi(hits.size()),
13  u(hits.size()),v(hits.size()),du(hits.size()),dv(hits.size()),
14  lphi(hits.size())
15 {
16 
17  // standard region have origin as 0,0,z (not true!!!!0
18  // cosmic region never used here
19  // assert(origin.x()==0 && origin.y()==0);
20 
21  for (std::vector<Hit>::const_iterator i=hits.begin(); i!=hits.end(); i++) {
22  theHits.push_back(HitWithPhi(*i));
23  }
24  std::sort( theHits.begin(), theHits.end(), HitLessPhi());
25 
26  for (unsigned int i=0; i!=theHits.size(); ++i) {
27  auto const & h = *theHits[i].hit();
28  auto const & gs = static_cast<BaseTrackerRecHit const &>(h).globalState();
29  auto loc = gs.position-origin.basicVector();
30  float lr = loc.perp();
31  // float lr = gs.position.perp();
32  float lz = gs.position.z();
33  float dr = gs.errorR;
34  float dz = gs.errorZ;
35  // r[i] = gs.position.perp();
36  // phi[i] = gs.position.barePhi();
37  x[i] = gs.position.x();
38  y[i] = gs.position.y();
39  z[i] = lz;
40  drphi[i] = gs.errorRPhi;
41  u[i] = isBarrel ? lr : lz;
42  v[i] = isBarrel ? lz : lr;
43  du[i] = isBarrel ? dr : dz;
44  dv[i] = isBarrel ? dz : dr;
45  lphi[i] = loc.barePhi();
46  }
47 
48 }
49 
50 
52  Range r1,r2;
53  if ( phiMin < phiMax) {
54  if ( phiMin < -Geom::fpi()) {
55  r1 = unsafeRange( phiMin + Geom::ftwoPi(), Geom::fpi());
56  r2 = unsafeRange( -Geom::fpi(), phiMax);
57  }
58  else if (phiMax > Geom::pi()) {
59  r1 = unsafeRange( phiMin, Geom::fpi());
60  r2 = unsafeRange( -Geom::fpi(), phiMax-Geom::ftwoPi());
61  }
62  else {
63  r1 = unsafeRange( phiMin, phiMax);
64  r2 = Range(theHits.begin(),theHits.begin());
65  }
66  }
67  else {
68  r1 =unsafeRange( phiMin, Geom::fpi());
69  r2 =unsafeRange( -Geom::fpi(), phiMax);
70  }
71 
72  return (DoubleRange){{int(r1.first-theHits.begin()),int(r1.second-theHits.begin())
73  ,int(r2.first-theHits.begin()),int(r2.second-theHits.begin())}};
74 }
75 
76 
77 void RecHitsSortedInPhi::hits( float phiMin, float phiMax, std::vector<Hit>& result) const
78 {
79  if ( phiMin < phiMax) {
80  if ( phiMin < -Geom::fpi()) {
81  copyResult( unsafeRange( phiMin + Geom::ftwoPi(), Geom::fpi()), result);
82  copyResult( unsafeRange( -Geom::fpi(), phiMax), result);
83  }
84  else if (phiMax > Geom::pi()) {
85  copyResult( unsafeRange( phiMin, Geom::fpi()), result);
86  copyResult( unsafeRange( -Geom::fpi(), phiMax-Geom::ftwoPi()), result);
87  }
88  else {
89  copyResult( unsafeRange( phiMin, phiMax), result);
90  }
91  }
92  else {
93  copyResult( unsafeRange( phiMin, Geom::fpi()), result);
94  copyResult( unsafeRange( -Geom::fpi(), phiMax), result);
95  }
96 }
97 
98 std::vector<RecHitsSortedInPhi::Hit> RecHitsSortedInPhi::hits( float phiMin, float phiMax) const
99 {
100  std::vector<Hit> result;
101  hits( phiMin, phiMax, result);
102  return result;
103 }
104 
106 RecHitsSortedInPhi::unsafeRange( float phiMin, float phiMax) const
107 {
108  auto low = std::lower_bound( theHits.begin(), theHits.end(), HitWithPhi(phiMin), HitLessPhi());
109  return Range( low,
110  std::upper_bound(low, theHits.end(), HitWithPhi(phiMax), HitLessPhi()));
111 }
std::vector< HitWithPhi > theHits
int i
Definition: DBlmapReader.cc:9
std::vector< float > drphi
Range unsafeRange(float phiMin, float phiMax) const
std::vector< float > z
std::array< int, 4 > DoubleRange
bool isBarrel(GeomDetEnumerators::SubDetector m)
float fpi()
Definition: Pi.h:35
std::vector< Hit > hits() const
float float float z
std::vector< float > x
DoubleRange doubleRange(float phiMin, float phiMax) const
std::vector< float > lphi
T x() const
Cartesian x coordinate.
std::pair< HitIter, HitIter > Range
tuple result
Definition: query.py:137
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< float > y
std::vector< float > v
T perp() const
Magnitude of transverse component.
std::vector< float > dv
static void copyResult(const Range &range, std::vector< Hit > &result)
double pi()
Definition: Pi.h:31
RecHitsSortedInPhi(const std::vector< Hit > &hits, GlobalPoint const &origin, DetLayer const *il)
std::vector< float > u
std::vector< float > du
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
tuple size
Write out results.
float ftwoPi()
Definition: Pi.h:36