| Summary: | please fix G4THitsMap<T>::PrintAllHits | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | andrea.di.simone |
| Component: | digits_hits/hits | Assignee: | asai |
| Status: | RESOLVED FIXED | ||
| Severity: | trivial | CC: | andrea.di.simone |
| Priority: | P5 | ||
| Version: | 9.4 | ||
| Hardware: | All | ||
| OS: | All | ||
Thanks for reporting this. I will temporary remove += operator for the coming release of 9.5, and investigate what we can do otherwise. I removed that part of the code for summing up and printing the sum. This modification will be included in the v9.5 release, and it will be back ported if we make patch release for v9.4. |
Hi, I am using in my application (SuperB) G4THitsMap<T>. Unfortunately, the present implementation of G4THitsMap<T>::PrintAllHits restricts T to be something which can be added to a double: template <typename T> void G4THitsMap<T>::PrintAllHits() { G4cout << "G4THitsMap " << SDname << " / " << collectionName << " --- " << entries() << " entries" << G4endl; std::map<G4int,T*> * theHitsMap = GetMap(); typename std::map<G4int, T*>::iterator itr = theHitsMap->begin(); // THIS IS THE PROBLEM G4double sum = 0.; for(; itr != theHitsMap->end(); itr++) { ///////////////////////////////G4cout << " " << itr->first << " : " << *(itr->second) << G4endl; sum += *(itr->second); } G4cout << " Total : " << sum << G4endl; } In my particular use case I want T to be a TVectorT<double>, since I need some binning in time. All of G4THitsMap works smoothly, but for this method. Could this be modified to be more general? I do have a workaround in place (through template specialization) but it would be great if this worked out-of-the-box with any class for which operator+= is defined... Thanks for your help, Andrea.