CMS 3D CMS Logo

CandCommonVertexFitter.h

Go to the documentation of this file.
00001 #ifndef RecoCandUtils_CandCommonVertexFitter_h
00002 #define RecoCandUtils_CandCommonVertexFitter_h
00003 /* \class CandCommonVertexFitter
00004  *
00005  * \author Luca Lista, INFN
00006  *
00007  */
00008 
00009 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
00010 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00011 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00012 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00013 #include <vector>
00014 class MagneticField;
00015 namespace reco { class VertexCompositeCandidate; }
00016 
00017 class CandCommonVertexFitterBase {
00018 public:
00019   typedef reco::Vertex::CovarianceMatrix CovarianceMatrix;
00020   CandCommonVertexFitterBase(const edm::ParameterSet &) : bField_(0) { }
00021   virtual ~CandCommonVertexFitterBase() { }
00022   void set(const MagneticField * bField) { bField_ = bField; }
00023   void set(reco::VertexCompositeCandidate &) const;
00024   
00025 protected:
00026   const MagneticField * bField_;
00027   void fill(std::vector<reco::TransientTrack> &, 
00028             std::vector<reco::Candidate *> &,
00029             std::vector<reco::RecoCandidate::TrackType> &,
00030             reco::Candidate &) const;
00031   virtual bool fit(TransientVertex &, 
00032                    const std::vector<reco::TransientTrack> &) const = 0;
00034   mutable double chi2_;
00036   mutable double ndof_;
00038   mutable CovarianceMatrix cov_;
00039 };
00040 
00041 #include "PhysicsTools/UtilAlgos/interface/ParameterAdapter.h"
00042 
00043 template<typename Fitter>
00044 class CandCommonVertexFitter : public CandCommonVertexFitterBase {
00045 public:
00046   CandCommonVertexFitter(const edm::ParameterSet & cfg) : 
00047     CandCommonVertexFitterBase(cfg),
00048     fitter_(reco::modules::make<Fitter>(cfg)) { 
00049   }
00050   bool fit(TransientVertex & vertex, 
00051            const std::vector<reco::TransientTrack> & tracks) const {
00052     try {
00053       vertex = fitter_.vertex(tracks);
00054     } catch (std::exception & err) {
00055       std::cerr << ">>> exception thrown by KalmanVertexFitter:\n"
00056                 << err.what() << "\n"
00057                 << ">>> candidate not fitted to common vertex" << std::endl;
00058       return false;
00059     }
00060     return vertex.isValid();
00061   }
00062 private:
00063   Fitter fitter_;
00064 };
00065 
00066 #endif

Generated on Tue Jun 9 17:41:50 2009 for CMSSW by  doxygen 1.5.4