85 hepmc_event->set_event_number(
event.id().event());
86 hepmc_event->set_signal_process_id(genEventInfoHandle->
signalProcessID());
87 hepmc_event->set_event_scale(genEventInfoHandle->
qScale());
88 hepmc_event->set_alphaQED(genEventInfoHandle->
alphaQED());
89 hepmc_event->set_alphaQCD(genEventInfoHandle->
alphaQCD());
91 hepmc_event->weights() = genEventInfoHandle->
weights();
93 hepmc_event->set_cross_section(
xsec_);
98 const int pdf_id1 = pdf->
id.first, pdf_id2 = pdf->
id.second;
99 const double pdf_x1 = pdf->
x.first, pdf_x2 = pdf->
x.second;
100 const double pdf_scalePDF = pdf->
scalePDF;
101 const double pdf_xPDF1 = pdf->
xPDF.first, pdf_xPDF2 = pdf->
xPDF.second;
102 HepMC::PdfInfo hepmc_pdfInfo(pdf_id1, pdf_id2, pdf_x1, pdf_x2, pdf_scalePDF, pdf_xPDF1, pdf_xPDF2);
103 hepmc_event->set_pdf_info(hepmc_pdfInfo);
107 std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
109 std::vector<HepMC::GenParticle*> hepmc_particles;
111 for (
unsigned int i = 0,
n = genParticlesHandle->
size();
i <
n; ++
i) {
114 hepmc_particle->suggest_barcode(
i + 1);
118 if (pTableData.particle(
p->pdgId()))
119 particleMass = pTableData.particle(
p->pdgId())->
mass();
121 particleMass =
p->mass();
123 hepmc_particle->set_generated_mass(particleMass);
125 hepmc_particles.push_back(hepmc_particle);
126 genCandToHepMCMap[
p] = hepmc_particle;
130 if (!parton1 and
p->pz() > 0) {
132 hepmc_parton1 = hepmc_particle;
133 }
else if (!parton2 and
p->pz() < 0) {
135 hepmc_parton2 = hepmc_particle;
140 HepMC::GenVertex* vertex1 =
nullptr;
141 HepMC::GenVertex* vertex2 =
nullptr;
142 if (parton1 ==
nullptr || parton2 ==
nullptr) {
147 vertex1 =
new HepMC::GenVertex(
FourVector(nullP4));
148 vertex2 =
new HepMC::GenVertex(
FourVector(nullP4));
154 vertex2 =
new HepMC::GenVertex(
FourVector(parton2->vertex()));
156 hepmc_event->add_vertex(vertex1);
157 hepmc_event->add_vertex(vertex2);
158 vertex1->add_particle_in(hepmc_parton1);
159 vertex2->add_particle_in(hepmc_parton2);
163 typedef std::map<const reco::Candidate*, HepMC::GenVertex*> ParticleToVertexMap;
164 ParticleToVertexMap particleToVertexMap;
165 particleToVertexMap[parton1] = vertex1;
166 particleToVertexMap[parton2] = vertex2;
167 for (
unsigned int i = 0,
n = genParticlesHandle->
size();
i <
n; ++
i) {
169 if (
p == parton1
or p == parton2)
173 for (
unsigned int j = 0, nMothers =
p->numberOfMothers();
j < nMothers; ++
j) {
177 if (particleToVertexMap.find(elder) == particleToVertexMap.end()) {
179 hepmc_event->add_vertex(
vertex);
180 particleToVertexMap[elder] =
vertex;
182 vertex = particleToVertexMap[elder];
187 vertex->add_particle_in(genCandToHepMCMap[mother]);
188 vertex->add_particle_out(hepmc_particles[
i]);
193 bool hasSignalVertex =
false;
196 for (
auto v = hepmc_event->vertices_begin();
v != hepmc_event->vertices_end(); ++
v) {
198 const int pdgId = (*p)->pdg_id();
201 hepmc_event->set_signal_process_vertex(*
v);
202 hasSignalVertex =
true;
211 if (!hasSignalVertex)
212 hepmc_event->set_signal_process_vertex(*(vertex1->vertices_begin()));
215 hepmc_product->addHepMCData(hepmc_event);
216 event.put(
std::move(hepmc_product),
"unsmeared");
edm::EDGetTokenT< GenEventInfoProduct > genEventInfoToken_
std::pair< double, double > x
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
HepMC::FourVector FourVector(const reco::Candidate::Point &point)
edm::EDGetTokenT< reco::CandidateView > genParticlesToken_
HepMC::GenCrossSection xsec_
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecord > pTable_
std::pair< double, double > xPDF
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::vector< int > signalParticlePdgIds_
Abs< T >::type abs(const T &t)
virtual const Point & vertex() const =0
vertex position
unsigned int signalProcessID() const
const_reference at(size_type pos) const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< double > & weights()