Message: Re: Automatically run example N06 for multiple energies Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: Automatically run example N06 for multiple energies 

Forum: Run Management
Re: Question Automatically run example N06 for multiple energies (Brian)
Date: 02 Oct, 2014
From: Michael H. Kelsey <Michael H. Kelsey>

On Thu, 17 Oct 2013 17:49:49 GMT, Brian wrote:
> Hello, I was wondering if anyone could offer some assistance. I am
> creating a simulation similar to example N06 but I need to run it for
> about 10**9 particles at each energy starting from 900 KeV to 14 MeV in
> intervals of 50 KeV or so. I modified the example to simulate a
> Cherenkov detector and I am trying to get the response spectrum. Can
> anyone suggest a better way to do it? I am great with FORTRAN but I am
> still learning C++. I don't fully understand how to work with GEANT4 and
> ROOT. As of now I have it outputting everything I am interested in to a
> file and post processing it. I just need a way to automatically switch
> energies and rerun. Thanks in advance.

There are two ways you could do this, depending on what kind of computing system you have.

The simplest way is to do the file and directory management in your shell, and submit jobs to a batch system. Write a shell script with a loop over the energy values (i.e., as shell variable strings). In that script, create a destination directory named for the energy, |cd| into it, then run your G4 application with a macro where the energy is set. The shell can write a unique macro file into the directory, or you could set an envvar and use the macro command |/control/getEnv| to access it. With a batch system, you'd submit each job to your batch queue; on a single computer, you can run them in parallel in the background (if you have ~30 cores), or sequentially.

With more complexity, you can do it with one gigantic GEANT4 run. We provide macro commands where you can set up a loop, and launch a macro for each iteration of the loop. The only examples of this we have are related to visualization (e.g., examples/extended/runAndEvent/RE03), but the functionality is generic. You can put /run/beamOn inside the loop macro, and have your G4UserRunAction take care of opening and closing the output files.

I'd recommend the shell-based method (partly because that's what I like to use :-), because the shell is already designed to do directory and file management, in a way that the G4 macros aren't as capable.

  -- Michael Kelsey

 Add Message Add Message
to: "Re: Automatically run example N06 for multiple energies"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]