CMS 3D CMS Logo

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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
33 #include <iostream>
34 
35 //
36 // class declaration
37 //
38 
39 class FourLepFilter : public edm::EDFilter {
40  public:
41  explicit FourLepFilter(const edm::ParameterSet&);
42  ~FourLepFilter() override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  private:
47 
48  bool filter(edm::Event&, const edm::EventSetup&) override;
49 
50  // ----------member data ---------------------------
51 
53  double minPt;
54  double maxEta;
55  double maxPt;
56  double minEta;
58 };
59 
60 //
61 // constants, enums and typedefs
62 //
63 
64 //
65 // static data member definitions
66 //
67 
68 //
69 // constructors and destructor
70 //
72 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
73 minPt(iConfig.getUntrackedParameter("MinPt", 0.)),
74 maxEta(iConfig.getUntrackedParameter("MaxEta", 10.)),
75 maxPt(iConfig.getUntrackedParameter("MaxPt", 1000.)),
76 minEta(iConfig.getUntrackedParameter("MinEta", 0.)),
77 particleID(iConfig.getUntrackedParameter("ParticleID", 0))
78 {
79 }
80 
81 
83 {
84 
85  // do anything here that needs to be done at desctruction time
86  // (e.g. close files, deallocate resources etc.)
87 
88 }
89 
90 
91 //
92 // member functions
93 //
94 
95 // ------------ method called on each new Event ------------
96 bool
98 {
99  using namespace edm;
100 // FourMuonInput++;
101 // std::cout<<"NumberofInputEvent "<<FourMuonInput<<std::endl;
102 
103  bool accepted = false;
104 // int n4muon = 0;
105  int nLeptons = 0;
106 
108  iEvent.getByToken(token_, evt);
109  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
110 
111 
112  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
113  if ( (*p)->status()!=1 ) continue;
114 // if ( abs((*p)->pdg_id()) == particleID )n4muon++;
115  if ((*p)->momentum().perp() > minPt && fabs((*p)->momentum().eta()) < maxEta &&
116  (*p)->momentum().perp() < maxPt && fabs((*p)->momentum().eta()) > minEta) {
117  if ( abs((*p)->pdg_id()) == particleID ) nLeptons++;
118  }
119  if (nLeptons >= 4) {
120  accepted = true;
121 // FourMuonFilter++;
122 // std::cout<<"NumberofFourMuonFilter "<<FourMuonFilter<<std::endl;
123  break;
124  }
125  }
126 
127 // if(n4muon>=4){FourMuon++; std::cout<<"NumberofFourMuon "<<FourMuon<<std::endl;}
128 
129  if (accepted) {
130  return true;
131  } else {
132  return false;
133  }
134 
135 
136 }
137 
138 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
139 void
141  //The following says we do not know what parameters are allowed so do no validation
142  // Please change this to state exactly what you do use, even if it is no parameters
144  desc.setUnknown();
145  descriptions.addDefault(desc);
146 }
147 //define this as a plug-in
FourLepFilter(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetToken token_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
~FourLepFilter() override
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
bool accepted(std::vector< std::string_view > const &, std::string_view)
HLT enums.
bool filter(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)