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