ZAnalysis.cc

Go to the documentation of this file.
00001 // ---------------------------------------------------------------------- 
00002 
00003 #include <iostream>
00004 
00005 #include "HepMC/GenEvent.h"
00006 #include "HepMC/IO_GenEvent.h"
00007 #include "HepMC/GenParticle.h"
00008 #include "HepMC/GenVertex.h"
00009 #include "HepMC/IO_AsciiParticles.h"
00010 #include "HepMC/SimpleVector.h"
00011 
00012 #include "HepPDT/ParticleData.hh"
00013 #include "CLHEP/Vector/LorentzVector.h"
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 #include "../include/ZAnalysis.h"
00027 
00028 using namespace std;
00029 
00030 // ---------------------------------------------------------------------- 
00031 ZAnalysis::ZAnalysis() : baseAnalysis()
00032 {}
00033 
00034 // ---------------------------------------------------------------------- 
00035 ZAnalysis::~ZAnalysis()
00036 {}
00037 
00038 // ---------------------------------------------------------------------- 
00039 /** Z analysis initialization. */
00040 // ---------------------------------------------------------------------- 
00041 int ZAnalysis::Init( double tr_max_eta, double tr_min_pt )
00042 {
00043   m_max_eta = tr_max_eta;     // default eta cut
00044   m_min_pt  = tr_min_pt;      // default pt cut
00045   
00046     // default output file name
00047   m_outputFileName = "ZBosonAnalysis.root";
00048   m_outputRootDir = "Z";
00049   
00050     // book histograms
00051   m_jet_count   = initHist( "jet_count", "Nr of Jets", "Nr Jets", 16, -0.5, 15.5 );
00052   m_jet_pt      = initHist( "leadingjet_pt_high", "Leading Jet Transverse Momentum", "Jet p_{T} [GeV]", 200, 0.0, 1000.0 );
00053   m_jet_pt_log  = initHist( "leadingjet_pt_high_logscale", "Leading Jet Transverse Momentum -logscale-", 
00054       "Jet p_{T} [GeV]", 200, 0.0, 1000.0 );
00055  
00056     // pt histograms 
00057   m_Z_pt      = initHist( "Z_pt", "Z Transverse Momentum", "Z p_{T} [GeV]", 50, 0.0, 25.0 );
00058   m_Z_pt_log  = initHist( "Z_pt_logscale", "Z Transverse Momentum -logscale-", "Z p_{T} [GeV]", 50, 0.0, 25.0 );
00059   m_Z_pt_prop      = initHist( "Z_pt_prop", "Z Transverse Momentum (propagator)", "Z p_{T} [GeV]", 50, 0.0, 25.0 );
00060   m_Z_pt_prop_log  = initHist( "Z_pt_prop_logscale", "Z Transverse Momentum (propagator) -logscale-", "Z p_{T} [GeV]", 50, 0.0, 25.0 );
00061   
00062   m_Z_pt_high     = initHist( "Z_pt_high", "Z Transverse Momentum", "Z p_{T} [GeV]", 80, 0.0, 240.0 );
00063   m_Z_pt_high_log = initHist( "Z_pt_high_logscale", "Z Transverse Momentum -logscale-", 
00064       "Z p_{T} [GeV]", 80, 0.0, 240.0 );
00065   m_Z_pt_high_prop     = initHist( "Z_pt_high_prop", "Z Transverse Momentum (propagator)", "Z p_{T} [GeV]", 80, 0.0, 240.0 );
00066   m_Z_pt_high_prop_log = initHist( "Z_pt_high_prop_logscale", "Z Transverse Momentum (propagator) -logscale-", 
00067       "Z p_{T} [GeV]", 80, 0.0, 240.0 );
00068 
00069     // Z eta/phi
00070   m_Z_eta = initHist( "Z_eta", "#eta Z-Boson", "#eta", 80, -8.0, 8.0 );
00071   m_Z_phi = initHist( "Z_phi", "#varphi Z-Boson", "#varphi", 64, -3.2, 3.2 );
00072   m_Z_eta_prop = initHist( "Z_eta_prop", "#eta Z-Boson (propagator)", "#eta", 80, -8.0, 8.0 );
00073   m_Z_phi_prop = initHist( "Z_phi_prop", "#varphi Z-Boson (propagator)", "#varphi", 64, -3.2, 3.2 );
00074 
00075     // Z mass
00076   m_Z_mass      = initHist( "Z_mass", "Z Mass", "m_{Z} [GeV]", 80, 70.0, 110.0 );
00077   m_Z_mass_log  = initHist( "Z_mass_logscale", "Z Mass -logscale-", "m_{Z} [GeV]", 80, 70.0, 110.0 );
00078   m_Z_mass_prop      = initHist( "Z_mass_prop", "Z Mass (propagator)", "m_{Z} [GeV]", 80, 70.0, 110.0 );
00079   m_Z_mass_prop_log  = initHist( "Z_mass_prop_logscale", "Z Mass (propagator) -logscale-", "m_{Z} [GeV]", 80, 70.0, 110.0 );
00080   
00081   m_charged_particle_multiplicity = initHist( "charged_particle_multiplicity", 
00082       "Number of charged Particles in the Event", "charged particle multiplicity", 100, 0.0, 300.0 );
00083   m_charged_particle_temp_pt = initHist( "Z_charged_particle_temp_mean_pt", "temp histogramm", 
00084       "Z charged particle temp mean p_{T}", 200, 0.0, 100.0 );
00085   m_charged_particle_pt = initHist( "Z_charged_particle_pt", "p_{T} pf charged particles", 
00086       "p_{T}", 200, 0.0, 100.0 );
00087 
00088   m_charged_particle_mean_pt = initHist( "charged_particle_mean_pt", "Average p_{T} charged Particles in the Event",
00089       "charged particle #bar{p}_{T}", 50, 0.0, 10.0 );
00090   m_charged_particle_rms_pt = initHist( "charged_particle_rms_pt", "RMS p_{T} charged Particles in the Event",
00091       "charged particle #sigma(p_{T})", 50, 0.0, 10.0 );
00092   m_charged_particle_pdgID = initHist( "charged_particle_pdgID", "charged Particles PDG ID", 
00093       "charged particle pid", 601, -300.0, 300.0 );
00094   
00095   return true;
00096 }
00097 
00098 // ---------------------------------------------------------------------- 
00099 /** @return flag indicating that Z boson was indeed found and the FourVector 
00100 of the final state (as the last function's parameter). */
00101 // ---------------------------------------------------------------------- 
00102 bool ZAnalysis::FSVector( HepMC::GenEvent::particle_const_iterator &zBoson, ZAnalysis::EParticleType productPid, 
00103     HepMC::FourVector &fsVector )
00104 {
00105   size_t  nNegParts = 0, 
00106           nPosParts = 0;
00107 
00108   HepMC::GenVertex::particle_iterator posParticle;        
00109   HepMC::GenVertex::particle_iterator negParticle;        
00110 
00111      // loop over children of the found Z boson
00112   for ( HepMC::GenVertex::particle_iterator child = (*zBoson)->end_vertex()->particles_begin( HepMC::children );
00113         child != (*zBoson)->end_vertex()->particles_end( HepMC::children ); ++child ) {
00114 
00115       // look for a pair e+e-, mu+mu-
00116     int pid = (*child)->pdg_id();
00117     if ( pid == productPid ) {         // look for specific particles only 
00118       posParticle = child;
00119       ++nPosParts;
00120     }
00121     if ( pid == -productPid ) {
00122       negParticle = child;
00123       ++nNegParts;
00124     }
00125   }
00126   //cout << "ID: " << productPid << ", nPosParticles: " << nPosParticles << ", nNegParticles: " << nNegParticles << endl; 
00127  
00128   if ( nPosParts == 1 && nNegParts == 1 )  {
00129     //cout << "==> Z boson found" << endl;
00130 
00131       // positive particle...  
00132     for ( HepMC::GenVertex::particle_iterator des = (*posParticle)->end_vertex()->particles_begin( HepMC::descendants );
00133         des != (*posParticle)->end_vertex()->particles_end( HepMC::descendants ); ++des ) {
00134       const HepMC::FourVector &desMom = (*des)->momentum();
00135     
00136       if ( IsFinalStateParticle( *des) ) {  
00137         fsVector.setPx( fsVector.px() + desMom.px() );
00138         fsVector.setPy( fsVector.py() + desMom.py() );
00139         fsVector.setPz( fsVector.pz() + desMom.pz() );
00140         fsVector.setE( fsVector.e() + desMom.e() );
00141       }
00142     }
00143 
00144       // negative particle...  
00145     for ( HepMC::GenVertex::particle_iterator des = (*negParticle)->end_vertex()->particles_begin( HepMC::descendants );
00146         des != (*negParticle)->end_vertex()->particles_end( HepMC::descendants ); ++des ) {
00147       const HepMC::FourVector &desMom = (*des)->momentum();
00148     
00149       if ( IsFinalStateParticle( *des) ) {  
00150         fsVector.setPx( fsVector.px() + desMom.px() );
00151         fsVector.setPy( fsVector.py() + desMom.py() );
00152         fsVector.setPz( fsVector.pz() + desMom.pz() );
00153         fsVector.setE( fsVector.e() + desMom.e() );
00154       }
00155     }
00156 
00157     if ( fsVector.m() == 0 ) {
00158       return false; 
00159     }
00160 
00161     return true;
00162   } 
00163   
00164   return false;
00165 } 
00166 
00167 // ---------------------------------------------------------------------- 
00168 /** This is the main analysis function. Search for Z bosons, get their
00169 properties and fill the histograms. */
00170 // ---------------------------------------------------------------------- 
00171 int ZAnalysis::Process( HepMC::GenEvent* hepmcevt ) 
00172 {
00173     // reset auxiliary histogramm
00174   m_charged_particle_temp_pt->Reset();
00175 
00176   size_t cntZ = 0;
00177   size_t cntChargedParts = 0;
00178 
00179     // loop over particles in the current event 
00180   for ( HepMC::GenEvent::particle_const_iterator p =  hepmcevt->particles_begin(); p != hepmcevt->particles_end(); ++p ) {
00181     int pid = (*p)->pdg_id(); 
00182     //cout << "pid = " << pid << endl;
00183 
00184     HepMC::FourVector eeFs( 0.0, 0.0, 0.0, 0.0 );
00185     HepMC::FourVector mumuFs( 0.0, 0.0, 0.0, 0.0 );
00186 
00187     if ( pid == 23 && (*p)->end_vertex() ) {   // Z boson PDG id=23 and should decay
00188         // --------------- propagator
00189       HepMC::GenVertex::particle_iterator firstChild = (*p)->end_vertex()->particles_begin(HepMC::children);
00190       HepMC::GenVertex::particle_iterator endChild =  (*p)->end_vertex()->particles_end(HepMC::children);
00191  
00192          // plot Pt, eta, phi and mass of the Z (generator values)
00193       if( (*firstChild)->pdg_id() != pid ){
00194         const HepMC::FourVector &mom = (*p)->momentum();
00195 
00196         m_Z_pt_prop->Fill( mom.perp() );
00197         m_Z_pt_prop_log->Fill( mom.perp() );
00198         m_Z_pt_high_prop->Fill( mom.perp() );
00199         m_Z_pt_high_prop_log->Fill( mom.perp() );
00200         m_Z_eta_prop->Fill( mom.eta() );
00201         m_Z_phi_prop->Fill( mom.phi() );
00202         m_Z_mass_prop->Fill( mom.m() );
00203         m_Z_mass_prop_log->Fill( mom.m() );
00204       } // --------------- 
00205 
00206       if ( FSVector( p, ZAnalysis::Electron, eeFs ) ) {  // e+e- 
00207         FillZHistograms( eeFs );
00208       } 
00209       if ( FSVector( p, ZAnalysis::Muon, mumuFs ) ) {    // mu+mu- 
00210         FillZHistograms( mumuFs );
00211       } 
00212       ++cntZ;
00213     } 
00214     
00215     if( !IsFinalStateParticle( *p ) ) {
00216       continue;
00217     }
00218 
00219       // cut out the neutral particles (charge is not stored in HepMC)
00220       // just remove the neutrinos, gammas, neutral pions and
00221       // neutrons, K0s, ... from the final state
00222     if( !chargedParticle( pid ) ) {
00223       continue;
00224     }
00225     ++cntChargedParts;
00226  
00227       // fill histograms for charged stable particles
00228     m_charged_particle_pt->Fill( (*p)->momentum().perp() );
00229     m_charged_particle_temp_pt->Fill( (*p)->momentum().perp() );
00230     m_charged_particle_pdgID->Fill( pid );
00231   }
00232 
00233     // fill rest of the histograms
00234   m_charged_particle_multiplicity->Fill( cntChargedParts );
00235   
00236   m_charged_particle_mean_pt->Fill( m_charged_particle_temp_pt->GetMean() );
00237   m_charged_particle_rms_pt->Fill( m_charged_particle_temp_pt->GetRMS() );
00238   
00239   m_jet_count->Fill( m_inclusive_jets.size() ); 
00240 
00241   if ( !m_inclusive_jets.empty() ){
00242     m_jet_pt->Fill( m_inclusive_jets[0].perp() );
00243     m_jet_pt_log->Fill( m_inclusive_jets[0].perp() );
00244   }
00245 
00246   return true;
00247 }
00248 
00249 // ---------------------------------------------------------------------- 
00250 /** Fill histograms specific for the Z analysis. */
00251 // ---------------------------------------------------------------------- 
00252 void ZAnalysis::FillZHistograms( const HepMC::FourVector &fsVec )
00253 {
00254   const double &pt = fsVec.perp();
00255 
00256   //cout << "pt: " << fsVec.perp() << ", m: " << fsVec.m() << ", phi: " << fsVec.phi() << endl;
00257 
00258   m_Z_pt->Fill( pt );
00259   m_Z_pt_log->Fill( pt );
00260   m_Z_pt_high->Fill( pt );
00261   m_Z_pt_high_log->Fill( pt );
00262 
00263   m_Z_phi->Fill( fsVec.phi() );
00264         m_Z_eta->Fill( fsVec.eta());
00265         m_Z_mass->Fill( fsVec.m() );
00266         m_Z_mass_log->Fill( fsVec.m() );
00267 }
00268 

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