Locked History Actions

Geant4

Geant4

メモ

  • CMake でインストール

    • Scientific Linux CERN 5.5 で CMake を使ってインストールしたときのメモはここ

    •  

  • シミュレーションプログラムの作成

    • basic/B1 サンプルプログラムをベースにして、自分のプログラムを作成するときのメモはここ

    • basic/B4c サンプルプログラムをベースにして、自分のプログラムを作成するときのメモはここ

    •  

  • Geant4 の構造

    • Geant4 の構造についてのメモは ここ (書き中)。

    •  

  • Geant4.9.5 on Windows 7

    • Windows 7 上の Visual C++ 2010 Express & CMake で Geant4.9.5 を動かしたときのメモはここ

    •  

  • FreeWRL のインストール

    • FreeWRL のインストールのメモはここ

    •  

  • Command のメモ

    • Command のメモはここ

    •  

インストール (in Scientific Linux CERN 5.5)

バージョン

  • Pieter さんのコードをメインで動かす予定なので、Geant4 と関連するソフトのバージョンを Pieter さんが RIBF クラスタで使っているものにあわせる。ちなみに、gcc のバージョンは 4.1.2。
    • geant4.9.1.p01
    • G4EMLOW4.3
    • dawn_3_88a
    • CLHEP 2.0.3.2
    • root 5.18/00

Pieter さんのコード

  • dEdXTable を使わないとめちゃくちゃおそい。

ディレクトリ構造

  • ホームディレクトリが雑多になるのを避けるため、cern ディレクトリをホームディレクトリに作り、そこに様々なプログラムをダウンロード&インストールした。ダウンロードしたものは下表の通り。いろんなバージョンの Geant4 をコンパイルして Try & Error を繰り返せるようにするため、ディレクトリの構造を少し深くして Geant4 のバージョンを切り換え易くした。ちなみに、gcc のバージョンは 4.1.2。

  • 参考1 : Geant4 Installation Guides - Installing Geant4 Release 4.9.2.p02 on Linux

  • 参考2 : 2004年7月23日 Geant4(v4.6.2)のインストール

  • 参考3 : Rootインストール

プログラム

ファイル

ダウンロードした
ディレクトリ

ダウンロード元

Geant4

geant4.9.1.p03.tar.gz

$HOME/cern/geant4.9.1.p03/

geant4 source > geant4.9.1.p03.tar.gz

G4EMLOW

G4EMLOW.5.1.tar.gz

$HOME/cern/geant4.9.1.p03/geant4.9.1.p03/data

G4EMLOW.5.1.tar.gz

CLHEP

clhep-2.0.3.2.tgz

$HOME/cern/clhep-2.0.3.2/

CLHEP > clhep-2.0.3.2.tgz

DAWN

dawn_3_88a.taz

$HOME/cern/dawn_3_88a/

DAWN > dawn_3_88a.taz

ROOT

root_v5.18.00.source.tar.gz

$HOME/cern/root_v5.18.00/

Downloading ROOT > Version 5.18 > root_v5.18.00.source.tar.gz

CLHEP インストール

  • $ cd
    $ mkdir cern cern/clhep-2.0.3.2
    $ cd cern/clhep-2.0.3.2
    $ wget http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/distributions/clhep-2.0.3.2.tgz
    $ tar zxvf clhep-2.0.3.2.tgz
    $ cd 2.0.3.2/CLHEP
    $ ./configure --prefix /home/username/cern/clhep-2.0.3.2 # prefix オプションでインストールする場所を指定。適宜 username の部分を変える。絶対パスの方がよいらしい。
    $ time make 2>&1 | tee make.log # tee コマンドで make.log というログを残しつつ、端末にも結果を表示してコンパイル。ついでに time コマンドでコンパイル時間も測定。
    ~~~~
    real    2m26.914s
    user    2m8.816s
    sys     0m16.817s
    $ make install # 自分のディレクトリにインストールするので root 権限はいらない。
    $ cd ~/cern
    $ ln -s clhep-2.0.3.2 CLHEP

Geant4 インストール

  • $ cd ~/cern
    $ mkdir geant4.9.1.p03
    $ cd geant4.9.1.p03
    $ wget http://geant4.web.cern.ch/geant4/support/source/geant4.9.1.p03.tar.gz
    $ tar zxvf geant4.9.1.p03.tar.gz
    $ cd geant4.9.1.p03
    $ mkdir data
    $ cd data
    $ wget http://geant4.web.cern.ch/geant4/support/source/G4EMLOW.5.1.tar.gz
    $ tar zxvf G4EMLOW.5.1.tar.gz
    $ cd ~/cern/geant4.9.1.p03/geant4.9.1.p03
    $ printenv | grep G4
    なにもないのを確認
    $ export MAKEFLAGS="-j 4"
    $ time ./Configure -build 2>&1 | tee make.log
    
    ~~~~~~~
    Libraries installation completed !
    
    ####################################################
    # Your Geant4 installation seems to be successful!  
    # To be sure please have a look into the log file:  
    # /home/koba/cern/geant4.9.1.p03/geant4.9.1.p03/.config/bin/Linux-g++/g4make.log  
    ####################################################
    
    real    32m4.529s
    user    24m48.888s
    sys     4m14.428s
    
    $ ./Configure
    $ ./Configure -install
    $ cd ~/cern
    $ ln -s geant4.9.1.p03 geant4
  • 注1) ./Configure の 設定を変えた場合、ディレクトリを全て消して、最初から Build しないと、サンプル(試したのはA01)のコンパイルが通らなかった。特に可視化関連のツール(DAWN, OpenGLなど)の設定。shared object の設定も変えるとダメだったかも?ちゃんと調べてないので、時間があればうまい方法を探す。
  • 注2) CPU の 4 core を使ってコンパイルする場合、./Conrigure の前に export MAKEFLAGS="-j 4" と打てば良い。参考 : Geant4のmakeで並列化

  • ./Configure -build で作成された config.sh の例は これ

DAWN インストール

  • $ su
    パスワード
    # yum -y install tcl tk ImageMagick
    # exit
    $ wish                     # Window-Based Shell が立ち上がるか確認
    % exit
    $ display                  # ImageMagick が立ち上がるか確認 (gv があれば、それでも良い。)
      x  ボタンで終了
    $ cd ~/cern
    $ mkdir dawn_3_88a
    $ cd dawn_3_88a
    $ wget http://geant4.kek.jp/~tanaka/src/dawn_3_88a.taz
    $ tar zxvf dawn_3_88a.taz
    $ cd dawn_3_88a
    $ ./configure_xwin
    ****************************************************
    * Configure script to generate Makefile of DAWN    *
    *                       ------ without OpenGL mode *
    *                                                  *
    * (Note: If you want to incorporate OpenGL mode,   *
    *        use the other script "configure".      )  *
    ****************************************************
    
    
    Input C++ compiler name (e.g. g++, no default).
     :g++
    Input optimization option (e.g. -O2, no default)
     :-O2
    Input Tcl/Tk window shell name
      (e.g. wish, no default): wish
    Input include directory of Xlib "with -I":
      (e.g. -I/usr/X11R6/include) 
       Hit return key if path is already set properly.            )
     : -I/usr/include/X11
    
    Input lib directory of Xlib "with -L":
      (e.g. -L/usr/X11R6/lib) 
       Hit return key if path is already set properly.)
     : -L/usr/lib
    
    Input directory to install executable files
      (e.g. /usr/local/bin, no default ): /home/koba/cern/dawn_3_88a/bin
    Select a system (0: Defalut, 1: AIX, 2: IRIX, 3: Solaris, 4: RedHat/FedoraCore): 4
    
    Do you use remote-visualization function? (y/n, no default)
     (Select n if your compilation fails for FRClientServer.cc)
     : n
    
    
    Old Makefile is deleted.
    New Makefile is created.
    
    C++ compiler            : g++
    Optimization level      : -O2
    Tcl/Tk window shell     : wish
    Xlib include directory  : -I/usr/include/X11
    Xlib lib directory      : -L/usr/lib
    Socket libraries        : 
    System name             : RedHat
    Remote visualization    : n
    
    Type  "make" to start compilation.
    
    After compilation, type  "make install" for installation.
    Then four executable files "dawn", "DAWN_GUI",
    "dawnunixd", and "dawninetd"  will be installed to 
    /home/koba/cern/dawn_3_88a/bin.
    
    $ time make -j 4  2>&1 | tee make.log
    real    0m5.477s
    user    0m19.191s
    sys     0m1.469s
    
    $ mkdir ~/cern/dawn_3_88a/bin
    $ make install
    $ cd ~/cern
  • さらに、~/cern/dawn_3_88a/bin に PATH を通しておく。普通は $HOME/.bashrc というファイル (シェルが起動したときに毎回実行されるシェルスクリプト) に export PATH=$HOME/cern/dawn_3_88a/bin/:$PATH という行を書いておく。(ただし、使っているシェルが bash の場合。csh を使っている場合は、Google で書き方を調べる。) echo コマンドを用いて $HOME/.bashrc の最下部に書き込む場合は、以下のようなコマンドを実行する。
    • $ echo '#' >> $HOME/.bashrc
      $ echo '# DAWN PATH' >> $HOME/.bashrc
      $ echo 'export PATH=$HOME/cern/dawn_3_88a/bin/:$PATH' >> $HOME/.bashrc
  • PATH を有効にしたら (source ~/.bashrc) 、サンプルファイルを試しに実行してみる。
    • $ source ~/.bashrc
      $ cd ~/cern/dawn_3_88a/dawn_3_88a/PRIM_DATA
      $ dawn primitives.prim
  • DAWN_GUI.png

ROOT インストール

  • $ cd ~/cern
    $ mkdir root_v5.18.00
    $ cd root_v5.18.00
    $ wget ftp://root.cern.ch/root/root_v5.18.00.source.tar.gz
    $ tar zxvf root_v5.18.00.source.tar.gz
    $ cd root
    $ ./configure --prefix=/home/username/cern/root_v5.18.00  --etcdir=/home/username/cern/root_v5.18.00/etc # prefix, etcdir オプションでインストールする場所を指定。適宜 username の部分を変える。
    $ time make -j 4  2>&1 | tee make.log
    ~~~~~~~~~~~
    real    4m36.183s
    user    16m30.874s
    sys     1m18.430s
    
    $ make install # 自分のディレクトリにインストールするので root 権限はいらない。
    $ cd ~/cern
    $ ln -s root_v5.18.00 root

Geant4Riken Memo

PieterさんのGEANT4 Simulation Code for Gamma-Ray Detectors used in the RIKEN-RIBF Facilityを使うにあたってのおぼえがき。

void UserSteppingAction(const G4Step*)

  • geant4/geant4.9.1.p01/source/tracking/include/G4UserSteppingAction.hh 内
    public:
       virtual void UserSteppingAction(const G4Step*){;}
  • /EventGenerator/include/SteppingAction.hh 内
        void UserSteppingAction(const G4Step*);
  • UserSteppingAction()は、!runManager->BeamOn(1); の後にステップごとに呼び出される?次のように呼び出される?

  • source/run/include/G4RunManager.hh 内
      public: // with description
        virtual void BeamOn(G4int n_event,const char* macroFile=0,G4int n_select=-1);
  • G4RunManager.cc 内

    00132 void G4RunManager::BeamOn(G4int n_event,const char* macroFile,G4int n_select)
    00133 {
    00134   G4bool cond = ConfirmBeamOnCondition();
    00135   if(cond)
    00136   {
    00137     numberOfEventToBeProcessed = n_event;
    00138     ConstructScoringWorlds();
    00139     RunInitialization();
    00140     if(n_event>0) DoEventLoop(n_event,macroFile,n_select);
    00141     RunTermination();
    00142   }
    00143 }
    ...
    00215 void G4RunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_select)
    00216 {
    ...
    00230 // Event loop
    00231   G4int i_event;
    00232   for( i_event=0; i_event<n_event; i_event++ )
    00233   {
    00234     currentEvent = GenerateEvent(i_event);
    00235     eventManager->ProcessOneEvent(currentEvent);
    00236     AnalyzeEvent(currentEvent);
    00237     UpdateScoring();
    00238     if(i_event<n_select) G4UImanager::GetUIpointer()->ApplyCommand(msg);
    00239     StackPreviousEvent(currentEvent);
    00240     currentEvent = 0;
    00241     if(runAborted) break;
    00242   }
  • G4EventManager.cc 内

    00098 void G4EventManager::DoProcessing(G4Event* anEvent)
    00099 {
    ...
    00185     trackManager->ProcessOneTrack( track );
    ...
    00332 void G4EventManager::ProcessOneEvent(G4Event* anEvent)
    00333 {
    00334   trackIDCounter = 0;
    00335   DoProcessing(anEvent);
    00336 }
  • G4TrackingManager.cc 内

    00068 void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
    00070 {
    ...
    00119   // Track the particle Step-by-Step while it is alive
    00120   G4StepStatus stepStatus;
    00121 
    00122   while( (fpTrack->GetTrackStatus() == fAlive) ||
    00123          (fpTrack->GetTrackStatus() == fStopButAlive) ){
    00124 
    00125     fpTrack->IncrementCurrentStepNumber();
    00126     stepStatus = fpSteppingManager->Stepping();
    00127 #ifdef G4_STORE_TRAJECTORY
    00128     if(StoreTrajectory) fpTrajectory->
    00129                         AppendStep(fpSteppingManager->GetStep()); 
    00130 #endif
    00131     if(EventIsAborted) {
    00132       fpTrack->SetTrackStatus( fKillTrackAndSecondaries );
    00133     }
    00134   }
    ...
  • G4SteppingManager.cc 内

    00117 G4StepStatus G4SteppingManager::Stepping()
    00119 {
    ...
    00242 // User intervention process.
    00243    if( fUserSteppingAction != NULL ) {
    00244       fUserSteppingAction->UserSteppingAction(fStep);
    00245    }
    00246    G4UserSteppingAction* regionalAction
    00247     = fStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()
    00248       ->GetRegionalSteppingAction();
    00249    if( regionalAction ) regionalAction->UserSteppingAction(fStep);
    ...

G4RandGauss::shoot

Geant4 インストール (in Vine Linux 4.1?)

http://cosmic.riken.jp/yujin/document/install_geant4_vine32.txtを参考にインストール。

ディレクトリの構成は、上記ページとGeant4Rikenのsetup.shのディレクトリ構造を参考に以下のように少し変えた。

  /usr/local --+- geant4 --+- CLHEP -----+- clhep-2.0.4.5.tgz 
               |           |             +- 2.0.4.5 -----------+- CLHEP
               |           |             +- bin     --link-->  +- bin
               |           |             +- include --link-->  +- include
               |           |             +- lib     --link-->  +- lib
               |           |
               |           +- dawn ------+- dawn_3_88a.taz
               |           |             +- dawn_3_88a
               |           |             +- bin
               |           |
               |           +- data
               |           +- env
               |           +- geant4.9.0.p02.tar.gz
               |           +- geant4.9.0.p02
               |
               +- root ----+- v5.26.00 ----------+- root
                           +- bin      --link--> +- bin
                           +- include  --link--> +- include
                           +- lib      --link--> +- lib
                           +- root     --link--> +- root
                           +- share    --link--> +- share
                                                 +- root_v5.26.00.source.tar.gz

それぞれのプログラムの./configureは確か以下の通り。

CLHEP : ./configure --prefix=/usr/local/geant4/CLHEP/2.0.4.5

root : ./configure --prefix=/usr/local/root/v5.26.00

[koba@he dawn_3_88a]$ ./configure_xwin
****************************************************
* Configure script to generate Makefile of DAWN    *
*                       ------ without OpenGL mode *
*                                                  *
* (Note: If you want to incorporate OpenGL mode,   *
*        use the other script "configure".      )  *
****************************************************


Input C++ compiler name (e.g. g++, no default).
 :g++
Input optimization option (e.g. -O2, no default)
 :
Input Tcl/Tk window shell name
  (e.g. wish, no default): wish
Input include directory of Xlib "with -I":
  (e.g. -I/usr/X11R6/include)
   Hit return key if path is already set properly.            )
 : -I/usr/X11R6/include

Input lib directory of Xlib "with -L":
  (e.g. -L/usr/X11R6/lib)
   Hit return key if path is already set properly.)
 : -L/usr/X11R6/lib

Input directory to install executable files
  (e.g. /usr/local/bin, no default ): /usr/local/geant4/dawn/bin
Select a system (0: Defalut, 1: AIX, 2: IRIX, 3: Solaris, 4: RedHat/FedoraCore): 4

Do you use remote-visualization function? (y/n, no default)
 (Select n if your compilation fails for FRClientServer.cc)
 : y

Geant4 コンパイルの際は、上記リンクに沿ってコンパイル。ただし、変わりにgeant4.9.0.p02-setup.csh を実行し、環境設定を行った。さらに、XOrg-gl-develというパッケージを追加でインストールしないと、コンパイルが通らなかった。

メモ

  • コンパイラを変えて G4R をコンパイルするときは、Geat4 本体もコンパイルしなおした。これでうまくいったけど、本当か?
  • 以下のコマンドでコンパイラのバージョンを選択。gcc-4.0.2, g++-4.0.2 で Geant4 本体をコンパイルしなおした。
  • /sbin/update-alternatives --config gcc
    /sbin/update-alternatives --config g++
  • libCore のエラーでG4Rコンパイルできず。