CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PythiaFilterZJet.cc
Go to the documentation of this file.
4 #include <iostream>
5 #include<list>
6 #include<vector>
7 #include<cmath>
8 
10 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
11 etaMuMax(iConfig.getUntrackedParameter<double>("MaxMuonEta", 2.5)),
12 ptZMin(iConfig.getUntrackedParameter<double>("MinZPt")),
13 ptZMax(iConfig.getUntrackedParameter<double>("MaxZPt")),
14 maxnumberofeventsinrun(iConfig.getUntrackedParameter<int>("MaxEvents",10000)){
15 
17 }
18 
19 
21 
22 
23 // ------------ method called to produce the data ------------
25 
26 // if(theNumberOfSelected>=maxnumberofeventsinrun) {
27 // throw cms::Exception("endJob")<<"we have reached the maximum number of events ";
28 // }
29 
30  bool accepted = false;
32  iEvent.getByToken(token_, evt);
33 
34  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
35 
36 
37  if(myGenEvent->signal_process_id() == 15 || myGenEvent->signal_process_id() == 30) {
38 
39 
40  std::vector<const HepMC::GenParticle *> mu;
41 
42  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
43 
44  if ( std::abs((*p)->pdg_id())==13 && (*p)->status()==1 )
45  mu.push_back(*p);
46  if(mu.size()>1) break;
47  }
48 
49  //***
50 
51  if(mu.size()>1){
52  math::XYZTLorentzVector tot_mom(mu[0]->momentum());
53  math::XYZTLorentzVector mom2(mu[1]->momentum());
54  tot_mom += mom2;
55  // double ptZ= (mu[0]->momentum() + mu[1]->momentum()).perp();
56  double ptZ = tot_mom.pt();
57  if (ptZ > ptZMin && ptZ < ptZMax &&
58  std::abs(mu[0]->momentum().eta()) < etaMuMax &&
59  std::abs(mu[1]->momentum().eta()) < etaMuMax)
60  accepted=true;
61  }
62 
63  } else {
64  // end of if(gammajetevent)
65  return true;
66  // accept all non-gammajet events
67  }
68 
69  if (accepted) {
71  return true;
72  }
73  else return false;
74 
75 }
76 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
virtual bool filter(edm::Event &, const edm::EventSetup &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
int iEvent
Definition: GenABIO.cc:230
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
PythiaFilterZJet(const edm::ParameterSet &)
edm::EDGetTokenT< edm::HepMCProduct > token_