rivet is hosted by Hepforge, IPPP Durham
MC_GENERIC.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/ChargedFinalState.hh"
00005 
00006 namespace Rivet {
00007 
00008 
00009   /// Generic analysis looking at various distributions of final state particles
00010   class MC_GENERIC : public Analysis {
00011   public:
00012 
00013     /// Constructor
00014     MC_GENERIC()
00015       : Analysis("MC_GENERIC")
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(ChargedFinalState(-5.0, 5.0, 500*MeV), "CFS");
00031 
00032       // Histograms
00033       // @todo Choose E/pT ranged based on input energies... can't do anything about kin. cuts, though
00034       _histMult   = bookHisto1D("Mult", 100, -0.5, 199.5);
00035       _histMultCh = bookHisto1D("MultCh", 100, -0.5, 199.5);
00036 
00037       _histPt   = bookHisto1D("Pt", 300, 0, 30);
00038       _histPtCh = bookHisto1D("PtCh", 300, 0, 30);
00039 
00040       _histE   = bookHisto1D("E", 100, 0, 200);
00041       _histECh = bookHisto1D("ECh", 100, 0, 200);
00042 
00043       _histEtaSumEt = bookProfile1D("EtaSumEt", 25, 0, 5);
00044 
00045       _histEta    = bookHisto1D("Eta", 50, -5, 5);
00046       _histEtaCh  = bookHisto1D("EtaCh", 50, -5, 5);
00047       _tmphistEtaPlus = Histo1D(25, 0, 5);
00048       _tmphistEtaMinus = Histo1D(25, 0, 5);
00049       _tmphistEtaChPlus = Histo1D(25, 0, 5);
00050       _tmphistEtaChMinus = Histo1D(25, 0, 5);
00051 
00052       _histRapidity    = bookHisto1D("Rapidity", 50, -5, 5);
00053       _histRapidityCh  = bookHisto1D("RapidityCh", 50, -5, 5);
00054       _tmphistRapPlus = Histo1D(25, 0, 5);
00055       _tmphistRapMinus = Histo1D(25, 0, 5);
00056       _tmphistRapChPlus = Histo1D(25, 0, 5);
00057       _tmphistRapChMinus = Histo1D(25, 0, 5);
00058 
00059       _histPhi    = bookHisto1D("Phi", 50, 0, TWOPI);
00060       _histPhiCh  = bookHisto1D("PhiCh", 50, 0, TWOPI);
00061 
00062       _histEtaPMRatio = bookScatter2D("EtaPMRatio");
00063       _histEtaChPMRatio = bookScatter2D("EtaChPMRatio");
00064       _histRapidityPMRatio = bookScatter2D("RapidityPMRatio");
00065       _histRapidityChPMRatio = bookScatter2D("RapidityChPMRatio");
00066     }
00067 
00068 
00069 
00070     /// Perform the per-event analysis
00071     void analyze(const Event& event) {
00072       const double weight = event.weight();
00073 
00074       // Charged + neutral final state
00075       const FinalState& cnfs = applyProjection<FinalState>(event, "FS");
00076       MSG_DEBUG("Total multiplicity = " << cnfs.size());
00077       _histMult->fill(cnfs.size(), weight);
00078       foreach (const Particle& p, cnfs.particles()) {
00079         const double eta = p.eta();
00080         _histEta->fill(eta, weight);
00081         _histEtaSumEt->fill(fabs(eta), p.momentum().Et(), weight);
00082         if (eta > 0) _tmphistEtaPlus.fill(fabs(eta), weight);
00083         else _tmphistEtaMinus.fill(fabs(eta), weight);
00084         //
00085         const double rapidity = p.rapidity();
00086         _histRapidity->fill(rapidity, weight);
00087         if (rapidity > 0) _tmphistRapPlus.fill(fabs(rapidity), weight);
00088         else _tmphistRapMinus.fill(fabs(rapidity), weight);
00089         //
00090         _histPt->fill(p.pT()/GeV, weight);
00091         _histE->fill(p.momentum().E()/GeV, weight);
00092         _histPhi->fill(p.momentum().phi(), weight);
00093       }
00094 
00095       const FinalState& cfs = applyProjection<FinalState>(event, "CFS");
00096       MSG_DEBUG("Total charged multiplicity = " << cfs.size());
00097       _histMultCh->fill(cfs.size(), weight);
00098       foreach (const Particle& p, cfs.particles()) {
00099         const double eta = p.eta();
00100         _histEtaCh->fill(eta, weight);
00101         if (eta > 0) {
00102           _tmphistEtaChPlus.fill(fabs(eta), weight);
00103         } else {
00104           _tmphistEtaChMinus.fill(fabs(eta), weight);
00105         }
00106         const double rapidity = p.rapidity();
00107         _histRapidityCh->fill(rapidity, weight);
00108         if (rapidity > 0) {
00109           _tmphistRapChPlus.fill(fabs(rapidity), weight);
00110         } else {
00111           _tmphistRapChMinus.fill(fabs(rapidity), weight);
00112         }
00113         _histPtCh->fill(p.pT()/GeV, weight);
00114         _histECh->fill(p.momentum().E()/GeV, weight);
00115         _histPhiCh->fill(p.momentum().phi(), weight);
00116       }
00117 
00118     }
00119 
00120 
00121     /// Finalize
00122     void finalize() {
00123       normalize(_histMult);
00124       normalize(_histMultCh);
00125       normalize(_histEta);
00126       normalize(_histEtaCh);
00127       normalize(_histRapidity);
00128       normalize(_histRapidityCh);
00129       normalize(_histPt);
00130       normalize(_histPtCh);
00131       normalize(_histE);
00132       normalize(_histECh);
00133       normalize(_histPhi);
00134       normalize(_histPhiCh);
00135       divide(_tmphistEtaPlus, _tmphistEtaMinus, _histEtaPMRatio);
00136       divide(_tmphistEtaChPlus, _tmphistEtaChMinus, _histEtaChPMRatio);
00137       divide(_tmphistRapPlus, _tmphistRapMinus, _histRapidityPMRatio);
00138       divide(_tmphistRapChPlus, _tmphistRapChMinus, _histRapidityChPMRatio);
00139     }
00140 
00141     //@}
00142 
00143 
00144   private:
00145 
00146     /// @name Histograms
00147     //@{
00148     Histo1DPtr _histMult, _histMultCh;
00149     Profile1DPtr _histEtaSumEt;
00150     Histo1DPtr _histEta, _histEtaCh;
00151     Histo1DPtr _histRapidity, _histRapidityCh;
00152     Histo1DPtr _histPt, _histPtCh;
00153     Histo1DPtr _histE, _histECh;
00154     Histo1DPtr _histPhi, _histPhiCh;
00155     Scatter2DPtr _histEtaPMRatio;
00156     Scatter2DPtr _histEtaChPMRatio;
00157     Scatter2DPtr _histRapidityPMRatio;
00158     Scatter2DPtr _histRapidityChPMRatio;
00159     //@}
00160 
00161     /// @name Temporary histos used to calculate eta+/eta- ratio plots
00162     //@{
00163     Histo1D _tmphistEtaPlus, _tmphistEtaMinus;
00164     Histo1D _tmphistEtaChPlus, _tmphistEtaChMinus;
00165     Histo1D _tmphistRapPlus, _tmphistRapMinus;
00166     Histo1D _tmphistRapChPlus, _tmphistRapChMinus;
00167     //@}
00168 
00169   };
00170 
00171 
00172   // The hook for the plugin system
00173   DECLARE_RIVET_PLUGIN(MC_GENERIC);
00174 
00175 }