Skip to content

Commit

Permalink
Merge pull request #181 from paolafer/fix-hit-ids
Browse files Browse the repository at this point in the history
Fix hit ids
  • Loading branch information
paolafer authored Oct 21, 2022
2 parents 4b3d3d5 + a2218a7 commit 4c95c5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit 4c95c5b

Please sign in to comment.