CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/AnalysisDataFormats/TopObjects/src/TtFullLepEvtPartons.cc

Go to the documentation of this file.
00001 #include "DataFormats/Candidate/interface/Candidate.h"
00002 #include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h"
00003 
00004 #include "AnalysisDataFormats/TopObjects/interface/TtFullLepEvtPartons.h"
00005 
00006 TtFullLepEvtPartons::TtFullLepEvtPartons(const std::vector<std::string>& partonsToIgnore)
00007 {
00008   // default: use all partons
00009   for(unsigned int i = 0; i < 2; i++)
00010     ignorePartons_.push_back(false);
00011   // read vector of strings and flag partons to be ignored
00012   for(std::vector<std::string>::const_iterator str = partonsToIgnore.begin(); str != partonsToIgnore.end(); ++str) {
00013     if     ((*str) == "B"   ) ignorePartons_[B   ] = true;
00014     else if((*str) == "BBar") ignorePartons_[BBar] = true;
00015     else throw cms::Exception("Configuration")
00016       << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
00017   }
00018 }
00019 
00020 std::vector<const reco::Candidate*>
00021 TtFullLepEvtPartons::vec(const TtGenEvent& genEvt)
00022 {
00023   std::vector<const reco::Candidate*> vec;
00024 
00025   if(genEvt.isFullLeptonic()) {
00026     // fill vector with partons from genEvent
00027     // (use enum for positions of the partons in the vector)
00028     vec.resize(2);
00029     vec[B   ] = genEvt.b()    ? genEvt.b()    : dummyCandidatePtr();
00030     vec[BBar] = genEvt.bBar() ? genEvt.bBar() : dummyCandidatePtr();
00031   }
00032   else {
00033     // fill vector with dummy objects if the event is not fully-leptonic ttbar
00034     for(unsigned i=0; i<2; i++)
00035       vec.push_back( dummyCandidatePtr() );
00036   }
00037 
00038   // erase partons from vector if they where chosen to be ignored
00039   prune(vec);
00040 
00041   return vec;
00042 }