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

◆ RZLine() [1/4]

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, PixelPluginsPhase0_cfi::isBarrel, dqmiodumpmetadata::n, AlCaHLTBitMon_ParallelJobs::p, hiPixelPairStep_cff::points, alignCSCRings::r, sqr(), and 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() : errors[i].rerr(points[i]) * simpleCot2;
43  }
44 
45  calculate(r, z, errZ2);
46  }
T sqr(T t)
Definition: RZLine.h:108
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:98
Definition: errors.py:1
#define declareDynArray(T, n, x)
Definition: DynArray.h:91

◆ RZLine() [2/4]

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 51 of file RZLine.h.

References calculate(), declareDynArray, fftjetvertexadder_cfi::errZ, mps_fire::i, dqmiodumpmetadata::n, alignCSCRings::r, sqr(), and z.

51  {
52  const size_t n = errZ.size();
53  declareDynArray(float, n, errZ2);
54  for (size_t i = 0; i < n; ++i)
55  errZ2[i] = sqr(errZ[i]);
56  calculate(r, z, errZ2);
57  }
T sqr(T t)
Definition: RZLine.h:108
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:98
#define declareDynArray(T, n, x)
Definition: DynArray.h:91

◆ RZLine() [3/4]

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 63 of file RZLine.h.

References calculate(), fftjetvertexadder_cfi::errZ, mps_fire::i, N, alignCSCRings::r, sqr(), and z.

63  {
64  std::array<float, N> errZ2;
65  for (size_t i = 0; i < N; ++i)
66  errZ2[i] = sqr(errZ[i]);
67  calculate(r, z, errZ2);
68  }
T sqr(T t)
Definition: RZLine.h:108
#define N
Definition: blowfish.cc:9
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:98

◆ RZLine() [4/4]

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 84 of file RZLine.h.

References calculate(), alignCSCRings::r, and z.

84  {
85  calculate(r, z, errZ2);
86  }
void calculate(const R &r, const Z &z, const E &errZ2)
Definition: RZLine.h:98

Member Function Documentation

◆ calculate()

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

Definition at line 98 of file RZLine.h.

References chi2_, cotTheta_, covii_, covsi_, covss_, mps_fire::i, intercept_, linearFit(), dqmiodumpmetadata::n, alignCSCRings::r, sqr(), and z.

Referenced by RZLine().

98  {
99  const size_t n = r.size();
100  linearFit(r.data(), z.data(), n, errZ2.data(), cotTheta_, intercept_, covss_, covii_, covsi_);
101  chi2_ = 0.f;
102  for (size_t i = 0; i < n; ++i) {
103  chi2_ += sqr(((z[i] - intercept_) - cotTheta_ * r[i])) / errZ2[i];
104  }
105  }
float covii_
Definition: RZLine.h:115
float chi2_
Definition: RZLine.h:117
T sqr(T t)
Definition: RZLine.h:108
float covss_
Definition: RZLine.h:114
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:29
float cotTheta_
Definition: RZLine.h:112
float covsi_
Definition: RZLine.h:116
float intercept_
Definition: RZLine.h:113

◆ chi2()

float RZLine::chi2 ( void  ) const
inline

◆ cotTheta()

float RZLine::cotTheta ( ) const
inline

Definition at line 88 of file RZLine.h.

References cotTheta_.

Referenced by PixelFitterByConformalMappingAndLine::run().

88 { return cotTheta_; }
float cotTheta_
Definition: RZLine.h:112

◆ covii()

float RZLine::covii ( ) const
inline

Definition at line 91 of file RZLine.h.

References covii_.

Referenced by PixelFitterByConformalMappingAndLine::run().

91 { return covii_; }
float covii_
Definition: RZLine.h:115

◆ covsi()

float RZLine::covsi ( ) const
inline

Definition at line 92 of file RZLine.h.

References covsi_.

92 { return covsi_; }
float covsi_
Definition: RZLine.h:116

◆ covss()

float RZLine::covss ( ) const
inline

Definition at line 90 of file RZLine.h.

References covss_.

Referenced by PixelFitterByConformalMappingAndLine::run().

90 { return covss_; }
float covss_
Definition: RZLine.h:114

◆ intercept()

float RZLine::intercept ( ) const
inline

Definition at line 89 of file RZLine.h.

References intercept_.

Referenced by PixelFitterByConformalMappingAndLine::run().

89 { return intercept_; }
float intercept_
Definition: RZLine.h:113

◆ sqr()

template<typename T >
T RZLine::sqr ( T  t)
inlineprivate

Definition at line 108 of file RZLine.h.

References submitPVValidationJobs::t.

Referenced by calculate(), and RZLine().

108  {
109  return t * t;
110  }

Member Data Documentation

◆ chi2_

float RZLine::chi2_
private

Definition at line 117 of file RZLine.h.

Referenced by calculate(), and chi2().

◆ cotTheta_

float RZLine::cotTheta_
private

Definition at line 112 of file RZLine.h.

Referenced by calculate(), and cotTheta().

◆ covii_

float RZLine::covii_
private

Definition at line 115 of file RZLine.h.

Referenced by calculate(), and covii().

◆ covsi_

float RZLine::covsi_
private

Definition at line 116 of file RZLine.h.

Referenced by calculate(), and covsi().

◆ covss_

float RZLine::covss_
private

Definition at line 114 of file RZLine.h.

Referenced by calculate(), and covss().

◆ intercept_

float RZLine::intercept_
private

Definition at line 113 of file RZLine.h.

Referenced by calculate(), and intercept().