CMS 3D CMS Logo

LHEDYdecayFilter.cc
Go to the documentation of this file.
1 
3 
5 #include <iostream>
6 
7 using namespace edm;
8 using namespace std;
9 
10 
12  src_(iConfig.getParameter<InputTag>( "src" ) ),
13  leptonID_(iConfig.getParameter<int>( "leptonID" ) ),
14  verbose_(iConfig.getUntrackedParameter<bool>( "verbose","False" ) )
15 {
16  //now do what ever initialization is needed
17 
18 }
19 
20 
22 {
23 
24  // do anything here that needs to be done at desctruction time
25  // (e.g. close files, deallocate resources etc.)
26 
27 }
28 
29 
30 //
31 // member functions
32 //
33 
34 // ------------ method called to produce the data ------------
36 {
37  bool accepted = false;
38 
40  iEvent.getByLabel( src_, evt );
41 
42  const lhef::HEPEUP hepeup_ = evt->hepeup();
43 
44  const int nup_ = hepeup_.NUP;
45  const std::vector<int> idup_ = hepeup_.IDUP;
46  const std::vector< std::pair<int,int> > mothup_ = hepeup_.MOTHUP;
47  const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP;
48 
49  unsigned int cLep = 0;
50  int netCharge = 0;
51 
52  for ( unsigned int icount = 0 ; icount < (unsigned int)nup_; icount++ ) {
53 
54  if ( std::abs(idup_[icount]) == leptonID_ ) {
55  if ( mothup_[icount].first != 0 ) {
56  if ( idup_[mothup_[icount].first-1] == 23 ) { cLep++; netCharge += idup_[icount]; }
57  }
58  }
59  }
60 
61  if ( cLep == 2 && netCharge == 0 ) {
62  accepted = true;
63  if (verbose_) {
64  for ( unsigned int icount = 0 ; icount < (unsigned int)nup_; icount++ ) {
65  std::cout << "# " << icount << " " << idup_[icount] << " " << (pup_[icount])[0] << " " << (pup_[icount])[1] << " " << (pup_[icount])[2] << " " << (pup_[icount])[3] << " " << (pup_[icount])[4] << std::endl;
66  }
67  }
68  }
69 
70  if (accepted){
71  return true; } else {return false;}
72 
73 }
74 
bool filter(edm::Event &, const edm::EventSetup &) override
const lhef::HEPEUP & hepeup() const
struct HEPEUP_ hepeup_
LHEDYdecayFilter(const edm::ParameterSet &)
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:249
int iEvent
Definition: GenABIO.cc:224
~LHEDYdecayFilter() override
std::vector< FiveVector > PUP
Definition: LesHouches.h:261
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
std::vector< int > IDUP
Definition: LesHouches.h:238
edm::InputTag src_
bool accepted(std::vector< std::string_view > const &, std::string_view)
HLT enums.