92 HepMC3::GenEvent* hepmc_event =
new HepMC3::GenEvent();
93 hepmc_event->set_event_number(
event.id().event());
94 hepmc_event->add_attribute(
"signal_process_id",
95 std::make_shared<HepMC3::IntAttribute>(genEventInfoHandle->
signalProcessID()));
96 hepmc_event->add_attribute(
"event_scale", std::make_shared<HepMC3::DoubleAttribute>(genEventInfoHandle->
qScale()));
97 hepmc_event->add_attribute(
"alphaQCD", std::make_shared<HepMC3::DoubleAttribute>(genEventInfoHandle->
alphaQCD()));
98 hepmc_event->add_attribute(
"alphaQED", std::make_shared<HepMC3::DoubleAttribute>(genEventInfoHandle->
alphaQED()));
100 hepmc_event->weights() = genEventInfoHandle->
weights();
102 if (hepmc_event->weights().size() == 0) {
103 hepmc_event->weights().push_back(1.);
107 if (
xsec_->xsecs().size() < hepmc_event->weights().size()) {
108 xsec_->set_cross_section(std::vector<double>(hepmc_event->weights().size(),
xsec_->xsec(0)),
109 std::vector<double>(hepmc_event->weights().size(),
xsec_->xsec_err(0)));
111 hepmc_event->set_cross_section(
xsec_);
115 if (pdf !=
nullptr) {
116 const int pdf_id1 = pdf->
id.first, pdf_id2 = pdf->
id.second;
117 const double pdf_x1 = pdf->
x.first, pdf_x2 = pdf->
x.second;
118 const double pdf_scalePDF = pdf->
scalePDF;
119 const double pdf_xPDF1 = pdf->
xPDF.first, pdf_xPDF2 = pdf->
xPDF.second;
120 HepMC3::GenPdfInfoPtr hepmc_pdfInfo = make_shared<HepMC3::GenPdfInfo>();
121 hepmc_pdfInfo->set(pdf_id1, pdf_id2, pdf_x1, pdf_x2, pdf_scalePDF, pdf_xPDF1, pdf_xPDF2);
122 hepmc_event->set_pdf_info(hepmc_pdfInfo);
126 std::map<const reco::Candidate*, HepMC3::GenParticlePtr> genCandToHepMCMap;
128 std::vector<HepMC3::GenParticlePtr> hepmc_particles;
130 for (
unsigned int i = 0,
n = genParticlesHandle->
size();
i <
n; ++
i) {
133 std::make_shared<HepMC3::GenParticle>(
FourVector(
p->p4()),
p->pdgId(),
p->status());
137 if (pTableData.particle(
p->pdgId()))
138 particleMass = pTableData.particle(
p->pdgId())->
mass();
140 particleMass =
p->mass();
142 hepmc_particle->set_generated_mass(particleMass);
144 hepmc_particles.push_back(hepmc_particle);
145 genCandToHepMCMap[
p] = hepmc_particle;
149 if (!parton1 and
p->pz() > 0) {
151 hepmc_parton1 = hepmc_particle;
152 }
else if (!parton2 and
p->pz() < 0) {
154 hepmc_parton2 = hepmc_particle;
159 HepMC3::GenVertexPtr vertex1;
160 HepMC3::GenVertexPtr vertex2;
161 if (parton1 ==
nullptr || parton2 ==
nullptr) {
166 vertex1 = make_shared<HepMC3::GenVertex>(
FourVector(nullP4));
167 vertex2 = make_shared<HepMC3::GenVertex>(
FourVector(nullP4));
168 hepmc_parton1 = make_shared<HepMC3::GenParticle>(
FourVector(+beamP4), 2212, 4);
169 hepmc_parton2 = make_shared<HepMC3::GenParticle>(
FourVector(-beamP4), 2212, 4);
173 vertex2 = make_shared<HepMC3::GenVertex>(
FourVector(parton2->vertex()));
175 hepmc_event->add_vertex(vertex1);
176 hepmc_event->add_vertex(vertex2);
177 vertex1->add_particle_in(hepmc_parton1);
178 vertex2->add_particle_in(hepmc_parton2);
182 typedef std::map<const reco::Candidate*, HepMC3::GenVertexPtr> ParticleToVertexMap;
183 ParticleToVertexMap particleToVertexMap;
184 particleToVertexMap[parton1] = vertex1;
185 particleToVertexMap[parton2] = vertex2;
186 for (
unsigned int i = 0,
n = genParticlesHandle->
size();
i <
n; ++
i) {
188 if (
p == parton1
or p == parton2)
192 for (
unsigned int j = 0, nMothers =
p->numberOfMothers();
j < nMothers; ++
j) {
195 HepMC3::GenVertexPtr
vertex;
196 if (particleToVertexMap.find(elder) == particleToVertexMap.end()) {
198 hepmc_event->add_vertex(
vertex);
199 particleToVertexMap[elder] =
vertex;
201 vertex = particleToVertexMap[elder];
206 vertex->add_particle_in(genCandToHepMCMap[mother]);
207 vertex->add_particle_out(hepmc_particles[
i]);
213 hepmc_product->addHepMCData(hepmc_event);
214 event.put(
std::move(hepmc_product),
"unsmeared");
edm::EDGetTokenT< GenEventInfoProduct > genEventInfoToken_
std::pair< double, double > x
edm::EDGetTokenT< reco::CandidateView > genParticlesToken_
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
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
edm::Ptr< GenParticle > GenParticlePtr
persistent reference to a GenParticle
HepMC3::FourVector FourVector(const reco::Candidate::Point &point)
HepMC3::GenCrossSectionPtr xsec_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< double > & weights()