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.pdgId())) continue;
00071 
00072         double pT = p.pT();
00073         double eta = p.eta();
00074         sumpt += pT;
00075         for (int ietabin = _etabins.size()-1; ietabin >= 0; --ietabin) {
00076           if (fabs(eta) <= _etabins[ietabin]){
00077             ++(_nch_in_Evt[ietabin]);
00078             if (pT > 0.5/GeV) ++(_nch_in_Evt_pt500[ietabin]);
00079           }
00080           else
00081             break;
00082         }
00083       }
00084 
00085       // Filling multiplicity-dependent histogramms
00086       for (size_t ietabin = 0; ietabin < _etabins.size(); ietabin++) {
00087         _h_dNch_dn[ietabin]->fill(_nch_in_Evt[ietabin], weight);
00088       }
00089 
00090       // Do only if eta bins are the needed ones
00091       if (_etabins[4] == 2.4 && _etabins[0] == 0.5) {
00092         if (_nch_in_Evt[4] != 0) {
00093           _h_dmpt_dNch_eta24->fill(_nch_in_Evt[4], sumpt/GeV / _nch_in_Evt[4], weight);
00094         }
00095         _h_dNch_dn_pt500_eta24->fill(_nch_in_Evt_pt500[4], weight);
00096       } else {
00097         MSG_WARNING("You changed the number of eta bins, but forgot to propagate it everywhere !!");
00098       }
00099     }
00100 
00101 
00102     void finalize() {
00103       for (size_t ietabin = 0; ietabin < _etabins.size(); ietabin++){
00104         normalize(_h_dNch_dn[ietabin]);
00105       }
00106       normalize(_h_dNch_dn_pt500_eta24);
00107     }
00108 
00109 
00110   private:
00111 
00112     vector<Histo1DPtr> _h_dNch_dn;
00113     Histo1DPtr _h_dNch_dn_pt500_eta24;
00114     Profile1DPtr _h_dmpt_dNch_eta24;
00115 
00116     vector<double> _etabins;
00117 
00118   };
00119 
00120 
00121   // The hook for the plugin system
00122   DECLARE_RIVET_PLUGIN(CMS_2011_S8884919);
00123 
00124 }