Helper class which calculates the posterior weights of a Gaussian mixture given a prior (predicted) mixture and a RecHit. The prior is specified during construction time in the form of a vector of trajectory states.
Definition at line 13 of file PosteriorWeightsCalculator.h.
template<unsigned int D>
std::vector< double > PosteriorWeightsCalculator::weights |
( |
const TrackingRecHit & |
tsos | ) |
const |
Definition at line 23 of file PosteriorWeightsCalculator.cc.
References vertices_cff::chi2, muonBadTrackFilter_cfi::chi2Min, JetChargeProducer_cfi::exp, TrackingRecHit::getKfComponents(), mps_fire::i, invertPosDefMatrix(), LogDebug, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, predictedComponents, dttmaxenums::R, alignCSCRings::r, mathSSE::sqrt(), w, weights(), and x.
28 using ROOT::Math::SMatrixNoInit;
32 edm::LogError(
"EmptyPredictedComponents")<<
"a multi state is empty. cannot compute any weight.";
37 std::vector<double> detRs;
39 std::vector<double> chi2s;
43 SMatDD V(SMatrixNoInit{}),
R(SMatrixNoInit{});
54 holder.template setup<D>(&
r, &V, &
p, &rMeas, &
R,
56 recHit.getKfComponents(holder);
62 if (! R.Det2(detR) ) {
63 edm::LogError(
"PosteriorWeightsCalculator") <<
"PosteriorWeightsCalculator: determinant failed";
64 return std::vector<double>();
66 detRs.push_back(detR);
71 <<
"PosteriorWeightsCalculator: inversion failed";
72 return std::vector<double>();
74 double chi2 = ROOT::Math::Similarity(r,R);
75 chi2s.push_back(chi2);
81 edm::LogError(
"PosteriorWeightsCalculator") <<
"Problem in vector sizes";
82 return std::vector<double>();
90 double sumWeights(0.);
96 double tempWeight(0.);
97 if ( detRs[
i]>FLT_MIN ) {
105 LogDebug(
"GsfTrackFitters") <<
"PosteriorWeightsCalculator: detR < FLT_MIN !!";
107 weights.push_back(tempWeight);
108 sumWeights += tempWeight;
111 if ( sumWeights<DBL_MIN ) {
112 LogDebug(
"GsfTrackFitters") <<
"PosteriorWeightsCalculator: sumWeight < DBL_MIN";
113 edm::LogError(
"PosteriorWeightsCalculator") <<
"PosteriorWeightsCalculator: sumWeight < DBL_MIN";
114 return std::vector<double>();
118 edm::LogError(
"PosteriorWeightsCalculator") <<
"Problem in vector sizes (2)";
119 return std::vector<double>();
121 sumWeights = 1./sumWeights;
122 for (
auto &
w : weights)
w *= sumWeights;
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
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, D1 > Vector