rivet is hosted by Hepforge, IPPP Durham
CMS_2015_I1384119.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/FinalState.hh"
00005 
00006 namespace Rivet {
00007 
00008 
00009   class CMS_2015_I1384119 : public Analysis {
00010   public:
00011 
00012     /// Constructor
00013     CMS_2015_I1384119()
00014       : Analysis("CMS_2015_I1384119")
00015     {    }
00016 
00017 
00018     /// Book histograms and initialise projections before the run
00019     void init() {
00020       const FinalState fsa(Cuts::abseta < 20);
00021       addProjection(fsa, "FSA");
00022       const ChargedFinalState cfs(Cuts::abseta < 2);
00023       addProjection(cfs, "CFS");
00024 
00025       _hist_dNch_dEta_inel = bookHisto1D(1, 1, 1);
00026     }
00027 
00028 
00029     /// Perform the per-event analysis
00030     void analyze(const Event& event) {
00031       // Apply inelastic selection (veto pp -> pp elastic events)
00032       const FinalState& fsa = applyProjection<FinalState>(event, "FSA");
00033       if (fsa.size() <= 2) vetoEvent;
00034 
00035       const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS");
00036       foreach (const Particle& p, cfs.particles()) {
00037         const int id = p.abspid();
00038         // continue if particle is a proton, a kaon or a pion
00039         if (id == 211 || id == 321 || id == 2212) ///< @todo Use PID:: ID constants
00040           _hist_dNch_dEta_inel->fill(p.eta(), event.weight());
00041       }
00042     }
00043 
00044 
00045     /// Normalise histograms etc., after the run
00046     void finalize() {
00047       scale(_hist_dNch_dEta_inel,  1/sumOfWeights());
00048     }
00049 
00050 
00051   private:
00052 
00053     /// Histograms
00054     Histo1DPtr _hist_dNch_dEta_inel;
00055 
00056   };
00057 
00058 
00059   // The hook for the plugin system
00060   DECLARE_RIVET_PLUGIN(CMS_2015_I1384119);
00061 
00062 }