rivet is hosted by Hepforge, IPPP Durham
ALEPH_2001_S4656318.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 DELPHI b-fragmentation measurement
00016   /// @author Hendrik Hoeth
00017   class ALEPH_2001_S4656318 : public Analysis {
00018   public:
00019 
00020     /// Constructor
00021    ALEPH_2001_S4656318()
00022       : Analysis("ALEPH_2001_S4656318")
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       _histXbweak     = bookHisto1D(8, 1, 1);
00035       _histXbprim     = bookHisto1D(8, 1, 2);
00036       _histMeanXbweak = bookProfile1D(6, 1, 1);
00037       _histMeanXbprim = bookProfile1D(7, 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* pv = p->production_vertex();
00064         const GenVertex* dv = p->end_vertex();
00065         if (IS_BHADRON_PDGID(p->pdg_id())) {
00066           const double xp = p->momentum().e()/meanBeamMom;
00067 
00068           // If the B-hadron has a parton as parent, call it primary B-hadron:
00069           if (pv) {
00070             bool is_primary = false;
00071             for (GenVertex::particles_in_const_iterator pp = pv->particles_in_const_begin(); pp != pv->particles_in_const_end() ; ++pp) {
00072               if (IS_PARTON_PDGID((*pp)->pdg_id())) is_primary = true;
00073             }
00074             if (is_primary) {
00075               _histXbprim->fill(xp, weight);
00076               _histMeanXbprim->fill(_histMeanXbprim->bin(0).midpoint(), xp, weight);
00077             }
00078           }
00079 
00080           // If the B-hadron has no B-hadron as a child, it decayed weakly:
00081           if (dv) {
00082             bool is_weak = true;
00083             for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin() ;
00084                  pp != dv->particles_out_const_end() ; ++pp) {
00085               if (IS_BHADRON_PDGID((*pp)->pdg_id())) {
00086                 is_weak = false;
00087               }
00088             }
00089             if (is_weak) {
00090               _histXbweak->fill(xp, weight);
00091               _histMeanXbweak->fill(_histMeanXbweak->bin(0).midpoint(), xp, weight);
00092             }
00093           }
00094 
00095         }
00096       }
00097     }
00098 
00099 
00100     // Finalize
00101     void finalize() {
00102       normalize(_histXbprim);
00103       normalize(_histXbweak);
00104     }
00105 
00106 
00107   private:
00108 
00109     /// Store the weighted sums of numbers of charged / charged+neutral
00110     /// particles - used to calculate average number of particles for the
00111     /// inclusive single particle distributions' normalisations.
00112 
00113     Histo1DPtr _histXbprim;
00114     Histo1DPtr _histXbweak;
00115 
00116     Profile1DPtr _histMeanXbprim;
00117     Profile1DPtr _histMeanXbweak;
00118 
00119     //@}
00120 
00121   };
00122 
00123 
00124 
00125   // The hook for the plugin system
00126   DECLARE_RIVET_PLUGIN(ALEPH_2001_S4656318);
00127 
00128 }