CMS 3D CMS Logo

PFCandCommonVertexFitter.h

Go to the documentation of this file.
00001 #ifndef TauTagTools_PFCandCommonVertexFitter_h
00002 #define TauTagTools_PFCandCommonVertexFitter_h
00003 
00004 /* \class PFCandCommonVertexFitter
00005  *
00006  * Adapted from PhysicsTools/RecoUtils for use with ShallowClones of PFCandidates, which
00007  * have a different method for retrieving the associated transient track
00008  *
00009  * \author Luca Lista, INFN
00010  * Modified by Evan Friis, UC Davis
00011  *
00012  */
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
00015 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00016 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00017 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00019 #include <vector>
00020 class MagneticField;
00021 namespace reco { class VertexCompositeCandidate; }
00022 
00023 class PFCandCommonVertexFitterBase {
00024 public:
00025   typedef reco::Vertex::CovarianceMatrix CovarianceMatrix;
00026   PFCandCommonVertexFitterBase(const edm::ParameterSet &) : bField_(0) { }
00027   virtual ~PFCandCommonVertexFitterBase() { }
00028   void set(const MagneticField * bField) { bField_ = bField; }
00029   void set(reco::VertexCompositeCandidate &) const;
00030   
00031 protected:
00032   const MagneticField * bField_;
00033   void fill(std::vector<reco::TransientTrack> &, 
00034             std::vector<reco::Candidate *> &,
00035             std::vector<reco::RecoCandidate::TrackType> &,
00036             reco::Candidate &) const;
00037   virtual bool fit(TransientVertex &, 
00038                    const std::vector<reco::TransientTrack> &) const = 0;
00040   mutable double chi2_;
00042   mutable double ndof_;
00044   mutable CovarianceMatrix cov_;
00045 };
00046 
00047 #include "PhysicsTools/UtilAlgos/interface/ParameterAdapter.h"
00048 
00049 template<typename Fitter>
00050 class PFCandCommonVertexFitter : public PFCandCommonVertexFitterBase {
00051 public:
00052   PFCandCommonVertexFitter(const edm::ParameterSet & cfg) : 
00053     PFCandCommonVertexFitterBase(cfg),
00054 //    fitter_(reco::modules::make<Fitter>(cfg)) { 
00055     fitter_(Fitter(cfg, true)) { 
00056   }
00057   bool fit(TransientVertex & vertex, 
00058            const std::vector<reco::TransientTrack> & tracks) const {
00059     try {
00060       vertex = fitter_.vertex(tracks);
00061     } catch (std::exception & err) {
00062       std::cerr << ">>> exception thrown by KalmanVertexFitter:\n"
00063                 << err.what() << "\n"
00064                 << ">>> candidate not fitted to common vertex" << std::endl;
00065       return false;
00066     }
00067     return vertex.isValid();
00068   }
00069 private:
00070   Fitter fitter_;
00071 };
00072 
00073 #endif

Generated on Tue Jun 9 17:45:05 2009 for CMSSW by  doxygen 1.5.4