G4MICE TutorialOctober 25, 2005 -- RAL |
Attendance
Marco Apollonio, Malcolm Ellis, Aron Fish, Terry Hart, Atsushi Horikoshi, Lara Howlett, Amit Klier, Chris Rogers, Hideyuki Sakamoto, Rikard Sandstrom, Yagmur Torun, Roumen Tsenov, Kenny Walaron, Makoto Yoshida
Introduction
The aim of the tutorial is to demonstrate the installation, compilation and use of G4MICE.
The main MICE software page can be found here.
G4MICE architecture can be found here.
The main packages are:
BeamTools - Tools implementing cooling channel elements (coils, cavities, absorbers). This is a Fermilab package that has been modified for use in G4MICE.
Interface - Tools for handling file and database i/o as well as event/spill/run models.
Config - Configuration, geometry, materials and setup data
Calib - Detector calibration
EngModel - Modeling of the cooling channel components and fields including the magnet coils, rf cavities and absorbers.
DetModel - Modeling of detectors.
Recon - Reconstruction code for all detectors.
Analysis - Emittance calculation and other tools for physics analysis.
Simulation - Generation and tracking of particles (beam and background) through the detectors including all the physics processes.
DetResp - Generation of raw data (digits) from detector hits.
During the course of the Software Meeting, a number of new packages will be added.
The code for all of these packages is maintained in a CVS repository at IIT.
A number of external packages are required to compile and run G4MICE:
CLHEP - version 1.8.1.0
GEANT4 - version 6.2.p02
GSL - a recent version
ROOT - a recent version
KALMAN - is also maintained on the IIT CVS repository
At the moment, I'm using g++ version 3.2.3
Tarballs of the compiler and external libraries can be found here along with a sample .cshrc file.
If your kernel is not compatible, you should follow the instructions prepared by Rikard here.
Installation
Before getting G4MICE you should ensure that you have installed g++ 3.2.3 (or similar):
> g++ -v
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-53)
Then install and compile the external libraries (see above).
You also need to set up a .cshrc (or equivalent for your prefered shell). The sample available above assumes a certain structure for the installation:
setenv GSL_IEEE_MODE mask-all
setenv MICE_PATH /usr/users/ellis/mice/
setenv PATH ${PATH}:.:/vols/mice/ellis/MICE/prod/beams/:/vols/mice/ellis/cern/pro/bin/
setenv LD_LIBRARY_PATH ${MICE_PATH}/gcc3.2.3/CLHEP/1.8.1.0/lib/:${MICE_PATH}/gcc3.2.3/root/lib/:/vols/mice/ellis/cern/pro/lib/
setenv COMPILER gcc3.2.3
setenv SX_BASE_DIR ${MICE_PATH}/${COMPILER}/libsx/
setenv CLHEP_BASE_DIR ${MICE_PATH}/${COMPILER}/CLHEP/1.8.1.0/
setenv CLHEP_INCLUDE_DIR $CLHEP_BASE_DIR/include
setenv CLHEP_LIB_DIR $CLHEP_BASE_DIR/lib
setenv CLHEP_LIB CLHEP
setenv G4SYSTEM Linux-g++
setenv G4INSTALL ${MICE_PATH}/${COMPILER}/geant4.6.2.p02
setenv G4LIB ${G4INSTALL}/lib
setenv G4INCLUDE ${G4INSTALL}/include
setenv OGLHOME /usr/X11R6
setenv ROOTSYS ${MICE_PATH}/${COMPILER}/root/
setenv GSL_BASE_DIR ${MICE_PATH}/${COMPILER}/gsl/
setenv MICESRC ${MICE_PATH}/MICE/
setenv MICEPLATFORM $G4SYSTEM
setenv MICEROOT $MICESRC
setenv KALMAN_BASE_DIR ${MICE_PATH}/Kalman
setenv CERN_PATH /vols/mice/ellis/cern/pro/
echo "Installed MICE Environment"
echo ${COMPILER}
setenv CVSROOT :pserver:anonymous@hep04.phys.iit.edu:2401/home/mice/cvsroot
Once the external packages and compiler are installed and the logon script set correctly, it is possible to get G4MICE. The default CVSROOT assumes an anonymous(e) access to the repository which will allow you to get the code and receive updates, but you will not be able to commit changes (or new files). Yagmur can give you a CVS account when you are ready to start modifying and adding code.
To get the current latest version (also called the "head") you execute the command:
> cvs checkout MICE
CVS also understand abbreviations, so the following is equivalent:
> cvs co MICE
This will result in a lot of files being downloaded in a directory tree from the current working directory:
cvs checkout: Updating MICE
cvs checkout: Updating MICE/Analysis
cvs checkout: Updating MICE/Analysis/doc
U MICE/Analysis/doc/AnaParams.instructions.txt
U MICE/Analysis/doc/AnalysisV4.gif
cvs checkout: Updating MICE/Analysis/include
U MICE/Analysis/include/AnaEvent.hh
U MICE/Analysis/include/AnaOutput.hh
U MICE/Analysis/include/AnalysisEvent.hh
U MICE/Analysis/include/AnalysisLoader.hh
U MICE/Analysis/include/AnalysisPlane.hh
U MICE/Analysis/include/AnalysisPlaneManager.hh
U MICE/Analysis/include/Cut.hh
...
U MICE/setup/inputBG.dat
U MICE/setup/micesetup.csh
U MICE/setup/micesetup.sh
cvs checkout: Updating MICE/test
cvs checkout: Updating MICE/test/doc
cvs checkout: Updating MICE/test/include
cvs checkout: Updating MICE/test/mgr
cvs checkout: Updating MICE/test/object
cvs checkout: Updating MICE/test/src
For the tutorial, we want to use a well defined set of versions of files that are known to compile and run with known functionality and accuracy. We mark files by making a tag, which applies to a particular version of all files in the repository. For this tutorial, we will use the tag "Malcolm-demo-T20050208".
cvs co MICE
If you later wanted to update to a newly released version, you can go to the MICE directory and issue a cvs update command:
cvs update -r <some new tag name>
It will then update to the newer version of any files that have been changed and get any new files that have been added.
cvs update -r Malcolm-demo-T20050208
The last package that needs to be downloaded is one of the extnernal packages (Kalman) that was not included in the tar ball.
To get this, go to the directory ${MICE_PATH} and get Kalman from CVS:
cvs co Kalman
Then go to Kalman/mgr and compile the library with the command gmake.
Compilation
Once G4MICE has been downloaded, go to the directory MICE/mgr/ and to compile all the libraries and executables, simply issue the command gmake:
> gmake
If you want a quieter output (only giving warning and error messages) the option -s can be added:
> gmake -s
Updating BeamTools library ..
a - /usr/users/ellis/mice//MICE//BeamTools/object/Linux-g++/BTCylindricalVessel.o
a - /usr/users/ellis/mice//MICE//BeamTools/object/Linux-g++/BTGlobalEMField.o
a - /usr/users/ellis/mice//MICE//BeamTools/object/Linux-g++/BTGlobalMagField.o
a - /usr/users/ellis/mice//MICE//BeamTools/object/Linux-g++/BTLinacPhysVol.o
a - /usr/users/ellis/mice//MICE//BeamTools/object/Linux-g++/BTMagFieldMap.o
a - /usr/users/ellis/mice//MICE//BeamTools/object/Linux-g++/BTMagFieldMapPlacement.o
...
Updating Analysis library ..
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/AnaEvent.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/AnalysisLoader.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/AnalysisPlane.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/AnalysisPlaneManager.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/AnaOutput.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/Cut.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/Distribution.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/NDCovMatrix.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/NDHistogram.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/TrackStore.o
a - /usr/users/ellis/mice//MICE//Analysis/object/Linux-g++/Weight.o
In this version, the executables are compiled in the relevant packages, for example:
Analysis/object/Linux-g++/Analysis
Simulation/object/Linux-g++/Simulation
DetResp/object/Linux-g++/Digitization
Recon/object/Linux-g++/Reconstruction
Cooling channel Simulation and Analysis
From the MICE directory, make another directory (for example called demo) and change to it.
Then download the files found in this gzipped tar file.
There are two sets of datacards files as well as two sets of parameters for the Analysis executable.
The simulation and analysis is performed in five steps:
../Analysis/object/Linux-g++/Analysis cards.beamsim
If this is the first time you've run the Simulation, you will need to calculate the magnetic field map, so comment out the line below in the file cards.beamsim:
!SolDataFiles
useFiles !use this setting after the first run
../Simulation/object/Linux-g++/Simulation cards.beamsim
../DetResp/object/Linux-g++/Digitization cards.beamsim
../Recon/object/Linux-g++/Reconstruction cards.rec
../Analysis/object/Linux-g++/Analysis cards.rec
A number of files have been produced by each of the five stages above:
-rw-r--r-- 1 ellis res0 159 Oct 24 21:10 AnaParams.dat.generate
-rw-r--r-- 1 ellis res0 274 Oct 24 21:10 AnaParams.dat.emittance
-rw-r--r-- 1 ellis res0 168 Oct 24 21:10 cards.rec
-rw-r--r-- 1 ellis res0 82K Oct 24 21:28 for003.dat
-rw-r--r-- 1 ellis res0 703 Oct 24 21:30 cards.beamsim
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 Focus.dat
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 Coupling.dat
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 SolenoidEnd.dat
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 Solenoid.dat
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 SolenoidEnd2.dat
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 Matching.dat
-rw-r--r-- 1 ellis res0 1.5M Oct 24 21:32 Matching2.dat
-rw-r--r-- 1 ellis res0 5.1M Oct 24 21:48 Sim.out
-rw-r--r-- 1 ellis res0 5.7M Oct 24 21:49 Digits.out
-rw-r--r-- 1 ellis res0 0 Oct 24 21:49 SciFiRec.dat
-rw-r--r-- 1 ellis res0 32K Oct 24 21:50 VirtualRec.dat
-rw-r--r-- 1 ellis res0 1.3M Oct 24 21:50 Rec.out
-rw-r--r-- 1 ellis res0 2.9K Oct 24 21:51 Ana.out
The file Ana.out contains the results of the emittance calculation, the relevant numbers are in red:
1 0 896 -4677 0 196.809 227.567 314.916 0 0.21814 8.31336 8.7698 6.12164 29.3341
3.98438 227.567 -0.936558 -0.164566 -0.0688663 0.363105
0.772077 -4.91087 1.64266 -0.0993843 -0.0274182 0.599366
-4.91087 719.282 -11.4196 24.2222 8.55684 -12.8158
1.64266 -11.4196 980.7 24.9506 -30.3854 613.84
-0.0993843 24.2222 24.9506 787.363 -644.76 16.6266
-0.0274182 8.55684 -30.3854 -644.76 1089.21 -16.0465
0.599366 -12.8158 613.84 16.6266 -16.0465 788.505
1 1 896 4677 0 194.394 225.878 254.215 0 0.42207 7.58826 8.16898 6.33222
42.143
39.9799 225.878 -0.323098 0.809153 -0.306861 -0.627078
3.71388 -40.958 2.05041 0.856759 -2.75477 -0.504188
-40.958 987.185 -18.9247 30.6022 82.9273 -1.87977
2.05041 -18.9247 849.734 -19.2186 50.673 -502.889
0.856759 30.6022 -19.2186 756.934 488.786 -61.3129
-2.75477 82.9273 50.673 488.786 900.146 -136.15
-0.504188 -1.87977 -502.889 -61.3129 -136.15 848.212
2 0 896 -4677 0 196.649 227.197 315.127 0 0.114933 8.34972 8.72933 6.12115
21.3049
4.34386 227.197 -0.92398 -0.27163 0.0498621 0.450111
0.279963 -3.70917 0.36549 -0.201282 -0.281388 -0.0764319
-3.70917 575.884 -12.8234 21.4263 6.86524 -5.05081
0.36549 -12.8234 982.648 22.6284 -34.6957 611.118
-0.201282 21.4263 22.6284 792.573 -647.266 10.317
-0.281388 6.86524 -34.6957 -647.266 1090.17 -16.6529
-0.0764319 -5.05081 611.118 10.317 -16.6529 780.581
2 1 896 4677 0 196.886 227.534 256.704 0 0.208855 7.61164 8.18324 6.35475 29.7108
40.3293 227.534 -0.271987 0.820439 -0.302884 -0.721433
3.09184 -39.8963 1.77389 -0.351683 -3.53393 -0.560098
-39.8963 672.311 -23.5544 39.328 73.5861 -3.81365
1.77389 -23.5544 849.13 -23.5563 45.8036 -503.332
-0.351683 39.328 -23.5563 762.364 488.105 -62.2623
-3.53393 73.5861 45.8036 488.105 901.719 -134.243
-0.560098 -3.81365 -503.332 -62.2623 -134.243 849.046