CMS 3D CMS Logo

TtGenEvent.cc

Go to the documentation of this file.
00001 //
00002 // $Id: TtGenEvent.cc,v 1.22.2.10 2009/04/24 12:05:41 rwolf Exp $
00003 //
00004 
00005 #include "FWCore/Utilities/interface/EDMException.h"
00006 #include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h"
00007 
00008 
00009 TtGenEvent::TtGenEvent(reco::GenParticleRefProd & parts, reco::GenParticleRefProd & inits)
00010 {
00011   parts_ = parts;
00012   initPartons_= inits;
00013 }
00014 
00015 WDecay::LeptonType 
00016 TtGenEvent::semiLeptonicChannel() const 
00017 {
00018   WDecay::LeptonType type=WDecay::kNone;
00019   if( isSemiLeptonic() && singleLepton() ){
00020     if( abs(singleLepton()->pdgId())==TopDecayID::elecID ) type=WDecay::kElec;
00021     if( abs(singleLepton()->pdgId())==TopDecayID::muonID ) type=WDecay::kMuon;
00022     if( abs(singleLepton()->pdgId())==TopDecayID::tauID  ) type=WDecay::kTau;
00023   }
00024   return type;
00025 }
00026 
00027 std::pair<WDecay::LeptonType, WDecay::LeptonType>
00028 TtGenEvent::fullLeptonicChannel() const 
00029 {
00030   WDecay::LeptonType typeA=WDecay::kNone, typeB=WDecay::kNone;  
00031   if( isFullLeptonic() ){
00032     if( lepton() ){
00033       if( abs(lepton()->pdgId())==TopDecayID::elecID ) typeA=WDecay::kElec;
00034       if( abs(lepton()->pdgId())==TopDecayID::muonID ) typeA=WDecay::kMuon;
00035       if( abs(lepton()->pdgId())==TopDecayID::tauID  ) typeA=WDecay::kTau;      
00036     }
00037     if( leptonBar() ){
00038       if( abs(leptonBar()->pdgId())==TopDecayID::elecID ) typeB=WDecay::kElec;
00039       if( abs(leptonBar()->pdgId())==TopDecayID::muonID ) typeB=WDecay::kMuon;
00040       if( abs(leptonBar()->pdgId())==TopDecayID::tauID  ) typeB=WDecay::kTau;      
00041     }
00042   }
00043   return ( std::pair<WDecay::LeptonType,WDecay::LeptonType>(typeA, typeB) );
00044 }
00045 
00046 const reco::GenParticle* 
00047 TtGenEvent::lepton(bool excludeTauLeptons) const 
00048 {
00049   const reco::GenParticle* cand = 0;
00050   const reco::GenParticleCollection& partsColl = *parts_;
00051   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00052     if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
00053         abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00054       if(reco::flavour(partsColl[i])>0){
00055         cand = &partsColl[i];
00056       }
00057     }
00058   }
00059   return cand;
00060 }
00061 
00062 const reco::GenParticle* 
00063 TtGenEvent::leptonBar(bool excludeTauLeptons) const 
00064 {
00065   const reco::GenParticle* cand = 0;
00066   const reco::GenParticleCollection& partsColl = *parts_;
00067   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00068     if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
00069         abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00070       if(reco::flavour(partsColl[i])<0){
00071         cand = &partsColl[i];
00072       }
00073     }
00074   }
00075   return cand;
00076 }
00077 
00078 const reco::GenParticle* 
00079 TtGenEvent::singleLepton(bool excludeTauLeptons) const 
00080 {
00081   const reco::GenParticle* cand = 0;
00082   if( isSemiLeptonic(excludeTauLeptons) ){
00083     const reco::GenParticleCollection& partsColl = *parts_;
00084     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00085       if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
00086           abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00087         cand = &partsColl[i];
00088       }
00089     }
00090   }
00091   return cand;
00092 }
00093 
00094 const reco::GenParticle* 
00095 TtGenEvent::neutrino(bool excludeTauLeptons) const 
00096 {
00097   const reco::GenParticle* cand=0;
00098   const reco::GenParticleCollection & partsColl = *parts_;
00099   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00100     if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
00101         abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00102       if(reco::flavour(partsColl[i])>0){
00103         cand = &partsColl[i];
00104       }
00105     }
00106   }
00107   return cand;
00108 }
00109 
00110 const reco::GenParticle* 
00111 TtGenEvent::neutrinoBar(bool excludeTauLeptons) const 
00112 {
00113   const reco::GenParticle* cand=0;
00114   const reco::GenParticleCollection & partsColl = *parts_;
00115   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00116     if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
00117         abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00118       if(reco::flavour(partsColl[i])<0){
00119         cand = &partsColl[i];
00120       }
00121     }
00122   }
00123   return cand;
00124 }
00125 
00126 const reco::GenParticle* 
00127 TtGenEvent::singleNeutrino(bool excludeTauLeptons) const 
00128 {
00129   const reco::GenParticle* cand=0;
00130   if( isSemiLeptonic(excludeTauLeptons) ) {
00131     const reco::GenParticleCollection & partsColl = *parts_;
00132     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00133       if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
00134           abs(partsColl[i].mother()->pdgId())==TopDecayID::WID) {
00135         cand = &partsColl[i];
00136       }
00137     }
00138   }
00139   return cand;
00140 }
00141 
00142 const reco::GenParticle* 
00143 TtGenEvent::hadronicDecayQuark(bool invert) const 
00144 {
00145   const reco::GenParticle* cand=0;
00146   // catch W boson and check its daughters for a quarks; 
00147   // make sure the decay is semi-leptonic first; this 
00148   // only makes sense if taus are not excluded from the 
00149   // decision
00150   if( singleLepton(false) ){
00151     for(reco::GenParticleCollection::const_iterator w=parts_->begin(); w!=parts_->end(); ++w){
00152       if( abs( w->pdgId() )==TopDecayID::WID ){
00153         // make sure that the particle is a W daughter
00154         for(reco::GenParticle::const_iterator wd=w->begin(); wd!=w->end(); ++wd){ 
00155           // make sure that the parton is a quark
00156           if( abs(wd->pdgId())<TopDecayID::tID ){
00157             if( invert ){ 
00158               //treat ~q case
00159               if( reco::flavour(*wd)<0 ){
00160                 cand = dynamic_cast<const reco::GenParticle* > (&(*wd));
00161                 if(cand == 0){
00162                   throw edm::Exception( edm::errors::InvalidReference, "Not a GenParticle" );
00163                 }
00164                 break;
00165               }
00166             }
00167             else{         
00168               //treat q case
00169               if( reco::flavour(*wd)>0 ){
00170                 cand = dynamic_cast<const reco::GenParticle* > (&(*wd));
00171                 if(cand == 0){
00172                   throw edm::Exception( edm::errors::InvalidReference, "Not a GenParticle" );
00173                 }
00174                 break;
00175               }
00176             }
00177           }
00178         }
00179       }
00180     }
00181   }
00182   return cand;
00183 }
00184 
00185 const reco::GenParticle* 
00186 TtGenEvent::hadronicDecayB(bool excludeTauLeptons) const 
00187 {
00188   const reco::GenParticle* cand=0;
00189   if( singleLepton(excludeTauLeptons) ){
00190     const reco::GenParticleCollection& partsColl = *parts_;
00191     const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
00192     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00193       if (abs(partsColl[i].pdgId())==TopDecayID::bID && 
00194           reco::flavour(singleLep)==reco::flavour(partsColl[i])) {
00195         cand = &partsColl[i];
00196       }
00197     }
00198   }
00199   return cand;
00200 }
00201 
00202 const reco::GenParticle* 
00203 TtGenEvent::hadronicDecayW(bool excludeTauLeptons) const 
00204 {
00205   const reco::GenParticle* cand=0;
00206   if( singleLepton(excludeTauLeptons) ){
00207     const reco::GenParticleCollection& partsColl = *parts_;
00208     const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
00209     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00210       if (abs(partsColl[i].pdgId())==TopDecayID::WID && 
00211           reco::flavour(singleLep) != -reco::flavour(partsColl[i])) { 
00212         // PDG Id:13=mu- 24=W+ (+24)->(-13) (-24)->(+13) opposite sign
00213         cand = &partsColl[i];
00214       }
00215     }
00216   }
00217   return cand;
00218 }
00219 
00220 const reco::GenParticle* 
00221 TtGenEvent::hadronicDecayTop(bool excludeTauLeptons) const 
00222 {
00223   const reco::GenParticle* cand=0;
00224   if( singleLepton(excludeTauLeptons) ){
00225     const reco::GenParticleCollection& partsColl = *parts_;
00226     const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
00227     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00228       if (abs(partsColl[i].pdgId())==TopDecayID::tID &&
00229           reco::flavour(singleLep)==reco::flavour(partsColl[i])) {
00230         cand = &partsColl[i];
00231       }
00232     }
00233   }
00234   return cand;
00235 }
00236 
00237 const reco::GenParticle* 
00238 TtGenEvent::leptonicDecayB(bool excludeTauLeptons) const 
00239 {
00240   const reco::GenParticle* cand=0;
00241   if( singleLepton(excludeTauLeptons) ){
00242     const reco::GenParticleCollection& partsColl = *parts_;
00243     const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
00244     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00245       if (abs(partsColl[i].pdgId())==TopDecayID::bID &&
00246           reco::flavour(singleLep)!=reco::flavour(partsColl[i])) {
00247         cand = &partsColl[i];
00248       }
00249     }
00250   }
00251   return cand;
00252 }
00253 
00254 const reco::GenParticle* 
00255 TtGenEvent::leptonicDecayW(bool excludeTauLeptons) const 
00256 {
00257   const reco::GenParticle* cand=0;
00258   if( singleLepton(excludeTauLeptons) ){
00259     const reco::GenParticleCollection& partsColl = *parts_;
00260     const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
00261     for (unsigned int i = 0; i < partsColl.size(); ++i) {
00262       if (abs(partsColl[i].pdgId())==TopDecayID::WID &&
00263           reco::flavour(singleLep) == - reco::flavour(partsColl[i])) { 
00264         // PDG Id:13=mu- 24=W+ (+24)->(-13) (-24)->(+13) opposite sign
00265         cand = &partsColl[i];
00266       }
00267     }
00268   }
00269   return cand;
00270 }
00271 
00272 const reco::GenParticle* 
00273 TtGenEvent::leptonicDecayTop(bool excludeTauLeptons) const 
00274 {
00275   const reco::GenParticle* cand=0;
00276   if( singleLepton(excludeTauLeptons) ){
00277     const reco::GenParticleCollection& partsColl = *parts_;
00278     const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
00279     for( unsigned int i = 0; i < partsColl.size(); ++i ){
00280       if( abs(partsColl[i].pdgId())==TopDecayID::tID &&
00281           reco::flavour(singleLep)!=reco::flavour(partsColl[i]) ){
00282         cand = &partsColl[i];
00283       }
00284     }
00285   }
00286   return cand;
00287 }
00288 
00289 const reco::GenParticle* 
00290 TtGenEvent::lightQFromTopBar() const 
00291 {
00292   const reco::GenParticle* cand=0;
00293   const reco::GenParticleCollection& partsColl = *parts_;
00294   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00295     if(partsColl[i].mother() && partsColl[i].mother()->pdgId()==-TopDecayID::WID &&
00296        abs(partsColl[i].pdgId())<TopDecayID::bID && reco::flavour(partsColl[i])>0){
00297       cand = &partsColl[i];
00298     }
00299   }
00300   return cand;
00301 }
00302 
00303 const reco::GenParticle* 
00304 TtGenEvent::lightQBarFromTopBar() const 
00305 {
00306   const reco::GenParticle* cand=0;
00307   const reco::GenParticleCollection& partsColl = *parts_;
00308   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00309     if(partsColl[i].mother() && partsColl[i].mother()->pdgId()==-TopDecayID::WID &&
00310        abs(partsColl[i].pdgId())<TopDecayID::bID && reco::flavour(partsColl[i])<0){
00311       cand = &partsColl[i];
00312     }
00313   }
00314   return cand;
00315 }
00316 
00317 const reco::GenParticle* 
00318 TtGenEvent::lightQFromTop() const 
00319 {
00320   const reco::GenParticle* cand=0;
00321   const reco::GenParticleCollection& partsColl = *parts_;
00322   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00323     if(partsColl[i].mother() && partsColl[i].mother()->pdgId()==TopDecayID::WID &&
00324        abs(partsColl[i].pdgId())<TopDecayID::bID && reco::flavour(partsColl[i])>0){
00325       cand = &partsColl[i];
00326     }  
00327   }
00328   return cand;
00329 }
00330 
00331 const reco::GenParticle* 
00332 TtGenEvent::lightQBarFromTop() const 
00333 {
00334   const reco::GenParticle* cand=0;
00335   const reco::GenParticleCollection& partsColl = *parts_;
00336   for (unsigned int i = 0; i < partsColl.size(); ++i) {
00337     if(partsColl[i].mother() && partsColl[i].mother()->pdgId()==TopDecayID::WID &&
00338        abs(partsColl[i].pdgId())<TopDecayID::bID && reco::flavour(partsColl[i])<0){
00339       cand = &partsColl[i];
00340     }  
00341   }
00342   return cand;
00343 }
00344 
00345 std::vector<const reco::GenParticle*> TtGenEvent::leptonicDecayTopRadiation(bool excludeTauLeptons) const{
00346   if( leptonicDecayTop(excludeTauLeptons) ){
00347     return (leptonicDecayTop(excludeTauLeptons)->pdgId()>0 ? radiatedGluons(TopDecayID::tID) : radiatedGluons(-TopDecayID::tID));
00348   }
00349   std::vector<const reco::GenParticle*> rad;
00350   return (rad);
00351 }
00352 
00353 std::vector<const reco::GenParticle*> TtGenEvent::hadronicDecayTopRadiation(bool excludeTauLeptons) const{
00354   if( hadronicDecayTop(excludeTauLeptons) ){
00355     return (hadronicDecayTop(excludeTauLeptons)->pdgId()>0 ? radiatedGluons(TopDecayID::tID) : radiatedGluons(-TopDecayID::tID));
00356   }
00357   std::vector<const reco::GenParticle*> rad;
00358   return (rad);
00359 }

Generated on Tue Jun 9 17:25:10 2009 for CMSSW by  doxygen 1.5.4