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 _histPdfX = bookHistogram1D("PdfX", logspace(0.000001, 1.0, 50));
00077 _histPdfXmin = bookHistogram1D("PdfXmin", logspace(0.000001, 1.0, 50));
00078 _histPdfXmax = bookHistogram1D("PdfXmax", logspace(0.000001, 1.0, 50));
00079 _histPdfQ = bookHistogram1D("PdfQ", 50, 0.0, 30.0);
00080
00081
00082
00083 }
00084
00085
00086
00087
00088 void analyze(const Event& event) {
00089 const double weight = event.weight();
00090
00091
00092 foreach (const GenParticle* gp, particles(event.genEvent())) {
00093 _histAllPIDs->fill(abs(gp->pdg_id()), weight);
00094 }
00095
00096
00097 if (event.genEvent().pdf_info() != 0) {
00098 HepMC::PdfInfo pdfi = *event.genEvent().pdf_info();
00099 MSG_DEBUG("PDF Q = " << pdfi.scalePDF() << " for (id, x) = "
00100 << "(" << pdfi.id1() << ", " << pdfi.x1() << ") "
00101 << "(" << pdfi.id2() << ", " << pdfi.x2() << ")");
00102 _histPdfX->fill(pdfi.x1(), weight);
00103 _histPdfX->fill(pdfi.x2(), weight);
00104 _histPdfXmin->fill(std::min(pdfi.x1(), pdfi.x2()), weight);
00105 _histPdfXmax->fill(std::max(pdfi.x1(), pdfi.x2()), weight);
00106 _histPdfQ->fill(pdfi.scalePDF(), weight);
00107 }
00108
00109
00110 const FinalState& cnfs = applyProjection<FinalState>(event, "FS");
00111 MSG_DEBUG("Total multiplicity = " << cnfs.size());
00112 _histMult->fill(cnfs.size(), weight);
00113 foreach (const Particle& p, cnfs.particles()) {
00114 _histStablePIDs->fill(abs(p.pdgId()), weight);
00115 const double eta = p.momentum().eta();
00116 _histEta->fill(eta, weight);
00117 _histEtaSumEt->fill(fabs(eta), p.momentum().Et(), weight);
00118 if (eta > 0) {
00119 _tmphistEtaPlus->fill(fabs(eta), weight);
00120 } else {
00121 _tmphistEtaMinus->fill(fabs(eta), weight);
00122 }
00123 const double rapidity = p.momentum().rapidity();
00124 _histRapidity->fill(rapidity, weight);
00125 if (rapidity > 0) {
00126 _tmphistRapPlus->fill(fabs(rapidity), weight);
00127 } else {
00128 _tmphistRapMinus->fill(fabs(rapidity), weight);
00129 }
00130 _histPt->fill(p.momentum().pT()/GeV, weight);
00131 _histE->fill(p.momentum().E()/GeV, weight);
00132 _histPhi->fill(p.momentum().phi(), weight);
00133 }
00134
00135 const FinalState& cfs = applyProjection<FinalState>(event, "CFS");
00136 MSG_DEBUG("Total charged multiplicity = " << cfs.size());
00137 _histMultCh->fill(cfs.size(), weight);
00138 foreach (const Particle& p, cfs.particles()) {
00139 const double eta = p.momentum().eta();
00140 _histEtaCh->fill(eta, weight);
00141 if (eta > 0) {
00142 _tmphistEtaChPlus->fill(fabs(eta), weight);
00143 } else {
00144 _tmphistEtaChMinus->fill(fabs(eta), weight);
00145 }
00146 const double rapidity = p.momentum().rapidity();
00147 _histRapidityCh->fill(rapidity, weight);
00148 if (rapidity > 0) {
00149 _tmphistRapChPlus->fill(fabs(rapidity), weight);
00150 } else {
00151 _tmphistRapChMinus->fill(fabs(rapidity), weight);
00152 }
00153 _histPtCh->fill(p.momentum().pT()/GeV, weight);
00154 _histECh->fill(p.momentum().E()/GeV, weight);
00155 _histPhiCh->fill(p.momentum().phi(), weight);
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 }
00166
00167
00168
00169 const UnstableFinalState& ufs = applyProjection<UnstableFinalState>(event, "UFS");
00170 foreach (const Particle& p, ufs.particles()) {
00171 const double eta_abs = fabs(p.momentum().eta());
00172 _histDecayedPIDs->fill(p.pdgId(), weight);
00173 const PdgId pid = abs(p.pdgId());
00174
00175 if (pid == 211 || pid == 111) _histEtaPi->fill(eta_abs, weight);
00176 else if (pid == 321 || pid == 130 || pid == 310) _histEtaK->fill(eta_abs, weight);
00177 else if (pid == 3122) _histEtaLambda->fill(eta_abs, weight);
00178
00179 }
00180
00181 }
00182
00183
00184
00185
00186 void finalize() {
00187 scale(_histMult, 1/sumOfWeights());
00188 scale(_histMultCh, 1/sumOfWeights());
00189
00190 scale(_histStablePIDs, 1/sumOfWeights());
00191 scale(_histDecayedPIDs, 1/sumOfWeights());
00192 scale(_histAllPIDs, 1/sumOfWeights());
00193
00194 scale(_histEta, 1/sumOfWeights());
00195 scale(_histEtaCh, 1/sumOfWeights());
00196
00197 scale(_histEtaPi, 1/sumOfWeights());
00198 scale(_histEtaK, 1/sumOfWeights());
00199 scale(_histEtaLambda, 1/sumOfWeights());
00200
00201 scale(_histRapidity, 1/sumOfWeights());
00202 scale(_histRapidityCh, 1/sumOfWeights());
00203
00204 scale(_histPt, 1/sumOfWeights());
00205 scale(_histPtCh, 1/sumOfWeights());
00206
00207 scale(_histE, 1/sumOfWeights());
00208 scale(_histECh, 1/sumOfWeights());
00209
00210 scale(_histPhi, 1/sumOfWeights());
00211 scale(_histPhiCh, 1/sumOfWeights());
00212
00213 scale(_histPdfX, 1/sumOfWeights());
00214 scale(_histPdfXmin, 1/sumOfWeights());
00215 scale(_histPdfXmax, 1/sumOfWeights());
00216 scale(_histPdfQ, 1/sumOfWeights());
00217
00218 histogramFactory().divide(histoPath("EtaPMRatio"), *_tmphistEtaPlus, *_tmphistEtaMinus);
00219 histogramFactory().divide(histoPath("EtaChPMRatio"), *_tmphistEtaChPlus, *_tmphistEtaChMinus);
00220 histogramFactory().divide(histoPath("RapidityPMRatio"), *_tmphistRapPlus, *_tmphistRapMinus);
00221 histogramFactory().divide(histoPath("RapidityChPMRatio"), *_tmphistRapChPlus, *_tmphistRapChMinus);
00222 }
00223
00224
00225
00226
00227 private:
00228
00229
00230 shared_ptr<LWH::Histogram1D> _tmphistEtaPlus, _tmphistEtaMinus;
00231 shared_ptr<LWH::Histogram1D> _tmphistEtaChPlus, _tmphistEtaChMinus;
00232 shared_ptr<LWH::Histogram1D> _tmphistRapPlus, _tmphistRapMinus;
00233 shared_ptr<LWH::Histogram1D> _tmphistRapChPlus, _tmphistRapChMinus;
00234
00235
00236
00237 AIDA::IHistogram1D *_histMult, *_histMultCh;
00238 AIDA::IHistogram1D *_histStablePIDs, *_histDecayedPIDs, *_histAllPIDs;
00239 AIDA::IHistogram1D *_histEtaPi, *_histEtaK, *_histEtaLambda;
00240 AIDA::IProfile1D *_histEtaSumEt;
00241 AIDA::IHistogram1D *_histEta, *_histEtaCh;
00242 AIDA::IHistogram1D *_histRapidity, *_histRapidityCh;
00243 AIDA::IHistogram1D *_histPt, *_histPtCh;
00244 AIDA::IHistogram1D *_histE, *_histECh;
00245 AIDA::IHistogram1D *_histPhi, *_histPhiCh;
00246 AIDA::IHistogram1D *_histPdfX, *_histPdfXmin, *_histPdfXmax, *_histPdfQ;
00247
00248
00249
00250 };
00251
00252
00253
00254 DECLARE_RIVET_PLUGIN(MC_GENERIC);
00255
00256 }