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