CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

RecHitsSortedInPhi Class Reference

#include <RecHitsSortedInPhi.h>

List of all members.

Classes

struct  HitLessPhi
class  HitWithPhi

Public Types

typedef
TransientTrackingRecHit::ConstRecHitPointer 
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
std::vector< Hithits () const
void hits (float phiMin, float phiMax, std::vector< Hit > &result) 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

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, i, isBarrel, lphi, python::multivaluedict::sort(), theHits, u, v, x, y, and z.

                                                                                                                  :
  layer(il),
  isBarrel(il->isBarrel()),
  x(hits.size()),y(hits.size()),z(hits.size()),drphi(hits.size()),
  u(hits.size()),v(hits.size()),du(hits.size()),dv(hits.size()),
  lphi(hits.size())
{

  // standard region have origin as 0,0,z (not true!!!!0
  // cosmic region never used here
  // assert(origin.x()==0 && origin.y()==0);

  for (std::vector<Hit>::const_iterator i=hits.begin(); i!=hits.end(); i++) {
    theHits.push_back(HitWithPhi(*i));
  }
  std::sort( theHits.begin(), theHits.end(), HitLessPhi());

  for (unsigned int i=0; i!=theHits.size(); ++i) {
    auto const & h = *theHits[i].hit();
    auto const & gs = reinterpret_cast<TValidTrackingRecHit const &>(h).globalState();
    auto loc = gs.position-origin.basicVector();
    float lr = loc.perp();
    // float lr = gs.position.perp();
    float lz = gs.position.z();
    float dr = gs.errorR;
    float dz = gs.errorZ;
    // r[i] = gs.position.perp();
    // phi[i] = gs.position.barePhi();
    x[i] = gs.position.x();
    y[i] = gs.position.y();
    z[i] = lz;
    drphi[i] = gs.errorRPhi;
    u[i] = isBarrel ? lr : lz;
    v[i] = isBarrel ? lz : lr;
    du[i] = isBarrel ? dr : dz;
    dv[i] = isBarrel ? dz : dr;
    lphi[i] = loc.barePhi();
  }
  
}

Member Function Documentation

Range RecHitsSortedInPhi::all ( ) const [inline]

Definition at line 82 of file RecHitsSortedInPhi.h.

References theHits.

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

                    {
    return Range(theHits.begin(), theHits.end());
  }
static void RecHitsSortedInPhi::copyResult ( const Range range,
std::vector< Hit > &  result 
) [inline, static]

Definition at line 113 of file RecHitsSortedInPhi.h.

References i.

Referenced by hits().

                                                                      {
    result.reserve(result.size()+(range.second-range.first));
    for (HitIter i = range.first; i != range.second; i++) result.push_back( i->hit());
  }
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().

                                                                                              {
  Range r1,r2;
  if ( phiMin < phiMax) {
    if ( phiMin < -Geom::fpi()) {
      r1 = unsafeRange( phiMin + Geom::ftwoPi(), Geom::fpi());
      r2 = unsafeRange( -Geom::fpi(), phiMax);
    }
    else if (phiMax > Geom::pi()) {
     r1 = unsafeRange( phiMin, Geom::fpi());
     r2 = unsafeRange( -Geom::fpi(), phiMax-Geom::ftwoPi());
    }
    else {
      r1 = unsafeRange( phiMin, phiMax);
      r2 = Range(theHits.begin(),theHits.begin());
    }
  }
  else {
    r1 =unsafeRange( phiMin, Geom::fpi());
    r2 =unsafeRange( -Geom::fpi(), phiMax);
  }

  return (DoubleRange){{int(r1.first-theHits.begin()),int(r1.second-theHits.begin())
        ,int(r2.first-theHits.begin()),int(r2.second-theHits.begin())}};
}
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().

{ return GlobalPoint(x[i],y[i],z[i]);}
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.

{ return isBarrel ? z[i] : gp(i).perp();}  // global v
void RecHitsSortedInPhi::hits ( float  phiMin,
float  phiMax,
std::vector< Hit > &  result 
) const
std::vector<Hit> RecHitsSortedInPhi::hits ( ) const [inline]

Definition at line 75 of file RecHitsSortedInPhi.h.

References i, query::result, and theHits.

Referenced by hits().

                              {
    std::vector<Hit> result; result.reserve(theHits.size());
    for (HitIter i=theHits.begin(); i!=theHits.end(); i++) result.push_back(i->hit());
    return result;
  }
std::vector< RecHitsSortedInPhi::Hit > RecHitsSortedInPhi::hits ( float  phiMin,
float  phiMax 
) const
float RecHitsSortedInPhi::phi ( int  i) const [inline]

Definition at line 87 of file RecHitsSortedInPhi.h.

References i, and theHits.

{ return theHits[i].phi();}
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().

{ return isBarrel ? u[i] : v[i];}  // dispaced r
std::size_t RecHitsSortedInPhi::size ( void  ) const [inline]

Definition at line 44 of file RecHitsSortedInPhi.h.

References theHits.

Referenced by HitPairGeneratorFromLayerPair::doublets().

{ return theHits.size();}
RecHitsSortedInPhi::Range RecHitsSortedInPhi::unsafeRange ( float  phiMin,
float  phiMax 
) const

Definition at line 106 of file RecHitsSortedInPhi.cc.

References theHits.

Referenced by doubleRange(), and hits().

{
  auto low = std::lower_bound( theHits.begin(), theHits.end(), HitWithPhi(phiMin), HitLessPhi());
  return Range( low,
               std::upper_bound(low, theHits.end(), HitWithPhi(phiMax), HitLessPhi()));
}

Member Data Documentation

std::vector<float> RecHitsSortedInPhi::drphi
std::vector<float> RecHitsSortedInPhi::du
std::vector<float> RecHitsSortedInPhi::dv

Definition at line 98 of file RecHitsSortedInPhi.h.

std::vector<float> RecHitsSortedInPhi::lphi

Definition at line 111 of file RecHitsSortedInPhi.h.

Referenced by RecHitsSortedInPhi().

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