Skip to content

Commit b5cb0bf

Browse files
authored
Merge pull request #129 from SeverinDiederichs/expose_WDTdata
expose Woodcock tracking data in G4HepEmTrackingManager
2 parents 0b1c7ec + f88f7eb commit b5cb0bf

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

G4HepEm/G4HepEm/include/G4HepEmTrackingManager.hh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ public:
4242
// Needed if the random engine was swapped after construction of the HepEm TM
4343
void RebindG4RandomEngine();
4444

45+
// Returns whether the region for the given region index is using woodcock tracking
46+
G4bool IsWDTRegion(G4int regionId) const;
47+
48+
// returns the Woodcock tracking kinetic energy limit
49+
G4double GetWDTKineticEnergyLimit() const;
50+
51+
// For a given region index with Woodcock tracking and root logical volume index,
52+
// this function returns the G4HepEm material cut couple index of that volume if it is indeed
53+
// a root logical volume of a Woodcock tracking region, -1 otherwise
54+
G4int GetWDTCoupleHepEmIndex(G4int regionId, G4int logicalVolumeId) const;
55+
4556
// Returns the vector of e-/e+ G4HepEmNoProcess pointers used only to set a
4657
// creator and step limiter G4VProcess of the G4Step with an appropriate
4758
// name and EM process type.

G4HepEm/G4HepEm/include/G4HepEmWoodcockHelper.hh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public:
3737

3838

3939
void SetKineticEnergyLimit(G4double val) { fWDTKineticEnergyLimit = val; }
40-
G4double GetKineticEnergyLimit() { return fWDTKineticEnergyLimit; }
40+
G4double GetKineticEnergyLimit() const { return fWDTKineticEnergyLimit; }
4141

4242

4343
// Checks if this step will be done in a WDT region with high enough kinetic energy.
@@ -55,6 +55,13 @@ public:
5555
// post step points and interaction can only happen at the post step point if any).
5656
G4bool KeepTracking(const struct G4HepEmData* theHepEmData, G4HepEmGammaTrack* theGammaTrack, G4Track& aTrack);
5757

58+
// Returns whether the region for the given region index is using woodcock tracking
59+
G4bool IsWDTRegion(G4int regionId) const;
60+
61+
// For a given region index with Woodcock tracking and root logical volume index,
62+
// this function returns the G4HepEm material cut couple index of that volume if it is indeed
63+
// a root logical volume of a Woodcock tracking region, -1 otherwise
64+
G4int GetWDTCoupleHepEmIndex(G4int regionId, G4int logicalVolumeId) const;
5865

5966
private:
6067

G4HepEm/G4HepEm/src/G4HepEmTrackingManager.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@ void G4HepEmTrackingManager::RebindG4RandomEngine() {
157157

158158
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159159

160+
G4bool G4HepEmTrackingManager::IsWDTRegion(G4int regionId) const {
161+
return (fWDTHelper) ? fWDTHelper->IsWDTRegion(regionId) : false;
162+
}
163+
164+
G4double G4HepEmTrackingManager::GetWDTKineticEnergyLimit() const {
165+
return (fWDTHelper) ? fWDTHelper->GetKineticEnergyLimit() : 0.0;
166+
}
167+
168+
G4int G4HepEmTrackingManager::GetWDTCoupleHepEmIndex(G4int regionId, G4int logicalVolumeId) const {
169+
return (fWDTHelper) ? fWDTHelper->GetWDTCoupleHepEmIndex(regionId, logicalVolumeId) : -1;
170+
}
171+
172+
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
173+
160174
void G4HepEmTrackingManager::BuildPhysicsTable(const G4ParticleDefinition &part) {
161175
if (&part == G4Electron::Definition()) {
162176
int particleID = 0;

G4HepEm/G4HepEm/src/G4HepEmWoodcockHelper.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,26 @@ G4bool G4HepEmWoodcockHelper::KeepTracking(const struct G4HepEmData* theHepEmDat
297297
return isWDTReachedBoundary;
298298
}
299299

300+
G4bool G4HepEmWoodcockHelper::IsWDTRegion(G4int regionId) const {
301+
auto itrRegion = fWDTData.find(regionId);
302+
return itrRegion != fWDTData.end() && itrRegion->second;
303+
}
304+
305+
G4int G4HepEmWoodcockHelper::GetWDTCoupleHepEmIndex(G4int regionId, G4int logicalVolumeId) const {
306+
// check whether the provided region is a Woodcock tracking region
307+
auto itrRegion = fWDTData.find(regionId);
308+
if (itrRegion == fWDTData.end() || !itrRegion->second) {
309+
return -1;
310+
}
311+
// check whether the provided logicalVolumeId corresponds to an entry in the root logical volumes map
312+
const auto& WDTmap = itrRegion->second->fWDTDataRegion;
313+
auto itrRootVol = WDTmap.find(logicalVolumeId);
314+
if (itrRootVol == WDTmap.end() || !itrRootVol->second) {
315+
return -1;
316+
}
317+
return itrRootVol->second->fG4CoupleHepEmIndex;
318+
}
319+
300320

301321
void G4HepEmWoodcockHelper::ClearData() {
302322
// iterate over the `fWDTData` map

0 commit comments

Comments
 (0)