rivet is hosted by Hepforge, IPPP Durham
OPAL_2002_S5361494.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetYODA.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005 #include "Rivet/Projections/Beam.hh"
00006 #include "Rivet/Projections/FinalState.hh"
00007 #include "Rivet/Projections/ChargedFinalState.hh"
00008 #include "Rivet/Projections/Sphericity.hh"
00009 #include "Rivet/Projections/Thrust.hh"
00010 #include "Rivet/Projections/FastJets.hh"
00011 #include "Rivet/Projections/ParisiTensor.hh"
00012 #include "Rivet/Projections/Hemispheres.hh"
00013 #include "Rivet/Projections/InitialQuarks.hh"
00014 #include <cmath>
00015 
00016 namespace Rivet {
00017 
00018 
00019   /// @brief OPAL multiplicities at various energies
00020   /// @author Peter Richardson
00021   class OPAL_2002_S5361494 : public Analysis {
00022   public:
00023 
00024     /// Constructor
00025     OPAL_2002_S5361494()
00026       : Analysis("OPAL_2002_S5361494"),
00027         _weightedTotalChargedPartNumLight(0.),
00028         _weightedTotalChargedPartNumCharm(0.),
00029         _weightedTotalChargedPartNumBottom(0.),
00030         _weightLight(0.),_weightCharm(0.),_weightBottom(0.)
00031     {}
00032 
00033     /// @name Analysis methods
00034     //@{
00035 
00036 
00037     void init() {
00038       // Projections
00039       addProjection(Beam(), "Beams");
00040       addProjection(ChargedFinalState(), "CFS");
00041       addProjection(InitialQuarks(), "IQF");
00042 
00043     }
00044 
00045 
00046     void analyze(const Event& event) {
00047       const double weight = event.weight();
00048       // Even if we only generate hadronic events, we still need a cut on numCharged >= 2.
00049       const FinalState& cfs = applyProjection<FinalState>(event, "CFS");
00050       if (cfs.size() < 2) vetoEvent;
00051 
00052 
00053       int flavour = 0;
00054       const InitialQuarks& iqf = applyProjection<InitialQuarks>(event, "IQF");
00055 
00056       // If we only have two quarks (qqbar), just take the flavour.
00057       // If we have more than two quarks, look for the highest energetic q-qbar pair.
00058       if (iqf.particles().size() == 2) {
00059         flavour = abs( iqf.particles().front().pdgId() );
00060       }
00061       else {
00062         map<int, double> quarkmap;
00063         foreach (const Particle& p, iqf.particles()) {
00064           if (quarkmap[p.pdgId()] < p.momentum().E()) {
00065             quarkmap[p.pdgId()] = p.momentum().E();
00066           }
00067         }
00068         double maxenergy = 0.;
00069         for (int i = 1; i <= 5; ++i) {
00070           if (quarkmap[i]+quarkmap[-i] > maxenergy) {
00071             flavour = i;
00072           }
00073         }
00074       }
00075       const size_t numParticles = cfs.particles().size();
00076       switch (flavour) {
00077       case 1: case 2: case 3:
00078         _weightLight  += weight;
00079         _weightedTotalChargedPartNumLight  += numParticles * weight;
00080         break;
00081       case 4:
00082         _weightCharm  += weight;
00083         _weightedTotalChargedPartNumCharm  += numParticles * weight;
00084         break;
00085       case 5:
00086         _weightBottom += weight;
00087         _weightedTotalChargedPartNumBottom += numParticles * weight;
00088         break;
00089       }
00090 
00091     }
00092 
00093 
00094     void finalize() {
00095       // @todo YODA
00096       //// bottom
00097       //const double avgNumPartsBottom = _weightedTotalChargedPartNumBottom / _weightBottom;
00098       //AIDA::IDataPointSet * multB = bookDataPointSet(1, 1, 1);
00099       //for (int i = 0; i < multB->size(); ++i) {
00100       //  if (fuzzyEquals(sqrtS(), multB->point(i)->coordinate(0)->value(), 0.01)) {
00101       //    multB->point(i)->coordinate(1)->setValue(avgNumPartsBottom);
00102       //  }
00103       //}
00104       //// charm
00105       //const double avgNumPartsCharm = _weightedTotalChargedPartNumCharm / _weightCharm;
00106       //AIDA::IDataPointSet * multC = bookDataPointSet(1, 1, 2);
00107       //for (int i = 0; i < multC->size(); ++i) {
00108       //  if (fuzzyEquals(sqrtS(), multC->point(i)->coordinate(0)->value(), 0.01)) {
00109       //    multC->point(i)->coordinate(1)->setValue(avgNumPartsCharm);
00110       //  }
00111       //}
00112       //// light
00113       //const double avgNumPartsLight = _weightedTotalChargedPartNumLight / _weightLight;
00114       //AIDA::IDataPointSet * multL = bookDataPointSet(1, 1, 3);
00115       //for (int i = 0; i < multL->size(); ++i) {
00116       //  if (fuzzyEquals(sqrtS(), multL->point(i)->coordinate(0)->value(), 0.01)) {
00117       //    multL->point(i)->coordinate(1)->setValue(avgNumPartsLight);
00118       //  }
00119       //}
00120       //// bottom-light
00121       //AIDA::IDataPointSet * multD = bookDataPointSet(1, 1, 4);
00122       //for (int i = 0; i < multD->size(); ++i) {
00123       //  if (fuzzyEquals(sqrtS(), multD->point(i)->coordinate(0)->value(), 0.01)) {
00124       //    multD->point(i)->coordinate(1)->setValue(avgNumPartsBottom-avgNumPartsLight);
00125       //  }
00126       //}
00127     }
00128     //@}
00129 
00130 
00131   private:
00132 
00133     /// @name Multiplicities
00134     //@{
00135     double _weightedTotalChargedPartNumLight;
00136     double _weightedTotalChargedPartNumCharm;
00137     double _weightedTotalChargedPartNumBottom;
00138     //@}
00139 
00140     /// @name Weights
00141     //@{
00142     double _weightLight;
00143     double _weightCharm;
00144     double _weightBottom;
00145     //@}
00146   };
00147 
00148   // The hook for the plugin system
00149   DECLARE_RIVET_PLUGIN(OPAL_2002_S5361494);
00150 
00151 }