CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PythiaFilterZgamma.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include<list>
5 #include<vector>
6 #include<cmath>
7 
9 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
10 selProc(iConfig.getUntrackedParameter<int>("SelectProcess")),
11 ptElMin(iConfig.getUntrackedParameter<double>("MinElPt", 5.0)),
12 ptMuMin(iConfig.getUntrackedParameter<double>("MinMuPt", 3.0)),
13 ptPhotonMin(iConfig.getUntrackedParameter<double>("MinPhotPt", 5.0)),
14 etaElMax(iConfig.getUntrackedParameter<double>("MaxElecEta", 2.7)),
15 etaMuMax(iConfig.getUntrackedParameter<double>("MaxMuonEta", 2.4)),
16 etaPhotonMax(iConfig.getUntrackedParameter<double>("MaxPhotEta", 2.7))
17 {
19 }
20 
21 
23 
24 
25 // ------------ method called to produce the data ------------
27 
28 
29  bool accepted = false;
31  iEvent.getByToken(token_, evt);
32 
33  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
34 
35  std::vector<const HepMC::GenParticle *> el;
36  std::vector<const HepMC::GenParticle *> mu;
37  std::vector<const HepMC::GenParticle *> gam;
38 
39  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
40  p != myGenEvent->particles_end(); ++p ) {
41 
42  if(selProc == 1 ) {
43  if ( std::abs((*p)->pdg_id())==11 && (*p)->status()==1 )
44  el.push_back(*p);
45  if(el.size()>1) break;
46  } else if(selProc == 2 ) {
47  if ( std::abs((*p)->pdg_id())==13 && (*p)->status()==1 )
48  mu.push_back(*p);
49  if(mu.size()>1) break;
50  }
51 
52  } // end of first particle loop for finding Z0 decays
53 
54  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
55  p != myGenEvent->particles_end(); ++p ) {
56 
57  if ( std::abs((*p)->pdg_id())==22 && (*p)->status()==1 )
58  gam.push_back(*p);
59  if(gam.size()==1) break;
60 
61  } // end of second particle loop for finding gamma
62 
63  if(selProc == 1 ) {
64  if(el.size()>1){
65  double ptEl1 = el[0]->momentum().perp();
66  double ptEl2 = el[1]->momentum().perp();
67  double etaEl1 = el[0]->momentum().eta();
68  double etaEl2 = el[1]->momentum().eta();
69  if (ptEl1 > ptElMin && ptEl2 > ptElMin &&
70  std::abs(etaEl1) < etaElMax &&
71  std::abs(etaEl2) < etaElMax) {
72  if(gam.size()==1) {
73  double ptGam = gam[0]->momentum().perp();
74  double etaGam = gam[0]->momentum().eta();
75  if(ptGam > ptPhotonMin && std::abs(etaGam) < etaPhotonMax)
76  accepted=true;
77  }
78  }
79  }
80  } else if(selProc == 2 ) {
81 
82  if(mu.size()>1){
83  double ptMu1 = mu[0]->momentum().perp();
84  double ptMu2 = mu[1]->momentum().perp();
85  double etaMu1 = mu[0]->momentum().eta();
86  double etaMu2 = mu[1]->momentum().eta();
87  if (ptMu1 > ptMuMin && ptMu2 > ptMuMin &&
88  std::abs(etaMu1) < etaMuMax &&
89  std::abs(etaMu2) < etaMuMax) {
90  if(gam.size()==1) {
91  double ptGam = gam[0]->momentum().perp();
92  double etaGam = gam[0]->momentum().eta();
93  if(ptGam > ptPhotonMin && std::abs(etaGam) < etaPhotonMax)
94  accepted=true;
95  }
96  }
97  }
98 
99  }
100 /*
101  if(accepted) {
102  std::cout << "Accepted event Number: " << theNumberOfSelected
103  << " of category " << selProc << std::endl;
104  if(selProc == 1 ) {
105  std::cout << "Electon 1 pt, eta = " << el[0]->momentum().perp() << ", "
106  << el[0]->momentum().eta() << std::endl;
107  std::cout << "Electon 2 pt, eta = " << el[1]->momentum().perp() << ", "
108  << el[1]->momentum().eta() << std::endl;
109  std::cout << "Photon pt, eta = " << gam[0]->momentum().perp() << ", "
110  << gam[0]->momentum().eta() << std::endl;
111  } else if(selProc == 2 ) {
112  std::cout << "Muon 1 pt, eta = " << mu[0]->momentum().perp() << ", "
113  << mu[0]->momentum().eta() << std::endl;
114  std::cout << "Muon 2 pt, eta = " << mu[1]->momentum().perp() << ", "
115  << mu[1]->momentum().eta() << std::endl;
116  std::cout << "Photon pt, eta = " << gam[0]->momentum().perp() << ", "
117  << gam[0]->momentum().eta() << std::endl;
118 
119  }
120  }
121 */
122  if (accepted) {
124  return true;
125  }
126  else return false;
127 
128 }
129 
edm::EDGetTokenT< edm::HepMCProduct > token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
int iEvent
Definition: GenABIO.cc:230
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
virtual bool filter(edm::Event &, const edm::EventSetup &)
PythiaFilterZgamma(const edm::ParameterSet &)