CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/AnalysisDataFormats/TopObjects/src/TtFullHadEvtPartons.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/TtFullHadEvtPartons.h"
00005 
00006 TtFullHadEvtPartons::TtFullHadEvtPartons(const std::vector<std::string>& partonsToIgnore)
00007 {
00008   // default: use all partons
00009   for(unsigned int i = 0; i < 6; 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) == "B"         ) ignorePartons_[B        ] = true;
00016     else if((*str) == "LightP"    ) ignorePartons_[LightP   ] = true;
00017     else if((*str) == "LightPBar" ) ignorePartons_[LightPBar] = true;
00018     else if((*str) == "BBar"      ) ignorePartons_[BBar     ] = true;
00019     else throw cms::Exception("Configuration")
00020       << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
00021   }
00022 }
00023 
00024 std::vector<const reco::Candidate*>
00025 TtFullHadEvtPartons::vec(const TtGenEvent& genEvt)
00026 {
00027   std::vector<const reco::Candidate*> vec;
00028 
00029   if(genEvt.isFullHadronic()) {
00030     // fill vector with partons from genEvent
00031     // (use enum for positions of the partons in the vector)
00032     vec.resize(6);
00033     vec[LightQ      ] = genEvt.daughterQuarkOfWPlus()     ? genEvt.daughterQuarkOfWPlus()     : dummyCandidatePtr();
00034     vec[LightQBar   ] = genEvt.daughterQuarkBarOfWPlus()  ? genEvt.daughterQuarkBarOfWPlus()  : dummyCandidatePtr();
00035     vec[B           ] = genEvt.b()                        ? genEvt.b()                        : dummyCandidatePtr();
00036     vec[LightP      ] = genEvt.daughterQuarkOfWMinus()    ? genEvt.daughterQuarkOfWMinus()    : dummyCandidatePtr();
00037     vec[LightPBar   ] = genEvt.daughterQuarkBarOfWMinus() ? genEvt.daughterQuarkBarOfWMinus() : dummyCandidatePtr();
00038     vec[BBar        ] = genEvt.bBar()                     ? genEvt.bBar()                     : dummyCandidatePtr();
00039   }
00040   else {
00041     // fill vector with dummy objects if the event is not fully-hadronic ttbar
00042     for(unsigned i=0; i<6; i++)
00043       vec.push_back( dummyCandidatePtr() );
00044   }
00045 
00046   // erase partons from vector if they where chosen to be ignored
00047   prune(vec);
00048 
00049   return vec;
00050 }