[Gate-users] problem with random number seed?

David Boersma david.boersma at physics.uu.se
Mon Feb 1 17:29:04 CET 2016


Den 01/02/2016 kl. 17:08, skrev Andrej:
> A quick and dirty fix is to set the randomSeed to some run related
> number. I know that in geant people would sometimes start each event
> with a seed equal to that event number. Here you only have to do it
> run-wise.

Unfortunately when we try that we still get identical outputs for 
successive runs.

I think that the problem is not in how Gate obtains a seed (from 
/dev/random with "auto" or reading a literal user-supplied value from 
the macro), but rather in how Gate communicates that seed to (a 
multithreaded version of) the geant4 library.


> Cheers
> Andrej
> surabhi balagopal nair je 2/1/2016 ob 4:40 PM napisal:
>> Hello,
>> Can anyone tell me whether the Virtual Gate is built on GEANT4
>> multithread ON or OFF?
>> Thank you,
>> SN
>> On 1 February 2016 at 10:14, David Boersma
>> <david.boersma at physics.uu.se <mailto:david.boersma at physics.uu.se>> wrote:
>>     Hi,
>>     It looks like Thomas Deschler was right: random number seeding in
>>     Gate (current develop version, but I suspect the conclusions also
>>     hold for release 7.1) only works correctly if the Geant4 10.1
>>     libraries were compiled with multithreading OFF. By "correctly" we
>>     mean: with "auto" seeding you get a different seed every time you
>>     run it, and therefore statistically independent outputs. If you
>>     use a geant4 installation built with multithreading=ON, then
>>     successive Gate runs will give identical outputs.
>>     We verified this (on Linux and on MacOSX) by compiling Geant4 with
>>     and without multithreading, and then building Gate with it. We ran
>>     Hediye's minimal RT macro (shoot electrons on a target foil, and
>>     collect a phasespace of the particles after it, stored in a ROOT
>>     output file). We ran the macro twice (renaming the output
>>     directory in between). "Ekine" histograms of the two runs were
>>     numerically identical when we ran *with* multithreading and they
>>     were clearly different *without* multithreading.
>>     Short term action item: it would be good to document this clearly
>>     in the README file and/or the 7.1 installation guide on the wiki.
>>     Medium/long term action item: fix Gate to work correctly with
>>     multithreaded geant4.
>>     I have more comments, but they are more technical, will submit
>>     them as "issues" on GitHub.
>>     HTH,
>>     David B.
>>     Den 01/02/2016 kl. 11:18, skrev hediye acun:
>>         Hello Loic,
>>         We tried your recommendations with David Boersma.  First we
>>         run main
>>         macro file for 20 particles and stored output in PhS_new.root
>>         file. We
>>         got particle's properties(location and energy) in root with
>>         Scan command
>>         and then we closed root to make sure root will not remember
>>         the first
>>         output file due to the same tree's name. We run main macro
>>         second time
>>         with same particle number(20) to get second output file which
>>         called
>>         PhS_try.root.  In root with scan we obtained particle's
>>         properties again
>>         for second run. After that we compared two text files which
>>         include
>>         particle's location and energies and there was no difference
>>         between them.
>>         David Boersma run same macro file in his computer which has Geant4
>>         compiled with multithread OFF, and he obtained different
>>         results for
>>         same number of primaries. My Geant4 compiled with multithread
>>         ON.  We
>>         are going to try to compile on my computer with multitherad
>>         OFF and on
>>         David's computer multithread ON to investigate whether it
>>         really depends
>>         on the multithreading.
>>         Best regards.
>>         Hediye acun
>>         PS. It looks like the mailing list not working today. David didn't
>>         receive your reply and we didn't see on the archive either.
>>         ------------------------------------------------------------------------
>>         *From:* Grevillot Loic <loic.grevillot at medaustron.at
>>         <mailto:loic.grevillot at medaustron.at>>
>>         *To:* hediye acun <acunhediye at yahoo.com
>>         <mailto:acunhediye at yahoo.com>>;
>>         "gate-users at lists.opengatecollaboration.org
>>         <mailto:gate-users at lists.opengatecollaboration.org>"
>>         <gate-users at lists.opengatecollaboration.org
>>         <mailto:gate-users at lists.opengatecollaboration.org>>
>>         *Sent:* Monday, February 1, 2016 9:20 AM
>>         *Subject:* RE: [Gate-users] problem with random number seed?
>>         Hello,
>>         In my experience the command"/gate/random/setEngineSeed
>>         auto"works.
>>         In your example you are looking at histograms, but to verify
>>         that issue
>>         I was thinking about something different:
>>         -If the seed did not change as you suspect, the physical
>>         properties from
>>         every single particle stored in your Phase Space one after the
>>         other
>>         shall be exactly the same (position, direction, energy, etc.)
>>         for 2
>>         simulations.
>>         -Could you check that on a particle basis for 10 or 20 particles?
>>         You could even try a very simple example where you could
>>         randomly sample
>>         10 particles and look if they are the same for 2 simulations.
>>         Let us know!
>>         Thanks
>>         Image:Uncle_Sam_pointing_finger_small.jpgImage:We-Need-You1-324x500.jpgImage:superdupont-we-need-you.jpgImage:gsam_want_gnu_small.jpg
>>         *//**/GATE is a /**/research community/**/, /**/ please
>>         contribute!/*//
>>         *You just started? You found some errors in the examples and the
>>         documentation?*
>>         § You can correct the documentation
>>         <http://wiki.opengatecollaboration.org/index.php/Main_Page> on
>>         the wiki
>>         web site
>>         § You can share your experience on the user mailing-list
>>         <http://www.opengatecollaboration.org/mailinglist>
>>         **
>>         *You have a few months of experience or more?*
>>         § You can correct or even propose new examples
>>         <http://www.opengatecollaboration.org/Examples>
>>         § You can propose a new gate actor, it is as easy as a plug-in!
>>         <http://wiki.opengatecollaboration.org/index.php/GateActor>
>>         *You are now an official Gate addict and you need more?*
>>         § You can participate in Gate C++ source code development:
>>         debugging,
>>         propose new classes, etc.
>>         ðFor new developments, use git
>>         <http://www.opengatecollaboration.org/Git> and contact the
>>         gate-devel-mailing-list
>>         <http://www.opengatecollaboration.org/mailinglist> to be guided.
>>         *//**/Thanks for your contribution, the OpenGate collaboration!/*
>>         *From:*gate-users-bounces at lists.opengatecollaboration.org
>>         <mailto:gate-users-bounces at lists.opengatecollaboration.org>
>>         [mailto:gate-users-bounces at lists.opengatecollaboration.org
>>         <mailto:gate-users-bounces at lists.opengatecollaboration.org>]
>>         *On Behalf
>>         Of *hediye acun
>>         *Sent:* Friday, January 29, 2016 3:46 PM
>>         *To:* gate-users at lists.opengatecollaboration.org
>>         <mailto:gate-users at lists.opengatecollaboration.org>
>>         *Subject:* [Gate-users] problem with random number seed?
>>         Hello All,
>>         I have Gate "develop" version and at the same time
>>         geant4.10.1.0 and
>>         root_v5.34.32 on the GPU. My operating system is Linux Mint 17.2 .
>>         I am triying to simulate a linac head to get Phase Space of
>>         photons.
>>         Just for an example I run Gate for a basic geometry which
>>         include only
>>         electron beam, target filter and Phase space plane inside a linac
>>         geometry. When I run Gate two or more times for same "number of
>>         primaries" I got the exactly the same Phase Space distributions
>>         (histogram of Ekine completely identical). But I am using
>>         "/gate/random/setEngineSeed auto" command and according to the
>>         documentation that should give me the different seed every
>>         time when I
>>         run it. I would expect some random differences between PhS's from
>>         different runs.
>>         Does anyone have any idea about this issue? Thank you in advance.
>>         Hediye Acun
>>         *Disclaimer:*
>>         Please notice our E-Mail Disclaimer
>>         http://www.medaustron.at/email-disclaimer/
>>     _______________________________________________
>>     Gate-users mailing list
>>     Gate-users at lists.opengatecollaboration.org
>>     <mailto:Gate-users at lists.opengatecollaboration.org>
>>     http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
>> _______________________________________________
>> Gate-users mailing list
>> Gate-users at lists.opengatecollaboration.org
>> http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
> _______________________________________________
> Gate-users mailing list
> Gate-users at lists.opengatecollaboration.org
> http://lists.opengatecollaboration.org/mailman/listinfo/gate-users

More information about the Gate-users mailing list