CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HadronDecayGenEvtSelector.cc
Go to the documentation of this file.
1 #include <iostream>
4 using namespace std;
5 
7  hadronId_ = pset.getParameter<vector<int> >("hadrons");
8  hadronStatus_ = pset.getParameter<vector<int> >("hadronStatus");
9  hadronEtaMax_ = pset.getParameter<vector<double> >("hadronEtaMax");
10  hadronEtaMin_ = pset.getParameter<vector<double> >("hadronEtaMin");
11  hadronPMin_ = pset.getParameter<vector<double> >("hadronPMin");
12  hadronPtMax_ = pset.getParameter<vector<double> >("hadronPtMax");
13  hadronPtMin_ = pset.getParameter<vector<double> >("hadronPtMin");
14 
15  decayId_ = pset.getParameter<int>("decays");
16  decayStatus_ = pset.getParameter<int>("decayStatus");
17  decayEtaMax_ = pset.getParameter<double>("decayEtaMax");
18  decayEtaMin_ = pset.getParameter<double>("decayEtaMin");
19  decayPMin_ = pset.getParameter<double>("decayPMin");
20  decayPtMax_ = pset.getParameter<double>("decayPtMax");
21  decayPtMin_ = pset.getParameter<double>("decayPtMin");
22  decayNtrig_ = pset.getParameter<int>("decayNtrig");
23 
24  int id = hadronId_.size();
25  int st = hadronStatus_.size();
26  int etamax = hadronEtaMax_.size();
27  int etamin = hadronEtaMin_.size();
28  int pmin = hadronPMin_.size();
29  int ptmax = hadronPtMax_.size();
30  int ptmin = hadronPtMin_.size();
31 
32  if (id != st || id != etamax || id != etamin || id != ptmax || id != ptmin || id != pmin) {
34  << "Hadron selection parameters: " << id << st << etamax << etamin << pmin << ptmax << ptmin << endl;
35  }
36 }
37 
38 //____________________________________________________________________________________________
40  // loop over HepMC event, and search for products of interest
41 
42  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
43  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
44 
45  bool foundHadron = false;
46  bool foundDecay = false;
47 
48  int foundtrig = 0;
49  HepMC::GenEvent::particle_const_iterator it = begin;
50  while ((!foundHadron || !foundDecay) && it != end) {
51  for (unsigned i = 0; i < hadronId_.size(); ++i) {
52  if (selectParticle(*it,
54  hadronId_[i],
55  hadronEtaMax_[i],
56  hadronEtaMin_[i],
57  hadronPMin_[i],
58  hadronPtMax_[i],
59  hadronPtMin_[i]))
60  foundHadron = true;
61  }
62 
64  foundtrig++;
65  if (decayNtrig_ == foundtrig)
66  foundDecay = true;
67 
68  ++it;
69  }
70 
71  return (foundHadron && foundDecay);
72 }
73 
74 //____________________________________________________________________________________________
bool selectParticle(HepMC::GenParticle *par, int status, int pdg, double etaMax, double etaMin, double pMin, double ptMax, double ptMin)
std::vector< double > hadronEtaMax_
HadronDecayGenEvtSelector(const edm::ParameterSet &pset)
std::vector< double > hadronEtaMin_
std::vector< double > hadronPtMax_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< double > hadronPtMin_
double ptmin
Definition: HydjetWrapper.h:84
string end
Definition: dataset.py:937
bool filter(HepMC::GenEvent *) override