Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:11

0001 #include "RecoVertex/KinematicFit/interface/InputSort.h"
0002 #include "RecoVertex/KinematicFitPrimitives/interface/KinematicTree.h"
0003 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
0004 
0005 std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> > InputSort::sort(
0006     const std::vector<RefCountedKinematicParticle> &particles) const {
0007   if (particles.empty())
0008     throw VertexException("Sorting particles for vertex fitter::number of particles = 0");
0009   std::vector<RefCountedKinematicParticle> sortedParticles;
0010   std::vector<FreeTrajectoryState> sortedStates;
0011 
0012   //checking that only top particles of the tree are passed by user
0013   //correcting them for the top ones otherwise
0014   for (std::vector<RefCountedKinematicParticle>::const_iterator i = particles.begin(); i != particles.end(); i++) {
0015     if ((*i)->correspondingTree() != nullptr) {
0016       sortedParticles.push_back((*i)->correspondingTree()->topParticle());
0017       sortedStates.push_back((*i)->correspondingTree()->topParticle()->currentState().freeTrajectoryState());
0018     } else {
0019       sortedParticles.push_back(*i);
0020       sortedStates.push_back((*i)->currentState().freeTrajectoryState());
0021     }
0022   }
0023   return std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> >(sortedParticles,
0024                                                                                                 sortedStates);
0025 }
0026 
0027 std::vector<RefCountedKinematicParticle> InputSort::sort(const std::vector<RefCountedKinematicTree> &trees) const {
0028   if (trees.empty())
0029     throw VertexException("Input Sort::Zero vector of trees passed");
0030   std::vector<RefCountedKinematicParticle> res;
0031   for (std::vector<RefCountedKinematicTree>::const_iterator i = trees.begin(); i != trees.end(); i++) {
0032     (*i)->movePointerToTheTop();
0033     res.push_back((*i)->currentParticle());
0034   }
0035   return res;
0036 }