CMS 3D CMS Logo

TtFullHadEvtPartons.cc
Go to the documentation of this file.
3 
5 
6 TtFullHadEvtPartons::TtFullHadEvtPartons(const std::vector<std::string>& partonsToIgnore) {
7  // default: use all partons
8  for (unsigned int i = 0; i < 6; i++)
9  ignorePartons_.push_back(false);
10  // read vector of strings and flag partons to be ignored
11  for (std::vector<std::string>::const_iterator str = partonsToIgnore.begin(); str != partonsToIgnore.end(); ++str) {
12  if ((*str) == "LightQ")
13  ignorePartons_[LightQ] = true;
14  else if ((*str) == "LightQBar")
15  ignorePartons_[LightQBar] = true;
16  else if ((*str) == "B")
17  ignorePartons_[B] = true;
18  else if ((*str) == "LightP")
19  ignorePartons_[LightP] = true;
20  else if ((*str) == "LightPBar")
21  ignorePartons_[LightPBar] = true;
22  else if ((*str) == "BBar")
23  ignorePartons_[BBar] = true;
24  else
25  throw cms::Exception("Configuration")
26  << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
27  }
28 }
29 
30 std::vector<const reco::Candidate*> TtFullHadEvtPartons::vec(const TtGenEvent& genEvt) {
31  std::vector<const reco::Candidate*> vec;
32 
33  if (genEvt.isFullHadronic()) {
34  // fill vector with partons from genEvent
35  // (use enum for positions of the partons in the vector)
36  vec.resize(6);
37  vec[LightQ] = genEvt.daughterQuarkOfWPlus() ? genEvt.daughterQuarkOfWPlus() : dummyCandidatePtr();
38  vec[LightQBar] = genEvt.daughterQuarkBarOfWPlus() ? genEvt.daughterQuarkBarOfWPlus() : dummyCandidatePtr();
39  vec[B] = genEvt.b() ? genEvt.b() : dummyCandidatePtr();
40  vec[LightP] = genEvt.daughterQuarkOfWMinus() ? genEvt.daughterQuarkOfWMinus() : dummyCandidatePtr();
41  vec[LightPBar] = genEvt.daughterQuarkBarOfWMinus() ? genEvt.daughterQuarkBarOfWMinus() : dummyCandidatePtr();
42  vec[BBar] = genEvt.bBar() ? genEvt.bBar() : dummyCandidatePtr();
43  } else {
44  // fill vector with dummy objects if the event is not fully-hadronic ttbar
45  for (unsigned i = 0; i < 6; i++)
46  vec.push_back(dummyCandidatePtr());
47  }
48 
49  // erase partons from vector if they where chosen to be ignored
50  prune(vec);
51 
52  return vec;
53 }
mps_fire.i
i
Definition: mps_fire.py:428
TtEventPartons::dummyCandidatePtr
reco::Candidate * dummyCandidatePtr() const
return pointer to an empty reco::Candidate
Definition: TtEventPartons.h:35
TtFullHadEvtPartons::LightQ
Definition: TtFullHadEvtPartons.h:25
TtEventPartons::prune
void prune(std::vector< const reco::Candidate * > &vec)
erase partons from vector if they where chosen to be ignored
Definition: TtEventPartons.cc:13
TtGenEvent
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
TtFullHadEvtPartons::LightP
Definition: TtFullHadEvtPartons.h:25
str
#define str(s)
Definition: TestProcessor.cc:51
TtFullHadEvtPartons::vec
std::vector< const reco::Candidate * > vec(const TtGenEvent &genEvt) override
return vector of partons in the order defined in the corresponding enum
Definition: TtFullHadEvtPartons.cc:30
TtEventPartons::ignorePartons_
std::vector< bool > ignorePartons_
flag partons that were chosen not to be used
Definition: TtEventPartons.h:43
TtFullHadEvtPartons::LightPBar
Definition: TtFullHadEvtPartons.h:25
TtFullHadJetPartonMatch_cfi.partonsToIgnore
partonsToIgnore
Definition: TtFullHadJetPartonMatch_cfi.py:57
TtFullHadEvtPartons::LightQBar
Definition: TtFullHadEvtPartons.h:25
TtGenEvent.h
TtFullHadEvtPartons::TtFullHadEvtPartons
TtFullHadEvtPartons(const std::vector< std::string > &partonsToIgnore=std::vector< std::string >())
default constructor
Definition: TtFullHadEvtPartons.cc:6
TtFullHadEvtPartons::BBar
Definition: TtFullHadEvtPartons.h:25
Exception
Definition: hltDiff.cc:246
TtFullHadEvtPartons.h
Candidate.h
TtFullHadEvtPartons::B
Definition: TtFullHadEvtPartons.h:25
TtGenEvtProducer_cfi.genEvt
genEvt
Definition: TtGenEvtProducer_cfi.py:7