00001 #include <iostream>
00002 #include <stdio.h>
00003 #include "HepMC/GenEvent.h"
00004 #include "HepMC/IO_GenEvent.h"
00005 #include "HepMC/GenParticle.h"
00006 #include "HepMC/GenVertex.h"
00007 #include "HepMC/IO_AsciiParticles.h"
00008 #include "HepMC/SimpleVector.h"
00009 #include "HepPDT/ParticleData.hh"
00010 #include "CLHEP/Vector/LorentzVector.h"
00011
00012 using namespace std;
00013
00014
00015 #include "TH1.h"
00016 #include <TH2.h>
00017 #include "TFile.h"
00018 #include "TMath.h"
00019 #include "TLorentzVector.h"
00020
00021 #include "fastjet/PseudoJet.hh"
00022 #include "fastjet/ClusterSequence.hh"
00023 #include "fastjet/JetDefinition.hh"
00024 #include "fastjet/SISConePlugin.hh"
00025
00026
00027 #include "../include/WplusJetAnalysis.h"
00028
00029
00030
00031
00032
00033
00034 WplusJetAnalysis::WplusJetAnalysis()
00035 {
00036
00037 }
00038
00039
00040
00041
00042 WplusJetAnalysis::~WplusJetAnalysis()
00043 {
00044 while (!m_histVector.empty()){
00045 delete m_histVector.back();
00046 m_histVector.pop_back();
00047 }
00048 }
00049
00050
00051
00052
00053 int WplusJetAnalysis::Init(double tr_max_eta, double tr_min_pt)
00054 {
00055
00056 m_max_eta=tr_max_eta;
00057
00058
00059 m_min_pt=tr_min_pt;
00060
00061
00062 m_outputFileName="WplusJetAnalysis.root";
00063 m_outputRootDir="WplusJet";
00064
00065
00066
00067
00068 m_W_count=baseAnalysis::initHist(string("W_count"), string("Nr of W-Bosons"), string("Nr W-Boson"),16, -0.5, 15.5);
00069 m_W_trans_mass=baseAnalysis::initHist(string("W_trans_mass"),string("transvers W Mass"),string("m_{T,W} [GeV]"), 100, 0., 100.);
00070 m_W_trans_mass_log=baseAnalysis::initHist(string("W_trans_mass_logscale"),string("transvers W Mass -logscale-"),string("m_{T,W} [GeV]"), 100, 0., 100.);
00071 m_W_pt=baseAnalysis::initHist(string("W_pt"),string("W Transverse Momentum"),string("W p_{T} [GeV]"), 50, 0., 25.);
00072 m_W_pt_log=baseAnalysis::initHist(string("W_pt_logscale"),string("W Transverse Momentum -logscale-"),string("W p_{T} [GeV]"), 50, 0., 25.);
00073 m_W_pt_high=baseAnalysis::initHist(string("W_pt_high"),string("W Transverse Momentum"),string("W p_{T} [GeV]"), 50, 0., 150.);
00074 m_W_pt_high_log=baseAnalysis::initHist(string("W_pt_high_logscale"),string("W Transverse Momentum -logscale-"),string("W p_{T} [GeV]"), 50, 0., 150.);
00075 m_W_eta=baseAnalysis::initHist(string("W_eta"),string("#eta W-Boson"),string("#eta"), 60, -6., 6.);
00076 m_W_rapidity=baseAnalysis::initHist(string("W_rapidity"),string("rapidity y W-Boson"),string("y"), 60, -6., 6.);
00077 m_W_phi=baseAnalysis::initHist(string("W_phi"),string("#varphi W-Boson"),string("#varphi"), 64, -3.2, 3.2);
00078
00079 m_lepton_count=baseAnalysis::initHist(string("lepton_count"), string("Nr of Leptons from W-Bosons"), string("Nr Leptons"),11, -0.5, 10.5);
00080 m_lepton_pt=baseAnalysis::initHist(string("lepton_pt_high"),string("Transverse Momentum Lepton from W-Boson"),string("lepton p_{T} [GeV]"), 50, 0., 25.);
00081 m_lepton_pt_log=baseAnalysis::initHist(string("lepton_pt_high_logscale"),string("Transverse Momentum Lepton from W-Boson -logscale-"),string("lepton p_{T} [GeV]"), 50, 0., 25.);
00082 m_lepton_pt_high=baseAnalysis::initHist(string("lepton_pt_high"),string("Transverse Momentum Lepton from W-Boson"),string("lepton p_{T} [GeV]"), 50, 0., 150.);
00083 m_lepton_pt_high_log=baseAnalysis::initHist(string("lepton_pt_high_logscale"),string("Transverse Momentum Lepton from W-Boson -logscale-"),string("lepton p_{T} [GeV]"), 50, 0., 150.);
00084 m_lepton_eta=baseAnalysis::initHist(string("lepton_eta"),string("#eta Lepton from W-Boson"),string("#eta"), 60, -6., 6.);
00085 m_lepton_phi=baseAnalysis::initHist(string("lepton_phi"),string("#varphi Lepton from W-Boson"),string("#varphi"), 64, -3.2, 3.2);
00086 m_lepton_pdgid=baseAnalysis::initHist(string("lepton_pdgid"),string("PDG ID Lepton from W-Boson"),string("PDG ID"), 40, -20., 20.);
00087
00088 m_charged_particle_multiplicity=baseAnalysis::initHist(string("charged_particle_multiplicity"),string("Number of charged Particles in the Event"),string("charged particle multiplicity"),100, 0., 300.);
00089 m_charged_particle_temp_pt= new TH1D("WplusJet_charged_particle_mean_pt","temp histogramm",200,0,200.);
00090 m_charged_particle_pt= new TH1D("WplusJet_charged_particle_pt","p_{T} of stable charged particles",200,0,200.);
00091 m_charged_particle_mean_pt=baseAnalysis::initHist(string("charged_particle_mean_pt"),string("Avarage p_{T} charged Particles in the Event"),string("charged particle #bar{p}_{T}"),50, 0., 10.);
00092 m_charged_particle_rms_pt=baseAnalysis::initHist(string("charged_particle_rms_pt"),string("RMS p_{T} charged Particles in the Event"),string("charged particle #sigma(p_{T})"),50, 0., 10.);
00093
00094
00095 m_jet_count=baseAnalysis::initHist(string("jet_count"), string("Nr of Jets"), string("Nr Jets"),16, -0.5, 15.5);
00096 m_jet_pt=baseAnalysis::initHist(string("jet_pt_high"),string("Jet Transverse Momentum"),string("Jet p_{T} [GeV]"), 50, 0.,150.);
00097 m_jet_pt_log=baseAnalysis::initHist(string("jet_pt_high_logscale"),string("Jet Transverse Momentum -logscale-"),string("Jet p_{T} [GeV]"), 50, 0.,150.);
00098
00099 m_jet_Deta_leadingJet_lepton=baseAnalysis::initHist(string("jet_Deta_leadingJet_lepton"),string("#Delta#eta leading Jet and Lepton from W-Boson"),string("#Delta#eta"), 60, 0., 6.);
00100 m_jet_Deta_leadingJet_lepton_singlejet=baseAnalysis::initHist(string("jet_Deta_leadingJet_lepton_singlejet"),string("#Delta#eta leading Jet (single) and Lepton from W-Boson"),string("#Delta#eta"), 60, 0., 6.);
00101 m_jet_Deta_leadingJet_lepton_multijet=baseAnalysis::initHist(string("jet_Deta_leadingJet_lepton_multijet"),string("#Delta#eta leading Jet (multi) and Lepton from W-Boson"),string("#Delta#eta"), 60, 0., 6.);
00102
00103 m_jet_Dphi_leadingJet_lepton=baseAnalysis::initHist(string("jet_Dphi_leadingJet_lepton"),string("#Delta#varphi leading Jet and Lepton from W-Boson"),string("#Delta#varphi"), 64, 0., 3.2);
00104 m_jet_Dphi_leadingJet_lepton_singlejet=baseAnalysis::initHist(string("jet_Dphi_leadingJet_lepton_singlejet"),string("#Delta#varphi leading Jet (single) and Lepton from W-Boson"),string("#Delta#varphi"), 64, 0., 3.2);
00105 m_jet_Dphi_leadingJet_lepton_multijet=baseAnalysis::initHist(string("jet_Dphi_leadingJet_lepton_multijet"),string("#Delta#varphi leading Jet (multi) and Lepton from W-Boson"),string("#Delta#varphi"), 64, 0., 3.2);
00106
00107 m_jet_DR_leadingJet_lepton=baseAnalysis::initHist(string("jet_DR_leadingJet_lepton"),string("#DeltaR leading Jet and Lepton from W-Boson"),string("#DeltaR"), 60, 0., 15.);
00108 m_jet_DR_leadingJet_lepton_singlejet=baseAnalysis::initHist(string("jet_DR_leadingJet_lepton_singlejet"),string("#DeltaR leading Jet (single) and Lepton from W-Boson"),string("#DeltaR"), 60, 0., 15.);
00109 m_jet_DR_leadingJet_lepton_multijet=baseAnalysis::initHist(string("jet_DR_leadingJet_lepton_multijet"),string("#DeltaR leading Jet (multi) and Lepton from W-Boson"),string("#DeltaR"), 60, 0., 15.);
00110
00111 for(unsigned int hist=0; hist< m_histVector.size(); hist++)
00112 {
00113 std::ostringstream counter_s;
00114 counter_s << hist;
00115 std::string histogram_name=m_outputRootDir;
00116 histogram_name+="_";
00117 histogram_name+=counter_s.str();
00118 histogram_name+="_";
00119 histogram_name+=m_histVector[hist]->GetName();
00120 m_histVector[hist]->SetName(histogram_name.c_str());
00121 }
00122
00123 return SUCCESS;
00124
00125 }
00126
00127
00128
00129
00130
00131 int WplusJetAnalysis::Process(HepMC::GenEvent* hepmcevt)
00132 {
00133
00134
00135 CLHEP::HepLorentzVector lv_leptonFromW(0,0,0,0);
00136 CLHEP::HepLorentzVector lv_neutrinoFromW(0,0,0,0);
00137 HepMC::GenParticle* leptonFromW=0;
00138 HepMC::GenParticle* neutrinoFromW=0;
00139
00140
00141
00142 m_charged_particle_temp_pt->Reset();
00143
00144
00145
00146
00147
00148 int Wcount=0;
00149 int leptoncount=0;
00150 int chargeParticlecount=0;
00151
00152
00153 for ( HepMC::GenEvent::particle_const_iterator p = hepmcevt->particles_begin(); p != hepmcevt->particles_end(); ++p )
00154 {
00155
00156 HepMC::GenParticle* WBoson=0;
00157
00158
00159 int pid = (*p)->pdg_id();
00160
00161
00162
00163 if( abs(pid) == 24 && (*p)->end_vertex() ){
00164
00165 if (!(*p)->end_vertex()) continue;
00166
00167 HepMC::GenVertex::particle_iterator firstChild = (*p)->end_vertex()->particles_begin(HepMC::children);
00168 HepMC::GenVertex::particle_iterator endChild = (*p)->end_vertex()->particles_end(HepMC::children);
00169
00170 if( (*firstChild)->pdg_id() != pid ){
00171 WBoson = (*p);
00172 m_W_pt->Fill((*p)->momentum().perp());
00173 m_W_pt_log->Fill((*p)->momentum().perp());
00174 m_W_pt_high->Fill((*p)->momentum().perp());
00175 m_W_pt_high_log->Fill((*p)->momentum().perp());
00176 m_W_eta->Fill((*p)->momentum().eta());
00177 m_W_rapidity->Fill(baseAnalysis::getRapidity(p));
00178 m_W_phi->Fill((*p)->momentum().phi());
00179 Wcount++;
00180 }
00181
00182 bool WtoLepton=false;
00183
00184 for(HepMC::GenVertex::particle_iterator iter=firstChild ; iter!=endChild; iter++)
00185 {
00186
00187 if(abs((*iter)->pdg_id())==12 || abs((*iter)->pdg_id())==14 || abs((*iter)->pdg_id())==16){
00188 neutrinoFromW=(*iter);
00189 lv_neutrinoFromW.setPx((*iter)->momentum().px());
00190 lv_neutrinoFromW.setPy((*iter)->momentum().py());
00191 lv_neutrinoFromW.setPz((*iter)->momentum().pz());
00192 lv_neutrinoFromW.setE((*iter)->momentum().e());
00193 }
00194
00195 if(abs((*iter)->pdg_id())==11 || abs((*iter)->pdg_id())==13 || abs((*iter)->pdg_id())==15) {
00196 leptonFromW=*iter;
00197 WtoLepton=true;
00198 m_lepton_pdgid->Fill((*iter)->pdg_id());
00199 lv_leptonFromW.setPx((*iter)->momentum().px());
00200 lv_leptonFromW.setPy((*iter)->momentum().py());
00201 lv_leptonFromW.setPz((*iter)->momentum().pz());
00202 lv_leptonFromW.setE((*iter)->momentum().e());
00203 }
00204 }
00205
00206 if(!WtoLepton) continue;
00207
00208
00209 m_lepton_pt->Fill(lv_leptonFromW.perp());
00210 m_lepton_pt_log->Fill(lv_leptonFromW.perp());
00211 m_lepton_pt_high->Fill(lv_leptonFromW.perp());
00212 m_lepton_pt_high_log->Fill(lv_leptonFromW.perp());
00213 m_lepton_eta->Fill(lv_leptonFromW.eta());
00214 m_lepton_phi->Fill(lv_leptonFromW.phi());
00215 leptoncount++;
00216
00217
00218
00219
00220 CLHEP::HepLorentzVector lv_transverse_leptonFromW(lv_leptonFromW.px(),lv_leptonFromW.py(),0,lv_leptonFromW.perp());
00221 CLHEP::HepLorentzVector lv_transverse_neutrinoFromW(lv_neutrinoFromW.px(),lv_neutrinoFromW.py(),0,lv_neutrinoFromW.perp());
00222 CLHEP::HepLorentzVector lv_transverse_W(lv_transverse_leptonFromW);
00223 lv_transverse_W+=lv_transverse_neutrinoFromW;
00224 m_W_trans_mass->Fill(lv_transverse_W.m());
00225 m_W_trans_mass_log->Fill(lv_transverse_W.m());
00226
00227 }
00228
00229
00230
00231
00232 if(chargedParticle(pid)==NOTCHARGED) continue;
00233
00234
00235
00236 if (!((*p)->status() == 1)) continue;
00237
00238 if (!(*p)->production_vertex()) continue;
00239
00240 if ((*p)->end_vertex()) continue;
00241
00242
00243 if(abs((*p)->momentum().eta()) > m_max_eta) continue;
00244
00245
00246 if((*p)->momentum().perp() < m_min_pt) continue;
00247
00248
00249 if(((abs(pid)==11) || (abs(pid)==13)) && trackfromPID(23,(*p))) continue;
00250
00251
00252 if(((abs(pid)==11) || (abs(pid)==13)) && trackfromPID(24,(*p))) continue;
00253 if(((abs(pid)==11) || (abs(pid)==13)) && trackfromPID(-24,(*p))) continue;
00254
00255
00256
00257
00258 m_charged_particle_pt->Fill((*p)->momentum().perp());
00259 m_charged_particle_temp_pt->Fill((*p)->momentum().perp());
00260 chargeParticlecount++;
00261
00262
00263 }
00264
00265
00266 CLHEP::HepLorentzVector lv_leadingJet(0,0,0,0);
00267
00268
00269 if(!m_inclusive_jets.size()) {
00270 int test = FindJet(hepmcevt);
00271 if(!test) {
00272 cout <<"no jets found - return failure" << endl;
00273
00274 }
00275 }
00276
00277
00278 m_W_count->Fill(Wcount);
00279 m_lepton_count->Fill(leptoncount);
00280 m_charged_particle_multiplicity->Fill(chargeParticlecount);
00281 m_charged_particle_mean_pt->Fill(m_charged_particle_temp_pt->GetMean());
00282 m_charged_particle_rms_pt->Fill(m_charged_particle_temp_pt->GetRMS());
00283
00284 m_jet_count->Fill(m_inclusive_jets.size());
00285
00286
00287 m_charged_particle_temp_pt->Reset();
00288
00289 if(m_inclusive_jets.size()){
00290
00291 m_jet_pt->Fill(m_inclusive_jets[0].perp());
00292 m_jet_pt_log->Fill(m_inclusive_jets[0].perp());
00293
00294 CLHEP::HepLorentzVector lv_firstJet(m_inclusive_jets[0].px(), m_inclusive_jets[0].py(), m_inclusive_jets[0].pz(), m_inclusive_jets[0].e());
00295
00296 if(leptonFromW) {
00297 if(leptoncount>1)
00298 std::cout << "WplusJetAnalysis: WARNING: You have more than one Lepton from W-Boson in the event!" << std::endl;
00299 m_jet_DR_leadingJet_lepton->Fill(abs(lv_firstJet.deltaR(lv_leptonFromW)));
00300 m_jet_Deta_leadingJet_lepton->Fill(abs(lv_firstJet.eta()-lv_leptonFromW.eta()));
00301 m_jet_Dphi_leadingJet_lepton->Fill(abs(lv_firstJet.vect().deltaPhi(lv_leptonFromW.vect())));
00302
00303
00304
00305 if(m_inclusive_jets.size() > 1 ) {
00306 m_jet_DR_leadingJet_lepton_multijet->Fill(abs(lv_firstJet.deltaR(lv_leptonFromW)));
00307 m_jet_Deta_leadingJet_lepton_multijet->Fill(abs(lv_firstJet.eta()-lv_leptonFromW.eta()));
00308 m_jet_Dphi_leadingJet_lepton_multijet->Fill(abs(lv_firstJet.vect().deltaPhi(lv_leptonFromW.vect())));
00309 }
00310 else{
00311 m_jet_DR_leadingJet_lepton_singlejet->Fill(abs(lv_firstJet.deltaR(lv_leptonFromW)));
00312 m_jet_Deta_leadingJet_lepton_singlejet->Fill(abs(lv_firstJet.eta()-lv_leptonFromW.eta()));
00313 m_jet_Dphi_leadingJet_lepton_singlejet->Fill(abs(lv_firstJet.vect().deltaPhi(lv_leptonFromW.vect())));
00314 }
00315 }
00316
00317 }
00318
00319 return SUCCESS;
00320 }