// -*- C++ -*- #include "Rivet/Analysis.hh" #include "Rivet/Projections/FinalState.hh" /// @todo Include more projections as required, e.g. ChargedFinalState, FastJets, ZFinder... namespace Rivet { class MC_STATUS3TEST : public Analysis { class StatusThreeParticles : public ParticleFinder { public: StatusThreeParticles(const Cut& c=Cuts::open()) { setName("StatusThreeParticles"); const bool open = ( c == Cuts::open() ); if (!open) addProjection(StatusThreeParticles(), "OpenStatusThreeParticles"); } virtual const Projection* clone() const { return new StatusThreeParticles(*this); } virtual void project(const Event& e) { _theParticles.clear(); if ( _cuts == Cuts::open() ) { foreach (const GenParticle* p, Rivet::particles(e.genEvent())) { if (p->status() == 3) _theParticles.push_back(Particle(*p)); } return; } const Particles allstable = applyProjection(e, "OpenStatusThreeParticles").particles(); foreach (const Particle& p, allstable) { const bool passed = accept(p); if (passed) _theParticles.push_back(p); } } virtual int compare(const Projection& p) const { const StatusThreeParticles& other = dynamic_cast(p); return _cuts == other._cuts ? EQUIVALENT : UNDEFINED; } virtual bool accept(const Particle& p) const { assert(p.genParticle() == NULL || p.genParticle()->status() == 3); return _cuts->accept(p); } }; public: /// Constructor MC_STATUS3TEST() : Analysis("MC_STATUS3TEST") { } /// @name Analysis methods //@{ /// Book histograms and initialise projections before the run void init() { /// @todo Initialise and register projections here addProjection(StatusThreeParticles(), "status3"); /// @todo Book histograms here, e.g.: // _h_XXXX = bookProfile1D(1, 1, 1); // _h_YYYY = bookHisto1D(2, 1, 1); } /// Perform the per-event analysis void analyze(const Event& event) { const double weight = event.weight(); /// @todo Do the event by event analysis here } /// 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 /// @name Histograms //@{ Profile1DPtr _h_XXXX; Histo1DPtr _h_YYYY; //@} }; // The hook for the plugin system DECLARE_RIVET_PLUGIN(MC_STATUS3TEST); }