Difference between revisions of "MOLLER GEANT4 Simulations"

From Hall A Wiki
Jump to: navigation, search
(Getting Started)
 
(37 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
<pre>
 +
This information is largely outdated as of September 2018. ~~Wouter
 +
</pre>
 +
 
I am going to suggest chapters and possibly sections (an outline) for the MOLLER GEANT4 documentation.  People will need to provide the text for the different sections.  People should also feel free to suggest a different outline or set-up.
 
I am going to suggest chapters and possibly sections (an outline) for the MOLLER GEANT4 documentation.  People will need to provide the text for the different sections.  People should also feel free to suggest a different outline or set-up.
  
 
== Overview ==
 
== Overview ==
 +
 +
This page contains a description of the GEANT4 application for use by MOLLER collaborators to perform simulation and design for the future MOLLER experiment.  There are at least two phases in the lifetime of the simulation.  The initial stage is one of continual improvement and modification to both add the geometry, additional physics generators, and options useful for design and optimization, as well as to improve the existing code with standards which will be adopted soon.  The second phase will be when gross changes in the geometry are no longer expected, and new physics generators are less likely to be added.     
 +
<br><br>
 +
At the current time the application in the initial stage and is under continual development in part to make it more efficient for use in the study of particular simulation projects.  Because the experiment is in the design phase and essentially no part of the geometry is fixed (target length, collimators, detectors, field maps) the application will continue to be modified so that these elements can be optimized. 
 +
<br><br>
 +
The second stage of the simulation will have less development activity and should be more user-friendly.  Once this stage is reached, the development of a gui interface which includes all the options which have been developed will be warranted. 
 +
<br><br>
 +
These two stages are not necessarily clearly separated in time; that is, the application will be used for projects while development is ongoing (see the [[MOLLER Simulations]] working group page).  It will be necessary to ensure that all of the options in the application are maintained through the transition to the second stage and their interactions are understood.
 +
<br><br>
 +
[[MOLLERsim application coding guidelines]] are under development.  The GEANT4 [https://geant4.cern.ch/collaboration/coding_guidelines.shtml coding guidelines] will be considered as a model for the MOLLERsim application.
  
 
=== GEANT4 ===
 
=== GEANT4 ===
=== MOLLER ===
+
[http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ GEANT Guide]
[http://hallaweb.jlab.org/12GeV/Moller/doxygen/doxygen/html/ DOxygen Documentation]
+
 
 +
[[JLAB GEANT4 Workshop, July 9-13, 2012]]
 +
 
 +
=== MOLLERsim ===
 +
[https://hallaweb.jlab.org/12GeV/Moller/doxygen/mollersim/html/index.html DOxygen Documentation]
 +
 
 +
 
 +
=== remoll ===
 +
[https://github.com/JeffersonLab/remoll/ remoll github repository][https://github.com/JeffersonLab/remoll/wiki/Home wiki]
  
 
== Getting Started ==
 
== Getting Started ==
  
Quick start (see important details below):<br>
+
=== Quick start (see important details below):===
  
 
:In a terminal window (on ifarml6, for example) type:  
 
:In a terminal window (on ifarml6, for example) type:  
 
::mkdir ~/scratch
 
::mkdir ~/scratch
::mkdir ~/scratch/ROOTfiles
+
::mkdir ~/scratch/ROOTfiles (you may actually want to make this a link to somewhere with more space)
 
::setenv MOLLERGEANTDIR <directory where you would like to have the simulation/moller12gev>
 
::setenv MOLLERGEANTDIR <directory where you would like to have the simulation/moller12gev>
:::(maybe in  
+
:::(maybe in /w/halla/parity/disk2/)
 
::cd <directory where you would like to have the simulation>
 
::cd <directory where you would like to have the simulation>
::svn checkout https://jlabsvn.jlab.org/svnroot/moller12gev
+
::svn checkout https://jlabsvn.jlab.org/svnroot/moller12gev/mollersim/trunk moller12gev
 
::cd moller12gev
 
::cd moller12gev
 
::source env_jlabcue
 
::source env_jlabcue
::make clean
+
::gmake clean
::make
+
::gmake
 
::cd analysis
 
::cd analysis
::make clean
+
::gmake clean
::make
+
::gmake
 
::cd ../
 
::cd ../
::jsub eesim.jsub <strong>OR</strong> change number of events in runee.mac to <10k and type bin/Linux-g++/moller_sim prerun.mac run_ee.mac
+
::change number of events in run_ee.mac to <10k and type bin/Linux-g++/moller_sim prerun.mac run_ee.mac
 
::change analysis/inifiles/sample.ini to point to rootfile that is eventually created in ~/scratch/ROOTfiles
 
::change analysis/inifiles/sample.ini to point to rootfile that is eventually created in ~/scratch/ROOTfiles
 
:::(may need to change number of events to match run_ee.mac)
 
:::(may need to change number of events to match run_ee.mac)
Line 32: Line 54:
 
::eog plots/moller_myr.gif (for example)
 
::eog plots/moller_myr.gif (for example)
  
 +
=== Detailed Instructions ===
 +
==== Getting the simulation ====
  
=== Getting the simulation ===
+
The following directions work for installing the MOLLER GEANT4 Simulation on ifarm: <br/>
 +
<br/>
 +
1.  Make a directory to store the simulation: <br/>
 +
mkdir moller_sim
 +
2.  Move into the directory for the simulation: <br/>
 +
cd moller_sim
 +
3.  Checkout the simulation: </br>
 +
svn checkout https://jlabsvn.jlab.org/svnroot/moller12gev/mollersim/trunk moller12gev 
 +
::  It may take a bit for the checkout to finish.
 +
4.  Run the following commands: <br/>
 +
setenv GEANT4_VERSION 4.9.5.p01
 +
setenv JLAB_ROOT /site/12gev_phys
 +
source ${JLAB_ROOT}/ce/jlab.csh
 +
::You may want to add these to your .tcsh file as well.
 +
5.  Go to moller12gev (the actual simulation directory) and do the following: <br/>
 +
/group/qweak/QwGeant4/cmake/bin/cmake CMakeLists.txt
 +
::If you do just cmake, you won't have the required version of it for the simulation
 +
6.  Then do the following: <br/>
 +
make -f Makefile
 +
::It'll take awhile, but then you will have the simulation!
  
In a terminal window, type:<br>
+
==== Setting the environment variables ====
:svn checkout https://jlabsvn.jlab.org/svnroot/moller12gev<br>
+
<br>
+
Get the field maps:<br>
+
:Proposal: [http://hallaweb.jlab.org/12GeV/Moller/downloads/fieldmap_front_4seg_Nov6.txt upstream], [http://hallaweb.jlab.org/12GeV/Moller/downloads/fieldmap_back_4seg_Nov6.txt hybrid]<br>
+
:Default: [http://hallaweb.jlab.org/12GeV/Moller/downloads/blockyUpstream_1.1.txt upstream], [http://hallaweb.jlab.org/12GeV/Moller/downloads/blockyHybrid_3.0.txt hybrid]<br>
+
<br>
+
:-OR- link to some central location, on the farm machines: <br>
+
:The defaults are currently (both in cylindrical coordinates):<br>
+
::ln -s /w/halla/parity/disk2/jmammei/tosca_stuff/MAPFILES/blockyHybrid_3.0.txt fieldmap_back.txt<br>
+
::ln -s /w/halla/parity/disk2/jmammei/tosca_stuff/MAPFILES/blockyUpstream_1.1.txt fieldmap_front.txt<br>
+
 
+
=== Setting the environment variables ===
+
 
<br>You'll have to make sure your environment variables are set correctly.  If you are running the simulation on your <br>
 
<br>You'll have to make sure your environment variables are set correctly.  If you are running the simulation on your <br>
 
own machine, for now you'll have to set the environment variables yourself, but be sure to also change the version <br>
 
own machine, for now you'll have to set the environment variables yourself, but be sure to also change the version <br>
Line 55: Line 86:
 
::source env_jlabcue
 
::source env_jlabcue
  
=== Batch Mode ===
+
==== Batch Mode ====
  
 
To run in batch mode: <br>
 
To run in batch mode: <br>
 
:Create a scratch directory in your home directory with a link to a ROOTfiles directory <br>
 
:Create a scratch directory in your home directory with a link to a ROOTfiles directory <br>
 
:Create your own .mac file or modify (or modify/use run_ee.mac, run_ep.mac or run_ine.mac) <br>
 
:Create your own .mac file or modify (or modify/use run_ee.mac, run_ep.mac or run_ine.mac) <br>
:Type, for example: bin/Linux-g++/moller_sim run_ee.mac <br>
+
:Type, for example: bin/Linux-g++/moller_sim prerun.mac run_ee.mac <br>
 
<br><br> Note: The default .mac files are intended to run on the farm using jsub, but to test you can change the number of  
 
<br><br> Note: The default .mac files are intended to run on the farm using jsub, but to test you can change the number of  
 
<br>events to 10k instead of 100k, for example.
 
<br>events to 10k instead of 100k, for example.
  
=== Interactive Mode ===
+
==== Interactive Mode ====
Right now the visualization works marginally well.  It uses OpenGL and it is very simple - you can only change the <br>
+
Right now the visualization works pretty well.  It uses OpenQt (thanks Wouter!). <br>
display with one of the macros that comes with svn.  Ultimately we will want to be able to change the view using <br>
+
I haven't played with it myself much, but you can use the mouse to change views and <br>
the mouse in the window, and will even probably want to develop a GUI. <br>
+
you can enter commands in the gui, or use the help to click the commands.<br>
 
<br>
 
<br>
For now, to use the visualization on the farm machines, in the moller12gev directory:<br>
+
To use the visualization on the farm machines, in the simulation directory:<br>
 
:Type:<br>
 
:Type:<br>
::bin/Linux-g++/moller_sim<br>
+
::bin/Linux-g++/moller_sim prerun.mac
<br>
+
:To change the view, modify vis.mac and then, in the GEANT4 terminal, type:<br>
+
::/control/execute vis.mac<br>
+
 
<br>
 
<br>
 
:To exit the interactive mode, type:
 
:To exit the interactive mode, type:
Line 83: Line 111:
 
:::with the OpenGL libraries.  I used Xming-mesa, and it works well.
 
:::with the OpenGL libraries.  I used Xming-mesa, and it works well.
  
=== Running on farm ===
+
==== Running on farm ====
 
If you want to run multiple simulations at the same time, or even one simulation with more than about 10k events, <br>
 
If you want to run multiple simulations at the same time, or even one simulation with more than about 10k events, <br>
you'll want to use the JLab Auger. <br>
+
you'll want to use the JLab Auger.  There is a batch submission script in the batch directory that will write the <br>
 +
necessary files and submit the jobs.  The script performs all the steps you could do by hand (see below).<br>
  
 
: If you haven't already, create a scratch directory in your home directory with a link to a ROOTfiles directory <br>
 
: If you haven't already, create a scratch directory in your home directory with a link to a ROOTfiles directory <br>
 
<br>
 
<br>
: To submit a job to the farm:
+
: To submit a job to the farm "by hand":
 
:: Create your own .mac file (or modify/use run_ee.mac, run_ep.mac or run_ine.mac) <br>
 
:: Create your own .mac file (or modify/use run_ee.mac, run_ep.mac or run_ine.mac) <br>
 
:: Create your own .csh file (or modify/use runsim_ee.csh, runsim_ep.csh or runsim_ine.csh) <br>
 
:: Create your own .csh file (or modify/use runsim_ee.csh, runsim_ep.csh or runsim_ine.csh) <br>
Line 102: Line 131:
 
:::MAIL: user@jlab.org -> your username at jlab or another email address
 
:::MAIL: user@jlab.org -> your username at jlab or another email address
  
=== Look at output ===
+
==== Look at output ====
 
            
 
            
 
From moller12gev directory:
 
From moller12gev directory:
Line 119: Line 148:
 
:::--> see more details in the README file
 
:::--> see more details in the README file
  
=== To do optics plots ===
+
==== To do optics plots ====
 +
 
 +
Use G4Trajectory in the future...
  
 
== Geometry ==
 
== Geometry ==
 +
 +
Currently the geometry is not very sophisticated.  It consists of the hydrogen of the target, with no aluminum cell. 
  
 
=== Target ===
 
=== Target ===
 +
Maybe Anna could work on improving the target geometry?
 +
* Add target windows
 +
 
=== Beamline ===
 
=== Beamline ===
 +
Right now there is no beamline in the simulation; the plan is to transport the scattered particles in vacuum; the <br>
 +
details will come as we decide whether to place the coils in the beamline or in a petal beamline.
 
=== Collimators ===
 
=== Collimators ===
 +
The collimators can be defined in a collimator geometry file which can be specified in the prerun.mac file.  The default <br>
 +
collimators are defined in svn as the default_coll.dat in the geometry directory.
 
=== Spectrometer ===
 
=== Spectrometer ===
 +
Currently there are no coils in the simulations, but the fields are present.  The field maps can be specified in the <br>
 +
prerun.mac file.
 
=== Detectors ===
 
=== Detectors ===
 +
Right now the detectors can be defined in the collimator geometry file which can be specified in the prerun.mac file.
  
 
== Generators ==
 
== Generators ==
Line 139: Line 182:
  
 
== Analysis ==
 
== Analysis ==
 +
[[moller_sim dictionary]] - a list of root variables and their definitions
  
 
== Benchmarks of the Simulation ==
 
== Benchmarks of the Simulation ==
 +
 +
== Options ==
 +
 +
GEANT4 allows you to create a messenger class for the different classes (Detector, Generator, Analysis, etc.) so that you can <br>
 +
specify options in macros that you include in the command line when you run the simulation.  Right now we have a "geometry" or <br>
 +
prerun.mac and a "gun" or run_<process>.mac.<br>
 +
<br>
 +
The prerun.mac sets the following options (shown with the defaults):<br>
 +
<pre>
 +
/control/verbose 2
 +
/run/verbose 0
 +
/tracking/verbose 0
 +
/moller/det/setCollimatorFileName default_coll
 +
/moller/det/setNumberofCollimators 10
 +
/moller/det/setTargetLength 150 cm
 +
/moller/field/setHybridMap blockyHybrid_3.0
 +
/moller/field/setUpstreamMap blockyUpstream_1.1
 +
/run/initialize
 +
</pre>
 +
<br>
 +
The gun macro sets the options related to the generator and the analysis:<br>
 +
<pre>
 +
moller/ana/rootfilename ee_test_jsub_sm_nt
 +
#
 +
/moller/gun/setConstSeed false
 +
/moller/gun/gen 0
 +
/run/beamOn 10000
 +
</pre>
 +
 +
  
 
<br><br> Return to [[MOLLER at 11 GeV E09-005]]
 
<br><br> Return to [[MOLLER at 11 GeV E09-005]]

Latest revision as of 09:45, 18 September 2018

This information is largely outdated as of September 2018. ~~Wouter

I am going to suggest chapters and possibly sections (an outline) for the MOLLER GEANT4 documentation. People will need to provide the text for the different sections. People should also feel free to suggest a different outline or set-up.

Overview

This page contains a description of the GEANT4 application for use by MOLLER collaborators to perform simulation and design for the future MOLLER experiment. There are at least two phases in the lifetime of the simulation. The initial stage is one of continual improvement and modification to both add the geometry, additional physics generators, and options useful for design and optimization, as well as to improve the existing code with standards which will be adopted soon. The second phase will be when gross changes in the geometry are no longer expected, and new physics generators are less likely to be added.

At the current time the application in the initial stage and is under continual development in part to make it more efficient for use in the study of particular simulation projects. Because the experiment is in the design phase and essentially no part of the geometry is fixed (target length, collimators, detectors, field maps) the application will continue to be modified so that these elements can be optimized.

The second stage of the simulation will have less development activity and should be more user-friendly. Once this stage is reached, the development of a gui interface which includes all the options which have been developed will be warranted.

These two stages are not necessarily clearly separated in time; that is, the application will be used for projects while development is ongoing (see the MOLLER Simulations working group page). It will be necessary to ensure that all of the options in the application are maintained through the transition to the second stage and their interactions are understood.

MOLLERsim application coding guidelines are under development. The GEANT4 coding guidelines will be considered as a model for the MOLLERsim application.

GEANT4

GEANT Guide

JLAB GEANT4 Workshop, July 9-13, 2012

MOLLERsim

DOxygen Documentation


remoll

remoll github repositorywiki

Getting Started

Quick start (see important details below):

In a terminal window (on ifarml6, for example) type:
mkdir ~/scratch
mkdir ~/scratch/ROOTfiles (you may actually want to make this a link to somewhere with more space)
setenv MOLLERGEANTDIR <directory where you would like to have the simulation/moller12gev>
(maybe in /w/halla/parity/disk2/)
cd <directory where you would like to have the simulation>
svn checkout https://jlabsvn.jlab.org/svnroot/moller12gev/mollersim/trunk moller12gev
cd moller12gev
source env_jlabcue
gmake clean
gmake
cd analysis
gmake clean
gmake
cd ../
change number of events in run_ee.mac to <10k and type bin/Linux-g++/moller_sim prerun.mac run_ee.mac
change analysis/inifiles/sample.ini to point to rootfile that is eventually created in ~/scratch/ROOTfiles
(may need to change number of events to match run_ee.mac)
analysis/mollerClass analysis/inifiles/sample.ini
eog plots/moller_myr.gif (for example)

Detailed Instructions

Getting the simulation

The following directions work for installing the MOLLER GEANT4 Simulation on ifarm:

1. Make a directory to store the simulation:

mkdir moller_sim

2. Move into the directory for the simulation:

cd moller_sim 

3. Checkout the simulation: </br>

svn checkout https://jlabsvn.jlab.org/svnroot/moller12gev/mollersim/trunk moller12gev  
It may take a bit for the checkout to finish.

4. Run the following commands:

setenv GEANT4_VERSION 4.9.5.p01
setenv JLAB_ROOT /site/12gev_phys
source ${JLAB_ROOT}/ce/jlab.csh
You may want to add these to your .tcsh file as well.

5. Go to moller12gev (the actual simulation directory) and do the following:

/group/qweak/QwGeant4/cmake/bin/cmake CMakeLists.txt
If you do just cmake, you won't have the required version of it for the simulation

6. Then do the following:

make -f Makefile
It'll take awhile, but then you will have the simulation!

Setting the environment variables


You'll have to make sure your environment variables are set correctly. If you are running the simulation on your
own machine, for now you'll have to set the environment variables yourself, but be sure to also change the version
of GEANT in the local_moller_settings.dat file.

On ifarml1 or ifarml6, type:
source env_jlabcue

Batch Mode

To run in batch mode:

Create a scratch directory in your home directory with a link to a ROOTfiles directory
Create your own .mac file or modify (or modify/use run_ee.mac, run_ep.mac or run_ine.mac)
Type, for example: bin/Linux-g++/moller_sim prerun.mac run_ee.mac



Note: The default .mac files are intended to run on the farm using jsub, but to test you can change the number of
events to 10k instead of 100k, for example.

Interactive Mode

Right now the visualization works pretty well. It uses OpenQt (thanks Wouter!).
I haven't played with it myself much, but you can use the mouse to change views and
you can enter commands in the gui, or use the help to click the commands.

To use the visualization on the farm machines, in the simulation directory:

Type:
bin/Linux-g++/moller_sim prerun.mac


To exit the interactive mode, type:
exit



Note: To use the visualization, at least from a Windows machine, I had to make sure my X-server was compiled
with the OpenGL libraries. I used Xming-mesa, and it works well.

Running on farm

If you want to run multiple simulations at the same time, or even one simulation with more than about 10k events,
you'll want to use the JLab Auger. There is a batch submission script in the batch directory that will write the
necessary files and submit the jobs. The script performs all the steps you could do by hand (see below).

If you haven't already, create a scratch directory in your home directory with a link to a ROOTfiles directory


To submit a job to the farm "by hand":
Create your own .mac file (or modify/use run_ee.mac, run_ep.mac or run_ine.mac)
Create your own .csh file (or modify/use runsim_ee.csh, runsim_ep.csh or runsim_ine.csh)
Create your own .jsub file (or modify/use eesim.jsub, epsim.jsub, inesim.jsub)


Then type, for example:
jsub eesim.jsub



Note: If you want to receive email notification of the completion of your job(s) you have to change the line
in the jsub file:
MAIL: user@jlab.org -> your username at jlab or another email address

Look at output

From moller12gev directory:

If you haven't compiled the analysis code yet:
cd analysis
make
cd ../


Then:
Modify sample.ini file in the analysis/initfiles directory to have the name(s) of the rootfile(s)
From terminal: ./analysis/mollerClass analysis/inifiles/sample.ini
The output and plot files should be created in your output/ and plots/ folders


--> see more details in the README file

To do optics plots

Use G4Trajectory in the future...

Geometry

Currently the geometry is not very sophisticated. It consists of the hydrogen of the target, with no aluminum cell.

Target

Maybe Anna could work on improving the target geometry?

  • Add target windows

Beamline

Right now there is no beamline in the simulation; the plan is to transport the scattered particles in vacuum; the
details will come as we decide whether to place the coils in the beamline or in a petal beamline.

Collimators

The collimators can be defined in a collimator geometry file which can be specified in the prerun.mac file. The default
collimators are defined in svn as the default_coll.dat in the geometry directory.

Spectrometer

Currently there are no coils in the simulations, but the fields are present. The field maps can be specified in the
prerun.mac file.

Detectors

Right now the detectors can be defined in the collimator geometry file which can be specified in the prerun.mac file.

Generators

Moller

Mott (Elastic ep)

Inelastic ep

Other backgrounds

Physics Processes

Analysis

moller_sim dictionary - a list of root variables and their definitions

Benchmarks of the Simulation

Options

GEANT4 allows you to create a messenger class for the different classes (Detector, Generator, Analysis, etc.) so that you can
specify options in macros that you include in the command line when you run the simulation. Right now we have a "geometry" or
prerun.mac and a "gun" or run_<process>.mac.

The prerun.mac sets the following options (shown with the defaults):

/control/verbose 2
/run/verbose 0
/tracking/verbose 0
/moller/det/setCollimatorFileName default_coll
/moller/det/setNumberofCollimators 10
/moller/det/setTargetLength 150 cm
/moller/field/setHybridMap blockyHybrid_3.0
/moller/field/setUpstreamMap blockyUpstream_1.1
/run/initialize


The gun macro sets the options related to the generator and the analysis:

moller/ana/rootfilename ee_test_jsub_sm_nt
#
/moller/gun/setConstSeed false
/moller/gun/gen 0
/run/beamOn 10000




Return to MOLLER at 11 GeV E09-005