CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
TtDecayChannelSelector Class Reference

#include <TtDecayChannelSelector.h>

Public Types

enum  { Elec = 0, Muon = 1, Tau = 2 }
 leafs of leptonic decay channel vector decay_ More...
 
typedef std::vector< int > Decay
 typedef to simplify the decay vectors More...
 

Public Member Functions

bool operator() (const reco::GenParticleCollection &parts, std::string inputType) const
 operator for decay channel selection More...
 
 TtDecayChannelSelector (const edm::ParameterSet &)
 std contructor More...
 
 ~TtDecayChannelSelector ()
 default destructor More...
 

Private Member Functions

unsigned int checkSum (const Decay &vec) const
 
unsigned int countProngs (const reco::Candidate &part) const
 count the number of charged particles for tau decays More...
 
unsigned int decayChannel () const
 return decay channel to select for from configuration More...
 
bool search (reco::GenParticle::const_iterator &part, int pdgId, std::string &inputType) const
 search for particle with pdgId in given listing (for top daughters) More...
 
bool search (reco::GenParticleCollection::const_iterator &part, int pdgId, std::string &inputType) const
 search for particle with pdgId in given listing (for top) More...
 
bool tauDecay (const reco::Candidate &) const
 check tau decay to be leptonic, 1-prong or 3-prong More...
 

Private Attributes

bool allow1Prong_
 allow 1-prong tau decays More...
 
bool allow3Prong_
 allow 2-prong tau decays More...
 
Decay allowedDecays_
 
bool allowElectron_
 allow tau decays into electron More...
 
bool allowMuon_
 allow tau decays into muon More...
 
Decay decayBranchA_
 top decay branch 1 More...
 
Decay decayBranchB_
 top decay branch 2 More...
 
bool invert_
 invert selection More...
 
bool restrictTauDecays_
 restrict tau decays More...
 

Detailed Description

Definition at line 8 of file TtDecayChannelSelector.h.

Member Typedef Documentation

◆ Decay

typedef std::vector<int> TtDecayChannelSelector::Decay

typedef to simplify the decay vectors

Definition at line 13 of file TtDecayChannelSelector.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

leafs of leptonic decay channel vector decay_

Enumerator
Elec 
Muon 
Tau 

Definition at line 11 of file TtDecayChannelSelector.h.

11 { Elec = 0, Muon = 1, Tau = 2 };

Constructor & Destructor Documentation

◆ TtDecayChannelSelector()

TtDecayChannelSelector::TtDecayChannelSelector ( const edm::ParameterSet cfg)

std contructor

Definition at line 15 of file TtDecayChannelSelector.cc.

16  : invert_(cfg.getParameter<bool>("invert")),
17  allowElectron_(false),
18  allowMuon_(false),
19  allow1Prong_(false),
20  allow3Prong_(false) {
21  // tau decays are not restricted if this PSet does not exist at all
22  restrictTauDecays_ = cfg.existsAs<edm::ParameterSet>("restrictTauDecays");
23  // determine allowed tau decays
24  if (restrictTauDecays_) {
25  edm::ParameterSet allowedTauDecays = cfg.getParameter<edm::ParameterSet>("restrictTauDecays");
26  // tau decays are not restricted if none of the following parameters exists
27  restrictTauDecays_ = (allowedTauDecays.existsAs<bool>("electron") || allowedTauDecays.existsAs<bool>("muon") ||
28  allowedTauDecays.existsAs<bool>("oneProng") || allowedTauDecays.existsAs<bool>("threeProng"));
29  // specify the different possible restrictions of the tau decay channels
31  (allowedTauDecays.existsAs<bool>("electron") ? allowedTauDecays.getParameter<bool>("electron") : false);
32  allowMuon_ = (allowedTauDecays.existsAs<bool>("muon") ? allowedTauDecays.getParameter<bool>("muon") : false);
33  allow1Prong_ =
34  (allowedTauDecays.existsAs<bool>("oneProng") ? allowedTauDecays.getParameter<bool>("oneProng") : false);
35  allow3Prong_ =
36  (allowedTauDecays.existsAs<bool>("threeProng") ? allowedTauDecays.getParameter<bool>("threeProng") : false);
37  }
38  // allowed top decays PSet
39  edm::ParameterSet allowedTopDecays = cfg.getParameter<edm::ParameterSet>("allowedTopDecays");
40 
41  // fill decayBranchA_
42  edm::ParameterSet decayBranchA = allowedTopDecays.getParameter<edm::ParameterSet>("decayBranchA");
43  decayBranchA_.push_back(decayBranchA.getParameter<bool>("electron"));
44  decayBranchA_.push_back(decayBranchA.getParameter<bool>("muon"));
45  decayBranchA_.push_back(decayBranchA.getParameter<bool>("tau"));
46 
47  // fill decay branchB_
48  edm::ParameterSet decayBranchB = allowedTopDecays.getParameter<edm::ParameterSet>("decayBranchB");
49  decayBranchB_.push_back(decayBranchB.getParameter<bool>("electron"));
50  decayBranchB_.push_back(decayBranchB.getParameter<bool>("muon"));
51  decayBranchB_.push_back(decayBranchB.getParameter<bool>("tau"));
52 
53  // fill allowedDecays_
54  for (unsigned int d = 0; d < kDecayChannels; ++d) {
56  }
57 }

References allow1Prong_, allow3Prong_, allowedDecays_, TtDecayChannelFilter_cfi::allowedTopDecays, allowElectron_, allowMuon_, looper::cfg, ztail::d, TtDecayChannelFilter_cfi::decayBranchA, decayBranchA_, TtDecayChannelFilter_cfi::decayBranchB, decayBranchB_, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), kDecayChannels, and restrictTauDecays_.

◆ ~TtDecayChannelSelector()

TtDecayChannelSelector::~TtDecayChannelSelector ( )

default destructor

Definition at line 59 of file TtDecayChannelSelector.cc.

59 {}

Member Function Documentation

◆ checkSum()

unsigned int TtDecayChannelSelector::checkSum ( const Decay vec) const
inlineprivate

Definition at line 69 of file TtDecayChannelSelector.h.

69  {
70  unsigned int sum = 0;
71  for (unsigned int d = 0; d < vec.size(); ++d) {
72  sum += vec[d];
73  }
74  return sum;
75 }

References ztail::d.

Referenced by operator()().

◆ countProngs()

unsigned int TtDecayChannelSelector::countProngs ( const reco::Candidate part) const
private

count the number of charged particles for tau decays

Definition at line 186 of file TtDecayChannelSelector.cc.

186  {
187  // if stable, return 1 or 0
188  if (part.status() == 1) {
189  return (part.charge() != 0);
190  }
191  // if unstable, call recursively on daughters
192  int prong = 0;
193  for (reco::Candidate::const_iterator daughter = part.begin(); daughter != part.end(); ++daughter) {
194  prong += countProngs(*daughter);
195  }
196  return prong;
197 }

Referenced by tauDecay().

◆ decayChannel()

unsigned int TtDecayChannelSelector::decayChannel ( ) const
inlineprivate

return decay channel to select for from configuration

Definition at line 58 of file TtDecayChannelSelector.h.

58  {
59  unsigned int channel = 0;
60  if (std::count(decayBranchA_.begin(), decayBranchA_.end(), 1) > 0) {
61  ++channel;
62  }
63  if (std::count(decayBranchB_.begin(), decayBranchB_.end(), 1) > 0) {
64  ++channel;
65  }
66  return channel;
67 }

References submitPVResolutionJobs::count, decayBranchA_, and decayBranchB_.

Referenced by operator()().

◆ operator()()

bool TtDecayChannelSelector::operator() ( const reco::GenParticleCollection parts,
std::string  inputType 
) const

operator for decay channel selection

Definition at line 61 of file TtDecayChannelSelector.cc.

61  {
62  bool verbose =
63  false; // set this to true for debugging and add TtDecayChannelSelector category to the MessageLogger in your cfg file
64  unsigned int iLep = 0;
65  unsigned int iTop = 0, iBeauty = 0, iElec = 0, iMuon = 0, iTau = 0;
66  for (reco::GenParticleCollection::const_iterator top = parts.begin(); top != parts.end(); ++top) {
67  if (search(top, TopDecayID::tID, inputType)) {
68  ++iTop;
69  for (reco::GenParticle::const_iterator td = top->begin(); td != top->end(); ++td) {
70  if (search(td, TopDecayID::bID, inputType)) {
71  ++iBeauty;
72  }
73  if (search(td, TopDecayID::WID, inputType)) {
74  for (reco::GenParticle::const_iterator wd = td->begin(); wd != td->end(); ++wd) {
75  if (std::abs(wd->pdgId()) == TopDecayID::elecID) {
76  ++iElec;
77  }
78  if (std::abs(wd->pdgId()) == TopDecayID::muonID) {
79  ++iMuon;
80  }
81  if (std::abs(wd->pdgId()) == TopDecayID::tauID) {
82  if (restrictTauDecays_) {
83  // count as iTau if it is leptonic, one-prong
84  // or three-prong and ignore increasing iLep
85  // though else
86  if (tauDecay(*wd)) {
87  ++iTau;
88  } else {
89  ++iLep;
90  }
91  } else {
92  ++iTau;
93  }
94  }
95  }
96  }
97  }
98  }
99  }
100  if (verbose) {
101  edm::LogVerbatim log("TtDecayChannelSelector");
102  log << "----------------------"
103  << "\n"
104  << " iTop : " << iTop << "\n"
105  << " iBeauty : " << iBeauty << "\n"
106  << " iElec : " << iElec << "\n"
107  << " iMuon : " << iMuon << "\n"
108  << " iTau : " << iTau + iLep;
109  if (restrictTauDecays_ && (iTau + iLep) > 0) {
110  log << " (" << iTau << ")\n";
111  } else {
112  log << "\n";
113  }
114  log << "- - - - - - - - - - - "
115  << "\n";
116  }
117  iLep += iElec + iMuon + iTau;
118 
119  bool accept = false;
120  unsigned int channel = decayChannel();
121  if ((iTop == 2) && (iBeauty == 2)) {
122  if (channel == iLep) {
123  if (channel == 0) {
124  // no lepton: accept without restriction we already
125  // know that the number of leptons is correct
126  accept = true;
127  }
128  if (channel == 1) {
129  // one lepton: check that this one is allowed
130  accept = (iElec && allowedDecays_[Elec]) || (iMuon && allowedDecays_[Muon]) || (iTau && allowedDecays_[Tau]);
131  }
132  if (channel == 2) {
133  if (checkSum(allowedDecays_) == channel) {
134  // no redundancy
135  accept = (allowedDecays_[Elec] == (int)iElec) && (allowedDecays_[Muon] == (int)iMuon) &&
136  (allowedDecays_[Tau] == (int)iTau);
137  } else {
138  // reject events with wrong tau decays
139  if (iElec + iMuon + iTau != channel) {
140  accept = false;
141  } else {
142  if ((iElec == 2) || (iMuon == 2) || (iTau == 2)) {
143  // same lepton twice: check that this is allowed.
144  accept = (allowedDecays_[Elec] == (int)iElec) || (allowedDecays_[Muon] == (int)iMuon) ||
145  (allowedDecays_[Tau] == (int)iTau);
146  } else {
147  // two different leptons: look if there is a possible combination
148  accept = (((iElec && decayBranchA_[Elec]) &&
149  ((iMuon && decayBranchB_[Muon]) || (iTau && decayBranchB_[Tau]))) ||
150  ((iMuon && decayBranchA_[Muon]) &&
151  ((iElec && decayBranchB_[Elec]) || (iTau && decayBranchB_[Tau]))) ||
152  ((iTau && decayBranchA_[Tau]) &&
153  ((iElec && decayBranchB_[Elec]) || (iMuon && decayBranchB_[Muon]))));
154  }
155  }
156  }
157  }
158  }
159  accept = ((!invert_ && accept) || (!(!invert_) && !accept));
160  } else {
161  edm::LogWarning("NoVtbDecay") << "Decay is not via Vtb";
162  }
163  if (verbose)
164  edm::LogVerbatim("TtDecayChannelSelector") << " accept : " << accept;
165  return accept;
166 }

References funct::abs(), accept(), allowedDecays_, TopDecayID::bID, checkSum(), decayBranchA_, decayBranchB_, decayChannel(), Elec, TopDecayID::elecID, createfilelist::int, invert_, dqm-mbProfile::log, Muon, TopDecayID::muonID, contentValuesFiles::parts, restrictTauDecays_, search(), Tau, tauDecay(), TopDecayID::tauID, TopDecayID::tID, verbose, and TopDecayID::WID.

◆ search() [1/2]

bool TtDecayChannelSelector::search ( reco::GenParticle::const_iterator part,
int  pdgId,
std::string &  inputType 
) const
private

search for particle with pdgId in given listing (for top daughters)

Definition at line 178 of file TtDecayChannelSelector.cc.

178  {
179  if (inputType == kGenParticles) {
180  return (std::abs(part->pdgId()) == pdgId && part->status() == TopDecayID::unfrag) ? true : false;
181  } else {
182  return (std::abs(part->pdgId()) == pdgId) ? true : false;
183  }
184 }

References funct::abs(), kGenParticles, EgammaValidation_cff::pdgId, funct::true, and TopDecayID::unfrag.

◆ search() [2/2]

bool TtDecayChannelSelector::search ( reco::GenParticleCollection::const_iterator &  part,
int  pdgId,
std::string &  inputType 
) const
private

search for particle with pdgId in given listing (for top)

Definition at line 168 of file TtDecayChannelSelector.cc.

170  {
171  if (inputType == kGenParticles) {
172  return (std::abs(part->pdgId()) == pdgId && part->status() == TopDecayID::unfrag) ? true : false;
173  } else {
174  return (std::abs(part->pdgId()) == pdgId) ? true : false;
175  }
176 }

References funct::abs(), kGenParticles, EgammaValidation_cff::pdgId, funct::true, and TopDecayID::unfrag.

Referenced by operator()().

◆ tauDecay()

bool TtDecayChannelSelector::tauDecay ( const reco::Candidate tau) const
private

check tau decay to be leptonic, 1-prong or 3-prong

Definition at line 199 of file TtDecayChannelSelector.cc.

199  {
200  bool electronTau = false;
201  bool muonTau = false;
202  unsigned int nch = 0;
203  // loop on tau decays, check for an elec
204  // or muon and count charged particles
205  for (reco::Candidate::const_iterator daughter = tau.begin(); daughter != tau.end(); ++daughter) {
206  // if the tau daughter is again a tau, this means that the particle has
207  // still to be propagated; in that case, return the result of the same
208  // method applied on the daughter of the current particle
209  if (daughter->pdgId() == tau.pdgId()) {
210  return tauDecay(*daughter);
211  }
212  // check for electron from tau decay
213  electronTau |= (std::abs(daughter->pdgId()) == TopDecayID::elecID);
214  // check for muon from tau decay
215  muonTau |= (std::abs(daughter->pdgId()) == TopDecayID::muonID);
216  // count charged particles
217  nch += countProngs(*daughter);
218  }
219  return ((allowElectron_ && electronTau) || (allowMuon_ && muonTau) ||
220  (allow1Prong_ && !electronTau && !muonTau && nch == 1) ||
221  (allow3Prong_ && !electronTau && !muonTau && nch == 3));
222 }

References funct::abs(), allow1Prong_, allow3Prong_, allowElectron_, allowMuon_, countProngs(), TopDecayID::elecID, TopDecayID::muonID, and metsig::tau.

Referenced by operator()().

Member Data Documentation

◆ allow1Prong_

bool TtDecayChannelSelector::allow1Prong_
private

allow 1-prong tau decays

Definition at line 46 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

◆ allow3Prong_

bool TtDecayChannelSelector::allow3Prong_
private

allow 2-prong tau decays

Definition at line 48 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

◆ allowedDecays_

Decay TtDecayChannelSelector::allowedDecays_
private

vector of allowed lepton decay channels; values may be 0,1,2 for the entries 'Elec','Muon','Tau'

Definition at line 55 of file TtDecayChannelSelector.h.

Referenced by operator()(), and TtDecayChannelSelector().

◆ allowElectron_

bool TtDecayChannelSelector::allowElectron_
private

allow tau decays into electron

Definition at line 42 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

◆ allowMuon_

bool TtDecayChannelSelector::allowMuon_
private

allow tau decays into muon

Definition at line 44 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

◆ decayBranchA_

Decay TtDecayChannelSelector::decayBranchA_
private

top decay branch 1

Definition at line 50 of file TtDecayChannelSelector.h.

Referenced by decayChannel(), operator()(), and TtDecayChannelSelector().

◆ decayBranchB_

Decay TtDecayChannelSelector::decayBranchB_
private

top decay branch 2

Definition at line 52 of file TtDecayChannelSelector.h.

Referenced by decayChannel(), operator()(), and TtDecayChannelSelector().

◆ invert_

bool TtDecayChannelSelector::invert_
private

invert selection

Definition at line 38 of file TtDecayChannelSelector.h.

Referenced by operator()().

◆ restrictTauDecays_

bool TtDecayChannelSelector::restrictTauDecays_
private

restrict tau decays

Definition at line 40 of file TtDecayChannelSelector.h.

Referenced by operator()(), and TtDecayChannelSelector().

TtDecayChannelSelector::allow3Prong_
bool allow3Prong_
allow 2-prong tau decays
Definition: TtDecayChannelSelector.h:48
metsig::tau
Definition: SignAlgoResolutions.h:49
TtDecayChannelSelector::allowMuon_
bool allowMuon_
allow tau decays into muon
Definition: TtDecayChannelSelector.h:44
TtDecayChannelSelector::decayChannel
unsigned int decayChannel() const
return decay channel to select for from configuration
Definition: TtDecayChannelSelector.h:58
TopDecayID::bID
static const int bID
Definition: TopGenEvent.h:13
TtDecayChannelSelector::decayBranchB_
Decay decayBranchB_
top decay branch 2
Definition: TtDecayChannelSelector.h:52
reco::candidate::const_iterator
Definition: const_iterator.h:14
TtDecayChannelSelector::allowElectron_
bool allowElectron_
allow tau decays into electron
Definition: TtDecayChannelSelector.h:42
kGenParticles
static const std::string kGenParticles
Definition: TtDecayChannelSelector.cc:9
TtDecayChannelSelector::Elec
Definition: TtDecayChannelSelector.h:11
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
Tau
Definition: Tau.py:1
TopDecayID::elecID
static const int elecID
Definition: TopGenEvent.h:18
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
Muon
Definition: Muon.py:1
TopDecayID::muonID
static const int muonID
Definition: TopGenEvent.h:19
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
contentValuesFiles.parts
parts
Definition: contentValuesFiles.py:58
part
part
Definition: HCALResponse.h:20
TtDecayChannelFilter_cfi.decayBranchA
decayBranchA
Definition: TtDecayChannelFilter_cfi.py:14
TtDecayChannelSelector::allow1Prong_
bool allow1Prong_
allow 1-prong tau decays
Definition: TtDecayChannelSelector.h:46
TopDecayID::tID
static const int tID
Definition: TopGenEvent.h:12
TtDecayChannelSelector::invert_
bool invert_
invert selection
Definition: TtDecayChannelSelector.h:38
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
funct::true
true
Definition: Factorize.h:173
TtDecayChannelSelector::search
bool search(reco::GenParticleCollection::const_iterator &part, int pdgId, std::string &inputType) const
search for particle with pdgId in given listing (for top)
Definition: TtDecayChannelSelector.cc:168
edm::ParameterSet
Definition: ParameterSet.h:47
TtDecayChannelSelector::Muon
Definition: TtDecayChannelSelector.h:11
createfilelist.int
int
Definition: createfilelist.py:10
TtDecayChannelSelector::Tau
Definition: TtDecayChannelSelector.h:11
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
kDecayChannels
static const unsigned int kDecayChannels
Definition: TtDecayChannelSelector.cc:13
TtDecayChannelSelector::checkSum
unsigned int checkSum(const Decay &vec) const
Definition: TtDecayChannelSelector.h:69
TtDecayChannelSelector::allowedDecays_
Decay allowedDecays_
Definition: TtDecayChannelSelector.h:55
looper.cfg
cfg
Definition: looper.py:297
TopDecayID::WID
static const int WID
Definition: TopGenEvent.h:17
TopDecayID::tauID
static const int tauID
Definition: TopGenEvent.h:20
TtDecayChannelSelector::decayBranchA_
Decay decayBranchA_
top decay branch 1
Definition: TtDecayChannelSelector.h:50
TtDecayChannelFilter_cfi.allowedTopDecays
allowedTopDecays
allow given lepton in corresponding decay branch for a given decay-channel selection; all leptons to ...
Definition: TtDecayChannelFilter_cfi.py:13
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
TtDecayChannelFilter_cfi.decayBranchB
decayBranchB
Definition: TtDecayChannelFilter_cfi.py:19
TopDecayID::unfrag
static const int unfrag
Definition: TopGenEvent.h:11
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TtDecayChannelSelector::countProngs
unsigned int countProngs(const reco::Candidate &part) const
count the number of charged particles for tau decays
Definition: TtDecayChannelSelector.cc:186
TtDecayChannelSelector::restrictTauDecays_
bool restrictTauDecays_
restrict tau decays
Definition: TtDecayChannelSelector.h:40
edm::Log
Definition: MessageLogger.h:70
TtDecayChannelSelector::tauDecay
bool tauDecay(const reco::Candidate &) const
check tau decay to be leptonic, 1-prong or 3-prong
Definition: TtDecayChannelSelector.cc:199