23 #include <boost/format.hpp> 28 #include "CLHEP/Vector/LorentzVector.h" 30 #include "HepMC/IO_GenEvent.h" 35 using namespace HepMC;
38 token_(consumes<
edm::
HepMCProduct>(
edm::InputTag(iConfig.getUntrackedParameter(
"moduleLabel",
std::
string(
"generator")),
"unsmeared")))
54 cout <<
"Proc: 2-->2 2-->3 Total" << endl;
71 int id_bdec=0, id_lJet=0, id_b_from_top=0, id_lep = 0;
74 GenVertex * gv_hard =
nullptr;
77 GenVertex * gv_lep =
nullptr;
78 vector<const GenParticle *> vgp_lep;
81 GenVertex * gv =
nullptr;
83 vector<const GenParticle *> vgp_bsec;
86 GenVertex * gv_lJet=
nullptr;
88 vector<const GenParticle *> vgp_lJet;
91 GenVertex * gv_b_t=
nullptr;
93 vector<const GenParticle *> vgp_b_t;
97 for (GenEvent::particle_const_iterator it = myEvt->particles_begin(); it != myEvt->particles_end(); ++it)
101 int abs_id =
abs((*it)->pdg_id());
102 if (abs_id==11 || abs_id==13 || abs_id==15)
105 id_lep = (*it)->pdg_id();
106 gv_lep=(*it)->production_vertex();
110 gp_lep_FSR =
nullptr;
111 for (GenVertex::particle_iterator it = gv_lep->particles_begin(
children); it != gv_lep->particles_end(
children); ++it)
113 if ((*it)->pdg_id() == id_lep)
115 if (!gp_lep_FSR || (*it)->momentum().perp2() > gp_lep_FSR->momentum().perp2())
123 gv_lep = gp_lep_FSR->end_vertex();
124 vgp_lep.push_back(gp_lep_FSR);
136 gv_hard = gp_clep->production_vertex();
140 cout <<
"ERROR: ComphepSingletopFilterPy8: no charged lepton" << endl;
146 for (GenVertex::particle_iterator it = gv_hard->particles_begin(
children); it != gv_hard->particles_end(
children); ++it)
148 int pdg_id = (*it)->pdg_id();
149 int abs_id =
abs(pdg_id);
154 id_lJet = (*it)->pdg_id();
155 gv_lJet=(*it)->production_vertex();
160 for (GenVertex::particle_iterator it = gv_lJet->particles_begin(
children); it != gv_lJet->particles_end(
children); ++it)
162 if ((*it)->pdg_id() == id_lJet)
164 if (!gplJet || (*it)->momentum().perp2() > gplJet->momentum().perp2())
173 gv_lJet = gplJet->end_vertex();
174 vgp_lJet.push_back(gplJet);
183 if (
abs(pdg_id) == 5)
185 if (pdg_id * (gp_clep->pdg_id()) < 0)
189 id_b_from_top = (*it)->pdg_id();
190 gv_b_t = (*it)->production_vertex();
195 for (GenVertex::particle_iterator it = gv_b_t->particles_begin(
children); it != gv_b_t->particles_end(
children); ++it)
197 if ((*it)->pdg_id() == id_b_from_top)
199 if (!gp_b_t || (*it)->momentum().perp2() > gp_b_t->momentum().perp2())
208 gv_b_t = gp_b_t->end_vertex();
209 vgp_b_t.push_back(gp_b_t);
219 vgp_bsec.push_back(*it);
225 bool process22 = (vgp_bsec.empty());
229 for (GenVertex::particle_iterator it = gv_hard->particles_begin(
parents); it != gv_hard->particles_end(
parents); ++it)
232 if ((*it)->pdg_id() == id_bdec)
234 gv = (*it)->production_vertex();
240 cerr <<
"ERROR: ComphepSingletopFilterPy8: HepMC inconsistency (! gv)" << endl;
247 gv = vgp_bsec.back()->end_vertex();
251 bool WeFoundAdditional_b_quark =
false;
252 int loopCount = 0, gv_loopCount = 0;
253 while (WeFoundAdditional_b_quark !=
true)
256 for (GenVertex::particle_iterator it = gv->particles_begin(
children); it != gv->particles_end(
children); ++it)
259 if ((*it)->pdg_id() == -id_bdec)
261 WeFoundAdditional_b_quark =
true;
264 if (WeFoundAdditional_b_quark ==
false)
267 for (GenVertex::particle_iterator it = gv->particles_begin(
parents); it != gv->particles_end(
parents); ++it)
269 if ((*it)->pdg_id() == id_bdec)
271 gv = (*it)->production_vertex();
280 cerr <<
"ERROR: ComphepSingletopFilterPy8: HepMC inconsistency (No add b vertex found)" << endl;
291 for (GenVertex::particle_iterator it = gv->particles_begin(
children); it != gv->particles_end(
children); ++it)
293 if ((*it)->pdg_id() == -id_bdec)
295 if (!gp || (*it)->momentum().perp2() > gp->momentum().perp2())
304 gv = gp->end_vertex();
305 vgp_bsec.push_back(gp);
315 if (vgp_bsec.empty())
317 cerr <<
"ERROR: ComphepSingletopFilterPy8: HepMC inconsistency (vgp_bsec.size() == 0)" << endl;
321 double pt = vgp_bsec.back()->momentum().perp();
T getParameter(std::string const &) const
ComphepSingletopFilterPy8(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool filter(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::HepMCProduct > token_
~ComphepSingletopFilterPy8() override
Abs< T >::type abs(const T &t)
format
Some error handling for the usage.
const HepMC::GenEvent * GetEvent() const