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

Fix hit ids #181

Merged
merged 2 commits into from
Oct 21, 2022
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
16 changes: 8 additions & 8 deletions source/persistency/PersistencyManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ G4bool PersistencyManager::Store(const G4Event* event)
StoreTrajectories(event->GetTrajectoryContainer());

// Store ionization hits and sensor hits
ihits_ = nullptr;
hit_map_.clear();
StoreHits(event->GetHCofThisEvent());

nevt_++;
Expand Down Expand Up @@ -252,8 +254,6 @@ void PersistencyManager::StoreIonizationHits(G4VHitsCollection* hc)
dynamic_cast<IonizationHitsCollection*>(hc);
if (!hits) return;

hit_map_.clear();

double evt_energy = 0.;
std::string sdname = hits->GetSDname();

Expand All @@ -264,19 +264,19 @@ void PersistencyManager::StoreIonizationHits(G4VHitsCollection* hc)

G4int trackid = hit->GetTrackID();

std::vector<G4int>* ihits = nullptr;

std::map<G4int, std::vector<G4int>* >::iterator it = hit_map_.find(trackid);
if (it != hit_map_.end()) {
ihits = it->second;
ihits_ = it->second;
} else {
ihits = new std::vector<G4int>;
hit_map_[trackid] = ihits;
ihits_ = new std::vector<G4int>;
hit_map_[trackid] = ihits_;
}

ihits->push_back(1);
ihits_->push_back(1);

G4ThreeVector xyz = hit->GetPosition();
h5writer_->WriteHitInfo(nevt_, trackid, ihits->size() - 1,
h5writer_->WriteHitInfo(nevt_, trackid, ihits_->size() - 1,
xyz[0], xyz[1], xyz[2],
hit->GetTime(), hit->GetEnergyDeposit(),
sdname.c_str());
Expand Down
1 change: 1 addition & 0 deletions source/persistency/PersistencyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ namespace nexus {

HDF5Writer* h5writer_; ///< Event writer to hdf5 file

std::vector<G4int>* ihits_;
std::map<G4int, std::vector<G4int>* > hit_map_;
std::vector<G4int> sns_posvec_;

Expand Down