CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoVertex/KinematicFit/src/InputSort.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFit/interface/InputSort.h"
00002 #include "RecoVertex/KinematicFitPrimitives/interface/KinematicTree.h"
00003 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00004 
00005 std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> > 
00006                     InputSort::sort(std::vector<RefCountedKinematicParticle> particles) const
00007 {
00008  if(particles.size()==0) throw VertexException("Sorting particles for vertex fitter::number of particles = 0");
00009  std::vector<RefCountedKinematicParticle> sortedParticles;
00010  std::vector<FreeTrajectoryState> sortedStates;
00011 
00012 //checking that only top particles of the tree are passed by user
00013 //correcting them for the top ones otherwise 
00014  for(std::vector<RefCountedKinematicParticle>::const_iterator i = particles.begin(); i != particles.end(); i++)
00015  {
00016   if((*i)->correspondingTree() != 0)
00017   {
00018    sortedParticles.push_back((*i)->correspondingTree()->topParticle());
00019    sortedStates.push_back((*i)->correspondingTree()->topParticle()->currentState().freeTrajectoryState());
00020   }else{
00021    sortedParticles.push_back(*i);
00022    sortedStates.push_back((*i)->currentState().freeTrajectoryState());
00023   }
00024  }
00025  return std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> >(sortedParticles, sortedStates);
00026 }
00027 
00028 std::vector<RefCountedKinematicParticle> InputSort::sort(std::vector<RefCountedKinematicTree> trees) const
00029 {
00030  if(trees.size() ==0) throw VertexException("Input Sort::Zero vector of trees passed"); 
00031  std::vector<RefCountedKinematicParticle> res;
00032  for(std::vector<RefCountedKinematicTree>::const_iterator i = trees.begin(); i!=trees.end(); i++)
00033  {
00034   (*i)->movePointerToTheTop();
00035   res.push_back((*i)->currentParticle());
00036  }
00037  return res;
00038 }