CMS_2011_S8884919.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.hh"
00004 #include "Rivet/Projections/ChargedFinalState.hh"
00005 #include "Rivet/Tools/ParticleIdUtils.hh"
00006 #include "Rivet/Projections/Beam.hh"
00007 using namespace std;
00008 
00009 namespace Rivet {
00010 
00011   class CMS_2011_S8884919 : public Analysis {
00012   public:
00013 
00014     CMS_2011_S8884919() : Analysis("CMS_2011_S8884919") {
00015        setNeedsCrossSection(false);
00016     }
00017 
00018   void init() {
00019     ChargedFinalState cfs(-2.4, 2.4, 0.0*GeV);
00020     addProjection(cfs, "CFS");
00021 
00022     //eta bins
00023     _etabins.push_back(0.5);
00024     _etabins.push_back(1.0);
00025     _etabins.push_back(1.5);
00026     _etabins.push_back(2.0);
00027     _etabins.push_back(2.4) ;
00028 
00029     if(fuzzyEquals(sqrtS()/GeV, 900)){
00030       for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++){
00031         _h_dNch_dn.push_back( bookHistogram1D( 2 + ietabin, 1, 1) );
00032       }
00033       _h_dNch_dn_pt500_eta24 = bookHistogram1D(20, 1, 1);
00034       _h_dmpt_dNch_eta24 = bookProfile1D(23, 1, 1);
00035     }
00036 
00037     if(fuzzyEquals(sqrtS()/GeV, 2360)){
00038       for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++){
00039         _h_dNch_dn.push_back( bookHistogram1D(7 + ietabin, 1, 1) );
00040       }
00041       _h_dNch_dn_pt500_eta24 = bookHistogram1D(21, 1, 1);
00042       _h_dmpt_dNch_eta24 = bookProfile1D(24, 1, 1);
00043     }
00044 
00045     if(fuzzyEquals(sqrtS()/GeV, 7000)){
00046       for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++){
00047         _h_dNch_dn.push_back( bookHistogram1D(12 + ietabin, 1, 1) );
00048       }
00049       _h_dNch_dn_pt500_eta24 = bookHistogram1D(22, 1, 1);
00050       _h_dmpt_dNch_eta24 = bookProfile1D(25, 1, 1);
00051     }
00052   }
00053 
00054   void analyze(const Event& event) {
00055     const double weight = event.weight();
00056 
00057     //charge 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.momentum().pT();
00073       double eta = p.momentum().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) ++(_nch_in_Evt_pt500[ietabin]);
00079         }
00080         else
00081           break;
00082       }
00083     }
00084 
00085     //filling mutliplicity 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) _h_dmpt_dNch_eta24->fill(_nch_in_Evt[4], sumpt / _nch_in_Evt[4], weight);
00093       _h_dNch_dn_pt500_eta24->fill(_nch_in_Evt_pt500[4], weight);
00094     }
00095     else
00096       getLog() << Log::WARNING << "You changed the number of eta bins, but forgot to propagate it everywhere !! " << endl;
00097 
00098   }
00099 
00100   void finalize() {
00101     for (size_t ietabin=0; ietabin < _etabins.size(); ietabin++){
00102       normalize(_h_dNch_dn[ietabin]);
00103     }
00104     normalize(_h_dNch_dn_pt500_eta24);
00105   }
00106 
00107   private:
00108     vector<AIDA::IHistogram1D*> _h_dNch_dn;
00109     AIDA::IHistogram1D* _h_dNch_dn_pt500_eta24;
00110     AIDA::IProfile1D*   _h_dmpt_dNch_eta24;
00111 
00112     vector<double> _etabins;
00113   };
00114 
00115   // This global object acts as a hook for the plugin system
00116   AnalysisBuilder<CMS_2011_S8884919> plugin_CMS_2011_S8884919;
00117 
00118 }
00119