Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:31

0001 #include "DataFormats/Candidate/interface/Candidate.h"
0002 #include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h"
0003 
0004 #include "AnalysisDataFormats/TopObjects/interface/TtFullLepEvtPartons.h"
0005 
0006 TtFullLepEvtPartons::TtFullLepEvtPartons(const std::vector<std::string>& partonsToIgnore) {
0007   // default: use all partons
0008   for (unsigned int i = 0; i < 2; i++)
0009     ignorePartons_.push_back(false);
0010   // read vector of strings and flag partons to be ignored
0011   for (std::vector<std::string>::const_iterator str = partonsToIgnore.begin(); str != partonsToIgnore.end(); ++str) {
0012     if ((*str) == "B")
0013       ignorePartons_[B] = true;
0014     else if ((*str) == "BBar")
0015       ignorePartons_[BBar] = true;
0016     else
0017       throw cms::Exception("Configuration")
0018           << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
0019   }
0020 }
0021 
0022 std::vector<const reco::Candidate*> TtFullLepEvtPartons::vec(const TtGenEvent& genEvt) const {
0023   std::vector<const reco::Candidate*> vec;
0024 
0025   if (genEvt.isFullLeptonic()) {
0026     // fill vector with partons from genEvent
0027     // (use enum for positions of the partons in the vector)
0028     vec.resize(2);
0029     vec[B] = genEvt.b() ? genEvt.b() : dummyCandidatePtr();
0030     vec[BBar] = genEvt.bBar() ? genEvt.bBar() : dummyCandidatePtr();
0031   } else {
0032     // fill vector with dummy objects if the event is not fully-leptonic ttbar
0033     for (unsigned i = 0; i < 2; i++)
0034       vec.push_back(dummyCandidatePtr());
0035   }
0036 
0037   // erase partons from vector if they where chosen to be ignored
0038   prune(vec);
0039 
0040   return vec;
0041 }