00001
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005 #include "Rivet/Projections/FinalState.hh"
00006 #include "Rivet/Projections/ChargedFinalState.hh"
00007 #include "Rivet/Projections/UnstableFinalState.hh"
00008 #include "Rivet/Projections/MissingMomentum.hh"
00009 #include "LWH/Histogram1D.h"
00010
00011 namespace Rivet {
00012
00013
00014
00015 class MC_GENERIC : public Analysis {
00016 public:
00017
00018
00019 MC_GENERIC()
00020 : Analysis("MC_GENERIC")
00021 { }
00022
00023
00024 public:
00025
00026
00027
00028
00029
00030 void init() {
00031
00032
00033 const FinalState cnfs(-5.0, 5.0, 500*MeV);
00034 addProjection(cnfs, "FS");
00035 addProjection(ChargedFinalState(-5.0, 5.0, 500*MeV), "CFS");
00036 addProjection(UnstableFinalState(-5.0, 5.0, 500*MeV), "UFS");
00037
00038
00039
00040
00041 _histMult = bookHistogram1D("Mult", 100, -0.5, 199.5);
00042 _histMultCh = bookHistogram1D("MultCh", 100, -0.5, 199.5);
00043
00044 _histStablePIDs = bookHistogram1D("MultsStablePIDs", 3335, -0.5, 3334.5);
00045 _histDecayedPIDs = bookHistogram1D("MultsDecayedPIDs", 3335, -0.5, 3334.5);
00046 _histAllPIDs = bookHistogram1D("MultsAllPIDs", 3335, -0.5, 3334.5);
00047
00048 _histPt = bookHistogram1D("Pt", 300, 0, 30);
00049 _histPtCh = bookHistogram1D("PtCh", 300, 0, 30);
00050
00051 _histE = bookHistogram1D("E", 100, 0, 200);
00052 _histECh = bookHistogram1D("ECh", 100, 0, 200);
00053
00054 _histEta = bookHistogram1D("Eta", 50, -5, 5);
00055 _histEtaCh = bookHistogram1D("EtaCh", 50, -5, 5);
00056 _tmphistEtaPlus.reset(new LWH::Histogram1D(25, 0, 5));
00057 _tmphistEtaMinus.reset(new LWH::Histogram1D(25, 0, 5));
00058 _tmphistEtaChPlus.reset(new LWH::Histogram1D(25, 0, 5));
00059 _tmphistEtaChMinus.reset(new LWH::Histogram1D(25, 0, 5));
00060
00061 _histEtaPi = bookHistogram1D("EtaPi", 25, 0, 5);
00062 _histEtaK = bookHistogram1D("EtaK", 25, 0, 5);
00063 _histEtaLambda = bookHistogram1D("EtaLambda", 25, 0, 5);
00064 _histEtaSumEt = bookProfile1D("EtaSumEt", 25, 0, 5);
00065
00066 _histRapidity = bookHistogram1D("Rapidity", 50, -5, 5);
00067 _histRapidityCh = bookHistogram1D("RapidityCh", 50, -5, 5);
00068 _tmphistRapPlus.reset(new LWH::Histogram1D(25, 0, 5));
00069 _tmphistRapMinus.reset(new LWH::Histogram1D(25, 0, 5));
00070 _tmphistRapChPlus.reset(new LWH::Histogram1D(25, 0, 5));
00071 _tmphistRapChMinus.reset(new LWH::Histogram1D(25, 0, 5));
00072
00073 _histPhi = bookHistogram1D("Phi", 50, 0, TWOPI);
00074 _histPhiCh = bookHistogram1D("PhiCh", 50, 0, TWOPI);
00075 }
00076
00077
00078
00079
00080 void analyze(const Event& event) {
00081 const double weight = event.weight();
00082
00083
00084 foreach (const GenParticle* gp, particles(event.genEvent())) {
00085 _histAllPIDs->fill(abs(gp->pdg_id()), weight);
00086 }
00087
00088
00089 const FinalState& cnfs = applyProjection<FinalState>(event, "FS");
00090 MSG_DEBUG("Total multiplicity = " << cnfs.size());
00091 _histMult->fill(cnfs.size(), weight);
00092 foreach (const Particle& p, cnfs.particles()) {
00093 _histStablePIDs->fill(abs(p.pdgId()), weight);
00094 const double eta = p.momentum().eta();
00095 _histEta->fill(eta, weight);
00096 _histEtaSumEt->fill(fabs(eta), p.momentum().Et(), weight);
00097 if (eta > 0) {
00098 _tmphistEtaPlus->fill(fabs(eta), weight);
00099 } else {
00100 _tmphistEtaMinus->fill(fabs(eta), weight);
00101 }
00102 const double rapidity = p.momentum().rapidity();
00103 _histRapidity->fill(rapidity, weight);
00104 if (rapidity > 0) {
00105 _tmphistRapPlus->fill(fabs(rapidity), weight);
00106 } else {
00107 _tmphistRapMinus->fill(fabs(rapidity), weight);
00108 }
00109 _histPt->fill(p.momentum().pT()/GeV, weight);
00110 _histE->fill(p.momentum().E()/GeV, weight);
00111 _histPhi->fill(p.momentum().phi(), weight);
00112 }
00113
00114 const FinalState& cfs = applyProjection<FinalState>(event, "CFS");
00115 MSG_DEBUG("Total charged multiplicity = " << cfs.size());
00116 _histMultCh->fill(cfs.size(), weight);
00117 foreach (const Particle& p, cfs.particles()) {
00118 const double eta = p.momentum().eta();
00119 _histEtaCh->fill(eta, weight);
00120 if (eta > 0) {
00121 _tmphistEtaChPlus->fill(fabs(eta), weight);
00122 } else {
00123 _tmphistEtaChMinus->fill(fabs(eta), weight);
00124 }
00125 const double rapidity = p.momentum().rapidity();
00126 _histRapidityCh->fill(rapidity, weight);
00127 if (rapidity > 0) {
00128 _tmphistRapChPlus->fill(fabs(rapidity), weight);
00129 } else {
00130 _tmphistRapChMinus->fill(fabs(rapidity), weight);
00131 }
00132 _histPtCh->fill(p.momentum().pT()/GeV, weight);
00133 _histECh->fill(p.momentum().E()/GeV, weight);
00134 _histPhiCh->fill(p.momentum().phi(), weight);
00135 }
00136
00137
00138
00139 const UnstableFinalState& ufs = applyProjection<UnstableFinalState>(event, "UFS");
00140 foreach (const Particle& p, ufs.particles()) {
00141 const double eta_abs = fabs(p.momentum().eta());
00142 _histDecayedPIDs->fill(p.pdgId(), weight);
00143 const PdgId pid = abs(p.pdgId());
00144
00145 if (pid == 211 || pid == 111) _histEtaPi->fill(eta_abs, weight);
00146 else if (pid == 321 || pid == 130 || pid == 310) _histEtaK->fill(eta_abs, weight);
00147 else if (pid == 3122) _histEtaLambda->fill(eta_abs, weight);
00148
00149 }
00150
00151 }
00152
00153
00154
00155
00156 void finalize() {
00157 scale(_histMult, 1/sumOfWeights());
00158 scale(_histMultCh, 1/sumOfWeights());
00159
00160 scale(_histStablePIDs, 1/sumOfWeights());
00161 scale(_histDecayedPIDs, 1/sumOfWeights());
00162 scale(_histAllPIDs, 1/sumOfWeights());
00163
00164 scale(_histEta, 1/sumOfWeights());
00165 scale(_histEtaCh, 1/sumOfWeights());
00166
00167 scale(_histEtaPi, 1/sumOfWeights());
00168 scale(_histEtaK, 1/sumOfWeights());
00169 scale(_histEtaLambda, 1/sumOfWeights());
00170
00171 scale(_histRapidity, 1/sumOfWeights());
00172 scale(_histRapidityCh, 1/sumOfWeights());
00173
00174 scale(_histPt, 1/sumOfWeights());
00175 scale(_histPtCh, 1/sumOfWeights());
00176
00177 scale(_histE, 1/sumOfWeights());
00178 scale(_histECh, 1/sumOfWeights());
00179
00180 scale(_histPhi, 1/sumOfWeights());
00181 scale(_histPhiCh, 1/sumOfWeights());
00182
00183 histogramFactory().divide(histoPath("EtaPMRatio"), *_tmphistEtaPlus, *_tmphistEtaMinus);
00184 histogramFactory().divide(histoPath("EtaChPMRatio"), *_tmphistEtaChPlus, *_tmphistEtaChMinus);
00185 histogramFactory().divide(histoPath("RapidityPMRatio"), *_tmphistRapPlus, *_tmphistRapMinus);
00186 histogramFactory().divide(histoPath("RapidityChPMRatio"), *_tmphistRapChPlus, *_tmphistRapChMinus);
00187 }
00188
00189
00190
00191
00192 private:
00193
00194
00195 shared_ptr<LWH::Histogram1D> _tmphistEtaPlus, _tmphistEtaMinus;
00196 shared_ptr<LWH::Histogram1D> _tmphistEtaChPlus, _tmphistEtaChMinus;
00197 shared_ptr<LWH::Histogram1D> _tmphistRapPlus, _tmphistRapMinus;
00198 shared_ptr<LWH::Histogram1D> _tmphistRapChPlus, _tmphistRapChMinus;
00199
00200
00201
00202 AIDA::IHistogram1D *_histMult, *_histMultCh;
00203 AIDA::IHistogram1D *_histStablePIDs, *_histDecayedPIDs, *_histAllPIDs;
00204 AIDA::IHistogram1D *_histEtaPi, *_histEtaK, *_histEtaLambda;
00205 AIDA::IProfile1D *_histEtaSumEt;
00206 AIDA::IHistogram1D *_histEta, *_histEtaCh;
00207 AIDA::IHistogram1D *_histRapidity, *_histRapidityCh;
00208 AIDA::IHistogram1D *_histPt, *_histPtCh;
00209 AIDA::IHistogram1D *_histE, *_histECh;
00210 AIDA::IHistogram1D *_histPhi, *_histPhiCh;
00211
00212
00213 };
00214
00215
00216
00217
00218 AnalysisBuilder<MC_GENERIC> plugin_MC_GENERIC;
00219
00220 }