Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make hit indices usable in Geant4 #1817

Merged
merged 4 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Material/MaterialInteraction.hpp"
#include "ActsExamples/EventData/SimHit.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsFatras/EventData/Barcode.hpp"

#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -39,6 +40,8 @@ class EventStoreRegistry {
SimHitContainer::sequence_type hits;
/// Tracks recorded in material mapping
std::unordered_map<size_t, Acts::RecordedMaterialTrack> materialTracks;
/// Particle hit count (for hit indexing)
std::unordered_map<SimBarcode, std::size_t> particleHitCount;
};

EventStoreRegistry() = delete;
Expand Down
7 changes: 5 additions & 2 deletions Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ void ActsExamples::SensitiveSteppingAction::UserSteppingAction(
// Retrieve the event data registry
auto& eventData = EventStoreRegistry::eventData();

// Fill into the registry
// Increase counter (starts at 1 because of ++)
++eventData.particleHitCount[particleID];

// Fill into the registry (subtract 1 from hit-count to get 0-based index)
eventData.hits.emplace_back(geoID, particleID, particlePosition,
beforeMomentum, afterMomentum,
eventData.hits.size());
eventData.particleHitCount[particleID] - 1);
}
}