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 
00010   class CMS_2013_I1122847 : public Analysis {
00011   public:
00012 
00013     /// Constructor
00014     CMS_2013_I1122847()
00015       : Analysis("CMS_2013_I1122847")  {}
00016 
00017 
00018     /// Book histograms and initialise projections before the run
00019     void init() {
00020       FinalState fs;
00021 
00022       Cut cuts_mu = Cuts::abseta < 2.4 && Cuts::pT > 20*GeV;
00023       ZFinder zfinder_mu(fs, cuts_mu, PID::MUON, 40.0*GeV, MAXDOUBLE,
00024                          0.0, ZFinder::CLUSTERNODECAY, ZFinder::NOTRACK);
00025       declare(zfinder_mu, "zfinder_mu");
00026 
00027       Cut cuts_el = (Cuts::pT >= 20*GeV && Cuts::abseta < 2.4 && !Cuts::absetaIn(1.447, 1.57));
00028       ZFinder zfinder_el(fs, cuts_el, PID::ELECTRON, 40.0*GeV, MAXDOUBLE,
00029                          0.0, ZFinder::CLUSTERNODECAY, ZFinder::NOTRACK);
00030       declare(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 
00069     double cosThetaCS(const Particle& l1, const Particle& l2) {
00070       const FourMomentum mom1 = l1.mom();
00071       const FourMomentum mom2 = l2.mom();
00072       const FourMomentum mom12 = mom1 + mom2;
00073       const double Q = mom12.mass();
00074       const double QT = mom12.pT();
00075       const double QZ = mom12.pz();
00076 
00077       /// @todo Why include factors of sqrt2 which then get immediately multiplied then divided out?
00078       const double sqrt2 = sqrt(2.0);
00079       /// @todo Can be done more nicely via PID-ordered references to mom1, mom2
00080       const double P1p = ((l1.pid() > 0) ? (mom1.E() + mom1.pz()) : (mom2.E() + mom2.pz())) / sqrt2;
00081       const double P1m = ((l1.pid() > 0) ? (mom1.E() - mom1.pz()) : (mom2.E() - mom2.pz())) / sqrt2;
00082       const double P2p = ((l1.pid() > 0) ? (mom2.E() + mom2.pz()) : (mom1.E() + mom1.pz())) / sqrt2;
00083       const double P2m = ((l1.pid() > 0) ? (mom2.E() - mom2.pz()) : (mom1.E() - mom1.pz())) / sqrt2;
00084 
00085       const double cosThetaCS = sign(QZ) * (2 / (Q * add_quad(Q, QT))) * (P1p*P2m - P1m*P2p);
00086       return cosThetaCS;
00087     }
00088 
00089 
00090     /// Perform the per-event analysis
00091     void analyze(const Event& event) {
00092       const double weight = event.weight();
00093 
00094       const ZFinder& zfinder_el = apply<ZFinder>(event, "zfinder_el");
00095       if (zfinder_el.bosons().size() > 0) {
00096         const Particle& z  = zfinder_el.bosons()[0];
00097         const Particle& l1 = zfinder_el.constituents()[0];
00098         const Particle& l2 = zfinder_el.constituents()[1];
00099 
00100         // Prepare variables for filling
00101         const double rap = z.absrap();
00102         const double costhetacs = cosThetaCS(l1, l2);
00103         const double sgn = sign(costhetacs);
00104 
00105         // Fill the histograms
00106         if (rap < 1.0) {
00107           _hist_ee_100_num.fill(z.mass(), weight * sgn);
00108           _hist_ll_100_num.fill(z.mass(), weight * sgn);
00109           _hist_ee_100_den.fill(z.mass(), weight);
00110           _hist_ll_100_den.fill(z.mass(), weight);
00111         } else if (rap < 1.25) {
00112           _hist_ee_125_num.fill(z.mass(), weight * sgn);
00113           _hist_ll_125_num.fill(z.mass(), weight * sgn);
00114           _hist_ee_125_den.fill(z.mass(), weight);
00115           _hist_ll_125_den.fill(z.mass(), weight);
00116         } else if (rap < 1.50) {
00117           _hist_ee_150_num.fill(z.mass(), weight * sgn);
00118           _hist_ll_150_num.fill(z.mass(), weight * sgn);
00119           _hist_ee_150_den.fill(z.mass(), weight);
00120           _hist_ll_150_den.fill(z.mass(), weight);
00121         } else if (rap < 2.40) {
00122           _hist_ee_240_num.fill(z.mass(), weight * sgn);
00123           _hist_ll_240_num.fill(z.mass(), weight * sgn);
00124           _hist_ee_240_den.fill(z.mass(), weight);
00125           _hist_ll_240_den.fill(z.mass(), weight);
00126         }
00127       }
00128 
00129       const ZFinder& zfinder_mu = apply<ZFinder>(event, "zfinder_mu");
00130       if (zfinder_mu.bosons().size() > 0) {
00131         const Particle& z  = zfinder_mu.bosons()[0];
00132         const Particle& l1 = zfinder_mu.constituents()[0];
00133         const Particle& l2 = zfinder_mu.constituents()[1];
00134 
00135         // Prepare variables for filling
00136         const double rap = z.absrap();
00137         const double costhetacs = cosThetaCS(l1, l2);
00138         const double sgn = sign(costhetacs);
00139 
00140         // Fill the histograms
00141         if (rap < 1.0) {
00142           _hist_mm_100_num.fill(z.mass(), weight * sgn);
00143           _hist_ll_100_num.fill(z.mass(), weight * sgn);
00144           _hist_mm_100_den.fill(z.mass(), weight);
00145           _hist_ll_100_den.fill(z.mass(), weight);
00146         } else if (rap < 1.25) {
00147           _hist_mm_125_num.fill(z.mass(), weight * sgn);
00148           _hist_ll_125_num.fill(z.mass(), weight * sgn);
00149           _hist_mm_125_den.fill(z.mass(), weight);
00150           _hist_ll_125_den.fill(z.mass(), weight);
00151         } else if (rap < 1.50) {
00152           _hist_mm_150_num.fill(z.mass(), weight * sgn);
00153           _hist_ll_150_num.fill(z.mass(), weight * sgn);
00154           _hist_mm_150_den.fill(z.mass(), weight);
00155           _hist_ll_150_den.fill(z.mass(), weight);
00156         } else if (rap < 2.40) {
00157           _hist_mm_240_num.fill(z.mass(), weight * sgn);
00158           _hist_ll_240_num.fill(z.mass(), weight * sgn);
00159           _hist_mm_240_den.fill(z.mass(), weight);
00160           _hist_ll_240_den.fill(z.mass(), weight);
00161         }
00162       }
00163     }
00164 
00165 
00166     /// Normalise histograms etc., after the run
00167     void finalize() {
00168       divide(_hist_mm_100_num, _hist_mm_100_den, bookScatter2D(1, 1, 1));
00169       divide(_hist_mm_125_num, _hist_mm_125_den, bookScatter2D(1, 1, 2));
00170       divide(_hist_mm_150_num, _hist_mm_150_den, bookScatter2D(1, 1, 3));
00171       divide(_hist_mm_240_num, _hist_mm_240_den, bookScatter2D(1, 1, 4));
00172 
00173       divide(_hist_ee_100_num, _hist_ee_100_den, bookScatter2D(2, 1, 1));
00174       divide(_hist_ee_125_num, _hist_ee_125_den, bookScatter2D(2, 1, 2));
00175       divide(_hist_ee_150_num, _hist_ee_150_den, bookScatter2D(2, 1, 3));
00176       divide(_hist_ee_240_num, _hist_ee_240_den, bookScatter2D(2, 1, 4));
00177 
00178       divide(_hist_ll_100_num, _hist_ll_100_den, bookScatter2D(3, 1, 1));
00179       divide(_hist_ll_125_num, _hist_ll_125_den, bookScatter2D(3, 1, 2));
00180       divide(_hist_ll_150_num, _hist_ll_150_den, bookScatter2D(3, 1, 3));
00181       divide(_hist_ll_240_num, _hist_ll_240_den, bookScatter2D(3, 1, 4));
00182     }
00183 
00184 
00185   private:
00186 
00187     /// Histograms
00188     Histo1D _hist_ee_100_num, _hist_ee_125_num, _hist_ee_150_num, _hist_ee_240_num;
00189     Histo1D _hist_ee_100_den, _hist_ee_125_den, _hist_ee_150_den, _hist_ee_240_den;
00190     Histo1D _hist_mm_100_num, _hist_mm_125_num, _hist_mm_150_num, _hist_mm_240_num;
00191     Histo1D _hist_mm_100_den, _hist_mm_125_den, _hist_mm_150_den, _hist_mm_240_den;
00192     Histo1D _hist_ll_100_num, _hist_ll_125_num, _hist_ll_150_num, _hist_ll_240_num;
00193     Histo1D _hist_ll_100_den, _hist_ll_125_den, _hist_ll_150_den, _hist_ll_240_den;
00194 
00195   };
00196 
00197 
00198   // The hook for the plugin system
00199   DECLARE_RIVET_PLUGIN(CMS_2013_I1122847);
00200 
00201 }