CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PythiaFilterTTBar.cc
Go to the documentation of this file.
2 
3 
4 //
5 // constants, enums and typedefs
6 //
7 
8 //
9 // static data member definitions
10 //
11 
12 //
13 // constructors and destructor
14 //
15 
17  token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
18  decayType_(iConfig.getUntrackedParameter("decayType",1)),
19  leptonFlavour_(iConfig.getUntrackedParameter("leptonFlavour",0))
20 {
21 }
22 
23 
25 {
26 
27  // do anything here that needs to be done at desctruction time
28  // (e.g. close files, deallocate resources etc.)
29 
30 }
31 
32 
33 //
34 // member functions
35 //
36 
37 // ------------ method called on each new Event ------------
38 bool
40 {
41 
42  bool accept=false;
43 
45  iEvent.getByToken(token_, evt);
46 
47  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
48 
49  unsigned int iE=0, iMu=0, iTau=0;
50 
51  unsigned int iNuE=0, iNuMu=0, iNuTau=0;
52 
53  unsigned int iLep=0, iNu=0;
54 
55 
56  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
57 
58  int pdgID = (*p)->pdg_id();
59 
60  int status = (*p)->status();
61 
62  if ( status == 3 ) {
63 
64  // count the final state leptons
65 
66  if (fabs(pdgID) == 11)
67  iE++;
68 
69  if(fabs(pdgID) == 13)
70  iMu++;
71 
72  if(fabs(pdgID) == 15)
73  iTau++;
74 
75  // count the final state neutrinos
76 
77  if(fabs(pdgID) == 12)
78  iNuE++;
79 
80  if(fabs(pdgID) == 14)
81  iNuMu++;
82 
83  if(fabs(pdgID) == 16)
84  iNuTau++;
85 
86  }
87 
88  }
89 
90  iLep = (iE+iMu+iTau);
91  iNu = (iNuE+iNuMu+iNuTau);
92 
93  if (decayType_ == 1) { // semi-leptonic decay
94 
95  // l = e,mu,tau
96 
97  if (leptonFlavour_ == 0 && iLep == 1 && iNu == 1)
98  accept=true;
99 
100  // l = e
101 
102  else if (leptonFlavour_ == 1 && iE == 1 && iNuE == 1 && iLep == 1 && iNu == 1)
103  accept=true;
104 
105  // l = mu
106 
107  else if (leptonFlavour_ == 2 && iMu == 1 && iNuMu == 1 && iLep == 1 && iNu == 1)
108  accept=true;
109 
110  // l = tau
111 
112  else if (leptonFlavour_ == 3 && iTau == 1 && iNuTau == 1 && iLep == 1 && iNu == 1)
113  accept=true;
114 
115  }
116 
117  else if (decayType_ == 2) { // di-leptonic decay (inclusive)
118 
119  if (iLep == 2 && iNu == 2)
120  accept=true;
121 
122  }
123 
124  else if (decayType_ == 3) { // fully-hadronic decay
125 
126  if (iLep == 0 && iNu == 0)
127  accept=true;
128  }
129 
130  else
131  accept=false;
132 
133 
134  return accept;
135 }
136 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< edm::HepMCProduct > token_
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
int iEvent
Definition: GenABIO.cc:230
unsigned int leptonFlavour_
virtual bool filter(edm::Event &, const edm::EventSetup &)
unsigned int decayType_
PythiaFilterTTBar(const edm::ParameterSet &)
tuple status
Definition: ntuplemaker.py:245