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