rivet is hosted by Hepforge, IPPP Durham
SLD_2002_S4869273.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/FinalState.hh"
00007 #include "Rivet/Projections/ChargedFinalState.hh"
00008 
00009 
00010 /// @todo Use inline PID functions instead
00011 #define IS_PARTON_PDGID(id) ( abs(id) <= 100 && abs(id) != 22 && (abs(id) < 11 || abs(id) > 18) )
00012 #define IS_BHADRON_PDGID(id) ( ((abs(id)/100)%10 == 5) || (abs(id) >= 5000 && abs(id) <= 5999) )
00013 
00014 namespace Rivet {
00015 
00016 
00017   /// @brief SLD b-fragmentation measurement
00018   /// @author Peter Richardson
00019   class SLD_2002_S4869273 : public Analysis {
00020   public:
00021 
00022     /// Constructor
00023     SLD_2002_S4869273()
00024       : Analysis("SLD_2002_S4869273")
00025     {
00026     }
00027 
00028 
00029     /// @name Analysis methods
00030     //@{
00031 
00032     /// Book projections and histograms
00033     void init() {
00034       addProjection(Beam(), "Beams");
00035       addProjection(ChargedFinalState(), "FS");
00036 
00037       _histXbweak     = bookHisto1D(1, 1, 1);
00038     }
00039 
00040 
00041     void analyze(const Event& e) {
00042       const FinalState& fs = applyProjection<FinalState>(e, "FS");
00043       const size_t numParticles = fs.particles().size();
00044 
00045       // Even if we only generate hadronic events, we still need a cut on numCharged >= 2.
00046       if (numParticles < 2) {
00047         MSG_DEBUG("Failed ncharged cut");
00048         vetoEvent;
00049       }
00050       MSG_DEBUG("Passed ncharged cut");
00051 
00052       // Get event weight for histo filling
00053       const double weight = e.weight();
00054 
00055       // Get beams and average beam momentum
00056       const ParticlePair& beams = applyProjection<Beam>(e, "Beams").beams();
00057       const double meanBeamMom = ( beams.first.momentum().vector3().mod() +
00058                                    beams.second.momentum().vector3().mod() ) / 2.0;
00059       MSG_DEBUG("Avg beam momentum = " << meanBeamMom);
00060 
00061 
00062       foreach (const GenParticle* p, particles(e.genEvent())) {
00063         const GenVertex* dv = p->end_vertex();
00064         if (IS_BHADRON_PDGID(p->pdg_id())) {
00065           const double xp = p->momentum().e()/meanBeamMom;
00066 
00067           // If the B-hadron has no B-hadron as a child, it decayed weakly:
00068           if (dv) {
00069             bool is_weak = true;
00070             for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin() ;
00071                  pp != dv->particles_out_const_end() ; ++pp) {
00072               if (IS_BHADRON_PDGID((*pp)->pdg_id())) {
00073                 is_weak = false;
00074               }
00075             }
00076             if (is_weak) {
00077               _histXbweak->fill(xp, weight);
00078             }
00079           }
00080 
00081         }
00082       }
00083     }
00084 
00085 
00086     // Finalize
00087     void finalize() {
00088       normalize(_histXbweak);
00089     }
00090 
00091 
00092   private:
00093 
00094     /// Store the weighted sums of numbers of charged / charged+neutral
00095     /// particles - used to calculate average number of particles for the
00096     /// inclusive single particle distributions' normalisations.
00097 
00098     Histo1DPtr _histXbweak;
00099 
00100     //@}
00101 
00102   };
00103 
00104 
00105 
00106   // The hook for the plugin system
00107   DECLARE_RIVET_PLUGIN(SLD_2002_S4869273);
00108 
00109 }