00001 #include <iostream>
00002 #include <sstream>
00003 #include <stdio.h>
00004 #include "HepMC/GenEvent.h"
00005 #include "HepMC/IO_GenEvent.h"
00006 #include "HepMC/GenParticle.h"
00007 #include "HepMC/GenVertex.h"
00008 #include "HepMC/IO_AsciiParticles.h"
00009 #include "HepMC/SimpleVector.h"
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
00022 #include "../include/TauAnalysis.h"
00023
00024
00025
00026
00027 TauAnalysis::TauAnalysis()
00028 {
00029
00030 }
00031
00032 TauAnalysis::~TauAnalysis()
00033 {
00034 while (!m_histVector.empty())
00035 {
00036 delete m_histVector.back();
00037 m_histVector.pop_back();
00038 }
00039 }
00040
00041 int TauAnalysis::Init(double tr_max_eta, double tr_min_pt)
00042 {
00043
00044 m_max_eta=tr_max_eta;
00045
00046
00047 m_min_pt=tr_min_pt;
00048
00049
00050 m_outputFileName="TauAnalysis.root";
00051 m_outputRootDir="Tau";
00052
00053
00054 m_evtnr=initHist(string("evtnr"),string("Event number"),string("Eventnumber"),100, 0., 99.);
00055 m_taupt=initHist(string("taupt"),string("transversal momentum of tau+ and tau-"),string("p_{T} [GeV]"),50, 0., 100.);
00056 m_taupt_log=initHist(string("taupt_logscale"),string("transversal momentum of tau+ and tau- - logscale -"),
00057 string("p_{T} [GeV]"),50, 0., 100.);
00058 m_taueta=initHist(string("taueta"),string("eta of tau+ and tau-"),string("#eta"),60, -6., 6.);
00059 m_tauphi=initHist(string("tauphi"),string("phi of tau+ and tau-"),string("#phi"),48, -3.15, 3.15);
00060 m_ptstable=initHist(string("ptstable"),string("transveral momentum of stable particles (without neutrinos)"),
00061 string("p_{T} [GeV]"),60, 0., 15.);
00062 m_ptstable_log=initHist(string("ptstable_logscale"),string("transveral momentum of stable particles (without neutrinos) - logscale"),
00063 string("p_{T} [GeV]"),60, 0., 15.);
00064 m_etastable=initHist(string("etastable"),string("eta of stable particles (without neutrinos)"),string("#eta"),100, -6., 6.);
00065 m_phistable=initHist(string("phistable"),string("phi of stable particles (without neutrinos)"),string("#phi"),100, -3.15, 3.15);
00066 m_E_stable=initHist(string("E_stable"),string("energy of stable particles (without neutrinos)"),string("E [GeV]"),50, 0., 100.);
00067 m_E_stable_log=initHist(string("E_stable_logscale"),string("energy of stable particles (without neutrinos) - logscale -"),
00068 string("E [GeV]"),50, 0., 100.);
00069 m_ptstable_charged=initHist(string("ptstable_charged"),string("transveral momentum of charged stable particles"),
00070 string("p_{T} [GeV]"),60, 0., 15.);
00071 m_ptstable_charged_log=initHist(string("ptstable_charged_logscale"),
00072 string("transveral momentum of charged stable particles - logscale -"),
00073 string("p_{T} [GeV]"),60, 0., 15.);
00074 m_etastable_charged=initHist(string("etastable_charged"),string("eta of charged stable particles"),string("#eta"),100, -6., 6.);
00075 m_phistable_charged=initHist(string("phistable_charged"),string("phi of charged stable particles"),string("#phi"),100, -3.15, 3.15);
00076 m_E_stable_charged=initHist(string("E_stable_without_neutrinos"),string("energy of charged stable particles"),
00077 string("E [GeV]"),50, 0., 100.);
00078 m_E_stable_charged_log=initHist(string("E_stable_without_neutrinos_logscale"),
00079 string("energy of charged stable particles - logscale -"),string("E [GeV]"),50, 0., 100.);
00080 m_cmultpart=initHist(string("cmultpart"),string("number of charged particles in the event"),string("charged particle multiplicity"),
00081 120, 0., 600.);
00082 m_nTrack_tau=initHist(string("nTrack_tau"),string("number of tracks of tau decay"),string("number of tracks"),16, -0.5, 15.5);
00083 m_pt_hightrack=initHist(string("pt_hightrack"),string("transversal momentum of highest p_{T}-track"),string("p_{T} [GeV]"),
00084 100, 0., 50.);
00085 m_pt_hightrack_log=initHist(string("pt_hightrack_logscale"),string("transversal momentum of highest p_{T}-track - logscale -"),
00086 string("p_{T} [GeV]"),100, 0., 50.);
00087
00088 m_jet_count=baseAnalysis::initHist(string("jet_count"), string("Nr of Jets"), string("Nr Jets"),16, -0.5, 15.5);
00089 m_jet_pt=baseAnalysis::initHist(string("jet_pt_high"),string("Jet Transverse Momentum"),string("Jet p_{T} [GeV]"), 50, 0.,150.);
00090 m_jet_pt_log=baseAnalysis::initHist(string("jet_pt_high_logscale"),string("Jet Transverse Momentum -logscale-"),string("Jet p_{T} [GeV]"), 50, 0.,150.);
00091
00092 for(unsigned int hist=0; hist< m_histVector.size(); hist++)
00093 {
00094 std::ostringstream counter_s;
00095 counter_s << hist;
00096 std::string histogram_name=m_outputRootDir;
00097 histogram_name+="_";
00098 histogram_name+=counter_s.str();
00099 histogram_name+="_";
00100 histogram_name+=m_histVector[hist]->GetName();
00101 m_histVector[hist]->SetName(histogram_name.c_str());
00102 }
00103 return SUCCESS;
00104 }
00105
00106 int TauAnalysis::Process(HepMC::GenEvent* hepmcevt)
00107 {
00108
00109 int cmult = 0;
00110 int tau_barcode = 0;
00111 int taubar_barcode = 0;
00112
00113
00114 int properStatus = 0;
00115
00116 m_evtnr->Fill(hepmcevt->event_number());
00117
00118
00119 for ( HepMC::GenEvent::particle_const_iterator p =
00120 hepmcevt->particles_begin(); p != hepmcevt->particles_end(); ++p )
00121 {
00122
00123 int pid = (*p)->pdg_id();
00124
00125
00126
00127
00128 if (pid == 23)
00129 {
00130 if (!((*p)->end_vertex()))
00131 {
00132 std::cout<<"CRASH!!!!!"<<std::endl;
00133 std::cout<<"event number: "<<hepmcevt->event_number()<<std::endl;
00134 std::cout<<"pdgId (of Z): "<<pid<<std::endl;
00135 std::cout<<"particle number (Z barcode): "<<(*p)->barcode()<<std::endl;
00136 std::cout<<"(*p)->status(): "<<(*p)->status()<<std::endl;
00137 std::cout<<"(*p)->end_vertex(): "<<(*p)->end_vertex()<<std::endl;
00138
00139 std::cout<<"skip event"<<std::endl;
00140 return FAILURE;
00141 }
00142 for(HepMC::GenVertex::particle_iterator iChild=(*p)->end_vertex()->particles_begin(HepMC::descendants);
00143 iChild!=(*p)->end_vertex()->particles_end(HepMC::descendants); iChild++)
00144 {
00145 if( (*iChild)->pdg_id() != pid )
00146 {
00147 if ((*iChild)->pdg_id() == 15) tau_barcode = (*iChild)->barcode();
00148 if ((*iChild)->pdg_id() == -15) taubar_barcode = (*iChild)->barcode();
00149 }
00150 }
00151 }
00152
00153
00154 properStatus = 1;
00155
00156 if( !(*p)->status() == properStatus) continue;
00157
00158 if(! ( abs(pid)==12 || abs(pid)==14 || abs(pid)==16 ) )
00159 {
00160 m_ptstable->Fill( (*p)->momentum().perp() );
00161 m_ptstable_log->Fill( (*p)->momentum().perp() );
00162 m_etastable->Fill( (*p)->momentum().eta() );
00163 m_phistable->Fill( (*p)->momentum().phi() );
00164 m_E_stable->Fill( (*p)->momentum().e() );
00165 m_E_stable_log->Fill( (*p)->momentum().e() );
00166 }
00167
00168
00169
00170
00171 if(chargedParticle(pid)==NOTCHARGED) continue;
00172
00173 m_ptstable_charged->Fill( (*p)->momentum().perp() );
00174 m_ptstable_charged_log->Fill( (*p)->momentum().perp() );
00175 m_etastable_charged->Fill( (*p)->momentum().eta() );
00176 m_phistable_charged->Fill( (*p)->momentum().phi() );
00177 m_E_stable_charged->Fill( (*p)->momentum().e() );
00178 m_E_stable_charged_log->Fill( (*p)->momentum().e() );
00179
00180 cmult++;
00181 }
00182
00183
00184 CLHEP::HepLorentzVector lv_leadingJet(0,0,0,0);
00185
00186
00187 if(!m_inclusive_jets.size()) {
00188 int test = FindJet(hepmcevt);
00189 if(test<=0){
00190 cout <<"no jets found - return failure" << endl;
00191
00192 }
00193 }
00194
00195
00196 m_jet_count->Fill(m_inclusive_jets.size());
00197
00198 if(m_inclusive_jets.size()){
00199 m_jet_pt->Fill(m_inclusive_jets[0].perp());
00200 m_jet_pt_log->Fill(m_inclusive_jets[0].perp());
00201 }
00202
00203
00204 HepMC::GenParticle *tau = hepmcevt->barcode_to_particle(tau_barcode);
00205 HepMC::GenParticle *taubar = hepmcevt->barcode_to_particle(taubar_barcode);
00206 if(tau && taubar)
00207 {
00208 m_taupt->Fill( tau->momentum().perp() );
00209 m_taupt->Fill( taubar->momentum().perp() );
00210 m_taupt_log->Fill( tau->momentum().perp() );
00211 m_taupt_log->Fill( taubar->momentum().perp() );
00212 m_taueta->Fill( tau->momentum().eta() );
00213 m_taueta->Fill( taubar->momentum().eta() );
00214 m_tauphi->Fill( tau->momentum().phi() );
00215 m_tauphi->Fill( taubar->momentum().phi() );
00216
00217 m_cmultpart->Fill(cmult);
00218 }
00219
00220
00221
00222
00223
00224 if (tau && tau->end_vertex())
00225 {
00226 int nTrack = 0;
00227 double highpT_Track = 0.;
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 for(HepMC::GenVertex::particle_iterator iChild=tau->end_vertex()->particles_begin(HepMC::descendants);
00240 iChild!=tau->end_vertex()->particles_end(HepMC::descendants); iChild++)
00241 {
00242 if (!tau->end_vertex())
00243 {
00244 std::cout<<"CRASH!!!!!"<<std::endl;
00245 std::cout<<"event number: "<<hepmcevt->event_number()<<std::endl;
00246 std::cout<<"particle number (tau barcode): "<<tau->barcode()<<std::endl;
00247 std::cout<<"tau->status(): "<<tau->status()<<std::endl;
00248 std::cout<<"tau->end_vertex(): "<<tau->end_vertex()<<std::endl;
00249
00250 std::cout<<"skip event"<<std::endl;
00251 return FAILURE;
00252 }
00253
00254 if( (*iChild)->pdg_id() != tau->pdg_id() )
00255 {
00256 int iChild_pid = (*iChild)->pdg_id();
00257 properStatus = 1;
00258
00259 if( (*iChild)->status() == properStatus && chargedParticle(iChild_pid)==CHARGED)
00260 {
00261 nTrack = nTrack + 1;
00262 if ( (*iChild)->momentum().perp() > highpT_Track )
00263 {
00264 highpT_Track = (*iChild)->momentum().perp();
00265 }
00266 }
00267 }
00268 }
00269
00270
00271 if (nTrack > 0)
00272 {
00273 m_nTrack_tau->Fill(nTrack);
00274 m_pt_hightrack->Fill(highpT_Track);
00275 m_pt_hightrack_log->Fill(highpT_Track);
00276 }
00277 }
00278
00279
00280
00281 if (taubar && taubar->end_vertex())
00282 {
00283 int nTrack = 0;
00284 double highpT_Track = 0.;
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 if (!taubar->end_vertex())
00296 {
00297 std::cout<<"CRASH!!!!!"<<std::endl;
00298 std::cout<<"event number: "<<hepmcevt->event_number()<<std::endl;
00299 std::cout<<"particle number (tau barcode): "<<taubar->barcode()<<std::endl;
00300 std::cout<<"taubar->status(): "<<taubar->status()<<std::endl;
00301 std::cout<<"taubar->end_vertex(): "<<taubar->end_vertex()<<std::endl;
00302
00303 std::cout<<"skip event"<<std::endl;
00304 return FAILURE;
00305 }
00306
00307
00308 for(HepMC::GenVertex::particle_iterator iChild=taubar->end_vertex()->particles_begin(HepMC::descendants);
00309 iChild!=taubar->end_vertex()->particles_end(HepMC::descendants); iChild++)
00310 {
00311 if( (*iChild)->pdg_id() != taubar->pdg_id() )
00312 {
00313 int iChild_pid = (*iChild)->pdg_id();
00314 properStatus = 1;
00315
00316 if( (*iChild)->status() == properStatus && chargedParticle(iChild_pid)==CHARGED)
00317 {
00318 nTrack = nTrack + 1;
00319 if ( (*iChild)->momentum().perp() > highpT_Track )
00320 {
00321 highpT_Track = (*iChild)->momentum().perp();
00322 }
00323 }
00324 }
00325
00326 }
00327
00328 if (nTrack > 0)
00329 {
00330 m_nTrack_tau->Fill(nTrack);
00331 m_pt_hightrack->Fill(highpT_Track);
00332 m_pt_hightrack_log->Fill(highpT_Track);
00333 }
00334 }
00335 return SUCCESS;
00336 }