CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PythiaFilterZJetWithOutBg.cc
Go to the documentation of this file.
4 #include <iostream>
5 #include<list>
6 #include<vector>
7 #include<cmath>
8 
10 label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
11 etaMuMax(iConfig.getUntrackedParameter<double>("MaxMuonEta", 2.5)),
12 ptMuMin(iConfig.getUntrackedParameter<double>("MinMuonPt", 3.5)),
13 ptZMin(iConfig.getUntrackedParameter<double>("MinZPt")),
14 ptZMax(iConfig.getUntrackedParameter<double>("MaxZPt")),
15 maxnumberofeventsinrun(iConfig.getUntrackedParameter<int>("MaxEvents",10000))
16 {
17  m_z=91.19;
18  dm_z=10.;
20 }
21 
22 
24 
25 
26 // ------------ method called to produce the data ------------
28 
29 // if(theNumberOfSelected>=maxnumberofeventsinrun) {
30 // throw cms::Exception("endJob")<<"we have reached the maximum number of events ";
31 // }
32 
33  bool accepted = false;
35  iEvent.getByLabel(label_, evt);
36 
37  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
38 
39 
40 
41  std::vector<const HepMC::GenParticle *> mu;
42 
43  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
44 
45  if ( std::abs((*p)->pdg_id())==13 && (*p)->status()==1 )
46  mu.push_back(*p);
47  if(mu.size()>1) break;
48  }
49 
50 // std::cout<<" Number of muons "<<mu.size()<<" "<<mu[0]->pdg_id()<<" "<<mu[1]->pdg_id()<<std::endl;
51 
52  if(mu.size() != 2) return false;
53 
54  if(mu[0]->pdg_id()*(mu[1]->pdg_id()) > 0) {
55  return false;
56  }
57 
58 // std::cout<<" Muons sign accept "<<mu[0]->momentum().perp()<<" "<<mu[1]->momentum().perp()<<std::endl;
59 
60  if(mu[0]->momentum().perp()<ptMuMin || mu[1]->momentum().perp()<ptMuMin) return false;
61 
62 // std::cout<<" Muons pt accept "<<std::fabs(mu[0]->momentum().eta())<<" "<<std::fabs(mu[1]->momentum().eta())<<std::endl;
63 
64  if(std::fabs(mu[0]->momentum().eta()) > etaMuMax) return false;
65  if(std::fabs(mu[1]->momentum().eta()) > etaMuMax) return false;
66 
67 
68  double mmup = mu[0]->generatedMass();
69  double mmum = mu[1]->generatedMass();
70  double pxZ = mu[0]->momentum().x()+mu[1]->momentum().x();
71  double pyZ = mu[0]->momentum().y()+mu[1]->momentum().y();
72  double pzZ = mu[0]->momentum().z()+mu[1]->momentum().z();
73 
74  double pmup2 = mu[0]->momentum().x()*mu[0]->momentum().x()+
75  mu[0]->momentum().y()*mu[0]->momentum().y()+
76  mu[0]->momentum().z()*mu[0]->momentum().z();
77  double pmum2 = mu[1]->momentum().x()*mu[1]->momentum().x()+
78  mu[1]->momentum().y()*mu[1]->momentum().y()+
79  mu[1]->momentum().z()*mu[1]->momentum().z();
80  double emup = sqrt(pmup2+mmup*mmup);
81  double emum = sqrt(pmum2+mmum*mmum);
82 
83  double massZ = sqrt((emup+emum)*(emup+emum)-pxZ*pxZ-pyZ*pyZ-pzZ*pzZ);
84 
85 // std::cout<<" Muons eta accept "<<massZ<<std::endl;
86 
87 
88  if(std::fabs(massZ-m_z)>dm_z) return false;
89 
90  // double ptZ= (mu[0]->momentum() + mu[1]->momentum()).perp();
91 // std::cout<<" MassZ accept "<<ptZ<<std::endl;
92 
93  math::XYZTLorentzVector tot_mom(mu[0]->momentum());
94  math::XYZTLorentzVector mom2(mu[1]->momentum());
95  tot_mom += mom2;
96  // double ptZ= (mu[0]->momentum() + mu[1]->momentum()).perp();
97  double ptZ = tot_mom.pt();
98 
99 
100  if (ptZ > ptZMin && ptZ < ptZMax ) accepted=true;
101 
102 
103  if (accepted) {
105  std::cout<<" Event accept "<<theNumberOfSelected<<std::endl;
106  return true;
107  }
108  else return false;
109 
110 }
111 
#define abs(x)
Definition: mlp_lapack.h:159
T eta() const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
int iEvent
Definition: GenABIO.cc:243
T sqrt(T t)
Definition: SSEVec.h:46
virtual bool filter(edm::Event &, const edm::EventSetup &)
const int mu
Definition: Constants.h:23
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple cout
Definition: gather_cfg.py:121
PythiaFilterZJetWithOutBg(const edm::ParameterSet &)