CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HZZ4lFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HZZ4lFilter
4 // Class: HZZ4lFilter
5 //
13 //
14 // Original Author: Puljak Ivica
15 // Created: Wed Apr 18 12:52:31 CEST 2007
16 //
17 //
18 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
34 
35 
37 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
38 minPtElectronMuon(iConfig.getUntrackedParameter("MinPtElectronMuon", 0.)),
39 maxEtaElectronMuon(iConfig.getUntrackedParameter("MaxEtaElectronMuon", 10.))
40 {
41  //now do what ever initialization is needed
42 
43 }
44 
45 
47 {
48 
49  // do anything here that needs to be done at desctruction time
50  // (e.g. close files, deallocate resources etc.)
51 
52 }
53 
54 
55 //
56 // member functions
57 //
58 
59 // ------------ method called on each new Event ------------
60 bool
62 {
63  using namespace edm;
64 
65  bool accepted = false;
66  int nLeptons = 0;
67 
69  iEvent.getByToken(token_, evt);
70 
71  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
72 
73  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
74 
75  if ( (*p)->status()!=1 ) continue;
76 
77  if ((*p)->momentum().perp() > minPtElectronMuon && fabs((*p)->momentum().eta()) < maxEtaElectronMuon) {
78  if ( abs((*p)->pdg_id()) == 11 || abs((*p)->pdg_id()) == 13 ) nLeptons++;
79  }
80  if (nLeptons == 3) {
81  accepted = true;
82  break;
83  }
84  }
85 
86  delete myGenEvent;
87 
88  if (accepted) {
89  return true;
90  } else {
91  return false;
92  }
93 
94 }
95 
96 
97 /*
98 // ------------ method called once each job just before starting event loop ------------
99 
100 // ------------ method called once each job just after ending the event loop ------------
101 void
102 HZZ4lFilter::endJob() {
103 }
104 */
105 
double minPtElectronMuon
Definition: HZZ4lFilter.h:55
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
double maxEtaElectronMuon
Definition: HZZ4lFilter.h:56
int iEvent
Definition: GenABIO.cc:230
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: HZZ4lFilter.h:53
HZZ4lFilter(const edm::ParameterSet &)
Definition: HZZ4lFilter.cc:36
virtual bool filter(edm::Event &, const edm::EventSetup &)
Definition: HZZ4lFilter.cc:61