SND@LHC Software
Loading...
Searching...
No Matches
gbl::GblData Class Reference

Data (block) for independent scalar measurement. More...

#include <GblData.h>

Public Member Functions

 GblData (unsigned int aLabel, double aMeas, double aPrec)
 Create data block.
 
virtual ~GblData ()
 
void addDerivatives (unsigned int iRow, const std::vector< unsigned int > &labDer, const SMatrix55 &matDer, unsigned int iOff, const TMatrixD &derLocal, const std::vector< int > &labGlobal, const TMatrixD &derGlobal, unsigned int nLocal, const TMatrixD &derTrans)
 Add derivatives from measurement.
 
void addDerivatives (unsigned int iRow, const std::vector< unsigned int > &labDer, const SMatrix27 &matDer, unsigned int nLocal, const TMatrixD &derTrans)
 Add derivatives from kink.
 
void addDerivatives (const std::vector< unsigned int > &index, const std::vector< double > &derivatives)
 Add derivatives from external seed.
 
void setPrediction (const VVector &aVector)
 Calculate prediction for data from fit (by GblTrajectory::fit).
 
double setDownWeighting (unsigned int aMethod)
 Outlier down weighting with M-estimators (by GblTrajectory::fit).
 
double getChi2 () const
 Calculate Chi2 contribution.
 
void printData () const
 Print data block.
 
void getLocalData (double &aValue, double &aWeight, std::vector< unsigned int > *&indLocal, std::vector< double > *&derLocal)
 Get Data for local fit.
 
void getAllData (double &aValue, double &aErr, std::vector< unsigned int > *&indLocal, std::vector< double > *&derLocal, std::vector< int > *&labGlobal, std::vector< double > *&derGlobal)
 Get all Data for MP-II binary record.
 
void getResidual (double &aResidual, double &aVariance, double &aDownWeight, std::vector< unsigned int > *&indLocal, std::vector< double > *&derLocal)
 Get data for residual (and errors).
 

Private Attributes

unsigned int theLabel
 Label (of measurements point)
 
double theValue
 Value (residual)
 
double thePrecision
 Precision (1/sigma**2)
 
double theDownWeight
 Down-weighting factor (0-1)
 
double thePrediction
 Prediction from fit.
 
std::vector< unsigned int > theParameters
 List of fit parameters (with non zero derivatives)
 
std::vector< double > theDerivatives
 List of derivatives for fit.
 
std::vector< int > globalLabels
 Labels for global derivatives.
 
std::vector< double > globalDerivatives
 Global derivatives.
 

Detailed Description

Data (block) for independent scalar measurement.

Data (block) containing value, precision and derivatives for measurements and kinks. Created from attributes of GblPoints, used to construct linear equation system for track fit.

Definition at line 33 of file GblData.h.

Constructor & Destructor Documentation

◆ GblData()

gbl::GblData::GblData ( unsigned int  aLabel,
double  aValue,
double  aPrec 
)

Create data block.

Parameters
[in]aLabelLabel of corresponding point
[in]aValueValue of (scalar) measurement
[in]aPrecPrecision of (scalar) measurement

Definition at line 19 of file GblData.cc.

19 :
20 theLabel(aLabel), theValue(aValue), thePrecision(aPrec), theDownWeight(
22
23}
double thePrecision
Precision (1/sigma**2)
Definition GblData.h:66
std::vector< int > globalLabels
Labels for global derivatives.
Definition GblData.h:71
double theDownWeight
Down-weighting factor (0-1)
Definition GblData.h:67
std::vector< double > theDerivatives
List of derivatives for fit.
Definition GblData.h:70
double thePrediction
Prediction from fit.
Definition GblData.h:68
std::vector< unsigned int > theParameters
List of fit parameters (with non zero derivatives)
Definition GblData.h:69
unsigned int theLabel
Label (of measurements point)
Definition GblData.h:64
double theValue
Value (residual)
Definition GblData.h:65
std::vector< double > globalDerivatives
Global derivatives.
Definition GblData.h:72

◆ ~GblData()

gbl::GblData::~GblData ( )
virtual

Definition at line 25 of file GblData.cc.

25 {
26}

Member Function Documentation

◆ addDerivatives() [1/3]

void gbl::GblData::addDerivatives ( const std::vector< unsigned int > &  index,
const std::vector< double > &  derivatives 
)

Add derivatives from external seed.

Add (non-zero) derivatives to data block. Fill list of labels of used fit parameters.

Parameters
[in]indexLabels for derivatives
[in]derivativesDerivatives (vector)

Definition at line 120 of file GblData.cc.

121 {
122 for (unsigned int i = 0; i < derivatives.size(); ++i) // any derivatives
123 {
124 if (derivatives[i]) {
125 theParameters.push_back(index[i]);
126 theDerivatives.push_back(derivatives[i]);
127 }
128 }
129}
int i
Definition ShipAna.py:86

◆ addDerivatives() [2/3]

void gbl::GblData::addDerivatives ( unsigned int  iRow,
const std::vector< unsigned int > &  labDer,
const SMatrix27 matDer,
unsigned int  extOff,
const TMatrixD &  extDer 
)

Add derivatives from kink.

Add (non-zero) derivatives to data block. Fill list of labels of used fit parameters.

Parameters
[in]iRowRow index (0-1) in 2D kink
[in]labDerLabels for derivatives
[in]matDerDerivatives (matrix) 'kink vs track fit parameters'
[in]extOffOffset for external parameters
[in]extDerDerivatives for external Parameters

Definition at line 89 of file GblData.cc.

91 {
92
93 unsigned int nParMax = 7 + extDer.GetNcols();
94 theParameters.reserve(nParMax); // have to be sorted
95 theDerivatives.reserve(nParMax);
96
97 for (int i = 0; i < extDer.GetNcols(); ++i) // external derivatives
98 {
99 if (extDer(iRow, i)) {
100 theParameters.push_back(extOff + i + 1);
101 theDerivatives.push_back(extDer(iRow, i));
102 }
103 }
104
105 for (unsigned int i = 0; i < 7; ++i) // curvature, offset derivatives
106 {
107 if (labDer[i] and matDer(iRow, i)) {
108 theParameters.push_back(labDer[i]);
109 theDerivatives.push_back(matDer(iRow, i));
110 }
111 }
112}

◆ addDerivatives() [3/3]

void gbl::GblData::addDerivatives ( unsigned int  iRow,
const std::vector< unsigned int > &  labDer,
const SMatrix55 matDer,
unsigned int  iOff,
const TMatrixD &  derLocal,
const std::vector< int > &  labGlobal,
const TMatrixD &  derGlobal,
unsigned int  extOff,
const TMatrixD &  extDer 
)

Add derivatives from measurement.

Add (non-zero) derivatives to data block. Fill list of labels of used fit parameters.

Parameters
[in]iRowRow index (0-4) in up to 5D measurement
[in]labDerLabels for derivatives
[in]matDerDerivatives (matrix) 'measurement vs track fit parameters'
[in]iOffOffset for row index for additional parameters
[in]derLocalDerivatives (matrix) for additional local parameters
[in]labGlobalLabels for additional global (MP-II) parameters
[in]derGlobalDerivatives (matrix) for additional global (MP-II) parameters
[in]extOffOffset for external parameters
[in]extDerDerivatives for external Parameters

Definition at line 41 of file GblData.cc.

45 {
46
47 unsigned int nParMax = 5 + derLocal.GetNcols() + extDer.GetNcols();
48 theParameters.reserve(nParMax); // have to be sorted
49 theDerivatives.reserve(nParMax);
50
51 for (int i = 0; i < derLocal.GetNcols(); ++i) // local derivatives
52 {
53 if (derLocal(iRow - iOff, i)) {
54 theParameters.push_back(i + 1);
55 theDerivatives.push_back(derLocal(iRow - iOff, i));
56 }
57 }
58
59 for (int i = 0; i < extDer.GetNcols(); ++i) // external derivatives
60 {
61 if (extDer(iRow - iOff, i)) {
62 theParameters.push_back(extOff + i + 1);
63 theDerivatives.push_back(extDer(iRow - iOff, i));
64 }
65 }
66
67 for (unsigned int i = 0; i < 5; ++i) // curvature, offset derivatives
68 {
69 if (labDer[i] and matDer(iRow, i)) {
70 theParameters.push_back(labDer[i]);
71 theDerivatives.push_back(matDer(iRow, i));
72 }
73 }
74
75 globalLabels = labGlobal;
76 for (int i = 0; i < derGlobal.GetNcols(); ++i) // global derivatives
77 globalDerivatives.push_back(derGlobal(iRow - iOff, i));
78}

◆ getAllData()

void gbl::GblData::getAllData ( double &  aValue,
double &  aErr,
std::vector< unsigned int > *&  indLocal,
std::vector< double > *&  derLocal,
std::vector< int > *&  labGlobal,
std::vector< double > *&  derGlobal 
)

Get all Data for MP-II binary record.

Parameters
[out]aValueValue
[out]aErrError
[out]indLocalList of labels of local parameters
[out]derLocalList of derivatives for local parameters
[out]labGlobalList of labels of global parameters
[out]derGlobalList of derivatives for global parameters

Definition at line 220 of file GblData.cc.

222 {
223 aValue = theValue;
224 aErr = 1.0 / sqrt(thePrecision);
225 indLocal = &theParameters;
226 derLocal = &theDerivatives;
227 labGlobal = &globalLabels;
228 derGlobal = &globalDerivatives;
229}

◆ getChi2()

double gbl::GblData::getChi2 ( ) const

Calculate Chi2 contribution.

Returns
(down-weighted) Chi2

Definition at line 173 of file GblData.cc.

173 {
174 double aDiff = theValue - thePrediction;
175 return aDiff * aDiff * thePrecision * theDownWeight;
176}

◆ getLocalData()

void gbl::GblData::getLocalData ( double &  aValue,
double &  aWeight,
std::vector< unsigned int > *&  indLocal,
std::vector< double > *&  derLocal 
)

Get Data for local fit.

Parameters
[out]aValueValue
[out]aWeightWeight
[out]indLocalList of labels of used (local) fit parameters
[out]derLocalList of derivatives for used (local) fit parameters

Definition at line 202 of file GblData.cc.

203 {
204
205 aValue = theValue;
206 aWeight = thePrecision * theDownWeight;
207 indLocal = &theParameters;
208 derLocal = &theDerivatives;
209}

◆ getResidual()

void gbl::GblData::getResidual ( double &  aResidual,
double &  aVariance,
double &  aDownWeight,
std::vector< unsigned int > *&  indLocal,
std::vector< double > *&  derLocal 
)

Get data for residual (and errors).

Parameters
[out]aResidualMeasurement-Prediction
[out]aVarianceVariance (of measurement)
[out]aDownWeightDown-weighting factor
[out]indLocalList of labels of used (local) fit parameters
[out]derLocalList of derivatives for used (local) fit parameters

Definition at line 239 of file GblData.cc.

241 {
242 aResidual = theValue - thePrediction;
243 aVariance = 1.0 / thePrecision;
244 aDownWeight = theDownWeight;
245 indLocal = &theParameters;
246 derLocal = &theDerivatives;
247}

◆ printData()

void gbl::GblData::printData ( ) const

Print data block.

Definition at line 179 of file GblData.cc.

179 {
180
181 std::cout << " measurement at label " << theLabel << ": " << theValue
182 << ", " << thePrecision << std::endl;
183 std::cout << " param " << theParameters.size() << ":";
184 for (unsigned int i = 0; i < theParameters.size(); ++i) {
185 std::cout << " " << theParameters[i];
186 }
187 std::cout << std::endl;
188 std::cout << " deriv " << theDerivatives.size() << ":";
189 for (unsigned int i = 0; i < theDerivatives.size(); ++i) {
190 std::cout << " " << theDerivatives[i];
191 }
192 std::cout << std::endl;
193}

◆ setDownWeighting()

double gbl::GblData::setDownWeighting ( unsigned int  aMethod)

Outlier down weighting with M-estimators (by GblTrajectory::fit).

Parameters
[in]aMethodM-estimator (1: Tukey, 2:Huber, 3:Cauchy)

Definition at line 144 of file GblData.cc.

144 {
145
146 double aWeight = 1.;
147 double scaledResidual = fabs(theValue - thePrediction) * sqrt(thePrecision);
148 if (aMethod == 1) // Tukey
149 {
150 if (scaledResidual < 4.6851) {
151 aWeight = (1.0 - 0.045558 * scaledResidual * scaledResidual);
152 aWeight *= aWeight;
153 } else {
154 aWeight = 0.;
155 }
156 } else if (aMethod == 2) //Huber
157 {
158 if (scaledResidual >= 1.345) {
159 aWeight = 1.345 / scaledResidual;
160 }
161 } else if (aMethod == 3) //Cauchy
162 {
163 aWeight = 1.0 / (1.0 + (scaledResidual * scaledResidual / 5.6877));
164 }
165 theDownWeight = aWeight;
166 return aWeight;
167}

◆ setPrediction()

void gbl::GblData::setPrediction ( const VVector aVector)

Calculate prediction for data from fit (by GblTrajectory::fit).

Definition at line 132 of file GblData.cc.

132 {
133
134 thePrediction = 0.;
135 for (unsigned int i = 0; i < theDerivatives.size(); ++i) {
136 thePrediction += theDerivatives[i] * aVector(theParameters[i] - 1);
137 }
138}

Member Data Documentation

◆ globalDerivatives

std::vector<double> gbl::GblData::globalDerivatives
private

Global derivatives.

Definition at line 72 of file GblData.h.

◆ globalLabels

std::vector<int> gbl::GblData::globalLabels
private

Labels for global derivatives.

Definition at line 71 of file GblData.h.

◆ theDerivatives

std::vector<double> gbl::GblData::theDerivatives
private

List of derivatives for fit.

Definition at line 70 of file GblData.h.

◆ theDownWeight

double gbl::GblData::theDownWeight
private

Down-weighting factor (0-1)

Definition at line 67 of file GblData.h.

◆ theLabel

unsigned int gbl::GblData::theLabel
private

Label (of measurements point)

Definition at line 64 of file GblData.h.

◆ theParameters

std::vector<unsigned int> gbl::GblData::theParameters
private

List of fit parameters (with non zero derivatives)

Definition at line 69 of file GblData.h.

◆ thePrecision

double gbl::GblData::thePrecision
private

Precision (1/sigma**2)

Definition at line 66 of file GblData.h.

◆ thePrediction

double gbl::GblData::thePrediction
private

Prediction from fit.

Definition at line 68 of file GblData.h.

◆ theValue

double gbl::GblData::theValue
private

Value (residual)

Definition at line 65 of file GblData.h.


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