CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
RZLine Class Reference

#include <RZLine.h>

Classes

struct  ErrZ2_tag
 

Public Member Functions

float chi2 () const
 
float cotTheta () const
 
float covii () const
 
float covsi () const
 
float covss () const
 
float intercept () const
 
template<typename P , typename E , typename B >
 RZLine (const P &points, const E &errors, const B &isBarrel)
 
 RZLine (const std::vector< float > &r, const std::vector< float > &z, const std::vector< float > &errZ)
 
template<size_t N>
 RZLine (const std::array< float, N > &r, const std::array< float, N > &z, const std::array< float, N > &errZ)
 
template<typename T >
 RZLine (const T &r, const T &z, const T &errZ2, ErrZ2_tag)
 

Private Member Functions

template<typename R , typename Z , typename E >
void calculate (const R &r, const Z &z, const E &errZ2)
 
template<typename T >
T sqr (T t)
 

Private Attributes

float chi2_
 
float cotTheta_
 
float covii_
 
float covsi_
 
float covss_
 
float intercept_
 

Detailed Description

Definition at line 12 of file RZLine.h.

Constructor & Destructor Documentation

template<typename P , typename E , typename B >
RZLine::RZLine ( const P points,
const E &  errors,
const B &  isBarrel 
)
inline

Constructor for containers of GlobalPoint, GlobalError, and bool

Template Parameters
PContainer of GlobalPoint
EContainer of GlobalError
BContainer of bool

Container can be e.g. std::vector, std::array, or DynArray.

Although for std::array use this constructor could be specialized to use std::array instead of DynArray for temporary storage.

Definition at line 29 of file RZLine.h.

References calculate(), declareDynArray, mps_fire::i, gen::n, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), alignCSCRings::r, sqr(), z, and PV3DBase< T, PVType, FrameType >::z().

29  {
30  const size_t n = points.size();
31  declareDynArray(float, n, r);
32  declareDynArray(float, n, z);
33  declareDynArray(float, n, errZ2);
34  for(size_t i=0; i<n; ++i) {
35  const GlobalPoint& p = points[i];
36  r[i] = p.perp();
37  z[i] = p.z();
38  }
39 
40  float simpleCot2 = sqr( (z[n-1]-z[0])/ (r[n-1]-r[0]) );
41  for (size_t i=0; i<n; ++i) {
42  errZ2[i] = (isBarrel[i]) ? errors[i].czz() :
43  errors[i].rerr(points[i]) * simpleCot2;
44  }
45 
46  calculate(r, z, errZ2);
47  }
T perp() const
Definition: PV3DBase.h:72
bool isBarrel(GeomDetEnumerators::SubDetector m)
T sqr(T t)
Definition: RZLine.h:111
T z() const
Definition: PV3DBase.h:64
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:101
Definition: errors.py:1
#define declareDynArray(T, n, x)
Definition: DynArray.h:59
RZLine::RZLine ( const std::vector< float > &  r,
const std::vector< float > &  z,
const std::vector< float > &  errZ 
)
inline

Constructor for std::vector of r, z, and z standard deviation

Definition at line 52 of file RZLine.h.

References calculate(), declareDynArray, mps_fire::i, gen::n, and sqr().

54  {
55  const size_t n = errZ.size();
56  declareDynArray(float, n, errZ2);
57  for(size_t i=0; i<n; ++i) errZ2[i] = sqr(errZ[i]);
58  calculate(r, z, errZ2);
59  }
T sqr(T t)
Definition: RZLine.h:111
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:101
#define declareDynArray(T, n, x)
Definition: DynArray.h:59
template<size_t N>
RZLine::RZLine ( const std::array< float, N > &  r,
const std::array< float, N > &  z,
const std::array< float, N > &  errZ 
)
inline

Constructor for std::array of r, z, and z standard deviation

Definition at line 65 of file RZLine.h.

References calculate(), mps_fire::i, N, and sqr().

67  {
68  std::array<float, N> errZ2;
69  for(size_t i=0; i<N; ++i) errZ2[i] = sqr(errZ[i]);
70  calculate(r, z, errZ2);
71  }
T sqr(T t)
Definition: RZLine.h:111
#define N
Definition: blowfish.cc:9
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:101
template<typename T >
RZLine::RZLine ( const T r,
const T z,
const T errZ2,
ErrZ2_tag   
)
inline

Constructor for container of r, z, and z variance

Template Parameters
TContainer of float

Container can be e.g. std::vector, std::array, or DynArray.

The ErrZ2_tag parameter is used to distinguish this constructor from other 3-parameter constructors.

Passing variance is useful in cases where it is already available to avoid making a square of a square root.

Definition at line 87 of file RZLine.h.

References calculate().

87  {
88  calculate(r, z, errZ2);
89  }
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:101

Member Function Documentation

template<typename R , typename Z , typename E >
void RZLine::calculate ( const R &  r,
const Z &  z,
const E &  errZ2 
)
inlineprivate

Definition at line 101 of file RZLine.h.

References chi2_, cotTheta_, covii_, covsi_, covss_, mps_fire::i, intercept_, linearFit(), gen::n, and sqr().

Referenced by RZLine().

101  {
102  const size_t n = r.size();
103  linearFit(r.data(), z.data(), n, errZ2.data(), cotTheta_, intercept_, covss_, covii_, covsi_);
104  chi2_ = 0.f;
105  for(size_t i=0; i<n; ++i) {
106  chi2_ += sqr( ((z[i]-intercept_) - cotTheta_*r[i]) ) / errZ2[i];
107  }
108  }
float covii_
Definition: RZLine.h:116
float chi2_
Definition: RZLine.h:118
T sqr(T t)
Definition: RZLine.h:111
float covss_
Definition: RZLine.h:115
void linearFit(T const *__restrict__ x, T const *__restrict__ y, int ndat, T const *__restrict__ sigy2, T &slope, T &intercept, T &covss, T &covii, T &covsi)
Definition: LinearFit.h:26
float cotTheta_
Definition: RZLine.h:113
float covsi_
Definition: RZLine.h:117
float intercept_
Definition: RZLine.h:114
float RZLine::chi2 ( void  ) const
inline
float RZLine::cotTheta ( ) const
inline

Definition at line 91 of file RZLine.h.

References cotTheta_.

Referenced by PixelFitterByConformalMappingAndLine::run().

91 { return cotTheta_; }
float cotTheta_
Definition: RZLine.h:113
float RZLine::covii ( ) const
inline

Definition at line 94 of file RZLine.h.

References covii_.

Referenced by PixelFitterByConformalMappingAndLine::run().

94 { return covii_; }
float covii_
Definition: RZLine.h:116
float RZLine::covsi ( ) const
inline

Definition at line 95 of file RZLine.h.

References covsi_.

95 { return covsi_; }
float covsi_
Definition: RZLine.h:117
float RZLine::covss ( ) const
inline

Definition at line 93 of file RZLine.h.

References covss_.

Referenced by PixelFitterByConformalMappingAndLine::run().

93 { return covss_; }
float covss_
Definition: RZLine.h:115
float RZLine::intercept ( ) const
inline

Definition at line 92 of file RZLine.h.

References intercept_.

Referenced by PixelFitterByConformalMappingAndLine::run().

92 { return intercept_; }
float intercept_
Definition: RZLine.h:114
template<typename T >
T RZLine::sqr ( T  t)
inlineprivate

Definition at line 111 of file RZLine.h.

References protons_cff::t.

Referenced by calculate(), and RZLine().

111 { return t*t; }

Member Data Documentation

float RZLine::chi2_
private

Definition at line 118 of file RZLine.h.

Referenced by calculate(), and chi2().

float RZLine::cotTheta_
private

Definition at line 113 of file RZLine.h.

Referenced by calculate(), and cotTheta().

float RZLine::covii_
private

Definition at line 116 of file RZLine.h.

Referenced by calculate(), and covii().

float RZLine::covsi_
private

Definition at line 117 of file RZLine.h.

Referenced by calculate(), and covsi().

float RZLine::covss_
private

Definition at line 115 of file RZLine.h.

Referenced by calculate(), and covss().

float RZLine::intercept_
private

Definition at line 114 of file RZLine.h.

Referenced by calculate(), and intercept().