bbbarAnalysis.cc

Go to the documentation of this file.
00001 // STL 
00002 #include <iostream>
00003 #include <sstream>
00004 #include <stdio.h>      // ???? TODO
00005 
00006 #include "HepMC/GenEvent.h"
00007 #include "HepMC/IO_GenEvent.h"
00008 #include "HepMC/GenParticle.h"
00009 #include "HepMC/GenVertex.h"
00010 #include "HepMC/IO_AsciiParticles.h"
00011 #include "HepMC/SimpleVector.h"
00012 #include "HepPDT/ParticleData.hh"
00013 #include "CLHEP/Vector/LorentzVector.h"
00014 
00015 // ROOT 
00016 #include "TH1.h"
00017 #include "TMath.h"
00018 #include "TLorentzVector.h"
00019 #include "TFile.h"
00020 
00021 // fastjet 
00022 #include "fastjet/PseudoJet.hh"
00023 #include "fastjet/ClusterSequence.hh"
00024 #include "fastjet/JetDefinition.hh"
00025 #include "fastjet/SISConePlugin.hh"
00026 
00027 // Analysis class
00028 #include "../include/bbbarAnalysis.h"
00029 
00030 using namespace std;
00031 
00032 // ---------------------------------------------------------------------- 
00033 bbbarAnalysis::bbbarAnalysis( char *fileName ) : 
00034   OutputFileName( fileName )  
00035 {
00036   clearCounters();
00037   //initPlots();
00038 }
00039 
00040 // ---------------------------------------------------------------------- 
00041 bbbarAnalysis::bbbarAnalysis() : 
00042   OutputFileName( "plots_lhcb.root" ) 
00043 {
00044   clearCounters();
00045   //initPlots();
00046 }
00047 
00048 // ---------------------------------------------------------------------- 
00049 bbbarAnalysis::~bbbarAnalysis() 
00050 {
00051   // write output file with histograms
00052   // hOutputFile->Write();
00053   // hOutputFile->Close();
00054 }
00055 
00056 // ---------------------------------------------------------------------- 
00057 void bbbarAnalysis::initPlots() 
00058 {
00059   // output file for histograms
00060   //hOutputFile = new TFile(OutputFileName, "RECREATE");
00061   // ROOT histograms definition
00062   hPtmb = new TH1D("hPtmb", "Pt of stable charged particles in MB events",
00063            100, 0., 20.);
00064   hPtbbbar = new TH1D("hPtbbbar", "Pt of stable charged particles in bbbar events",
00065               100, 0., 20.);
00066   hPtbhadr = new TH1D("hPtbhadr", "Pt of B hadrons in bbbar events",
00067               100, 0., 20.);
00068   hEtabhadr = new TH1D("hEtabhadr", "Eta of B hadrons in bbbar events",
00069                100, -10., 10.);
00070 }
00071 
00072 // ---------------------------------------------------------------------- 
00073 void bbbarAnalysis::clearCounters() 
00074 {
00075   // reset the number of 'b events'
00076   Bcount = 0;
00077   BcountTotal = 0;
00078   // reset the number of Bd/Bu/Bs/b-baryons
00079   Bdcount = 0;
00080   Bucount = 0;
00081   Bscount = 0;
00082   Barions = 0;
00083   // reset the numbers of stable charged particles in MB and b-bbar events
00084   ChargedPartMB = 0;
00085   ChargedPartBBbar = 0;
00086 }
00087 
00088 // ---------------------------------------------------------------------- 
00089 int bbbarAnalysis::Init( double tr_max_eta, double tr_min_pt )
00090 {
00091   // specify default eta cut
00092   m_max_eta=tr_max_eta;
00093 
00094   // specify default pt cut
00095   m_min_pt=tr_min_pt;
00096 
00097   // default Output file name
00098   m_outputFileName  = "bbarAnalysis.root";
00099   m_outputRootDir   = "bbar";
00100 
00101   //m_h_njets   = initHist("njets", "N_jets", "Number of Jets", 15, 0., 15.);
00102 
00103   // ROOT histograms definition
00104   hPtmb = initHist("hPtmb", "Ptmb", "Pt of stable charged particles in MB events",
00105            100, 0., 20.);
00106   hPtbbbar = initHist("hPtbbbar", "Ptbbbar", "Pt of stable charged particles in bbbar events",
00107               100, 0., 20.);
00108   hPtbhadr = initHist("hPtbhadr", "Ptbhadr", "Pt of B hadrons in bbbar events",
00109               100, 0., 20.);
00110   hEtabhadr = initHist("hEtabhadr", "Etabhadr", "Eta of B hadrons in bbbar events",
00111                100, -10., 10.);
00112 
00113   //initPlots();
00114   return true;
00115 }
00116 
00117 // ---------------------------------------------------------------------- 
00118 int bbbarAnalysis::Process( HepMC::GenEvent* hepmcevt ) 
00119 {
00120   getBbbar( hepmcevt );
00121   return true;
00122 }
00123 
00124 // ---------------------------------------------------------------------- 
00125 void bbbarAnalysis::getBbbar(HepMC::GenEvent* evt) 
00126 {
00127 //  std::cout << "getBbbar, in the beginning" << std::endl;
00128 
00129   HepMC::GenEvent::particle_iterator part;
00130   bool bbbar = false;
00131   bool bhadr = false;
00132 //  IsFinalState isStable;
00133 
00134   int BcountInEvent = 0;
00135 
00136 //  std::cout << "getBbbar, before the loop" << std::endl;
00137 
00138   // Check if b-bbar pair is present and count it
00139   for (part = evt->particles_begin(); part != evt->particles_end(); part++)
00140     {
00141 //      std::cout << "getBbbar, first the loop" << std::endl;
00142       int pdgID = (*part)->pdg_id();
00143       int apdgID = abs(pdgID);
00144 
00145       // check if b-quark is present
00146       if (apdgID == 5) {
00147     bbbar = true;
00148  //   std::cout << " pdgID = " << pdgID << "  status = " << (*part)->status() << std::endl;
00149     if ((*part)->status() == 2) BcountInEvent++;
00150       }
00151 
00152       // measure fractions of Bd/Bu/Bs in b-bbar events
00153       if (apdgID == 511) { Bdcount++; bhadr = true; }
00154       if (apdgID == 521) { Bucount++; bhadr = true; }
00155       if (apdgID == 531) { Bscount++; bhadr = true; }
00156 
00157       // measure fractions of b-baryons in b-bbar events
00158       if (apdgID == 5122 || apdgID == 5232 || apdgID == 5132) {
00159     Barions++; bhadr = true; }
00160 
00161       double Pt = (*part)->momentum().perp();
00162       double Eta = (*part)->momentum().pseudoRapidity();
00163 
00164       if (bhadr) {             // B hadron
00165     hPtbhadr->Fill(Pt);
00166     hEtabhadr->Fill(Eta);
00167       }
00168 
00169 
00170       if ( !(*part)->end_vertex() && (*part)->status()==1 )
00171 //      if (isStable(*part))     // stable particle
00172     {
00173 //      if(pdgID > 3000 && pdgID < 4000) std::cout << "charm-beauty stable particle" << std::endl;
00174 
00175       if ( chargedParticle(pdgID) )    // charged particle
00176         {
00177           ChargedPartMB++;
00178           hPtmb->Fill(Pt); // MB stable charged particle
00179 
00180           if (bbbar) {     // b-bbar stable charged particle
00181         ChargedPartBBbar++;
00182         hPtbbbar->Fill(Pt);
00183           }
00184         }
00185 
00186     }
00187     }
00188   if (bbbar) { Bcount++; BcountTotal += BcountInEvent/2; }
00189 //  std::cout << "getBbbar, at the end" << std::endl;
00190 }
00191 

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