Belle II Software development
CDCSZObservations Class Reference

Class serving as a storage of observed sz positions to present to the sz line fitters. More...

#include <CDCSZObservations.h>

Public Member Functions

 CDCSZObservations (EFitVariance fitVariance=EFitVariance::c_Proper, bool onlyStereo=false)
 Constructor taking in preferred variance which is taken from the various hit objects if present.
 
std::size_t size () const
 Returns the number of observations stored.
 
double * data ()
 Return the pointer to the number buffer.
 
bool empty () const
 Returns true if there are no observations stored.
 
void clear ()
 Removes all observations stored.
 
void reserve (std::size_t nObservations)
 Reserves enough space for nObservations.
 
double getS (int iObservation) const
 Getter for the arc length value of the observation at the given index.
 
double getZ (int iObservation) const
 Getter for the z value of the observation at the given index.
 
double getWeight (int iObservation) const
 Getter for the weight / inverse variance of the observation at the given index.
 
std::size_t fill (double s, double z, double weight=1.0)
 Appends the observed position.
 
std::size_t append (const TrackingUtilities::CDCRecoHit3D &recoHit3D)
 Appends the observed position.
 
std::size_t appendRange (const std::vector< TrackingUtilities::CDCRecoHit3D > &recoHit3Ds)
 Appends all reconstructed hits from the three dimensional track.
 
std::size_t appendRange (const TrackingUtilities::CDCSegment3D &segment3D)
 Appends all reconstructed hits from the three dimensional segment.
 
std::size_t appendRange (const TrackingUtilities::CDCTrack &track)
 Appends all reconstructed hits from the three dimensional track.
 
TrackingUtilities::Vector2D getCentralPoint () const
 Extracts the observation center that is at the index in the middle.
 
void passiveMoveBy (const TrackingUtilities::Vector2D &origin)
 Moves all observations passively such that the given vector becomes to origin of the new coordinate system.
 
TrackingUtilities::Vector2D centralize ()
 Picks one observation as a reference point and transform all observations to that new origin.
 
void setFitVariance (EFitVariance fitVariance)
 Setter for the indicator that the drift variance should be used.
 

Private Attributes

std::vector< double > m_szObservations
 Memory for the individual observations.
 
EFitVariance m_fitVariance
 Indicator which variance information should preferably be extracted from hits in calls to append.
 
bool m_onlyStereo
 Switch to only use information from stereo hits.
 

Detailed Description

Class serving as a storage of observed sz positions to present to the sz line fitters.

Definition at line 30 of file CDCSZObservations.h.

Constructor & Destructor Documentation

◆ CDCSZObservations()

CDCSZObservations ( EFitVariance fitVariance = EFitVariance::c_Proper,
bool onlyStereo = false )
inlineexplicit

Constructor taking in preferred variance which is taken from the various hit objects if present.

Parameters
fitVarianceVariance information to be used Currently only c_Unit and c_Proper are supported.
onlyStereoSwitch to only use the information of stereo hits.

Definition at line 40 of file CDCSZObservations.h.

42 : m_fitVariance(fitVariance)
43 , m_onlyStereo(onlyStereo)
44 {
45 }

Member Function Documentation

◆ append()

std::size_t append ( const TrackingUtilities::CDCRecoHit3D & recoHit3D)

Appends the observed position.

Definition at line 40 of file CDCSZObservations.cc.

41{
42 if (m_onlyStereo and recoHit3D.isAxial()) return 0;
43
44 const double s = recoHit3D.getArcLength2D();
45 const double z = recoHit3D.getRecoPos3D().z();
46
47 double weight = 1.0;
48 if (m_fitVariance == EFitVariance::c_Unit) {
49 weight = 1;
50 } else {
51 // Translate the drift length uncertainty to a uncertainty in z
52 // by the taking the projected wire vector part parallel to the displacement
53 // as a proportionality factor to the z direction.
54 const CDCWire& wire = recoHit3D.getWire();
55 const Vector3D& wireVector = wire.getWireVector();
56 const Vector2D disp2D = recoHit3D.getRecoDisp2D();
57 const double driftlengthVariance = recoHit3D.getRecoDriftLengthVariance();
58
59 double dispNorm = disp2D.norm();
60
61 double zeta = 1.0;
62 if (dispNorm == 0.0) {
63 zeta = wireVector.xy().norm() / wireVector.z();
64 } else {
65 zeta = wireVector.xy().dot(disp2D) / wireVector.z() / dispNorm;
66 }
67
68 weight = zeta * zeta / driftlengthVariance;
69 }
70
71 size_t appendedHit = fill(s, z, weight);
72 return appendedHit;
73}
ROOT::Math::XYZVector getWireVector() const
Getter for the vector pointing from the back end of the wire to the front end of the wire.
Definition CDCWire.h:240
bool m_onlyStereo
Switch to only use information from stereo hits.
std::size_t fill(double s, double z, double weight=1.0)
Appends the observed position.
EFitVariance m_fitVariance
Indicator which variance information should preferably be extracted from hits in calls to append.
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition Vector2D.h:178
double norm() const
Calculates the length of the vector.
Definition Vector2D.h:206
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition Vector3D.h:513
double z() const
Getter for the z coordinate.
Definition Vector3D.h:501
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34

◆ appendRange() [1/3]

std::size_t appendRange ( const std::vector< TrackingUtilities::CDCRecoHit3D > & recoHit3Ds)

Appends all reconstructed hits from the three dimensional track.

Returns
Number of added hits

Definition at line 75 of file CDCSZObservations.cc.

76{
77 std::size_t nAppendedHits = 0;
78 for (const CDCRecoHit3D& recoHit3D : recoHit3Ds) {
79 nAppendedHits += append(recoHit3D);
80 }
81 return nAppendedHits;
82}
std::size_t append(const TrackingUtilities::CDCRecoHit3D &recoHit3D)
Appends the observed position.

◆ appendRange() [2/3]

std::size_t appendRange ( const TrackingUtilities::CDCSegment3D & segment3D)

Appends all reconstructed hits from the three dimensional segment.

Returns
Number of added hits

Definition at line 84 of file CDCSZObservations.cc.

85{
86 const std::vector<CDCRecoHit3D> recoHit3Ds = segment3D;
87 return this->appendRange(recoHit3Ds);
88}
std::size_t appendRange(const std::vector< TrackingUtilities::CDCRecoHit3D > &recoHit3Ds)
Appends all reconstructed hits from the three dimensional track.

◆ appendRange() [3/3]

std::size_t appendRange ( const TrackingUtilities::CDCTrack & track)

Appends all reconstructed hits from the three dimensional track.

Returns
Number of added hits

Definition at line 90 of file CDCSZObservations.cc.

91{
92 const std::vector<CDCRecoHit3D> recoHit3Ds = track;
93 return this->appendRange(recoHit3Ds);
94}

◆ centralize()

Vector2D centralize ( )

Picks one observation as a reference point and transform all observations to that new origin.

Definition at line 120 of file CDCSZObservations.cc.

121{
122 // Pick an observation at the center
123 Vector2D centralPoint = getCentralPoint();
124 passiveMoveBy(centralPoint);
125 return centralPoint;
126}
TrackingUtilities::Vector2D getCentralPoint() const
Extracts the observation center that is at the index in the middle.
void passiveMoveBy(const TrackingUtilities::Vector2D &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...

◆ clear()

void clear ( )
inline

Removes all observations stored.

Definition at line 67 of file CDCSZObservations.h.

68 {
69 m_szObservations.clear();
70 }

◆ data()

double * data ( )
inline

Return the pointer to the number buffer.

Definition at line 55 of file CDCSZObservations.h.

56 {
57 return m_szObservations.data();
58 }

◆ empty()

bool empty ( ) const
inline

Returns true if there are no observations stored.

Definition at line 61 of file CDCSZObservations.h.

62 {
63 return m_szObservations.empty();
64 }

◆ fill()

std::size_t fill ( double s,
double z,
double weight = 1.0 )

Appends the observed position.

Note
Observations are skipped, if one of the given variables is NAN.
Parameters
sS coordinate of the center of the observed position.
zZ coordinate of the center of the observed position.
weightThe relative weight of the observation. In order to generate a unit less chi^2 measure the weight should be chosen as the inverse variance of the drift length. Defaults to 1.
Returns
Number of observations added. One if the observation was added. Zero if one of the given variables is NAN.

Definition at line 25 of file CDCSZObservations.cc.

26{
27 if (std::isnan(s)) return 0;
28 if (std::isnan(z)) return 0;
29 if (std::isnan(weight)) {
30 B2WARNING("Weight is nan. Skipping observation");
31 return 0;
32 }
33
34 m_szObservations.push_back(s);
35 m_szObservations.push_back(z);
36 m_szObservations.push_back(weight);
37 return 1;
38}
std::vector< double > m_szObservations
Memory for the individual observations.

◆ getCentralPoint()

Vector2D getCentralPoint ( ) const

Extracts the observation center that is at the index in the middle.

Definition at line 96 of file CDCSZObservations.cc.

97{
98 std::size_t n = size();
99 if (n == 0) return Vector2D(NAN, NAN);
100 std::size_t i = n / 2;
101
102 if (isEven(n)) {
103 // For even number of observations use the middle one with the bigger distance from IP
104 Vector2D center1(getS(i), getZ(i));
105 Vector2D center2(getS(i - 1), getZ(i - 1));
106 return center1.normSquared() > center2.normSquared() ? center1 : center2;
107 } else {
108 Vector2D center1(getS(i), getZ(i));
109 return center1;
110 }
111}
double getZ(int iObservation) const
Getter for the z value of the observation at the given index.
std::size_t size() const
Returns the number of observations stored.
double getS(int iObservation) const
Getter for the arc length value of the observation at the given index.

◆ getS()

double getS ( int iObservation) const
inline

Getter for the arc length value of the observation at the given index.

Definition at line 79 of file CDCSZObservations.h.

80 {
81 return m_szObservations[iObservation * 3];
82 }

◆ getWeight()

double getWeight ( int iObservation) const
inline

Getter for the weight / inverse variance of the observation at the given index.

Definition at line 91 of file CDCSZObservations.h.

92 {
93 return m_szObservations[iObservation * 3 + 2];
94 }

◆ getZ()

double getZ ( int iObservation) const
inline

Getter for the z value of the observation at the given index.

Definition at line 85 of file CDCSZObservations.h.

86 {
87 return m_szObservations[iObservation * 3 + 1];
88 }

◆ passiveMoveBy()

void passiveMoveBy ( const TrackingUtilities::Vector2D & origin)

Moves all observations passively such that the given vector becomes to origin of the new coordinate system.

Definition at line 113 of file CDCSZObservations.cc.

114{
115 Eigen::Matrix<double, 1, 2> eigenOrigin(origin.x(), origin.y());
116 EigenObservationMatrix eigenObservations = getEigenObservationMatrix(this);
117 eigenObservations.leftCols<2>().rowwise() -= eigenOrigin;
118}

◆ reserve()

void reserve ( std::size_t nObservations)
inline

Reserves enough space for nObservations.

Definition at line 73 of file CDCSZObservations.h.

74 {
75 m_szObservations.reserve(nObservations * 3);
76 }

◆ setFitVariance()

void setFitVariance ( EFitVariance fitVariance)
inline

Setter for the indicator that the drift variance should be used.

Definition at line 141 of file CDCSZObservations.h.

142 {
143 m_fitVariance = fitVariance;
144 }

◆ size()

std::size_t size ( ) const
inline

Returns the number of observations stored.

Definition at line 49 of file CDCSZObservations.h.

50 {
51 return m_szObservations.size() / 3;
52 }

Member Data Documentation

◆ m_fitVariance

EFitVariance m_fitVariance
private

Indicator which variance information should preferably be extracted from hits in calls to append.

Meaning of the constants detailed in EFitVariance.

Definition at line 158 of file CDCSZObservations.h.

◆ m_onlyStereo

bool m_onlyStereo
private

Switch to only use information from stereo hits.

Definition at line 161 of file CDCSZObservations.h.

◆ m_szObservations

std::vector<double> m_szObservations
private

Memory for the individual observations.

Arrangement of values is s, z, weight, s, z, .....

Definition at line 151 of file CDCSZObservations.h.


The documentation for this class was generated from the following files: