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