rivet is hosted by Hepforge, IPPP Durham
MC_WJETS.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analyses/MC_JetAnalysis.hh"
00003 #include "Rivet/Projections/WFinder.hh"
00004 #include "Rivet/Projections/FastJets.hh"
00005 #include "Rivet/Tools/Logging.hh"
00006 #include "Rivet/RivetYODA.hh"
00007 #include "Rivet/Tools/ParticleIdUtils.hh"
00008 #include "Rivet/Analysis.hh"
00009 
00010 namespace Rivet {
00011 
00012 
00013   /// @brief MC validation analysis for W + jets events
00014   class MC_WJETS : public MC_JetAnalysis {
00015   public:
00016 
00017     /// Default constructor
00018     MC_WJETS()
00019       : MC_JetAnalysis("MC_WJETS", 4, "Jets")
00020     {    }
00021 
00022 
00023     /// @name Analysis methods
00024     //@{
00025 
00026     /// Book histograms
00027     void init() {
00028       FinalState fs;
00029       WFinder wfinder(fs, -3.5, 3.5, 25.0*GeV, ELECTRON, 60.0*GeV, 100.0*GeV, 25.0*GeV, 0.2);
00030       addProjection(wfinder, "WFinder");
00031       FastJets jetpro(wfinder.remainingFinalState(), FastJets::KT, 0.7);
00032       addProjection(jetpro, "Jets");
00033 
00034       _h_W_mass = bookHisto1D("W_mass", 50, 55.0, 105.0);
00035       _h_W_pT = bookHisto1D("W_pT", logspace(100, 1.0, 0.5*sqrtS()));
00036       _h_W_pT_peak = bookHisto1D("W_pT_peak", 25, 0.0, 125.0);
00037       _h_W_y = bookHisto1D("W_y", 40, -4.0, 4.0);
00038       _h_W_phi = bookHisto1D("W_phi", 25, 0.0, TWOPI);
00039       _h_W_jet1_deta = bookHisto1D("W_jet1_deta", 50, -5.0, 5.0);
00040       _h_W_jet1_dR = bookHisto1D("W_jet1_dR", 25, 0.5, 7.0);
00041       _h_Wplus_pT = bookHisto1D("Wplus_pT", logspace(25, 10.0, 0.5*sqrtS()));
00042       _h_Wminus_pT = bookHisto1D("Wminus_pT", logspace(25, 10.0, 0.5*sqrtS()));
00043       _h_lepton_pT = bookHisto1D("lepton_pT", logspace(100, 10.0, 0.25*sqrtS()));
00044       _h_lepton_eta = bookHisto1D("lepton_eta", 40, -4.0, 4.0);
00045       _htmp_dsigminus_deta = bookHisto1D("lepton_dsigminus_deta", 20, 0.0, 4.0);
00046       _htmp_dsigplus_deta  = bookHisto1D("lepton_dsigplus_deta", 20, 0.0, 4.0);
00047 
00048       _h_asym = bookScatter2D("W_chargeasymm_eta");
00049       _h_asym_pT = bookScatter2D("W_chargeasymm_pT");
00050 
00051       MC_JetAnalysis::init();
00052     }
00053 
00054 
00055 
00056     /// Do the analysis
00057     void analyze(const Event & e) {
00058       const WFinder& wfinder = applyProjection<WFinder>(e, "WFinder");
00059       if (wfinder.bosons().size() != 1) {
00060         vetoEvent;
00061       }
00062       const double weight = e.weight();
00063 
00064       double charge3_x_eta = 0;
00065       int charge3 = 0;
00066       FourMomentum emom;
00067       FourMomentum wmom(wfinder.bosons().front().momentum());
00068       _h_W_mass->fill(wmom.mass(), weight);
00069       _h_W_pT->fill(wmom.pT(), weight);
00070       _h_W_pT_peak->fill(wmom.pT(), weight);
00071       _h_W_y->fill(wmom.rapidity(), weight);
00072       _h_W_phi->fill(wmom.azimuthalAngle(), weight);
00073       Particle l=wfinder.constituentLeptons()[0];
00074       _h_lepton_pT->fill(l.momentum().pT(), weight);
00075       _h_lepton_eta->fill(l.momentum().eta(), weight);
00076       if (PID::threeCharge(l.pdgId()) != 0) {
00077         emom = l.momentum();
00078         charge3_x_eta = PID::threeCharge(l.pdgId()) * emom.eta();
00079         charge3 = PID::threeCharge(l.pdgId());
00080       }
00081       assert(charge3_x_eta != 0);
00082       assert(charge3!=0);
00083       if (emom.Et() > 30/GeV) {
00084         if (charge3_x_eta < 0) {
00085           _htmp_dsigminus_deta->fill(emom.eta(), weight);
00086         } else {
00087           _htmp_dsigplus_deta->fill(emom.eta(), weight);
00088         }
00089       }
00090       if (charge3 < 0) {
00091         _h_Wminus_pT->fill(wmom.pT(), weight);
00092       } else {
00093         _h_Wplus_pT->fill(wmom.pT(), weight);
00094       }
00095 
00096       const FastJets& jetpro = applyProjection<FastJets>(e, "Jets");
00097       const Jets& jets = jetpro.jetsByPt(20.0*GeV);
00098       if (jets.size() > 0) {
00099         _h_W_jet1_deta->fill(wmom.eta()-jets[0].momentum().eta(), weight);
00100         _h_W_jet1_dR->fill(deltaR(wmom, jets[0].momentum()), weight);
00101       }
00102 
00103       MC_JetAnalysis::analyze(e);
00104     }
00105 
00106 
00107     /// Finalize
00108     void finalize() {
00109       scale(_h_W_mass, crossSection()/sumOfWeights());
00110       scale(_h_W_pT, crossSection()/sumOfWeights());
00111       scale(_h_W_pT_peak, crossSection()/sumOfWeights());
00112       scale(_h_W_y, crossSection()/sumOfWeights());
00113       scale(_h_W_phi, crossSection()/sumOfWeights());
00114       scale(_h_W_jet1_deta, crossSection()/sumOfWeights());
00115       scale(_h_W_jet1_dR, crossSection()/sumOfWeights());
00116       scale(_h_lepton_pT, crossSection()/sumOfWeights());
00117       scale(_h_lepton_eta, crossSection()/sumOfWeights());
00118 
00119       // Construct asymmetry: (dsig+/deta - dsig-/deta) / (dsig+/deta + dsig-/deta) for each Et region
00120       divide(*_htmp_dsigplus_deta - *_htmp_dsigminus_deta,
00121          *_htmp_dsigplus_deta + *_htmp_dsigminus_deta,
00122          _h_asym);
00123 
00124       // // W charge asymmetry vs. pTW: dsig+/dpT / dsig-/dpT
00125       divide(_h_Wplus_pT, _h_Wminus_pT, 
00126          _h_asym_pT);
00127 
00128       scale(_h_Wplus_pT, crossSection()/sumOfWeights());
00129       scale(_h_Wminus_pT, crossSection()/sumOfWeights());
00130 
00131       MC_JetAnalysis::finalize();
00132     }
00133 
00134     //@}
00135 
00136 
00137   private:
00138 
00139     /// @name Histograms
00140     //@{
00141     Histo1DPtr _h_W_mass;
00142     Histo1DPtr _h_W_pT;
00143     Histo1DPtr _h_W_pT_peak;
00144     Histo1DPtr _h_W_y;
00145     Histo1DPtr _h_W_phi;
00146     Histo1DPtr _h_W_jet1_deta;
00147     Histo1DPtr _h_W_jet1_dR;
00148     Histo1DPtr _h_Wplus_pT;
00149     Histo1DPtr _h_Wminus_pT;
00150     Histo1DPtr _h_lepton_pT;
00151     Histo1DPtr _h_lepton_eta;
00152 
00153     Histo1DPtr _htmp_dsigminus_deta;
00154     Histo1DPtr _htmp_dsigplus_deta;
00155 
00156     Scatter2DPtr _h_asym;
00157     Scatter2DPtr _h_asym_pT;
00158 
00159 
00160     //@}
00161 
00162   };
00163 
00164 
00165 
00166   // The hook for the plugin system
00167   DECLARE_RIVET_PLUGIN(MC_WJETS);
00168 
00169 }