|
[Rivet-svn] rivet: 2 new changesetsRivet Mercurial rivet at projects.hepforge.orgThu Jul 20 15:30:05 BST 2017
details: https://rivet.hepforge.org/hg/rivet/rev/b593b27adbe6 branches: changeset: 5962:b593b27adbe6 user: Andy Buckley <andy at insectnation.org> date: Thu Jul 20 14:46:40 2017 +0100 description: Eliminate foreach from projections code details: https://rivet.hepforge.org/hg/rivet/rev/f9e3d607cc5b branches: changeset: 5963:f9e3d607cc5b user: Andy Buckley <andy at insectnation.org> date: Thu Jul 20 14:47:51 2017 +0100 description: Eliminate PDG code #define diffs (truncated from 621 to 50 lines): --- a/src/Projections/BeamThrust.cc Thu Jul 20 14:33:30 2017 +0100 +++ b/src/Projections/BeamThrust.cc Thu Jul 20 14:47:51 2017 +0100 @@ -14,7 +14,7 @@ void BeamThrust::calc(const vector<Particle>& fsparticles) { vector<FourMomentum> fsmomenta; fsmomenta.reserve(fsparticles.size()); - foreach (const Particle& p, fsparticles) { + for (const Particle& p : fsparticles) { const FourMomentum p4 = p.momentum(); fsmomenta.push_back(p4); } @@ -30,7 +30,7 @@ // Do the full calculation void BeamThrust::_calcBeamThrust(const vector<FourMomentum>& fsmomenta) { _beamthrust = 0.; - foreach (const FourMomentum& p, fsmomenta) { + for (const FourMomentum& p : fsmomenta) { _beamthrust += p.E() - fabs(p.z()); } } --- a/src/Projections/CentralEtHCM.cc Thu Jul 20 14:33:30 2017 +0100 +++ b/src/Projections/CentralEtHCM.cc Thu Jul 20 14:47:51 2017 +0100 @@ -7,7 +7,7 @@ void CentralEtHCM::project(const Event& e) { const DISFinalState& fs = applyProjection<DISFinalState>(e, "FS"); _sumet = 0.0; - foreach (const Particle& p, fs.particles()) { + for (const Particle& p : fs.particles()) { /// @todo Generalise rapidity cut value if (fabs(p.rapidity()) < 0.5) _sumet += p.Et(); } --- a/src/Projections/ChargedLeptons.cc Thu Jul 20 14:33:30 2017 +0100 +++ b/src/Projections/ChargedLeptons.cc Thu Jul 20 14:47:51 2017 +0100 @@ -15,12 +15,11 @@ // Loop over charged particles and fill vector with leptons const FinalState& fs = applyProjection<FinalState>(evt, "ChFS"); - foreach (const Particle& p, fs.particles()) { - if (PID::isChargedLepton(p.pid())) { + for (const Particle& p : fs.particles()) { + if (PID::isChargedLepton(p.pid())) _theParticles += Particle(p); - } } - std::sort(_theParticles.begin(), _theParticles.end(), cmpMomByPt); + sortBy(_theParticles, cmpMomByPt); } --- a/src/Projections/FParameter.cc Thu Jul 20 14:33:30 2017 +0100
More information about the Rivet-svn mailing list |