rivet is hosted by Hepforge, IPPP Durham
OPAL_1998_S3780481.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 #include "Rivet/Projections/InitialQuarks.hh"
00009 
00010 namespace Rivet {
00011 
00012 
00013   /// @brief OPAL flavour-dependent fragmentation paper
00014   /// @author Hendrik Hoeth
00015   class OPAL_1998_S3780481 : public Analysis {
00016   public:
00017 
00018     /// Constructor
00019     OPAL_1998_S3780481() : Analysis("OPAL_1998_S3780481")
00020     {
00021 
00022       // Counters
00023       _weightedTotalPartNum = 0;
00024       _SumOfudsWeights = 0;
00025       _SumOfcWeights = 0;
00026       _SumOfbWeights = 0;
00027     }
00028 
00029 
00030     /// @name Analysis methods
00031     //@{
00032 
00033     void analyze(const Event& e) {
00034       // First, veto on leptonic events by requiring at least 4 charged FS particles
00035       const FinalState& fs = applyProjection<FinalState>(e, "FS");
00036       const size_t numParticles = fs.particles().size();
00037 
00038       // Even if we only generate hadronic events, we still need a cut on numCharged >= 2.
00039       if (numParticles < 2) {
00040         MSG_DEBUG("Failed ncharged cut");
00041         vetoEvent;
00042       }
00043       MSG_DEBUG("Passed ncharged cut");
00044 
00045       // Get event weight for histo filling
00046       const double weight = e.weight();
00047       _weightedTotalPartNum += numParticles * weight;
00048 
00049       // Get beams and average beam momentum
00050       const ParticlePair& beams = applyProjection<Beam>(e, "Beams").beams();
00051       const double meanBeamMom = ( beams.first.momentum().vector3().mod() +
00052                                    beams.second.momentum().vector3().mod() ) / 2.0;
00053       MSG_DEBUG("Avg beam momentum = " << meanBeamMom);
00054 
00055       int flavour = 0;
00056       const InitialQuarks& iqf = applyProjection<InitialQuarks>(e, "IQF");
00057 
00058       // If we only have two quarks (qqbar), just take the flavour.
00059       // If we have more than two quarks, look for the highest energetic q-qbar pair.
00060       if (iqf.particles().size() == 2) {
00061         flavour = abs( iqf.particles().front().pdgId() );
00062       }
00063       else {
00064         map<int, double> quarkmap;
00065         foreach (const Particle& p, iqf.particles()) {
00066           if (quarkmap[p.pdgId()] < p.momentum().E()) {
00067             quarkmap[p.pdgId()] = p.momentum().E();
00068           }
00069         }
00070         double maxenergy = 0.;
00071         for (int i = 1; i <= 5; ++i) {
00072           if (quarkmap[i]+quarkmap[-i] > maxenergy) {
00073             flavour = i;
00074           }
00075         }
00076       }
00077 
00078       switch (flavour) {
00079       case 1:
00080       case 2:
00081       case 3:
00082         _SumOfudsWeights += weight;
00083         break;
00084       case 4:
00085         _SumOfcWeights += weight;
00086         break;
00087       case 5:
00088         _SumOfbWeights += weight;
00089         break;
00090       }
00091 
00092       foreach (const Particle& p, fs.particles()) {
00093         const double xp = p.momentum().vector3().mod()/meanBeamMom;
00094         const double logxp = -std::log(xp);
00095         _histXpall->fill(xp, weight);
00096         _histLogXpall->fill(logxp, weight);
00097         _histMultiChargedall->fill(_histMultiChargedall->bin(0).xMean(), weight);
00098         switch (flavour) {
00099           /// @todo Use PDG code enums
00100         case DQUARK:
00101         case UQUARK:
00102         case SQUARK:
00103           _histXpuds->fill(xp, weight);
00104           _histLogXpuds->fill(logxp, weight);
00105           _histMultiChargeduds->fill(_histMultiChargeduds->bin(0).xMean(), weight);
00106           break;
00107         case CQUARK:
00108           _histXpc->fill(xp, weight);
00109           _histLogXpc->fill(logxp, weight);
00110           _histMultiChargedc->fill(_histMultiChargedc->bin(0).xMean(), weight);
00111           break;
00112         case BQUARK:
00113           _histXpb->fill(xp, weight);
00114           _histLogXpb->fill(logxp, weight);
00115           _histMultiChargedb->fill(_histMultiChargedb->bin(0).xMean(), weight);
00116           break;
00117         }
00118       }
00119 
00120     }
00121 
00122 
00123     void init() {
00124       // Projections
00125       addProjection(Beam(), "Beams");
00126       addProjection(ChargedFinalState(), "FS");
00127       addProjection(InitialQuarks(), "IQF");
00128 
00129       // Book histos
00130       _histXpuds           = bookHisto1D(1, 1, 1);
00131       _histXpc             = bookHisto1D(2, 1, 1);
00132       _histXpb             = bookHisto1D(3, 1, 1);
00133       _histXpall           = bookHisto1D(4, 1, 1);
00134       _histLogXpuds        = bookHisto1D(5, 1, 1);
00135       _histLogXpc          = bookHisto1D(6, 1, 1);
00136       _histLogXpb          = bookHisto1D(7, 1, 1);
00137       _histLogXpall        = bookHisto1D(8, 1, 1);
00138       _histMultiChargeduds = bookHisto1D(9, 1, 1);
00139       _histMultiChargedc   = bookHisto1D(9, 1, 2);
00140       _histMultiChargedb   = bookHisto1D(9, 1, 3);
00141       _histMultiChargedall = bookHisto1D(9, 1, 4);
00142     }
00143 
00144 
00145     /// Finalize
00146     void finalize() {
00147       const double avgNumParts = _weightedTotalPartNum / sumOfWeights();
00148       normalize(_histXpuds    , avgNumParts);
00149       normalize(_histXpc      , avgNumParts);
00150       normalize(_histXpb      , avgNumParts);
00151       normalize(_histXpall    , avgNumParts);
00152       normalize(_histLogXpuds , avgNumParts);
00153       normalize(_histLogXpc   , avgNumParts);
00154       normalize(_histLogXpb   , avgNumParts);
00155       normalize(_histLogXpall , avgNumParts);
00156 
00157       scale(_histMultiChargeduds, 1.0/_SumOfudsWeights);
00158       scale(_histMultiChargedc  , 1.0/_SumOfcWeights);
00159       scale(_histMultiChargedb  , 1.0/_SumOfbWeights);
00160       scale(_histMultiChargedall, 1.0/sumOfWeights());
00161     }
00162 
00163     //@}
00164 
00165 
00166   private:
00167 
00168     /// Store the weighted sums of numbers of charged / charged+neutral
00169     /// particles - used to calculate average number of particles for the
00170     /// inclusive single particle distributions' normalisations.
00171     double _weightedTotalPartNum;
00172 
00173     double _SumOfudsWeights;
00174     double _SumOfcWeights;
00175     double _SumOfbWeights;
00176 
00177     Histo1DPtr _histXpuds;
00178     Histo1DPtr _histXpc;
00179     Histo1DPtr _histXpb;
00180     Histo1DPtr _histXpall;
00181     Histo1DPtr _histLogXpuds;
00182     Histo1DPtr _histLogXpc;
00183     Histo1DPtr _histLogXpb;
00184     Histo1DPtr _histLogXpall;
00185     Histo1DPtr _histMultiChargeduds;
00186     Histo1DPtr _histMultiChargedc;
00187     Histo1DPtr _histMultiChargedb;
00188     Histo1DPtr _histMultiChargedall;
00189 
00190     //@}
00191 
00192   };
00193 
00194 
00195 
00196   // The hook for the plugin system
00197   DECLARE_RIVET_PLUGIN(OPAL_1998_S3780481);
00198 
00199 }