Skip to content

Commit f5849ac

Browse files
aalkinalcaliva
authored andcommitted
O2sim: update hepmc info propagation (#12709)
* O2sim: update hepmc info propagation
1 parent 276dc2b commit f5849ac

4 files changed

Lines changed: 52 additions & 36 deletions

File tree

DataFormats/simulation/include/SimulationDataFormat/MCEventHeader.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ weights.
8686
static constexpr const char* processCode = "processCode";
8787
static constexpr const char* weight = "weight";
8888
/** @} */
89+
/** @{
90+
@name Pythia8-specific fields */
91+
static constexpr const char* processID = "signal_process_id";
92+
static constexpr const char* eventScale = "event_scale";
93+
static constexpr const char* mpi = "mpi";
94+
/** @} */
8995
};
9096

9197
/*****************************************************************/

Detectors/AOD/src/AODMcProducerHelpers.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ bool updateHepMCXSection(const XSectionCursor& cursor,
9797
getEventInfo(header, Key::attemptedEvents, 0),
9898
getEventInfo(header, Key::xSection, 0.f),
9999
getEventInfo(header, Key::xSectionError, 0.f),
100-
getEventInfo(header, "ptHard", 1.f),
101-
getEventInfo(header, "MPI", -1),
102-
getEventInfo(header, "processId", -1));
100+
getEventInfo(header, Key::eventScale, 1.f),
101+
getEventInfo(header, Key::mpi, -1),
102+
getEventInfo(header, Key::processCode, -1));
103103
return true;
104104
}
105105
//--------------------------------------------------------------------

Generators/src/GeneratorPythia8.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ void GeneratorPythia8::updateHeader(o2::dataformats::MCEventHeader* eventHeader)
594594
eventHeader->putInfo<float>(Key::xSection, info.sigmaGen() * 1e9);
595595
eventHeader->putInfo<float>(Key::xSectionError, info.sigmaErr() * 1e9);
596596

597+
// Set event scale and nMPI
598+
eventHeader->putInfo<float>(Key::eventScale, info.QRen());
599+
eventHeader->putInfo<int>(Key::mpi, info.nMPI());
600+
597601
// Set weights (overrides cross-section for each weight)
598602
size_t iw = 0;
599603
auto xsecErr = info.weightContainerPtr->getTotalXsecErr();

run/o2sim_hepmc_publisher.cxx

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "Framework/runDataProcessing.h"
2626

2727
using namespace o2::framework;
28+
using namespace o2::dataformats;
2829

2930
struct O2simHepmcPublisher {
3031
Configurable<std::string> hepmcFileName{"hepmc", "input.hepmc", "name of the input file with HepMC events"};
@@ -70,51 +71,56 @@ struct O2simHepmcPublisher {
7071
mcHeader.SetVertex(event.event_pos().px(), event.event_pos().py(), event.event_pos().pz());
7172
auto xsecInfo = event.cross_section();
7273
if (xsecInfo != nullptr) {
73-
mcHeader.putInfo("Accepted", (uint64_t)xsecInfo->get_accepted_events());
74-
mcHeader.putInfo("Attempted", (uint64_t)xsecInfo->get_attempted_events());
75-
mcHeader.putInfo("XsectGen", (float)xsecInfo->xsec());
76-
mcHeader.putInfo("XsectErr", (float)xsecInfo->xsec_err());
74+
mcHeader.putInfo(MCInfoKeys::acceptedEvents, (uint64_t)xsecInfo->get_accepted_events());
75+
mcHeader.putInfo(MCInfoKeys::attemptedEvents, (uint64_t)xsecInfo->get_attempted_events());
76+
mcHeader.putInfo(MCInfoKeys::xSection, (float)xsecInfo->xsec());
77+
mcHeader.putInfo(MCInfoKeys::xSectionError, (float)xsecInfo->xsec_err());
7778
}
78-
auto scale = event.attribute<HepMC3::DoubleAttribute>("event_scale");
79+
auto scale = event.attribute<HepMC3::DoubleAttribute>(MCInfoKeys::eventScale);
7980
if (scale != nullptr) {
80-
mcHeader.putInfo("PtHard", (float)scale->value());
81+
mcHeader.putInfo(MCInfoKeys::eventScale, (float)scale->value());
8182
}
82-
auto nMPI = event.attribute<HepMC3::IntAttribute>("mpi");
83+
auto nMPI = event.attribute<HepMC3::IntAttribute>(MCInfoKeys::mpi);
8384
if (nMPI != nullptr) {
84-
mcHeader.putInfo("MPI", nMPI->value());
85+
mcHeader.putInfo(MCInfoKeys::mpi, nMPI->value());
8586
}
86-
auto sid = event.attribute<HepMC3::IntAttribute>("signal_process_id");
87+
auto sid = event.attribute<HepMC3::IntAttribute>(MCInfoKeys::processCode);
88+
auto scode = event.attribute<HepMC3::IntAttribute>(MCInfoKeys::processID); // default pythia8 hepmc3 interface uses signal_process_id
8789
if (sid != nullptr) {
88-
mcHeader.putInfo("ProcessId", sid->value());
90+
mcHeader.putInfo(MCInfoKeys::processCode, sid->value());
91+
} else if (scode != nullptr) {
92+
mcHeader.putInfo(MCInfoKeys::processCode, scode->value());
8993
}
9094
auto pdfInfo = event.pdf_info();
9195
if (pdfInfo != nullptr) {
92-
mcHeader.putInfo("Id1", pdfInfo->parton_id[0]);
93-
mcHeader.putInfo("Id2", pdfInfo->parton_id[1]);
94-
mcHeader.putInfo("PdfId1", pdfInfo->pdf_id[0]);
95-
mcHeader.putInfo("PdfId2", pdfInfo->pdf_id[1]);
96-
mcHeader.putInfo("X1", (float)pdfInfo->x[0]);
97-
mcHeader.putInfo("X2", (float)pdfInfo->x[1]);
98-
mcHeader.putInfo("scale", (float)pdfInfo->scale);
99-
mcHeader.putInfo("Pdf1", (float)pdfInfo->xf[0]);
100-
mcHeader.putInfo("Pdf2", (float)pdfInfo->xf[1]);
96+
mcHeader.putInfo(MCInfoKeys::pdfParton1Id, pdfInfo->parton_id[0]);
97+
mcHeader.putInfo(MCInfoKeys::pdfParton2Id, pdfInfo->parton_id[1]);
98+
mcHeader.putInfo(MCInfoKeys::pdfCode1, pdfInfo->pdf_id[0]);
99+
mcHeader.putInfo(MCInfoKeys::pdfCode2, pdfInfo->pdf_id[1]);
100+
mcHeader.putInfo(MCInfoKeys::pdfX1, (float)pdfInfo->x[0]);
101+
mcHeader.putInfo(MCInfoKeys::pdfX2, (float)pdfInfo->x[1]);
102+
mcHeader.putInfo(MCInfoKeys::pdfScale, (float)pdfInfo->scale);
103+
mcHeader.putInfo(MCInfoKeys::pdfXF1, (float)pdfInfo->xf[0]);
104+
mcHeader.putInfo(MCInfoKeys::pdfXF2, (float)pdfInfo->xf[1]);
101105
}
102106
auto heavyIon = event.heavy_ion();
103107
if (heavyIon != nullptr) {
104-
mcHeader.putInfo("NcollHard", heavyIon->Ncoll_hard);
105-
mcHeader.putInfo("NpartProj", heavyIon->Npart_proj);
106-
mcHeader.putInfo("NpartTarg", heavyIon->Npart_targ);
107-
mcHeader.putInfo("Ncoll", heavyIon->Ncoll);
108-
mcHeader.putInfo("NNwoundedCollisions", heavyIon->N_Nwounded_collisions);
109-
mcHeader.putInfo("NwoundedNCollisions", heavyIon->Nwounded_N_collisions);
110-
mcHeader.putInfo("NwoundedNwoundedCollisions", heavyIon->Nwounded_Nwounded_collisions);
111-
mcHeader.putInfo("SpectatorNeutrons", heavyIon->spectator_neutrons);
112-
mcHeader.putInfo("SpectatorProtons", heavyIon->spectator_protons);
113-
mcHeader.putInfo("ImpactParameter", (float)heavyIon->impact_parameter);
114-
mcHeader.putInfo("EventPlaneAngle", (float)heavyIon->event_plane_angle);
115-
mcHeader.putInfo("Eccentricity", (float)heavyIon->eccentricity);
116-
mcHeader.putInfo("SigmaInelNN", (float)heavyIon->sigma_inel_NN);
117-
mcHeader.putInfo("Centrality", (float)heavyIon->centrality);
108+
mcHeader.putInfo(MCInfoKeys::nCollHard, heavyIon->Ncoll_hard);
109+
mcHeader.putInfo(MCInfoKeys::nPartProjectile, heavyIon->Npart_proj);
110+
mcHeader.putInfo(MCInfoKeys::nPartTarget, heavyIon->Npart_targ);
111+
mcHeader.putInfo(MCInfoKeys::nColl, heavyIon->Ncoll);
112+
mcHeader.putInfo(MCInfoKeys::nCollNNWounded, heavyIon->N_Nwounded_collisions);
113+
mcHeader.putInfo(MCInfoKeys::nCollNWoundedN, heavyIon->Nwounded_N_collisions);
114+
mcHeader.putInfo(MCInfoKeys::nCollNWoundedNwounded, heavyIon->Nwounded_Nwounded_collisions);
115+
mcHeader.putInfo(MCInfoKeys::nSpecProjectileNeutron, heavyIon->Nspec_proj_n);
116+
mcHeader.putInfo(MCInfoKeys::nSpecProjectileProton, heavyIon->Nspec_proj_p);
117+
mcHeader.putInfo(MCInfoKeys::nSpecTargetNeutron, heavyIon->Nspec_targ_n);
118+
mcHeader.putInfo(MCInfoKeys::nSpecTargetProton, heavyIon->Nspec_targ_p);
119+
mcHeader.putInfo(MCInfoKeys::impactParameter, (float)heavyIon->impact_parameter);
120+
mcHeader.putInfo(MCInfoKeys::planeAngle, (float)heavyIon->event_plane_angle);
121+
mcHeader.putInfo("eccentricity", (float)heavyIon->eccentricity);
122+
mcHeader.putInfo(MCInfoKeys::sigmaInelNN, (float)heavyIon->sigma_inel_NN);
123+
mcHeader.putInfo(MCInfoKeys::centrality, (float)heavyIon->centrality);
118124
}
119125

120126
auto particles = event.particles();

0 commit comments

Comments
 (0)