CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InputSort.cc
Go to the documentation of this file.
4 
5 std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> >
6  InputSort::sort(std::vector<RefCountedKinematicParticle> particles) const
7 {
8  if(particles.size()==0) throw VertexException("Sorting particles for vertex fitter::number of particles = 0");
9  std::vector<RefCountedKinematicParticle> sortedParticles;
10  std::vector<FreeTrajectoryState> sortedStates;
11 
12 //checking that only top particles of the tree are passed by user
13 //correcting them for the top ones otherwise
14  for(std::vector<RefCountedKinematicParticle>::const_iterator i = particles.begin(); i != particles.end(); i++)
15  {
16  if((*i)->correspondingTree() != 0)
17  {
18  sortedParticles.push_back((*i)->correspondingTree()->topParticle());
19  sortedStates.push_back((*i)->correspondingTree()->topParticle()->currentState().freeTrajectoryState());
20  }else{
21  sortedParticles.push_back(*i);
22  sortedStates.push_back((*i)->currentState().freeTrajectoryState());
23  }
24  }
25  return std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> >(sortedParticles, sortedStates);
26 }
27 
28 std::vector<RefCountedKinematicParticle> InputSort::sort(std::vector<RefCountedKinematicTree> trees) const
29 {
30  if(trees.size() ==0) throw VertexException("Input Sort::Zero vector of trees passed");
31  std::vector<RefCountedKinematicParticle> res;
32  for(std::vector<RefCountedKinematicTree>::const_iterator i = trees.begin(); i!=trees.end(); i++)
33  {
34  (*i)->movePointerToTheTop();
35  res.push_back((*i)->currentParticle());
36  }
37  return res;
38 }
int i
Definition: DBlmapReader.cc:9
std::pair< std::vector< RefCountedKinematicParticle >, std::vector< FreeTrajectoryState > > sort(std::vector< RefCountedKinematicParticle > particles) const
Definition: InputSort.cc:6
Common base class.