CMS 3D CMS Logo

KinematicParticleVertexFitter.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFit/interface/KinematicParticleVertexFitter.h"
00002 // #include "Vertex/LinearizationPointFinders/interface/LMSLinearizationPointFinder.h"
00003 #include "RecoVertex/KinematicFit/interface/FinalTreeBuilder.h"
00004 #include "RecoVertex/VertexTools/interface/SequentialVertexSmoother.h"
00005 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexUpdator.h"
00006 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexTrackUpdator.h"
00007 #include "RecoVertex/KalmanVertexFit/interface/KalmanSmoothedVertexChi2Estimator.h"
00008 #include "RecoVertex/KalmanVertexFit/interface/KalmanTrackToTrackCovCalculator.h"
00009 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00010 #include "RecoVertex/LinearizationPointFinders/interface/DefaultLinearizationPointFinder.h"
00011 #include "RecoVertex/VertexTools/interface/SequentialVertexFitter.h"
00012 #include "DataFormats/CLHEP/interface/Migration.h"
00013 
00014 KinematicParticleVertexFitter::KinematicParticleVertexFitter()
00015 { 
00016 
00017   pointFinder =  new DefaultLinearizationPointFinder();
00018   vFactory = new VertexTrackFactory<6>();
00019 
00020   KalmanVertexTrackUpdator<6> vtu;
00021   KalmanSmoothedVertexChi2Estimator<6> vse;
00022   KalmanTrackToTrackCovCalculator<6> covCalc;
00023   SequentialVertexSmoother<6> smoother(vtu, vse, covCalc);
00024   edm::ParameterSet pSet;
00025   pSet.addParameter<double>("maxDistance", 0.01);
00026   pSet.addParameter<int>("maxNbrOfIterations", 10); //10
00027   fitter 
00028     = new SequentialVertexFitter<6>(pSet, *pointFinder, KalmanVertexUpdator<6>(),
00029                                  smoother, ParticleKinematicLinearizedTrackStateFactory());
00030 }
00031 
00032 KinematicParticleVertexFitter::~KinematicParticleVertexFitter()
00033 {
00034  delete vFactory;
00035  delete pointFinder;
00036  delete fitter;
00037 }
00038  
00039 RefCountedKinematicTree KinematicParticleVertexFitter::fit(vector<RefCountedKinematicParticle> particles) const
00040 {
00041  typedef ReferenceCountingPointer<VertexTrack<6> > RefCountedVertexTrack;
00042 //sorting the input 
00043  if(particles.size()<2) throw VertexException("KinematicParticleVertexFitter::input states are less than 2"); 
00044  InputSort iSort;
00045  pair<vector<RefCountedKinematicParticle>, vector<FreeTrajectoryState> > input = iSort.sort(particles);
00046  vector<RefCountedKinematicParticle> & newPart = input.first;
00047  vector<FreeTrajectoryState> & freeStates = input.second;
00048 
00049  GlobalPoint linPoint = pointFinder->getLinearizationPoint(freeStates);
00050   
00051 // cout<<"Linearization point found"<<endl; 
00052  
00053 //making initial veretx seed with lin point as position and a fake error
00054  AlgebraicSymMatrix33 we;
00055  we(0,0)=we(1,1)=we(2,2) = 10000.;
00056  GlobalError error(we);
00057  VertexState state(linPoint, error);
00058  
00059 //vector of Vertex Tracks to fit
00060  vector<RefCountedVertexTrack> ttf; 
00061  for(vector<RefCountedKinematicParticle>::const_iterator i = newPart.begin();i != newPart.end();i++)
00062  {ttf.push_back(vFactory->vertexTrack((*i)->particleLinearizedTrackState(linPoint),state,1.));}
00063 
00064 // //debugging code to check neutrals: 
00065 //  for(vector<RefCountedVertexTrack>::const_iterator i = ttf.begin(); i!=ttf.end(); i++)
00066 //  {
00067 // //   cout<<"predicted state momentum error"<<(*i)->linearizedTrack()->predictedStateMomentumError()<<endl;
00068 // //  cout<<"Momentum jacobian"<<(*i)->linearizedTrack()->momentumJacobian() <<endl;
00069 //  //  cout<<"predicted state momentum "<<(*i)->linearizedTrack()->predictedStateMomentum()<<endl;
00070 // //   cout<<"constant term"<<(*i)->linearizedTrack()->constantTerm()<<endl;
00071 // 
00072 //  }
00073 
00074  CachingVertex<6> vtx = fitter->vertex(ttf); 
00075 
00076  FinalTreeBuilder tBuilder;
00077  return tBuilder.buildTree(vtx, newPart); 
00078 }

Generated on Tue Jun 9 17:46:09 2009 for CMSSW by  doxygen 1.5.4