11 case 1:
return weights<1>(recHit);
12 case 2:
return weights<2>(recHit);
13 case 3:
return weights<3>(recHit);
14 case 4:
return weights<4>(recHit);
15 case 5:
return weights<5>(recHit);
20 template<
unsigned int D>
26 using ROOT::Math::SMatrixNoInit;
30 edm::LogError(
"EmptyPredictedComponents")<<
"a multi state is empty. cannot compute any weight.";
35 std::vector<double> detRs;
37 std::vector<double> chi2s;
41 SMatDD V(SMatrixNoInit{}),
R(SMatrixNoInit{});
48 double chi2Min(DBL_MAX);
53 holder.template setup<D>(&
r, &V, &
p, &rMeas, &
R,
61 if (! R.Det2(detR) ) {
62 edm::LogError(
"PosteriorWeightsCalculator") <<
"PosteriorWeightsCalculator: determinant failed";
63 return std::vector<double>();
65 detRs.push_back(detR);
67 int ierr = ! R.Invert();
70 <<
"PosteriorWeightsCalculator: inversion failed, ierr = " << ierr;
71 return std::vector<double>();
73 double chi2 = ROOT::Math::Similarity(r,R);
74 chi2s.push_back(chi2);
75 if ( chi2<chi2Min ) chi2Min = chi2;
79 edm::LogError(
"PosteriorWeightsCalculator") <<
"Problem in vector sizes";
80 return std::vector<double>();
87 double sumWeights(0.);
91 double chi2 = chi2s[
i] - chi2Min;
93 double tempWeight(0.);
94 if ( detRs[
i]>FLT_MIN ) {
99 tempWeight = priorWeight *
sqrt(1./detRs[
i]) *
exp(-0.5 * chi2);
104 weights.push_back(tempWeight);
105 sumWeights += tempWeight;
107 if ( sumWeights<DBL_MIN ) {
108 edm::LogInfo(
"PosteriorWeightsCalculator") <<
"PosteriorWeightsCalculator: sumWeight < DBL_MIN";
109 edm::LogError(
"PosteriorWeightsCalculator") <<
"PosteriorWeightsCalculator: sumWeight < DBL_MIN";
110 return std::vector<double>();
114 edm::LogError(
"PosteriorWeightsCalculator") <<
"Problem in vector sizes (2)";
115 return std::vector<double>();
117 for (std::vector<double>::iterator iter = weights.begin();
118 iter != weights.end(); iter++) {
119 (*iter) /= sumWeights;
virtual int dimension() const =0
virtual void getKfComponents(KfComponentsHolder &holder) const
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
std::vector< double > weights(const TrackingRecHit &tsos) const
Create random state.
std::vector< TSOS > predictedComponents
ROOT::Math::SMatrix< double, D1, D2, ROOT::Math::MatRepStd< double, D1, D2 > > Matrix
ROOT::Math::SVector< double, D1 > Vector
ROOT::Math::SVector< double, 5 > AlgebraicVector5