rivet is hosted by Hepforge, IPPP Durham
OPAL_1994_S2927284.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetYODA.hh"
00004 #include "Rivet/Tools/ParticleIdUtils.hh"
00005 #include "Rivet/Projections/Beam.hh"
00006 #include "Rivet/Projections/ChargedFinalState.hh"
00007 
00008 namespace Rivet {
00009 
00010 
00011   /// @brief OPAL charged particle fragmentation functions
00012   /// @author Peter Richardson
00013   class OPAL_1994_S2927284 : public Analysis {
00014   public:
00015 
00016     /// Constructor
00017     OPAL_1994_S2927284() : Analysis("OPAL_1994_S2927284")
00018     {}
00019 
00020 
00021     /// @name Analysis methods
00022     //@{
00023 
00024     void analyze(const Event& e) {
00025       // First, veto on leptonic events by requiring at least 4 charged FS particles
00026       const FinalState& fs = applyProjection<FinalState>(e, "FS");
00027 
00028       // Even if we only generate hadronic events, we still need a cut on numCharged >= 2.
00029       if (fs.particles().size() < 2) {
00030         MSG_DEBUG("Failed ncharged cut");
00031         vetoEvent;
00032       }
00033       MSG_DEBUG("Passed ncharged cut");
00034       // Get event weight for histo filling
00035       const double weight = e.weight();
00036 
00037       // Get beams and average beam momentum
00038       const ParticlePair& beams = applyProjection<Beam>(e, "Beams").beams();
00039       const double meanBeamMom = ( beams.first.momentum().vector3().mod() +
00040                                    beams.second.momentum().vector3().mod() ) / 2.0;
00041       MSG_DEBUG("Avg beam momentum = " << meanBeamMom);
00042 
00043       foreach (const Particle& p, fs.particles()) {
00044         int id = abs(p.pdgId());
00045         // charged pions
00046         if(id==PIPLUS) {
00047           _histXpPiPlus->fill(p.momentum().vector3().mod(), weight);
00048         }
00049         else if(id==KPLUS) {
00050           _histXpKPlus->fill(p.momentum().vector3().mod(), weight);
00051         }
00052         else if(id==PROTON) {
00053           _histXpProton->fill(p.momentum().vector3().mod(), weight);
00054         }
00055       }
00056     }
00057 
00058 
00059     void init() {
00060       // Projections
00061       addProjection(Beam(), "Beams");
00062       addProjection(ChargedFinalState(), "FS");
00063 
00064       _histXpPiPlus = bookHisto1D( 1, 1, 1);
00065       _histXpKPlus  = bookHisto1D( 2, 1, 1);
00066       _histXpProton = bookHisto1D( 3, 1, 1);
00067     }
00068 
00069 
00070     /// Finalize
00071     void finalize() {
00072       scale(_histXpPiPlus,1./sumOfWeights());
00073       scale(_histXpKPlus ,1./sumOfWeights());
00074       scale(_histXpProton,1./sumOfWeights());
00075     }
00076 
00077     //@}
00078 
00079   private:
00080 
00081     Histo1DPtr _histXpPiPlus;
00082     Histo1DPtr _histXpKPlus;
00083     Histo1DPtr _histXpProton;
00084     //@}
00085 
00086   };
00087 
00088   // The hook for the plugin system
00089   DECLARE_RIVET_PLUGIN(OPAL_1994_S2927284);
00090 
00091 }