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