test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
RecHitsSortedInPhi Class Reference

#include <RecHitsSortedInPhi.h>

Classes

struct  HitLessPhi
 
class  HitWithPhi
 

Public Types

using DoubleRange = std::array< int, 4 >
 
typedef BaseTrackerRecHit const * Hit
 
typedef std::vector
< HitWithPhi >::const_iterator 
HitIter
 
typedef std::pair< HitIter,
HitIter
Range
 

Public Member Functions

Range all () const
 
DoubleRange doubleRange (float phiMin, float phiMax) const
 
bool empty () const
 
GlobalPoint gp (int i) const
 
float gv (int i) const
 
std::vector< Hithits (float phiMin, float phiMax) const
 
void hits (float phiMin, float phiMax, std::vector< Hit > &result) const
 
std::vector< Hithits () const
 
float phi (int i) const
 
 RecHitsSortedInPhi (const std::vector< Hit > &hits, GlobalPoint const &origin, DetLayer const *il)
 
float rv (int i) const
 
std::size_t size () const
 
Range unsafeRange (float phiMin, float phiMax) const
 

Static Public Member Functions

static void copyResult (const Range &range, std::vector< Hit > &result)
 

Public Attributes

std::vector< float > drphi
 
std::vector< float > du
 
std::vector< float > dv
 
bool isBarrel
 
DetLayer const * layer
 
std::vector< float > lphi
 
std::vector< HitWithPhitheHits
 
GlobalPoint theOrigin
 
std::vector< float > u
 
std::vector< float > v
 
std::vector< float > x
 
std::vector< float > y
 
std::vector< float > z
 

Detailed Description

A RecHit container sorted in phi. Provides fast access for hits in a given phi window using binary search.

Definition at line 15 of file RecHitsSortedInPhi.h.

Member Typedef Documentation

using RecHitsSortedInPhi::DoubleRange = std::array<int,4>

Definition at line 39 of file RecHitsSortedInPhi.h.

Definition at line 18 of file RecHitsSortedInPhi.h.

typedef std::vector<HitWithPhi>::const_iterator RecHitsSortedInPhi::HitIter

Definition at line 36 of file RecHitsSortedInPhi.h.

Definition at line 37 of file RecHitsSortedInPhi.h.

Constructor & Destructor Documentation

RecHitsSortedInPhi::RecHitsSortedInPhi ( const std::vector< Hit > &  hits,
GlobalPoint const &  origin,
DetLayer const *  il 
)

Definition at line 9 of file RecHitsSortedInPhi.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), drphi, du, dv, h, AnalysisDataFormats_SUSYBSMObjects::hp, i, isBarrel, lphi, Basic3DVector< T >::perp(), theHits, u, v, x, y, and z.

9  :
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  theHits.reserve(hits.size());
22  for (auto const & hp : hits) theHits.emplace_back(hp);
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 }
std::vector< HitWithPhi > theHits
int i
Definition: DBlmapReader.cc:9
std::vector< float > drphi
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
DetLayer const * layer
std::vector< float > z
std::vector< Hit > hits() const
std::vector< float > x
std::vector< float > lphi
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
std::vector< float > y
std::vector< float > v
std::vector< float > dv
std::vector< float > u
std::vector< float > du

Member Function Documentation

Range RecHitsSortedInPhi::all ( ) const
inline

Definition at line 82 of file RecHitsSortedInPhi.h.

References theHits.

Referenced by HitQuadrupletGeneratorFromLayerPairForPhotonConversion::hitPairs(), MultiHitGeneratorFromChi2::hitSets(), and LayerHitMapCache::operator()().

82  {
83  return Range(theHits.begin(), theHits.end());
84  }
std::vector< HitWithPhi > theHits
std::pair< HitIter, HitIter > Range
static void RecHitsSortedInPhi::copyResult ( const Range range,
std::vector< Hit > &  result 
)
inlinestatic

Definition at line 113 of file RecHitsSortedInPhi.h.

References i.

Referenced by hits().

113  {
114  result.reserve(result.size()+(range.second-range.first));
115  for (HitIter i = range.first; i != range.second; i++) result.push_back( i->hit());
116  }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:84
std::vector< HitWithPhi >::const_iterator HitIter
RecHitsSortedInPhi::DoubleRange RecHitsSortedInPhi::doubleRange ( float  phiMin,
float  phiMax 
) const

Definition at line 51 of file RecHitsSortedInPhi.cc.

References Geom::fpi(), Geom::ftwoPi(), Geom::pi(), diffTwoXMLs::r1, diffTwoXMLs::r2, theHits, and unsafeRange().

Referenced by HitPairGeneratorFromLayerPair::doublets().

51  {
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 }
std::vector< HitWithPhi > theHits
Range unsafeRange(float phiMin, float phiMax) const
constexpr float ftwoPi()
Definition: Pi.h:36
constexpr float fpi()
Definition: Pi.h:35
std::array< int, 4 > DoubleRange
std::pair< HitIter, HitIter > Range
constexpr double pi()
Definition: Pi.h:31
bool RecHitsSortedInPhi::empty ( void  ) const
inline
GlobalPoint RecHitsSortedInPhi::gp ( int  i) const
inline

Definition at line 90 of file RecHitsSortedInPhi.h.

References x, y, and z.

Referenced by gv().

90 { return GlobalPoint(x[i],y[i],z[i]);}
int i
Definition: DBlmapReader.cc:9
std::vector< float > z
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< float > x
std::vector< float > y
float RecHitsSortedInPhi::gv ( int  i) const
inline

Definition at line 88 of file RecHitsSortedInPhi.h.

References gp(), i, isBarrel, PV3DBase< T, PVType, FrameType >::perp(), and z.

88 { return isBarrel ? z[i] : gp(i).perp();} // global v
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
std::vector< float > z
GlobalPoint gp(int i) const
std::vector< RecHitsSortedInPhi::Hit > RecHitsSortedInPhi::hits ( float  phiMin,
float  phiMax 
) const

Definition at line 98 of file RecHitsSortedInPhi.cc.

References hits(), and mps_fire::result.

Referenced by HitQuadrupletGeneratorFromLayerPairForPhotonConversion::hitPairs(), HitPairGeneratorFromLayerPairForPhotonConversion::hitPairs(), PixelTripletNoTipGenerator::hitTriplets(), and PixelTripletLowPtGenerator::hitTriplets().

99 {
100  std::vector<Hit> result;
101  hits( phiMin, phiMax, result);
102  return result;
103 }
std::vector< Hit > hits() const
tuple result
Definition: mps_fire.py:84
void RecHitsSortedInPhi::hits ( float  phiMin,
float  phiMax,
std::vector< Hit > &  result 
) const

Definition at line 77 of file RecHitsSortedInPhi.cc.

References copyResult(), Geom::fpi(), Geom::ftwoPi(), Geom::pi(), and unsafeRange().

78 {
79  if ( phiMin < phiMax) {
80  if ( phiMin < -Geom::fpi()) {
82  copyResult( unsafeRange( -Geom::fpi(), phiMax), result);
83  }
84  else if (phiMax > Geom::pi()) {
85  copyResult( unsafeRange( phiMin, Geom::fpi()), 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 }
Range unsafeRange(float phiMin, float phiMax) const
constexpr float ftwoPi()
Definition: Pi.h:36
constexpr float fpi()
Definition: Pi.h:35
tuple result
Definition: mps_fire.py:84
static void copyResult(const Range &range, std::vector< Hit > &result)
constexpr double pi()
Definition: Pi.h:31
std::vector<Hit> RecHitsSortedInPhi::hits ( void  ) const
inline

Definition at line 75 of file RecHitsSortedInPhi.h.

References i, mps_fire::result, and theHits.

Referenced by hits().

75  {
76  std::vector<Hit> result; result.reserve(theHits.size());
77  for (HitIter i=theHits.begin(); i!=theHits.end(); i++) result.push_back(i->hit());
78  return result;
79  }
std::vector< HitWithPhi > theHits
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:84
std::vector< HitWithPhi >::const_iterator HitIter
float RecHitsSortedInPhi::phi ( int  i) const
inline

Definition at line 87 of file RecHitsSortedInPhi.h.

References i, and theHits.

Referenced by Particle.Particle::__str__().

87 { return theHits[i].phi();}
std::vector< HitWithPhi > theHits
int i
Definition: DBlmapReader.cc:9
float RecHitsSortedInPhi::rv ( int  i) const
inline

Definition at line 89 of file RecHitsSortedInPhi.h.

References i, isBarrel, u, and v.

Referenced by HitPairGeneratorFromLayerPair::doublets().

89 { return isBarrel ? u[i] : v[i];} // dispaced r
int i
Definition: DBlmapReader.cc:9
std::vector< float > v
std::vector< float > u
std::size_t RecHitsSortedInPhi::size ( void  ) const
inline

Definition at line 44 of file RecHitsSortedInPhi.h.

References theHits.

Referenced by HitPairGeneratorFromLayerPair::doublets().

44 { return theHits.size();}
std::vector< HitWithPhi > theHits
RecHitsSortedInPhi::Range RecHitsSortedInPhi::unsafeRange ( float  phiMin,
float  phiMax 
) const

Definition at line 106 of file RecHitsSortedInPhi.cc.

References theHits.

Referenced by doubleRange(), and hits().

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
std::pair< HitIter, HitIter > Range

Member Data Documentation

std::vector<float> RecHitsSortedInPhi::drphi
std::vector<float> RecHitsSortedInPhi::du
std::vector<float> RecHitsSortedInPhi::dv
bool RecHitsSortedInPhi::isBarrel
DetLayer const* RecHitsSortedInPhi::layer
std::vector<float> RecHitsSortedInPhi::lphi

Definition at line 111 of file RecHitsSortedInPhi.h.

Referenced by RecHitsSortedInPhi().

std::vector<HitWithPhi> RecHitsSortedInPhi::theHits
GlobalPoint RecHitsSortedInPhi::theOrigin
mutable

Definition at line 94 of file RecHitsSortedInPhi.h.

Referenced by LayerHitMapCache::operator()().

std::vector<float> RecHitsSortedInPhi::u

Definition at line 107 of file RecHitsSortedInPhi.h.

Referenced by RecHitsSortedInPhi(), and rv().

std::vector<float> RecHitsSortedInPhi::v

Definition at line 108 of file RecHitsSortedInPhi.h.

Referenced by RecHitsSortedInPhi(), and rv().

std::vector<float> RecHitsSortedInPhi::x
std::vector<float> RecHitsSortedInPhi::y
std::vector<float> RecHitsSortedInPhi::z