Go to the documentation of this file.00001 #include "RecoVertex/KinematicFit/interface/KinematicParticleVertexFitter.h"
00002
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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014
00015 KinematicParticleVertexFitter::KinematicParticleVertexFitter()
00016 {
00017 edm::ParameterSet pSet = defaultParameters();
00018 setup(pSet);
00019 }
00020
00021 KinematicParticleVertexFitter::KinematicParticleVertexFitter(const edm::ParameterSet &pSet)
00022 {
00023 setup(pSet);
00024 }
00025
00026 void
00027 KinematicParticleVertexFitter::setup(const edm::ParameterSet &pSet)
00028 {
00029
00030 pointFinder = new DefaultLinearizationPointFinder();
00031 vFactory = new VertexTrackFactory<6>();
00032
00033 KalmanVertexTrackUpdator<6> vtu;
00034 KalmanSmoothedVertexChi2Estimator<6> vse;
00035 KalmanTrackToTrackCovCalculator<6> covCalc;
00036 SequentialVertexSmoother<6> smoother(vtu, vse, covCalc);
00037 fitter
00038 = new SequentialVertexFitter<6>(pSet, *pointFinder, KalmanVertexUpdator<6>(),
00039 smoother, ParticleKinematicLinearizedTrackStateFactory());
00040 }
00041
00042 KinematicParticleVertexFitter::~KinematicParticleVertexFitter()
00043 {
00044 delete vFactory;
00045 delete pointFinder;
00046 delete fitter;
00047 }
00048
00049 edm::ParameterSet KinematicParticleVertexFitter::defaultParameters() const
00050 {
00051 edm::ParameterSet pSet;
00052 pSet.addParameter<double>("maxDistance", 0.01);
00053 pSet.addParameter<int>("maxNbrOfIterations", 100);
00054 return pSet;
00055 }
00056
00057 RefCountedKinematicTree KinematicParticleVertexFitter::fit(const std::vector<RefCountedKinematicParticle> &particles) const
00058 {
00059 typedef ReferenceCountingPointer<VertexTrack<6> > RefCountedVertexTrack;
00060
00061 if(particles.size()<2) throw VertexException("KinematicParticleVertexFitter::input states are less than 2");
00062 InputSort iSort;
00063 std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> > input = iSort.sort(particles);
00064 std::vector<RefCountedKinematicParticle> & newPart = input.first;
00065 std::vector<FreeTrajectoryState> & freeStates = input.second;
00066
00067 GlobalPoint linPoint = pointFinder->getLinearizationPoint(freeStates);
00068
00069
00070
00071
00072 AlgebraicSymMatrix33 we;
00073 we(0,0)=we(1,1)=we(2,2) = 10000.;
00074 GlobalError error(we);
00075 VertexState state(linPoint, error);
00076
00077
00078 std::vector<RefCountedVertexTrack> ttf;
00079 TrackKinematicStatePropagator propagator_;
00080 for(std::vector<RefCountedKinematicParticle>::const_iterator i = newPart.begin();i != newPart.end();i++){
00081 if( !(*i)->currentState().isValid() || !propagator_.propagateToTheTransversePCA((*i)->currentState(), linPoint).isValid() ) {
00082
00083 return ReferenceCountingPointer<KinematicTree>(new KinematicTree());
00084 }
00085 ttf.push_back(vFactory->vertexTrack((*i)->particleLinearizedTrackState(linPoint),state,1.));
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 CachingVertex<6> vtx = fitter->vertex(ttf);
00099 if (!vtx.isValid()) {
00100 LogDebug("RecoVertex/KinematicParticleVertexFitter")
00101 << "Fitted position is invalid. Returned Tree is invalid\n";
00102 return ReferenceCountingPointer<KinematicTree>(new KinematicTree());
00103 }
00104 FinalTreeBuilder tBuilder;
00105 return tBuilder.buildTree(vtx, newPart);
00106 }