|
|
User /
Using Geant4 on the clusterGeant4 is a Monte Carlo code for particle transport; it is widely used in High Energy Physics, but is also applicable to lower energies. Using Geant4Here we look at how to run multiple instances of a plain Geant4 simulation. Configure the environmentThe cluster uses a network file system to use CERN's versions of software like Geant4. This is called CernVM File System. Source the following script to set up the environment:# source this # get the Geant4 . /cvmfs/geant4.cern.ch/etc/setup.sh . /cvmfs/geant4.cern.ch/etc/setup-gcc.sh #export G4PLATFORM=x86_64-slc5-gcc43-opt . /cvmfs/geant4.cern.ch/etc/login.sh . /cvmfs/geant4.cern.ch/releases/geant4.9.5.p01/setup.sh # get the ROOT installation export ROOTSYS=/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/5.34.05/$G4PLATFORM/root export PATH=$ROOTSYS/bin:$PATH export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$ROOTSYS/lib:$DYLD_LIBRARY_PATH # add in libexpat ... it couldnt find it in the system export LD_LIBRARY_PATH=/cvmfs/sft.cern.ch/lcg/external/expat/2.0.1/$G4PLATFORM/lib:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=/cvmfs/sft.cern.ch/lcg/external/expat/2.0.1/$G4PLATFORM/lib:$DYLD_LIBRARY_PATH # now we need cmake export PATH=/cvmfs/sft.cern.ch/lcg/external/CMake/2.8.6/$G4PLATFORM/bin:$PATH # not yet sure if we are configure for make or cmake #CMAKE_INSTALL_PREFIX=/cvmfs/geant4.cern.ch/releases/geant4.9.5.p01/x86_64-slc5-gcc43-opt/ # now we need CLHEP export CLHEP_BASE_DIR=/cvmfs/sft.cern.ch/lcg/external/clhep/2.0.4.5/x86_64-slc5-gcc43-opt Note that every worker node will need to source this, so the easiest might be to have a shell file that first sets up the environment, then runs the executable. Prepare your code for parallel executionThe most important thing is to make sure that for each instance you use a different seed for the number number generator; this can be done using with
/analysis/setFilename BGOpix1+NaI_coinc_26cm-opt.{seed}.root
/random/setSeed {seed}
and change the if (argc>=3) { for (int ia=2;ia<argc;ia++){ // split an alias=value string and call /control/alias char* alias=argv[ia]; char* value=strchr(alias,'='); if (value!=NULL) { value[0]='\0';value++; char cmd[1024]; snprintf(cmd,1024,"/control/alias %s %s",alias,value); //printf("%s\n",cmd); UI->ApplyCommand(cmd); } } UI->ApplyCommand("/control/listAlias"); } Run with PBSSample job definition script #PBS -N batchG4test #PBS -m ae #PBS -q default #PBS -l cput=01:00:00 #PBS -v LD_LIBRARY_PATH,ROOTSYS,SEED cd $PBS_O_WORKDIR time ./g4test novis.g4m seed=$SEED ## end of batch script Then you can use the script to launch multiple instances of your Geant4 job: # SEED=1 qsub batchG4test.pbs # SEED=2 qsub batchG4test.pbs # SEED=3 qsub batchG4test.pbs The analysis of the separate ntuple files can easily be done by setting up an ntuple chain. |