MC_PHOTONS.cc
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #include "Rivet/Analysis.hh" 00003 #include "Rivet/Projections/IdentifiedFinalState.hh" 00004 #include "Rivet/Projections/FinalState.hh" 00005 #include "Rivet/Projections/ChargedFinalState.hh" 00006 00007 namespace Rivet { 00008 00009 00010 class MC_PHOTONS : public Analysis { 00011 public: 00012 00013 /// @name Constructors etc. 00014 //@{ 00015 00016 /// Constructor 00017 MC_PHOTONS() 00018 : Analysis("MC_PHOTONS") 00019 { } 00020 00021 //@} 00022 00023 00024 /// @name Analysis methods 00025 //@{ 00026 00027 /// Book histograms and initialise projections before the run 00028 void init() { 00029 IdentifiedFinalState leptons(-5.0, 5.0, 10*GeV); 00030 IdentifiedFinalState photons(-5.0, 5.0); 00031 leptons.acceptChLeptons(); 00032 photons.acceptId(PID::PHOTON); 00033 addProjection(leptons, "lFS"); 00034 addProjection(photons, "gammaFS"); 00035 00036 _h_Ptgamma = bookHisto1D("Ptgamma", logspace(50, 0.01, 30)); 00037 _h_Egamma = bookHisto1D("Egamma", logspace(50, 0.01, 200)); 00038 _h_sumPtgamma = bookHisto1D("sumPtgamma", 50, 0, 100); 00039 _h_sumEgamma = bookHisto1D("sumEgamma", 50, 0, sqrtS()/GeV/5.0); 00040 _h_DelR = bookHisto1D("DeltaR", 50, 0, 2); 00041 _h_DelR_weighted = bookHisto1D("DeltaR_ptweighted", 50, 0, 2); 00042 _h_DelR_R = bookHisto1D("DeltaR_R", 50, 0, 2); 00043 _h_DelR_R_weighted = bookHisto1D("DeltaR_R_ptweighted", 50, 0, 2); 00044 _p_DelR_vs_pTl = bookProfile1D("DeltaR_vs_pTlep", 50, 10, 120); 00045 _p_DelR_weighted_vs_pTl = bookProfile1D("DeltaR_ptweighted_vs_pTlep", 50, 10, 120); 00046 _p_DelR_R_vs_pTl = bookProfile1D("DeltaR_R_vs_pTlep", 50, 10, 120); 00047 _p_DelR_R_weighted_vs_pTl = bookProfile1D("DeltaR_R_ptweighted_vs_pTlep", 50, 10, 120); 00048 _p_sumPtgamma_vs_pTl = bookProfile1D("sumPtGamma_vs_pTlep", 50, 10, 120); 00049 } 00050 00051 00052 /// Perform the per-event analysis 00053 void analyze(const Event& event) { 00054 const double weight = event.weight(); 00055 00056 /// Get photons and leptons 00057 const Particles& photons = applyProjection<FinalState>(event, "gammaFS").particles(); 00058 MSG_DEBUG("Photon multiplicity = " << photons.size()); 00059 const Particles& leptons = applyProjection<FinalState>(event, "lFS").particles(); 00060 MSG_DEBUG("Photon multiplicity = " << leptons.size()); 00061 00062 // Initialise a map of sumPtgamma for each lepton 00063 map<size_t, double> sumpT_per_lep; 00064 for (size_t il = 0; il < leptons.size(); ++il) sumpT_per_lep[il] = 0; 00065 00066 // Calculate photon energies and transverse momenta 00067 double sumPtgamma(0), sumEgamma(0); 00068 foreach (const Particle& p, photons) { 00069 // Individual and summed pTs and energies 00070 double pTgamma = p.pT()/GeV; 00071 double Egamma = p.momentum().E()/GeV; 00072 _h_Ptgamma->fill(pTgamma, weight); 00073 _h_Egamma->fill(Egamma, weight); 00074 sumPtgamma += pTgamma; 00075 sumEgamma += Egamma; 00076 00077 // Calculate delta R with respect to the nearest lepton 00078 int ilep = -1; 00079 double delR = 10000; 00080 for (size_t il = 0; il < leptons.size(); ++il) { 00081 const double tmpdelR = deltaR(leptons[il].momentum(), p.momentum()); 00082 if (tmpdelR < delR) { 00083 ilep = il; 00084 delR = tmpdelR; 00085 } 00086 } 00087 if (ilep != -1) { 00088 _h_DelR->fill(delR, weight); 00089 _h_DelR_weighted->fill(delR, weight*pTgamma/GeV); 00090 _h_DelR_R->fill(delR, weight/(delR+1e-5)); 00091 _h_DelR_R_weighted->fill(delR, weight*pTgamma/GeV/(delR+1e-5)); 00092 _p_DelR_vs_pTl->fill(leptons[ilep].pT()/GeV, delR, weight); 00093 _p_DelR_weighted_vs_pTl->fill(leptons[ilep].pT()/GeV, delR, weight*pTgamma/GeV); 00094 _p_DelR_R_vs_pTl->fill(leptons[ilep].pT()/GeV, delR, weight/(delR+1e-5)); 00095 _p_DelR_R_weighted_vs_pTl->fill(leptons[ilep].pT()/GeV, delR, weight*pTgamma/GeV/(delR+1e-5)); 00096 sumpT_per_lep[ilep] += pTgamma; 00097 } 00098 } 00099 00100 // Histogram whole-event photon HT/energy 00101 _h_sumPtgamma->fill(sumPtgamma/GeV, weight); 00102 _h_sumEgamma->fill(sumEgamma/GeV, weight); 00103 00104 // Histogram per-lepton sum(pT) 00105 for (size_t il = 0; il < leptons.size(); ++il) { 00106 _p_sumPtgamma_vs_pTl->fill(leptons[il].pT()/GeV, sumpT_per_lep[il]/GeV, weight); 00107 } 00108 00109 } 00110 00111 00112 /// Normalise histograms etc., after the run 00113 void finalize() { 00114 normalize(_h_Ptgamma); 00115 normalize(_h_Egamma); 00116 normalize(_h_sumPtgamma); 00117 normalize(_h_sumEgamma); 00118 normalize(_h_DelR); 00119 normalize(_h_DelR_weighted); 00120 normalize(_h_DelR_R); 00121 normalize(_h_DelR_R_weighted); 00122 } 00123 00124 //@} 00125 00126 00127 private: 00128 00129 /// @name Histograms 00130 //@{ 00131 Histo1DPtr _h_Ptgamma, _h_Egamma; 00132 Histo1DPtr _h_sumPtgamma, _h_sumEgamma; 00133 Histo1DPtr _h_DelR, _h_DelR_weighted; 00134 Histo1DPtr _h_DelR_R, _h_DelR_R_weighted; 00135 Profile1DPtr _p_DelR_vs_pTl, _p_DelR_weighted_vs_pTl; 00136 Profile1DPtr _p_DelR_R_vs_pTl, _p_DelR_R_weighted_vs_pTl; 00137 Profile1DPtr _p_sumPtgamma_vs_pTl; 00138 //@} 00139 00140 }; 00141 00142 00143 // The hook for the plugin system 00144 DECLARE_RIVET_PLUGIN(MC_PHOTONS); 00145 00146 00147 } Generated on Fri Oct 25 2013 12:41:46 for The Rivet MC analysis system by ![]() |