WtaunuAnalysis.cc

Go to the documentation of this file.
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 "HepPDT/ParticleData.hh"
00011 #include "CLHEP/Vector/LorentzVector.h"
00012 
00013 using namespace std;
00014 
00015 // ROOT headers
00016 #include "TH1.h"
00017 #include "TMath.h"
00018 #include "TLorentzVector.h"
00019 
00020 // fastjet headers
00021 #include "fastjet/PseudoJet.hh"
00022 #include "fastjet/ClusterSequence.hh"
00023 #include "fastjet/JetDefinition.hh"
00024 #include "fastjet/SISConePlugin.hh"
00025 
00026 // header for this analysis class
00027 #include "../include/WtaunuAnalysis.h"
00028 
00029 //**********************
00030 
00031 /// empty default constructor
00032 WtaunuAnalysis::WtaunuAnalysis()
00033 {
00034 }
00035 
00036 /// empty default destructor
00037 WtaunuAnalysis::~WtaunuAnalysis()
00038 {
00039 }
00040 
00041 
00042 int WtaunuAnalysis::Init(double tr_max_eta, double tr_min_pt)
00043 {
00044   // specify default eta cut
00045   m_max_eta=tr_max_eta;
00046   
00047   // specify default pt cut
00048   m_min_pt=tr_min_pt;
00049   
00050   // default Output file name
00051   m_outputFileName="WtaunuAnalysis.root";
00052   m_outputRootDir="Wtaunu";
00053 
00054   //declaration of histograms
00055   m_W_count=initHist("W_count","number of W-bosons in the event","W-bosons multiplicity",6, 0.,3.);
00056   m_W_charge=initHist("W_charge","charge of W-bosons in the event","W-bosons charge",10, -2., 2.);
00057   m_W_mass=initHist("W_mass","W mass","m_{W} [GeV]", 80, 60., 100.);
00058   m_W_mt=initHist(string("W_mt"),string("transverse W mass"),string("m_{T,W} [GeV]"), 120, 0., 120.);
00059   m_W_trans_mass=initHist(string("W_trans_mass"),string("transverse W mass"),string("m_{T,W} [GeV]"), 120, 0., 120.);
00060   m_W_pt=initHist("W_pt","transverse momentum of W","p_{T} [GeV]",200, 0., 200.);
00061   m_W_eta=initHist("W_eta","eta of W and anti W","#eta",60, -6., 6.);
00062   m_W_phi=initHist("W_phi","phi of W and anti W","#phi",48, -3.15, 3.15);
00063   m_W_rapidity=initHist("W_rapidity","rapidity y W-Boson","y", 60, -6., 6.);
00064 
00065   m_charged_particle=initHist("charged_particle","number of charged particles in the event","charged particle multiplicity",100, 0., 200.);
00066   m_charged_particle_pdgID=initHist("charged_particle_pdgID","charged Particles PDG ID","charged particle pid",601, -300., 300.);
00067   m_ptstable_charged=initHist("ptstable_charged","transveral momentum of charged stable particles","p_{T} [GeV]",200, 0., 20.);
00068   m_etastable_charged=initHist("etastable_charged","eta of charged stable particles","#eta",100, -6., 6.);
00069   m_phistable_charged=initHist("phistable_charged","phi of charged stable particles","#phi",100, -3.15, 3.15);
00070 
00071   m_tau_mass=initHist("tau_mass","tau mass","m_{#tau} [GeV]", 50, 0., 3.);
00072   m_tau_pt=initHist("tau_pt","transverse momentum of tau","p_{T} [GeV]",200, 0., 200.);
00073   m_tau_eta=initHist(string("tau_eta"),string("eta of tau and anti tau"),string("#eta"),60, -6., 6.);
00074   m_tau_phi=initHist(string("tau_phi"),string("phi of tau and anti tau"),string("#phi"),48, -3.15, 3.15);
00075   m_nTrack_tau=initHist(string("nTrack_tau"),string("number of tracks of tau decay"),string("number of tracks"),16, -0.5, 15.5);
00076 
00077   m_Delta_Phi_TauNeutrino=initHist("Delta_Phi_TauNeutrino","phi between tau and neutrino","#Delta #phi",48, -4.15, 4.15);
00078 
00079   m_nu_pt=initHist("nu_pt","transverse momentum of neutrino","p_{T} [GeV]",200, 0., 200.);
00080   m_nu_px=initHist("nu_px","momentum in x direction of neutrino","p_{x} [GeV]",301, -150., 150.);
00081   m_nu_py=initHist("nu_py","momentum in y direction of neutrino","p_{y} [GeV]",301, -150., 150.);
00082   m_nu_pz=initHist("nu_pz","momentum in z direction of neutrino","p_{z} [GeV]",301, -150., 150.);
00083   m_zoom_nu_px1=initHist("nu_zoom_px", "momentum in x direction of neutrino zoomed", "p_{x} [GeV]",123, -20., 20.);
00084   m_zoom_nu_py1=initHist("nu_zoom_py", "momentum in y direction of neutrino zoomed", "p_{y} [GeV]",123, -20., 20.);
00085   m_zoom_nu_pz1=initHist("nu_zoom_pz", "momentum in z direction of neutrino zoomed", "p_{z} [GeV]",123, -20., 20.);
00086 
00087   return true; 
00088 }
00089 
00090 int WtaunuAnalysis::Process(HepMC::GenEvent* hepmcevt)
00091 { 
00092 
00093   //some variables for storage are needed
00094   int W_barcode=0;
00095   int Wbar_barcode=0;
00096   int tau_barcode=0;
00097   int taubar_barcode=0;
00098   int nu_tau_barcode=0;
00099   int nubar_tau_barcode=0;
00100 
00101   //variables to count the number of W bosons and charged particles
00102   int Wcount=0;
00103   int charged_particle_counter=0;
00104 
00105   int properStatus = 0;
00106 
00107   bool tau_found = false;
00108   bool anti_tau_found = false;
00109   bool neutrino_found = false;
00110   bool anti_neutrino_found = false;
00111 
00112   //calculating rapidity
00113   double rapidity= -999;
00114 
00115   // loop over the particles and select pdgid and pt
00116   for ( HepMC::GenEvent::particle_const_iterator p = hepmcevt->particles_begin(); p != hepmcevt->particles_end(); ++p )
00117     {
00118       // use the pdg id to identify the particles
00119       int pid = (*p)->pdg_id();
00120       
00121       //search for decaying W+ bosons
00122       if (pid == 24 && (*p)->end_vertex())
00123         { 
00124           //prove decay of the W+ boson
00125           if (!(*p)->end_vertex()) continue;
00126           
00127           //loop over all decay particles of the W+ boson
00128           for(HepMC::GenVertex::particle_iterator iter=(*p)->end_vertex()->particles_begin(HepMC::descendants); 
00129               iter!=(*p)->end_vertex()->particles_end(HepMC::descendants); iter++)
00130             {
00131               if( (*iter)->pdg_id() != pid )
00132                 {
00133                   //search for anti-tau and tau_neutrino as decay products
00134                   if ((*iter)->pdg_id() == -15) 
00135                     {
00136                       taubar_barcode = (*iter)->barcode();
00137                       anti_tau_found=true;
00138                     }
00139                   if ((*iter)->pdg_id() == 16)
00140                     {
00141                       nu_tau_barcode = (*iter)->barcode();
00142                       neutrino_found=true;
00143                     }
00144                 }
00145             }
00146           
00147           //if W+ decays into anti-tau and tau_neutrino, then fill barcode
00148           if (anti_tau_found==true && neutrino_found==true )
00149             {
00150               W_barcode = (*p)->barcode();
00151             }
00152           //calculate rapidity of W boson
00153           rapidity = getRapidity(p);
00154         }
00155          
00156       //search for decaying W- bosons
00157       if (pid == -24 && (*p)->end_vertex())
00158         { 
00159           //prove decay of the W- boson
00160           if (!(*p)->end_vertex()) continue;
00161           
00162           //loop over all decay particles of the W- boson
00163           for(HepMC::GenVertex::particle_iterator iter=(*p)->end_vertex()->particles_begin(HepMC::descendants); 
00164               iter!=(*p)->end_vertex()->particles_end(HepMC::descendants); iter++)
00165             {
00166               if( (*iter)->pdg_id() != pid )
00167                 {
00168                   //search for tau and tau_anti-neutrino as decay products
00169                   if ((*iter)->pdg_id() == 15) 
00170                     {
00171                       tau_barcode = (*iter)->barcode();
00172                       tau_found=true;
00173                     }
00174                   if ((*iter)->pdg_id() == -16)
00175                     {
00176                       nubar_tau_barcode = (*iter)->barcode();
00177                       anti_neutrino_found=true;
00178                     }
00179                 }
00180             }
00181 
00182           //if W- decays into tau and anti-tau_neutrino, then fill barcode
00183           if (tau_found==true && anti_neutrino_found==true )
00184             {
00185               Wbar_barcode = (*p)->barcode();
00186             }
00187           //calculate rapidity of W boson
00188           rapidity = getRapidity(p);
00189         }
00190       
00191       //check if final state particle
00192       if(!IsFinalStateParticle((*p))) continue;
00193       
00194       //check all the charge final state particles
00195       if(!chargedParticle(pid)) continue;
00196       
00197       //write out the pt, eta and phi for the charged stable paricles
00198       m_ptstable_charged->Fill( (*p)->momentum().perp() );
00199       m_etastable_charged->Fill( (*p)->momentum().eta() );
00200       m_phistable_charged->Fill( (*p)->momentum().phi() );
00201       m_charged_particle_pdgID->Fill(pid);
00202       charged_particle_counter++;
00203       
00204     } //end particle loop
00205   
00206   //Fill number of charged particles
00207   m_charged_particle->Fill(charged_particle_counter);
00208   
00209   //Define W+ and W- 
00210   HepMC::GenParticle *W = hepmcevt->barcode_to_particle(W_barcode);
00211   HepMC::GenParticle *Wbar = hepmcevt->barcode_to_particle(Wbar_barcode);
00212   
00213   if (W)
00214     {
00215       //calculate transverse mass of the W-boson
00216       CLHEP::HepLorentzVector W_momentum(0.,0.,0.,0.);
00217       W_momentum.setPx(W->momentum().px());
00218       W_momentum.setPy(W->momentum().py());
00219       W_momentum.setPz(W->momentum().pz());
00220       W_momentum.setE(W->momentum().e());
00221       
00222       m_W_pt->Fill( W->momentum().perp() );
00223       m_W_eta->Fill( W->momentum().eta() );
00224       m_W_phi->Fill( W->momentum().phi() );
00225       m_W_mass->Fill(W->momentum().m());
00226       m_W_rapidity->Fill(rapidity);
00227       m_W_mt->Fill(W_momentum.mt());
00228       m_W_charge->Fill(+1);
00229       Wcount++;
00230     }
00231 
00232   if (Wbar)
00233     {
00234       //calculate transverse mass of the W-boson
00235       CLHEP::HepLorentzVector Wbar_momentum(0.,0.,0.,0.);
00236       Wbar_momentum.setPx(Wbar->momentum().px());
00237       Wbar_momentum.setPy(Wbar->momentum().py());
00238       Wbar_momentum.setPz(Wbar->momentum().pz());
00239       Wbar_momentum.setE(Wbar->momentum().e());
00240       
00241       m_W_pt->Fill( Wbar->momentum().perp() );
00242       m_W_eta->Fill( Wbar->momentum().eta() );
00243       m_W_phi->Fill( Wbar->momentum().phi() ) ;
00244       m_W_mass->Fill(Wbar->momentum().m());
00245       m_W_rapidity->Fill(rapidity);
00246       m_W_mt->Fill(Wbar_momentum.mt());
00247       m_W_charge->Fill(-1);
00248       Wcount++;
00249     }
00250 
00251   m_W_count->Fill(Wcount);
00252   
00253   //decay particles tau and nu
00254   
00255   HepMC::GenParticle *tau = hepmcevt->barcode_to_particle(tau_barcode);
00256   HepMC::GenParticle *taubar = hepmcevt->barcode_to_particle(taubar_barcode);
00257   HepMC::GenParticle *nu_tau = hepmcevt->barcode_to_particle(nu_tau_barcode);
00258   HepMC::GenParticle *nubar_tau = hepmcevt->barcode_to_particle(nubar_tau_barcode);
00259 
00260   if (tau && nubar_tau)
00261     {
00262       m_tau_pt->Fill( tau->momentum().perp() );
00263       m_tau_mass->Fill(tau->momentum().m());
00264       m_tau_eta->Fill(tau->momentum().eta());
00265       m_tau_phi->Fill(tau->momentum().phi());
00266       
00267       m_nu_pt->Fill(nubar_tau->momentum().perp());
00268       m_nu_px->Fill(nubar_tau->momentum().px());
00269       m_nu_py->Fill(nubar_tau->momentum().py());
00270       m_nu_pz->Fill(nubar_tau->momentum().pz());
00271       m_zoom_nu_px1->Fill(nubar_tau->momentum().px());
00272       m_zoom_nu_py1->Fill(nubar_tau->momentum().py());
00273       m_zoom_nu_pz1->Fill(nubar_tau->momentum().pz());
00274       
00275       //calculate angle phi between the decay products
00276       double tau_phi = 0;
00277       double nubar_tau_phi = 0;
00278       double DeltaPhi = 0;
00279       
00280       tau_phi = tau->momentum().phi();
00281       nubar_tau_phi = nubar_tau->momentum().phi();
00282       DeltaPhi = tau_phi - nubar_tau_phi;
00283       if( DeltaPhi > TMath::Pi() ||  DeltaPhi == TMath::Pi() )
00284         {
00285           DeltaPhi = DeltaPhi - 2 * TMath::Pi() ;
00286         }
00287       if( DeltaPhi < - TMath::Pi() ||  DeltaPhi == - TMath::Pi() )
00288         {
00289           DeltaPhi = DeltaPhi + 2 * TMath::Pi();
00290         }
00291       m_Delta_Phi_TauNeutrino->Fill(DeltaPhi);
00292       
00293       //calculate transverse mass of W-boson my changing the reference system
00294       //use Lorentzvectors of the decay particles and set the z-component to zero
00295       CLHEP::HepLorentzVector lv_transverse_leptonFromW(tau->momentum().px(),tau->momentum().py(),0,tau->momentum().perp());
00296       CLHEP::HepLorentzVector lv_transverse_neutrinoFromW(nubar_tau->momentum().px(),nubar_tau->momentum().py(),0,nubar_tau->momentum().perp());
00297       //add the Lorentzvector of the neutrino and lepton
00298       CLHEP::HepLorentzVector lv_transverse_W(lv_transverse_leptonFromW+lv_transverse_neutrinoFromW);
00299       //calculate the mass which is according to the reference system the transverse mass
00300       m_W_trans_mass->Fill(lv_transverse_W.m());
00301     }
00302 
00303   if (taubar && nu_tau)
00304     {
00305       m_tau_pt->Fill( taubar->momentum().perp() );
00306       m_tau_mass->Fill(taubar->momentum().m());
00307       m_tau_eta->Fill(taubar->momentum().eta());
00308       m_tau_phi->Fill(taubar->momentum().phi());
00309       
00310       m_nu_pt->Fill(nu_tau->momentum().perp());
00311       m_nu_px->Fill(nu_tau->momentum().px());
00312       m_nu_py->Fill(nu_tau->momentum().py());
00313       m_nu_pz->Fill(nu_tau->momentum().py());
00314       m_zoom_nu_px1->Fill(nu_tau->momentum().px());
00315       m_zoom_nu_py1->Fill(nu_tau->momentum().py());
00316       m_zoom_nu_pz1->Fill(nu_tau->momentum().pz());
00317       
00318       double taubar_phi = 0;
00319       double nu_tau_phi = 0;
00320       double DeltaPhi2 = 0;
00321       
00322       taubar_phi = taubar->momentum().phi();
00323       nu_tau_phi = nu_tau->momentum().phi();
00324       DeltaPhi2 = taubar_phi - nu_tau_phi;
00325       
00326       if( DeltaPhi2 > TMath::Pi() ||  DeltaPhi2 == TMath::Pi() )
00327         {
00328           DeltaPhi2 = DeltaPhi2 - 2 * TMath::Pi() ;
00329         }
00330       if( DeltaPhi2 < - TMath::Pi() ||  DeltaPhi2 == - TMath::Pi() )
00331         {
00332           DeltaPhi2 = DeltaPhi2 + 2 * TMath::Pi();
00333         }
00334       m_Delta_Phi_TauNeutrino->Fill(DeltaPhi2);      
00335 
00336       //calculate transverse mass of W-boson
00337       CLHEP::HepLorentzVector lv_transverse_leptonFromW(taubar->momentum().px(),taubar->momentum().py(),0,taubar->momentum().perp());
00338       CLHEP::HepLorentzVector lv_transverse_neutrinoFromW(nu_tau->momentum().px(),nu_tau->momentum().py(),0,nu_tau->momentum().perp());
00339       CLHEP::HepLorentzVector lv_transverse_W(lv_transverse_leptonFromW+lv_transverse_neutrinoFromW);
00340       m_W_trans_mass->Fill(lv_transverse_W.m());
00341     }
00342 
00343   //checking for children of tau
00344   if (tau && tau->end_vertex())
00345     {
00346       // search for decaying taus
00347       if (!tau->end_vertex()) return false;
00348       
00349       //number of tracks in tau decay
00350       int nTrack = 0; 
00351       
00352       //all generations as descendants
00353       for(HepMC::GenVertex::particle_iterator iChild=tau->end_vertex()->particles_begin(HepMC::descendants); 
00354           iChild!=tau->end_vertex()->particles_end(HepMC::descendants); iChild++)
00355         {
00356           if( (*iChild)->pdg_id() != tau->pdg_id() )
00357             {
00358               int iChild_pid = (*iChild)->pdg_id();
00359               properStatus = 1;
00360               
00361               if( chargedParticle(iChild_pid)==true && (*iChild)->status()%1000 == properStatus && !(*iChild)->end_vertex())
00362                 {
00363                   // search for stable decay products of the taus
00364                   if ((*iChild)->end_vertex()) continue;
00365                   nTrack = nTrack + 1;
00366                 }
00367             }
00368         }
00369       m_nTrack_tau->Fill(nTrack);
00370     }
00371   
00372   if (taubar && taubar->end_vertex())
00373     {
00374       // search for decaying taubars
00375       if (!taubar->end_vertex()) return false;
00376       
00377       //number of tracks in tau decay
00378       int nTrack = 0; 
00379       
00380       //all generations as descendants
00381       for(HepMC::GenVertex::particle_iterator iChild=taubar->end_vertex()->particles_begin(HepMC::descendants); 
00382           iChild!=taubar->end_vertex()->particles_end(HepMC::descendants); iChild++)
00383         {
00384           if( (*iChild)->pdg_id() != taubar->pdg_id() )
00385             {
00386               int iChild_pid = (*iChild)->pdg_id();
00387               properStatus = 1;
00388               
00389               if( (*iChild)->status()%1000 == properStatus && !(*iChild)->end_vertex() && chargedParticle(iChild_pid)==true)
00390                 {
00391                   //search for stable decay products of the taubars
00392                   if ((*iChild)->end_vertex()) continue;
00393                   nTrack = nTrack + 1;
00394                 }
00395             }
00396         }
00397       m_nTrack_tau->Fill(nTrack);
00398     }
00399   
00400   return true;
00401 } //end of Process

Generated on Wed Aug 31 09:44:48 2011 for HepMCAnalysis by  doxygen 1.4.7