CMS 3D CMS Logo

AdaptiveChisquarePrimaryVertexFitter.h
Go to the documentation of this file.
1 #ifndef RecoVertex_PrimaryVertexProducer_AdaptiveChisquarePrimaryVertexFitter_h
2 #define RecoVertex_PrimaryVertexProducer_AdaptiveChisquarePrimaryVertexFitter_h
3 
9 #include <vector>
10 
14 
16 public:
17  AdaptiveChisquarePrimaryVertexFitter(double chicutoff = 2.5,
18  double zcutoff = 1.0,
19  double mintrkweight = 0.4,
20  bool multivertexfit = false);
21  ~AdaptiveChisquarePrimaryVertexFitter() override = default;
22 
23  std::vector<TransientVertex> fit(const std::vector<reco::TransientTrack> &,
24  const std::vector<TransientVertex> &,
25  const reco::BeamSpot &,
26  const bool) override;
27 
28  using Error3 = ROOT::Math::SMatrix<double, 3>;
29 
30 protected:
31  void verify() { // DEBUG only
32  unsigned int nt = trackinfo_.size();
33  unsigned int nv = xv_.size();
34  assert((yv_.size() == nv) && "yv size");
35  assert((zv_.size() == nv) && "zv size");
36  assert((tkfirstv_.size() == (nv + 1)) && "tkfirstv size");
37  assert((tkmap_.size() == tkweight_.size()) && "tkmapsize <> tkweightssize");
38  for (unsigned int k = 0; k < nv; k++) {
39  assert((tkfirstv_[k] < tkweight_.size()) && "tkfirst[k]");
40  assert((tkfirstv_[k + 1] <= tkweight_.size()) && "tkfirst[k+1]");
41  assert((tkfirstv_[k] <= tkfirstv_[k + 1]) && "tkfirst[k/k+1]");
42  for (unsigned int j = tkfirstv_[k]; j < tkfirstv_[k + 1]; k++) {
43  assert((j < tkmap_.size()) && "illegal tkfirst entry");
44  unsigned int i = tkmap_[j];
45  assert((i < nt) && "illegal tkmap entry");
46  assert((tkweight_[i] >= 0) && "negative tkweight or nan");
47  assert((tkweight_[i] <= 1) && "tkweight > 1 or nan");
48  }
49  }
50  };
51 
52  struct TrackInfo {
53  double S11, S22, S12; // inverse of the covariance (sub-)matrix
54  Error3 C; // H^T S H
55  double g[3];
56  double H1[3], H2[3];
57  double b1, b2;
58  double zpca, dzError;
59  };
60 
61  std::vector<TransientVertex> vertices(const std::vector<reco::TransientTrack> &,
62  const std::vector<TransientVertex> &,
63  const reco::BeamSpot &,
64  const bool);
65  TransientVertex refit(const TransientVertex &, const reco::BeamSpot &, const bool);
66  double track_in_vertex_chsq(const TrackInfo &, const double, const double, const double);
67  void fill_trackinfo(const std::vector<reco::TransientTrack> &, const reco::BeamSpot &);
68  void fill_weights(const reco::BeamSpot &, const double beta = 1.);
69  TransientVertex get_TransientVertex(const unsigned int,
70  const std::vector<std::pair<unsigned int, float>> &,
71  const std::vector<reco::TransientTrack> &,
72  const float,
73  const reco::BeamSpot &);
75  double update(const reco::BeamSpot &, float beam_weight, const bool fill_covariances = false);
76  void make_vtx_trk_map(const double);
77  bool clean();
78  void remove_vertex(unsigned int);
79 
80  // track information
81  std::vector<TrackInfo> trackinfo_;
82 
83  // vertex lists:
84  std::vector<double> xv_;
85  std::vector<double> yv_;
86  std::vector<double> zv_;
87  std::vector<Error3> covv_;
88  // track-vertex-mapping and weights after a coarse z-cut:
89  std::vector<unsigned int> tkfirstv_; // parallel to the vertex list
90  std::vector<unsigned int> tkmap_; // parallel to tkweight
91  std::vector<double> tkweight_; // parallel to tkmap
92  // configuration
93  double chi_cutoff_;
94  double z_cutoff_;
97 };
98 #endif
void fill_weights(const reco::BeamSpot &, const double beta=1.)
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &, const std::vector< TransientVertex > &, const reco::BeamSpot &, const bool)
assert(be >=bs)
std::vector< TransientVertex > fit(const std::vector< reco::TransientTrack > &, const std::vector< TransientVertex > &, const reco::BeamSpot &, const bool) override
void fill_trackinfo(const std::vector< reco::TransientTrack > &, const reco::BeamSpot &)
int nt
Definition: AMPTWrapper.h:42
double update(const reco::BeamSpot &, float beam_weight, const bool fill_covariances=false)
TransientVertex get_TransientVertex(const unsigned int, const std::vector< std::pair< unsigned int, float >> &, const std::vector< reco::TransientTrack > &, const float, const reco::BeamSpot &)
~AdaptiveChisquarePrimaryVertexFitter() override=default
TransientVertex refit(const TransientVertex &, const reco::BeamSpot &, const bool)
double track_in_vertex_chsq(const TrackInfo &, const double, const double, const double)
AdaptiveChisquarePrimaryVertexFitter(double chicutoff=2.5, double zcutoff=1.0, double mintrkweight=0.4, bool multivertexfit=false)