| Summary: | G4SPSPosDistribution::GenerateOne() and updating of particle_position and localP | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Liz <lindbohansen> |
| Component: | event | Assignee: | Andrea Dotti <andrea.dotti> |
| Status: | RESOLVED FIXED | ||
| Severity: | trivial | CC: | asai |
| Priority: | P5 | ||
| Version: | other | ||
| Hardware: | All | ||
| OS: | All | ||
|
Description
Liz
2014-07-14 09:58:18 CEST
*http://www-geant4.kek.jp/lxr/source/event/src/G4SPSPosDistribution.cc Hi again, I checked the G4SPSPosDistribution::GenerateOne() function for a few different releases (via * and the latest beta release). Releases 10.1.b1 uses e.g. the following G4ThreeVector G4SPSPosDistribution::GenerateOne() { // G4ThreeVector localP = particle_position; G4bool srcconf = false; G4int LoopCount = 0; while(srcconf == false) { if(SourcePosType == "Point") GeneratePointSource(localP); else if(SourcePosType == "Beam") GeneratePointsInBeam(localP); else if(SourcePosType == "Plane") GeneratePointsInPlane(localP); else if(SourcePosType == "Surface") GeneratePointsOnSurface(); else if(SourcePosType == "Volume") GeneratePointsInVolume(); whereas previous relases use another version which I would guess does not have this problem (I haven't checked this explicitly) G4ThreeVector G4SPSPosDistribution::GenerateOne() { // G4bool srcconf = false; G4int LoopCount = 0; while(srcconf == false) { if(SourcePosType == "Point") GeneratePointSource(); else if(SourcePosType == "Beam") GeneratePointsInBeam(); else if(SourcePosType == "Plane") GeneratePointsInPlane(); else if(SourcePosType == "Surface") GeneratePointsOnSurface(); else if(SourcePosType == "Volume") GeneratePointsInVolume(); Hello, thank you for reporting this. Sorry for the inconvenience. Indeed GPS has been modified in the beta release and few thinks need to be ironed-out. It will be fixed for final release. In the meantime let me take a look at the problem. If the bug-fix is simple and can be implemented with few lines of code I will comment here. Andrea Hi! Thanks for clarifying. I fixed it for my purposes very naively just by updating the position variable at the right place after the random x, y, z was generated. Cheers, Liz. Hi Liz, if you are using a Multi-threaded build of Geant4 what you propose unfortunately will not work. Instead if you are using a sequential build it should be ok. I am working on a more general fix. I will keep you posted. Please note that due to some important changes for multi-threading in 10.1.beta we have substantially re-designed the code of GPS. I've tried to do my best in implementing all correct code, but you have already found out an issue! For beta releases unfortunately this may happen... We will fix all problems that we can spot for the final release 10.1 scheduled for December this year. May I ask you which is the feature of 10.1.beta that you are particularly interested in? Andrea Hi Andrea, Yeah, I (vaguely) suspected as much about the multi-threading, thanks for info! Regarding 10.1.beta, I must admit that I just started really using Geant4 a couple of weeks ago and without much further reflection thought I might as well familiarize myself with the newest version. I'm primarily interested in using low-energy/DNA/GPS features. Cheers, Liz. Hi again,
Just wanted to let you know that I suspect there could be a similar issue relating to certain types of useage of the GPS via the G4SPSEneDistribution class. I have for instance an app similar to TestEm12 where the particle type and energy is requested in RunAction::BeginOfRunAction like this:
G4ParticleDefinition* particle
= fPrimary->GetParticleGun()->GetParticleDefinition();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
G4cout << "Particle type " << particle->GetParticleName() << "\n";
G4cout << "Particle energy "<< energy << "\n";
Here the gun is the GPS and GetParticleEnergy() will return the default energy set as particle_energy = 1.0 * MeV at the start of G4SingleParticleSource.cc. The actual shot particle appears to have the right energy though, and some other 'simultaneous' requests, such as e.g. the request for the type of particle above, will work.
Cheers,
Liz.
Dear Liz, the original issue you have found has been solved in tag event-V10-00-06. Thank you for reporting your other findings. I will work on them, but unfortunately I will not be able to do it fast. Please let me propose the following: if you need to learn G4 and get started, please use Geant4 Version 10.0.p02 (latest patch production version). We provide beta releases to give expert users a preview of features in up-coming features, however it is usually better to use a stable production release. In such version GPS is working, but it is not optimized for MT. This mean that very large number of sources (hundreds) may cause a large memory consumption. Unless you use special setups (e.g. Xeon Phi Coprocessors) where you have large thread counts and limited RAM this issue should not be a problem. I really appreciate your feedback and help in debugging this part. Regards, Andrea P.S. I will not close this bug report since the new findings have to be understood The new GPS system for 10.1 has been accepted and will be released with next version of G4. The new re-design should solve these problems. |