CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

CandKinematicVertexFitter Class Reference

#include <CandKinematicVertexFitter.h>

List of all members.

Public Types

typedef
reco::Vertex::CovarianceMatrix 
CovarianceMatrix

Public Member Functions

 CandKinematicVertexFitter (const edm::ParameterSet &cfg)
 CandKinematicVertexFitter (const CandKinematicVertexFitter &o)
RefCountedKinematicParticle currentParticle () const
bool fit (const std::vector< RefCountedKinematicParticle > &tracks) const
void set (const ParticleDataTable *pdt)
void set (const MagneticField *bField)
void set (reco::VertexCompositeCandidate &) const

Private Member Functions

void fill (std::vector< RefCountedKinematicParticle > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const

Private Attributes

const MagneticFieldbField_
double chi2_
 chi-sqared
CovarianceMatrix cov_
 covariance matrix (3x3)
KinematicParticleFactoryFromTransientTrack factory_
 particle factor
KinematicParticleVertexFitter fitter_
 fitter
boost::shared_ptr< std::vector
< CandKinematicVertexFitter > > 
fitters_
 fitters used for recursive calls
double ndof_
 number of degrees of freedom
const ParticleDataTablepdt_
RefCountedKinematicTree tree_
 fit tree

Detailed Description

Definition at line 23 of file CandKinematicVertexFitter.h.


Member Typedef Documentation

Definition at line 25 of file CandKinematicVertexFitter.h.


Constructor & Destructor Documentation

CandKinematicVertexFitter::CandKinematicVertexFitter ( const edm::ParameterSet cfg) [inline]

Definition at line 26 of file CandKinematicVertexFitter.h.

                                                         :  
    bField_(0), pdt_(0), fitter_(), fitters_(new std::vector<CandKinematicVertexFitter>) { 
  }
CandKinematicVertexFitter::CandKinematicVertexFitter ( const CandKinematicVertexFitter o) [inline]

Definition at line 29 of file CandKinematicVertexFitter.h.

                                                                :
    bField_(o.bField_), pdt_(o.pdt_), fitter_(), fitters_(new std::vector<CandKinematicVertexFitter>) {
  }

Member Function Documentation

RefCountedKinematicParticle CandKinematicVertexFitter::currentParticle ( ) const [inline]

Definition at line 36 of file CandKinematicVertexFitter.h.

References tree_.

                                                      {
    tree_->movePointerToTheTop();
    return tree_->currentParticle();
  }
void CandKinematicVertexFitter::fill ( std::vector< RefCountedKinematicParticle > &  ,
std::vector< reco::Candidate * > &  ,
std::vector< reco::RecoCandidate::TrackType > &  ,
reco::Candidate  
) const [private]
bool CandKinematicVertexFitter::fit ( const std::vector< RefCountedKinematicParticle > &  tracks) const
void CandKinematicVertexFitter::set ( const ParticleDataTable pdt) [inline]

Definition at line 33 of file CandKinematicVertexFitter.h.

References pdt_.

{ pdt_ = pdt; }
void CandKinematicVertexFitter::set ( reco::VertexCompositeCandidate c) const

Definition at line 31 of file CandKinematicVertexFitter.cc.

References GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::cyx(), GlobalErrorBase< T, ErrorWeightType >::cyy(), GlobalErrorBase< T, ErrorWeightType >::czx(), GlobalErrorBase< T, ErrorWeightType >::czy(), GlobalErrorBase< T, ErrorWeightType >::czz(), reco::Candidate::energy(), relval_parameters_module::energy, Exception, lumiContext::fill, reco::RecoCandidate::gsfTrackType, edm::errors::InvalidReference, reco::Candidate::longLived(), PV3DBase< T, PVType, FrameType >::mag(), AlCaHLTBitMon_ParallelJobs::p, p3, pileupReCalc_HLTpaths::scale, reco::VertexCompositeCandidate::setChi2AndNdof(), reco::VertexCompositeCandidate::setCovariance(), reco::LeafCandidate::setP4(), reco::Candidate::setP4(), reco::LeafCandidate::setVertex(), reco::Candidate::setVertex(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                      {
  if(bField_ == 0)
    throw edm::Exception(edm::errors::InvalidReference)
      << "B-Field was not set up CandKinematicVertexFitter.\n"
      << "the following method must be called before fitting a candidate:\n"
      << " CandKinematicVertexFitter:.set( const MagneticField * )" << endl;
  vector<RefCountedKinematicParticle> particles;
  vector<Candidate *> daughters;
  vector<RecoCandidate::TrackType> trackTypes;
  // fill particles with KinematicParticles and daughters with Candidates of the daughters of c
  fill(particles, daughters, trackTypes, c);
  assert(particles.size() == daughters.size());

  // attempt to fit the KinematicParticles, particles  
  if(fit(particles)) {
    // after the fit, tree_ contains the KinematicTree from the fit
    tree_->movePointerToTheTop();
    // set the kinematic properties of the daughters from the fit
    RefCountedKinematicVertex vertex = tree_->currentDecayVertex();
    if(vertex->vertexIsValid()) {
      Candidate::Point vtx(vertex->position());
      c.setVertex(vtx);
      vector<RefCountedKinematicParticle> treeParticles = tree_->daughterParticles();
      vector<RefCountedKinematicParticle>::const_iterator particleIt = treeParticles.begin();
      vector<Candidate *>::const_iterator daughterIt = daughters.begin(), daughtersEnd = daughters.end();
      vector<RecoCandidate::TrackType>::const_iterator trackTypeIt = trackTypes.begin();
      Candidate::LorentzVector mp4(0, 0, 0, 0);
      for(; daughterIt != daughtersEnd; ++ particleIt, ++ daughterIt, ++trackTypeIt) {
        Candidate & daughter = * * daughterIt;
        GlobalVector p3 = (*particleIt)->currentState().globalMomentum();
        double px = p3.x(), py = p3.y(), pz = p3.z(), p = p3.mag();
        double energy;

        if(!daughter.longLived()) daughter.setVertex(vtx);
        double scale;
        switch(*trackTypeIt) {
        case RecoCandidate::gsfTrackType :
          //gsf used for electron tracks
          energy = daughter.energy();
          scale = energy / p;
          px *= scale; py *= scale; pz *= scale; 
        default:
          double mass = (*particleIt)->currentState().mass();
          energy = sqrt(p*p + mass*mass);
        };
        Candidate::LorentzVector dp4(px, py, pz, energy);
        daughter.setP4(dp4);
        mp4 += dp4;
      }
      c.setP4(mp4);
      c.setChi2AndNdof(chi2_ = vertex->chiSquared(), ndof_ = vertex->degreesOfFreedom());
      GlobalError err = vertex->error();
      cov_(0,0) = err.cxx();
      cov_(0,1) = err.cyx();
      cov_(0,2) = err.czx();
      cov_(1,2) = err.czy();
      cov_(1,1) = err.cyy();
      cov_(2,2) = err.czz();
      c.setCovariance(cov_);
    }
  } else {
    c.setChi2AndNdof(chi2_ = -1, ndof_ = 0);
    c.setCovariance(cov_ = CovarianceMatrix(ROOT::Math::SMatrixIdentity())); 
  }
}
void CandKinematicVertexFitter::set ( const MagneticField bField) [inline]

Member Data Documentation

Definition at line 41 of file CandKinematicVertexFitter.h.

Referenced by set().

double CandKinematicVertexFitter::chi2_ [mutable, private]

chi-sqared

Definition at line 54 of file CandKinematicVertexFitter.h.

covariance matrix (3x3)

Definition at line 58 of file CandKinematicVertexFitter.h.

particle factor

Definition at line 52 of file CandKinematicVertexFitter.h.

fitter

Definition at line 48 of file CandKinematicVertexFitter.h.

boost::shared_ptr<std::vector<CandKinematicVertexFitter> > CandKinematicVertexFitter::fitters_ [private]

fitters used for recursive calls

Definition at line 60 of file CandKinematicVertexFitter.h.

double CandKinematicVertexFitter::ndof_ [mutable, private]

number of degrees of freedom

Definition at line 56 of file CandKinematicVertexFitter.h.

Definition at line 42 of file CandKinematicVertexFitter.h.

Referenced by set().

fit tree

Definition at line 50 of file CandKinematicVertexFitter.h.

Referenced by currentParticle().