rivet is hosted by Hepforge, IPPP Durham
CMS_QCD_10_024.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Projections/ChargedFinalState.hh"
00004 #include "Rivet/Particle.hh"
00005 
00006 namespace Rivet {
00007 
00008 
00009   class CMS_QCD_10_024 : public Analysis {
00010   public:
00011 
00012     /// @name Constructors etc.
00013     //@{
00014 
00015     /// Constructor
00016     CMS_QCD_10_024() : Analysis("CMS_QCD_10_024"),
00017                _weight_pt05_eta08(0.), _weight_pt10_eta08(0.),
00018                _weight_pt05_eta24(0.), _weight_pt10_eta24(0.) {  }
00019 
00020 
00021     void init() {
00022       addProjection(ChargedFinalState(-0.8, 0.8, 0.5*GeV), "CFS_08_05");
00023       addProjection(ChargedFinalState(-0.8, 0.8, 1.0*GeV), "CFS_08_10");
00024       addProjection(ChargedFinalState(-2.4, 2.4, 0.5*GeV), "CFS_24_05");
00025       addProjection(ChargedFinalState(-2.4, 2.4, 1.0*GeV), "CFS_24_10");
00026 
00027       size_t offset = 0;
00028       if (fuzzyEquals(sqrtS()/GeV, 7000, 1E-3)) offset = 0;
00029       if (fuzzyEquals(sqrtS()/GeV, 900, 1E-3)) offset = 4;
00030       _hist_dNch_deta_pt05_eta08 = bookHisto1D(1+offset, 1, 1);
00031       _hist_dNch_deta_pt10_eta08 = bookHisto1D(2+offset, 1, 1);
00032       _hist_dNch_deta_pt05_eta24 = bookHisto1D(3+offset, 1, 1);
00033       _hist_dNch_deta_pt10_eta24 = bookHisto1D(4+offset, 1, 1);
00034     }
00035 
00036 
00037     void analyze(const Event& event) {
00038       const double weight = event.weight();
00039       const ChargedFinalState& cfs_08_05 = applyProjection<ChargedFinalState>(event, "CFS_08_05");
00040       const ChargedFinalState& cfs_08_10 = applyProjection<ChargedFinalState>(event, "CFS_08_10");
00041       const ChargedFinalState& cfs_24_05 = applyProjection<ChargedFinalState>(event, "CFS_24_05");
00042       const ChargedFinalState& cfs_24_10 = applyProjection<ChargedFinalState>(event, "CFS_24_10");
00043 
00044       // Plot distributions
00045       if(!cfs_08_05.particles().empty()) _weight_pt05_eta08 += weight;
00046       if(!cfs_24_05.particles().empty()) _weight_pt05_eta24 += weight;
00047       foreach (const Particle& p, cfs_24_05.particles()) {
00048         _hist_dNch_deta_pt05_eta24->fill(p.momentum().pseudorapidity(), weight);
00049         if(!cfs_08_05.particles().empty())
00050       _hist_dNch_deta_pt05_eta08->fill(p.momentum().pseudorapidity(), weight);
00051       }
00052       if(!cfs_08_10.particles().empty()) _weight_pt10_eta08 += weight;
00053       if(!cfs_24_10.particles().empty()) _weight_pt10_eta24 += weight;
00054       foreach (const Particle& p, cfs_24_10.particles()) {
00055         _hist_dNch_deta_pt10_eta24->fill(p.momentum().pseudorapidity(), weight);
00056     if(!cfs_08_10.particles().empty())
00057       _hist_dNch_deta_pt10_eta08->fill(p.momentum().pseudorapidity(), weight);
00058       }
00059     }
00060 
00061 
00062     /// Normalise histograms etc., after the run
00063     void finalize() {
00064       scale(_hist_dNch_deta_pt05_eta08,1./_weight_pt05_eta08);
00065       scale(_hist_dNch_deta_pt10_eta08,1./_weight_pt10_eta08);
00066       scale(_hist_dNch_deta_pt05_eta24,1./_weight_pt05_eta24);
00067       scale(_hist_dNch_deta_pt10_eta24,1./_weight_pt10_eta24);
00068     }
00069 
00070 
00071   private:
00072 
00073     Histo1DPtr _hist_dNch_deta_pt05_eta08;
00074     Histo1DPtr _hist_dNch_deta_pt10_eta08;
00075     Histo1DPtr _hist_dNch_deta_pt05_eta24;
00076     Histo1DPtr _hist_dNch_deta_pt10_eta24;
00077     double _weight_pt05_eta08,_weight_pt10_eta08,_weight_pt05_eta24,_weight_pt10_eta24;
00078   };
00079 
00080 
00081   // Hook for the plugin system
00082   DECLARE_RIVET_PLUGIN(CMS_QCD_10_024);
00083 
00084 }