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::GenParticleCollection::const_iterator &part, int pdgId, std::string &inputType) const
 search for particle with pdgId in given listing (for top) 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 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

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

typedef to simplify the decay vectors

Definition at line 15 of file TtDecayChannelSelector.h.

Member Enumeration Documentation

anonymous enum

leafs of leptonic decay channel vector decay_

Enumerator
Elec 
Muon 
Tau 

Definition at line 13 of file TtDecayChannelSelector.h.

Constructor & Destructor Documentation

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

std contructor

Definition at line 16 of file TtDecayChannelSelector.cc.

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

16  :
17  invert_ ( cfg.getParameter<bool>("invert" ) ),
18  allowElectron_(false), allowMuon_(false), allow1Prong_(false),
19  allow3Prong_(false)
20 {
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
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" )||
28  allowedTauDecays.existsAs<bool>("muon" )||
29  allowedTauDecays.existsAs<bool>("oneProng" )||
30  allowedTauDecays.existsAs<bool>("threeProng") );
31  // specify the different possible restrictions of the tau decay channels
32  allowElectron_ = (allowedTauDecays.existsAs<bool>("electron" ) ? allowedTauDecays.getParameter<bool>("electron" ) : false);
33  allowMuon_ = (allowedTauDecays.existsAs<bool>("muon" ) ? allowedTauDecays.getParameter<bool>("muon" ) : false);
34  allow1Prong_ = (allowedTauDecays.existsAs<bool>("oneProng" ) ? allowedTauDecays.getParameter<bool>("oneProng" ) : false);
35  allow3Prong_ = (allowedTauDecays.existsAs<bool>("threeProng") ? allowedTauDecays.getParameter<bool>("threeProng") : false);
36  }
37  // allowed top decays PSet
39 
40  // fill decayBranchA_
41  edm::ParameterSet decayBranchA = allowedTopDecays.getParameter<edm::ParameterSet>("decayBranchA");
42  decayBranchA_.push_back(decayBranchA.getParameter<bool>("electron"));
43  decayBranchA_.push_back(decayBranchA.getParameter<bool>("muon" ));
44  decayBranchA_.push_back(decayBranchA.getParameter<bool>("tau" ));
45 
46  // fill decay branchB_
47  edm::ParameterSet decayBranchB = allowedTopDecays.getParameter<edm::ParameterSet>("decayBranchB");
48  decayBranchB_.push_back(decayBranchB.getParameter<bool>("electron"));
49  decayBranchB_.push_back(decayBranchB.getParameter<bool>("muon" ));
50  decayBranchB_.push_back(decayBranchB.getParameter<bool>("tau" ));
51 
52  // fill allowedDecays_
53  for(unsigned int d=0; d<kDecayChannels; ++d){
55  }
56 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
Decay decayBranchA_
top decay branch 1
static const unsigned int kDecayChannels
bool restrictTauDecays_
restrict tau decays
Decay decayBranchB_
top decay branch 2
bool allowElectron_
allow tau decays into electron
bool allow3Prong_
allow 2-prong tau decays
bool allowMuon_
allow tau decays into muon
allowedTopDecays
allow given lepton in corresponding decay branch for a given decay-channel selection; all leptons to ...
bool allow1Prong_
allow 1-prong tau decays
bool invert_
invert selection
TtDecayChannelSelector::~TtDecayChannelSelector ( )

default destructor

Definition at line 58 of file TtDecayChannelSelector.cc.

59 {
60 }

Member Function Documentation

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

Definition at line 76 of file TtDecayChannelSelector.h.

References edmIntegrityCheck::d.

Referenced by operator()().

77 {
78  unsigned int sum=0;
79  for(unsigned int d=0; d<vec.size(); ++d){
80  sum+=vec[d];
81  }
82  return sum;
83 }
unsigned int TtDecayChannelSelector::countProngs ( const reco::Candidate part) const
private

count the number of charged particles for tau decays

Definition at line 192 of file TtDecayChannelSelector.cc.

References reco::Candidate::begin(), reco::Candidate::charge(), reco::Candidate::end(), and reco::Candidate::status().

Referenced by tauDecay().

193 {
194  // if stable, return 1 or 0
195  if(part.status()==1){
196  return (part.charge()!=0);
197  }
198  // if unstable, call recursively on daughters
199  int prong =0;
200  for(reco::Candidate::const_iterator daughter=part.begin();daughter!=part.end(); ++daughter){
201  prong += countProngs(*daughter);
202  }
203  return prong;
204 }
virtual int status() const =0
status word
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
unsigned int countProngs(const reco::Candidate &part) const
count the number of charged particles for tau decays
virtual int charge() const =0
electric charge
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
unsigned int TtDecayChannelSelector::decayChannel ( ) const
inlineprivate

return decay channel to select for from configuration

Definition at line 63 of file TtDecayChannelSelector.h.

References KineDebug3::count(), decayBranchA_, and decayBranchB_.

Referenced by operator()().

64 {
65  unsigned int channel=0;
66  if( std::count(decayBranchA_.begin(), decayBranchA_.end(), 1) > 0 ){
67  ++channel;
68  }
69  if( std::count(decayBranchB_.begin(), decayBranchB_.end(), 1) > 0 ){
70  ++channel;
71  }
72  return channel;
73 }
Decay decayBranchA_
top decay branch 1
Decay decayBranchB_
top decay branch 2
bool TtDecayChannelSelector::operator() ( const reco::GenParticleCollection parts,
std::string  inputType 
) const

operator for decay channel selection

Definition at line 63 of file TtDecayChannelSelector.cc.

References funct::abs(), accept(), allowedDecays_, reco::Candidate::begin(), TopDecayID::bID, checkSum(), decayBranchA_, decayBranchB_, decayChannel(), Elec, TopDecayID::elecID, reco::Candidate::end(), createfilelist::int, invert_, cmsBatch::log, Muon, TopDecayID::muonID, restrictTauDecays_, search(), Tau, tauDecay(), TopDecayID::tauID, TopDecayID::tID, and TopDecayID::WID.

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

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

Referenced by operator()().

171 {
172  if(inputType==kGenParticles){
173  return (std::abs(part->pdgId())==pdgId && part->status()==TopDecayID::unfrag) ? true : false;
174  }
175  else{
176  return (std::abs(part->pdgId())==pdgId) ? true : false;
177  }
178 }
static const int unfrag
Definition: TopGenEvent.h:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
part
Definition: HCALResponse.h:20
static const std::string kGenParticles
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 181 of file TtDecayChannelSelector.cc.

References funct::abs(), kGenParticles, reco::Candidate::pdgId(), reco::Candidate::status(), and TopDecayID::unfrag.

182 {
183  if(inputType==kGenParticles){
184  return (std::abs(part->pdgId())==pdgId && part->status()==TopDecayID::unfrag) ? true : false;
185  }
186  else{
187  return (std::abs(part->pdgId())==pdgId) ? true : false;
188  }
189 }
static const int unfrag
Definition: TopGenEvent.h:12
virtual int status() const =0
status word
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const std::string kGenParticles
bool TtDecayChannelSelector::tauDecay ( const reco::Candidate tau) const
private

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

Definition at line 207 of file TtDecayChannelSelector.cc.

References funct::abs(), allow1Prong_, allow3Prong_, allowElectron_, allowMuon_, reco::Candidate::begin(), countProngs(), TopDecayID::elecID, reco::Candidate::end(), TopDecayID::muonID, and reco::Candidate::pdgId().

Referenced by operator()().

208 {
209  bool electronTau = false;
210  bool muonTau = false;
211  unsigned int nch = 0;
212  // loop on tau decays, check for an elec
213  // or muon and count charged particles
214  for(reco::Candidate::const_iterator daughter=tau.begin();daughter!=tau.end(); ++daughter){
215  // if the tau daughter is again a tau, this means that the particle has
216  // still to be propagated; in that case, return the result of the same
217  // method applied on the daughter of the current particle
218  if(daughter->pdgId()==tau.pdgId()){
219  return tauDecay(*daughter);
220  }
221  // check for electron from tau decay
222  electronTau |= (std::abs(daughter->pdgId())==TopDecayID::elecID);
223  // check for muon from tau decay
224  muonTau |= (std::abs(daughter->pdgId())==TopDecayID::muonID);
225  // count charged particles
226  nch += countProngs(*daughter);
227  }
228  return ((allowElectron_ && electronTau) ||
229  (allowMuon_ && muonTau)||
230  (allow1Prong_ && !electronTau && !muonTau && nch==1)||
231  (allow3Prong_ && !electronTau && !muonTau && nch==3));
232 }
virtual int pdgId() const =0
PDG identifier.
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int countProngs(const reco::Candidate &part) const
count the number of charged particles for tau decays
bool allowElectron_
allow tau decays into electron
bool tauDecay(const reco::Candidate &) const
check tau decay to be leptonic, 1-prong or 3-prong
bool allow3Prong_
allow 2-prong tau decays
bool allowMuon_
allow tau decays into muon
static const int muonID
Definition: TopGenEvent.h:20
static const int elecID
Definition: TopGenEvent.h:19
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
bool allow1Prong_
allow 1-prong tau decays

Member Data Documentation

bool TtDecayChannelSelector::allow1Prong_
private

allow 1-prong tau decays

Definition at line 50 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

bool TtDecayChannelSelector::allow3Prong_
private

allow 2-prong tau decays

Definition at line 52 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

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 59 of file TtDecayChannelSelector.h.

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

bool TtDecayChannelSelector::allowElectron_
private

allow tau decays into electron

Definition at line 46 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

bool TtDecayChannelSelector::allowMuon_
private

allow tau decays into muon

Definition at line 48 of file TtDecayChannelSelector.h.

Referenced by tauDecay(), and TtDecayChannelSelector().

Decay TtDecayChannelSelector::decayBranchA_
private

top decay branch 1

Definition at line 54 of file TtDecayChannelSelector.h.

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

Decay TtDecayChannelSelector::decayBranchB_
private

top decay branch 2

Definition at line 56 of file TtDecayChannelSelector.h.

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

bool TtDecayChannelSelector::invert_
private

invert selection

Definition at line 42 of file TtDecayChannelSelector.h.

Referenced by operator()().

bool TtDecayChannelSelector::restrictTauDecays_
private

restrict tau decays

Definition at line 44 of file TtDecayChannelSelector.h.

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