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