rivet is hosted by Hepforge, IPPP Durham
CMS_2011_S8884919.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Projections/ChargedFinalState.hh"
00004 #include "Rivet/Projections/Beam.hh"
00005 using namespace std;
00006 
00007 namespace Rivet {
00008 
00009   class CMS_2011_S8884919 : public Analysis {
00010   public:
00011 
00012     CMS_2011_S8884919()
00013       : Analysis("CMS_2011_S8884919")
00014     {    }
00015 
00016 
00017     void init() {
00018       ChargedFinalState cfs(-2.4, 2.4, 0.0*GeV);
00019       addProjection(cfs, "CFS");
00020 
00021       // eta bins
00022       _etabins.push_back(0.5);
00023       _etabins.push_back(1.0);
00024       _etabins.push_back(1.5);
00025       _etabins.push_back(2.0);
00026       _etabins.push_back(2.4) ;
00027 
00028       if (fuzzyEquals(sqrtS()/GeV, 900)) {
00029         for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++) {
00030           _h_dNch_dn.push_back( bookHisto1D( 2 + ietabin, 1, 1) );
00031         }
00032         _h_dNch_dn_pt500_eta24 = bookHisto1D(20, 1, 1);
00033         _h_dmpt_dNch_eta24 = bookProfile1D(23, 1, 1);
00034       }
00035 
00036       if (fuzzyEquals(sqrtS()/GeV, 2360)) {
00037         for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++) {
00038           _h_dNch_dn.push_back( bookHisto1D(7 + ietabin, 1, 1) );
00039         }
00040         _h_dNch_dn_pt500_eta24 = bookHisto1D(21, 1, 1);
00041         _h_dmpt_dNch_eta24 = bookProfile1D(24, 1, 1);
00042       }
00043 
00044       if (fuzzyEquals(sqrtS()/GeV, 7000)) {
00045         for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++) {
00046           _h_dNch_dn.push_back( bookHisto1D(12 + ietabin, 1, 1) );
00047         }
00048         _h_dNch_dn_pt500_eta24 = bookHisto1D(22, 1, 1);
00049         _h_dmpt_dNch_eta24 = bookProfile1D(25, 1, 1);
00050       }
00051     }
00052 
00053 
00054     void analyze(const Event& event) {
00055       const double weight = event.weight();
00056 
00057       // Get the charged particles
00058       const ChargedFinalState& charged = applyProjection<ChargedFinalState>(event, "CFS");
00059 
00060       // Resetting the multiplicity for the event to 0;
00061       vector<int> _nch_in_Evt;
00062       vector<int> _nch_in_Evt_pt500;
00063       _nch_in_Evt.assign(_etabins.size(), 0);
00064       _nch_in_Evt_pt500.assign(_etabins.size(), 0);
00065       double sumpt = 0;
00066 
00067       // Loop over particles in event
00068       foreach (const Particle& p, charged.particles()) {
00069         // Selecting only charged hadrons
00070         if (! PID::isHadron(p.pid())) continue;
00071 
00072         double pT = p.pT();
00073         double eta = p.eta();
00074         sumpt += pT;
00075         for (size_t ietabin = _etabins.size(); ietabin > 0; --ietabin) {
00076           if (fabs(eta) > _etabins[ietabin-1]) break;
00077           ++_nch_in_Evt[ietabin-1];
00078           if (pT > 0.5/GeV) ++_nch_in_Evt_pt500[ietabin-1];
00079         }
00080       }
00081 
00082       // Filling multiplicity-dependent histogramms
00083       for (size_t ietabin = 0; ietabin < _etabins.size(); ietabin++) {
00084         _h_dNch_dn[ietabin]->fill(_nch_in_Evt[ietabin], weight);
00085       }
00086 
00087       // Do only if eta bins are the needed ones
00088       if (_etabins[4] == 2.4 && _etabins[0] == 0.5) {
00089         if (_nch_in_Evt[4] != 0) {
00090           _h_dmpt_dNch_eta24->fill(_nch_in_Evt[4], sumpt/GeV / _nch_in_Evt[4], weight);
00091         }
00092         _h_dNch_dn_pt500_eta24->fill(_nch_in_Evt_pt500[4], weight);
00093       } else {
00094         MSG_WARNING("You changed the number of eta bins, but forgot to propagate it everywhere !!");
00095       }
00096     }
00097 
00098 
00099     void finalize() {
00100       for (size_t ietabin = 0; ietabin < _etabins.size(); ietabin++){
00101         normalize(_h_dNch_dn[ietabin]);
00102       }
00103       normalize(_h_dNch_dn_pt500_eta24);
00104     }
00105 
00106 
00107   private:
00108 
00109     vector<Histo1DPtr> _h_dNch_dn;
00110     Histo1DPtr _h_dNch_dn_pt500_eta24;
00111     Profile1DPtr _h_dmpt_dNch_eta24;
00112 
00113     vector<double> _etabins;
00114 
00115   };
00116 
00117 
00118   // The hook for the plugin system
00119   DECLARE_RIVET_PLUGIN(CMS_2011_S8884919);
00120 
00121 }