rivet is hosted by Hepforge, IPPP Durham
CMS_2013_I1122847.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/ZFinder.hh"
00005 #include "Rivet/Tools/BinnedHistogram.hh"
00006 
00007 namespace Rivet {
00008 
00009   using namespace Cuts;
00010 
00011   class CMS_2013_I1122847 : public Analysis {
00012   public:
00013 
00014     /// Constructor
00015     CMS_2013_I1122847()
00016       : Analysis("CMS_2013_I1122847")  {}
00017 
00018     /// Book histograms and initialise projections before the run
00019     void init() {
00020       FinalState fs;
00021 
00022       Cut cuts_mu = etaIn(-2.4, 2.4) & (pT >= 20.0*GeV);
00023       ZFinder zfinder_mu(fs, cuts_mu, PID::MUON, 40.0*GeV, MAXDOUBLE,
00024                          0.0, ZFinder::CLUSTERNODECAY, ZFinder::NOTRACK);
00025       addProjection(zfinder_mu, "zfinder_mu");
00026 
00027       Cut cuts_el = (pT >= 20.0*GeV) & ((abseta < 1.447) | ((abseta > 1.57) & (abseta < 2.4)));
00028       ZFinder zfinder_el(fs, cuts_el, PID::ELECTRON, 40.0*GeV, MAXDOUBLE,
00029                          0.0, ZFinder::CLUSTERNODECAY, ZFinder::NOTRACK);
00030       addProjection(zfinder_el, "zfinder_el");
00031 
00032 
00033       /// histograms
00034       // dimuon
00035       _hist_mm_100_num = Histo1D(refData(1, 1, 1));
00036       _hist_mm_125_num = Histo1D(refData(1, 1, 2));
00037       _hist_mm_150_num = Histo1D(refData(1, 1, 3));
00038       _hist_mm_240_num = Histo1D(refData(1, 1, 4));
00039 
00040       _hist_mm_100_den = Histo1D(refData(1, 1, 1));
00041       _hist_mm_125_den = Histo1D(refData(1, 1, 2));
00042       _hist_mm_150_den = Histo1D(refData(1, 1, 3));
00043       _hist_mm_240_den = Histo1D(refData(1, 1, 4));
00044 
00045       // dielectron
00046       _hist_ee_100_num = Histo1D(refData(2, 1, 1));
00047       _hist_ee_125_num = Histo1D(refData(2, 1, 2));
00048       _hist_ee_150_num = Histo1D(refData(2, 1, 3));
00049       _hist_ee_240_num = Histo1D(refData(2, 1, 4));
00050 
00051       _hist_ee_100_den = Histo1D(refData(2, 1, 1));
00052       _hist_ee_125_den = Histo1D(refData(2, 1, 2));
00053       _hist_ee_150_den = Histo1D(refData(2, 1, 3));
00054       _hist_ee_240_den = Histo1D(refData(2, 1, 4));
00055 
00056       // dilepton
00057       _hist_ll_100_num = Histo1D(refData(3, 1, 1));
00058       _hist_ll_125_num = Histo1D(refData(3, 1, 2));
00059       _hist_ll_150_num = Histo1D(refData(3, 1, 3));
00060       _hist_ll_240_num = Histo1D(refData(3, 1, 4));
00061 
00062       _hist_ll_100_den = Histo1D(refData(3, 1, 1));
00063       _hist_ll_125_den = Histo1D(refData(3, 1, 2));
00064       _hist_ll_150_den = Histo1D(refData(3, 1, 3));
00065       _hist_ll_240_den = Histo1D(refData(3, 1, 4));
00066     }
00067 
00068     double cosThetaCS(const Particle& l1, const Particle&  l2) {
00069 
00070       FourMomentum mom1 = l1.momentum();
00071       FourMomentum mom2 = l2.momentum();
00072 
00073       double Q = FourMomentum(mom1 + mom2).mass();
00074       double QT = sqrt(pow((mom1.px() + mom2.px()), 2) + pow((mom1.py() + mom2.py()), 2));
00075 
00076       double P1p = 0.0;
00077       double P1m = 0.0;
00078       double P2p = 0.0;
00079       double P2m = 0.0;
00080 
00081 
00082       if (l1.pid() > 0) {
00083         P1p = (mom1.E() + mom1.pz()) / sqrt(2.0);
00084         P1m = (mom1.E() - mom1.pz()) / sqrt(2.0);
00085         P2p = (mom2.E() + mom2.pz()) / sqrt(2.0);
00086         P2m = (mom2.E() - mom2.pz()) / sqrt(2.0);
00087       } else if (l1.pid() < 0) {
00088         P1p = (mom2.E() + mom2.pz()) / sqrt(2.0);
00089         P1m = (mom2.E() - mom2.pz()) / sqrt(2.0);
00090         P2p = (mom1.E() + mom1.pz()) / sqrt(2.0);
00091         P2m = (mom1.E() - mom1.pz()) / sqrt(2.0);
00092       }
00093 
00094       double QZ = mom1.pz() + mom2.pz();
00095       double cosThetaCS = (2 / (Q * sqrt(Q * Q + QT * QT))) * (P1p * P2m - P1m * P2p);
00096       if (QZ < 0.0)
00097         cosThetaCS = -cosThetaCS;
00098 
00099       return cosThetaCS;
00100     }
00101 
00102 
00103     /// Perform the per-event analysis
00104     void analyze(const Event& event) {
00105       const double weight = event.weight();
00106 
00107       const ZFinder& zfinder_el = applyProjection<ZFinder>(event, "zfinder_el");
00108       if (zfinder_el.bosons().size() > 0) {
00109         const Particle& z  = zfinder_el.bosons()[0];
00110         const Particle& l1 = zfinder_el.constituents()[0];
00111         const Particle& l2 = zfinder_el.constituents()[1];
00112 
00113         // Prepare variables for filling
00114         double rap = z.momentum().absrap();
00115         double costhetacs = cosThetaCS(l1, l2);
00116 
00117         double sign = 1.0;
00118         if (costhetacs < 0.) sign = -1.0;
00119         // Fill the histograms
00120         if (rap < 1.0) {
00121           _hist_ee_100_num.fill(z.momentum().mass(), weight * sign);
00122           _hist_ll_100_num.fill(z.momentum().mass(), weight * sign);
00123           _hist_ee_100_den.fill(z.momentum().mass(), weight);
00124           _hist_ll_100_den.fill(z.momentum().mass(), weight);
00125         } else if (rap < 1.25) {
00126           _hist_ee_125_num.fill(z.momentum().mass(), weight * sign);
00127           _hist_ll_125_num.fill(z.momentum().mass(), weight * sign);
00128           _hist_ee_125_den.fill(z.momentum().mass(), weight);
00129           _hist_ll_125_den.fill(z.momentum().mass(), weight);
00130         } else if (rap < 1.50) {
00131           _hist_ee_150_num.fill(z.momentum().mass(), weight * sign);
00132           _hist_ll_150_num.fill(z.momentum().mass(), weight * sign);
00133           _hist_ee_150_den.fill(z.momentum().mass(), weight);
00134           _hist_ll_150_den.fill(z.momentum().mass(), weight);
00135         } else if (rap < 2.40) {
00136           _hist_ee_240_num.fill(z.momentum().mass(), weight * sign);
00137           _hist_ll_240_num.fill(z.momentum().mass(), weight * sign);
00138           _hist_ee_240_den.fill(z.momentum().mass(), weight);
00139           _hist_ll_240_den.fill(z.momentum().mass(), weight);
00140         }
00141       }
00142 
00143       const ZFinder& zfinder_mu = applyProjection<ZFinder>(event, "zfinder_mu");
00144       if (zfinder_mu.bosons().size() > 0) {
00145         const Particle& z  = zfinder_mu.bosons()[0];
00146         const Particle& l1 = zfinder_mu.constituents()[0];
00147         const Particle& l2 = zfinder_mu.constituents()[1];
00148 
00149         // Prepare variables for filling
00150         double rap = z.momentum().absrap();
00151         double costhetacs = cosThetaCS(l1, l2);
00152 
00153         double sign = 1.0;
00154         if (costhetacs < 0.) sign = -1.0;
00155 
00156         // Fill the histograms
00157         if (rap < 1.0) {
00158           _hist_mm_100_num.fill(z.momentum().mass(), weight * sign);
00159           _hist_ll_100_num.fill(z.momentum().mass(), weight * sign);
00160           _hist_mm_100_den.fill(z.momentum().mass(), weight);
00161           _hist_ll_100_den.fill(z.momentum().mass(), weight);
00162         } else if (rap < 1.25) {
00163           _hist_mm_125_num.fill(z.momentum().mass(), weight * sign);
00164           _hist_ll_125_num.fill(z.momentum().mass(), weight * sign);
00165           _hist_mm_125_den.fill(z.momentum().mass(), weight);
00166           _hist_ll_125_den.fill(z.momentum().mass(), weight);
00167         } else if (rap < 1.50) {
00168           _hist_mm_150_num.fill(z.momentum().mass(), weight * sign);
00169           _hist_ll_150_num.fill(z.momentum().mass(), weight * sign);
00170           _hist_mm_150_den.fill(z.momentum().mass(), weight);
00171           _hist_ll_150_den.fill(z.momentum().mass(), weight);
00172         } else if (rap < 2.40) {
00173           _hist_mm_240_num.fill(z.momentum().mass(), weight * sign);
00174           _hist_ll_240_num.fill(z.momentum().mass(), weight * sign);
00175           _hist_mm_240_den.fill(z.momentum().mass(), weight);
00176           _hist_ll_240_den.fill(z.momentum().mass(), weight);
00177         }
00178       }
00179     }
00180 
00181     /// Normalise histograms etc., after the run
00182     void finalize() {
00183       divide(_hist_mm_100_num, _hist_mm_100_den, bookScatter2D(1, 1, 1));
00184       divide(_hist_mm_125_num, _hist_mm_125_den, bookScatter2D(1, 1, 2));
00185       divide(_hist_mm_150_num, _hist_mm_150_den, bookScatter2D(1, 1, 3));
00186       divide(_hist_mm_240_num, _hist_mm_240_den, bookScatter2D(1, 1, 4));
00187 
00188       divide(_hist_ee_100_num, _hist_ee_100_den, bookScatter2D(2, 1, 1));
00189       divide(_hist_ee_125_num, _hist_ee_125_den, bookScatter2D(2, 1, 2));
00190       divide(_hist_ee_150_num, _hist_ee_150_den, bookScatter2D(2, 1, 3));
00191       divide(_hist_ee_240_num, _hist_ee_240_den, bookScatter2D(2, 1, 4));
00192 
00193       divide(_hist_ll_100_num, _hist_ll_100_den, bookScatter2D(3, 1, 1));
00194       divide(_hist_ll_125_num, _hist_ll_125_den, bookScatter2D(3, 1, 2));
00195       divide(_hist_ll_150_num, _hist_ll_150_den, bookScatter2D(3, 1, 3));
00196       divide(_hist_ll_240_num, _hist_ll_240_den, bookScatter2D(3, 1, 4));
00197     }
00198 
00199   private:
00200     /// Histograms
00201     Histo1D _hist_ee_100_num;
00202     Histo1D _hist_ee_125_num;
00203     Histo1D _hist_ee_150_num;
00204     Histo1D _hist_ee_240_num;
00205 
00206     Histo1D _hist_ee_100_den;
00207     Histo1D _hist_ee_125_den;
00208     Histo1D _hist_ee_150_den;
00209     Histo1D _hist_ee_240_den;
00210 
00211     Histo1D _hist_mm_100_num;
00212     Histo1D _hist_mm_125_num;
00213     Histo1D _hist_mm_150_num;
00214     Histo1D _hist_mm_240_num;
00215 
00216     Histo1D _hist_mm_100_den;
00217     Histo1D _hist_mm_125_den;
00218     Histo1D _hist_mm_150_den;
00219     Histo1D _hist_mm_240_den;
00220 
00221     Histo1D _hist_ll_100_num;
00222     Histo1D _hist_ll_125_num;
00223     Histo1D _hist_ll_150_num;
00224     Histo1D _hist_ll_240_num;
00225 
00226     Histo1D _hist_ll_100_den;
00227     Histo1D _hist_ll_125_den;
00228     Histo1D _hist_ll_150_den;
00229     Histo1D _hist_ll_240_den;
00230 
00231   };
00232 
00233 
00234   // The hook for the plugin system
00235   DECLARE_RIVET_PLUGIN(CMS_2013_I1122847);
00236 
00237 }