Import Geant4 9.1.0 source tree
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
$Id: History,v 1.1 2007/11/16 04:02:10 kmura Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
16 Nov. 2007 K.Murakami
|
||||
- commited to G4 CVS.
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
$Id: README,v 1.2 2007/11/16 14:04:05 kmura Exp $
|
||||
==========================================================================
|
||||
Geant4 MPI Interface
|
||||
|
||||
Author:
|
||||
Koichi Murakami (KEK) / Koichi.Murakami@kek.jp
|
||||
==========================================================================
|
||||
|
||||
About the interface
|
||||
===================
|
||||
G4MPI is a native interface with MPI libraries. The directory contains
|
||||
a Geant4 UI library and a couple of parallelized examples.
|
||||
Using this interface, users applications can be parllelized with
|
||||
different MPI compliant libraries, such as LAM/MPI, MPICH2, OpenMPI,
|
||||
and so on.
|
||||
|
||||
System Requirements:
|
||||
-------------------
|
||||
* Platform
|
||||
|
||||
- Linux (32bit/64bit)
|
||||
- MacOS (Tiger)
|
||||
|
||||
|
||||
* MPI implementation
|
||||
|
||||
- LAM/MPI (7.1.3)
|
||||
http://www.lam-mpi.org/
|
||||
|
||||
- MPICH2 (1.0.6p1)
|
||||
http://www.mcs.anl.gov/research/projects/mpich2/
|
||||
|
||||
- Open MPI (1.2.4)
|
||||
http://www.open-mpi.org/
|
||||
|
||||
|
||||
* Optional
|
||||
- ROOT for histogramming/analysis
|
||||
|
||||
|
||||
G4MPI UI library
|
||||
----------------
|
||||
G4MPI UI library is provided in the "mpi_interface" directory.
|
||||
Start with building the G4MPI UI library according to the instruction
|
||||
in the directory.
|
||||
|
||||
|
||||
How to make parallel applications:
|
||||
----------------------------------
|
||||
* An example of a main program:
|
||||
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
// At first, G4MPImanager/G4MPIsession should be created.
|
||||
G4MPImanager* g4MPI= new G4MPImanager(argc,argv);
|
||||
|
||||
// MPI session (G4MPIsession) instead of G4UIterminal
|
||||
G4MPIsession* session= g4MPI-> GetMPIsession();
|
||||
|
||||
// LAM users can use G4tcsh.
|
||||
G4String prompt= "G4MPI";
|
||||
G4UItcsh* tcsh= new G4UItcsh(prompt);
|
||||
session-> SetShell(tcsh);
|
||||
|
||||
// user application setting
|
||||
G4RunManager* runManager= new G4RunManager();
|
||||
|
||||
// ....
|
||||
|
||||
// After user application setting, just start a MPI session.
|
||||
// MPIsession treats both interactive and batch modes.
|
||||
session-> SessionStart();
|
||||
|
||||
// Finally, terminate the program
|
||||
delete g4MPI;
|
||||
delete runManager;
|
||||
}
|
||||
|
||||
|
||||
* Notes about session shell:
|
||||
|
||||
LAM/MPI users can use "G4tcsh" as an interactive session shell.
|
||||
For other users (Open MPI/MPICH2), plese use G4csh (default).
|
||||
|
||||
|
||||
How to use:
|
||||
-----------
|
||||
* MPI runtime rnvironment
|
||||
|
||||
1. Make hosts/cluster configuration of your MPI environment.
|
||||
|
||||
2. Launch MPI runtime environment, typically executing
|
||||
lamboot (LAM) / mpdboot (MPICH2).
|
||||
|
||||
* How to run
|
||||
For example,
|
||||
|
||||
> mpiexec -n # <your application>
|
||||
|
||||
Instead, "mpirun" command is more convenient for LAM users.
|
||||
|
||||
|
||||
MPI G4UI commands:
|
||||
------------------
|
||||
G4UI commands handling the G4MPI interface are placed in /mpi/.
|
||||
|
||||
Command directory path : /mpi/
|
||||
|
||||
Guidance :
|
||||
MPI control commands
|
||||
|
||||
Sub-directories :
|
||||
Commands :
|
||||
verbose * Set verbose level.
|
||||
status * Show mpi status.
|
||||
execute * Execute a macro file. (=/control/execute)
|
||||
beamOn * Start a parallel run w/ thread.
|
||||
.beamOn * Start a parallel run w/o thread. (=/run/beamOn)
|
||||
masterWeight * Set weight for master node.
|
||||
showSeeds * Show seeds of MPI nodes.
|
||||
setMasterSeed * Set a master seed for the seed generator.
|
||||
setSeed * Set a seed for a specified node.
|
||||
|
||||
* Notes:
|
||||
While "/run/beamOn" is executed in foreground, the "/mpi/beamOn"
|
||||
command invokes beam-on in background, so you can input UI commands
|
||||
even while event processing.
|
||||
|
||||
The original "/control/execute" and "/run/beamOn" are overwritten
|
||||
with "/mpi/execute" and "/mpi/.beamOn" commands, customized for
|
||||
the MPI interface.
|
||||
|
||||
|
||||
Examples
|
||||
========
|
||||
There are a couple of examples for Geant4 MPI applications.
|
||||
|
||||
In some cases, you need to set some additional environment variables
|
||||
for running examples:
|
||||
|
||||
- G4LEVELGAMMADATA : directory path for the data of
|
||||
"low energy electromagnetic processes".
|
||||
|
||||
For running ROOT applications,
|
||||
|
||||
- ROOTSYS : root path of the ROOT package
|
||||
- LD_LIBRARY_PATH : add ROOT library path, such as $(ROOTSYS)/lib/root
|
||||
|
||||
|
||||
[exMPI01]
|
||||
A simple application.
|
||||
|
||||
* Geometry : chamber / calorimeter
|
||||
* Primary : particle gun (200 MeV electron as default)
|
||||
* Physics List : standard EM
|
||||
|
||||
- Particles are transported in a geometry without any scoring.
|
||||
- Learn how to parallelize your G4 session.
|
||||
|
||||
|
||||
[exMPI02] (ROOT application)
|
||||
An example of dosimetry in a water phantom.
|
||||
|
||||
* Geometry : water phantom
|
||||
* Primary : particle gun (200 MeV proton as default)
|
||||
* Physics List : QGSP_BIC
|
||||
|
||||
- Score dose distribution in a water phantom.
|
||||
- Learn how to paralleize your applications.
|
||||
- Create a ROOT file containing histograms in each node.
|
||||
* treat multiple outputs properly:
|
||||
each slave node generate a ROOT file, whose file name should
|
||||
be different from each other.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# $Id: GNUmakefile,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building G4 MPI aplication
|
||||
# ===========================================================
|
||||
name := exMPI01#
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
G4WORKDIR := .
|
||||
|
||||
.PHONY: all
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
include ../mpi_interface/G4MPI.gmk
|
||||
|
||||
LDLIBS1 += -lG4UImpi
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
$Id: History,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
exMPI01 History
|
||||
---------------
|
||||
|
||||
16 Nov. 2007 K.Murakami
|
||||
- commited to G4 CVS.
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
$Id: README,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Example MPI01
|
||||
-------------
|
||||
|
||||
A simple application.
|
||||
|
||||
* Geometry : chamber / calorimeter
|
||||
* Primary : particle gun (200 MeV electron as default)
|
||||
* Physics List : standard EM
|
||||
|
||||
- Particles are transported in a geometry without any scoring.
|
||||
- Learn how to parallelized your G4 session.
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exMPI01.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// exMPI01.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#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"
|
||||
#include "G4UItcsh.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "G4VisExecutive.hh"
|
||||
#endif
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
// random engine
|
||||
//CLHEP::HepJamesRandom randomEngine;
|
||||
CLHEP::Ranlux64Engine randomEngine;
|
||||
CLHEP::HepRandom::setTheEngine(&randomEngine);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// MPI session
|
||||
// --------------------------------------------------------------------
|
||||
// At first, G4MPImanager/G4MPIsession should be created.
|
||||
G4MPImanager* g4MPI= new G4MPImanager(argc,argv);
|
||||
|
||||
// MPI session (G4MPIsession) instead of G4UIterminal
|
||||
// Terminal availability depends on your MPI implementation.
|
||||
G4MPIsession* session= g4MPI-> GetMPIsession();
|
||||
|
||||
// LAM/MPI users can use G4tcsh.
|
||||
G4String prompt= "[40;01;33m";
|
||||
prompt+= "G4MPI";
|
||||
prompt+= "[40;31m(%s)[40;36m[%/][00;30m:";
|
||||
|
||||
G4UItcsh* tcsh= new G4UItcsh(prompt);
|
||||
tcsh-> SetLsColor(BLUE,RED);
|
||||
session-> SetShell(tcsh);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// user application setting
|
||||
// --------------------------------------------------------------------
|
||||
G4RunManager* runManager= new G4RunManager();
|
||||
|
||||
// setup your application
|
||||
runManager-> SetUserInitialization(new DetectorConstruction);
|
||||
runManager-> SetUserInitialization(new PhysicsList);
|
||||
runManager-> SetUserAction(new PrimaryGeneratorAction);
|
||||
|
||||
runManager-> Initialize();
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
G4VisExecutive* visManager= new G4VisExecutive;
|
||||
visManager-> Initialize();
|
||||
G4cout << G4endl;
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// ready for go
|
||||
// MPIsession treats both interactive and batch modes.
|
||||
// Just start your session as below.
|
||||
// --------------------------------------------------------------------
|
||||
session-> SessionStart();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// termination
|
||||
// --------------------------------------------------------------------
|
||||
#ifdef G4VIS_USE
|
||||
delete visManager;
|
||||
#endif
|
||||
|
||||
delete g4MPI;
|
||||
|
||||
delete runManager;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// DetectorConstruction.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef DETECTOR_CONSTRUCTION_H
|
||||
#define DETECTOR_CONSTRUCTION_H
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Materials.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// Materials.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef MATERIALS_H
|
||||
#define MATERIALS_H
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class Materials {
|
||||
|
||||
public:
|
||||
Materials();
|
||||
~Materials();
|
||||
|
||||
void Construct();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Particles.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// Particles.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef PARTICLES_H
|
||||
#define PARTICLES_H
|
||||
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class Particles : public G4VPhysicsConstructor {
|
||||
|
||||
public:
|
||||
Particles();
|
||||
~Particles();
|
||||
|
||||
virtual void ConstructParticle();
|
||||
virtual void ConstructProcess();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsList.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// PhysicsList.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef PHYSICS_LIST_H
|
||||
#define PHYSICS_LIST_H
|
||||
|
||||
#include "G4VModularPhysicsList.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class PhysicsList: public G4VModularPhysicsList {
|
||||
public:
|
||||
PhysicsList();
|
||||
~PhysicsList();
|
||||
|
||||
virtual void SetCuts();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsListEMstd.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// PhysicsListEMstd.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef PHYSICS_LIST_EM_STD_H
|
||||
#define PHYSICS_LIST_EM_STD_H
|
||||
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class PhysicsListEMstd : public G4VPhysicsConstructor {
|
||||
|
||||
public:
|
||||
PhysicsListEMstd();
|
||||
~PhysicsListEMstd();
|
||||
|
||||
virtual void ConstructParticle();
|
||||
virtual void ConstructProcess();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// PrimaryGeneratorAction.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef PRIMARY_GENERATOR_ACTION_H
|
||||
#define PRIMARY_GENERATOR_ACTION_H
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
|
||||
|
||||
private:
|
||||
G4ParticleGun* particleGun;
|
||||
|
||||
public:
|
||||
PrimaryGeneratorAction();
|
||||
~PrimaryGeneratorAction();
|
||||
|
||||
virtual void GeneratePrimaries(G4Event* anEvent);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// DetectorConstruction.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "Materials.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
// constants (detector parameters)
|
||||
static const G4double DXYZ_AREA= 32.*cm;
|
||||
static const G4double DW= 10.*cm;
|
||||
|
||||
////////////////////////////////////////////
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
/////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
///////////////////////////////////////////////////
|
||||
{
|
||||
// material definition
|
||||
Materials* materialConstruction= new Materials;
|
||||
materialConstruction-> Construct();
|
||||
|
||||
G4Material* mate;
|
||||
G4VisAttributes* va;
|
||||
|
||||
// ==============================================================
|
||||
// world volume
|
||||
// ==============================================================
|
||||
G4Box* areaSolid= new G4Box("AREA",
|
||||
DXYZ_AREA/2., DXYZ_AREA/2., DXYZ_AREA/2.);
|
||||
|
||||
G4Material* vacuum= G4Material::GetMaterial("Vacuum");
|
||||
G4LogicalVolume* areaLV= new G4LogicalVolume(areaSolid, vacuum, "AREA_LV");
|
||||
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;
|
||||
const G4double dl= 10.*cm;
|
||||
|
||||
G4Box* svoxel= new G4Box("voxel", dvoxel, dl, dvoxel);
|
||||
mate= G4Material::GetMaterial("Vacuum");
|
||||
G4LogicalVolume* lvoxel= new G4LogicalVolume(svoxel, mate, "voxel");
|
||||
va= new G4VisAttributes(G4Color(0.,0.8,0.8));
|
||||
va-> SetVisibility(false);
|
||||
lvoxel-> SetVisAttributes(va);
|
||||
|
||||
G4int ix, iz;
|
||||
G4int index=0;
|
||||
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),
|
||||
lvoxel, "voxel", areaLV, false, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// tube
|
||||
//G4Tubs* stube= new G4Tubs("tube", 15./2.*mm, 19./2.*mm, dl,
|
||||
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));
|
||||
ltube-> SetVisAttributes(va);
|
||||
|
||||
G4RotationMatrix* rmtube= new G4RotationMatrix;
|
||||
rmtube-> rotateX(-90.*deg);
|
||||
new G4PVPlacement(rmtube, G4ThreeVector(),
|
||||
ltube, "tube", lvoxel, false, 0);
|
||||
|
||||
// cal
|
||||
const G4double dxycal= 25.*mm;
|
||||
const G4double dzcal= 3.*cm;
|
||||
|
||||
G4Box* scal= new G4Box("cal", dxycal, dxycal, dzcal);
|
||||
mate= G4Material::GetMaterial("CsI");
|
||||
G4LogicalVolume* lcal= new G4LogicalVolume(scal, mate, "cal");
|
||||
va= new G4VisAttributes(G4Color(0.5,0.5,0.));
|
||||
lcal-> SetVisAttributes(va);
|
||||
|
||||
index= 0;
|
||||
for (ix=-2; ix<=2; ix++) {
|
||||
G4double x0= (5.*ix)*cm;
|
||||
new G4PVPlacement(0, G4ThreeVector(x0, 0., 2.*cm),
|
||||
lcal, "cal", areaLV, false, index);
|
||||
index++;
|
||||
}
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Materials.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// Materials.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "Materials.hh"
|
||||
#include "G4Material.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////
|
||||
Materials::Materials()
|
||||
//////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
Materials::~Materials()
|
||||
///////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
void Materials::Construct()
|
||||
///////////////////////////
|
||||
{
|
||||
G4double A, Z;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Elements
|
||||
// ------------------------------------------------------------------------
|
||||
G4Element* elH = new G4Element("Hydrogen","H", Z=1., A=1.00794*g/mole);
|
||||
G4Element* elC = new G4Element("Carbon", "C", Z=6., A= 12.011 *g/mole);
|
||||
G4Element* elN = new G4Element("Nitrogen","N", Z=7., A= 14.00674*g/mole);
|
||||
G4Element* elO = new G4Element("Oxygen", "O", Z=8., A= 15.9994*g/mole);
|
||||
G4Element* elNa = new G4Element("Sodium", "Na", Z=11., A= 22.989768*g/mole);
|
||||
G4Element* elSi = new G4Element("Silicon", "Si", Z=14., A= 28.0855*g/mole);
|
||||
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
|
||||
// ------------------------------------------------------------------------
|
||||
G4double density, massfraction;
|
||||
G4int natoms, nel;
|
||||
|
||||
// temperature of experimental hall is controlled at 20 degree.
|
||||
const G4double expTemp= STP_Temperature+20.*kelvin;
|
||||
|
||||
// vacuum
|
||||
density= universe_mean_density;
|
||||
G4Material* Vacuum= new G4Material("Vacuum", density, nel=2);
|
||||
Vacuum-> AddElement(elN, .7);
|
||||
Vacuum-> AddElement(elO, .3);
|
||||
|
||||
// air
|
||||
density= 1.2929e-03 *g/cm3; // at 20 degree
|
||||
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);
|
||||
Air-> AddElement(elO, massfraction= 23.20/ttt);
|
||||
Air-> AddElement(elAr, massfraction= 1.28/ttt);
|
||||
|
||||
// Ar gas
|
||||
A= 39.948 *g/mole;
|
||||
const G4double denAr= 1.782e-03 *g/cm3 * STP_Temperature/expTemp;
|
||||
G4Material* Ar= new G4Material("ArgonGas", Z=18., A, denAr,
|
||||
kStateGas, expTemp);
|
||||
|
||||
// ethane (C2H6)
|
||||
const G4double denEthane= 1.356e-3 *g/cm3 * STP_Temperature/expTemp;
|
||||
G4Material* Ethane= new G4Material("Ethane", denEthane, nel=2,
|
||||
kStateGas, expTemp);
|
||||
Ethane-> AddElement(elC, natoms=2);
|
||||
Ethane-> AddElement(elH, natoms=6);
|
||||
|
||||
// Ar(50%) + ethane(50%) mixture
|
||||
density= (denAr+denEthane)/2.;
|
||||
G4Material* ArEthane= new G4Material("ArEthane", density, nel=2,
|
||||
kStateGas, expTemp);
|
||||
ArEthane-> AddMaterial(Ar, massfraction= denAr/density/2.);
|
||||
ArEthane-> AddMaterial(Ethane, massfraction= denEthane/density/2.);
|
||||
|
||||
// silicon
|
||||
A= 28.0855 *g/mole;
|
||||
density= 2.33 *g/cm3;
|
||||
new G4Material("SiliconWafer", Z=14., A, density);
|
||||
|
||||
// alminium
|
||||
A= 26.98 *g/mole;
|
||||
density= 2.70 *g/cm3;
|
||||
new G4Material("Al", Z=13., A, density);
|
||||
|
||||
// iron
|
||||
A= 55.847 *g/mole;
|
||||
density= 7.87 *g/cm3;
|
||||
new G4Material("Iron", Z=26., A, density);
|
||||
|
||||
// lead
|
||||
A= 207.2 *g/mole;
|
||||
density= 11.35 *g/cm3;
|
||||
new G4Material("Lead", Z=82., A, density);
|
||||
|
||||
// scintillator (Polystyene(C6H5CH=CH2))
|
||||
density= 1.032 *g/cm3;
|
||||
G4Material* Scinti= new G4Material("Scinti", density, nel=2);
|
||||
Scinti-> AddElement(elC, natoms=8);
|
||||
Scinti-> AddElement(elH, natoms=8);
|
||||
|
||||
// quartz (SiO2, crystalline)
|
||||
density= 2.64 *g/cm3;
|
||||
G4Material* Quartz= new G4Material("Quartz", density, nel= 2);
|
||||
Quartz-> AddElement(elSi, natoms=1);
|
||||
Quartz-> AddElement(elO, natoms=2);
|
||||
|
||||
// NaI crystal
|
||||
density= 3.67 *g/cm3;
|
||||
G4Material* NaI= new G4Material("NaI", density, nel= 2);
|
||||
NaI-> AddElement(elNa, natoms=1);
|
||||
NaI-> AddElement(elI, natoms=1);
|
||||
|
||||
// CsI crystal
|
||||
density= 4.51 *g/cm3;
|
||||
G4Material* CsI= new G4Material("CsI", density, nel= 2);
|
||||
CsI-> AddElement(elCs, natoms=1);
|
||||
CsI-> AddElement(elI, natoms=1);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Particles.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// Particles.cc
|
||||
// Physics list for defining particles
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "Particles.hh"
|
||||
|
||||
#include "G4LeptonConstructor.hh"
|
||||
#include "G4BosonConstructor.hh"
|
||||
#include "G4MesonConstructor.hh"
|
||||
#include "G4BaryonConstructor.hh"
|
||||
#include "G4ShortLivedConstructor.hh"
|
||||
#include "G4IonConstructor.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////
|
||||
Particles::Particles()
|
||||
: G4VPhysicsConstructor("Particles")
|
||||
//////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
Particles::~Particles()
|
||||
///////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
void Particles::ConstructParticle()
|
||||
///////////////////////////////////
|
||||
{
|
||||
G4LeptonConstructor::ConstructParticle();
|
||||
G4BosonConstructor::ConstructParticle();
|
||||
G4MesonConstructor::ConstructParticle();
|
||||
G4BaryonConstructor::ConstructParticle();
|
||||
G4ShortLivedConstructor::ConstructParticle();
|
||||
G4IonConstructor::ConstructParticle();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
void Particles::ConstructProcess()
|
||||
//////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsList.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// PhysicsList.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "PhysicsList.hh"
|
||||
#include "Particles.hh"
|
||||
#include "PhysicsListEMstd.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
///////////////////////////
|
||||
PhysicsList::PhysicsList()
|
||||
: G4VModularPhysicsList()
|
||||
////////////////////////////
|
||||
{
|
||||
// default cut value (1.0mm)
|
||||
defaultCutValue = 1.*mm;
|
||||
SetVerboseLevel(1);
|
||||
|
||||
// particles
|
||||
RegisterPhysics(new Particles);
|
||||
|
||||
// EM Physics
|
||||
RegisterPhysics(new PhysicsListEMstd);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
PhysicsList::~PhysicsList()
|
||||
///////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
void PhysicsList::SetCuts()
|
||||
///////////////////////////
|
||||
{
|
||||
// " G4VUserPhysicsList::SetCutsWithDefault" method sets
|
||||
// the default cut value for all particle types
|
||||
SetCutsWithDefault();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsListEMstd.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// PhysicsListEMstd.cc
|
||||
// Physics list for electron/positron/gamma
|
||||
// EM-standard package w/ default parameters
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#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 "G4MultipleScattering.hh"
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////
|
||||
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
|
||||
// ----------------------------------------------------------
|
||||
G4MultipleScattering* msc= new G4MultipleScattering;
|
||||
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 G4MultipleScattering;
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// PrimaryGeneratorAction.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////////
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
////////////////////////////////////////////////
|
||||
{
|
||||
particleGun= 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);
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
/////////////////////////////////////////////////
|
||||
{
|
||||
delete particleGun;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
////////////////////////////////////////////////////////////////
|
||||
{
|
||||
particleGun-> GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/vis/open OGLIX
|
||||
|
||||
/vis/scene/create
|
||||
/vis/scene/add/volume
|
||||
|
||||
/vis/sceneHandler/attach
|
||||
|
||||
/vis/viewer/set/viewpointThetaPhi 90. 270.
|
||||
|
||||
/tracking/storeTrajectory 1
|
||||
/vis/scene/add/trajectories
|
||||
/vis/scene/endOfEventAction accumulate
|
||||
#/vis/scene/endOfEventAction refresh
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# $Id: GNUmakefile,v 1.1 2007/11/16 14:28:34 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building G4 MPI aplication
|
||||
# ===========================================================
|
||||
name := exMPI02#
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
G4WORKDIR := .
|
||||
|
||||
.PHONY: all
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
include ../mpi_interface/G4MPI.gmk
|
||||
|
||||
LDLIBS1 += -lG4UImpi
|
||||
|
||||
ifdef ROOTSYS
|
||||
CPPFLAGS += -I$(shell $(ROOTSYS)/bin/root-config --incdir)
|
||||
LDLIBS += $(shell $(ROOTSYS)/bin/root-config --libs)
|
||||
endif
|
||||
|
||||
ifeq ($(G4SYSTEM),Linux-g++)
|
||||
LDLIBS += -Wl,-rpath,$(shell $(ROOTSYS)/bin/root-config --libdir)
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
$Id: History,v 1.1 2007/11/16 14:28:34 kmura Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
exMPI02 History
|
||||
---------------
|
||||
|
||||
16 Nov. 2007 K.Murakami
|
||||
- commited to G4 CVS.
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
$Id: README,v 1.1 2007/11/16 14:28:34 kmura Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Example MPI02
|
||||
-------------
|
||||
|
||||
An example of dosimetry in a water phantom.
|
||||
|
||||
* Geometry : water phantom
|
||||
* Primary : broad beam (200 MeV proton)
|
||||
* Physics List : QGSP_BIC
|
||||
You need to set an additional environment variable;
|
||||
$G4LEVELGAMMADATA indicates a directory path for the data of
|
||||
"low energy electromagnetic processes".
|
||||
* Analysis : ROOT histogramming
|
||||
ROOT should be installed under $ROOTSYS.
|
||||
|
||||
- Score dose distribution in a water phantom.
|
||||
- Learn how to paralleized your applications.
|
||||
- Create a ROOT file containing histograms/trees in each node.
|
||||
* treat multiple outputs properly:
|
||||
each slave node generate a ROOT file, whose file name should
|
||||
be different from each other.
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exMPI02.cc,v 1.1 2007/11/16 14:28:34 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// exMPI02.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
// my application
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "MedicalBeam.hh"
|
||||
#include "QGSP_BIC.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
|
||||
// MPI session
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
#include "G4UItcsh.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "G4VisExecutive.hh"
|
||||
#endif
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
// random engine
|
||||
//CLHEP::Ranlux64Engine randomEngine;
|
||||
//CLHEP::HepRandom::setTheEngine(&randomEngine);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// MPI session
|
||||
// --------------------------------------------------------------------
|
||||
// At first, G4MPImanager/G4MPIsession should be created.
|
||||
G4MPImanager* g4MPI= new G4MPImanager(argc,argv);
|
||||
|
||||
// MPI session (G4MPIsession) instead of G4UIterminal
|
||||
// Terminal availability depends on your MPI implementation.
|
||||
G4MPIsession* session= g4MPI-> GetMPIsession();
|
||||
|
||||
// LAM/MPI users can use G4tcsh.
|
||||
G4String prompt= "[40;01;33m";
|
||||
prompt+= "G4MPI";
|
||||
prompt+= "[40;31m(%s)[40;36m[%/][00;30m:";
|
||||
|
||||
G4UItcsh* tcsh= new G4UItcsh(prompt);
|
||||
tcsh-> SetLsColor(BLUE,RED);
|
||||
session-> SetShell(tcsh);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// user application setting
|
||||
// --------------------------------------------------------------------
|
||||
G4RunManager* runManager= new G4RunManager();
|
||||
|
||||
// setup your application
|
||||
runManager-> SetUserInitialization(new DetectorConstruction);
|
||||
runManager-> SetUserInitialization(new QGSP_BIC);
|
||||
runManager-> SetUserAction(new MedicalBeam);
|
||||
runManager-> SetUserAction(new RunAction);
|
||||
runManager-> SetUserAction(new EventAction);
|
||||
|
||||
runManager-> Initialize();
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
G4VisExecutive* visManager= new G4VisExecutive;
|
||||
visManager-> Initialize();
|
||||
G4cout << G4endl;
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// ready for go
|
||||
// MPIsession treats both interactive and batch modes.
|
||||
// Just start your session as below.
|
||||
// --------------------------------------------------------------------
|
||||
session-> SessionStart();
|
||||
|
||||
|
||||
// termination
|
||||
#ifdef G4VIS_USE
|
||||
delete visManager;
|
||||
#endif
|
||||
|
||||
delete g4MPI;
|
||||
|
||||
delete runManager;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Analysis.hh,v 1.1 2007/11/16 14:29:32 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// Analysis.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef ANALYSIS_MANAGER_H
|
||||
#define ANALYSIS_MANAGER_H
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class TH1D;
|
||||
class TH2D;
|
||||
|
||||
class Analysis {
|
||||
private:
|
||||
static Analysis* myanalysis;
|
||||
|
||||
TH2D* incident_map;
|
||||
TH1D* incident_x_hist;
|
||||
|
||||
TH2D* dose_map;
|
||||
TH1D* dose_hist;
|
||||
|
||||
Analysis(); // protected
|
||||
|
||||
G4bool incidentFlag;
|
||||
|
||||
public:
|
||||
~Analysis();
|
||||
|
||||
static Analysis* GetAnalysis();
|
||||
|
||||
void Update();
|
||||
void Clear();
|
||||
void Save(const G4String& fname);
|
||||
|
||||
void FillIncident(const G4ThreeVector& p);
|
||||
void FillDose(const G4ThreeVector& p, G4double dedx);
|
||||
|
||||
void ClearIncidentFlag();
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
|
||||
inline void Analysis::ClearIncidentFlag()
|
||||
{ incidentFlag= false; }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.hh,v 1.1 2007/11/16 14:29:32 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// DetectorConstruction.hh
|
||||
//
|
||||
// Q
|
||||
// ====================================================================
|
||||
#ifndef DETECTOR_CONSTRUCTION_H
|
||||
#define DETECTOR_CONSTRUCTION_H
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
|
||||
public:
|
||||
DetectorConstruction();
|
||||
~DetectorConstruction();
|
||||
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventAction.hh,v 1.2 2007/12/10 16:28:34 gunter Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// EventAction.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef EVENT_ACTION_H
|
||||
#define EVENT_ACTION_H
|
||||
|
||||
#include "G4UserEventAction.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class EventAction : public G4UserEventAction {
|
||||
|
||||
public:
|
||||
EventAction();
|
||||
~EventAction();
|
||||
|
||||
virtual void BeginOfEventAction(const G4Event* aevent);
|
||||
virtual void EndOfEventAction(const G4Event* aevent);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: MedicalBeam.hh,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// MedicalBeam.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef MEDICAL_BEAM_H
|
||||
#define MEDICAL_BEAM_H
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleDefinition;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class MedicalBeam : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
enum FieldShape{ SQUARE=0, CIRCLE };
|
||||
|
||||
protected:
|
||||
G4ParticleDefinition* particle;
|
||||
G4double kineticE;
|
||||
G4ThreeVector sourcePosition;
|
||||
|
||||
G4double SSD; // (SSD= Source Skin Depth)
|
||||
FieldShape fieldShape;
|
||||
G4double fieldXY[2];
|
||||
G4double fieldR;
|
||||
|
||||
// local methods...
|
||||
G4ThreeVector GenerateBeamDirection() const;
|
||||
|
||||
public:
|
||||
MedicalBeam();
|
||||
~MedicalBeam();
|
||||
|
||||
// set/get functions...
|
||||
void SetParticleDefinition(G4ParticleDefinition* pd);
|
||||
const G4ParticleDefinition* GetParticleDefinition() const;
|
||||
|
||||
void SetKineticE(G4double e);
|
||||
G4double GetKineticE() const;
|
||||
|
||||
void SetSourcePosition(const G4ThreeVector& pos);
|
||||
G4ThreeVector GetSourcePosition() const;
|
||||
|
||||
void SetFieldShape(FieldShape shape);
|
||||
FieldShape GetFieldShape() const;
|
||||
|
||||
void SetSSD(G4double ssd);
|
||||
G4double GetSSD() const;
|
||||
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
inline void MedicalBeam::SetParticleDefinition(G4ParticleDefinition* pd)
|
||||
{ particle= pd; }
|
||||
|
||||
inline const G4ParticleDefinition* MedicalBeam::GetParticleDefinition() const
|
||||
{ return particle; }
|
||||
|
||||
inline void MedicalBeam::SetKineticE(G4double e)
|
||||
{ kineticE= e; }
|
||||
|
||||
inline G4double MedicalBeam::GetKineticE() const
|
||||
{ return kineticE; }
|
||||
|
||||
inline void MedicalBeam::SetSourcePosition(const G4ThreeVector& pos)
|
||||
{ sourcePosition= pos; }
|
||||
|
||||
inline G4ThreeVector MedicalBeam::GetSourcePosition() const
|
||||
{ return sourcePosition; }
|
||||
|
||||
inline void MedicalBeam::SetFieldShape(MedicalBeam::FieldShape shape)
|
||||
{ fieldShape= shape; }
|
||||
|
||||
inline MedicalBeam::FieldShape MedicalBeam::GetFieldShape() const
|
||||
{ return fieldShape; }
|
||||
|
||||
inline void MedicalBeam::SetSSD(G4double ssd)
|
||||
{ SSD= ssd; }
|
||||
|
||||
inline G4double MedicalBeam::GetSSD() const
|
||||
{ return SSD; }
|
||||
|
||||
inline void MedicalBeam::SetFieldXY(G4double fx, G4double fy)
|
||||
{ fieldXY[0]= fx; fieldXY[1]= fy; }
|
||||
|
||||
inline G4double MedicalBeam::GetFieldX() const
|
||||
{ return fieldXY[0]; }
|
||||
|
||||
inline G4double MedicalBeam::GetFieldY() const
|
||||
{ return fieldXY[1]; }
|
||||
|
||||
inline void MedicalBeam::SetFieldR(G4double r)
|
||||
{ fieldR= r; }
|
||||
|
||||
inline G4double MedicalBeam::GetFieldR() const
|
||||
{ return fieldR; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.hh,v 1.2 2007/12/10 16:28:39 gunter Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// RunAction.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef RUN_ACTION_H
|
||||
#define RUN_ACTION_H
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class RunAction : public G4UserRunAction {
|
||||
|
||||
public:
|
||||
RunAction();
|
||||
~RunAction();
|
||||
|
||||
virtual void BeginOfRunAction(const G4Run* arun);
|
||||
virtual void EndOfRunAction(const G4Run* arun);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelParam.hh,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// VoxelParam.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef VOXEL_PARAM_H
|
||||
#define VOXEL_PARAM_H
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class VoxelParam : public G4VPVParameterisation {
|
||||
|
||||
public:
|
||||
VoxelParam();
|
||||
~VoxelParam();
|
||||
|
||||
virtual void ComputeTransformation(const G4int id,
|
||||
G4VPhysicalVolume* vol) const;
|
||||
|
||||
virtual void ComputeDimensions(G4Box& box, const G4int id,
|
||||
const G4VPhysicalVolume* vol) const;
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Trd&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Trap&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
virtual void ComputeDimensions
|
||||
(G4Cons&,const G4int,const G4VPhysicalVolume*) const {}
|
||||
|
||||
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 {}
|
||||
|
||||
|
||||
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 {}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelSD.hh,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// VoxelSD.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef VOXEL_SD_H
|
||||
#define VOXEL_SD_H
|
||||
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class VoxelSD : public G4VSensitiveDetector {
|
||||
|
||||
public:
|
||||
VoxelSD(const G4String& name);
|
||||
~VoxelSD();
|
||||
|
||||
// virtual methods
|
||||
virtual G4bool ProcessHits(G4Step* astep, G4TouchableHistory* rohist);
|
||||
virtual void Initialize(G4HCofThisEvent* HCTE);
|
||||
virtual void EndOfEvent(G4HCofThisEvent* HCTE);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,179 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Analysis.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// Analysis.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "Analysis.hh"
|
||||
|
||||
// ROOT headers
|
||||
#include "TROOT.h"
|
||||
#include "TFile.h"
|
||||
#include "TH1.h"
|
||||
#include "TH2.h"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
Analysis* Analysis::myanalysis= 0;
|
||||
|
||||
|
||||
////////////////////
|
||||
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=0;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
Analysis* Analysis::GetAnalysis()
|
||||
/////////////////////////////////
|
||||
{
|
||||
if (myanalysis == 0) {
|
||||
myanalysis = new Analysis();
|
||||
}
|
||||
|
||||
return myanalysis;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
void Analysis::Update()
|
||||
///////////////////////
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
void Analysis::Clear()
|
||||
//////////////////////
|
||||
{
|
||||
incident_map-> Reset();
|
||||
incident_x_hist-> Reset();
|
||||
dose_map-> Reset();
|
||||
dose_hist-> Reset();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
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();
|
||||
|
||||
file-> Close();
|
||||
|
||||
delete file;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
void Analysis::FillIncident(const G4ThreeVector& p)
|
||||
///////////////////////////////////////////////////
|
||||
{
|
||||
if(! incidentFlag) {
|
||||
incident_map-> Fill(p.x()/cm, p.y()/cm);
|
||||
incident_x_hist-> Fill(p.x()/cm);
|
||||
|
||||
incidentFlag= true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// DetectorConstruction.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "VoxelParam.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "VoxelSD.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
typedef G4LogicalVolume G4LV;
|
||||
typedef G4PVPlacement G4PVP;
|
||||
typedef G4VisAttributes G4VA;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
/////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
////////////////////////////////////////////////////
|
||||
{
|
||||
G4NistManager* nistManager= G4NistManager::Instance();
|
||||
G4VisAttributes* va;
|
||||
|
||||
// ==============================================================
|
||||
// world volume
|
||||
// ==============================================================
|
||||
const G4double DXYZ_WORLD= 200.*cm;
|
||||
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",
|
||||
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",
|
||||
DXY_PHANTOM/2., DXY_PHANTOM/2., DZ_PHANTOM/2.);
|
||||
|
||||
G4Material* water= nistManager-> FindOrBuildMaterial("G4_WATER");
|
||||
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
|
||||
const G4double DXY_VXP= 20.*cm;
|
||||
const G4double DZ_VXP= 1.*mm;
|
||||
|
||||
G4Box* sld_vxp= new G4Box("vxplane", DXY_VXP/2., DXY_VXP/2., DZ_VXP/2.);
|
||||
G4LV* lv_vxp= new G4LV(sld_vxp, water, "vxplane");
|
||||
|
||||
va= new G4VA(G4Color(1.,0.,0.));
|
||||
va-> SetVisibility(false);
|
||||
lv_vxp-> SetVisAttributes(va);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// 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"));
|
||||
|
||||
va= new G4VA(G4Color(0.,1.,1.));
|
||||
va-> SetVisibility(false);
|
||||
lv_voxel-> SetVisAttributes(va);
|
||||
|
||||
const G4int nvoxels= 100*100;
|
||||
new G4PVParameterised("voxle", lv_voxel, lv_vxp,
|
||||
kUndefined, nvoxels, new VoxelParam());
|
||||
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventAction.cc,v 1.2 2007/12/10 16:28:52 gunter Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// EventAction.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "EventAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "Analysis.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////
|
||||
EventAction::EventAction()
|
||||
//////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
EventAction::~EventAction()
|
||||
///////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
void EventAction::BeginOfEventAction(const G4Event*)
|
||||
////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
void EventAction::EndOfEventAction(const G4Event*)
|
||||
//////////////////////////////////////////////////
|
||||
{
|
||||
Analysis* myana= Analysis::GetAnalysis();
|
||||
myana-> ClearIncidentFlag();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: MedicalBeam.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// MedicalBeam.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "MedicalBeam.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PrimaryVertex.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
///////////////////////////////////
|
||||
MedicalBeam::MedicalBeam()
|
||||
: particle(0),
|
||||
kineticE(1.*MeV),
|
||||
sourcePosition(G4ThreeVector()),
|
||||
SSD(1.*m),
|
||||
fieldShape(MedicalBeam::SQUARE),
|
||||
fieldR(10.*cm)
|
||||
///////////////////////////////////
|
||||
{
|
||||
|
||||
G4ParticleTable* particleTable= G4ParticleTable::GetParticleTable();
|
||||
particle= particleTable-> FindParticle("proton");
|
||||
|
||||
kineticE= 200.*MeV;
|
||||
sourcePosition= G4ThreeVector(0.,0.,-125.*cm);
|
||||
SSD= 100.*cm;
|
||||
fieldXY[0]= fieldXY[1]= 5.*cm;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
MedicalBeam::~MedicalBeam()
|
||||
///////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
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.));
|
||||
} else {
|
||||
dr= fieldR;
|
||||
}
|
||||
|
||||
G4double sin0= dr/SSD;
|
||||
G4double cos0= std::sqrt(1.-sqr(sin0));
|
||||
|
||||
G4double dcos=0.;
|
||||
G4double dsin, dphi, z;
|
||||
|
||||
G4double x= DBL_MAX;
|
||||
G4double y= DBL_MAX;
|
||||
|
||||
G4double xmax, ymax;
|
||||
if(fieldShape == MedicalBeam::SQUARE) {
|
||||
xmax= fieldXY[0]/2./SSD;
|
||||
ymax= fieldXY[1]/2./SSD;
|
||||
} else {
|
||||
xmax= ymax= DBL_MAX-1.;
|
||||
}
|
||||
|
||||
while(! (std::abs(x)< xmax && std::abs(y)< ymax) ) {
|
||||
dcos= RandFlat::shoot(cos0, 1.);
|
||||
dsin= std::sqrt(1.-sqr(dcos));
|
||||
dphi= RandFlat::shoot(0., twopi);
|
||||
|
||||
x= std::cos(dphi)*dsin*dcos;
|
||||
y= std::sin(dphi)*dsin*dcos;
|
||||
}
|
||||
z= dcos;
|
||||
|
||||
return G4ThreeVector(x,y,z);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
void MedicalBeam::GeneratePrimaries(G4Event* anEvent)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
if(particle==0) return;
|
||||
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex= new G4PrimaryVertex(sourcePosition, 0.*ns);
|
||||
|
||||
// momentum
|
||||
G4double mass= particle-> GetPDGMass();
|
||||
G4double p= std::sqrt(sqr(mass+kineticE)-sqr(mass));
|
||||
G4ThreeVector pmon= p*GenerateBeamDirection();
|
||||
G4PrimaryParticle* primary= new G4PrimaryParticle(particle,
|
||||
pmon.x(),
|
||||
pmon.y(),
|
||||
pmon.z());
|
||||
// set primary to vertex
|
||||
vertex-> SetPrimary(primary);
|
||||
|
||||
// set vertex to event
|
||||
anEvent-> AddPrimaryVertex(vertex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.cc,v 1.2 2007/12/10 16:28:54 gunter Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// RunAction.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "RunAction.hh"
|
||||
#include "Analysis.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include <stdio.h>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////
|
||||
RunAction::RunAction()
|
||||
//////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
RunAction::~RunAction()
|
||||
///////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
void RunAction::BeginOfRunAction(const G4Run*)
|
||||
//////////////////////////////////////////////
|
||||
{
|
||||
Analysis* myana= Analysis::GetAnalysis();
|
||||
myana-> Clear();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
void RunAction::EndOfRunAction(const G4Run*)
|
||||
////////////////////////////////////////////
|
||||
{
|
||||
G4int rank= G4MPImanager::GetManager()-> GetRank();
|
||||
|
||||
char str[64];
|
||||
sprintf(str, "dose-%03d.root", rank);
|
||||
G4String fname(str);
|
||||
|
||||
Analysis* myana= Analysis::GetAnalysis();
|
||||
myana-> Save(fname);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelParam.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// VoxelParam.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "VoxelParam.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Box.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////
|
||||
VoxelParam::VoxelParam()
|
||||
////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
VoxelParam::~VoxelParam()
|
||||
/////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void VoxelParam::ComputeTransformation(const G4int id,
|
||||
G4VPhysicalVolume* vol) const
|
||||
////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
const G4int NX= 100;
|
||||
|
||||
G4int iy= id / NX;
|
||||
G4int ix= id % NX;
|
||||
|
||||
const G4double dxyz= 1.*mm;
|
||||
const G4double DXY= 10.*cm;
|
||||
|
||||
G4double x0= -DXY/2. + ix*dxyz;
|
||||
G4double y0= -DXY/2. + iy*dxyz;
|
||||
|
||||
vol-> SetTranslation(G4ThreeVector(x0,y0,0.));
|
||||
vol-> SetRotation(0);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
void VoxelParam::ComputeDimensions(G4Box& box, const G4int,
|
||||
const G4VPhysicalVolume*) const
|
||||
//////////////////////////////////////////////////////////////////
|
||||
{
|
||||
const G4double dxyz= 0.5*mm;
|
||||
|
||||
box.SetXHalfLength(dxyz);
|
||||
box.SetYHalfLength(dxyz);
|
||||
box.SetZHalfLength(dxyz);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: VoxelSD.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// VoxelSD.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "VoxelSD.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "Analysis.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////
|
||||
VoxelSD::VoxelSD(const G4String& name)
|
||||
: G4VSensitiveDetector(name)
|
||||
//////////////////////////////////////
|
||||
{
|
||||
G4SDManager::GetSDMpointer()-> AddNewDetector(this);
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
VoxelSD::~VoxelSD()
|
||||
///////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
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);
|
||||
|
||||
Analysis* myana= Analysis::GetAnalysis();
|
||||
|
||||
// incident position
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
void VoxelSD::Initialize(G4HCofThisEvent*)
|
||||
////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
void VoxelSD::EndOfEvent(G4HCofThisEvent*)
|
||||
////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/vis/verbose 0
|
||||
|
||||
/vis/open OGLIX
|
||||
|
||||
/vis/scene/create
|
||||
/vis/scene/add/volume
|
||||
|
||||
/vis/sceneHandler/attach
|
||||
|
||||
/vis/viewer/set/viewpointThetaPhi 90. 270.
|
||||
|
||||
/tracking/storeTrajectory 1
|
||||
/vis/scene/add/trajectories
|
||||
/vis/scene/endOfEventAction accumulate
|
||||
#/vis/scene/endOfEventAction refresh
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# $Id: G4MPI-lam.gmk,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building G4MPI (LAM)
|
||||
# ===========================================================
|
||||
|
||||
ifndef G4MPIROOT
|
||||
G4MPIROOT = /opt/lam
|
||||
endif
|
||||
|
||||
# additional flags
|
||||
CXX := mpic++
|
||||
CPPFLAGS += -I$(G4MPIROOT)/include
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# $Id: G4MPI-mpich2.gmk,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building G4MPI (MPICH2)
|
||||
# ===========================================================
|
||||
|
||||
ifndef G4MPIROOT
|
||||
G4MPIROOT = /opt/mpich2
|
||||
endif
|
||||
|
||||
# additional flags
|
||||
CXX := mpicxx
|
||||
CPPFLAGS += -I$(G4MPIROOT)/include -DMPICH_IGNORE_CXX_SEEK
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# $Id: G4MPI-openmpi.gmk,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building G4MPI (LAM)
|
||||
# ===========================================================
|
||||
|
||||
ifndef G4MPIROOT
|
||||
G4MPIROOT = /opt/ompi
|
||||
endif
|
||||
|
||||
# additional flags
|
||||
CXX := mpic++
|
||||
CPPFLAGS += -I$(G4MPIROOT)/include -I$(G4MPIROOT)/include/openmpi
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# $Id: G4MPI.gmk,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building G4MPI (LAM)
|
||||
# ===========================================================
|
||||
|
||||
ifndef G4MPIROOT
|
||||
G4MPIROOT = /opt/lam
|
||||
endif
|
||||
|
||||
# additional flags
|
||||
CXX := mpic++
|
||||
CPPFLAGS += -I$(G4MPIROOT)/include
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# $Id: GNUmakefile,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
# $Name: geant4-09-01 $
|
||||
# ===========================================================
|
||||
# Makefile for building MPI interface
|
||||
# ===========================================================
|
||||
name := G4UImpi
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
include G4MPI.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/global/HEPRandom/include \
|
||||
-I$(G4BASE)/global/HEPGeometry/include \
|
||||
-I$(G4BASE)/run/include \
|
||||
-I$(G4BASE)/event/include \
|
||||
-I$(G4BASE)/track/include \
|
||||
-I$(G4BASE)/tracking/include \
|
||||
-I$(G4BASE)/particles/management/include \
|
||||
-I$(G4BASE)/processes/management/include \
|
||||
-I$(G4BASE)/processes/cuts/include \
|
||||
-I$(G4BASE)/processes/electromagnetic/utils/include \
|
||||
-I$(G4BASE)/processes/transportation/include \
|
||||
-I$(G4BASE)/processes/decay/include \
|
||||
-I$(G4BASE)/materials/include \
|
||||
-I$(G4BASE)/geometry/management/include \
|
||||
-I$(G4BASE)/geometry/volumes/include \
|
||||
-I$(G4BASE)/geometry/navigation/include \
|
||||
-I$(G4BASE)/geometry/magneticfield/include \
|
||||
-I$(G4BASE)/geometry/biasing/include \
|
||||
-I$(G4BASE)/digits_hits/detector/include \
|
||||
-I$(G4BASE)/digits_hits/hits/include \
|
||||
-I$(G4BASE)/digits_hits/digits/include \
|
||||
-I$(G4BASE)/interfaces/common/include \
|
||||
-I$(G4BASE)/interfaces/basic/include \
|
||||
-I$(G4BASE)/intercoms/include \
|
||||
-I$(G4BASE)/graphics_reps/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
$Id: History,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
G4MPI History file
|
||||
------------------
|
||||
|
||||
16 Nov. 2007 K.Murakami
|
||||
- commited to G4 CVS.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
$Id: README,v 1.1 2007/11/16 13:32:56 kmura Exp $
|
||||
==========================================================================
|
||||
Geant4 MPI Interface
|
||||
|
||||
Author:
|
||||
Koichi Murakami (KEK) / Koichi.Murakami@kek.jp
|
||||
==========================================================================
|
||||
|
||||
How to build
|
||||
============
|
||||
|
||||
1. Check "G4MPI.gmk" for yor MPI configuration:
|
||||
|
||||
* Set "G4MPIROOT", which is the root path to your MPI library.
|
||||
* Redifine CXX as (wrapped) MPI C++ compiler.
|
||||
* Specify additional include paths and compiler flags to "CPPFLAGS".
|
||||
|
||||
Sample makefiles for (LAM, MPICH2, OpenMPI) are also presented.
|
||||
An example of "G4MPI.gmk":
|
||||
|
||||
# ===========================================================
|
||||
# Makefile for building G4MPI (LAM)
|
||||
# ===========================================================
|
||||
|
||||
ifndef G4MPIROOT
|
||||
G4MPIROOT = /opt/lam
|
||||
endif
|
||||
|
||||
# additional flags
|
||||
CXX := mpic++
|
||||
CPPFLAGS += -I$(G4MPIROOT)/include
|
||||
|
||||
|
||||
2. Build the library
|
||||
|
||||
# make
|
||||
# make includes
|
||||
|
||||
The library (libG4UImpi) will be created in $G4LIB,
|
||||
and header files will be installed into $G4INCLUDE.
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIbatch.hh,v 1.1 2007/11/16 14:05:39 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIbatch.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4MPI_BATCH_H
|
||||
#define G4MPI_BATCH_H
|
||||
|
||||
#include "G4VMPIsession.hh"
|
||||
#include <fstream>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class G4MPIbatch : public G4VMPIsession {
|
||||
protected:
|
||||
std::ifstream batchStream;
|
||||
G4bool isOpened;
|
||||
G4bool isBatchMode;
|
||||
|
||||
// get command from a batch script file
|
||||
G4String ReadCommand();
|
||||
|
||||
public:
|
||||
G4MPIbatch(const G4String& fname="", G4bool qbatch=false);
|
||||
~G4MPIbatch();
|
||||
|
||||
// concrete implementations
|
||||
virtual G4UIsession* SessionStart();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,243 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPImanager.hh,v 1.1 2007/11/16 14:05:40 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPImanager.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4MPI_MANAGER_H
|
||||
#define G4MPI_MANAGER_H
|
||||
|
||||
#include "mpi.h"
|
||||
#include "globals.hh"
|
||||
#include <pthread.h>
|
||||
#include <fstream>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class G4MPImessenger;
|
||||
class G4MPIsession;
|
||||
class G4MPIstatus;
|
||||
class G4VMPIseedGenerator;
|
||||
|
||||
class G4MPImanager {
|
||||
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;
|
||||
|
||||
// internal use
|
||||
void Initialize();
|
||||
void ParseArguments(G4int argc, char** argv);
|
||||
void Wait(G4int ausec) const;
|
||||
void UpdateStatus();
|
||||
|
||||
// for beamOn
|
||||
pthread_t threadID;
|
||||
|
||||
// seed generator
|
||||
G4VMPIseedGenerator* seedGenerator;
|
||||
|
||||
// parallel parameters
|
||||
G4double masterWeight;
|
||||
|
||||
public:
|
||||
|
||||
enum { // MPI master rank
|
||||
RANK_MASTER= 0
|
||||
};
|
||||
|
||||
enum { // MPI tag
|
||||
TAG_G4COMMAND= 100,
|
||||
TAG_G4STATUS= 200,
|
||||
TAG_G4SEED= 300,
|
||||
TAG_DATA= 1000
|
||||
};
|
||||
|
||||
G4MPImanager();
|
||||
G4MPImanager(int argc, char** argv);
|
||||
~G4MPImanager();
|
||||
|
||||
static G4MPImanager* GetManager();
|
||||
|
||||
// set/get methods
|
||||
G4MPIsession* GetMPIsession() const;
|
||||
|
||||
G4int GetVerbose() const;
|
||||
void SetVerbose(G4int iverbose);
|
||||
|
||||
G4int GetSize() const;
|
||||
G4int GetRank() const;
|
||||
|
||||
G4bool IsMaster() const;
|
||||
G4bool IsSlave() const;
|
||||
|
||||
G4bool IsInitMacro() const;
|
||||
const G4String& GetInitFileName() const;
|
||||
|
||||
G4bool IsBatchMode() const;
|
||||
const G4String& GetMacroFileName() const;
|
||||
|
||||
void SetMasterWeight(G4double aweight);
|
||||
G4double GetMasterWeight() const;
|
||||
|
||||
G4VMPIseedGenerator* GetSeedGenerator() const;
|
||||
|
||||
// MPI methods
|
||||
G4String BcastCommand(const G4String& command);
|
||||
void ShowStatus();
|
||||
void ShowSeeds();
|
||||
void SetSeed(G4int inode, G4long seed);
|
||||
|
||||
// methods for MPI environment
|
||||
void DistributeSeeds();
|
||||
void ExecuteMacroFile(const G4String& fname, G4bool qbatch=false);
|
||||
G4bool CheckThreadStatus();
|
||||
void ExecuteThreadCommand(const G4String& command);
|
||||
void ExecuteBeamOnThread(const G4String& command);
|
||||
void JoinBeamOnThread();
|
||||
|
||||
void BeamOn(G4int nevent, G4bool qdivide=true);
|
||||
void Print(const G4String& message);
|
||||
|
||||
// misc
|
||||
void ShowHelp() const;
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
|
||||
inline G4MPIsession* G4MPImanager::GetMPIsession() const
|
||||
{
|
||||
return session;
|
||||
}
|
||||
|
||||
inline G4int G4MPImanager::GetVerbose() const
|
||||
{
|
||||
return verbose;
|
||||
}
|
||||
|
||||
inline void G4MPImanager::SetVerbose(G4int iverbose)
|
||||
{
|
||||
G4int lv=iverbose;
|
||||
if(iverbose>1) lv=1;
|
||||
if(iverbose<0) lv=0;
|
||||
|
||||
verbose= lv;
|
||||
return;
|
||||
}
|
||||
|
||||
inline G4int G4MPImanager::GetRank() const
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
|
||||
inline G4int G4MPImanager::GetSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsMaster() const
|
||||
{
|
||||
return isMaster;
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsSlave() const
|
||||
{
|
||||
return isSlave;
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsInitMacro() const
|
||||
{
|
||||
return qinitmacro;
|
||||
|
||||
}
|
||||
|
||||
inline const G4String& G4MPImanager::GetInitFileName() const
|
||||
{
|
||||
return initFileName;
|
||||
|
||||
}
|
||||
|
||||
inline G4bool G4MPImanager::IsBatchMode() const
|
||||
{
|
||||
return qbatchmode;
|
||||
}
|
||||
|
||||
inline const G4String& G4MPImanager::GetMacroFileName() const
|
||||
{
|
||||
return macroFileName;
|
||||
}
|
||||
|
||||
inline void G4MPImanager::SetMasterWeight(G4double aweight)
|
||||
{
|
||||
masterWeight= aweight;
|
||||
|
||||
if(aweight<0.) masterWeight= 0.;
|
||||
if(aweight>1.) masterWeight= 1.;
|
||||
}
|
||||
|
||||
inline G4double G4MPImanager::GetMasterWeight() const
|
||||
{
|
||||
return masterWeight;
|
||||
}
|
||||
|
||||
inline G4VMPIseedGenerator* G4MPImanager::GetSeedGenerator() const
|
||||
{
|
||||
return seedGenerator;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPImessenger.hh,v 1.1 2007/11/16 14:05:40 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPImessenger.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4MPI_MESSENGER_H
|
||||
#define G4MPI_MESSENGER_H
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class G4MPImanager;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAnInteger;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithADouble;
|
||||
class G4UIcommand;
|
||||
|
||||
class G4MPImessenger : public G4UImessenger {
|
||||
private:
|
||||
G4MPImanager* g4MPI;
|
||||
|
||||
// /mpi
|
||||
G4UIdirectory* dir;
|
||||
|
||||
G4UIcmdWithAnInteger* verbose;
|
||||
G4UIcmdWithoutParameter* status;
|
||||
|
||||
G4UIcmdWithAString* execute;
|
||||
|
||||
G4UIcommand* beamOn;
|
||||
G4UIcmdWithAnInteger* dotbeamOn;
|
||||
G4UIcmdWithADouble* masterWeight;
|
||||
|
||||
G4UIcmdWithoutParameter* showSeeds;
|
||||
G4UIcmdWithAnInteger* setMasterSeed;
|
||||
G4UIcommand* setSeed;
|
||||
|
||||
public:
|
||||
G4MPImessenger(G4MPImanager* manager);
|
||||
~G4MPImessenger();
|
||||
|
||||
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
|
||||
virtual G4String GetCurrentValue(G4UIcommand* command);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIrandomSeedGenerator.hh,v 1.1 2007/11/16 14:05:40 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIrandomSeedGenerator.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4MPI_RANDOM_SEED_GENERATOR_H
|
||||
#define G4MPI_RANDOM_SEED_GENERATOR_H
|
||||
|
||||
#include "G4VMPIseedGenerator.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class G4MPIrandomSeedGenerator : public G4VMPIseedGenerator {
|
||||
protected:
|
||||
G4bool CheckDoubleCount();
|
||||
virtual void GenerateSeeds();
|
||||
|
||||
public:
|
||||
G4MPIrandomSeedGenerator();
|
||||
~G4MPIrandomSeedGenerator();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIsession.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIsession.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4MPI_SESSION_H
|
||||
#define G4MPI_SESSION_H
|
||||
|
||||
#include "G4VMPIsession.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class G4MPIsession : public G4VMPIsession {
|
||||
protected:
|
||||
G4VUIshell* shell;
|
||||
|
||||
// get command from user prompt of the master node
|
||||
G4String GetCommand(const char* msg=0);
|
||||
|
||||
// misc
|
||||
G4bool TryForcedTerminate();
|
||||
|
||||
public:
|
||||
G4MPIsession(G4VUIshell* ashell=0);
|
||||
~G4MPIsession();
|
||||
|
||||
void SetPrompt(const G4String& prompt);
|
||||
void SetShell(G4VUIshell* ashell);
|
||||
|
||||
// concrete implementations
|
||||
virtual G4UIsession* SessionStart();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIstatus.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIstatus.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4MPI_STATUS_H
|
||||
#define G4MPI_STATUS_H
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ApplicationState.hh"
|
||||
#include "G4Timer.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class G4Timer;
|
||||
|
||||
class G4MPIstatus {
|
||||
private:
|
||||
G4int rank;
|
||||
G4int runID;
|
||||
G4int nEventToBeProcessed;
|
||||
G4int eventID;
|
||||
G4double cputime;
|
||||
G4ApplicationState g4state;
|
||||
G4Timer* timer;
|
||||
|
||||
G4String GetStateString(G4ApplicationState astate) const;
|
||||
|
||||
public:
|
||||
enum { NSIZE=10 };
|
||||
|
||||
G4MPIstatus();
|
||||
~G4MPIstatus();
|
||||
|
||||
// set/get functions
|
||||
void SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid,
|
||||
G4ApplicationState state);
|
||||
|
||||
G4int GetRank() const;
|
||||
G4int GetRunID() const;
|
||||
G4int GetNEventToBeProcessed() const;
|
||||
G4int GetEventID() const;
|
||||
G4double GetCPUTime() const;
|
||||
G4ApplicationState GetG4State() const;
|
||||
|
||||
// for pickling
|
||||
G4int SizeOf() const;
|
||||
void Pack(G4int* data) const;
|
||||
void UnPack(G4int* data);
|
||||
|
||||
// for timer
|
||||
void StartTimer();
|
||||
void StopTimer();
|
||||
|
||||
void Print() const;
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
inline G4int G4MPIstatus::SizeOf() const
|
||||
{
|
||||
return NSIZE;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetRank() const
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetRunID() const
|
||||
{
|
||||
return runID;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetNEventToBeProcessed() const
|
||||
{
|
||||
return nEventToBeProcessed;
|
||||
}
|
||||
|
||||
inline G4int G4MPIstatus::GetEventID() const
|
||||
{
|
||||
return eventID;
|
||||
}
|
||||
|
||||
inline G4double G4MPIstatus::GetCPUTime() const
|
||||
{
|
||||
return cputime;
|
||||
}
|
||||
|
||||
inline G4ApplicationState G4MPIstatus::GetG4State() const
|
||||
{
|
||||
return g4state;
|
||||
}
|
||||
|
||||
inline void G4MPIstatus::StartTimer()
|
||||
{
|
||||
timer-> Start();
|
||||
}
|
||||
|
||||
inline void G4MPIstatus::StopTimer()
|
||||
{
|
||||
timer-> Stop();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4UImpish.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4UImpish.hh
|
||||
//
|
||||
// shell for MPI slaves
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4UI_MPI_SH_H
|
||||
#define G4UI_MPI_SH_H
|
||||
|
||||
#include "G4VUIshell.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class G4UImpish : public G4VUIshell {
|
||||
|
||||
public:
|
||||
G4UImpish();
|
||||
~G4UImpish();
|
||||
|
||||
virtual G4String GetCommandLine(const char* msg=0);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VMPIseedGenerator.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4VMPIseedGenerator.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4VMPI_SEED_GENERATOR_H
|
||||
#define G4VMPI_SEED_GENERATOR_H
|
||||
|
||||
#include "globals.hh"
|
||||
#include <vector>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class G4VMPIseedGenerator {
|
||||
protected:
|
||||
G4long masterSeed;
|
||||
std::vector<G4long> seedList;
|
||||
|
||||
// generate seeds for MPI nodes
|
||||
virtual void GenerateSeeds()=0;
|
||||
|
||||
public:
|
||||
G4VMPIseedGenerator();
|
||||
virtual ~G4VMPIseedGenerator();
|
||||
|
||||
// set/get methods
|
||||
void SetMasterSeed(G4long aseed); // trigger GenerateSeeds()
|
||||
G4long GetMasterSeed() const;
|
||||
|
||||
const std::vector<G4long>& GetSeedList() const;
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
inline G4long G4VMPIseedGenerator::GetMasterSeed() const
|
||||
{
|
||||
return masterSeed;
|
||||
}
|
||||
|
||||
inline const std::vector<G4long>& G4VMPIseedGenerator::GetSeedList() const
|
||||
{
|
||||
return seedList;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VMPIsession.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4VMPIsession.hh
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#ifndef G4VMPI_SESSION_H
|
||||
#define G4VMPI_SESSION_H
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
typedef void* (*Func_t)(void *); // for thead function
|
||||
|
||||
class G4MPImanager;
|
||||
class G4VUIshell;
|
||||
|
||||
class G4VMPIsession : public G4VBasicShell {
|
||||
protected:
|
||||
// MPI handling
|
||||
G4MPImanager* g4MPI;
|
||||
|
||||
// MPI node info (cache)
|
||||
G4bool isMaster;
|
||||
G4bool isSlave;
|
||||
G4int rank;
|
||||
|
||||
G4int ExecCommand(G4String aCommand);
|
||||
G4String TruncateCommand(const G4String& command) const;
|
||||
G4String BypassCommand(const G4String& command) const;
|
||||
|
||||
// for help operation
|
||||
virtual G4bool GetHelpChoice(G4int& aval);
|
||||
virtual void ExitHelp();
|
||||
|
||||
public:
|
||||
G4VMPIsession();
|
||||
~G4VMPIsession();
|
||||
|
||||
// concrete implementations
|
||||
virtual void PauseSessionStart(G4String msg);
|
||||
|
||||
virtual G4int ReceiveG4cout(G4String coutString);
|
||||
virtual G4int ReceiveG4cerr(G4String cerrString);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIbatch.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIsession.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4MPIbatch.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
G4MPIbatch::G4MPIbatch(const G4String& fname, G4bool qbatch)
|
||||
: G4VMPIsession(),
|
||||
isOpened(false), isBatchMode(qbatch)
|
||||
////////////////////////////////////////////////////////////
|
||||
{
|
||||
if(isMaster) {
|
||||
batchStream.open(fname, std::ios::in);
|
||||
if(batchStream.fail()) {
|
||||
G4cerr << "cannot open a macro file(" << fname << ")."
|
||||
<< G4endl;
|
||||
} else {
|
||||
isOpened= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
G4MPIbatch::~G4MPIbatch()
|
||||
/////////////////////////////
|
||||
{
|
||||
if(isOpened) batchStream.close();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
G4String G4MPIbatch::ReadCommand()
|
||||
//////////////////////////////////
|
||||
{
|
||||
enum { BUFSIZE= 256 };
|
||||
char linebuf[BUFSIZE];
|
||||
|
||||
while(batchStream.good()) {
|
||||
batchStream.getline(linebuf, BUFSIZE);
|
||||
|
||||
G4String cmdline(linebuf);
|
||||
cmdline= cmdline.strip(G4String::both);
|
||||
cmdline= cmdline.strip(G4String::both, '\011'); // remove TAB
|
||||
cmdline= TruncateCommand(cmdline);
|
||||
|
||||
str_size ic= cmdline.find_first_of('#');
|
||||
if(ic != G4String::npos) {
|
||||
cmdline= cmdline(0, ic);
|
||||
}
|
||||
|
||||
if(batchStream.eof()) {
|
||||
if(cmdline.size()==0) {
|
||||
return "exit";
|
||||
} else {
|
||||
return cmdline;
|
||||
}
|
||||
}
|
||||
|
||||
if(cmdline.size()==0) continue; // skip null line
|
||||
return cmdline;
|
||||
}
|
||||
|
||||
return "exit"; // dummy
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
G4UIsession* G4MPIbatch::SessionStart()
|
||||
///////////////////////////////////////
|
||||
{
|
||||
G4String newCommand="", scommand; // newCommand is always "" in slaves
|
||||
|
||||
if(isMaster) newCommand= ReadCommand();
|
||||
// broadcast a new G4 command
|
||||
scommand= g4MPI-> BcastCommand(newCommand);
|
||||
if(scommand == "exit" ) return 0;
|
||||
|
||||
while(1){
|
||||
G4int rc= ExecCommand(scommand);
|
||||
if(rc != fCommandSucceeded) break;
|
||||
|
||||
if(isMaster) newCommand= ReadCommand();
|
||||
scommand= g4MPI-> BcastCommand(newCommand);
|
||||
if(scommand == "exit" ) {
|
||||
if(isBatchMode) {
|
||||
if(g4MPI-> CheckThreadStatus()) {
|
||||
g4MPI-> JoinBeamOnThread();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,592 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPImanager.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPImanager.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4MPImessenger.hh"
|
||||
#include "G4MPIsession.hh"
|
||||
#include "G4MPIbatch.hh"
|
||||
#include "G4MPIstatus.hh"
|
||||
#include "G4MPIrandomSeedGenerator.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Run.hh"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
|
||||
G4MPImanager* G4MPImanager::theManager= 0;
|
||||
|
||||
// ====================================================================
|
||||
// wrappers for thread functions
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
static void thread_ExecuteThreadCommand(const G4String* command)
|
||||
////////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4MPImanager::GetManager()-> ExecuteThreadCommand(*command);
|
||||
}
|
||||
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////
|
||||
G4MPImanager::G4MPImanager()
|
||||
: verbose(0),
|
||||
qfcout(false),
|
||||
qinitmacro(false),
|
||||
qbatchmode(false),
|
||||
threadID(0),
|
||||
masterWeight(1.)
|
||||
////////////////////////////
|
||||
{
|
||||
//MPI::Init();
|
||||
MPI::Init_thread(MPI::THREAD_SERIALIZED);
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
G4MPImanager::G4MPImanager(int argc, char** argv)
|
||||
: verbose(0), qfcout(false),
|
||||
qinitmacro(false), qbatchmode(false),
|
||||
threadID(0),
|
||||
masterWeight(1.)
|
||||
/////////////////////////////////////////////////
|
||||
{
|
||||
//MPI::Init(argc, argv);
|
||||
MPI::Init_thread(argc, argv, MPI::THREAD_SERIALIZED);
|
||||
Initialize();
|
||||
ParseArguments(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
G4MPImanager::~G4MPImanager()
|
||||
/////////////////////////////
|
||||
{
|
||||
if(isSlave && qfcout) fscout.close();
|
||||
|
||||
delete status;
|
||||
delete messenger;
|
||||
delete session;
|
||||
|
||||
COMM_G4COMMAND.Free();
|
||||
|
||||
MPI::Finalize();
|
||||
|
||||
theManager= 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
G4MPImanager* G4MPImanager::GetManager()
|
||||
////////////////////////////////////////
|
||||
{
|
||||
if(theManager==0) {
|
||||
G4Exception("G4MPImanager is not created.");
|
||||
}
|
||||
return theManager;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
void G4MPImanager::Initialize()
|
||||
///////////////////////////////
|
||||
{
|
||||
if(theManager != 0) {
|
||||
G4Exception("G4MPImanager is constructed twice.");
|
||||
}
|
||||
theManager= this;
|
||||
|
||||
// get rank information
|
||||
size= MPI::COMM_WORLD.Get_size();
|
||||
rank= MPI::COMM_WORLD.Get_rank();
|
||||
isMaster= (rank == RANK_MASTER);
|
||||
isSlave= (rank != RANK_MASTER);
|
||||
|
||||
// initialize MPI communicator
|
||||
COMM_G4COMMAND= MPI::COMM_WORLD.Dup();
|
||||
|
||||
// new G4MPI stuffs
|
||||
messenger= new G4MPImessenger(this);
|
||||
|
||||
session= new G4MPIsession;
|
||||
|
||||
status= new G4MPIstatus;
|
||||
|
||||
// default seed generator is random generator.
|
||||
seedGenerator= new G4MPIrandomSeedGenerator;
|
||||
DistributeSeeds();
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
void G4MPImanager::ParseArguments(int argc, char** argv)
|
||||
////////////////////////////////////////////////////////
|
||||
{
|
||||
G4int qhelp= 0;
|
||||
G4String ofprefix="mpi";
|
||||
|
||||
G4int c;
|
||||
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}
|
||||
};
|
||||
|
||||
opterr= 0; // suppress message
|
||||
c= getopt_long(argc, argv, "hvi:o", long_options, &option_index);
|
||||
opterr= 1;
|
||||
|
||||
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;
|
||||
break;
|
||||
case 'i' :
|
||||
qinitmacro= true;
|
||||
initFileName= optarg;
|
||||
break;
|
||||
case 'o' :
|
||||
qfcout= true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// show help
|
||||
if(qhelp) {
|
||||
if(isMaster) ShowHelp();
|
||||
MPI::Finalize();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// file output
|
||||
if(isSlave && qfcout) {
|
||||
G4String prefix= ofprefix+".%03d"+".cout";
|
||||
char str[1024];
|
||||
sprintf(str, prefix.c_str(), rank);
|
||||
G4String fname(str);
|
||||
fscout.open(fname.c_str(), std::ios::out);
|
||||
}
|
||||
|
||||
// non-option ARGV-elements ...
|
||||
if (optind < argc ) {
|
||||
qbatchmode= true;
|
||||
macroFileName= 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()
|
||||
/////////////////////////////////
|
||||
{
|
||||
G4RunManager* runManager= G4RunManager::GetRunManager();
|
||||
const G4Run* run= runManager-> GetCurrentRun();
|
||||
|
||||
G4int runid, eventid, neventTBP;
|
||||
|
||||
if (run) { // running...
|
||||
runid= run-> GetRunID();
|
||||
neventTBP= run -> GetNumberOfEventToBeProcessed();
|
||||
eventid= run-> GetNumberOfEvent();
|
||||
} else {
|
||||
runid= 0;
|
||||
eventid= 0;
|
||||
neventTBP= 0;
|
||||
}
|
||||
|
||||
G4StateManager* stateManager= G4StateManager::GetStateManager();
|
||||
G4ApplicationState g4state= stateManager-> GetCurrentState();
|
||||
|
||||
status-> SetStatus(rank, runid, neventTBP, eventid, g4state);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
void G4MPImanager::ShowStatus()
|
||||
///////////////////////////////
|
||||
{
|
||||
G4int buff[G4MPIstatus::NSIZE];
|
||||
|
||||
UpdateStatus();
|
||||
G4bool gstatus= CheckThreadStatus();
|
||||
|
||||
if(isMaster) {
|
||||
status-> Print(); // for maser itself
|
||||
|
||||
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();
|
||||
|
||||
// aggregation
|
||||
nev+= status-> GetEventID();
|
||||
nevtp+= status-> GetNEventToBeProcessed();
|
||||
//mpistate= status-> GetG4State();
|
||||
cputime+= status-> GetCPUTime();
|
||||
}
|
||||
|
||||
G4String strStatus;
|
||||
if(gstatus) {
|
||||
strStatus= "Run";
|
||||
} else {
|
||||
strStatus= "Idle";
|
||||
}
|
||||
|
||||
G4cout << "-------------------------------------------------------"
|
||||
<< G4endl
|
||||
<< "* #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);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////
|
||||
void G4MPImanager::DistributeSeeds()
|
||||
////////////////////////////////////
|
||||
{
|
||||
std::vector<G4long> seedList= seedGenerator-> GetSeedList();
|
||||
CLHEP::HepRandom::setTheSeed(seedList[rank]);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
void G4MPImanager::ShowSeeds()
|
||||
//////////////////////////////
|
||||
{
|
||||
G4long buff;
|
||||
|
||||
if(isMaster) {
|
||||
// print master
|
||||
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);
|
||||
G4cout << "* rank= " << islave
|
||||
<< " seed= " << buff
|
||||
<< G4endl;
|
||||
}
|
||||
} else { // slaves
|
||||
buff= CLHEP::HepRandom::getTheSeed();
|
||||
COMM_G4COMMAND.Send(&buff, 1, MPI::LONG, RANK_MASTER, TAG_G4SEED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
void G4MPImanager::SetSeed(G4int inode, G4long seed)
|
||||
////////////////////////////////////////////////////
|
||||
{
|
||||
if(rank==inode) {
|
||||
CLHEP::HepRandom::setTheSeed(seed);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////
|
||||
G4bool G4MPImanager::CheckThreadStatus()
|
||||
////////////////////////////////////////
|
||||
{
|
||||
unsigned buff;
|
||||
G4bool qstatus= false;
|
||||
|
||||
if(isMaster) {
|
||||
qstatus= threadID;
|
||||
// get slave status
|
||||
for (G4int islave=1; islave< size; islave++) {
|
||||
COMM_G4COMMAND.Recv(&buff, 1, MPI::UNSIGNED, islave, TAG_G4STATUS);
|
||||
qstatus |= buff;
|
||||
}
|
||||
} else {
|
||||
buff= unsigned(threadID);
|
||||
COMM_G4COMMAND.Send(&buff, 1, MPI::UNSIGNED, RANK_MASTER, TAG_G4STATUS);
|
||||
}
|
||||
|
||||
// broadcast
|
||||
buff= qstatus; // for master
|
||||
COMM_G4COMMAND.Bcast(&buff, 1, MPI::UNSIGNED, RANK_MASTER);
|
||||
qstatus= buff; // for slave
|
||||
|
||||
return qstatus;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
void G4MPImanager::ExecuteThreadCommand(const G4String& command)
|
||||
////////////////////////////////////////////////////////////////
|
||||
{
|
||||
// this method is a thread function.
|
||||
G4UImanager* UI= G4UImanager::GetUIpointer();
|
||||
G4int rc= UI-> ApplyCommand(command);
|
||||
|
||||
G4int commandStatus = rc - (rc%100);
|
||||
|
||||
switch(commandStatus) {
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "illegal application state -- command refused" << G4endl;
|
||||
break;
|
||||
default:
|
||||
G4cerr << "command refused (" << commandStatus << ")" << G4endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// thread is joined
|
||||
if(threadID) {
|
||||
pthread_join(threadID, 0);
|
||||
threadID= 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
void G4MPImanager::ExecuteBeamOnThread(const G4String& command)
|
||||
///////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4bool threadStatus= CheckThreadStatus();
|
||||
|
||||
if (threadStatus) {
|
||||
if(isMaster) {
|
||||
G4cout << "G4MPIsession:: beamOn is still running." << G4endl;
|
||||
}
|
||||
} else { // ok
|
||||
static G4String cmdstr;
|
||||
cmdstr= command;
|
||||
G4int rc= pthread_create(&threadID, 0,
|
||||
(Func_t)thread_ExecuteThreadCommand,
|
||||
(void*)&cmdstr);
|
||||
if (rc != 0)
|
||||
G4Exception("G4MPIsession:: failed to create a beamOn thread.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
void G4MPImanager::JoinBeamOnThread()
|
||||
/////////////////////////////////////
|
||||
{
|
||||
if(threadID) {
|
||||
pthread_join(threadID, 0);
|
||||
threadID= 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
G4String G4MPImanager::BcastCommand(const G4String& command)
|
||||
////////////////////////////////////////////////////////////
|
||||
{
|
||||
enum { BUFF_SIZE= 512 };
|
||||
static char sbuff[BUFF_SIZE];
|
||||
command.copy(sbuff,BUFF_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, BUFF_SIZE, 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);
|
||||
}
|
||||
} else {
|
||||
// try non-blocking receive
|
||||
MPI::Request request= COMM_G4COMMAND.Irecv(sbuff, BUFF_SIZE, MPI::CHAR,
|
||||
RANK_MASTER, TAG_G4COMMAND);
|
||||
// polling...
|
||||
MPI::Status status;
|
||||
while(! request.Test(status)) {
|
||||
Wait(100);
|
||||
}
|
||||
}
|
||||
|
||||
return G4String(sbuff);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
void G4MPImanager::ExecuteMacroFile(const G4String& fname, G4bool qbatch)
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4MPIbatch* batchSession= new G4MPIbatch(fname, qbatch);
|
||||
batchSession-> SessionStart();
|
||||
delete batchSession;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
void G4MPImanager::BeamOn(G4int nevent, G4bool qdivide)
|
||||
///////////////////////////////////////////////////////
|
||||
{
|
||||
G4RunManager* runManager= G4RunManager::GetRunManager();
|
||||
|
||||
if(qdivide) { // events are divided
|
||||
G4double ntot= masterWeight+size-1.;
|
||||
G4int nproc= G4int(nevent/ntot);
|
||||
G4int nproc0= nevent-nproc*(size-1);
|
||||
|
||||
if(verbose>0 && isMaster) {
|
||||
G4cout << "#events in master=" << nproc0 << " / "
|
||||
<< "#events in slave=" << nproc << G4endl;
|
||||
}
|
||||
|
||||
status-> StartTimer(); // start timer
|
||||
if(isMaster) runManager-> BeamOn(nproc0);
|
||||
else runManager-> BeamOn(nproc);
|
||||
status-> StopTimer(); // stop timer
|
||||
|
||||
} else { // same events are generated in each node (for test use)
|
||||
if(verbose>0 && isMaster) {
|
||||
G4cout << "#events in master=" << nevent << " / "
|
||||
<< "#events in slave=" << nevent << G4endl;
|
||||
}
|
||||
status-> StartTimer(); // start timer
|
||||
runManager-> BeamOn(nevent);
|
||||
status-> StopTimer(); // stop timer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
void G4MPImanager::Print(const G4String& message)
|
||||
/////////////////////////////////////////////////
|
||||
{
|
||||
if(isMaster){
|
||||
std::cout << message << std::flush;
|
||||
} else {
|
||||
if(qfcout) { // output to a file
|
||||
fscout << message << std::flush;
|
||||
} else { // output to stdout
|
||||
std::cout << rank << ":" << message << std::flush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
void G4MPImanager::ShowHelp() const
|
||||
///////////////////////////////////
|
||||
{
|
||||
if(isSlave) return;
|
||||
|
||||
G4cout << "Geant4 MPI interface" << G4endl;
|
||||
G4cout << "usage:" << G4endl;
|
||||
G4cout << "<app> [options] [macro file]"
|
||||
<< G4endl << G4endl;
|
||||
G4cout << " -h, --help show this message."
|
||||
<< G4endl;
|
||||
G4cout << " -v, --verbose show verbose message"
|
||||
<< G4endl;
|
||||
G4cout << " -i, --init=FNAME set an init macro file"
|
||||
<< G4endl;
|
||||
G4cout << " -o, --ofile[=FNAME] set slave output to a flie"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPImessenger.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPImessenger.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4MPImessenger.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4VMPIseedGenerator.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include <sstream>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
G4MPImessenger::G4MPImessenger( G4MPImanager* manager)
|
||||
: G4UImessenger(), g4MPI(manager)
|
||||
//////////////////////////////////////////////////////
|
||||
{
|
||||
// /mpi
|
||||
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");
|
||||
|
||||
// /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);
|
||||
|
||||
// /mpi/beamOn
|
||||
beamOn= new G4UIcommand("/mpi/beamOn", this);
|
||||
beamOn-> SetGuidance("Start a parallel run w/ thread.");
|
||||
|
||||
G4UIparameter* p1= new G4UIparameter("numberOfEvent", 'i', true);
|
||||
p1-> SetDefaultValue(1);
|
||||
p1-> SetParameterRange("numberOfEvent>=0");
|
||||
beamOn-> SetParameter(p1);
|
||||
|
||||
G4UIparameter* p2= new G4UIparameter("divide", 'b', true);
|
||||
p2-> SetDefaultValue(true);
|
||||
beamOn-> SetParameter(p2);
|
||||
|
||||
// /mpi/.beamOn
|
||||
dotbeamOn= new G4UIcmdWithAnInteger("/mpi/.beamOn", this);
|
||||
dotbeamOn-> SetGuidance("Start a parallel run w/o thread. (=/run/beamOn)");
|
||||
dotbeamOn-> SetParameterName("numberOfEvent", true, false);
|
||||
dotbeamOn-> SetDefaultValue(1);
|
||||
dotbeamOn-> SetRange("numberOfEvent>=0");
|
||||
|
||||
// /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.");
|
||||
|
||||
// /mpi/showSeeds
|
||||
showSeeds= new G4UIcmdWithoutParameter("/mpi/showSeeds", this);
|
||||
showSeeds-> 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);
|
||||
|
||||
// /mpi/setSeed
|
||||
setSeed= new G4UIcommand("/mpi/setSeed", this);
|
||||
setSeed-> SetGuidance("Set a seed for a specified node.");
|
||||
|
||||
p1= new G4UIparameter("node", 'i', false);
|
||||
p1-> SetParameterRange("node>=0");
|
||||
setSeed-> SetParameter(p1);
|
||||
|
||||
p2= new G4UIparameter("seed", 'i', false);
|
||||
setSeed-> SetParameter(p2);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
G4MPImessenger::~G4MPImessenger()
|
||||
/////////////////////////////////
|
||||
{
|
||||
delete verbose;
|
||||
delete status;
|
||||
delete execute;
|
||||
delete beamOn;
|
||||
delete dotbeamOn;
|
||||
delete masterWeight;
|
||||
delete showSeeds;
|
||||
delete setMasterSeed;
|
||||
delete setSeed;
|
||||
|
||||
delete dir;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void G4MPImessenger::SetNewValue( G4UIcommand* command, G4String newValue)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
if (command == verbose) { // /mpi/verbose
|
||||
G4int lv= verbose-> GetNewIntValue(newValue);
|
||||
g4MPI-> SetVerbose(lv);
|
||||
|
||||
} else if (command == status){ // /mpi/status
|
||||
g4MPI-> ShowStatus();
|
||||
|
||||
} else if (command == execute){ // /mpi/execute
|
||||
g4MPI-> ExecuteMacroFile(newValue);
|
||||
|
||||
} else if (command == beamOn){ // /mpi/beamOn
|
||||
std::istringstream is(newValue);
|
||||
G4int nevent;
|
||||
G4bool qdivide;
|
||||
is >> nevent >> qdivide;
|
||||
g4MPI-> BeamOn(nevent, qdivide);
|
||||
|
||||
} else if (command == dotbeamOn){ // /mpi/.beamOn
|
||||
G4int nevent= dotbeamOn-> GetNewIntValue(newValue);
|
||||
g4MPI-> BeamOn(nevent);
|
||||
|
||||
} else if (command == masterWeight){ // /mpi/masterWeight
|
||||
G4double weight= masterWeight-> GetNewDoubleValue(newValue);
|
||||
g4MPI-> SetMasterWeight(weight);
|
||||
|
||||
} else if (command == showSeeds){ // /mpi/showSeeds
|
||||
g4MPI-> ShowSeeds();
|
||||
|
||||
} else if (command == setMasterSeed){ // /mpi/setMasterSeed
|
||||
std::istringstream is(newValue);
|
||||
G4long seed;
|
||||
is >> seed;
|
||||
g4MPI-> GetSeedGenerator()-> SetMasterSeed(seed);
|
||||
g4MPI-> DistributeSeeds();
|
||||
|
||||
} else if (command == setSeed){ // /mpi/setSeed
|
||||
std::istringstream is(newValue);
|
||||
G4int inode;
|
||||
G4long seed;
|
||||
is >> inode >> seed;
|
||||
g4MPI-> SetSeed(inode, seed);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
G4String G4MPImessenger::GetCurrentValue(G4UIcommand* command)
|
||||
/////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4String cv;
|
||||
|
||||
if (command == verbose) {
|
||||
cv= verbose-> ConvertToString(g4MPI->GetVerbose());
|
||||
} else if (command == masterWeight) {
|
||||
cv= masterWeight-> ConvertToString(g4MPI->GetMasterWeight());
|
||||
}
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIrandomSeedGenerator.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIrandomSeedGenerator.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4MPIrandomSeedGenerator.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
G4MPIrandomSeedGenerator::G4MPIrandomSeedGenerator()
|
||||
: G4VMPIseedGenerator()
|
||||
////////////////////////////////////////////////////
|
||||
{
|
||||
GenerateSeeds();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
G4MPIrandomSeedGenerator::~G4MPIrandomSeedGenerator()
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
G4bool G4MPIrandomSeedGenerator::CheckDoubleCount()
|
||||
///////////////////////////////////////////////////
|
||||
{
|
||||
G4MPImanager* g4MPI= G4MPImanager::GetManager();
|
||||
G4int nsize= g4MPI-> GetSize();
|
||||
|
||||
for (G4int i=0; i< nsize; i++) {
|
||||
for (G4int j=0; j< nsize; j++) {
|
||||
if((i != j) && (seedList[i] == seedList[j])) {
|
||||
G4double x= G4UniformRand();
|
||||
seedList[j]= G4long(x*LONG_MAX);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
void G4MPIrandomSeedGenerator::GenerateSeeds()
|
||||
//////////////////////////////////////////////
|
||||
{
|
||||
G4MPImanager* g4MPI= G4MPImanager::GetManager();
|
||||
G4int nsize= g4MPI-> GetSize();
|
||||
seedList.clear();
|
||||
|
||||
for (G4int i=0; i< nsize; i++) {
|
||||
G4double x= G4UniformRand();
|
||||
G4int seed= G4long(x*LONG_MAX);
|
||||
seedList.push_back(seed);
|
||||
}
|
||||
|
||||
while(! CheckDoubleCount()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIsession.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIsession.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4MPIsession.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcsh.hh"
|
||||
#include "G4UImpish.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////////////
|
||||
G4MPIsession::G4MPIsession(G4VUIshell* ashell)
|
||||
: G4VMPIsession()
|
||||
//////////////////////////////////////////////
|
||||
{
|
||||
G4UImanager* UI= G4UImanager::GetUIpointer();
|
||||
UI-> SetSession(this);
|
||||
UI-> SetCoutDestination(this);
|
||||
|
||||
// shell
|
||||
if(isMaster) {
|
||||
if(ashell) {
|
||||
shell= ashell;
|
||||
} else {
|
||||
shell= new G4UIcsh;
|
||||
}
|
||||
} else {
|
||||
shell= new G4UImpish;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
G4MPIsession::~G4MPIsession()
|
||||
/////////////////////////////
|
||||
{
|
||||
delete shell;
|
||||
|
||||
G4UImanager* UI= G4UImanager::GetUIpointer();
|
||||
UI-> SetSession(0);
|
||||
UI-> SetCoutDestination(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
void G4MPIsession::SetPrompt(const G4String& prompt)
|
||||
////////////////////////////////////////////////////
|
||||
{
|
||||
shell-> SetPrompt(prompt);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
void G4MPIsession::SetShell(G4VUIshell* ashell)
|
||||
///////////////////////////////////////////////
|
||||
{
|
||||
delete shell;
|
||||
shell= ashell;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
G4String G4MPIsession::GetCommand(const char* msg)
|
||||
//////////////////////////////////////////////////
|
||||
{
|
||||
G4UImanager* UI= G4UImanager::GetUIpointer();
|
||||
|
||||
G4String newCommand;
|
||||
const G4String nullString="";
|
||||
|
||||
// get command from shell...
|
||||
newCommand= shell-> GetCommandLine(msg);
|
||||
|
||||
G4String nC= newCommand.strip(G4String::leading);
|
||||
if( nC.length() == 0 ) {
|
||||
newCommand= nullString;
|
||||
|
||||
} else if( nC(0) == '#' ) {
|
||||
G4cout << nC << G4endl;
|
||||
newCommand= nullString;
|
||||
|
||||
} 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));
|
||||
newCommand= nullString;
|
||||
|
||||
} else if(nC == "pwd") { // show current directory
|
||||
G4cout << "Current Command Directory : "
|
||||
<< GetCurrentWorkingDirectory() << G4endl;
|
||||
newCommand= nullString;
|
||||
|
||||
} else if(nC == "cwd") { // ... by shell
|
||||
shell-> ShowCurrentDirectory();
|
||||
newCommand= nullString;
|
||||
|
||||
} else if(nC == "cd" || nC(0,3) == "cd ") { // "cd"
|
||||
ChangeDirectoryCommand(nC);
|
||||
shell-> SetCurrentDirectory(GetCurrentWorkingDirectory());
|
||||
newCommand= nullString;
|
||||
|
||||
} else if(nC == "help" || nC(0,5) == "help ") { // "help"
|
||||
TerminalHelp(nC);
|
||||
newCommand= nullString;
|
||||
|
||||
} 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;
|
||||
}
|
||||
newCommand= nullString;
|
||||
|
||||
} 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);
|
||||
G4cout << newCommand << G4endl;
|
||||
} else {
|
||||
G4cerr << "history " << vl << " is not found." << G4endl;
|
||||
newCommand= nullString;
|
||||
}
|
||||
|
||||
} else if( nC.empty() ){ // NULL command
|
||||
newCommand= nullString;
|
||||
|
||||
} else if( nC == "exit" ){ // "exit"
|
||||
return "exit";
|
||||
|
||||
} else { // ...
|
||||
|
||||
}
|
||||
|
||||
newCommand= TruncateCommand(newCommand);
|
||||
return ModifyToFullPathCommand(newCommand);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
G4UIsession* G4MPIsession::SessionStart()
|
||||
/////////////////////////////////////////
|
||||
{
|
||||
// execute init macro
|
||||
if(g4MPI-> IsInitMacro()) {
|
||||
g4MPI-> ExecuteMacroFile(g4MPI->GetInitFileName());
|
||||
}
|
||||
|
||||
// batch mode
|
||||
if(g4MPI-> IsBatchMode()) {
|
||||
g4MPI-> ExecuteMacroFile(g4MPI->GetMacroFileName(), true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// interactive session
|
||||
G4String newCommand="", scommand; // newCommand is always "" in slaves
|
||||
|
||||
if(isMaster) newCommand= GetCommand();
|
||||
// broadcast a new G4 command
|
||||
scommand= g4MPI-> BcastCommand(newCommand);
|
||||
if(scommand == "exit" ) return 0;
|
||||
|
||||
while(1){
|
||||
ExecCommand(scommand);
|
||||
|
||||
// get next ...
|
||||
if(isMaster) newCommand= GetCommand();
|
||||
scommand= g4MPI-> BcastCommand(newCommand);
|
||||
if(scommand == "exit" ) {
|
||||
G4bool qexit= TryForcedTerminate();
|
||||
if(qexit) break;
|
||||
else scommand="";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
G4bool G4MPIsession::TryForcedTerminate()
|
||||
/////////////////////////////////////////
|
||||
{
|
||||
if(! g4MPI-> CheckThreadStatus()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
G4String xmessage;
|
||||
|
||||
// beamOn is still running
|
||||
if(isMaster) {
|
||||
char c[1024];
|
||||
while(1) {
|
||||
G4cout << "Run is still running. Do you abort a run? [y/N]:"
|
||||
<< std::flush;
|
||||
G4cin.getline(c,1024);
|
||||
G4String yesno= c;
|
||||
if(yesno=="y" || yesno=="Y" ||
|
||||
yesno=="n" || yesno=="N" || yesno == "") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(c[0]=='y' || c[0]=='Y') {
|
||||
G4cout << "Aborting a run..." << G4endl;
|
||||
xmessage= g4MPI-> BcastCommand("kill me");
|
||||
} else {
|
||||
xmessage= g4MPI-> BcastCommand("alive");
|
||||
}
|
||||
} else {
|
||||
xmessage= g4MPI->BcastCommand("");
|
||||
}
|
||||
|
||||
if(xmessage == "kill me") {
|
||||
G4RunManager* runManager= G4RunManager::GetRunManager();
|
||||
runManager-> AbortRun(true); // soft abort
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MPIstatus.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4MPIstatus.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4MPIstatus.hh"
|
||||
#include "G4ApplicationState.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////
|
||||
G4MPIstatus::G4MPIstatus()
|
||||
: rank(0), runID(0),
|
||||
nEventToBeProcessed(0),
|
||||
eventID(0),
|
||||
cputime(0.),
|
||||
g4state(G4State_Quit)
|
||||
//////////////////////////
|
||||
{
|
||||
timer= new G4Timer;
|
||||
timer-> Start();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
G4MPIstatus::~G4MPIstatus()
|
||||
//////////////////////////
|
||||
{
|
||||
delete timer;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
void G4MPIstatus::SetStatus(G4int arank, G4int runid,
|
||||
G4int noe, G4int evtid,
|
||||
G4ApplicationState state)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
rank= arank;
|
||||
runID= runid;
|
||||
nEventToBeProcessed= noe;
|
||||
eventID= evtid;
|
||||
g4state= state;
|
||||
|
||||
timer-> Stop();
|
||||
cputime= timer-> GetUserElapsed();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
void G4MPIstatus::Pack(G4int* data) const
|
||||
/////////////////////////////////////////
|
||||
{
|
||||
data[0]= rank;
|
||||
data[1]= runID;
|
||||
data[2]= nEventToBeProcessed;
|
||||
data[3]= eventID;
|
||||
data[4]= g4state;
|
||||
|
||||
G4double* ddata= (G4double*)(data+5);
|
||||
ddata[0]= cputime;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
void G4MPIstatus::UnPack(G4int* data)
|
||||
/////////////////////////////////////
|
||||
{
|
||||
rank= data[0];
|
||||
runID= data[1];
|
||||
nEventToBeProcessed= data[2];
|
||||
eventID= data[3];
|
||||
g4state= (G4ApplicationState)data[4];
|
||||
|
||||
G4double* ddata= (G4double*)(data+5);
|
||||
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"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
G4String G4MPIstatus::GetStateString(G4ApplicationState astate) const
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4String sname;
|
||||
|
||||
switch(astate) {
|
||||
case G4State_PreInit:
|
||||
sname = "PreInit";
|
||||
break;
|
||||
case G4State_Init:
|
||||
sname = "Init";
|
||||
break;
|
||||
case G4State_Idle:
|
||||
sname = "Idle";
|
||||
break;
|
||||
case G4State_GeomClosed:
|
||||
sname = "GeomClosed";
|
||||
break;
|
||||
case G4State_EventProc:
|
||||
sname = "EventProc";
|
||||
break;
|
||||
case G4State_Quit:
|
||||
sname = "Quit";
|
||||
break;
|
||||
case G4State_Abort:
|
||||
sname = "Abort";
|
||||
break;
|
||||
default:
|
||||
sname = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
return sname;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4UImpish.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4UImpish.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4UImpish.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////
|
||||
G4UImpish::G4UImpish()
|
||||
: G4VUIshell("")
|
||||
//////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
G4UImpish::~G4UImpish()
|
||||
///////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
G4String G4UImpish::GetCommandLine(const char*)
|
||||
///////////////////////////////////////////////
|
||||
{
|
||||
G4String newCommand;
|
||||
|
||||
// recieve command string from master
|
||||
G4cout << "hoge hoge" << G4endl;
|
||||
|
||||
return newCommand;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VMPIseedGenerator.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
// ====================================================================
|
||||
// G4VMPIseedGenerator.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4VMPIseedGenerator.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////////
|
||||
G4VMPIseedGenerator::G4VMPIseedGenerator()
|
||||
: masterSeed(123456789)
|
||||
//////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
G4VMPIseedGenerator::~G4VMPIseedGenerator()
|
||||
///////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
void G4VMPIseedGenerator::SetMasterSeed(G4long aseed)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
masterSeed= aseed;
|
||||
GenerateSeeds();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VMPIsession.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
|
||||
// $Name: geant4-09-01 $
|
||||
//
|
||||
// ====================================================================
|
||||
// G4VMPIsession.cc
|
||||
//
|
||||
// 2007 Q
|
||||
// ====================================================================
|
||||
#include "G4VMPIsession.hh"
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////
|
||||
G4VMPIsession::G4VMPIsession()
|
||||
: G4VBasicShell()
|
||||
//////////////////////////////
|
||||
{
|
||||
// MPI
|
||||
g4MPI= G4MPImanager::GetManager();
|
||||
|
||||
isMaster= g4MPI-> IsMaster();
|
||||
isSlave= g4MPI-> IsSlave();
|
||||
rank= g4MPI-> GetRank();
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
G4VMPIsession::~G4VMPIsession()
|
||||
///////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
G4bool G4VMPIsession::GetHelpChoice(G4int& aval)
|
||||
////////////////////////////////////////////////
|
||||
{
|
||||
G4cin >> aval;
|
||||
if(!G4cin.good()){
|
||||
G4cin.clear();
|
||||
G4cin.ignore(30,'\n');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
void G4VMPIsession::ExitHelp()
|
||||
//////////////////////////////
|
||||
{
|
||||
char temp[100];
|
||||
G4cin.getline(temp, 100);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
void G4VMPIsession::PauseSessionStart(G4String)
|
||||
///////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
G4int G4VMPIsession::ExecCommand(G4String aCommand)
|
||||
///////////////////////////////////////////////////
|
||||
{
|
||||
if(aCommand.length()<2) return fCommandSucceeded;
|
||||
|
||||
G4UImanager* UI= G4UImanager::GetUIpointer();
|
||||
G4int returnVal= 0;
|
||||
|
||||
G4String command= BypassCommand(aCommand);
|
||||
|
||||
// "/mpi/beamOn is threaded out.
|
||||
if(command(0,11) == "/mpi/beamOn") {
|
||||
g4MPI-> ExecuteBeamOnThread(aCommand);
|
||||
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) {
|
||||
G4cout << "G4MPIsession:: beamOn is still running." << G4endl;
|
||||
}
|
||||
returnVal= fCommandSucceeded;
|
||||
} else {
|
||||
returnVal = UI-> ApplyCommand(command);
|
||||
}
|
||||
} else { // normal command
|
||||
returnVal = UI-> ApplyCommand(command);
|
||||
}
|
||||
|
||||
G4int paramIndex = returnVal % 100;
|
||||
// 0 - 98 : paramIndex-th parameter is invalid
|
||||
// 99 : convination of parameters is invalid
|
||||
G4int commandStatus = returnVal - paramIndex;
|
||||
|
||||
G4UIcommand* cmd = 0;
|
||||
if(commandStatus!=fCommandSucceeded) {
|
||||
cmd = FindCommand(command);
|
||||
}
|
||||
|
||||
switch(commandStatus) {
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
G4cerr << "command <" << UI->SolveAlias(command)
|
||||
<< "> not found" << G4endl;
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "illegal application state -- command refused" << G4endl;
|
||||
break;
|
||||
case fParameterOutOfRange:
|
||||
// ...
|
||||
break;
|
||||
case fParameterOutOfCandidates:
|
||||
G4cerr << "Parameter is out of candidate list (index "
|
||||
<< paramIndex << ")" << G4endl;
|
||||
G4cerr << "Candidates : "
|
||||
<< cmd->GetParameter(paramIndex)-> GetParameterCandidates()
|
||||
<< G4endl;
|
||||
break;
|
||||
case fParameterUnreadable:
|
||||
G4cerr << "Parameter is wrong type and/or is not omittable (index "
|
||||
<< paramIndex << ")" << G4endl;
|
||||
break;
|
||||
case fAliasNotFound:
|
||||
// ...
|
||||
break;
|
||||
default:
|
||||
G4cerr << "command refused (" << commandStatus << ")" << G4endl;
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
G4String G4VMPIsession::TruncateCommand(const G4String& command) const
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
// replace "//" with "/" in G4command
|
||||
G4String acommand= command;
|
||||
G4String strarg;
|
||||
|
||||
str_size iarg= acommand.find(' ');
|
||||
if(iarg != G4String::npos) {
|
||||
strarg= acommand(iarg, acommand.size()-iarg);
|
||||
acommand= acommand(0,iarg);
|
||||
}
|
||||
|
||||
str_size idx;
|
||||
while( (idx= acommand.find("//")) != G4String::npos) {
|
||||
G4String command1= acommand(0,idx+1);
|
||||
G4String command2= acommand(idx+2, acommand.size()-idx-2);
|
||||
acommand= command1 + command2;
|
||||
}
|
||||
|
||||
acommand += strarg;
|
||||
|
||||
return acommand;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
G4String G4VMPIsession::BypassCommand(const G4String& command) const
|
||||
////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
// bypass some commands
|
||||
// /run/beamon -> /mpi/.beamOn
|
||||
// /control/execute -> /mpi/execute
|
||||
|
||||
G4String acommand= command;
|
||||
|
||||
if(acommand(0,11) == "/run/beamOn") {
|
||||
if(g4MPI-> GetVerbose()>0 && isMaster) {
|
||||
G4cout << "/run/beamOn is overridden by /mpi/.beamOn"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
acommand= "/mpi/.beamOn ";
|
||||
|
||||
G4String strarg= "";
|
||||
G4bool qget= false;
|
||||
G4bool qdone= false;
|
||||
|
||||
for (str_size idx=10; idx< command.size(); idx++) {
|
||||
if(command[idx] == ' ' || command[idx] == '\011') {
|
||||
qget= true;
|
||||
if(qdone) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(qget) {
|
||||
strarg+= command[idx];
|
||||
qdone= true;
|
||||
}
|
||||
}
|
||||
acommand += strarg;
|
||||
}
|
||||
|
||||
if(acommand(0,16) == "/control/execute") {
|
||||
if(g4MPI-> GetVerbose()>0 && isMaster) {
|
||||
G4cout << "/control/execute is overridden by /mpi/execute"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
acommand.replace(0, 16, "/mpi/execute ");
|
||||
}
|
||||
|
||||
return acommand;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
G4int G4VMPIsession::ReceiveG4cout(G4String coutString)
|
||||
//////////////////////////////////////////////////////
|
||||
{
|
||||
g4MPI-> Print(coutString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
G4int G4VMPIsession::ReceiveG4cerr(G4String cerrString)
|
||||
//////////////////////////////////////////////////////
|
||||
{
|
||||
g4MPI-> Print(cerrString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user