|Message: Re: Clear the memory allocated for G4VPrimitiveScorer?||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
first of all, I apologize for reviving this old conversation but I somehow feel like I am encountering a very similar problem.
I am also adapting the example RE02 to my needs and tracked the dose deposition inside a voxel phantom and a CSi detector until now (using G4PSDoseDeposit3D). Everything worked just fine and I was able to easily run simulations of 1e8 gamma particles.
Now, I am further interested in tracking the kinetic energy of incident photons in each voxel. Since I found no primitive scorer that suited my needs exactly, I decided to implement one on my own. Therefore I derived a KineticEnergyScorer[3D] from G4VPrimitiveScorer. To bypass any complications I simply copied and pasted the G4PSNofSecondary[3D] scorer IIRC and only altered the ProcessHits method to the following:
if ( aStep->GetTrack()->GetParticleDefinition()->GetParticleSubType() != "photon" ) return FALSE; if (!aStep->IsFirstStepInVolume()) return FALSE; G4double kinetic = aStep->GetPreStepPoint()->GetKineticEnergy(); if (kinetic == 0.) return FALSE; G4int index = GetIndex(aStep); EvtMap->add(index, kinetic); return TRUE;
The implementation is pretty straight-forward; only photons that just enter the voxel are considered. This is how I register my specific scorer in RE02DetectorConstruction::ConstructSDandField:
//m_FD->RegisterPrimitive(new G4PSDoseDeposit3D(G4String("TotalDose"),m_voxel_detector_list[i]->get_voxel_num_x(),m_voxel_detector_list[i]->get_voxel_num_y(),m_voxel_detector_list[i]->get_voxel_num_z())); m_FD->RegisterPrimitive(new KineticEnergyScorer3D(G4String("TotalEKin"),m_voxel_detector_list[i]->get_voxel_num_x(),m_voxel_detector_list[i]->get_voxel_num_y(),m_voxel_detector_list[i]->get_voxel_num_z()));
Everything compiles and runs just fine for few primary particles (1e4). However, increasing the number of primaries to e.g. 1e7, the RAM on my CPU (8GB) is quickly filled up. Even an HPC Cluster node with 32 GB RAM is filled quickly. I assumed self-imposed memory leaks at first (for I know there are certainly some new calls without delete) and checked my program with valgrind.
Therefore I altered the above two lines such that only one scorer is commented in at once. Surprisingly, the valgrind log is identical for both configurations. Thus I concluded that my implementation of KineticEnergyScorer3D is not flawed in principal.
This is the point where I started searching this forum. I thought maybe a self-implemented scorer needs to be 'introduced/initialized' in the same way as UserActions for example. After reading your conversation I came to the conclusion that Clare potentially had the same issue, that only got 'disguised' by the fact that she used 28 scorers at once, whereas I have only one active scorer at once (2 in sum considering patient and detector).
I am well aware that I could carry out multiple simulations with fewer photons, but 1) I would rather solve the problem and 2) I intend to run simulations of >1e9 photons thus single simulations of 1e8 photons are my personal pain barrier. Does anyone have an idea how to solve my problem? I hope I gave a comprehensible explanation. If you need additional code or information don't hesitate to contact me.
Thanks in advance.
|Inline Depth:||Outline Depth:||Add message:|