I think there are some issues identifying the volumes.
I am trying with the example 04.MuonScan
where we actually define 2 active volumes in the geometry.
TRestGeant4Metadata produces the following output:
|| ++++++++++ Detector +++++++++++ ||
|| Energy range (keV): (0, 1e+20) ||
|| Number of sensitive volumes: 1 ||
|| Sensitive volume: det_dw_01 ||
|| Number of active volumes: 2 ||
|| Name: det_dw_01, ID: 0, maxStep: 1mm , chance: 1 ||
|| Name: det_up_01, ID: 1, maxStep: 1mm , chance: 1 ||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I print the track #7 here. The volume name is det_dw_01
, thus the id should be 0.
* TrackID: 7 - Particle: e- - ParentID: 1 - Parent particle: mu- - Created by 'muIoni' with initial KE of 17.12 keV
Initial position (-224.115, -30.444, -321.290) mm at time 2.91 ns - Time length of 0.16 ns and spatial length of 9.98 mm
- Hit 0 - Energy: 0 - Process: Init - Volume: det_dw_01 - Position: (-224.115, -30.444, -321.290) mm - Time: 2.91 ns - KE: 17.12 keV
- Hit 1 - Energy: 228.69 eV - Process: msc - Volume: det_dw_01 - Position: (-224.063, -31.162, -321.946) mm - Time: 2.93 ns - KE: 16.89 keV
- Hit 2 - Energy: 492.31 eV - Process: msc - Volume: det_dw_01 - Position: (-223.678, -31.773, -322.564) mm - Time: 2.94 ns - KE: 16.40 keV
- Hit 3 - Energy: 1.43 keV - Process: msc - Volume: det_dw_01 - Position: (-223.406, -32.124, -323.359) mm - Time: 2.95 ns - KE: 14.98 keV
- Hit 4 - Energy: 738.05 eV - Process: msc - Volume: det_dw_01 - Position: (-223.055, -32.513, -323.911) mm - Time: 2.96 ns - KE: 14.24 keV
- Hit 5 - Energy: 792.08 eV - Process: msc - Volume: det_dw_01 - Position: (-222.858, -32.947, -324.430) mm - Time: 2.97 ns - KE: 13.45 keV
- Hit 6 - Energy: 91.86 eV - Process: msc - Volume: det_dw_01 - Position: (-222.601, -33.057, -324.606) mm - Time: 2.98 ns - KE: 13.35 keV
- Hit 7 - Energy: 581.28 eV - Process: msc - Volume: det_dw_01 - Position: (-222.426, -32.868, -324.899) mm - Time: 2.98 ns - KE: 12.77 keV
However, if I add a bit of debugging output in the method TRestGeant4Track::GetEnergyInVolume()
that is used internally in the method that we are testing, I get the following.
TRestGeant4Track::GetEnergyInVolume(). Track : 7
Hit: 0 volId: 1
Hit: 1 volId: 1
Hit: 2 volId: 1
Hit: 3 volId: 1
Hit: 4 volId: 1
Hit: 5 volId: 1
Hit: 6 volId: 1
Hit: 7 volId: 1
Hit: 8 volId: 1
Thus, there is no hit with id 0, as it should be. I hope @lobis could have a quick solution for this.
I opened an issue Problem retrieving volume id at `GetEnergyInVolume` · Issue #99 · rest-for-physics/geant4lib · GitHub