Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -117,7 +117,7 @@ MPI runtime Environment
|
||||
-----------------------
|
||||
1. Make hosts/cluster configuration of your MPI environment.
|
||||
2. Launch MPI runtime environment, typically executing
|
||||
`lamboot` (LAM) / `mpdboot` (MPICH2).
|
||||
`lamboot` (LAM) / `mpdboot` (MPICH2) / `mpd` (Inrel).
|
||||
|
||||
How to run
|
||||
----------
|
||||
@@ -188,7 +188,7 @@ A simple application.
|
||||
|
||||
- Geometry : chamber / calorimeter
|
||||
- Primary : particle gun (200 MeV electron as default)
|
||||
- Physics List : standard EM
|
||||
- Physics List : FTFT_BERT
|
||||
|
||||
**Features:**
|
||||
- Particles are transported in a geometry without any scoring.
|
||||
|
||||
@@ -9,6 +9,19 @@
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
10 Novembeer 2013 K. Murakami (MPI-V09-06-00)
|
||||
[source]
|
||||
- new coding guide line
|
||||
- CMakeLists.txt, add BUILD_SHARED_LIBS flag for creating static lib
|
||||
add check IntelMPI, mpiicpc
|
||||
- MT migration : beamOn thread stacked to main for MT
|
||||
use /run/beamOn command, instead of direct call of RM.BeamOn()
|
||||
[examples]
|
||||
- change coding guideling to the example guide
|
||||
- MT migration
|
||||
- PhysicsList is changed to FTFP_BERT
|
||||
- add run.mac
|
||||
|
||||
20 November 2012, I. Hrivnacova (MPI-V09-05-06)
|
||||
- Fixed .README files
|
||||
|
||||
|
||||
@@ -129,66 +129,75 @@ pre code {
|
||||
.right {text-align:right}
|
||||
|
||||
</style><style type="text/css">
|
||||
body{font-size:14px;line-height:1.6;font-family: Helvetica, arial, freesans, clean, sans-serif;padding: 20px;}
|
||||
body>*:first-child{margin-top:0!important;}
|
||||
body>*:last-child{margin-bottom:0!important;}
|
||||
body a:active {outline: none;}
|
||||
body a:hover {text-decoration: underline;}
|
||||
body a {color: #4183C4;text-decoration: none;}
|
||||
body a.absent{color:#c00;}
|
||||
body h1, body h2, h3, h4, h5, h6{margin:20px 0 10px;padding:0;font-weight:bold;-webkit-font-smoothing:antialiased;}
|
||||
body h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code{font-size:inherit;}
|
||||
body h1{font-size:28px;color:#000;}
|
||||
body h2{font-size:24px;border-bottom:1px solid #ccc;color:#000;}
|
||||
body h3{font-size:18px;}
|
||||
body h4{font-size:16px;}
|
||||
body h5{font-size:14px;}
|
||||
body h6{color:#777;font-size:14px;}
|
||||
body p, blockquote, ul, ol, dl, li, table, pre{margin:15px 0;}
|
||||
body hr{background:transparent url('../../images/modules/pulls/dirty-shade.png') repeat-x 0 0;border:0 none;color:#ccc;height:4px;padding:0;}
|
||||
body>h2:first-child,>h1:first-child,>h1:first-child+h2,>h3:first-child,>h4:first-child,>h5:first-child,>h6:first-child{margin-top:0;padding-top:0;}
|
||||
body h1+p, h2+p, h3+p, h4+p, h5+p, h6+p{margin-top:0;}
|
||||
body li p.first{display:inline-block;}
|
||||
body ul, ol{padding-left:30px;}
|
||||
body ul li>:first-child, ol li>:first-child{margin-top:0;}
|
||||
body ul li>:last-child, ol li>:last-child{margin-bottom:0;}
|
||||
body dl{padding:0;}
|
||||
body dl dt{font-size:14px;font-weight:bold;font-style:italic;padding:0;margin:15px 0 5px;}
|
||||
body dl dt:first-child{padding:0;}
|
||||
body dl dt>:first-child{margin-top:0;}
|
||||
body dl dt>:last-child{margin-bottom:0;}
|
||||
body dl dd{margin:0 0 15px;padding:0 15px;}
|
||||
body dl dd>:first-child{margin-top:0;}
|
||||
body dl dd>:last-child{margin-bottom:0;}
|
||||
body blockquote{border-left:4px solid #DDD;padding:0 15px;color:#777;}
|
||||
body blockquote>:first-child{margin-top:0;}
|
||||
body blockquote>:last-child{margin-bottom:0;}
|
||||
body table{padding:0;}
|
||||
body table tr{border-top:1px solid #ccc;background-color:#fff;margin:0;padding:0;}
|
||||
body table tr:nth-child(2n){background-color:#f8f8f8;}
|
||||
body table tr th{font-weight:bold;}
|
||||
body table tr th, table tr td{border:1px solid #ccc;text-align:left;margin:0;padding:6px 13px;}
|
||||
body table tr th>:first-child, table tr td>:first-child{margin-top:0;}
|
||||
body table tr th>:last-child, table tr td>:last-child{margin-bottom:0;}
|
||||
body img{max-width:100%;}
|
||||
body span.frame{display:block;overflow:hidden;}
|
||||
body span.frame>span{border:1px solid #ddd;display:block;float:left;overflow:hidden;margin:13px 0 0;padding:7px;width:auto;}
|
||||
body span.frame span img{display:block;float:left;}
|
||||
body span.frame span span{clear:both;color:#333;display:block;padding:5px 0 0;}
|
||||
body span.align-center{display:block;overflow:hidden;clear:both;}
|
||||
body span.align-center>span{display:block;overflow:hidden;margin:13px auto 0;text-align:center;}
|
||||
body span.align-center span img{margin:0 auto;text-align:center;}
|
||||
body span.align-right{display:block;overflow:hidden;clear:both;}
|
||||
body span.align-right>span{display:block;overflow:hidden;margin:13px 0 0;text-align:right;}
|
||||
body span.align-right span img{margin:0;text-align:right;}
|
||||
body span.float-left{display:block;margin-right:13px;overflow:hidden;float:left;}
|
||||
body span.float-left span{margin:13px 0 0;}
|
||||
body span.float-right{display:block;margin-left:13px;overflow:hidden;float:right;}
|
||||
body span.float-right>span{display:block;overflow:hidden;margin:13px auto 0;text-align:right;}
|
||||
body code, tt{margin:0 2px;padding:0 5px;white-space:nowrap;border:1px solid #eaeaea;background-color:#f8f8f8;border-radius:3px;}
|
||||
body pre>code{margin:0;padding:0;white-space:pre;border:none;background:transparent;}
|
||||
body .highlight pre, pre{background-color:#f8f8f8;border:1px solid #ccc;font-size:13px;line-height:19px;overflow:auto;padding:6px 10px;border-radius:3px;}
|
||||
body pre code, pre tt{background-color:transparent;border:none;}
|
||||
body {
|
||||
font-family: "Geneva", Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #09c;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #336699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0px 0px 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2 {
|
||||
border-bottom: 2px dotted #ccc;
|
||||
margin: 5px 0px 15px;
|
||||
}
|
||||
|
||||
h6 {
|
||||
color: #09c;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
font-family: "Georgia", Courier New, courier, sans-serif;
|
||||
background: #efefef;
|
||||
padding: 5px 10px;
|
||||
border: solid 1px #ddd;
|
||||
margin: 15px;
|
||||
-webkit-border-radius:6px;
|
||||
-moz-border-radius:6px;
|
||||
border-radius:6px;
|
||||
color: #333;
|
||||
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
li {
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
code {
|
||||
background-color: #f1f1f1;
|
||||
color: #336699;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
pre > code {
|
||||
margin: 0px;
|
||||
padding: 5px;
|
||||
border: 0px;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
|
||||
</style></head>
|
||||
<body>
|
||||
<h1>Geant4 MPI Interface</h1>
|
||||
@@ -298,7 +307,7 @@ to the dynamic linker configuration using <code>ldconfig</code>.
|
||||
<ol>
|
||||
<li>Make hosts/cluster configuration of your MPI environment.</li>
|
||||
<li>Launch MPI runtime environment, typically executing
|
||||
<code>lamboot</code> (LAM) / <code>mpdboot</code> (MPICH2).</li>
|
||||
<code>lamboot</code> (LAM) / <code>mpdboot</code> (MPICH2) / <code>mpd</code> (Intel).</li>
|
||||
</ol>
|
||||
|
||||
<h2>How to run</h2>
|
||||
@@ -373,7 +382,7 @@ for running examples:</p>
|
||||
<ul>
|
||||
<li>Geometry : chamber / calorimeter</li>
|
||||
<li>Primary : particle gun (200 MeV electron as default)</li>
|
||||
<li>Physics List : standard EM</li>
|
||||
<li>Physics List : FTFP_BERT</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>Features:</strong></p>
|
||||
|
||||
@@ -110,7 +110,7 @@ MPI runtime Environment
|
||||
-----------------------
|
||||
1. Make hosts/cluster configuration of your MPI environment.
|
||||
2. Launch MPI runtime environment, typically executing
|
||||
`lamboot` (LAM) / `mpdboot` (MPICH2).
|
||||
`lamboot` (LAM) / `mpdboot` (MPICH2) / `mpd` (Intel).
|
||||
|
||||
How to run
|
||||
----------
|
||||
@@ -180,7 +180,7 @@ A simple application.
|
||||
|
||||
- Geometry : chamber / calorimeter
|
||||
- Primary : particle gun (200 MeV electron as default)
|
||||
- Physics List : standard EM
|
||||
- Physics List : FTFP_BERT
|
||||
|
||||
**Features:**
|
||||
- Particles are transported in a geometry without any scoring.
|
||||
|
||||
@@ -12,7 +12,7 @@ A simple application
|
||||
|
||||
- Geometry : chamber / calorimeter
|
||||
- Primary : particle gun (200 MeV electron as default)
|
||||
- Physics List : standard EM
|
||||
- Physics List : FTFP_BERT
|
||||
|
||||
The environment variable *G4LEDATA* for low energy EM data is required.
|
||||
|
||||
|
||||
@@ -8,8 +8,11 @@ project(exMPI01)
|
||||
#----------------------------------------------------------------------------
|
||||
# check MPI package...
|
||||
find_package(MPI REQUIRED)
|
||||
# modify these var. if needed
|
||||
|
||||
# modify these variables if needed
|
||||
set(CMAKE_CXX_COMPILER mpicxx)
|
||||
#set(CMAKE_CXX_COMPILER mpiicpc)
|
||||
|
||||
#set(CMAKE_CXX_INCLUDE_PATH )
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@@ -69,6 +72,7 @@ set_target_properties(exMPI01
|
||||
# relies on these scripts being in the current working directory.
|
||||
#
|
||||
set(exMPI01_SCRIPTS
|
||||
run.mac
|
||||
v.mac
|
||||
)
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
$Id: History,v 1.3 2010-06-06 05:07:23 perl Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
exMPI01 History
|
||||
---------------
|
||||
|
||||
27 October 2012 K. Murakami
|
||||
- migrated to CMake build
|
||||
- updated documentations
|
||||
|
||||
4 June 2010 J.Perl
|
||||
- Updated vis usage.
|
||||
|
||||
18 May 2010 K.Murakami
|
||||
- use G4UIcsh instead of G4UItcsh because OpenMPI is now default.
|
||||
- use G4eMultipleScattering instead of obsolete G4MultipleScattering.
|
||||
|
||||
16 Nov. 2007 K.Murakami
|
||||
- commited to G4 CVS.
|
||||
@@ -129,66 +129,75 @@ pre code {
|
||||
.right {text-align:right}
|
||||
|
||||
</style><style type="text/css">
|
||||
body{font-size:14px;line-height:1.6;font-family: Helvetica, arial, freesans, clean, sans-serif;padding: 20px;}
|
||||
body>*:first-child{margin-top:0!important;}
|
||||
body>*:last-child{margin-bottom:0!important;}
|
||||
body a:active {outline: none;}
|
||||
body a:hover {text-decoration: underline;}
|
||||
body a {color: #4183C4;text-decoration: none;}
|
||||
body a.absent{color:#c00;}
|
||||
body h1, body h2, h3, h4, h5, h6{margin:20px 0 10px;padding:0;font-weight:bold;-webkit-font-smoothing:antialiased;}
|
||||
body h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code{font-size:inherit;}
|
||||
body h1{font-size:28px;color:#000;}
|
||||
body h2{font-size:24px;border-bottom:1px solid #ccc;color:#000;}
|
||||
body h3{font-size:18px;}
|
||||
body h4{font-size:16px;}
|
||||
body h5{font-size:14px;}
|
||||
body h6{color:#777;font-size:14px;}
|
||||
body p, blockquote, ul, ol, dl, li, table, pre{margin:15px 0;}
|
||||
body hr{background:transparent url('../../images/modules/pulls/dirty-shade.png') repeat-x 0 0;border:0 none;color:#ccc;height:4px;padding:0;}
|
||||
body>h2:first-child,>h1:first-child,>h1:first-child+h2,>h3:first-child,>h4:first-child,>h5:first-child,>h6:first-child{margin-top:0;padding-top:0;}
|
||||
body h1+p, h2+p, h3+p, h4+p, h5+p, h6+p{margin-top:0;}
|
||||
body li p.first{display:inline-block;}
|
||||
body ul, ol{padding-left:30px;}
|
||||
body ul li>:first-child, ol li>:first-child{margin-top:0;}
|
||||
body ul li>:last-child, ol li>:last-child{margin-bottom:0;}
|
||||
body dl{padding:0;}
|
||||
body dl dt{font-size:14px;font-weight:bold;font-style:italic;padding:0;margin:15px 0 5px;}
|
||||
body dl dt:first-child{padding:0;}
|
||||
body dl dt>:first-child{margin-top:0;}
|
||||
body dl dt>:last-child{margin-bottom:0;}
|
||||
body dl dd{margin:0 0 15px;padding:0 15px;}
|
||||
body dl dd>:first-child{margin-top:0;}
|
||||
body dl dd>:last-child{margin-bottom:0;}
|
||||
body blockquote{border-left:4px solid #DDD;padding:0 15px;color:#777;}
|
||||
body blockquote>:first-child{margin-top:0;}
|
||||
body blockquote>:last-child{margin-bottom:0;}
|
||||
body table{padding:0;}
|
||||
body table tr{border-top:1px solid #ccc;background-color:#fff;margin:0;padding:0;}
|
||||
body table tr:nth-child(2n){background-color:#f8f8f8;}
|
||||
body table tr th{font-weight:bold;}
|
||||
body table tr th, table tr td{border:1px solid #ccc;text-align:left;margin:0;padding:6px 13px;}
|
||||
body table tr th>:first-child, table tr td>:first-child{margin-top:0;}
|
||||
body table tr th>:last-child, table tr td>:last-child{margin-bottom:0;}
|
||||
body img{max-width:100%;}
|
||||
body span.frame{display:block;overflow:hidden;}
|
||||
body span.frame>span{border:1px solid #ddd;display:block;float:left;overflow:hidden;margin:13px 0 0;padding:7px;width:auto;}
|
||||
body span.frame span img{display:block;float:left;}
|
||||
body span.frame span span{clear:both;color:#333;display:block;padding:5px 0 0;}
|
||||
body span.align-center{display:block;overflow:hidden;clear:both;}
|
||||
body span.align-center>span{display:block;overflow:hidden;margin:13px auto 0;text-align:center;}
|
||||
body span.align-center span img{margin:0 auto;text-align:center;}
|
||||
body span.align-right{display:block;overflow:hidden;clear:both;}
|
||||
body span.align-right>span{display:block;overflow:hidden;margin:13px 0 0;text-align:right;}
|
||||
body span.align-right span img{margin:0;text-align:right;}
|
||||
body span.float-left{display:block;margin-right:13px;overflow:hidden;float:left;}
|
||||
body span.float-left span{margin:13px 0 0;}
|
||||
body span.float-right{display:block;margin-left:13px;overflow:hidden;float:right;}
|
||||
body span.float-right>span{display:block;overflow:hidden;margin:13px auto 0;text-align:right;}
|
||||
body code, tt{margin:0 2px;padding:0 5px;white-space:nowrap;border:1px solid #eaeaea;background-color:#f8f8f8;border-radius:3px;}
|
||||
body pre>code{margin:0;padding:0;white-space:pre;border:none;background:transparent;}
|
||||
body .highlight pre, pre{background-color:#f8f8f8;border:1px solid #ccc;font-size:13px;line-height:19px;overflow:auto;padding:6px 10px;border-radius:3px;}
|
||||
body pre code, pre tt{background-color:transparent;border:none;}
|
||||
body {
|
||||
font-family: "Geneva", Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #09c;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #336699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0px 0px 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2 {
|
||||
border-bottom: 2px dotted #ccc;
|
||||
margin: 5px 0px 15px;
|
||||
}
|
||||
|
||||
h6 {
|
||||
color: #09c;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
font-family: "Georgia", Courier New, courier, sans-serif;
|
||||
background: #efefef;
|
||||
padding: 5px 10px;
|
||||
border: solid 1px #ddd;
|
||||
margin: 15px;
|
||||
-webkit-border-radius:6px;
|
||||
-moz-border-radius:6px;
|
||||
border-radius:6px;
|
||||
color: #333;
|
||||
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
li {
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
code {
|
||||
background-color: #f1f1f1;
|
||||
color: #336699;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
pre > code {
|
||||
margin: 0px;
|
||||
padding: 5px;
|
||||
border: 0px;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
|
||||
</style></head>
|
||||
<body>
|
||||
<h1>MPI/Examples : exMPI01</h1>
|
||||
@@ -202,11 +211,9 @@ body pre code, pre tt{background-color:transparent;border:none;}
|
||||
<ul>
|
||||
<li>Geometry : chamber / calorimeter</li>
|
||||
<li>Primary : particle gun (200 MeV electron as default)</li>
|
||||
<li>Physics List : standard EM</li>
|
||||
<li>Physics List : FTFP_BERT</li>
|
||||
</ul>
|
||||
|
||||
<p>The environment variable <em>G4LEDATA</em> for low energy EM data is required.</p>
|
||||
|
||||
<h3>Features:</h3>
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -9,9 +9,7 @@ A simple application
|
||||
|
||||
- Geometry : chamber / calorimeter
|
||||
- Primary : particle gun (200 MeV electron as default)
|
||||
- Physics List : standard EM
|
||||
|
||||
The environment variable *G4LEDATA* for low energy EM data is required.
|
||||
- Physics List : FTFP_BERT
|
||||
|
||||
### Features:
|
||||
|
||||
|
||||
@@ -23,30 +23,36 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file exMPI01.cc
|
||||
// $Id: exMPI01.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @brief A MPI example code
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
// my application
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PhysicsList.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
// MPI session
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
#include "G4MTRunManager.hh"
|
||||
#else
|
||||
#include "G4RunManager.hh"
|
||||
#endif
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "G4VisExecutive.hh"
|
||||
#endif
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "FTFP_BERT.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// random engine
|
||||
//CLHEP::HepJamesRandom randomEngine;
|
||||
CLHEP::Ranlux64Engine randomEngine;
|
||||
CLHEP::HepRandom::setTheEngine(&randomEngine);
|
||||
CLHEP::MTwistEngine randomEngine;
|
||||
G4Random::setTheEngine(&randomEngine);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// MPI session
|
||||
@@ -67,12 +73,17 @@ int main(int argc, char** argv)
|
||||
// --------------------------------------------------------------------
|
||||
// user application setting
|
||||
// --------------------------------------------------------------------
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MTRunManager* runManager = new G4MTRunManager();
|
||||
runManager-> SetNumberOfThreads(4);
|
||||
#else
|
||||
G4RunManager* runManager = new G4RunManager();
|
||||
#endif
|
||||
|
||||
// setup your application
|
||||
runManager-> SetUserInitialization(new DetectorConstruction);
|
||||
runManager-> SetUserInitialization(new PhysicsList);
|
||||
runManager-> SetUserAction(new PrimaryGeneratorAction);
|
||||
runManager-> SetUserInitialization(new FTFP_BERT);
|
||||
runManager-> SetUserInitialization(new ActionInitialization);
|
||||
|
||||
runManager-> Initialize();
|
||||
|
||||
@@ -100,5 +111,5 @@ int main(int argc, char** argv)
|
||||
|
||||
delete runManager;
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+13
-10
@@ -22,21 +22,24 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file Particles.hh
|
||||
/// @brief Define particles
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.hh 66587 2012-12-21 11:06:44Z ihrivnac $
|
||||
//
|
||||
/// @file PrimaryGeneratrorAction.hh
|
||||
/// @brief Define primary generator action
|
||||
|
||||
#ifndef PARTICLES_H
|
||||
#define PARTICLES_H
|
||||
#ifndef ACTION_INITIALIZATION_H
|
||||
#define ACTION_INITIALIZATION_H
|
||||
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
class Particles : public G4VPhysicsConstructor {
|
||||
class ActionInitialization : public G4VUserActionInitialization {
|
||||
public:
|
||||
Particles();
|
||||
~Particles();
|
||||
ActionInitialization();
|
||||
~ActionInitialization();
|
||||
|
||||
virtual void Build() const;
|
||||
|
||||
virtual void ConstructParticle();
|
||||
virtual void ConstructProcess();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -22,10 +22,12 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.hh 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file DetectorConstruction.hh
|
||||
/// @brief Define geometry
|
||||
|
||||
|
||||
#ifndef DETECTOR_CONSTRUCTION_H
|
||||
#define DETECTOR_CONSTRUCTION_H
|
||||
|
||||
@@ -34,9 +36,10 @@
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
virtual void ConstructSDandField();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Materials.hh 71843 2013-06-25 16:58:09Z gcosmo $
|
||||
//
|
||||
/// @file Materials.hh
|
||||
/// @brief Define materials
|
||||
|
||||
|
||||
@@ -22,12 +22,15 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.hh 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file PrimaryGeneratrorAction.hh
|
||||
/// @brief Define primary generator action
|
||||
|
||||
#ifndef PRIMARY_GENERATOR_ACTION_H
|
||||
#define PRIMARY_GENERATOR_ACTION_H
|
||||
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
@@ -40,7 +43,7 @@ public:
|
||||
virtual void GeneratePrimaries(G4Event* anEvent);
|
||||
|
||||
private:
|
||||
G4ParticleGun* particleGun;
|
||||
G4ParticleGun* fparticleGun;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/run/beamOn 40000
|
||||
/mpi/status
|
||||
|
||||
|
||||
+21
-14
@@ -22,21 +22,28 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file PhysicsList.hh
|
||||
/// @brief Define physics list
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc 66587 2012-12-21 11:06:44Z ihrivnac $
|
||||
//
|
||||
/// @file PrimaryGeneratrorAction.cc
|
||||
/// @brief Define primary generator action
|
||||
|
||||
#ifndef PHYSICS_LIST_H
|
||||
#define PHYSICS_LIST_H
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4VModularPhysicsList.hh"
|
||||
#include "globals.hh"
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
ActionInitialization::ActionInitialization()
|
||||
: G4VUserActionInitialization()
|
||||
{
|
||||
}
|
||||
|
||||
class PhysicsList: public G4VModularPhysicsList {
|
||||
public:
|
||||
PhysicsList();
|
||||
~PhysicsList();
|
||||
|
||||
virtual void SetCuts();
|
||||
};
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
ActionInitialization::~ActionInitialization()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
SetUserAction(new PrimaryGeneratorAction);
|
||||
}
|
||||
@@ -22,34 +22,33 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file DetectorConstruction.cc
|
||||
/// @brief Define geometry
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "Materials.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "Materials.hh"
|
||||
|
||||
// constants (detector parameters)
|
||||
static const G4double DXYZ_AREA= 32.*cm;
|
||||
static const G4double DW= 10.*cm;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
// material definition
|
||||
@@ -60,18 +59,19 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
G4VisAttributes* va;
|
||||
|
||||
// world volume
|
||||
G4Box* areaSolid = new G4Box("AREA",
|
||||
DXYZ_AREA/2., DXYZ_AREA/2., DXYZ_AREA/2.);
|
||||
const G4double DXYZ_AREA = 32.*cm;
|
||||
G4Box* areaSolid = new G4Box("AREA", DXYZ_AREA/2., DXYZ_AREA/2.,
|
||||
DXYZ_AREA/2.);
|
||||
|
||||
G4Material* vacuum = G4Material::GetMaterial("Vacuum");
|
||||
G4Material* vacuum = G4Material::GetMaterial("Vacuum");
|
||||
G4LogicalVolume* areaLV = new G4LogicalVolume(areaSolid, vacuum, "AREA_LV");
|
||||
G4PVPlacement* area = new G4PVPlacement(0, G4ThreeVector(), "AREA_PV",
|
||||
G4PVPlacement* area = new G4PVPlacement(0, G4ThreeVector(), "AREA_PV",
|
||||
areaLV, 0, false, 0);
|
||||
// vis. attributes
|
||||
va = new G4VisAttributes(G4Color(1.,1.,1.));
|
||||
va-> SetVisibility(false);
|
||||
areaLV-> SetVisAttributes(va);
|
||||
|
||||
|
||||
// detectors
|
||||
// voxel
|
||||
const G4double dvoxel = 10.*mm;
|
||||
@@ -86,8 +86,8 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
|
||||
G4int ix, iz;
|
||||
G4int index = 0;
|
||||
for (iz = 0; iz < 5; iz++) {
|
||||
for (ix = -7; ix <= 7; ix++) {
|
||||
for ( iz = 0; iz < 5; iz++ ) {
|
||||
for ( ix = -7; ix <= 7; ix++ ) {
|
||||
G4double x0 = (2.*ix) * cm;
|
||||
G4double z0 = (-13.+2.*iz) * cm;
|
||||
new G4PVPlacement(0, G4ThreeVector(x0, 0., z0),
|
||||
@@ -97,8 +97,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
}
|
||||
|
||||
// tube
|
||||
G4Tubs* stube = new G4Tubs("tube", 0.*mm, 19./2.*mm, dl,
|
||||
0., 360.*deg);
|
||||
G4Tubs* stube = new G4Tubs("tube", 0.*mm, 19./2.*mm, dl, 0., 360.*deg);
|
||||
mate = G4Material::GetMaterial("Al");
|
||||
G4LogicalVolume* ltube = new G4LogicalVolume(stube, mate, "tube");
|
||||
va = new G4VisAttributes(G4Color(0.,0.8,0.8));
|
||||
@@ -108,7 +107,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
rmtube-> rotateX(-90.*deg);
|
||||
new G4PVPlacement(rmtube, G4ThreeVector(),
|
||||
ltube, "tube", lvoxel, false, 0);
|
||||
|
||||
|
||||
// cal
|
||||
const G4double dxycal = 25.*mm;
|
||||
const G4double dzcal = 3.*cm;
|
||||
@@ -120,7 +119,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
lcal-> SetVisAttributes(va);
|
||||
|
||||
index = 0;
|
||||
for (ix = -2; ix <= 2; ix++) {
|
||||
for ( ix = -2; ix <= 2; ix++ ) {
|
||||
G4double x0 = (5.*ix)*cm;
|
||||
new G4PVPlacement(0, G4ThreeVector(x0, 0., 2.*cm),
|
||||
lcal, "cal", areaLV, false, index);
|
||||
@@ -129,3 +128,8 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,25 +22,28 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Materials.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file Materials.cc
|
||||
/// @brief Define materials
|
||||
|
||||
#include "Materials.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Materials.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Materials::Materials()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Materials::~Materials()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Materials::Construct()
|
||||
{
|
||||
G4double A, Z;
|
||||
@@ -57,7 +60,7 @@ void Materials::Construct()
|
||||
G4Element* elAr = new G4Element("Argon", "Ar", Z=18., A= 39.948*g/mole);
|
||||
G4Element* elI = new G4Element("Iodine", "I", Z=53., A= 126.90447*g/mole);
|
||||
G4Element* elCs = new G4Element("Cesium", "Cs", Z=55., A= 132.90543*g/mole);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Materials
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -65,7 +68,7 @@ void Materials::Construct()
|
||||
G4int natoms, nel;
|
||||
|
||||
// temperature of experimental hall is controlled at 20 degree.
|
||||
const G4double expTemp = STP_Temperature+20.*kelvin;
|
||||
const G4double expTemp = STP_Temperature+20.*kelvin;
|
||||
|
||||
// vacuum
|
||||
density = universe_mean_density;
|
||||
@@ -75,7 +78,7 @@ void Materials::Construct()
|
||||
|
||||
// air
|
||||
density = 1.2929e-03 *g/cm3; // at 20 degree
|
||||
G4Material* Air = new G4Material("Air", density, nel=3,
|
||||
G4Material* Air = new G4Material("Air", density, nel=3,
|
||||
kStateGas, expTemp);
|
||||
G4double ttt = 75.47+23.20+1.28;
|
||||
Air-> AddElement(elN, massfraction= 75.47/ttt);
|
||||
@@ -98,7 +101,7 @@ void Materials::Construct()
|
||||
// Ar(50%) + ethane(50%) mixture
|
||||
density = (denAr+denEthane)/2.;
|
||||
G4Material* ArEthane = new G4Material("ArEthane", density, nel=2,
|
||||
kStateGas, expTemp);
|
||||
kStateGas, expTemp);
|
||||
ArEthane-> AddMaterial(Ar, massfraction= denAr/density/2.);
|
||||
ArEthane-> AddMaterial(Ethane, massfraction= denEthane/density/2.);
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file Particles.cc
|
||||
/// @brief Define particles
|
||||
|
||||
#include "Particles.hh"
|
||||
|
||||
#include "G4LeptonConstructor.hh"
|
||||
#include "G4BosonConstructor.hh"
|
||||
#include "G4MesonConstructor.hh"
|
||||
#include "G4BaryonConstructor.hh"
|
||||
#include "G4ShortLivedConstructor.hh"
|
||||
#include "G4IonConstructor.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
Particles::Particles()
|
||||
: G4VPhysicsConstructor("Particles")
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
Particles::~Particles()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void Particles::ConstructParticle()
|
||||
{
|
||||
G4LeptonConstructor::ConstructParticle();
|
||||
G4BosonConstructor::ConstructParticle();
|
||||
G4MesonConstructor::ConstructParticle();
|
||||
G4BaryonConstructor::ConstructParticle();
|
||||
G4ShortLivedConstructor::ConstructParticle();
|
||||
G4IonConstructor::ConstructParticle();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void Particles::ConstructProcess()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file PhysicsListEMstd.cc
|
||||
/// @brief Define standard EM physics list
|
||||
|
||||
#include "PhysicsListEMstd.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
#include "G4Gamma.hh"
|
||||
#include "G4Electron.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4NeutrinoE.hh"
|
||||
#include "G4AntiNeutrinoE.hh"
|
||||
|
||||
#include "G4ComptonScattering.hh"
|
||||
#include "G4GammaConversion.hh"
|
||||
#include "G4PhotoElectricEffect.hh"
|
||||
#include "G4eMultipleScattering.hh"
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
PhysicsListEMstd::PhysicsListEMstd()
|
||||
: G4VPhysicsConstructor("EM-std")
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
PhysicsListEMstd::~PhysicsListEMstd()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void PhysicsListEMstd::ConstructParticle()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void PhysicsListEMstd::ConstructProcess()
|
||||
{
|
||||
G4ProcessManager* pm;
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// gamma physics
|
||||
// ----------------------------------------------------------
|
||||
pm = G4Gamma::Gamma()-> GetProcessManager();
|
||||
pm-> AddDiscreteProcess(new G4PhotoElectricEffect);
|
||||
pm-> AddDiscreteProcess(new G4ComptonScattering);
|
||||
pm-> AddDiscreteProcess(new G4GammaConversion);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// electron physics
|
||||
// ----------------------------------------------------------
|
||||
G4eMultipleScattering* msc = new G4eMultipleScattering;
|
||||
G4eIonisation* eion = new G4eIonisation;
|
||||
G4eBremsstrahlung* ebrems = new G4eBremsstrahlung;
|
||||
|
||||
pm = G4Electron::Electron()->GetProcessManager();
|
||||
pm-> AddProcess(msc, ordInActive, 1, 1);
|
||||
pm-> AddProcess(eion, ordInActive, 2, 2);
|
||||
pm-> AddProcess(ebrems, ordInActive, ordInActive, 3);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// positron physics
|
||||
// ----------------------------------------------------------
|
||||
msc = new G4eMultipleScattering;
|
||||
eion = new G4eIonisation;
|
||||
ebrems = new G4eBremsstrahlung;
|
||||
G4eplusAnnihilation* annihilation= new G4eplusAnnihilation;
|
||||
|
||||
pm = G4Positron::Positron()-> GetProcessManager();
|
||||
pm-> AddProcess(msc, ordInActive, 1, 1);
|
||||
pm-> AddProcess(eion, ordInActive, 2, 2);
|
||||
pm-> AddProcess(ebrems, ordInActive, ordInActive, 3);
|
||||
pm-> AddProcess(annihilation, 0, ordInActive, 4);
|
||||
}
|
||||
@@ -22,37 +22,40 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file PrimaryGeneratrorAction.cc
|
||||
/// @brief Define primary generator action
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
{
|
||||
particleGun = new G4ParticleGun;
|
||||
fparticleGun = new G4ParticleGun;
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* particle = particleTable-> FindParticle("e-");
|
||||
|
||||
particleGun-> SetParticleDefinition(particle);
|
||||
particleGun-> SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
particleGun->SetParticlePosition(G4ThreeVector(0.,0.,-14.9*cm));
|
||||
particleGun-> SetParticleEnergy(200.*MeV);
|
||||
fparticleGun-> SetParticleDefinition(particle);
|
||||
fparticleGun-> SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
fparticleGun->SetParticlePosition(G4ThreeVector(0.,0.,-14.9*cm));
|
||||
fparticleGun-> SetParticleEnergy(200.*MeV);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
delete fparticleGun;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
particleGun-> GeneratePrimaryVertex(anEvent);
|
||||
fparticleGun-> GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,11 @@ project(exMPI02)
|
||||
#------------------------------------------------------------------------------
|
||||
# check MPI package...
|
||||
find_package(MPI REQUIRED)
|
||||
# modify these var. if needed
|
||||
|
||||
# modify these variables if needed
|
||||
set(CMAKE_CXX_COMPILER mpicxx)
|
||||
#set(CMAKE_CXX_COMPILER mpiicpc)
|
||||
|
||||
#set(CMAKE_CXX_INCLUDE_PATH )
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
@@ -37,7 +40,7 @@ include(${Geant4_USE_FILE})
|
||||
#
|
||||
find_package(ROOT QUIET)
|
||||
if(NOT ROOT_FOUND)
|
||||
message(STATUS "G4 Examples: ROOT package not found. --> exMPI02 example disabled")
|
||||
message(STATUS "G4 Examples: ROOT package not found. --> exMPI02 example disabled")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -60,7 +63,7 @@ file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
|
||||
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
|
||||
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${Geant4_INCLUDE_DIR}
|
||||
${ROOT_INCLUDE_DIR})
|
||||
|
||||
@@ -81,6 +84,7 @@ set_target_properties(exMPI02
|
||||
# relies on these scripts being in the current working directory.
|
||||
#
|
||||
set(exMPI02_SCRIPTS
|
||||
run.mac
|
||||
v.mac
|
||||
)
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
$Id: History,v 1.3 2010-06-06 05:07:23 perl Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
exMPI02 History
|
||||
---------------
|
||||
|
||||
27 October 2012 K. Murakami
|
||||
- migrated to CMake build
|
||||
- Physis list is changed to FTFP_BERT
|
||||
- updated documentations
|
||||
|
||||
4 June 2010 J.Perl
|
||||
- Updated vis usage.
|
||||
|
||||
18 May 2010 K.Murakami
|
||||
- use G4UIcsh instead of G4UItcsh because OpenMPI is now default.
|
||||
|
||||
16 Nov. 2007 K.Murakami
|
||||
- commited to G4 CVS.
|
||||
|
||||
@@ -23,32 +23,31 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file exMPI02.cc
|
||||
// $Id: exMPI02.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @brief A MPI example code
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
// my application
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "MedicalBeam.hh"
|
||||
#include "FTFP_BERT.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
|
||||
// MPI session
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
#include "G4MTRunManager.hh"
|
||||
#else
|
||||
#include "G4RunManager.hh"
|
||||
#endif
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "G4VisExecutive.hh"
|
||||
#endif
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "FTFP_BERT.hh"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// random engine
|
||||
//CLHEP::Ranlux64Engine randomEngine;
|
||||
//CLHEP::HepRandom::setTheEngine(&randomEngine);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// MPI session
|
||||
// --------------------------------------------------------------------
|
||||
@@ -68,14 +67,17 @@ int main(int argc, char** argv)
|
||||
// --------------------------------------------------------------------
|
||||
// user application setting
|
||||
// --------------------------------------------------------------------
|
||||
G4RunManager* runManager= new G4RunManager();
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MTRunManager* runManager = new G4MTRunManager();
|
||||
runManager-> SetNumberOfThreads(4);
|
||||
#else
|
||||
G4RunManager* runManager = new G4RunManager();
|
||||
#endif
|
||||
|
||||
// setup your application
|
||||
runManager-> SetUserInitialization(new DetectorConstruction);
|
||||
runManager-> SetUserInitialization(new FTFP_BERT);
|
||||
runManager-> SetUserAction(new MedicalBeam);
|
||||
runManager-> SetUserAction(new RunAction);
|
||||
runManager-> SetUserAction(new EventAction);
|
||||
runManager-> SetUserInitialization(new ActionInitialization);
|
||||
|
||||
runManager-> Initialize();
|
||||
|
||||
@@ -92,8 +94,9 @@ int main(int argc, char** argv)
|
||||
// --------------------------------------------------------------------
|
||||
session-> SessionStart();
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// termination
|
||||
// --------------------------------------------------------------------
|
||||
#ifdef G4VIS_USE
|
||||
delete visManager;
|
||||
#endif
|
||||
@@ -102,5 +105,5 @@ int main(int argc, char** argv)
|
||||
|
||||
delete runManager;
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+13
-10
@@ -22,21 +22,24 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file PhysicsListEMstd.hh
|
||||
/// @brief Define standard EM physics list
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.hh 66587 2012-12-21 11:06:44Z ihrivnac $
|
||||
//
|
||||
/// @file PrimaryGeneratrorAction.hh
|
||||
/// @brief Define primary generator action
|
||||
|
||||
#ifndef PHYSICS_LIST_EM_STD_H
|
||||
#define PHYSICS_LIST_EM_STD_H
|
||||
#ifndef ACTION_INITIALIZATION_H
|
||||
#define ACTION_INITIALIZATION_H
|
||||
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
class PhysicsListEMstd : public G4VPhysicsConstructor {
|
||||
class ActionInitialization : public G4VUserActionInitialization {
|
||||
public:
|
||||
PhysicsListEMstd();
|
||||
~PhysicsListEMstd();
|
||||
ActionInitialization();
|
||||
~ActionInitialization();
|
||||
|
||||
virtual void ConstructParticle();
|
||||
virtual void ConstructProcess();
|
||||
virtual void BuildForMaster() const;
|
||||
virtual void Build() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Analysis.hh 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file Analysis.hh
|
||||
/// @brief Define histograms
|
||||
|
||||
@@ -30,6 +33,10 @@
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
class TH1D;
|
||||
class TH2D;
|
||||
|
||||
@@ -49,21 +56,22 @@ public:
|
||||
void ClearIncidentFlag();
|
||||
|
||||
private:
|
||||
static Analysis* myanalysis;
|
||||
Analysis();
|
||||
DISALLOW_COPY_AND_ASSIGN(Analysis);
|
||||
|
||||
TH2D* incident_map;
|
||||
TH1D* incident_x_hist;
|
||||
TH2D* fincident_map;
|
||||
TH1D* fincident_x_hist;
|
||||
|
||||
TH2D* dose_map;
|
||||
TH1D* dose_hist;
|
||||
TH2D* fdose_map;
|
||||
TH1D* fdose_hist;
|
||||
|
||||
Analysis(); // protected
|
||||
|
||||
G4bool incidentFlag;
|
||||
static G4ThreadLocal G4int fincidentFlag;
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
inline void Analysis::ClearIncidentFlag()
|
||||
{ incidentFlag= false; }
|
||||
{
|
||||
fincidentFlag = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.hh 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file DetectorConstruction.hh
|
||||
/// @brief Define geometry
|
||||
|
||||
@@ -30,12 +33,19 @@
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
class G4LogicalVolume;
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
virtual void ConstructSDandField();
|
||||
|
||||
private:
|
||||
G4LogicalVolume* flv_voxel;
|
||||
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventAction.hh 71843 2013-06-25 16:58:09Z gcosmo $
|
||||
//
|
||||
/// @file EventAction.hh
|
||||
/// @brief Describe event actions
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: MedicalBeam.hh 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file MedicalBeam.hh
|
||||
/// @brief Define beam profile as primary generator
|
||||
|
||||
@@ -36,7 +39,7 @@ class G4ParticleDefinition;
|
||||
|
||||
class MedicalBeam : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
enum FieldShape{ SQUARE=0, CIRCLE };
|
||||
enum FieldShape{ kSQUARE=0, kCIRCLE };
|
||||
|
||||
MedicalBeam();
|
||||
~MedicalBeam();
|
||||
@@ -60,72 +63,103 @@ public:
|
||||
void SetFieldXY(G4double fx, G4double fy);
|
||||
G4double GetFieldX() const;
|
||||
G4double GetFieldY() const;
|
||||
|
||||
|
||||
void SetFieldR(G4double r);
|
||||
G4double GetFieldR() const;
|
||||
|
||||
// methods...
|
||||
virtual void GeneratePrimaries(G4Event* anEvent);
|
||||
|
||||
protected:
|
||||
G4ParticleDefinition* particle;
|
||||
G4double kineticE;
|
||||
G4ThreeVector sourcePosition;
|
||||
|
||||
G4double SSD; // (SSD= Source Skin Depth)
|
||||
FieldShape fieldShape;
|
||||
G4double fieldXY[2];
|
||||
G4double fieldR;
|
||||
|
||||
private:
|
||||
// local methods...
|
||||
G4ThreeVector GenerateBeamDirection() const;
|
||||
|
||||
G4ParticleDefinition* fparticle;
|
||||
G4double fkineticE;
|
||||
G4ThreeVector fsourcePosition;
|
||||
|
||||
G4double fSSD; // (SSD= Source Skin Depth)
|
||||
FieldShape ffieldShape;
|
||||
G4double ffieldXY[2];
|
||||
G4double ffieldR;
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
inline void MedicalBeam::SetParticleDefinition(G4ParticleDefinition* pd)
|
||||
{ particle= pd; }
|
||||
{
|
||||
fparticle = pd;
|
||||
}
|
||||
|
||||
inline const G4ParticleDefinition* MedicalBeam::GetParticleDefinition() const
|
||||
{ return particle; }
|
||||
{
|
||||
return fparticle;
|
||||
}
|
||||
|
||||
inline void MedicalBeam::SetKineticE(G4double e)
|
||||
{ kineticE= e; }
|
||||
{
|
||||
fkineticE = e;
|
||||
}
|
||||
|
||||
inline G4double MedicalBeam::GetKineticE() const
|
||||
{ return kineticE; }
|
||||
{
|
||||
return fkineticE;
|
||||
}
|
||||
|
||||
inline void MedicalBeam::SetSourcePosition(const G4ThreeVector& pos)
|
||||
{ sourcePosition= pos; }
|
||||
{
|
||||
fsourcePosition = pos;
|
||||
}
|
||||
|
||||
inline G4ThreeVector MedicalBeam::GetSourcePosition() const
|
||||
{ return sourcePosition; }
|
||||
{
|
||||
return fsourcePosition;
|
||||
}
|
||||
|
||||
inline void MedicalBeam::SetFieldShape(MedicalBeam::FieldShape shape)
|
||||
{ fieldShape= shape; }
|
||||
{
|
||||
ffieldShape = shape;
|
||||
}
|
||||
|
||||
inline MedicalBeam::FieldShape MedicalBeam::GetFieldShape() const
|
||||
{ return fieldShape; }
|
||||
{
|
||||
return ffieldShape;
|
||||
}
|
||||
|
||||
inline void MedicalBeam::SetSSD(G4double ssd)
|
||||
{ SSD= ssd; }
|
||||
{
|
||||
fSSD = ssd;
|
||||
}
|
||||
|
||||
inline G4double MedicalBeam::GetSSD() const
|
||||
{ return SSD; }
|
||||
{
|
||||
return fSSD;
|
||||
}
|
||||
|
||||
inline void MedicalBeam::SetFieldXY(G4double fx, G4double fy)
|
||||
{ fieldXY[0]= fx; fieldXY[1]= fy; }
|
||||
{
|
||||
ffieldXY[0] = fx;
|
||||
ffieldXY[1] = fy;
|
||||
}
|
||||
|
||||
inline G4double MedicalBeam::GetFieldX() const
|
||||
{ return fieldXY[0]; }
|
||||
{
|
||||
return ffieldXY[0];
|
||||
}
|
||||
|
||||
inline G4double MedicalBeam::GetFieldY() const
|
||||
{ return fieldXY[1]; }
|
||||
{
|
||||
return ffieldXY[1];
|
||||
}
|
||||
|
||||
inline void MedicalBeam::SetFieldR(G4double r)
|
||||
{ fieldR= r; }
|
||||
{
|
||||
ffieldR = r;
|
||||
}
|
||||
|
||||
inline G4double MedicalBeam::GetFieldR() const
|
||||
{ return fieldR; }
|
||||
{
|
||||
return ffieldR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.hh 71843 2013-06-25 16:58:09Z gcosmo $
|
||||
//
|
||||
/// @file RunAction.hh
|
||||
/// @brief Describe run actions
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelParam.hh 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file VoxelParam.hh
|
||||
/// @brief Define voxel parameterization
|
||||
|
||||
@@ -40,7 +43,7 @@ public:
|
||||
|
||||
virtual void ComputeDimensions(G4Box& box, const G4int id,
|
||||
const G4VPhysicalVolume* vol) const;
|
||||
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Trd&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
@@ -52,26 +55,28 @@ public:
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Sphere&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Orb&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Torus&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
(G4Ellipsoid&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Torus&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Para&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Hype&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Tubs&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Polycone&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Polyhedra&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelSD.hh 71843 2013-06-25 16:58:09Z gcosmo $
|
||||
//
|
||||
/// @file VoxelSD.hh
|
||||
/// @brief Define detector sensitivity on voxels
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/run/beamOn 40000
|
||||
/mpi/status
|
||||
|
||||
|
||||
+28
-26
@@ -22,36 +22,38 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
/// @file PhysicsList.cc
|
||||
/// @brief Define physics list
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc 66587 2012-12-21 11:06:44Z ihrivnac $
|
||||
//
|
||||
/// @file PrimaryGeneratrorAction.cc
|
||||
/// @brief Define primary generator action
|
||||
|
||||
#include "PhysicsList.hh"
|
||||
#include "Particles.hh"
|
||||
#include "PhysicsListEMstd.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "MedicalBeam.hh"
|
||||
#include "RunAction.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
PhysicsList::PhysicsList()
|
||||
: G4VModularPhysicsList()
|
||||
{
|
||||
// default cut value (1.0mm)
|
||||
defaultCutValue = 1.*mm;
|
||||
SetVerboseLevel(1);
|
||||
|
||||
// particles
|
||||
RegisterPhysics(new Particles);
|
||||
|
||||
// EM Physics
|
||||
RegisterPhysics(new PhysicsListEMstd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
PhysicsList::~PhysicsList()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
ActionInitialization::ActionInitialization()
|
||||
: G4VUserActionInitialization()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void PhysicsList::SetCuts()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
ActionInitialization::~ActionInitialization()
|
||||
{
|
||||
SetCutsWithDefault();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
SetUserAction(new RunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
SetUserAction(new MedicalBeam);
|
||||
SetUserAction(new EventAction);
|
||||
SetUserAction(new RunAction);
|
||||
}
|
||||
@@ -22,100 +22,92 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Analysis.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file Analysis.cc
|
||||
/// @brief Define histograms
|
||||
|
||||
#include "Analysis.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
// ROOT headers
|
||||
#include "TROOT.h"
|
||||
#include "TFile.h"
|
||||
#include "TH1.h"
|
||||
#include "TH2.h"
|
||||
#include "TROOT.h"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Analysis.hh"
|
||||
|
||||
Analysis* Analysis::myanalysis = NULL;
|
||||
G4ThreadLocal G4int Analysis::fincidentFlag = false;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
Analysis::Analysis()
|
||||
{
|
||||
// ROOT style
|
||||
gROOT-> Reset();
|
||||
|
||||
// define histograms
|
||||
incident_map = new TH2D("incident map", "Incident Distributuon",
|
||||
50, -5., 5.,
|
||||
50, -5., 5.);
|
||||
incident_map-> GetXaxis()-> SetTitle("X (cm)");
|
||||
incident_map-> GetYaxis()-> SetTitle("Y (cm)");
|
||||
incident_map-> SetStats(0);
|
||||
|
||||
incident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
|
||||
incident_x_hist-> GetXaxis()-> SetTitle("X (cm)");
|
||||
incident_x_hist-> SetFillColor(kRed);
|
||||
|
||||
dose_map = new TH2D("dose map", "Dose Distribution",
|
||||
500, 0., 50.,
|
||||
200, -10., 10.);
|
||||
dose_map-> GetXaxis()-> SetTitle("Z (cm)");
|
||||
dose_map-> GetYaxis()-> SetTitle("X (cm)");
|
||||
dose_map-> SetStats(0);
|
||||
|
||||
dose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
|
||||
dose_hist-> GetXaxis()-> SetTitle("Z (cm)");
|
||||
dose_hist-> GetYaxis()-> SetTitle("Dose (GeV)");
|
||||
dose_hist-> SetFillColor(kBlue);
|
||||
dose_hist-> SetStats(0);
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
Analysis::~Analysis()
|
||||
{
|
||||
delete incident_map;
|
||||
delete incident_x_hist;
|
||||
delete dose_map;
|
||||
delete dose_hist;
|
||||
|
||||
myanalysis = NULL;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Analysis* Analysis::GetAnalysis()
|
||||
{
|
||||
if ( myanalysis == NULL ) {
|
||||
myanalysis = new Analysis();
|
||||
}
|
||||
|
||||
return myanalysis;
|
||||
static Analysis the_analysis;
|
||||
return &the_analysis;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Analysis::Analysis()
|
||||
{
|
||||
// define histograms
|
||||
fincident_map = new TH2D("incident map", "Incident Distributuon",
|
||||
50, -5., 5.,
|
||||
50, -5., 5.);
|
||||
fincident_map-> GetXaxis()-> SetTitle("X (cm)");
|
||||
fincident_map-> GetYaxis()-> SetTitle("Y (cm)");
|
||||
fincident_map-> SetStats(0);
|
||||
|
||||
fincident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
|
||||
fincident_x_hist-> GetXaxis()-> SetTitle("X (cm)");
|
||||
fincident_x_hist-> SetFillColor(kRed);
|
||||
|
||||
fdose_map = new TH2D("dose map", "Dose Distribution",
|
||||
500, 0., 50.,
|
||||
200, -10., 10.);
|
||||
fdose_map-> GetXaxis()-> SetTitle("Z (cm)");
|
||||
fdose_map-> GetYaxis()-> SetTitle("X (cm)");
|
||||
fdose_map-> SetStats(0);
|
||||
|
||||
fdose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
|
||||
fdose_hist-> GetXaxis()-> SetTitle("Z (cm)");
|
||||
fdose_hist-> GetYaxis()-> SetTitle("Dose (GeV)");
|
||||
fdose_hist-> SetFillColor(kBlue);
|
||||
fdose_hist-> SetStats(0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Analysis::~Analysis()
|
||||
{
|
||||
delete fincident_map;
|
||||
delete fincident_x_hist;
|
||||
delete fdose_map;
|
||||
delete fdose_hist;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::Update()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::Clear()
|
||||
{
|
||||
incident_map-> Reset();
|
||||
incident_x_hist-> Reset();
|
||||
dose_map-> Reset();
|
||||
dose_hist-> Reset();
|
||||
fincident_map-> Reset();
|
||||
fincident_x_hist-> Reset();
|
||||
fdose_map-> Reset();
|
||||
fdose_hist-> Reset();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::Save(const G4String& fname)
|
||||
{
|
||||
TFile* file = new TFile(fname.c_str(),
|
||||
"RECREATE", "Geant4 ROOT analysis");
|
||||
incident_map-> Write();
|
||||
incident_x_hist-> Write();
|
||||
dose_map-> Write();
|
||||
dose_hist-> Write();
|
||||
TFile* file = new TFile(fname.c_str(), "RECREATE", "Geant4 ROOT analysis");
|
||||
|
||||
fincident_map-> Write();
|
||||
fincident_x_hist-> Write();
|
||||
fdose_map-> Write();
|
||||
fdose_hist-> Write();
|
||||
|
||||
file-> Close();
|
||||
|
||||
@@ -124,29 +116,28 @@ void Analysis::Save(const G4String& fname)
|
||||
return;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::FillIncident(const G4ThreeVector& p)
|
||||
{
|
||||
if ( ! incidentFlag ) {
|
||||
incident_map-> Fill(p.x()/cm, p.y()/cm);
|
||||
incident_x_hist-> Fill(p.x()/cm);
|
||||
if ( ! fincidentFlag ) {
|
||||
fincident_map-> Fill(p.x()/cm, p.y()/cm);
|
||||
fincident_x_hist-> Fill(p.x()/cm);
|
||||
|
||||
incidentFlag = true;
|
||||
fincidentFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::FillDose(const G4ThreeVector& p, G4double dedx)
|
||||
{
|
||||
const G4double Z0 = 25.*cm;
|
||||
const G4double dxy = 10.*mm;
|
||||
|
||||
if(std::abs(p.y()) < dxy ) {
|
||||
dose_map-> Fill((p.z()+Z0)/cm, p.x()/cm, dedx/GeV);
|
||||
|
||||
if(std::abs(p.x()) < dxy) {
|
||||
dose_hist-> Fill((p.z()+Z0)/cm, dedx/GeV);
|
||||
if ( std::abs(p.y()) < dxy ) {
|
||||
fdose_map-> Fill((p.z()+Z0)/cm, p.x()/cm, dedx/GeV);
|
||||
|
||||
if ( std::abs(p.x()) < dxy ) {
|
||||
fdose_hist-> Fill((p.z()+Z0)/cm, dedx/GeV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,35 +22,39 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file DetectorConstruction.hh
|
||||
/// @brief Define geometry
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "VoxelParam.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "VoxelSD.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "VoxelParam.hh"
|
||||
#include "VoxelSD.hh"
|
||||
|
||||
typedef G4LogicalVolume G4LV;
|
||||
typedef G4PVPlacement G4PVP;
|
||||
typedef G4VisAttributes G4VA;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
: flv_voxel(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
G4NistManager* nistManager = G4NistManager::Instance();
|
||||
@@ -58,32 +62,32 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
|
||||
// world volume
|
||||
const G4double DXYZ_WORLD = 200.*cm;
|
||||
G4Box* sld_world = new G4Box("world",
|
||||
G4Box* sld_world = new G4Box("world",
|
||||
DXYZ_WORLD/2., DXYZ_WORLD/2., DXYZ_WORLD/2.);
|
||||
|
||||
G4Material* vacuum = nistManager-> FindOrBuildMaterial("G4_Galactic");
|
||||
G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
|
||||
G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA",
|
||||
G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA",
|
||||
lv_world, 0, false, 0);
|
||||
// vis. attributes
|
||||
va = new G4VA(G4Color(1.,1.,1.));
|
||||
va-> SetVisibility(false);
|
||||
lv_world-> SetVisAttributes(va);
|
||||
|
||||
|
||||
// water phantom
|
||||
const G4double DXY_PHANTOM = 20.*cm;
|
||||
const G4double DZ_PHANTOM = 50.*cm;
|
||||
|
||||
G4Box* sld_phantom = new G4Box("phantom",
|
||||
G4Box* sld_phantom = new G4Box("phantom",
|
||||
DXY_PHANTOM/2., DXY_PHANTOM/2., DZ_PHANTOM/2.);
|
||||
|
||||
G4Material* water = nistManager-> FindOrBuildMaterial("G4_WATER");
|
||||
G4LV* lv_phantom = new G4LogicalVolume(sld_phantom,
|
||||
G4LV* lv_phantom = new G4LogicalVolume(sld_phantom,
|
||||
water, "phantom");
|
||||
|
||||
va = new G4VA(G4Color(0.,1.,1.));
|
||||
lv_phantom-> SetVisAttributes(va);
|
||||
|
||||
|
||||
new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
|
||||
|
||||
// voxel planes
|
||||
@@ -99,23 +103,27 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
|
||||
for (G4int iz =0; iz < 500; iz++) {
|
||||
G4double z0 = -DZ_PHANTOM/2. + (iz+0.5)*DZ_VXP;
|
||||
new G4PVP(0, G4ThreeVector(0.,0.,z0),
|
||||
lv_vxp, "vxplane", lv_phantom,
|
||||
false, 1000+iz);
|
||||
new G4PVP(0, G4ThreeVector(0.,0.,z0),
|
||||
lv_vxp, "vxplane", lv_phantom, false, 1000+iz);
|
||||
}
|
||||
|
||||
// voxel parameterized
|
||||
G4Box* sld_voxel = new G4Box("voxel",1.,1.,1.); // dummy
|
||||
G4LV* lv_voxel = new G4LV(sld_voxel, water, "voxel");
|
||||
lv_voxel-> SetSensitiveDetector(new VoxelSD("voxel"));
|
||||
flv_voxel = new G4LV(sld_voxel, water, "voxel");
|
||||
|
||||
va = new G4VA(G4Color(0.,1.,1.));
|
||||
va-> SetVisibility(false);
|
||||
lv_voxel-> SetVisAttributes(va);
|
||||
flv_voxel-> SetVisAttributes(va);
|
||||
|
||||
const G4int nvoxels = 100*100;
|
||||
new G4PVParameterised("voxle", lv_voxel, lv_vxp,
|
||||
kUndefined, nvoxels, new VoxelParam());
|
||||
new G4PVParameterised("voxle", flv_voxel, lv_vxp, kUndefined, nvoxels,
|
||||
new VoxelParam());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
flv_voxel-> SetSensitiveDetector(new VoxelSD("voxel"));
|
||||
}
|
||||
|
||||
@@ -22,31 +22,34 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventAction.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file EventAction.cc
|
||||
/// @brief Describe event actions
|
||||
|
||||
#include "EventAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "Analysis.hh"
|
||||
#include "EventAction.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
EventAction::EventAction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
EventAction::~EventAction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void EventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
Analysis* myana = Analysis::GetAnalysis();
|
||||
myana-> ClearIncidentFlag();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,51 +22,52 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: MedicalBeam.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file MedicalBeam.cc
|
||||
/// @brief Define beam profile as primary generator
|
||||
|
||||
#include "MedicalBeam.hh"
|
||||
#include "Randomize.hh"
|
||||
#include <cmath>
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PrimaryVertex.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "MedicalBeam.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
MedicalBeam::MedicalBeam()
|
||||
: particle(0), kineticE(1.*MeV), sourcePosition(G4ThreeVector()),
|
||||
SSD(1.*m), fieldShape(MedicalBeam::SQUARE), fieldR(10.*cm)
|
||||
: fparticle(0), fkineticE(1.*MeV), fsourcePosition(G4ThreeVector()),
|
||||
fSSD(1.*m), ffieldShape(MedicalBeam::kSQUARE), ffieldR(10.*cm)
|
||||
{
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
particle = particleTable-> FindParticle("proton");
|
||||
fparticle = particleTable-> FindParticle("proton");
|
||||
|
||||
kineticE = 200.*MeV;
|
||||
sourcePosition = G4ThreeVector(0.,0.,-125.*cm);
|
||||
SSD = 100.*cm;
|
||||
fieldXY[0] = fieldXY[1] = 5.*cm;
|
||||
fkineticE = 200.*MeV;
|
||||
fsourcePosition = G4ThreeVector(0.,0.,-125.*cm);
|
||||
fSSD = 100.*cm;
|
||||
ffieldXY[0] = ffieldXY[1] = 5.*cm;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
MedicalBeam::~MedicalBeam()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4ThreeVector MedicalBeam::GenerateBeamDirection() const
|
||||
{
|
||||
// uniform distribution in a limitted solid angle
|
||||
G4double dr;
|
||||
if ( fieldShape == MedicalBeam::SQUARE ) {
|
||||
dr = std::sqrt(sqr(fieldXY[0]/2.) + sqr(fieldXY[1]/2.));
|
||||
if ( ffieldShape == MedicalBeam::kSQUARE ) {
|
||||
dr = std::sqrt(sqr(ffieldXY[0]/2.) + sqr(ffieldXY[1]/2.));
|
||||
} else {
|
||||
dr = fieldR;
|
||||
dr = ffieldR;
|
||||
}
|
||||
|
||||
G4double sin0 = dr/SSD;
|
||||
G4double sin0 = dr/fSSD;
|
||||
G4double cos0 = std::sqrt(1.-sqr(sin0));
|
||||
|
||||
G4double dcos = 0.;
|
||||
@@ -76,9 +77,9 @@ G4ThreeVector MedicalBeam::GenerateBeamDirection() const
|
||||
G4double y = DBL_MAX;
|
||||
|
||||
G4double xmax, ymax;
|
||||
if ( fieldShape == MedicalBeam::SQUARE ) {
|
||||
xmax = fieldXY[0]/2./SSD;
|
||||
ymax = fieldXY[1]/2./SSD;
|
||||
if ( ffieldShape == MedicalBeam::kSQUARE ) {
|
||||
xmax = ffieldXY[0]/2./fSSD;
|
||||
ymax = ffieldXY[1]/2./fSSD;
|
||||
} else {
|
||||
xmax = ymax = DBL_MAX-1.;
|
||||
}
|
||||
@@ -96,20 +97,20 @@ G4ThreeVector MedicalBeam::GenerateBeamDirection() const
|
||||
return G4ThreeVector(x,y,z);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void MedicalBeam::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
if ( particle == 0 ) return;
|
||||
if ( fparticle == NULL ) return;
|
||||
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex = new G4PrimaryVertex(sourcePosition, 0.*ns);
|
||||
G4PrimaryVertex* vertex = new G4PrimaryVertex(fsourcePosition, 0.*ns);
|
||||
|
||||
// momentum
|
||||
G4double mass = particle-> GetPDGMass();
|
||||
G4double p = std::sqrt(sqr(mass+kineticE)-sqr(mass));
|
||||
G4double mass = fparticle-> GetPDGMass();
|
||||
G4double p = std::sqrt(sqr(mass+fkineticE)-sqr(mass));
|
||||
G4ThreeVector pmon = p*GenerateBeamDirection();
|
||||
G4PrimaryParticle* primary =
|
||||
new G4PrimaryParticle(particle, pmon.x(), pmon.y(), pmon.z());
|
||||
G4PrimaryParticle* primary =
|
||||
new G4PrimaryParticle(fparticle, pmon.x(), pmon.y(), pmon.z());
|
||||
|
||||
// set primary to vertex
|
||||
vertex-> SetPrimary(primary);
|
||||
|
||||
@@ -22,36 +22,43 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file RunAction.cc
|
||||
/// @brief Describe run actions
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "Analysis.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include <stdio.h>
|
||||
#include "G4Threading.hh"
|
||||
#include "Analysis.hh"
|
||||
#include "RunAction.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
RunAction::RunAction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
RunAction::~RunAction()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
Analysis* myana = Analysis::GetAnalysis();
|
||||
myana-> Clear();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void RunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
G4bool is_worker = G4Threading::IsWorkerThread();
|
||||
if ( is_worker ) return;
|
||||
|
||||
G4int rank = G4MPImanager::GetManager()-> GetRank();
|
||||
|
||||
|
||||
char str[64];
|
||||
sprintf(str, "dose-%03d.root", rank);
|
||||
G4String fname(str);
|
||||
|
||||
@@ -22,25 +22,28 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelParam.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file VoxelParam.cc
|
||||
/// @brief Define voxel parameterization
|
||||
|
||||
#include "VoxelParam.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "VoxelParam.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelParam::VoxelParam()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelParam::~VoxelParam()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelParam::ComputeTransformation(const G4int id,
|
||||
G4VPhysicalVolume* vol) const
|
||||
{
|
||||
@@ -59,7 +62,7 @@ void VoxelParam::ComputeTransformation(const G4int id,
|
||||
vol-> SetRotation(0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelParam::ComputeDimensions(G4Box& box, const G4int,
|
||||
const G4VPhysicalVolume*) const
|
||||
{
|
||||
|
||||
@@ -22,37 +22,40 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelSD.cc 78126 2013-12-03 17:43:56Z gcosmo $
|
||||
//
|
||||
/// @file VoxelSD.cc
|
||||
/// @brief Define detector sensitivity on voxels
|
||||
|
||||
#include "VoxelSD.hh"
|
||||
//#include "G4MPImanager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "Analysis.hh"
|
||||
#include "VoxelSD.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelSD::VoxelSD(const G4String& name)
|
||||
: G4VSensitiveDetector(name)
|
||||
{
|
||||
G4SDManager::GetSDMpointer()-> AddNewDetector(this);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelSD::~VoxelSD()
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4bool VoxelSD::ProcessHits(G4Step* astep, G4TouchableHistory*)
|
||||
{
|
||||
G4ThreeVector x0 = astep-> GetPreStepPoint()-> GetPosition();
|
||||
G4ThreeVector x1 = astep-> GetPostStepPoint()-> GetPosition();
|
||||
|
||||
|
||||
G4int tid = astep-> GetTrack()-> GetTrackID();
|
||||
G4int iz = astep-> GetPreStepPoint()-> GetTouchable()-> GetReplicaNumber(1);
|
||||
|
||||
@@ -62,21 +65,21 @@ G4bool VoxelSD::ProcessHits(G4Step* astep, G4TouchableHistory*)
|
||||
if ( tid == 1 && iz == 1000 ) { // scored @ first layer
|
||||
myana-> FillIncident(x0);
|
||||
}
|
||||
|
||||
|
||||
// energy deposit
|
||||
G4ThreeVector p = G4UniformRand()*(x1-x0) + x0; // position sampling
|
||||
G4double edep = astep-> GetTotalEnergyDeposit();
|
||||
myana-> FillDose(p, edep);
|
||||
myana-> FillDose(p, edep);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelSD::Initialize(G4HCofThisEvent*)
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -7,10 +7,16 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
||||
|
||||
# check MPI package...
|
||||
find_package(MPI REQUIRED)
|
||||
# modify these var. if needed
|
||||
|
||||
# modify these variables if needed
|
||||
|
||||
set(CMAKE_CXX_COMPILER mpicxx)
|
||||
#set(CMAKE_CXX_COMPILER mpiicpc)
|
||||
|
||||
#set(CMAKE_CXX_INCLUDE_PATH )
|
||||
|
||||
set(BUILD_SHARED_LIBS TRUE CACHE BOOL "Build shared library")
|
||||
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
|
||||
#------------------------------------------------------------------------------
|
||||
find_package(Geant4 REQUIRED)
|
||||
include(${Geant4_USE_FILE})
|
||||
@@ -22,7 +28,7 @@ endif()
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIR})
|
||||
|
||||
# sources
|
||||
add_library(G4mpi SHARED
|
||||
add_library(G4mpi
|
||||
src/G4MPIbatch.cc
|
||||
src/G4MPImanager.cc
|
||||
src/G4MPImessenger.cc
|
||||
@@ -48,6 +54,6 @@ set(HEADERS
|
||||
)
|
||||
|
||||
# install
|
||||
INSTALL(TARGETS G4mpi LIBRARY DESTINATION ${Geant4_DIR}/..)
|
||||
INSTALL(TARGETS G4mpi DESTINATION ${Geant4_DIR}/..)
|
||||
INSTALL(FILES ${HEADERS} DESTINATION ${Geant4_INCLUDE_DIR})
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#ifndef G4MPI_BATCH_H
|
||||
#define G4MPI_BATCH_H
|
||||
|
||||
#include "G4VMPIsession.hh"
|
||||
#include <fstream>
|
||||
#include "G4VMPIsession.hh"
|
||||
|
||||
class G4MPIbatch : public G4VMPIsession {
|
||||
public:
|
||||
@@ -39,9 +39,9 @@ public:
|
||||
virtual G4UIsession* SessionStart();
|
||||
|
||||
protected:
|
||||
std::ifstream batchStream;
|
||||
G4bool isOpened;
|
||||
G4bool isBatchMode;
|
||||
std::ifstream batch_stream_;
|
||||
G4bool is_opened_;
|
||||
G4bool is_batch_mode_;
|
||||
|
||||
// get a command from a batch script file
|
||||
G4String ReadCommand();
|
||||
|
||||
@@ -29,9 +29,13 @@
|
||||
#define G4MPI_MANAGER_H
|
||||
|
||||
#include "mpi.h"
|
||||
#include "globals.hh"
|
||||
#include <pthread.h>
|
||||
#include <fstream>
|
||||
#include <pthread.h>
|
||||
#include "globals.hh"
|
||||
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
class G4MPImessenger;
|
||||
class G4MPIsession;
|
||||
@@ -41,13 +45,13 @@ class G4VMPIseedGenerator;
|
||||
class G4MPImanager {
|
||||
public:
|
||||
// MPI master rank
|
||||
enum { RANK_MASTER = 0 };
|
||||
|
||||
enum { kRANK_MASTER = 0 };
|
||||
|
||||
enum { // MPI tag
|
||||
TAG_G4COMMAND = 100,
|
||||
TAG_G4STATUS = 200,
|
||||
TAG_G4SEED = 300,
|
||||
TAG_DATA = 1000
|
||||
kTAG_G4COMMAND = 100,
|
||||
kTAG_G4STATUS = 200,
|
||||
kTAG_G4SEED = 300,
|
||||
kTAG_DATA = 1000
|
||||
};
|
||||
|
||||
G4MPImanager();
|
||||
@@ -101,127 +105,129 @@ public:
|
||||
void ShowHelp() const;
|
||||
|
||||
private:
|
||||
static G4MPImanager* theManager;
|
||||
G4MPImessenger* messenger;
|
||||
G4MPIsession* session;
|
||||
|
||||
G4int verbose;
|
||||
G4MPIstatus* status; // status for each node
|
||||
|
||||
// MPI rank
|
||||
G4bool isMaster;
|
||||
G4bool isSlave;
|
||||
G4int rank;
|
||||
G4int size;
|
||||
|
||||
// MPI communicator
|
||||
MPI::Intracomm COMM_G4COMMAND;
|
||||
|
||||
// cout/cerr control
|
||||
G4bool qfcout;
|
||||
std::ofstream fscout;
|
||||
|
||||
// init/macro file
|
||||
G4bool qinitmacro;
|
||||
G4String initFileName;
|
||||
G4bool qbatchmode;
|
||||
G4String macroFileName;
|
||||
DISALLOW_COPY_AND_ASSIGN(G4MPImanager);
|
||||
|
||||
// internal use
|
||||
void Initialize();
|
||||
void ParseArguments(G4int argc, char** argv);
|
||||
void Wait(G4int ausec) const;
|
||||
void UpdateStatus();
|
||||
|
||||
// for beamOn
|
||||
pthread_t threadID;
|
||||
static G4MPImanager* g4mpi_;
|
||||
G4MPImessenger* messenger_;
|
||||
G4MPIsession* session_;
|
||||
|
||||
// seed generator
|
||||
G4VMPIseedGenerator* seedGenerator;
|
||||
G4VMPIseedGenerator* seed_generator_;
|
||||
|
||||
G4MPIstatus* status_; // status for each node
|
||||
|
||||
G4int verbose_;
|
||||
|
||||
// MPI rank
|
||||
G4bool is_master_;
|
||||
G4bool is_slave_;
|
||||
G4int rank_;
|
||||
G4int size_;
|
||||
|
||||
// MPI communicator
|
||||
MPI::Intracomm COMM_G4COMMAND_;
|
||||
|
||||
// cout/cerr control
|
||||
G4bool qfcout_;
|
||||
std::ofstream fscout_;
|
||||
|
||||
// init/macro file
|
||||
G4bool qinitmacro_;
|
||||
G4String init_file_name_;
|
||||
G4bool qbatchmode_;
|
||||
G4String macro_file_name_;
|
||||
|
||||
// for beamOn
|
||||
pthread_t thread_id_;
|
||||
|
||||
// parallel parameters
|
||||
G4double masterWeight;
|
||||
G4double master_weight_;
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
inline G4MPIsession* G4MPImanager::GetMPIsession() const
|
||||
{
|
||||
return session;
|
||||
return session_;
|
||||
}
|
||||
|
||||
inline G4int G4MPImanager::GetVerbose() const
|
||||
{
|
||||
return verbose;
|
||||
return verbose_;
|
||||
}
|
||||
|
||||
inline void G4MPImanager::SetVerbose(G4int iverbose)
|
||||
{
|
||||
G4int lv=iverbose;
|
||||
if(iverbose>1) lv=1;
|
||||
if(iverbose<0) lv=0;
|
||||
G4int lv = iverbose;
|
||||
if( iverbose > 1 ) lv = 1;
|
||||
if( iverbose < 0 ) lv = 0;
|
||||
|
||||
verbose= lv;
|
||||
verbose_ = lv;
|
||||
return;
|
||||
}
|
||||
|
||||
inline G4int G4MPImanager::GetRank() const
|
||||
{
|
||||
return rank;
|
||||
return rank_;
|
||||
}
|
||||
|
||||
inline G4int G4MPImanager::GetSize() const
|
||||
{
|
||||
return size;
|
||||
return size_;
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsMaster() const
|
||||
{
|
||||
return isMaster;
|
||||
return is_master_;
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsSlave() const
|
||||
{
|
||||
return isSlave;
|
||||
return is_slave_;
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsInitMacro() const
|
||||
{
|
||||
return qinitmacro;
|
||||
return qinitmacro_;
|
||||
|
||||
}
|
||||
|
||||
inline const G4String& G4MPImanager::GetInitFileName() const
|
||||
{
|
||||
return initFileName;
|
||||
return init_file_name_;
|
||||
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsBatchMode() const
|
||||
{
|
||||
return qbatchmode;
|
||||
return qbatchmode_;
|
||||
}
|
||||
|
||||
inline const G4String& G4MPImanager::GetMacroFileName() const
|
||||
{
|
||||
return macroFileName;
|
||||
return macro_file_name_;
|
||||
}
|
||||
|
||||
inline void G4MPImanager::SetMasterWeight(G4double aweight)
|
||||
{
|
||||
masterWeight= aweight;
|
||||
master_weight_ = aweight;
|
||||
|
||||
if(aweight<0.) masterWeight= 0.;
|
||||
if(aweight>1.) masterWeight= 1.;
|
||||
if( aweight < 0. ) master_weight_ = 0.;
|
||||
if( aweight > 1. ) master_weight_ = 1.;
|
||||
}
|
||||
|
||||
inline G4double G4MPImanager::GetMasterWeight() const
|
||||
{
|
||||
return masterWeight;
|
||||
return master_weight_;
|
||||
}
|
||||
|
||||
inline G4VMPIseedGenerator* G4MPImanager::GetSeedGenerator() const
|
||||
{
|
||||
return seedGenerator;
|
||||
return seed_generator_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
class G4MPImanager;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
@@ -40,30 +44,40 @@ class G4UIcommand;
|
||||
|
||||
class G4MPImessenger : public G4UImessenger {
|
||||
public:
|
||||
G4MPImessenger(G4MPImanager* manager);
|
||||
G4MPImessenger();
|
||||
~G4MPImessenger();
|
||||
|
||||
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
|
||||
virtual G4String GetCurrentValue(G4UIcommand* command);
|
||||
|
||||
void SetTargetObject(G4MPImanager* mpi_manager);
|
||||
|
||||
private:
|
||||
G4MPImanager* g4MPI;
|
||||
DISALLOW_COPY_AND_ASSIGN(G4MPImessenger);
|
||||
|
||||
G4MPImanager* g4mpi_;
|
||||
|
||||
// /mpi
|
||||
G4UIdirectory* dir;
|
||||
G4UIdirectory* dir_;
|
||||
|
||||
G4UIcmdWithAnInteger* verbose;
|
||||
G4UIcmdWithoutParameter* status;
|
||||
G4UIcmdWithAnInteger* verbose_;
|
||||
G4UIcmdWithoutParameter* status_;
|
||||
|
||||
G4UIcmdWithAString* execute;
|
||||
G4UIcmdWithAString* execute_;
|
||||
|
||||
G4UIcommand* beamOn;
|
||||
G4UIcommand* dotbeamOn;
|
||||
G4UIcmdWithADouble* masterWeight;
|
||||
G4UIcommand* beam_on_;
|
||||
G4UIcommand* dot_beam_on_;
|
||||
G4UIcmdWithADouble* master_weight_;
|
||||
|
||||
G4UIcmdWithoutParameter* showSeeds;
|
||||
G4UIcmdWithAnInteger* setMasterSeed;
|
||||
G4UIcommand* setSeed;
|
||||
G4UIcmdWithoutParameter* show_seeds_;
|
||||
G4UIcmdWithAnInteger* set_master_seed_;
|
||||
G4UIcommand* set_seed_;
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
inline void G4MPImessenger::SetTargetObject(G4MPImanager* mpi_manager)
|
||||
{
|
||||
g4mpi_ = mpi_manager;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
|
||||
virtual G4UIsession* SessionStart();
|
||||
|
||||
protected:
|
||||
G4VUIshell* shell;
|
||||
private:
|
||||
G4VUIshell* shell_;
|
||||
|
||||
// get command from user prompt of the master node
|
||||
G4String GetCommand(const char* msg = 0);
|
||||
|
||||
@@ -36,8 +36,6 @@ class G4Timer;
|
||||
|
||||
class G4MPIstatus {
|
||||
public:
|
||||
enum { NSIZE = 10 };
|
||||
|
||||
G4MPIstatus();
|
||||
~G4MPIstatus();
|
||||
|
||||
@@ -63,14 +61,16 @@ public:
|
||||
|
||||
void Print() const;
|
||||
|
||||
enum { kNSIZE = 10 };
|
||||
|
||||
private:
|
||||
G4int rank;
|
||||
G4int runID;
|
||||
G4int nEventToBeProcessed;
|
||||
G4int eventID;
|
||||
G4double cputime;
|
||||
G4ApplicationState g4state;
|
||||
G4Timer* timer;
|
||||
G4int rank_;
|
||||
G4int run_id_;
|
||||
G4int nevent_to_be_processed_;
|
||||
G4int event_id_;
|
||||
G4double cputime_;
|
||||
G4ApplicationState g4state_;
|
||||
G4Timer* timer_;
|
||||
|
||||
G4String GetStateString(G4ApplicationState astate) const;
|
||||
};
|
||||
@@ -78,47 +78,37 @@ private:
|
||||
// ====================================================================
|
||||
inline G4int G4MPIstatus::SizeOf() const
|
||||
{
|
||||
return NSIZE;
|
||||
return kNSIZE;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetRank() const
|
||||
{
|
||||
return rank;
|
||||
return rank_;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetRunID() const
|
||||
{
|
||||
return runID;
|
||||
return run_id_;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetNEventToBeProcessed() const
|
||||
{
|
||||
return nEventToBeProcessed;
|
||||
return nevent_to_be_processed_;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetEventID() const
|
||||
{
|
||||
return eventID;
|
||||
return event_id_;
|
||||
}
|
||||
|
||||
inline G4double G4MPIstatus::GetCPUTime() const
|
||||
{
|
||||
return cputime;
|
||||
return cputime_;
|
||||
}
|
||||
|
||||
inline G4ApplicationState G4MPIstatus::GetG4State() const
|
||||
{
|
||||
return g4state;
|
||||
}
|
||||
|
||||
inline void G4MPIstatus::StartTimer()
|
||||
{
|
||||
timer-> Start();
|
||||
}
|
||||
|
||||
inline void G4MPIstatus::StopTimer()
|
||||
{
|
||||
timer-> Stop();
|
||||
return g4state_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,22 +43,22 @@ public:
|
||||
const std::vector<G4long>& GetSeedList() const;
|
||||
|
||||
protected:
|
||||
G4long masterSeed;
|
||||
std::vector<G4long> seedList;
|
||||
G4long master_seed_;
|
||||
std::vector<G4long> seed_list_;
|
||||
|
||||
// generate seeds for MPI nodes
|
||||
virtual void GenerateSeeds()=0;
|
||||
virtual void GenerateSeeds() = 0;
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
inline G4long G4VMPIseedGenerator::GetMasterSeed() const
|
||||
{
|
||||
return masterSeed;
|
||||
return master_seed_;
|
||||
}
|
||||
|
||||
inline const std::vector<G4long>& G4VMPIseedGenerator::GetSeedList() const
|
||||
inline const std::vector<G4long>& G4VMPIseedGenerator::GetSeedList() const
|
||||
{
|
||||
return seedList;
|
||||
return seed_list_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
|
||||
typedef void* (*Func_t)(void *); // for thead function
|
||||
typedef void* (*Func_t)(void *); // for thread function
|
||||
|
||||
class G4MPImanager;
|
||||
class G4VUIshell;
|
||||
@@ -46,14 +46,14 @@ public:
|
||||
virtual G4int ReceiveG4cerr(const G4String& cerrString);
|
||||
|
||||
protected:
|
||||
G4MPImanager* g4MPI;
|
||||
G4MPImanager* g4mpi_;
|
||||
|
||||
// MPI node info (cache)
|
||||
G4bool isMaster;
|
||||
G4bool isSlave;
|
||||
G4int rank;
|
||||
G4bool is_master_;
|
||||
G4bool is_slave_;
|
||||
G4int rank_;
|
||||
|
||||
G4int ExecCommand(G4String acommand);
|
||||
G4int ExecCommand(const G4String& acommand);
|
||||
G4String TruncateCommand(const G4String& command) const;
|
||||
G4String BypassCommand(const G4String& command) const;
|
||||
|
||||
|
||||
@@ -25,14 +25,17 @@
|
||||
/// @file G4MPIbatch.cc
|
||||
/// @brief MPI batch session
|
||||
|
||||
#include "mpi.h"
|
||||
#include <vector>
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4MPIbatch.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include <vector>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
static void Tokenize(const G4String& str, std::vector<G4String>& tokens)
|
||||
namespace {
|
||||
|
||||
void Tokenize(const G4String& str, std::vector<G4String>& tokens)
|
||||
{
|
||||
const char* delimiter = " ";
|
||||
|
||||
@@ -55,17 +58,19 @@ static void Tokenize(const G4String& str, std::vector<G4String>& tokens)
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIbatch::G4MPIbatch(const G4String& fname, G4bool qbatch)
|
||||
: G4VMPIsession(), isOpened(false), isBatchMode(qbatch)
|
||||
: G4VMPIsession(), is_opened_(false), is_batch_mode_(qbatch)
|
||||
{
|
||||
if(isMaster) {
|
||||
batchStream.open(fname, std::ios::in);
|
||||
if(batchStream.fail()) {
|
||||
if( is_master_ ) {
|
||||
batch_stream_.open(fname, std::ios::in);
|
||||
if(batch_stream_.fail()) {
|
||||
G4cerr << "cannot open a macro file(" << fname << ")."
|
||||
<< G4endl;
|
||||
} else {
|
||||
isOpened = true;
|
||||
is_opened_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +78,7 @@ G4MPIbatch::G4MPIbatch(const G4String& fname, G4bool qbatch)
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIbatch::~G4MPIbatch()
|
||||
{
|
||||
if(isOpened) batchStream.close();
|
||||
if( is_opened_ ) batch_stream_.close();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -84,8 +89,8 @@ G4String G4MPIbatch::ReadCommand()
|
||||
|
||||
G4String cmdtotal = "";
|
||||
G4bool qcontinued = false;
|
||||
while(batchStream.good()) {
|
||||
batchStream.getline(linebuf, BUFSIZE);
|
||||
while( batch_stream_.good() ) {
|
||||
batch_stream_.getline(linebuf, BUFSIZE);
|
||||
|
||||
G4String cmdline(linebuf);
|
||||
|
||||
@@ -99,24 +104,24 @@ G4String G4MPIbatch::ReadCommand()
|
||||
cmdline = cmdline.strip(G4String::both);
|
||||
|
||||
// skip null line if single line
|
||||
if(!qcontinued && cmdline.size() == 0) continue;
|
||||
if( !qcontinued && cmdline.size() == 0 ) continue;
|
||||
|
||||
// '#' is treated as echoing something
|
||||
if(cmdline(0) == '#') return cmdline;
|
||||
if( cmdline(0) == '#' ) return cmdline;
|
||||
|
||||
// tokenize...
|
||||
std::vector<G4String> tokens;
|
||||
Tokenize(cmdline, tokens);
|
||||
qcontinued = false;
|
||||
for (G4int i = 0; i < G4int(tokens.size()); i++) {
|
||||
for( G4int i = 0; i < G4int(tokens.size()); i++ ) {
|
||||
// string after '#" is ignored
|
||||
if(tokens[i](0) == '#' ) break;
|
||||
if( tokens[i](0) == '#' ) break;
|
||||
// '\' or '_' is treated as continued line.
|
||||
if(tokens[i] == '\\' || tokens[i] == '_' ) {
|
||||
if( tokens[i] == '\\' || tokens[i] == '_' ) {
|
||||
qcontinued = true;
|
||||
// check nothing after line continuation character
|
||||
if( i != G4int(tokens.size())-1) {
|
||||
G4Exception("G4MPIbatch::ReadCommand", "MPI002", JustWarning,
|
||||
if( i != G4int(tokens.size())-1 ) {
|
||||
G4Exception("G4MPIbatch::ReadCommand", "MPI004", JustWarning,
|
||||
"unexpected character after line continuation character");
|
||||
}
|
||||
break; // stop parsing
|
||||
@@ -125,10 +130,10 @@ G4String G4MPIbatch::ReadCommand()
|
||||
cmdtotal += " ";
|
||||
}
|
||||
|
||||
if(qcontinued) continue; // read the next line
|
||||
if( qcontinued ) continue; // read the next line
|
||||
|
||||
if(cmdtotal.size() != 0) break;
|
||||
if(batchStream.eof()) break;
|
||||
if( cmdtotal.size() != 0 ) break;
|
||||
if( batch_stream_.eof() ) break;
|
||||
}
|
||||
|
||||
// strip again
|
||||
@@ -138,7 +143,7 @@ G4String G4MPIbatch::ReadCommand()
|
||||
cmdtotal = BypassCommand(cmdtotal);
|
||||
|
||||
// finally,
|
||||
if(batchStream.eof() && cmdtotal.size()==0) {
|
||||
if( batch_stream_.eof() && cmdtotal.size()==0 ) {
|
||||
return "exit";
|
||||
}
|
||||
|
||||
@@ -148,32 +153,32 @@ G4String G4MPIbatch::ReadCommand()
|
||||
// --------------------------------------------------------------------------
|
||||
G4UIsession* G4MPIbatch::SessionStart()
|
||||
{
|
||||
if( isMaster && !isOpened ){ // macro file is not found
|
||||
g4MPI-> BcastCommand("exit");
|
||||
if( is_master_ && !is_opened_ ) { // macro file is not found
|
||||
g4mpi_-> BcastCommand("exit");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
G4String newCommand = "", scommand; // newCommand is always "" in slaves
|
||||
|
||||
while(1) {
|
||||
if (isMaster) newCommand = ReadCommand();
|
||||
if( is_master_ ) newCommand = ReadCommand();
|
||||
// broadcast a new G4 command
|
||||
scommand = g4MPI-> BcastCommand(newCommand);
|
||||
if(scommand == "exit") {
|
||||
g4MPI-> WaitBeamOn();
|
||||
scommand = g4mpi_-> BcastCommand(newCommand);
|
||||
if( scommand == "exit" ) {
|
||||
g4mpi_-> WaitBeamOn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// just echo something
|
||||
if( scommand(0) == '#') {
|
||||
if(G4UImanager::GetUIpointer()-> GetVerboseLevel() == 2) {
|
||||
if( scommand(0) == '#' ) {
|
||||
if( G4UImanager::GetUIpointer()-> GetVerboseLevel() == 2 ) {
|
||||
G4cout << scommand << G4endl;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
G4int rc = ExecCommand(scommand);
|
||||
if (rc != fCommandSucceeded) {
|
||||
if ( rc != fCommandSucceeded ) {
|
||||
G4cerr << G4endl << "***** Batch is interupted!! *****" << G4endl;
|
||||
break;
|
||||
}
|
||||
@@ -181,4 +186,3 @@ G4UIsession* G4MPIbatch::SessionStart()
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,34 +25,49 @@
|
||||
/// @file G4MPImanager.cc
|
||||
/// @brief MPI manager class
|
||||
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPImessenger.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
#include "G4MPIbatch.hh"
|
||||
#include "G4MPIstatus.hh"
|
||||
#include "G4MPIrandomSeedGenerator.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "mpi.h"
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Run.hh"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <assert.h>
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4MPIbatch.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPImessenger.hh"
|
||||
#include "G4MPIrandomSeedGenerator.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
#include "G4MPIstatus.hh"
|
||||
|
||||
G4MPImanager* G4MPImanager::theManager = 0;
|
||||
G4MPImanager* G4MPImanager::g4mpi_ = NULL;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
namespace {
|
||||
|
||||
// wrappers for thread functions
|
||||
static void thread_ExecuteThreadCommand(const G4String* command)
|
||||
void thread_ExecuteThreadCommand(const G4String* command)
|
||||
{
|
||||
G4MPImanager::GetManager()-> ExecuteThreadCommand(*command);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void Wait(G4int ausec)
|
||||
{
|
||||
struct timespec treq, trem;
|
||||
treq.tv_sec = 0;
|
||||
treq.tv_nsec = ausec*1000;
|
||||
|
||||
nanosleep(&treq, &trem);
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPImanager::G4MPImanager()
|
||||
: verbose(0), qfcout(false), qinitmacro(false), qbatchmode(false),
|
||||
threadID(0), masterWeight(1.)
|
||||
: verbose_(0), qfcout_(false), qinitmacro_(false), qbatchmode_(false),
|
||||
thread_id_(0), master_weight_(1.)
|
||||
{
|
||||
//MPI::Init();
|
||||
MPI::Init_thread(MPI::THREAD_SERIALIZED);
|
||||
@@ -61,8 +76,8 @@ G4MPImanager::G4MPImanager()
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPImanager::G4MPImanager(int argc, char** argv)
|
||||
: verbose(0), qfcout(false), qinitmacro(false), qbatchmode(false),
|
||||
threadID(0), masterWeight(1.)
|
||||
: verbose_(0), qfcout_(false), qinitmacro_(false), qbatchmode_(false),
|
||||
thread_id_(0), master_weight_(1.)
|
||||
{
|
||||
//MPI::Init(argc, argv);
|
||||
MPI::Init_thread(argc, argv, MPI::THREAD_SERIALIZED);
|
||||
@@ -73,49 +88,54 @@ G4MPImanager::G4MPImanager(int argc, char** argv)
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPImanager::~G4MPImanager()
|
||||
{
|
||||
if(isSlave && qfcout) fscout.close();
|
||||
if( is_slave_ && qfcout_ ) fscout_.close();
|
||||
|
||||
delete status;
|
||||
delete messenger;
|
||||
delete session;
|
||||
delete status_;
|
||||
delete messenger_;
|
||||
delete session_;
|
||||
|
||||
COMM_G4COMMAND.Free();
|
||||
COMM_G4COMMAND_.Free();
|
||||
|
||||
MPI::Finalize();
|
||||
|
||||
theManager = 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPImanager* G4MPImanager::GetManager()
|
||||
{
|
||||
assert( theManager != 0 );
|
||||
return theManager;
|
||||
if ( g4mpi_ == NULL ) {
|
||||
G4Exception("G4MPImanager::GetManager()", "MPI001",
|
||||
FatalException, "G4MPImanager is not instantiated.");
|
||||
}
|
||||
return g4mpi_;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::Initialize()
|
||||
{
|
||||
assert( theManager == 0 );
|
||||
if ( g4mpi_ != NULL ) {
|
||||
G4Exception("G4MPImanager::Initialize()", "MPI002",
|
||||
FatalException, "G4MPImanager is already instantiated.");
|
||||
}
|
||||
|
||||
theManager= this;
|
||||
g4mpi_ = this;
|
||||
|
||||
// get rank information
|
||||
size = MPI::COMM_WORLD.Get_size();
|
||||
rank = MPI::COMM_WORLD.Get_rank();
|
||||
isMaster = (rank == RANK_MASTER);
|
||||
isSlave = (rank != RANK_MASTER);
|
||||
size_ = MPI::COMM_WORLD.Get_size();
|
||||
rank_ = MPI::COMM_WORLD.Get_rank();
|
||||
is_master_ = (rank_ == kRANK_MASTER);
|
||||
is_slave_ = (rank_ != kRANK_MASTER);
|
||||
|
||||
// initialize MPI communicator
|
||||
COMM_G4COMMAND = MPI::COMM_WORLD.Dup();
|
||||
COMM_G4COMMAND_ = MPI::COMM_WORLD.Dup();
|
||||
|
||||
// new G4MPI stuffs
|
||||
messenger = new G4MPImessenger(this);
|
||||
session = new G4MPIsession;
|
||||
status = new G4MPIstatus;
|
||||
messenger_ = new G4MPImessenger();
|
||||
messenger_-> SetTargetObject(this);
|
||||
session_ = new G4MPIsession;
|
||||
status_ = new G4MPIstatus;
|
||||
|
||||
// default seed generator is random generator.
|
||||
seedGenerator = new G4MPIrandomSeedGenerator;
|
||||
seed_generator_ = new G4MPIrandomSeedGenerator;
|
||||
DistributeSeeds();
|
||||
}
|
||||
|
||||
@@ -126,92 +146,67 @@ void G4MPImanager::ParseArguments(int argc, char** argv)
|
||||
G4String ofprefix = "mpi";
|
||||
|
||||
G4int c;
|
||||
while (1) {
|
||||
G4int option_index= 0;
|
||||
while ( 1 ) {
|
||||
G4int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"help", 0, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"init", 1, 0, 0},
|
||||
{"ofile", 2, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"init", required_argument, NULL, 'i'},
|
||||
{"ofile", optional_argument, NULL, 'o'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
opterr = 0; // suppress message
|
||||
c= getopt_long(argc, argv, "hvi:o", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "hvi:o", long_options, &option_index);
|
||||
opterr = 1;
|
||||
|
||||
if(c == -1) break;
|
||||
if( c == -1 ) break;
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
switch(option_index) {
|
||||
case 0 : // --help
|
||||
qhelp = 1;
|
||||
break;
|
||||
case 1 : // --verbose
|
||||
verbose = 1;
|
||||
break;
|
||||
case 2 : // --init
|
||||
qinitmacro = true;
|
||||
initFileName = optarg;
|
||||
break;
|
||||
case 3 : // --ofile
|
||||
qfcout = true;
|
||||
if(optarg) ofprefix = optarg;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'h' :
|
||||
qhelp = 1;
|
||||
break;
|
||||
case 'v' :
|
||||
verbose = 1;
|
||||
verbose_ = 1;
|
||||
break;
|
||||
case 'i' :
|
||||
qinitmacro = true;
|
||||
initFileName = optarg;
|
||||
qinitmacro_ = true;
|
||||
init_file_name_ = optarg;
|
||||
break;
|
||||
case 'o' :
|
||||
qfcout = true;
|
||||
qfcout_ = true;
|
||||
if ( optarg ) ofprefix = optarg;
|
||||
break;
|
||||
default:
|
||||
G4cerr << "*** invalid options specified." << G4endl;
|
||||
std::exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// show help
|
||||
if(qhelp) {
|
||||
if(isMaster) ShowHelp();
|
||||
if ( qhelp ) {
|
||||
if ( is_master_ ) ShowHelp();
|
||||
MPI::Finalize();
|
||||
exit(0);
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
// file output
|
||||
if(isSlave && qfcout) {
|
||||
if( is_slave_ && qfcout_ ) {
|
||||
G4String prefix = ofprefix + ".%03d" + ".cout";
|
||||
char str[1024];
|
||||
sprintf(str, prefix.c_str(), rank);
|
||||
sprintf(str, prefix.c_str(), rank_);
|
||||
G4String fname(str);
|
||||
fscout.open(fname.c_str(), std::ios::out);
|
||||
fscout_.open(fname.c_str(), std::ios::out);
|
||||
}
|
||||
|
||||
// non-option ARGV-elements ...
|
||||
if (optind < argc ) {
|
||||
qbatchmode = true;
|
||||
macroFileName = argv[optind];
|
||||
if ( optind < argc ) {
|
||||
qbatchmode_ = true;
|
||||
macro_file_name_ = argv[optind];
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::Wait(G4int ausec) const
|
||||
{
|
||||
struct timespec treq, trem;
|
||||
treq.tv_sec = 0;
|
||||
treq.tv_nsec = ausec*1000;
|
||||
|
||||
nanosleep(&treq, &trem);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
void G4MPImanager::UpdateStatus()
|
||||
{
|
||||
@@ -223,12 +218,12 @@ void G4MPImanager::UpdateStatus()
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState g4state = stateManager-> GetCurrentState();
|
||||
|
||||
if (run) {
|
||||
if ( run ) {
|
||||
runid = run-> GetRunID();
|
||||
neventTBP = run -> GetNumberOfEventToBeProcessed();
|
||||
eventid = run-> GetNumberOfEvent();
|
||||
if(g4state == G4State_GeomClosed || g4state == G4State_EventProc) {
|
||||
status-> StopTimer();
|
||||
if( g4state == G4State_GeomClosed || g4state == G4State_EventProc ) {
|
||||
status_-> StopTimer();
|
||||
}
|
||||
} else {
|
||||
runid = 0;
|
||||
@@ -236,39 +231,39 @@ void G4MPImanager::UpdateStatus()
|
||||
neventTBP = 0;
|
||||
}
|
||||
|
||||
status-> SetStatus(rank, runid, neventTBP, eventid, g4state);
|
||||
status_-> SetStatus(rank_, runid, neventTBP, eventid, g4state);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::ShowStatus()
|
||||
{
|
||||
G4int buff[G4MPIstatus::NSIZE];
|
||||
G4int buff[G4MPIstatus::kNSIZE];
|
||||
|
||||
UpdateStatus();
|
||||
G4bool gstatus = CheckThreadStatus();
|
||||
|
||||
if(isMaster) {
|
||||
status-> Print(); // for maser itself
|
||||
if ( is_master_ ) {
|
||||
status_-> Print(); // for maser itself
|
||||
|
||||
G4int nev = status-> GetEventID();
|
||||
G4int nevtp = status-> GetNEventToBeProcessed();
|
||||
G4double cputime = status-> GetCPUTime();
|
||||
G4int nev = status_-> GetEventID();
|
||||
G4int nevtp = status_-> GetNEventToBeProcessed();
|
||||
G4double cputime = status_-> GetCPUTime();
|
||||
|
||||
// receive from each slave
|
||||
for (G4int islave = 1; islave < size; islave++) {
|
||||
COMM_G4COMMAND.Recv(buff, G4MPIstatus::NSIZE, MPI::INT,
|
||||
islave, TAG_G4STATUS);
|
||||
status-> UnPack(buff);
|
||||
status-> Print();
|
||||
for ( G4int islave = 1; islave < size_; islave++ ) {
|
||||
COMM_G4COMMAND_.Recv(buff, G4MPIstatus::kNSIZE, MPI::INT,
|
||||
islave, kTAG_G4STATUS);
|
||||
status_-> UnPack(buff);
|
||||
status_-> Print();
|
||||
|
||||
// aggregation
|
||||
nev += status-> GetEventID();
|
||||
nevtp += status-> GetNEventToBeProcessed();
|
||||
cputime += status-> GetCPUTime();
|
||||
nev += status_-> GetEventID();
|
||||
nevtp += status_-> GetNEventToBeProcessed();
|
||||
cputime += status_-> GetCPUTime();
|
||||
}
|
||||
|
||||
G4String strStatus;
|
||||
if(gstatus) {
|
||||
if ( gstatus ) {
|
||||
strStatus = "Run";
|
||||
} else {
|
||||
strStatus = "Idle";
|
||||
@@ -276,23 +271,23 @@ void G4MPImanager::ShowStatus()
|
||||
|
||||
G4cout << "-------------------------------------------------------"
|
||||
<< G4endl
|
||||
<< "* #ranks= " << size
|
||||
<< "* #ranks= " << size_
|
||||
<< " event= " << nev << "/" << nevtp
|
||||
<< " state= " << strStatus
|
||||
<< " time= " << cputime << "s"
|
||||
<< G4endl;
|
||||
} else {
|
||||
status-> Pack(buff);
|
||||
COMM_G4COMMAND.Send(buff, G4MPIstatus::NSIZE, MPI::INT,
|
||||
RANK_MASTER, TAG_G4STATUS);
|
||||
status_-> Pack(buff);
|
||||
COMM_G4COMMAND_.Send(buff, G4MPIstatus::kNSIZE, MPI::INT,
|
||||
kRANK_MASTER, kTAG_G4STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
void G4MPImanager::DistributeSeeds()
|
||||
{
|
||||
std::vector<G4long> seedList = seedGenerator-> GetSeedList();
|
||||
CLHEP::HepRandom::setTheSeed(seedList[rank]);
|
||||
std::vector<G4long> seed_list = seed_generator_-> GetSeedList();
|
||||
CLHEP::HepRandom::setTheSeed(seed_list[rank_]);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -300,28 +295,28 @@ void G4MPImanager::ShowSeeds()
|
||||
{
|
||||
G4long buff;
|
||||
|
||||
if(isMaster) {
|
||||
if ( is_master_ ) {
|
||||
// print master
|
||||
G4cout << "* rank= " << rank
|
||||
G4cout << "* rank= " << rank_
|
||||
<< " seed= " << CLHEP::HepRandom::getTheSeed()
|
||||
<< G4endl;
|
||||
// receive from each slave
|
||||
for (G4int islave = 1; islave < size; islave++) {
|
||||
COMM_G4COMMAND.Recv(&buff, 1, MPI::LONG, islave, TAG_G4SEED);
|
||||
for ( G4int islave = 1; islave < size_; islave++ ) {
|
||||
COMM_G4COMMAND_.Recv(&buff, 1, MPI::LONG, islave, kTAG_G4SEED);
|
||||
G4cout << "* rank= " << islave
|
||||
<< " seed= " << buff
|
||||
<< G4endl;
|
||||
}
|
||||
} else { // slaves
|
||||
buff = CLHEP::HepRandom::getTheSeed();
|
||||
COMM_G4COMMAND.Send(&buff, 1, MPI::LONG, RANK_MASTER, TAG_G4SEED);
|
||||
COMM_G4COMMAND_.Send(&buff, 1, MPI::LONG, kRANK_MASTER, kTAG_G4SEED);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::SetSeed(G4int inode, G4long seed)
|
||||
{
|
||||
if(rank == inode) {
|
||||
if( rank_ == inode ) {
|
||||
CLHEP::HepRandom::setTheSeed(seed);
|
||||
}
|
||||
}
|
||||
@@ -330,31 +325,31 @@ void G4MPImanager::SetSeed(G4int inode, G4long seed)
|
||||
G4bool G4MPImanager::CheckThreadStatus()
|
||||
{
|
||||
unsigned buff;
|
||||
G4bool qstatus= false;
|
||||
unsigned qstatus = 0;
|
||||
|
||||
if(isMaster) {
|
||||
qstatus = threadID;
|
||||
if( is_master_ ) {
|
||||
qstatus = unsigned(thread_id_);
|
||||
// get slave status
|
||||
for (G4int islave = 1; islave < size; islave++) {
|
||||
MPI::Request request = COMM_G4COMMAND.Irecv(&buff, 1, MPI::UNSIGNED,
|
||||
islave, TAG_G4STATUS);
|
||||
MPI::Status status;
|
||||
while(! request.Test(status)) {
|
||||
Wait(1000);
|
||||
for ( G4int islave = 1; islave < size_; islave++ ) {
|
||||
MPI::Request request = COMM_G4COMMAND_.Irecv(&buff, 1, MPI::UNSIGNED,
|
||||
islave, kTAG_G4STATUS);
|
||||
while( ! request.Test() ) {
|
||||
::Wait(1000);
|
||||
}
|
||||
qstatus |= buff;
|
||||
}
|
||||
} else {
|
||||
buff = unsigned(threadID);
|
||||
COMM_G4COMMAND.Send(&buff, 1, MPI::UNSIGNED, RANK_MASTER, TAG_G4STATUS);
|
||||
buff = unsigned(thread_id_);
|
||||
COMM_G4COMMAND_.Send(&buff, 1, MPI::UNSIGNED, kRANK_MASTER, kTAG_G4STATUS);
|
||||
}
|
||||
|
||||
// broadcast
|
||||
buff = qstatus; // for master
|
||||
COMM_G4COMMAND.Bcast(&buff, 1, MPI::UNSIGNED, RANK_MASTER);
|
||||
COMM_G4COMMAND_.Bcast(&buff, 1, MPI::UNSIGNED, kRANK_MASTER);
|
||||
qstatus = buff; // for slave
|
||||
|
||||
return qstatus;
|
||||
if ( qstatus != 0 ) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -366,7 +361,7 @@ void G4MPImanager::ExecuteThreadCommand(const G4String& command)
|
||||
|
||||
G4int commandStatus = rc - (rc%100);
|
||||
|
||||
switch(commandStatus) {
|
||||
switch( commandStatus ) {
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
@@ -378,9 +373,9 @@ void G4MPImanager::ExecuteThreadCommand(const G4String& command)
|
||||
}
|
||||
|
||||
// thread is joined
|
||||
if(threadID) {
|
||||
pthread_join(threadID, 0);
|
||||
threadID = 0;
|
||||
if ( thread_id_ ) {
|
||||
pthread_join(thread_id_, 0);
|
||||
thread_id_ = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -392,19 +387,18 @@ void G4MPImanager::ExecuteBeamOnThread(const G4String& command)
|
||||
G4bool threadStatus = CheckThreadStatus();
|
||||
|
||||
if (threadStatus) {
|
||||
if(isMaster) {
|
||||
if ( is_master_ ) {
|
||||
G4cout << "G4MPIsession:: beamOn is still running." << G4endl;
|
||||
}
|
||||
} else { // ok
|
||||
static G4String cmdstr;
|
||||
cmdstr = command;
|
||||
G4int rc = pthread_create(&threadID, 0,
|
||||
G4int rc = pthread_create(&thread_id_, 0,
|
||||
(Func_t)thread_ExecuteThreadCommand,
|
||||
(void*)&cmdstr);
|
||||
if (rc != 0)
|
||||
G4Exception("G4MPImanager::ExecuteBeamOnThread()",
|
||||
"MPI001",
|
||||
FatalException,
|
||||
"MPI003", FatalException,
|
||||
"Failed to create a beamOn thread.");
|
||||
}
|
||||
}
|
||||
@@ -412,39 +406,39 @@ void G4MPImanager::ExecuteBeamOnThread(const G4String& command)
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::JoinBeamOnThread()
|
||||
{
|
||||
if(threadID) {
|
||||
pthread_join(threadID, 0);
|
||||
threadID = 0;
|
||||
if ( thread_id_ ) {
|
||||
pthread_join(thread_id_, 0);
|
||||
thread_id_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
G4String G4MPImanager::BcastCommand(const G4String& command)
|
||||
{
|
||||
enum { BUFF_SIZE = 512 };
|
||||
static char sbuff[BUFF_SIZE];
|
||||
command.copy(sbuff,BUFF_SIZE);
|
||||
enum { kBUFF_SIZE = 512 };
|
||||
static char sbuff[kBUFF_SIZE];
|
||||
command.copy(sbuff, kBUFF_SIZE);
|
||||
G4int len = command.size();
|
||||
sbuff[len] ='\0'; // no boundary check
|
||||
|
||||
// "command" is not yet fixed in slaves at this time.
|
||||
|
||||
// waiting message exhausts CPU in LAM!
|
||||
//COMM_G4COMMAND.Bcast(sbuff, ssize, MPI::CHAR, RANK_MASTER);
|
||||
//COMM_G4COMMAND_.Bcast(sbuff, ssize, MPI::CHAR, RANK_MASTER);
|
||||
|
||||
// another implementation
|
||||
if( isMaster ) {
|
||||
for (G4int islave = 1; islave < size; islave++) {
|
||||
COMM_G4COMMAND.Send(sbuff, BUFF_SIZE, MPI::CHAR, islave, TAG_G4COMMAND);
|
||||
if( is_master_ ) {
|
||||
for ( G4int islave = 1; islave < size_; islave++ ) {
|
||||
COMM_G4COMMAND_.Send(sbuff, kBUFF_SIZE, MPI::CHAR,
|
||||
islave, kTAG_G4COMMAND);
|
||||
}
|
||||
} else {
|
||||
// try non-blocking receive
|
||||
MPI::Request request= COMM_G4COMMAND.Irecv(sbuff, BUFF_SIZE, MPI::CHAR,
|
||||
RANK_MASTER, TAG_G4COMMAND);
|
||||
MPI::Request request= COMM_G4COMMAND_.Irecv(sbuff, kBUFF_SIZE, MPI::CHAR,
|
||||
kRANK_MASTER, kTAG_G4COMMAND);
|
||||
// polling...
|
||||
MPI::Status status;
|
||||
while(! request.Test(status)) {
|
||||
Wait(1000);
|
||||
while(! request.Test()) {
|
||||
::Wait(1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,42 +448,62 @@ G4String G4MPImanager::BcastCommand(const G4String& command)
|
||||
// ====================================================================
|
||||
void G4MPImanager::ExecuteMacroFile(const G4String& fname, G4bool qbatch)
|
||||
{
|
||||
G4bool currentmode = qbatchmode;
|
||||
qbatchmode = true;
|
||||
G4bool currentmode = qbatchmode_;
|
||||
qbatchmode_ = true;
|
||||
G4MPIbatch* batchSession = new G4MPIbatch(fname, qbatch);
|
||||
batchSession-> SessionStart();
|
||||
delete batchSession;
|
||||
qbatchmode = currentmode;
|
||||
qbatchmode_ = currentmode;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::BeamOn(G4int nevent, G4bool qdivide)
|
||||
{
|
||||
#ifndef G4MULTITHREADED
|
||||
G4RunManager* runManager = G4RunManager::GetRunManager();
|
||||
#endif
|
||||
|
||||
if(qdivide) { // events are divided
|
||||
G4double ntot = masterWeight+size-1.;
|
||||
if ( qdivide ) { // events are divided
|
||||
G4double ntot = master_weight_ + size_ - 1.;
|
||||
G4int nproc = G4int(nevent/ntot);
|
||||
G4int nproc0 = nevent-nproc*(size-1);
|
||||
G4int nproc0 = nevent - nproc*(size_-1);
|
||||
|
||||
if(verbose>0 && isMaster) {
|
||||
if ( verbose_ > 0 && is_master_ ) {
|
||||
G4cout << "#events in master=" << nproc0 << " / "
|
||||
<< "#events in slave=" << nproc << G4endl;
|
||||
}
|
||||
|
||||
status-> StartTimer(); // start timer
|
||||
if(isMaster) runManager-> BeamOn(nproc0);
|
||||
status_-> StartTimer(); // start timer
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4String str_nevt;
|
||||
if ( is_master_ ) str_nevt = G4UIcommand::ConvertToString(nproc0);
|
||||
else str_nevt = G4UIcommand::ConvertToString(nproc);
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI-> ApplyCommand("/run/beamOn " + str_nevt);
|
||||
#else
|
||||
if ( is_master_ ) runManager-> BeamOn(nproc0);
|
||||
else runManager-> BeamOn(nproc);
|
||||
status-> StopTimer(); // stop timer
|
||||
#endif
|
||||
|
||||
status_-> StopTimer(); // stop timer
|
||||
|
||||
} else { // same events are generated in each node (for test use)
|
||||
if(verbose>0 && isMaster) {
|
||||
if( verbose_ > 0 && is_master_ ) {
|
||||
G4cout << "#events in master=" << nevent << " / "
|
||||
<< "#events in slave=" << nevent << G4endl;
|
||||
}
|
||||
status-> StartTimer(); // start timer
|
||||
status_-> StartTimer(); // start timer
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4String str_nevt = G4UIcommand::ConvertToString(nevent);
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI-> ApplyCommand("/run/beamOn " + str_nevt);
|
||||
#else
|
||||
runManager-> BeamOn(nevent);
|
||||
status-> StopTimer(); // stop timer
|
||||
#endif
|
||||
|
||||
status_-> StopTimer(); // stop timer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,20 +511,19 @@ void G4MPImanager::BeamOn(G4int nevent, G4bool qdivide)
|
||||
void G4MPImanager::WaitBeamOn()
|
||||
{
|
||||
G4int buff = 0;
|
||||
if (qbatchmode) { // valid only in batch mode
|
||||
if(isMaster) {
|
||||
if ( qbatchmode_ ) { // valid only in batch mode
|
||||
if ( is_master_ ) {
|
||||
// receive from each slave
|
||||
for (G4int islave = 1; islave < size; islave++) {
|
||||
MPI::Request request = COMM_G4COMMAND.Irecv(&buff, 1, MPI::INT,
|
||||
islave, TAG_G4STATUS);
|
||||
MPI::Status status;
|
||||
while(! request.Test(status)) {
|
||||
Wait(1000);
|
||||
for (G4int islave = 1; islave < size_; islave++) {
|
||||
MPI::Request request = COMM_G4COMMAND_.Irecv(&buff, 1, MPI::INT,
|
||||
islave, kTAG_G4STATUS);
|
||||
while(! request.Test()) {
|
||||
::Wait(1000);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buff = 1;
|
||||
COMM_G4COMMAND.Send(&buff, 1, MPI::INT, RANK_MASTER, TAG_G4STATUS);
|
||||
COMM_G4COMMAND_.Send(&buff, 1, MPI::INT, kRANK_MASTER, kTAG_G4STATUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,13 +531,13 @@ void G4MPImanager::WaitBeamOn()
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::Print(const G4String& message)
|
||||
{
|
||||
if(isMaster){
|
||||
if ( is_master_ ){
|
||||
std::cout << message << std::flush;
|
||||
} else {
|
||||
if(qfcout) { // output to a file
|
||||
fscout << message << std::flush;
|
||||
if ( qfcout_ ) { // output to a file
|
||||
fscout_ << message << std::flush;
|
||||
} else { // output to stdout
|
||||
std::cout << rank << ":" << message << std::flush;
|
||||
std::cout << rank_ << ":" << message << std::flush;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,7 +545,7 @@ void G4MPImanager::Print(const G4String& message)
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImanager::ShowHelp() const
|
||||
{
|
||||
if(isSlave) return;
|
||||
if (is_slave_ ) return;
|
||||
|
||||
G4cout << "Geant4 MPI interface" << G4endl;
|
||||
G4cout << "usage:" << G4endl;
|
||||
|
||||
@@ -25,159 +25,160 @@
|
||||
/// @file G4MPImessenger.cc
|
||||
/// @brief Define MPI commands
|
||||
|
||||
#include "G4MPImessenger.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4VMPIseedGenerator.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "mpi.h"
|
||||
#include <sstream>
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include <sstream>
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPImessenger.hh"
|
||||
#include "G4VMPIseedGenerator.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPImessenger::G4MPImessenger( G4MPImanager* manager)
|
||||
: G4UImessenger(), g4MPI(manager)
|
||||
G4MPImessenger::G4MPImessenger()
|
||||
: G4UImessenger()
|
||||
{
|
||||
// /mpi
|
||||
dir = new G4UIdirectory("/mpi/");
|
||||
dir-> SetGuidance("MPI control commands");
|
||||
dir_ = new G4UIdirectory("/mpi/");
|
||||
dir_-> SetGuidance("MPI control commands");
|
||||
|
||||
// /mpi/verbose
|
||||
verbose = new G4UIcmdWithAnInteger("/mpi/verbose", this);
|
||||
verbose-> SetGuidance("Set verbose level.");
|
||||
verbose-> SetParameterName("verbose", false, false);
|
||||
verbose->SetRange("verbose>=0 && verbose<=1");
|
||||
verbose_ = new G4UIcmdWithAnInteger("/mpi/verbose", this);
|
||||
verbose_-> SetGuidance("Set verbose level.");
|
||||
verbose_-> SetParameterName("verbose", false, false);
|
||||
verbose_->SetRange("verbose>=0 && verbose<=1");
|
||||
|
||||
// /mpi/status
|
||||
status = new G4UIcmdWithoutParameter("/mpi/status", this);
|
||||
status-> SetGuidance( "Show mpi status.");
|
||||
status_ = new G4UIcmdWithoutParameter("/mpi/status", this);
|
||||
status_-> SetGuidance( "Show mpi status.");
|
||||
|
||||
// /mpi/execute
|
||||
execute = new G4UIcmdWithAString("/mpi/execute", this);
|
||||
execute-> SetGuidance("Execute a macro file. (=/control/execute)");
|
||||
execute-> SetParameterName("fileName", false, false);
|
||||
execute_ = new G4UIcmdWithAString("/mpi/execute", this);
|
||||
execute_-> SetGuidance("Execute a macro file. (=/control/execute)");
|
||||
execute_-> SetParameterName("fileName", false, false);
|
||||
|
||||
// /mpi/beamOn
|
||||
beamOn = new G4UIcommand("/mpi/beamOn", this);
|
||||
beamOn-> SetGuidance("Start a parallel run w/ thread.");
|
||||
beam_on_ = new G4UIcommand("/mpi/beamOn", this);
|
||||
beam_on_-> SetGuidance("Start a parallel run w/ thread.");
|
||||
|
||||
G4UIparameter* p1= new G4UIparameter("numberOfEvent", 'i', true);
|
||||
p1-> SetDefaultValue(1);
|
||||
p1-> SetParameterRange("numberOfEvent>=0");
|
||||
beamOn-> SetParameter(p1);
|
||||
beam_on_-> SetParameter(p1);
|
||||
|
||||
G4UIparameter* p2= new G4UIparameter("divide", 'b', true);
|
||||
p2-> SetDefaultValue(true);
|
||||
beamOn-> SetParameter(p2);
|
||||
beam_on_-> SetParameter(p2);
|
||||
|
||||
// /mpi/.beamOn
|
||||
dotbeamOn = new G4UIcommand("/mpi/.beamOn", this);
|
||||
dotbeamOn-> SetGuidance("Start a parallel run w/o thread.");
|
||||
dot_beam_on_ = new G4UIcommand("/mpi/.beamOn", this);
|
||||
dot_beam_on_-> SetGuidance("Start a parallel run w/o thread.");
|
||||
|
||||
p1= new G4UIparameter("numberOfEvent", 'i', true);
|
||||
p1-> SetDefaultValue(1);
|
||||
p1-> SetParameterRange("numberOfEvent>=0");
|
||||
dotbeamOn-> SetParameter(p1);
|
||||
dot_beam_on_-> SetParameter(p1);
|
||||
|
||||
p2= new G4UIparameter("divide", 'b', true);
|
||||
p2-> SetDefaultValue(true);
|
||||
dotbeamOn-> SetParameter(p2);
|
||||
dot_beam_on_-> SetParameter(p2);
|
||||
|
||||
// /mpi/weightForMaster
|
||||
masterWeight = new G4UIcmdWithADouble("/mpi/masterWeight", this);
|
||||
masterWeight-> SetGuidance("Set weight for master node.");
|
||||
masterWeight-> SetParameterName("weight", false, false);
|
||||
masterWeight-> SetRange("weight>=0. && weight<=1.");
|
||||
master_weight_ = new G4UIcmdWithADouble("/mpi/masterWeight", this);
|
||||
master_weight_-> SetGuidance("Set weight for master node.");
|
||||
master_weight_-> SetParameterName("weight", false, false);
|
||||
master_weight_-> SetRange("weight>=0. && weight<=1.");
|
||||
|
||||
// /mpi/showSeeds
|
||||
showSeeds = new G4UIcmdWithoutParameter("/mpi/showSeeds", this);
|
||||
showSeeds-> SetGuidance("Show seeds of MPI nodes.");
|
||||
show_seeds_ = new G4UIcmdWithoutParameter("/mpi/showSeeds", this);
|
||||
show_seeds_-> SetGuidance("Show seeds of MPI nodes.");
|
||||
|
||||
// /mpi/setMasterSeed
|
||||
setMasterSeed = new G4UIcmdWithAnInteger("/mpi/setMasterSeed", this);
|
||||
setMasterSeed-> SetGuidance("Set a master seed for the seed generator.");
|
||||
setMasterSeed-> SetParameterName("seed", false, false);
|
||||
set_master_seed_ = new G4UIcmdWithAnInteger("/mpi/setMasterSeed", this);
|
||||
set_master_seed_-> SetGuidance("Set a master seed for the seed generator.");
|
||||
set_master_seed_-> SetParameterName("seed", false, false);
|
||||
|
||||
// /mpi/setSeed
|
||||
setSeed = new G4UIcommand("/mpi/setSeed", this);
|
||||
setSeed-> SetGuidance("Set a seed for a specified node.");
|
||||
set_seed_ = new G4UIcommand("/mpi/setSeed", this);
|
||||
set_seed_-> SetGuidance("Set a seed for a specified node.");
|
||||
|
||||
p1 = new G4UIparameter("node", 'i', false);
|
||||
p1-> SetParameterRange("node>=0");
|
||||
setSeed-> SetParameter(p1);
|
||||
set_seed_-> SetParameter(p1);
|
||||
|
||||
p2 = new G4UIparameter("seed", 'i', false);
|
||||
setSeed-> SetParameter(p2);
|
||||
set_seed_-> SetParameter(p2);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPImessenger::~G4MPImessenger()
|
||||
{
|
||||
delete verbose;
|
||||
delete status;
|
||||
delete execute;
|
||||
delete beamOn;
|
||||
delete dotbeamOn;
|
||||
delete masterWeight;
|
||||
delete showSeeds;
|
||||
delete setMasterSeed;
|
||||
delete setSeed;
|
||||
delete verbose_;
|
||||
delete status_;
|
||||
delete execute_;
|
||||
delete beam_on_;
|
||||
delete dot_beam_on_;
|
||||
delete master_weight_;
|
||||
delete show_seeds_;
|
||||
delete set_master_seed_;
|
||||
delete set_seed_;
|
||||
|
||||
delete dir;
|
||||
delete dir_;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPImessenger::SetNewValue( G4UIcommand* command, G4String newValue)
|
||||
void G4MPImessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (command == verbose) { // /mpi/verbose
|
||||
G4int lv= verbose-> GetNewIntValue(newValue);
|
||||
g4MPI-> SetVerbose(lv);
|
||||
if ( command == verbose_ ) { // /mpi/verbose
|
||||
G4int lv = verbose_-> GetNewIntValue(newValue);
|
||||
g4mpi_-> SetVerbose(lv);
|
||||
|
||||
} else if (command == status){ // /mpi/status
|
||||
g4MPI-> ShowStatus();
|
||||
} else if ( command == status_ ) { // /mpi/status
|
||||
g4mpi_-> ShowStatus();
|
||||
|
||||
} else if (command == execute){ // /mpi/execute
|
||||
} else if ( command == execute_ ) { // /mpi/execute
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
g4MPI-> ExecuteMacroFile(UI-> FindMacroPath(newValue));
|
||||
g4mpi_-> ExecuteMacroFile(UI-> FindMacroPath(newValue));
|
||||
|
||||
} else if (command == beamOn){ // /mpi/beamOn
|
||||
} else if ( command == beam_on_ ) { // /mpi/beamOn
|
||||
std::istringstream is(newValue);
|
||||
G4int nevent;
|
||||
G4bool qdivide;
|
||||
is >> nevent >> qdivide;
|
||||
g4MPI-> BeamOn(nevent, qdivide);
|
||||
g4mpi_-> BeamOn(nevent, qdivide);
|
||||
|
||||
} else if (command == dotbeamOn){ // /mpi/.beamOn
|
||||
} else if ( command == dot_beam_on_ ) { // /mpi/.beamOn
|
||||
std::istringstream is(newValue);
|
||||
G4int nevent;
|
||||
G4bool qdivide;
|
||||
is >> nevent >> qdivide;
|
||||
g4MPI-> BeamOn(nevent, qdivide);
|
||||
g4mpi_-> BeamOn(nevent, qdivide);
|
||||
|
||||
} else if (command == masterWeight){ // /mpi/masterWeight
|
||||
G4double weight= masterWeight-> GetNewDoubleValue(newValue);
|
||||
g4MPI-> SetMasterWeight(weight);
|
||||
} else if ( command == master_weight_ ) { // /mpi/masterWeight
|
||||
G4double weight= master_weight_-> GetNewDoubleValue(newValue);
|
||||
g4mpi_-> SetMasterWeight(weight);
|
||||
|
||||
} else if (command == showSeeds){ // /mpi/showSeeds
|
||||
g4MPI-> ShowSeeds();
|
||||
} else if ( command == show_seeds_ ) { // /mpi/showSeeds
|
||||
g4mpi_-> ShowSeeds();
|
||||
|
||||
} else if (command == setMasterSeed){ // /mpi/setMasterSeed
|
||||
} else if ( command == set_master_seed_ ) { // /mpi/setMasterSeed
|
||||
std::istringstream is(newValue);
|
||||
G4long seed;
|
||||
is >> seed;
|
||||
g4MPI-> GetSeedGenerator()-> SetMasterSeed(seed);
|
||||
g4MPI-> DistributeSeeds();
|
||||
g4mpi_-> GetSeedGenerator()-> SetMasterSeed(seed);
|
||||
g4mpi_-> DistributeSeeds();
|
||||
|
||||
} else if (command == setSeed){ // /mpi/setSeed
|
||||
} else if ( command == set_seed_ ) { // /mpi/setSeed
|
||||
std::istringstream is(newValue);
|
||||
G4int inode;
|
||||
G4long seed;
|
||||
is >> inode >> seed;
|
||||
g4MPI-> SetSeed(inode, seed);
|
||||
g4mpi_-> SetSeed(inode, seed);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -188,12 +189,11 @@ G4String G4MPImessenger::GetCurrentValue(G4UIcommand* command)
|
||||
{
|
||||
G4String cv;
|
||||
|
||||
if (command == verbose) {
|
||||
cv= verbose-> ConvertToString(g4MPI->GetVerbose());
|
||||
} else if (command == masterWeight) {
|
||||
cv= masterWeight-> ConvertToString(g4MPI->GetMasterWeight());
|
||||
if ( command == verbose_ ) {
|
||||
cv = verbose_-> ConvertToString(g4mpi_->GetVerbose());
|
||||
} else if ( command == master_weight_ ) {
|
||||
cv= master_weight_-> ConvertToString(g4mpi_->GetMasterWeight());
|
||||
}
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
/// @file G4MPIrandomSeedGenerator.cc
|
||||
/// @brief An implementation of random number seed distribution
|
||||
|
||||
#include "G4MPIrandomSeedGenerator.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "mpi.h"
|
||||
#include "Randomize.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPIrandomSeedGenerator.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIrandomSeedGenerator::G4MPIrandomSeedGenerator()
|
||||
@@ -44,14 +45,15 @@ G4MPIrandomSeedGenerator::~G4MPIrandomSeedGenerator()
|
||||
// --------------------------------------------------------------------------
|
||||
G4bool G4MPIrandomSeedGenerator::CheckDoubleCount()
|
||||
{
|
||||
G4MPImanager* g4MPI = G4MPImanager::GetManager();
|
||||
G4int nsize = g4MPI-> GetSize();
|
||||
G4MPImanager* g4mpi = G4MPImanager::GetManager();
|
||||
|
||||
for (G4int i = 0; i < nsize; i++) {
|
||||
for (G4int j = 0; j < nsize; j++) {
|
||||
if((i != j) && (seedList[i] == seedList[j])) {
|
||||
G4int nsize = g4mpi-> GetSize();
|
||||
|
||||
for ( G4int i = 0; i < nsize; i++ ) {
|
||||
for ( G4int j = 0; j < nsize; j++ ) {
|
||||
if( (i != j) && (seed_list_[i] == seed_list_[j]) ) {
|
||||
G4double x = G4UniformRand();
|
||||
seedList[j] = G4long(x*LONG_MAX);
|
||||
seed_list_[j] = G4long(x*LONG_MAX);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -63,14 +65,16 @@ G4bool G4MPIrandomSeedGenerator::CheckDoubleCount()
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIrandomSeedGenerator::GenerateSeeds()
|
||||
{
|
||||
G4MPImanager* g4MPI = G4MPImanager::GetManager();
|
||||
G4int nsize= g4MPI-> GetSize();
|
||||
seedList.clear();
|
||||
G4MPImanager* g4mpi = G4MPImanager::GetManager();
|
||||
|
||||
for (G4int i = 0; i < nsize; i++) {
|
||||
G4int nsize = g4mpi-> GetSize();
|
||||
|
||||
seed_list_.clear();
|
||||
|
||||
for ( G4int i = 0; i < nsize; i++ ) {
|
||||
G4double x = G4UniformRand();
|
||||
G4int seed = G4long(x*LONG_MAX);
|
||||
seedList.push_back(seed);
|
||||
seed_list_.push_back(seed);
|
||||
}
|
||||
|
||||
while(! CheckDoubleCount()) {
|
||||
|
||||
@@ -25,75 +25,80 @@
|
||||
/// @file G4MPIsession.cc
|
||||
/// @brief A terminal session for MPI application
|
||||
|
||||
#include "G4MPIsession.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "mpi.h"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcsh.hh"
|
||||
#include "G4UItcsh.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UImpish.hh"
|
||||
#include "G4UItcsh.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
namespace {
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
|
||||
#ifndef WIN32
|
||||
static const G4bool tcsh_build = true;
|
||||
const G4bool tcsh_build = true;
|
||||
#else
|
||||
static const G4bool tcsh_build = false;
|
||||
const G4bool tcsh_build = false;
|
||||
#endif
|
||||
|
||||
} // end of namespace
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIsession::G4MPIsession(G4VUIshell* ashell)
|
||||
: G4VMPIsession()
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI-> SetSession(this);
|
||||
UI-> SetCoutDestination(this);
|
||||
::UI-> SetSession(this);
|
||||
::UI-> SetCoutDestination(this);
|
||||
|
||||
// shell
|
||||
if(isMaster) {
|
||||
if(ashell) {
|
||||
shell = ashell;
|
||||
if( is_master_ ) {
|
||||
if( ashell ) {
|
||||
shell_ = ashell;
|
||||
} else {
|
||||
if ( g4MPI->GetSize() == 1 && tcsh_build ) shell = new G4UItcsh;
|
||||
else shell = new G4UIcsh;
|
||||
if ( g4mpi_-> GetSize() == 1 && ::tcsh_build ) shell_ = new G4UItcsh;
|
||||
else shell_ = new G4UIcsh;
|
||||
}
|
||||
} else {
|
||||
shell = new G4UImpish;
|
||||
shell_ = new G4UImpish;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIsession::~G4MPIsession()
|
||||
{
|
||||
delete shell;
|
||||
delete shell_;
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI-> SetSession(0);
|
||||
UI-> SetCoutDestination(0);
|
||||
::UI = G4UImanager::GetUIpointer();
|
||||
::UI-> SetSession(0);
|
||||
::UI-> SetCoutDestination(0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIsession::SetPrompt(const G4String& prompt)
|
||||
{
|
||||
shell-> SetPrompt(prompt);
|
||||
shell_-> SetPrompt(prompt);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIsession::SetShell(G4VUIshell* ashell)
|
||||
{
|
||||
delete shell;
|
||||
shell = ashell;
|
||||
delete shell_;
|
||||
shell_ = ashell;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4String G4MPIsession::GetCommand(const char* msg)
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
|
||||
G4String newCommand;
|
||||
const G4String nullString="";
|
||||
const G4String nullString = "";
|
||||
|
||||
// get command from shell...
|
||||
newCommand = shell-> GetCommandLineString(msg);
|
||||
newCommand = shell_-> GetCommandLineString(msg);
|
||||
|
||||
G4String nC= newCommand.strip(G4String::leading);
|
||||
if( nC.length() == 0 ) {
|
||||
@@ -103,62 +108,62 @@ G4String G4MPIsession::GetCommand(const char* msg)
|
||||
G4cout << nC << G4endl;
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC=="ls" || nC(0,3)=="ls " ) { // list commands
|
||||
} else if( nC == "ls" || nC(0,3) == "ls " ) { // list commands
|
||||
ListDirectory(nC);
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC=="lc" || nC(0,3)=="lc " ) { // ... by shell
|
||||
shell-> ListCommand(nC.remove(0,2));
|
||||
} else if( nC == "lc" || nC(0,3) == "lc " ) { // ... by shell
|
||||
shell_-> ListCommand(nC.remove(0,2));
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC == "pwd") { // show current directory
|
||||
} else if( nC == "pwd" ) { // show current directory
|
||||
G4cout << "Current Command Directory : "
|
||||
<< GetCurrentWorkingDirectory() << G4endl;
|
||||
<< GetCurrentWorkingDirectory() << G4endl;
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC == "cwd") { // ... by shell
|
||||
shell-> ShowCurrentDirectory();
|
||||
} else if( nC == "cwd" ) { // ... by shell
|
||||
shell_-> ShowCurrentDirectory();
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC == "cd" || nC(0,3) == "cd ") { // "cd"
|
||||
} else if(nC == "cd" || nC(0,3) == "cd " ) { // "cd"
|
||||
ChangeDirectoryCommand(nC);
|
||||
shell-> SetCurrentDirectory(GetCurrentWorkingDirectory());
|
||||
shell_-> SetCurrentDirectory(GetCurrentWorkingDirectory());
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC == "help" || nC(0,5) == "help ") { // "help"
|
||||
} else if( nC == "help" || nC(0,5) == "help " ) { // "help"
|
||||
TerminalHelp(nC);
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC(0) == '?') { // "show current value of a parameter"
|
||||
} else if( nC(0) == '?' ) { // "show current value of a parameter"
|
||||
ShowCurrent(nC);
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC == "hist" || nC == "history") { // "hist/history"
|
||||
G4int nh= UI-> GetNumberOfHistory();
|
||||
for (G4int i = 0; i<nh; i++) {
|
||||
G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl;
|
||||
} else if( nC == "hist" || nC == "history" ) { // "hist/history"
|
||||
G4int nh= ::UI-> GetNumberOfHistory();
|
||||
for( G4int i = 0; i<nh; i++ ) {
|
||||
G4cout << i << ": " << ::UI-> GetPreviousCommand(i) << G4endl;
|
||||
}
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC(0) == '!') { // "!"
|
||||
G4String ss= nC(1, nC.length()-1);
|
||||
} else if( nC(0) == '!' ) { // "!"
|
||||
G4String ss = nC(1, nC.length()-1);
|
||||
G4int vl;
|
||||
const char* tt = ss;
|
||||
std::istringstream is(tt);
|
||||
is >> vl;
|
||||
G4int nh= UI-> GetNumberOfHistory();
|
||||
if(vl>=0 && vl<nh) {
|
||||
newCommand = UI-> GetPreviousCommand(vl);
|
||||
G4int nh = ::UI-> GetNumberOfHistory();
|
||||
if( vl>=0 && vl<nh ) {
|
||||
newCommand = ::UI-> GetPreviousCommand(vl);
|
||||
G4cout << newCommand << G4endl;
|
||||
} else {
|
||||
G4cerr << "history " << vl << " is not found." << G4endl;
|
||||
newCommand = nullString;
|
||||
}
|
||||
|
||||
} else if( nC.empty() ){ // NULL command
|
||||
} else if( nC.empty() ) { // NULL command
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC == "exit" ){ // "exit"
|
||||
} else if( nC == "exit" ) { // "exit"
|
||||
return "exit";
|
||||
|
||||
} else { // ...
|
||||
@@ -173,13 +178,13 @@ G4String G4MPIsession::GetCommand(const char* msg)
|
||||
G4UIsession* G4MPIsession::SessionStart()
|
||||
{
|
||||
// execute init macro
|
||||
if( g4MPI-> IsInitMacro() ) {
|
||||
g4MPI-> ExecuteMacroFile(g4MPI->GetInitFileName());
|
||||
if( g4mpi_-> IsInitMacro() ) {
|
||||
g4mpi_-> ExecuteMacroFile(g4mpi_->GetInitFileName());
|
||||
}
|
||||
|
||||
// batch mode
|
||||
if( g4MPI-> IsBatchMode() ) {
|
||||
g4MPI-> ExecuteMacroFile(g4MPI->GetMacroFileName(), true);
|
||||
if( g4mpi_-> IsBatchMode() ) {
|
||||
g4mpi_-> ExecuteMacroFile(g4mpi_->GetMacroFileName(), true);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -187,12 +192,12 @@ G4UIsession* G4MPIsession::SessionStart()
|
||||
G4String newCommand = "", scommand; // newCommand is always "" in slaves
|
||||
|
||||
while(1) {
|
||||
if(isMaster) newCommand = GetCommand();
|
||||
if( is_master_ ) newCommand = GetCommand();
|
||||
// broadcast a new G4 command
|
||||
scommand = g4MPI-> BcastCommand(newCommand);
|
||||
if(scommand == "exit") {
|
||||
scommand = g4mpi_-> BcastCommand(newCommand);
|
||||
if( scommand == "exit" ) {
|
||||
G4bool qexit = TryForcedTerminate();
|
||||
if(qexit) break;
|
||||
if( qexit ) break;
|
||||
else scommand = "";
|
||||
}
|
||||
ExecCommand(scommand);
|
||||
@@ -204,14 +209,14 @@ G4UIsession* G4MPIsession::SessionStart()
|
||||
// --------------------------------------------------------------------------
|
||||
G4bool G4MPIsession::TryForcedTerminate()
|
||||
{
|
||||
if(! g4MPI-> CheckThreadStatus()) {
|
||||
if(! g4mpi_-> CheckThreadStatus()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
G4String xmessage;
|
||||
|
||||
// beamOn is still running
|
||||
if(isMaster) {
|
||||
if( is_master_ ) {
|
||||
char c[1024];
|
||||
while(1) {
|
||||
G4cout << "Run is still running. Do you abort a run? [y/N]:"
|
||||
@@ -225,16 +230,16 @@ G4bool G4MPIsession::TryForcedTerminate()
|
||||
}
|
||||
if(c[0] == 'y' || c[0] == 'Y') {
|
||||
G4cout << "Aborting a run..." << G4endl;
|
||||
xmessage = g4MPI-> BcastCommand("kill me");
|
||||
xmessage = g4mpi_-> BcastCommand("kill me");
|
||||
} else {
|
||||
xmessage = g4MPI-> BcastCommand("alive");
|
||||
xmessage = g4mpi_-> BcastCommand("alive");
|
||||
}
|
||||
} else {
|
||||
xmessage = g4MPI-> BcastCommand("");
|
||||
xmessage = g4mpi_-> BcastCommand("");
|
||||
}
|
||||
|
||||
if(xmessage == "kill me") {
|
||||
G4RunManager* runManager= G4RunManager::GetRunManager();
|
||||
G4RunManager* runManager = G4RunManager::GetRunManager();
|
||||
runManager-> AbortRun(true); // soft abort
|
||||
}
|
||||
|
||||
|
||||
@@ -25,71 +25,83 @@
|
||||
/// @file G4MPIstatus.cc
|
||||
/// @brief status of MPI application
|
||||
|
||||
#include "G4MPIstatus.hh"
|
||||
#include "G4ApplicationState.hh"
|
||||
#include "G4MPIstatus.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIstatus::G4MPIstatus()
|
||||
: rank(0), runID(0), nEventToBeProcessed(0), eventID(0),
|
||||
cputime(0.), g4state(G4State_Quit)
|
||||
: rank_(0), run_id_(0), nevent_to_be_processed_(0), event_id_(0),
|
||||
cputime_(0.), g4state_(G4State_Quit)
|
||||
{
|
||||
timer = new G4Timer;
|
||||
timer_ = new G4Timer;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4MPIstatus::~G4MPIstatus()
|
||||
{
|
||||
delete timer;
|
||||
delete timer_;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIstatus::StartTimer()
|
||||
{
|
||||
timer_-> Start();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIstatus::StopTimer()
|
||||
{
|
||||
timer_-> Stop();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIstatus::SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid,
|
||||
G4ApplicationState state)
|
||||
{
|
||||
rank = arank;
|
||||
runID = runid;
|
||||
nEventToBeProcessed = noe;
|
||||
eventID = evtid;
|
||||
g4state = state;
|
||||
if (timer-> IsValid()) cputime = timer-> GetUserElapsed();
|
||||
else cputime = 0.;
|
||||
rank_ = arank;
|
||||
run_id_ = runid;
|
||||
nevent_to_be_processed_ = noe;
|
||||
event_id_ = evtid;
|
||||
g4state_ = state;
|
||||
if ( timer_-> IsValid() ) cputime_= timer_-> GetUserElapsed();
|
||||
else cputime_ = 0.;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIstatus::Pack(G4int* data) const
|
||||
{
|
||||
data[0] = rank;
|
||||
data[1] = runID;
|
||||
data[2] = nEventToBeProcessed;
|
||||
data[3] = eventID;
|
||||
data[4] = g4state;
|
||||
data[0] = rank_;
|
||||
data[1] = run_id_;
|
||||
data[2] = nevent_to_be_processed_;
|
||||
data[3] = event_id_;
|
||||
data[4] = g4state_;
|
||||
|
||||
G4double* ddata = (G4double*)(data+5);
|
||||
ddata[0] = cputime;
|
||||
ddata[0] = cputime_;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIstatus::UnPack(G4int* data)
|
||||
{
|
||||
rank = data[0];
|
||||
runID = data[1];
|
||||
nEventToBeProcessed = data[2];
|
||||
eventID = data[3];
|
||||
g4state = (G4ApplicationState)data[4];
|
||||
rank_ = data[0];
|
||||
run_id_ = data[1];
|
||||
nevent_to_be_processed_ = data[2];
|
||||
event_id_ = data[3];
|
||||
g4state_ = (G4ApplicationState)data[4];
|
||||
|
||||
G4double* ddata = (G4double*)(data+5);
|
||||
cputime = ddata[0];
|
||||
cputime_ = ddata[0];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
void G4MPIstatus::Print() const
|
||||
{
|
||||
// * rank= 001 run= 10002 event= 00001 / 100000 state= Idle"
|
||||
G4cout << "* rank= " << rank
|
||||
<< " run= " << runID
|
||||
<< " event= " << eventID << " / " << nEventToBeProcessed
|
||||
<< " state= " << GetStateString(g4state)
|
||||
<< " time= " << cputime << "s"
|
||||
G4cout << "* rank= " << rank_
|
||||
<< " run= " << run_id_
|
||||
<< " event= " << event_id_ << " / " << nevent_to_be_processed_
|
||||
<< " state= " << GetStateString(g4state_)
|
||||
<< " time= " << cputime_ << "s"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4VMPIseedGenerator::G4VMPIseedGenerator()
|
||||
: masterSeed(123456789)
|
||||
: master_seed_(123456789)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,6 +41,6 @@ G4VMPIseedGenerator::~G4VMPIseedGenerator()
|
||||
// --------------------------------------------------------------------------
|
||||
void G4VMPIseedGenerator::SetMasterSeed(G4long aseed)
|
||||
{
|
||||
masterSeed = aseed;
|
||||
master_seed_ = aseed;
|
||||
GenerateSeeds();
|
||||
}
|
||||
|
||||
@@ -25,21 +25,21 @@
|
||||
/// @file G4VMPIsession.cc
|
||||
/// @brief A base class for MPI sessions
|
||||
|
||||
#include "G4VMPIsession.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "mpi.h"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4VMPIsession.hh"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4VMPIsession::G4VMPIsession()
|
||||
: G4VBasicShell()
|
||||
{
|
||||
// MPI
|
||||
g4MPI = G4MPImanager::GetManager();
|
||||
g4mpi_ = G4MPImanager::GetManager();
|
||||
|
||||
isMaster = g4MPI-> IsMaster();
|
||||
isSlave = g4MPI-> IsSlave();
|
||||
rank = g4MPI-> GetRank();
|
||||
is_master_ = g4mpi_-> IsMaster();
|
||||
is_slave_ = g4mpi_-> IsSlave();
|
||||
rank_ = g4mpi_-> GetRank();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -51,7 +51,7 @@ G4VMPIsession::~G4VMPIsession()
|
||||
G4bool G4VMPIsession::GetHelpChoice(G4int& aval)
|
||||
{
|
||||
G4cin >> aval;
|
||||
if(!G4cin.good()){
|
||||
if( !G4cin.good() ){
|
||||
G4cin.clear();
|
||||
G4cin.ignore(30,'\n');
|
||||
return false;
|
||||
@@ -72,7 +72,7 @@ void G4VMPIsession::PauseSessionStart(const G4String&)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4int G4VMPIsession::ExecCommand(G4String acommand)
|
||||
G4int G4VMPIsession::ExecCommand(const G4String& acommand)
|
||||
{
|
||||
if( acommand.length() < 2 ) return fCommandSucceeded;
|
||||
|
||||
@@ -82,13 +82,13 @@ G4int G4VMPIsession::ExecCommand(G4String acommand)
|
||||
G4String command = BypassCommand(acommand);
|
||||
|
||||
// "/mpi/beamOn is threaded out.
|
||||
if(command(0,11) == "/mpi/beamOn") {
|
||||
g4MPI-> ExecuteBeamOnThread(command);
|
||||
if( command(0,11) == "/mpi/beamOn" ) {
|
||||
g4mpi_-> ExecuteBeamOnThread(command);
|
||||
returnVal = fCommandSucceeded;
|
||||
} else if(command(0,12) == "/mpi/.beamOn") { // care for beamOn
|
||||
G4bool threadStatus = g4MPI-> CheckThreadStatus();
|
||||
if (threadStatus) { // still /run/beamOn is active
|
||||
if(isMaster) {
|
||||
} else if( command(0,12) == "/mpi/.beamOn" ) { // care for beamOn
|
||||
G4bool threadStatus = g4mpi_-> CheckThreadStatus();
|
||||
if ( threadStatus ) { // still /run/beamOn is active
|
||||
if( is_master_ ) {
|
||||
G4cout << "G4MPIsession:: beamOn is still running." << G4endl;
|
||||
}
|
||||
returnVal = fCommandSucceeded;
|
||||
@@ -105,11 +105,11 @@ G4int G4VMPIsession::ExecCommand(G4String acommand)
|
||||
G4int commandStatus = returnVal - paramIndex;
|
||||
|
||||
G4UIcommand* cmd = 0;
|
||||
if(commandStatus != fCommandSucceeded) {
|
||||
if( commandStatus != fCommandSucceeded ) {
|
||||
cmd = FindCommand(command);
|
||||
}
|
||||
|
||||
switch(commandStatus) {
|
||||
switch( commandStatus ) {
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
@@ -151,7 +151,7 @@ G4String G4VMPIsession::TruncateCommand(const G4String& command) const
|
||||
G4String strarg;
|
||||
|
||||
str_size iarg = acommand.find(' ');
|
||||
if(iarg != G4String::npos) {
|
||||
if( iarg != G4String::npos ) {
|
||||
strarg = acommand(iarg, acommand.size()-iarg);
|
||||
acommand = acommand(0,iarg);
|
||||
}
|
||||
@@ -174,58 +174,75 @@ G4String G4VMPIsession::BypassCommand(const G4String& command) const
|
||||
// bypass some commands
|
||||
// * /mpi/beamOn
|
||||
// -> /mpi/.beamOn (batch session)
|
||||
// -> /mpi/.beamOn (MT mode)
|
||||
//
|
||||
// * /run/beamOn
|
||||
// -> /mpi/.beamOn (batch session)
|
||||
// -> /mpi/beamOn (interactive session)
|
||||
// -> /mpi/.beamOn (MT mode)
|
||||
//
|
||||
// * /control/execute -> /mpi/execute
|
||||
|
||||
G4String acommand = command;
|
||||
|
||||
// /mpi/beamOn
|
||||
if(acommand(0,11) == "/mpi/beamOn") {
|
||||
if(g4MPI-> IsBatchMode()) {
|
||||
if( acommand(0,11) == "/mpi/beamOn" ) {
|
||||
#ifdef G4MULTITHREADED
|
||||
acommand = "/mpi/.beamOn";
|
||||
if(command.length() > 11) {
|
||||
acommand += command.substr(11);
|
||||
}
|
||||
#else
|
||||
if( g4mpi_-> IsBatchMode()) {
|
||||
acommand = "/mpi/.beamOn";
|
||||
if(command.length() > 11) {
|
||||
acommand += command.substr(11);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// /run/beamOn
|
||||
if(acommand(0,11) == "/run/beamOn") {
|
||||
if( acommand(0,11) == "/run/beamOn" ) {
|
||||
G4String strarg = "";
|
||||
G4bool qget = false;
|
||||
G4bool qdone = false;
|
||||
|
||||
for (str_size idx = 10; idx < command.size(); idx++) {
|
||||
if(command[idx] == ' ' || command[idx] == '\011') {
|
||||
for ( str_size idx = 10; idx < command.size(); idx++ ) {
|
||||
if( command[idx] == ' ' || command[idx] == '\011' ) {
|
||||
qget = true;
|
||||
if(qdone) break;
|
||||
continue;
|
||||
}
|
||||
if(qget) {
|
||||
if( qget ) {
|
||||
strarg += command[idx];
|
||||
qdone = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(g4MPI-> IsBatchMode()) { // batch session
|
||||
if( g4mpi_-> IsBatchMode() ) { // batch session
|
||||
acommand = "/mpi/.beamOn ";
|
||||
if(command.length() > 11) acommand += strarg;
|
||||
if( command.length() > 11 ) acommand += strarg;
|
||||
} else { // interactive session
|
||||
if(g4MPI-> GetVerbose()>0 && isMaster) {
|
||||
#ifdef G4MULTITHREADED
|
||||
if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
|
||||
G4cout << "/run/beamOn is overridden by /mpi/.beamOn" << G4endl;
|
||||
}
|
||||
acommand = "/mpi/.beamOn ";
|
||||
if( command.length() > 11 ) acommand += strarg;
|
||||
#else
|
||||
if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
|
||||
G4cout << "/run/beamOn is overridden by /mpi/beamOn" << G4endl;
|
||||
}
|
||||
acommand = "/mpi/beamOn ";
|
||||
if(command.length() > 11) acommand += strarg;
|
||||
if( command.length() > 11 ) acommand += strarg;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// /control/execute
|
||||
if(acommand(0,16) == "/control/execute") {
|
||||
if(g4MPI-> GetVerbose()>0 && isMaster) {
|
||||
if( acommand(0,16) == "/control/execute" ) {
|
||||
if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
|
||||
G4cout << "/control/execute is overridden by /mpi/execute"
|
||||
<< G4endl;
|
||||
}
|
||||
@@ -238,14 +255,13 @@ G4String G4VMPIsession::BypassCommand(const G4String& command) const
|
||||
// --------------------------------------------------------------------------
|
||||
G4int G4VMPIsession::ReceiveG4cout(const G4String& coutString)
|
||||
{
|
||||
g4MPI-> Print(coutString);
|
||||
g4mpi_-> Print(coutString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
G4int G4VMPIsession::ReceiveG4cerr(const G4String& cerrString)
|
||||
{
|
||||
g4MPI-> Print(cerrString);
|
||||
g4mpi_-> Print(cerrString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user