rivet is hosted by Hepforge, IPPP Durham
MC_IDENTIFIED.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Projections/FinalState.hh"
00004 #include "Rivet/Projections/UnstableFinalState.hh"
00005 
00006 namespace Rivet {
00007 
00008   using namespace Cuts;
00009 
00010 
00011   /// Generic analysis looking at various distributions of final state particles
00012   /// @todo Rename as MC_HADRONS
00013   class MC_IDENTIFIED : public Analysis {
00014   public:
00015 
00016     /// Constructor
00017     MC_IDENTIFIED()
00018       : Analysis("MC_IDENTIFIED")
00019     {    }
00020 
00021 
00022   public:
00023 
00024     /// @name Analysis methods
00025     //@{
00026 
00027     /// Book histograms and initialise projections before the run
00028     void init() {
00029 
00030       // Projections
00031       const FinalState cnfs(-5.0, 5.0, 500*MeV);
00032       addProjection(cnfs, "FS");
00033       addProjection(UnstableFinalState(-5.0, 5.0, 500*MeV), "UFS");
00034 
00035       // Histograms
00036       // @todo Choose E/pT ranged based on input energies... can't do anything about kin. cuts, though
00037 
00038       _histStablePIDs  = bookHisto1D("MultsStablePIDs", 3335, -0.5, 3334.5);
00039       _histDecayedPIDs = bookHisto1D("MultsDecayedPIDs", 3335, -0.5, 3334.5);
00040       _histAllPIDs     = bookHisto1D("MultsAllPIDs", 3335, -0.5, 3334.5);
00041 
00042       _histEtaPi       = bookHisto1D("EtaPi", 25, 0, 5);
00043       _histEtaK        = bookHisto1D("EtaK", 25, 0, 5);
00044       _histEtaLambda   = bookHisto1D("EtaLambda", 25, 0, 5);
00045     }
00046 
00047 
00048 
00049     /// Perform the per-event analysis
00050     void analyze(const Event& event) {
00051       const double weight = event.weight();
00052 
00053       // Unphysical (debug) plotting of all PIDs in the event, physical or otherwise
00054       foreach (const GenParticle* gp, particles(event.genEvent())) {
00055         _histAllPIDs->fill(abs(gp->pdg_id()), weight);
00056       }
00057 
00058       // Charged + neutral final state PIDs
00059       const FinalState& cnfs = applyProjection<FinalState>(event, "FS");
00060       foreach (const Particle& p, cnfs.particles()) {
00061         _histStablePIDs->fill(p.abspid(), weight);
00062       }
00063 
00064       // Unstable PIDs and identified particle eta spectra
00065       const UnstableFinalState& ufs = applyProjection<UnstableFinalState>(event, "UFS");
00066       foreach (const Particle& p, ufs.particles()) {
00067         _histDecayedPIDs->fill(p.pid(), weight);
00068         const double eta_abs = p.abseta();
00069         const PdgId pid = p.abspid(); //if (PID::isMeson(pid) && PID::hasStrange()) {
00070         if (pid == 211 || pid == 111) _histEtaPi->fill(eta_abs, weight);
00071         else if (pid == 321 || pid == 130 || pid == 310) _histEtaK->fill(eta_abs, weight);
00072         else if (pid == 3122) _histEtaLambda->fill(eta_abs, weight);
00073       }
00074 
00075     }
00076 
00077 
00078 
00079     /// Finalize
00080     void finalize() {
00081       scale(_histStablePIDs, 1/sumOfWeights());
00082       scale(_histDecayedPIDs, 1/sumOfWeights());
00083       scale(_histAllPIDs, 1/sumOfWeights());
00084       scale(_histEtaPi, 1/sumOfWeights());
00085       scale(_histEtaK, 1/sumOfWeights());
00086       scale(_histEtaLambda, 1/sumOfWeights());
00087     }
00088 
00089     //@}
00090 
00091 
00092   private:
00093 
00094     /// @name Histograms
00095     //@{
00096     Histo1DPtr _histStablePIDs, _histDecayedPIDs, _histAllPIDs;
00097     Histo1DPtr _histEtaPi, _histEtaK, _histEtaLambda;
00098     //@}
00099 
00100   };
00101 
00102 
00103   // The hook for the plugin system
00104   DECLARE_RIVET_PLUGIN(MC_IDENTIFIED);
00105 
00106 }