47 return HepMC::FourVector(10 *
point.x(), 10 *
point.y(), 10 *
point.z(), 0);
52 return HepMC::FourVector(lvec.px(), lvec.py(), lvec.pz(), std::hypot(lvec.P(),
std::max(0., lvec.mass())));
58 : cmEnergy_(
pset.getUntrackedParameter<double>(
"cmEnergy", 13000)) {
64 produces<edm::HepMCProduct>(
"unsmeared");
84 hepmc_event->set_event_number(
event.id().event());
85 hepmc_event->set_signal_process_id(genEventInfoHandle->
signalProcessID());
86 hepmc_event->set_event_scale(genEventInfoHandle->
qScale());
87 hepmc_event->set_alphaQED(genEventInfoHandle->
alphaQED());
88 hepmc_event->set_alphaQCD(genEventInfoHandle->
alphaQCD());
90 hepmc_event->weights() = genEventInfoHandle->
weights();
92 hepmc_event->set_cross_section(
xsec_);
97 const int pdf_id1 = pdf->
id.first, pdf_id2 = pdf->
id.second;
98 const double pdf_x1 = pdf->
x.first, pdf_x2 = pdf->
x.second;
99 const double pdf_scalePDF = pdf->
scalePDF;
100 const double pdf_xPDF1 = pdf->
xPDF.first, pdf_xPDF2 = pdf->
xPDF.second;
101 HepMC::PdfInfo hepmc_pdfInfo(pdf_id1, pdf_id2, pdf_x1, pdf_x2, pdf_scalePDF, pdf_xPDF1, pdf_xPDF2);
102 hepmc_event->set_pdf_info(hepmc_pdfInfo);
106 std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
108 std::vector<HepMC::GenParticle*> hepmc_particles;
110 for (
unsigned int i = 0,
n = genParticlesHandle->
size();
i <
n; ++
i) {
113 hepmc_particle->suggest_barcode(
i + 1);
120 particleMass =
p->mass();
122 hepmc_particle->set_generated_mass(particleMass);
124 hepmc_particles.push_back(hepmc_particle);
125 genCandToHepMCMap[
p] = hepmc_particle;
129 if (!parton1 and
p->pz() > 0) {
131 hepmc_parton1 = hepmc_particle;
132 }
else if (!parton2 and
p->pz() < 0) {
134 hepmc_parton2 = hepmc_particle;
139 HepMC::GenVertex* vertex1 =
nullptr;
140 HepMC::GenVertex* vertex2 =
nullptr;
141 if (parton1 ==
nullptr || parton2 ==
nullptr) {
146 vertex1 =
new HepMC::GenVertex(
FourVector(nullP4));
147 vertex2 =
new HepMC::GenVertex(
FourVector(nullP4));
153 vertex2 =
new HepMC::GenVertex(
FourVector(parton2->vertex()));
155 hepmc_event->add_vertex(vertex1);
156 hepmc_event->add_vertex(vertex2);
157 vertex1->add_particle_in(hepmc_parton1);
158 vertex2->add_particle_in(hepmc_parton2);
162 typedef std::map<const reco::Candidate*, HepMC::GenVertex*> ParticleToVertexMap;
163 ParticleToVertexMap particleToVertexMap;
164 particleToVertexMap[parton1] = vertex1;
165 particleToVertexMap[parton2] = vertex2;
166 for (
unsigned int i = 0,
n = genParticlesHandle->
size();
i <
n; ++
i) {
168 if (
p == parton1
or p == parton2)
172 for (
unsigned int j = 0, nMothers =
p->numberOfMothers();
j < nMothers; ++
j) {
176 if (particleToVertexMap.find(elder) == particleToVertexMap.end()) {
178 hepmc_event->add_vertex(
vertex);
179 particleToVertexMap[elder] =
vertex;
181 vertex = particleToVertexMap[elder];
186 vertex->add_particle_in(genCandToHepMCMap[mother]);
187 vertex->add_particle_out(hepmc_particles[
i]);
192 bool hasSignalVertex =
false;
195 for (
auto v = hepmc_event->vertices_begin();
v != hepmc_event->vertices_end(); ++
v) {
197 const int pdgId = (*p)->pdg_id();
200 hepmc_event->set_signal_process_vertex(*
v);
201 hasSignalVertex =
true;
210 if (!hasSignalVertex)
211 hepmc_event->set_signal_process_vertex(*(vertex1->vertices_begin()));
214 hepmc_product->addHepMCData(hepmc_event);
215 event.put(
std::move(hepmc_product),
"unsmeared");