12#include "../Framework/Core/src/ArrowSupport.h"
14#include "Monitoring/Monitoring.h"
19#include "HepMC3/GenEvent.h"
20#include "HepMC3/GenParticle.h"
21#include "HepMC3/GenVertex.h"
22#include "HepMC3/ReaderAscii.h"
23#include "HepMC3/ReaderAsciiHepMC2.h"
52 LOGP(fatal,
"Cannot open HEPMC kine file {}", (std::string)
hepmcFileName);
61 HepMC3::GenEvent
event;
63 for (
auto i = 0;
i < batch; ++
i) {
71 LOGP(warn,
"Failed to read from HEPMC input file");
77 mcheader->SetEventID(
event.event_number());
78 mcheader->SetVertex(
event.event_pos().px(),
event.event_pos().py(),
event.event_pos().pz());
79 auto xsecInfo =
event.cross_section();
80 if (xsecInfo !=
nullptr) {
87 if (scale !=
nullptr) {
91 if (nMPI !=
nullptr) {
98 }
else if (scode !=
nullptr) {
101 auto pdfInfo =
event.pdf_info();
102 if (pdfInfo !=
nullptr) {
113 auto heavyIon =
event.heavy_ion();
114 if (heavyIon !=
nullptr) {
128 mcheader->putInfo(
"eccentricity", (
float)heavyIon->eccentricity);
133 auto particles =
event.particles();
134 for (
auto const& particle : particles) {
135 auto parents = particle->parents();
136 auto has_parents = parents.size() > 0;
137 auto children = particle->children();
138 auto has_children = children.size() > 0;
139 auto p = particle->momentum();
140 auto v = particle->production_vertex();
141 mctracks->emplace_back(
143 has_parents ? parents.front()->id() : -1, has_parents ? parents.back()->id() : -1,
144 has_children ? children.front()->id() : -1, has_children ? children.back()->id() : -1,
145 p.px(), p.py(), p.pz(),
146 v->position().x(),
v->position().y(),
v->position().z(),
147 v->position().t(), 0);
154 pc.
services().
get<o2::monitoring::Monitoring>().send(o2::monitoring::Metric{(uint64_t)
tfCounter,
"df-sent"}.addTag(o2::monitoring::tags::Key::Subsystem, o2::monitoring::tags::Value::DPL));
164 auto spec = adaptAnalysisTask<O2simHepmcPublisher>(cfgc);
165 spec.outputs.emplace_back(
"MC",
"MCHEADER", 0, Lifetime::Timeframe);
166 spec.outputs.emplace_back(
"MC",
"MCTRACKS", 0, Lifetime::Timeframe);
Definition of the MCTrack class.
decltype(auto) make(const Output &spec, Args... args)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
Defining ITS Vertex explicitly as messageable.
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
Configurable< int > aggregate
Configurable< std::string > hepmcFileName
void run(o2::framework::ProcessingContext &pc)
std::vector< o2::pmr::vector< o2::MCTrack > * > mctracks_vector
void init(o2::framework::InitContext &)
std::vector< o2::dataformats::MCEventHeader * > mcheader_vector
std::shared_ptr< HepMC3::Reader > hepMCReader
Configurable< bool > hepmcv2
Configurable< int > maxEvents
static ServiceSpec arrowBackendSpec()
static AlgorithmSpec wrapWithRateLimiting(AlgorithmSpec spec)