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       scale(_histMult, 1/sumOfWeights());
00124       scale(_histMultCh, 1/sumOfWeights());
00125 
00126       scale(_histEta, 1/sumOfWeights());
00127       scale(_histEtaCh, 1/sumOfWeights());
00128 
00129       scale(_histRapidity, 1/sumOfWeights());
00130       scale(_histRapidityCh, 1/sumOfWeights());
00131 
00132       scale(_histPt, 1/sumOfWeights());
00133       scale(_histPtCh, 1/sumOfWeights());
00134 
00135       scale(_histE, 1/sumOfWeights());
00136       scale(_histECh, 1/sumOfWeights());
00137 
00138       scale(_histPhi, 1/sumOfWeights());
00139       scale(_histPhiCh, 1/sumOfWeights());
00140 
00141       divide(_tmphistEtaPlus, _tmphistEtaMinus, _histEtaPMRatio);
00142       divide(_tmphistEtaChPlus, _tmphistEtaChMinus, _histEtaChPMRatio);
00143       divide(_tmphistRapPlus, _tmphistRapMinus, _histRapidityPMRatio);
00144       divide(_tmphistRapChPlus, _tmphistRapChMinus, _histRapidityChPMRatio);
00145     }
00146 
00147     //@}
00148 
00149 
00150   private:
00151 
00152     /// @name Histograms
00153     //@{
00154     Histo1DPtr _histMult, _histMultCh;
00155     Profile1DPtr _histEtaSumEt;
00156     Histo1DPtr _histEta, _histEtaCh;
00157     Histo1DPtr _histRapidity, _histRapidityCh;
00158     Histo1DPtr _histPt, _histPtCh;
00159     Histo1DPtr _histE, _histECh;
00160     Histo1DPtr _histPhi, _histPhiCh;
00161     Scatter2DPtr _histEtaPMRatio;
00162     Scatter2DPtr _histEtaChPMRatio;
00163     Scatter2DPtr _histRapidityPMRatio;
00164     Scatter2DPtr _histRapidityChPMRatio;
00165     //@}
00166 
00167     /// @name Temporary histos used to calculate eta+/eta- ratio plots
00168     //@{
00169     Histo1D _tmphistEtaPlus, _tmphistEtaMinus;
00170     Histo1D _tmphistEtaChPlus, _tmphistEtaChMinus;
00171     Histo1D _tmphistRapPlus, _tmphistRapMinus;
00172     Histo1D _tmphistRapChPlus, _tmphistRapChMinus;
00173     //@}
00174 
00175   };
00176 
00177 
00178   // The hook for the plugin system
00179   DECLARE_RIVET_PLUGIN(MC_GENERIC);
00180 
00181 }