// -*- C++ -*- #include "Rivet/Analysis.hh" #include "Rivet/RivetAIDA.hh" #include "Rivet/Tools/Logging.hh" #include "Rivet/Projections/FinalState.hh" #include "Rivet/Projections/FastJets.hh" #include "HepMC/GenEvent.h" #include "Rivet/Particle.hh" /// @todo Include more projections as required, e.g. ChargedFinalState, FastJets, ZFinder... namespace Rivet { class TEST_GENPARTICLE : public Analysis { public: /// @name Constructors etc. //@{ /// Constructor TEST_GENPARTICLE() : Analysis("TEST_GENPARTICLE") { } //@} public: /// @name Analysis methods //@{ /// Book histograms and initialise projections before the run void init() { /// @todo Initialise and register projections here const FinalState fs(-4.5, 4.5); addProjection(fs, "ALL_FS"); // Get the jets FastJets jets(fs, FastJets::ANTIKT, 0.4); addProjection(jets, "JETS"); } /// Perform the per-event analysis void analyze(const Event& event) { const double weight = event.weight(); /// @todo Do the event by event analysis here const Jets& jets = applyProjection(event, "JETS").jetsByPt(25.0*GeV, MAXDOUBLE, -2.5, 2.5); if(jets.size() < 1) return; vector constituents = jets.at(0).particles(); HepMC::GenParticle constituent_g = constituents.at(0).genParticle(); int constituent_g_barcode = constituent_g.barcode(); MSG_INFO("GenParticle from Jet::particles() :"); constituent_g.print(); HepMC::GenEvent evt = event.genEvent(); for (HepMC::GenEvent::particle_const_iterator p = evt.particles_begin(); p != evt.particles_end(); ++p) { int p_bcode = (*p)->barcode(); if(p_bcode != constituent_g_barcode) continue; MSG_INFO("GenParticle directly from GenEvent:"); (*p)->print(); } } /// Normalise histograms etc., after the run void finalize() { /// @todo Normalise, scale and otherwise manipulate histograms here // scale(_h_YYYY, crossSection()/sumOfWeights()); # norm to cross section // normalize(_h_YYYY); # normalize to unity } //@} private: // Data members like post-cuts event weight counters go here }; // The hook for the plugin system DECLARE_RIVET_PLUGIN(TEST_GENPARTICLE); }