CMS 3D CMS Logo

cloneDecayTree.cc

Go to the documentation of this file.
00001 #include "PhysicsTools/CandUtils/interface/cloneDecayTree.h"
00002 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00003 using namespace std;
00004 using namespace reco;
00005 
00006 auto_ptr<Candidate> cloneDecayTree(const Candidate & c) {
00007   size_t n = c.numberOfDaughters();
00008   if (n == 1) return auto_ptr<Candidate>(c.clone());
00009   // pass a particle, not a candidate, to avoid cloning daughters 
00010   const Particle &p = c;
00011   CompositeCandidate * cmp(new CompositeCandidate(p));
00012   auto_ptr<Candidate> cmpPtr(cmp);
00013   for(size_t i = 0; i < n; ++ i)
00014     cmp->addDaughter(cloneDecayTree(* c.daughter(i)));
00015   return cmpPtr;
00016 }

Generated on Tue Jun 9 17:41:04 2009 for CMSSW by  doxygen 1.5.4