CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FourLepFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FourLepFilter
4 // Class: FourLepFilter
5 //
13 //
14 // Original Author: bian jianguo
15 // Created: Tue Nov 22 20:39:54 CST 2011
16 // $Id: FourLepFilter.cc,v 1.1 2012/03/16 14:37:33 lenzip Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
33 
34 #include <iostream>
35 
36 //
37 // class declaration
38 //
39 
40 class FourLepFilter : public edm::EDFilter {
41  public:
42  explicit FourLepFilter(const edm::ParameterSet&);
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47  private:
48  virtual void beginJob() ;
49  virtual bool filter(edm::Event&, const edm::EventSetup&);
50  virtual void endJob() ;
51 
52  virtual bool beginRun(edm::Run&, edm::EventSetup const&);
53  virtual bool endRun(edm::Run&, edm::EventSetup const&);
56 
57  // ----------member data ---------------------------
58 
59  std::string label_;
60  double minPt;
61  double maxEta;
62  double maxPt;
63  double minEta;
65 };
66 
67 //
68 // constants, enums and typedefs
69 //
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79 label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
80 minPt(iConfig.getUntrackedParameter("MinPt", 0.)),
81 maxEta(iConfig.getUntrackedParameter("MaxEta", 10.)),
82 maxPt(iConfig.getUntrackedParameter("MaxPt", 1000.)),
83 minEta(iConfig.getUntrackedParameter("MinEta", 0.)),
84 particleID(iConfig.getUntrackedParameter("ParticleID", 0))
85 {
86 }
87 
88 
90 {
91 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 
95 }
96 
97 
98 //
99 // member functions
100 //
101 
102 // ------------ method called on each new Event ------------
103 bool
105 {
106  using namespace edm;
107 // FourMuonInput++;
108 // std::cout<<"NumberofInputEvent "<<FourMuonInput<<std::endl;
109 
110  bool accepted = false;
111 // int n4muon = 0;
112  int nLeptons = 0;
113 
115  iEvent.getByLabel(label_, evt);
116  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
117 
118 
119  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
120  if ( (*p)->status()!=1 ) continue;
121 // if ( abs((*p)->pdg_id()) == particleID )n4muon++;
122  if ((*p)->momentum().perp() > minPt && fabs((*p)->momentum().eta()) < maxEta &&
123  (*p)->momentum().perp() < maxPt && fabs((*p)->momentum().eta()) > minEta) {
124  if ( abs((*p)->pdg_id()) == particleID ) nLeptons++;
125  }
126  if (nLeptons >= 4) {
127  accepted = true;
128 // FourMuonFilter++;
129 // std::cout<<"NumberofFourMuonFilter "<<FourMuonFilter<<std::endl;
130  break;
131  }
132  }
133 
134 // if(n4muon>=4){FourMuon++; std::cout<<"NumberofFourMuon "<<FourMuon<<std::endl;}
135 
136  if (accepted) {
137  return true;
138  } else {
139  return false;
140  }
141 
142 
143 }
144 
145 // ------------ method called once each job just before starting event loop ------------
146 void
148 {
149 }
150 
151 // ------------ method called once each job just after ending the event loop ------------
152 void
154 }
155 
156 // ------------ method called when starting to processes a run ------------
157 bool
159 {
160  return true;
161 }
162 
163 // ------------ method called when ending the processing of a run ------------
164 bool
166 {
167  return true;
168 }
169 
170 // ------------ method called when starting to processes a luminosity block ------------
171 bool
173 {
174  return true;
175 }
176 
177 // ------------ method called when ending the processing of a luminosity block ------------
178 bool
180 {
181  return true;
182 }
183 
184 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
185 void
187  //The following says we do not know what parameters are allowed so do no validation
188  // Please change this to state exactly what you do use, even if it is no parameters
190  desc.setUnknown();
191  descriptions.addDefault(desc);
192 }
193 //define this as a plug-in
FourLepFilter(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endJob()
#define abs(x)
Definition: mlp_lapack.h:159
virtual bool endLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
virtual bool beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
virtual bool filter(edm::Event &, const edm::EventSetup &)
double maxEta
virtual bool beginRun(edm::Run &, edm::EventSetup const &)
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
virtual bool endRun(edm::Run &, edm::EventSetup const &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string label_
virtual void beginJob()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Run.h:33