16 #include "SQLamarr/HepMC2DataLoader.h"
17 #include "SQLamarr/db_functions.h"
18 #include "SQLamarr/preprocessor_symbols.h"
26 const std::string& file_path,
32 const int ds_id = insert_event(file_path, run_number, evt_number);
34 HepMC3::ReaderAsciiHepMC2 reader(file_path.c_str());
35 while ( !reader.failed() )
37 HepMC3::GenEvent evt(HepMC3::Units::MEV, HepMC3::Units::MM);
38 reader.read_event(evt);
40 auto pos = evt.event_pos();
41 const int event_id = insert_collision(
51 for (
auto& bp: evt.beams())
53 pvs.push_back(bp->end_vertex()->id());
55 std::unordered_map<int, int> vtxid_mapping;
56 for (
auto vertex: evt.vertices())
57 vtxid_mapping[vertex->id()] = insert_vertex(
61 vertex->position().t(),
62 vertex->position().x(),
63 vertex->position().y(),
64 vertex->position().z(),
65 (std::find(pvs.begin(), pvs.end(), vertex->id()) != pvs.end())
68 for (
auto particle: evt.particles())
70 auto pv = particle->production_vertex();
71 auto ev = particle->end_vertex();
77 (pv ? vtxid_mapping[pv->id()] : LAMARR_BAD_INDEX),
78 (ev ? vtxid_mapping[ev->id()] : LAMARR_BAD_INDEX),
81 particle->momentum().e(),
82 particle->momentum().px(),
83 particle->momentum().py(),
84 particle->momentum().pz(),
85 particle->generated_mass()
def load(self, str filename, int runNumber, int evtNumber)
Loads an ASCII file with HepMC3::ReaderAsciiHepMC2.