CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SequentialGhostTrackFitter.cc
Go to the documentation of this file.
1 #include <vector>
2 
5 
7 
8 using namespace reco;
9 
10 namespace {
11  inline double sqr(double arg) { return arg * arg; }
12 } // namespace
13 
15  : maxIteration(15), minDeltaR(0.0015), minDistance(0.002), weightThreshold(0.001) {}
16 
18  return (sqr(after.sz() - before.sz()) + sqr(after.ip() - before.ip()) < sqr(minDistance) &&
19  sqr(after.eta() - before.eta()) + sqr(after.phi() - before.phi()) < sqr(minDeltaR));
20 }
21 
24  std::vector<GhostTrackState> &states,
25  double &ndof,
26  double &chi2) {
27  GhostTrackPrediction pred, lastPred = prior;
28 
29  reset();
30 
31  ndof = 0.;
32  chi2 = 0.;
33 
34  unsigned int iteration = 0;
35  for (;;) {
36  pred = prior;
37 
38  if (states.begin() == states.end())
39  break;
40 
41  if (iteration > 0) {
42  for (unsigned int i = 0; i < states.size(); i++) {
43  GhostTrackState &state = states[i];
44  state.linearize(lastPred);
45  }
46  }
47 
48  ndof = 0.; // prior gives us an initial ndof
49  chi2 = 0.;
50 
51  for (std::vector<GhostTrackState>::const_iterator state = states.begin(); state != states.end(); ++state) {
52  if (state->isValid() && state->weight() > weightThreshold)
53  pred = updater.update(pred, *state, ndof, chi2);
54  }
55 
56  if (++iteration >= maxIteration || stable(lastPred, pred))
57  break;
58 
59  postFit(updater, pred, states);
60 
61  lastPred = pred;
62  }
63 
64  return pred;
65 }
virtual bool stable(const GhostTrackPrediction &before, const GhostTrackPrediction &after) const
int sqr(const T &t)
A arg
Definition: Factorize.h:31
GhostTrackPrediction fit(const GhostTrackFitter::PredictionUpdater &updater, const GhostTrackPrediction &prior, std::vector< GhostTrackState > &states, double &ndof, double &chi2) override
tuple iteration
Definition: align_cfg.py:5
virtual void postFit(const GhostTrackFitter::PredictionUpdater &updater, const GhostTrackPrediction &pred, std::vector< GhostTrackState > &states)
virtual GhostTrackPrediction update(const GhostTrackPrediction &pred, const GhostTrackState &state, double &ndof, double &chi2) const =0
bool linearize(const GhostTrackPrediction &pred, bool initial=false, double lambda=0.)
dictionary prior