diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index a28ea17..4eb5e9b 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -45,6 +45,8 @@ file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/geant4/*.cpp") add_library(${PROJECT_NAME} SHARED ${SOURCES}) +set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY + ${PROJECT_BINARY_DIR}/lib) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIRS}) diff --git a/application/include/geant4/DataModel.h b/application/include/geant4/DataModel.h index d52f4f4..f736314 100644 --- a/application/include/geant4/DataModel.h +++ b/application/include/geant4/DataModel.h @@ -17,12 +17,15 @@ class G4Step; namespace geant4::data { enum Field : std::size_t { eventId, + // trackId, trackParentId, - trackEnergy, + trackInitialEnergy, trackTime, - trackHitsEnergy, - trackHitsTime, + // + hitsEnergy, + hitsTime, + hitsProcess, }; using UserDefinedMap = std::map; @@ -43,21 +46,25 @@ typedef unsigned int id; using Builder = RecordBuilder(Field::eventId), NumpyBuilder>, RecordField(Field::trackId), ListOffsetBuilder>>, RecordField(Field::trackParentId), ListOffsetBuilder>>, - RecordField(Field::trackEnergy), ListOffsetBuilder>>, + RecordField(Field::trackInitialEnergy), ListOffsetBuilder>>, RecordField(Field::trackTime), ListOffsetBuilder>>, - RecordField(Field::trackHitsEnergy), ListOffsetBuilder>>>, - RecordField(Field::trackHitsTime), ListOffsetBuilder>>>>; + RecordField(Field::hitsEnergy), ListOffsetBuilder>>>, + RecordField(Field::hitsTime), ListOffsetBuilder>>> + // RecordField(Field::hitsProcess), ListOffsetBuilder>>> + >; inline Builder MakeBuilder() { return { - {{Field::eventId, "event_id"}, - {Field::trackId, "track.id"}, - {Field::trackParentId, "track.parent_id"}, - {Field::trackEnergy, "track.energy"}, - {Field::trackTime, "track.time"}, - {Field::trackHitsEnergy, "track.hits.energy"}, - {Field::trackHitsTime, "track.hits.time"}}, - }; + { + {Field::eventId, "event_id"}, + {Field::trackId, "track.id"}, + {Field::trackParentId, "track.parent_id"}, + {Field::trackInitialEnergy, "track.initial_energy"}, + {Field::trackTime, "track.time"}, + {Field::hitsEnergy, "track.hits.energy"}, + {Field::hitsTime, "track.hits.time"}, + // {Field::hitsProcess, "track.hits.process"}}, + }}; } void InsertEventBegin(const G4Event* event, Builder& builder); diff --git a/application/src/geant4/DataModel.cpp b/application/src/geant4/DataModel.cpp index 0f8aca1..17dc42d 100644 --- a/application/src/geant4/DataModel.cpp +++ b/application/src/geant4/DataModel.cpp @@ -2,11 +2,14 @@ #include "geant4/DataModel.h" #include +#include +#include #include #include #include #include #include +#include #include #include @@ -19,42 +22,29 @@ namespace geant4::data { void InsertEventBegin(const G4Event* event, Builder& builder) { builder.content().append(event->GetEventID()); - auto& trackId = builder.content(); - auto& trackParentId = builder.content(); - auto& trackEnergy = builder.content(); - auto& trackTime = builder.content(); - auto& trackHitsEnergy = builder.content(); - auto& trackHitsTime = builder.content(); - - trackId.begin_list(); - trackParentId.begin_list(); - trackEnergy.begin_list(); - trackTime.begin_list(); - trackHitsEnergy.begin_list(); - trackHitsTime.begin_list(); + builder.content().begin_list(); + builder.content().begin_list(); + builder.content().begin_list(); + builder.content().begin_list(); + builder.content().begin_list(); + builder.content().begin_list(); + // builder.content().begin_list(); } void InsertEventEnd(const G4Event*, Builder& builder) { - - auto& trackId = builder.content(); - auto& trackParentId = builder.content(); - auto& trackEnergy = builder.content(); - auto& trackTime = builder.content(); - auto& trackHitsEnergy = builder.content(); - auto& trackHitsTime = builder.content(); - - trackId.end_list(); - trackParentId.end_list(); - trackEnergy.end_list(); - trackTime.end_list(); - trackHitsEnergy.end_list(); - trackHitsTime.end_list(); + builder.content().end_list(); + builder.content().end_list(); + builder.content().end_list(); + builder.content().end_list(); + builder.content().end_list(); + builder.content().end_list(); + // builder.content().end_list(); } void InsertTrackBegin(const G4Track* track, Builder& builder) { auto& trackId = builder.content(); auto& trackParentId = builder.content(); - auto& trackEnergy = builder.content(); + auto& trackEnergy = builder.content(); auto& trackTime = builder.content(); trackId.content().append(track->GetTrackID()); @@ -62,29 +52,40 @@ void InsertTrackBegin(const G4Track* track, Builder& builder) { trackEnergy.content().append(track->GetKineticEnergy() / units::energy); trackTime.content().append(track->GetGlobalTime() / units::time); - builder.content().content().begin_list(); - builder.content().content().begin_list(); + builder.content().content().begin_list(); + builder.content().content().begin_list(); + // builder.content().content().begin_list(); - // we should probably insert a step here to mark the beginning of the track + // we should probably insert a step here to mark the beginning of the track / use stepping verbose } void InsertTrackEnd(const G4Track*, Builder& builder) { - auto& trackHitsEnergy = builder.content(); - auto& trackHitsTime = builder.content(); - - trackHitsEnergy.content().end_list(); - trackHitsTime.content().end_list(); + builder.content().content().end_list(); + builder.content().content().end_list(); + // builder.content().content().end_list(); } void InsertStep(const G4Step* step, Builder& builder) { - auto& trackHitsEnergy = builder.content(); - auto& trackHitsTime = builder.content(); + auto& hitsEnergy = builder.content(); + auto& hitsTime = builder.content(); + + const G4Track* track = step->GetTrack(); const auto& stepPost = step->GetPostStepPoint(); const auto& stepPre = step->GetPreStepPoint(); - trackHitsEnergy.content().content().append(step->GetTotalEnergyDeposit() / units::energy); - trackHitsTime.content().content().append(stepPost->GetGlobalTime() / units::time); + const auto process = step->GetPostStepPoint()->GetProcessDefinedStep(); + G4String processName = "Init"; + G4String processTypeName = "Init"; + if (track->GetCurrentStepNumber() != 0) { + // 0 = Init step (G4SteppingVerbose) process is not defined for this step + processName = process->GetProcessName(); + processTypeName = G4VProcess::GetProcessTypeName(process->GetProcessType()); + } + + builder.content().content().content().append(step->GetTotalEnergyDeposit() / units::energy); + builder.content().content().content().append(stepPost->GetGlobalTime() / units::time); + // builder.content().content().content().append(processName); } py::object SnapshotBuilder(Builder& builder) {