CMS 3D CMS Logo

EcalGenEvtSelector.cc
Go to the documentation of this file.
1 #include <iostream>
4 using namespace std;
5 
7 
8  partonId_ = pset.getParameter<vector<int> >("partons");
9  partonStatus_ = pset.getParameter<vector<int> >("partonStatus");
10  partonPt_ = pset.getParameter<vector<double> >("partonPt");
11 
12  particleId_ = pset.getParameter<vector<int> >("particles");
13  particleStatus_ = pset.getParameter<vector<int> >("particleStatus");
14  particlePt_ = pset.getParameter<vector<double> >("particlePt");
15 
16  etaMax_ = pset.getParameter<double>("etaMax");
17 
18  int id = partonId_.size();
19  int st = partonStatus_.size();
20  int pt = partonPt_.size();
21 
22  if(partonId_.size() != partonStatus_.size() || partonId_.size() != partonPt_.size()){
23  throw edm::Exception(edm::errors::LogicError)<<id<<st<<pt<<endl;
24  }
25 
26  id = particleId_.size();
27  st = particleStatus_.size();
28  pt = particlePt_.size();
29 
30  if(particleId_.size() != particleStatus_.size() || particleId_.size() != particlePt_.size()){
31  throw edm::Exception(edm::errors::LogicError)<<id<<st<<pt<<endl;
32 
33  }
34 
35 }
36 
37 bool EcalGenEvtSelector::filter(HepMC::GenEvent *evt){
38  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
39  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
40 
41  bool foundParticle = false;
42  bool foundParton = false;
43 
44  HepMC::GenEvent::particle_const_iterator it = begin;
45  while((!foundParton || !foundParticle) && it != end){
46  for(unsigned i = 0; i < partonId_.size(); ++i){
47  if(selectParticle(*it, partonStatus_[i], partonId_[i], partonPt_[i], etaMax_)) foundParton = true;
48  }
49  for(unsigned i = 0; i < particleId_.size(); ++i){
50  if(selectParticle(*it, particleStatus_[i], particleId_[i], particlePt_[i], etaMax_)) foundParticle = true;
51  }
52  ++it;
53  }
54 
55  return (foundParton && foundParticle);
56 }
std::vector< int > partonId_
T getParameter(std::string const &) const
std::vector< double > partonPt_
std::vector< int > particleStatus_
bool selectParticle(HepMC::GenParticle *par, int status, int pdg, double ptMin, double etaMax)
std::vector< int > particleId_
bool filter(HepMC::GenEvent *) override
EcalGenEvtSelector(const edm::ParameterSet &pset)
std::vector< double > particlePt_
#define end
Definition: vmac.h:39
std::vector< int > partonStatus_
#define begin
Definition: vmac.h:32