Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:03

0001 // $Id: AddFourMomenta.cc,v 1.2 2009/09/29 12:24:45 llista Exp $

0002 #include "CommonTools/CandUtils/interface/AddFourMomenta.h"
0003 #include "DataFormats/Candidate/interface/Candidate.h"
0004 using namespace reco;
0005 
0006 void AddFourMomenta::set(Candidate &c) const {
0007   Candidate::LorentzVector p4(0, 0, 0, 0);
0008   Candidate::Charge charge = 0;
0009   size_t n = c.numberOfDaughters();
0010   for (size_t i = 0; i < n; ++i) {
0011     const Candidate *d = (const_cast<const Candidate &>(c)).daughter(i);
0012     p4 += d->p4();
0013     charge += d->charge();
0014   }
0015   c.setP4(p4);
0016   c.setCharge(charge);
0017 }