CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Static 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 T >
void calculate (const T *r, const T *z, const T *errZ2, size_t n)
 

Static Private Member Functions

template<typename T >
static constexpr 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(), mps_fire::i, PixelPluginsPhase0_cfi::isBarrel, dqmiodumpmetadata::n, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, sqr(), and z.

29  {
30  const size_t n = points.size();
31  const size_t nSafe = n > 0 ? n : 1;
32  float r[nSafe];
33  float z[nSafe];
34  float errZ2[nSafe];
35  for (size_t i = 0; i < n; ++i) {
36  const GlobalPoint& p = points[i];
37  r[i] = p.perp();
38  z[i] = p.z();
39  }
40 
41  float simpleCot2 = n > 1 ? sqr((z[n - 1] - z[0]) / (r[n - 1] - r[0])) : 0.f;
42  for (size_t i = 0; i < n; ++i) {
43  errZ2[i] = (isBarrel[i]) ? errors[i].czz() : errors[i].rerr(points[i]) * simpleCot2;
44  }
45 
46  calculate(r, z, errZ2, n);
47  }
static constexpr T sqr(T t)
Definition: RZLine.h:112
double f[11][100]
void calculate(const T *r, const T *z, const T *errZ2, size_t n)
Definition: RZLine.h:99
Definition: errors.py:1

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

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

52  {
53  const size_t n = errZ.size();
54  float errZ2[n > 0 ? n : n + 1];
55  for (size_t i = 0; i < n; ++i)
56  errZ2[i] = sqr(errZ[i]);
57  calculate(r.data(), z.data(), errZ2, n);
58  }
static constexpr T sqr(T t)
Definition: RZLine.h:112
void calculate(const T *r, const T *z, const T *errZ2, size_t n)
Definition: RZLine.h:99

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

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

64  {
65  std::array<float, N> errZ2;
66  for (size_t i = 0; i < N; ++i)
67  errZ2[i] = sqr(errZ[i]);
68  calculate(r.data(), z.data(), errZ2.data(), N);
69  }
static constexpr T sqr(T t)
Definition: RZLine.h:112
#define N
Definition: blowfish.cc:9
void calculate(const T *r, const T *z, const T *errZ2, size_t n)
Definition: RZLine.h:99

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

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

85  {
86  calculate(r.data(), z.data(), errZ2.data(), r.size());
87  }
void calculate(const T *r, const T *z, const T *errZ2, size_t n)
Definition: RZLine.h:99

Member Function Documentation

◆ calculate()

template<typename T >
void RZLine::calculate ( const T r,
const T z,
const T errZ2,
size_t  n 
)
inlineprivate

Definition at line 99 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().

99  {
100  //Have 0 and 1 cases return same value
101  if (n < 2) [[unlikely]] {
102  n = 0;
103  }
105  chi2_ = 0.f;
106  for (size_t i = 0; i < n; ++i) {
107  chi2_ += sqr(((z[i] - intercept_) - cotTheta_ * r[i])) / errZ2[i];
108  }
109  }
float covii_
Definition: RZLine.h:119
float chi2_
Definition: RZLine.h:121
static constexpr T sqr(T t)
Definition: RZLine.h:112
float covss_
Definition: RZLine.h:118
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:116
float covsi_
Definition: RZLine.h:120
float intercept_
Definition: RZLine.h:117

◆ chi2()

float RZLine::chi2 ( void  ) const
inline

◆ cotTheta()

float RZLine::cotTheta ( ) const
inline

Definition at line 89 of file RZLine.h.

References cotTheta_.

Referenced by PixelFitterByConformalMappingAndLine::run().

89 { return cotTheta_; }
float cotTheta_
Definition: RZLine.h:116

◆ covii()

float RZLine::covii ( ) const
inline

Definition at line 92 of file RZLine.h.

References covii_.

Referenced by PixelFitterByConformalMappingAndLine::run().

92 { return covii_; }
float covii_
Definition: RZLine.h:119

◆ covsi()

float RZLine::covsi ( ) const
inline

Definition at line 93 of file RZLine.h.

References covsi_.

93 { return covsi_; }
float covsi_
Definition: RZLine.h:120

◆ covss()

float RZLine::covss ( ) const
inline

Definition at line 91 of file RZLine.h.

References covss_.

Referenced by PixelFitterByConformalMappingAndLine::run().

91 { return covss_; }
float covss_
Definition: RZLine.h:118

◆ intercept()

float RZLine::intercept ( ) const
inline

Definition at line 90 of file RZLine.h.

References intercept_.

Referenced by PixelFitterByConformalMappingAndLine::run().

90 { return intercept_; }
float intercept_
Definition: RZLine.h:117

◆ sqr()

template<typename T >
static constexpr T RZLine::sqr ( T  t)
inlinestaticprivate

Definition at line 112 of file RZLine.h.

References submitPVValidationJobs::t.

Referenced by calculate(), and RZLine().

112  {
113  return t * t;
114  }

Member Data Documentation

◆ chi2_

float RZLine::chi2_
private

Definition at line 121 of file RZLine.h.

Referenced by calculate(), and chi2().

◆ cotTheta_

float RZLine::cotTheta_
private

Definition at line 116 of file RZLine.h.

Referenced by calculate(), and cotTheta().

◆ covii_

float RZLine::covii_
private

Definition at line 119 of file RZLine.h.

Referenced by calculate(), and covii().

◆ covsi_

float RZLine::covsi_
private

Definition at line 120 of file RZLine.h.

Referenced by calculate(), and covsi().

◆ covss_

float RZLine::covss_
private

Definition at line 118 of file RZLine.h.

Referenced by calculate(), and covss().

◆ intercept_

float RZLine::intercept_
private

Definition at line 117 of file RZLine.h.

Referenced by calculate(), and intercept().