CMS_2010_S8656010.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 
00007 namespace Rivet {
00008 
00009 
00010   class CMS_2010_S8656010 : public Analysis {
00011   public:
00012 
00013     CMS_2010_S8656010() : Analysis("CMS_2010_S8656010") {}
00014 
00015     void init() {
00016       ChargedFinalState cfs(-2.5, 2.5, 0.0*GeV);
00017       addProjection(cfs, "CFS");
00018 
00019       for (int d=1; d<=3; d++) {
00020         for (int y=1; y<=4; y++) {
00021           _h_dNch_dpT.push_back(bookHistogram1D(d, 1, y));
00022         }
00023       }
00024 
00025       _h_dNch_dpT_all = bookHistogram1D(4, 1, 1);
00026       _h_dNch_dEta = bookHistogram1D(5, 1, 1);
00027     }
00028 
00029 
00030     void analyze(const Event& event) {
00031       const double weight = event.weight();
00032 
00033       //charged particles
00034       const ChargedFinalState& charged = applyProjection<ChargedFinalState>(event, "CFS");
00035 
00036       foreach (const Particle& p, charged.particles()) {
00037         //selecting only charged hadrons
00038         if(! PID::isHadron(p.pdgId())) continue;
00039 
00040         const double pT = p.momentum().pT();
00041         const double eta = p.momentum().eta();
00042 
00043         // The data is actually a duplicated folded distribution.  This should mimic it.
00044         _h_dNch_dEta->fill(eta, 0.5*weight);
00045         _h_dNch_dEta->fill(-eta, 0.5*weight);
00046         if (fabs(eta)<2.4 && pT>0.1) {
00047           if (pT<6.0) {
00048             _h_dNch_dpT_all->fill(pT, weight/pT);
00049             if (pT<2.0) {
00050               int ietabin = fabs(eta)/0.2;
00051               _h_dNch_dpT[ietabin]->fill(pT, weight);
00052             }
00053           }
00054         }
00055       }
00056     }
00057 
00058     void finalize() {
00059       const double normfac = 1.0/sumOfWeights(); // Normalizing to unit eta is automatic
00060       // The pT distributions in bins of eta must be normalized to unit eta.  This is a factor of 2
00061       // for the |eta| times 0.2 (eta range).
00062       // The pT distributions over all eta are normalized to unit eta (2.0*2.4) and by 1/2*pi*pT.
00063       // The 1/pT part is taken care of in the filling.  The 1/2pi is taken care of here.
00064       const double normpT = normfac/(2.0*0.2);
00065       const double normpTall = normfac/(2.0*M_PI*2.0*2.4);
00066 
00067       for (size_t ietabin=0; ietabin < _h_dNch_dpT.size(); ietabin++){
00068         scale(_h_dNch_dpT[ietabin], normpT);
00069       }
00070       scale(_h_dNch_dpT_all, normpTall);
00071       scale(_h_dNch_dEta, normfac);
00072     }
00073 
00074 
00075   private:
00076     std::vector<AIDA::IHistogram1D*> _h_dNch_dpT;
00077     AIDA::IHistogram1D* _h_dNch_dpT_all;
00078     AIDA::IHistogram1D* _h_dNch_dEta;
00079    };
00080 
00081   // This global object acts as a hook for the plugin system
00082   AnalysisBuilder<CMS_2010_S8656010> plugin_CMS_2010_S8656010;
00083 }
00084