CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CommonTools/CandUtils/src/AddFourMomenta.cc

Go to the documentation of this file.
00001 // $Id: AddFourMomenta.cc,v 1.3 2009/10/01 09:14:52 llista Exp $
00002 #include "CommonTools/CandUtils/interface/AddFourMomenta.h"
00003 #include "DataFormats/Candidate/interface/Candidate.h"
00004 using namespace reco;
00005 
00006 void AddFourMomenta::set( Candidate & c ) const {
00007   Candidate::LorentzVector p4( 0, 0, 0, 0 );
00008   Candidate::Charge charge = 0;
00009   size_t n = c.numberOfDaughters();
00010   for(size_t i = 0; i < n; ++i) {
00011     const Candidate * d = (const_cast<const Candidate &>(c)).daughter(i);
00012     p4 += d->p4();
00013     charge += d->charge();
00014   }
00015   c.setP4( p4 );
00016   c.setCharge( charge );
00017 }