Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:55

0001 #ifndef DataFormats_Candidate_VertexCompositeCandidate_H
0002 #define DataFormats_Candidate_VertexCompositeCandidate_H
0003 /** \class reco::VertexCompositeCandidate
0004  *
0005  * A composite Candidate  with error
0006  * matrix and other vertex fix information. 
0007  *
0008  * \author Luca Lista, INFN
0009  *
0010  *
0011  */
0012 #include "DataFormats/Candidate/interface/VertexCompositeCandidateFwd.h"
0013 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
0014 
0015 namespace reco {
0016   class VertexCompositeCandidate : public CompositeCandidate {
0017   public:
0018     VertexCompositeCandidate() : CompositeCandidate() {}
0019     /// constructor from values
0020     VertexCompositeCandidate(
0021         Charge q, const LorentzVector &p4, const Point &vtx, int pdgId = 0, int status = 0, bool integerCharge = true)
0022         : CompositeCandidate(q, p4, vtx, pdgId, status, integerCharge), chi2_(0), ndof_(0) {}
0023     /// constructor from values
0024     VertexCompositeCandidate(Charge q,
0025                              const LorentzVector &p4,
0026                              const Point &vtx,
0027                              const CovarianceMatrix &err,
0028                              double chi2,
0029                              double ndof,
0030                              int pdgId = 0,
0031                              int status = 0,
0032                              bool integerCharge = true);
0033     /// constructor from values
0034     explicit VertexCompositeCandidate(const Candidate &p) : CompositeCandidate(p), chi2_(0), ndof_(0) {}
0035     /// constructor from values
0036     explicit VertexCompositeCandidate(const CompositeCandidate &p) : CompositeCandidate(p), chi2_(0), ndof_(0) {}
0037     /// destructor
0038     ~VertexCompositeCandidate() override;
0039     /// returns a clone of the candidate
0040     VertexCompositeCandidate *clone() const override;
0041     /// chi-squares
0042     double vertexChi2() const override { return chi2_; }
0043     /** Number of degrees of freedom
0044      *  Meant to be Double32_t for soft-assignment fitters: 
0045      *  tracks may contribute to the vertex with fractional weights.
0046      *  The ndof is then = to the sum of the track weights.
0047      *  see e.g. CMS NOTE-2006/032, CMS NOTE-2004/002
0048      */
0049     double vertexNdof() const override { return ndof_; }
0050     /// chi-squared divided by n.d.o.f.
0051     double vertexNormalizedChi2() const override { return chi2_ / ndof_; }
0052     /// (i, j)-th element of error matrix, i, j = 0, ... 2
0053     double vertexCovariance(int i, int j) const override { return covariance_[idx(i, j)]; }
0054     using reco::LeafCandidate::vertexCovariance;  // avoid hiding the
0055     /// fill SMatrix
0056     void fillVertexCovariance(CovarianceMatrix &v) const override;
0057     /// set chi2 and ndof
0058     void setChi2AndNdof(double chi2, double ndof) {
0059       chi2_ = chi2;
0060       ndof_ = ndof;
0061     }
0062     /// set covariance matrix
0063     void setCovariance(const CovarianceMatrix &m);
0064 
0065   private:
0066     /// chi-sqared
0067     Double32_t chi2_;
0068     /// number of degrees of freedom
0069     Double32_t ndof_;
0070     /// covariance matrix (3x3) as vector
0071     Double32_t covariance_[size];
0072     /// position index
0073     index idx(index i, index j) const {
0074       int a = (i <= j ? i : j), b = (i <= j ? j : i);
0075       return b * (b + 1) / 2 + a;
0076     }
0077   };
0078 
0079 }  // namespace reco
0080 
0081 #endif