CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/AnalysisDataFormats/TopObjects/src/TtSemiLepEvtPartons.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/TtSemiLepEvtPartons.h"
00005 
00006 TtSemiLepEvtPartons::TtSemiLepEvtPartons(const std::vector<std::string>& partonsToIgnore)
00007 {
00008   // default: use all partons
00009   for(unsigned int i = 0; i < 4; 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) == "LightQ"   ) ignorePartons_[LightQ   ] = true;
00014     else if((*str) == "LightQBar") ignorePartons_[LightQBar] = true;
00015     else if((*str) == "HadB"     ) ignorePartons_[HadB     ] = true;
00016     else if((*str) == "LepB"     ) ignorePartons_[LepB     ] = true;
00017     else throw cms::Exception("Configuration")
00018       << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
00019   }
00020 }
00021 
00022 std::vector<const reco::Candidate*>
00023 TtSemiLepEvtPartons::vec(const TtGenEvent& genEvt)
00024 {
00025   std::vector<const reco::Candidate*> vec;
00026 
00027   if(genEvt.isSemiLeptonic()) {
00028     // fill vector with partons from genEvent
00029     // (use enum for positions of the partons in the vector)
00030     vec.resize(4);
00031     vec[LightQ   ] = genEvt.hadronicDecayQuark()    ? genEvt.hadronicDecayQuark()    : dummyCandidatePtr();
00032     vec[LightQBar] = genEvt.hadronicDecayQuarkBar() ? genEvt.hadronicDecayQuarkBar() : dummyCandidatePtr();
00033     vec[HadB     ] = genEvt.hadronicDecayB()        ? genEvt.hadronicDecayB()        : dummyCandidatePtr();
00034     vec[LepB     ] = genEvt.leptonicDecayB()        ? genEvt.leptonicDecayB()        : dummyCandidatePtr();
00035   }
00036   else {
00037     // fill vector with dummy objects if the event is not semi-leptonic ttbar
00038     for(unsigned i=0; i<4; i++)
00039       vec.push_back( dummyCandidatePtr() );
00040   }
00041 
00042   // erase partons from vector if they where chosen to be ignored
00043   prune(vec);
00044 
00045   return vec;
00046 }