CMS 3D CMS Logo

PartonHadronDecayGenEvtSelector.cc
Go to the documentation of this file.
1 #include <iostream>
4 using namespace std;
5 
7  : BaseHiGenEvtSelector(pset) {
8  hadronId_ = pset.getParameter<vector<int> >("hadrons");
9  hadronStatus_ = pset.getParameter<vector<int> >("hadronStatus");
10  hadronEtaMax_ = pset.getParameter<vector<double> >("hadronEtaMax");
11  hadronEtaMin_ = pset.getParameter<vector<double> >("hadronEtaMin");
12  hadronPMin_ = pset.getParameter<vector<double> >("hadronPMin");
13  hadronPtMax_ = pset.getParameter<vector<double> >("hadronPtMax");
14  hadronPtMin_ = pset.getParameter<vector<double> >("hadronPtMin");
15 
16  decayId_ = pset.getParameter<int>("decays");
17  decayStatus_ = pset.getParameter<int>("decayStatus");
18  decayEtaMax_ = pset.getParameter<double>("decayEtaMax");
19  decayEtaMin_ = pset.getParameter<double>("decayEtaMin");
20  decayPMin_ = pset.getParameter<double>("decayPMin");
21  decayPtMax_ = pset.getParameter<double>("decayPtMax");
22  decayPtMin_ = pset.getParameter<double>("decayPtMin");
23  decayNtrig_ = pset.getParameter<int>("decayNtrig");
24 
25  partonId_ = pset.getParameter<vector<int> >("partons");
26  partonStatus_ = pset.getParameter<vector<int> >("partonStatus");
27  partonEtaMax_ = pset.getParameter<vector<double> >("partonEtaMax");
28  partonPtMin_ = pset.getParameter<vector<double> >("partonPtMin");
29 
30  int id = hadronId_.size();
31  int st = hadronStatus_.size();
32  int etamax = hadronEtaMax_.size();
33  int etamin = hadronEtaMin_.size();
34  int pmin = hadronPMin_.size();
35  int ptmax = hadronPtMax_.size();
36  int ptmin = hadronPtMin_.size();
37 
38  if (id != st || id != etamax || id != etamin || id != ptmax || id != ptmin || id != pmin) {
40  << "Hadron selection parameters: " << id << st << etamax << etamin << pmin << ptmax << ptmin << endl;
41  }
42 
43  id = partonId_.size();
44  st = partonStatus_.size();
45  etamax = partonEtaMax_.size();
46  ptmin = partonPtMin_.size();
47 
48  if (id != st || id != etamax || id != ptmin) {
50  << "Parton selection parameters: " << id << st << etamax << ptmin << endl;
51  }
52 }
53 
54 //____________________________________________________________________________________________
56  // loop over HepMC event, and search for products of interest
57 
58  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
59  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
60 
61  bool foundHadron = false;
62  bool foundDecay = false;
63  bool foundParton = false;
64 
65  HepMC::GenEvent::particle_const_iterator it = begin;
66  while (!foundParton && it != end) {
67  for (unsigned i = 0; i < partonId_.size(); ++i) {
69  foundParton = true;
70  }
71  ++it;
72  }
73 
74  int foundtrig = 0;
75  HepMC::GenEvent::particle_const_iterator it2 = begin;
76 
77  if (foundParton) {
78  while ((!foundHadron || !foundDecay) && it2 != end) {
79  for (unsigned i = 0; i < hadronId_.size(); ++i) {
80  if (selectParticle(*it2,
82  hadronId_[i],
83  hadronEtaMax_[i],
84  hadronEtaMin_[i],
85  hadronPMin_[i],
86  hadronPtMax_[i],
87  hadronPtMin_[i]))
88  foundHadron = true;
89  }
90 
91  if (selectParticle(
93  foundtrig++;
94  if (decayNtrig_ == foundtrig)
95  foundDecay = true;
96 
97  ++it2;
98  }
99  }
100 
101  return (foundHadron && foundDecay && foundParton);
102 }
103 
104 //____________________________________________________________________________________________
T getParameter(std::string const &) const
PartonHadronDecayGenEvtSelector(const edm::ParameterSet &pset)
#define end
Definition: vmac.h:39
double ptmin
Definition: HydjetWrapper.h:84
#define begin
Definition: vmac.h:32
bool filter(HepMC::GenEvent *) override
bool selectParticle(HepMC::GenParticle *par, int status, int pdg, double ptMin, double etaMax)