CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/AnalysisDataFormats/TopObjects/src/StGenEvent.cc

Go to the documentation of this file.
00001 //
00002 // $Id: StGenEvent.cc,v 1.11 2010/10/15 22:44:30 wmtan Exp $
00003 //
00004 
00005 #include "FWCore/Utilities/interface/EDMException.h"
00006 #include "CommonTools/CandUtils/interface/pdgIdUtils.h"
00007 #include "AnalysisDataFormats/TopObjects/interface/StGenEvent.h"
00008 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00009 
00010 StGenEvent::StGenEvent()
00011 {
00012 }
00013 
00014 StGenEvent::StGenEvent(reco::GenParticleRefProd & parts, reco::GenParticleRefProd & inits)
00015 {
00016   parts_ = parts;
00017   initPartons_= inits;
00018 }
00019 
00020 StGenEvent::~StGenEvent()
00021 {
00022 }
00023 
00024 const reco::GenParticle* 
00025 StGenEvent::decayB() const 
00026 {
00027   const reco::GenParticle* cand=0;
00028   if (singleLepton()) {
00029     const reco::GenParticleCollection & partsColl = *parts_;
00030     const reco::GenParticle & singleLep = *singleLepton();
00031     for (unsigned int i = 0; i < parts_->size(); ++i) {
00032       if (std::abs(partsColl[i].pdgId())==TopDecayID::bID && 
00033           reco::flavour(singleLep)== - reco::flavour(partsColl[i])) { 
00034         // ... but it should be the opposite!
00035         cand = &partsColl[i];
00036       }
00037     }
00038   }
00039   return cand;
00040 }
00041 
00042 const reco::GenParticle* 
00043 StGenEvent::associatedB() const 
00044 {
00045   const reco::GenParticle* cand=0;
00046   if (singleLepton()) {
00047     const reco::GenParticleCollection & partsColl = *parts_;
00048     const reco::GenParticle & singleLep = *singleLepton();
00049     for (unsigned int i = 0; i < parts_->size(); ++i) {
00050       if (std::abs(partsColl[i].pdgId())==TopDecayID::bID && 
00051           reco::flavour(singleLep)== reco::flavour(partsColl[i])) { 
00052         // ... but it should be the opposite!
00053         cand = &partsColl[i];
00054       }
00055     }
00056   }
00057   return cand;
00058 }
00059 
00060 const reco::GenParticle* 
00061 StGenEvent::singleLepton() const 
00062 {
00063   const reco::GenParticle* cand = 0;
00064   const reco::GenParticleCollection& partsColl = *parts_;
00065   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00066     if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
00067         std::abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00068       cand = &partsColl[i];
00069     }
00070   }
00071   return cand;
00072 }
00073 
00074 const reco::GenParticle* 
00075 StGenEvent::singleNeutrino() const 
00076 {
00077   const reco::GenParticle* cand=0;
00078   const reco::GenParticleCollection & partsColl = *parts_;
00079   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00080     if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
00081         std::abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00082       cand = &partsColl[i];
00083     }
00084   }
00085   return cand;
00086 }
00087 
00088 const reco::GenParticle* 
00089 StGenEvent::singleW() const 
00090 {
00091   const reco::GenParticle* cand=0;
00092   if (singleLepton()) {
00093     const reco::GenParticleCollection & partsColl = *parts_;
00094     const reco::GenParticle & singleLep = *singleLepton();
00095     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00096       if (std::abs(partsColl[i].pdgId())==TopDecayID::WID &&
00097           reco::flavour(singleLep) == - reco::flavour(partsColl[i])){ 
00098         // PDG Id:13=mu- 24=W+ (+24)->(-13) (-24)->(+13) opposite sign
00099         cand = &partsColl[i];
00100       }
00101     }
00102   }
00103   return cand;
00104 }
00105 
00106 const reco::GenParticle* 
00107 StGenEvent::singleTop() const 
00108 {
00109   const reco::GenParticle* cand=0;
00110   if (singleLepton()) {
00111     const reco::GenParticleCollection & partsColl = *parts_;
00112     const reco::GenParticle & singleLep = *singleLepton();
00113     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00114       if (std::abs(partsColl[i].pdgId())==TopDecayID::tID &&
00115           reco::flavour(singleLep)!=reco::flavour(partsColl[i])) {
00116         cand = &partsColl[i];
00117       }
00118     }
00119   }
00120   return cand;
00121 }