Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * 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: B1ActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $
//
/// \file B1ActionInitialization.cc
/// \brief Implementation of the B1ActionInitialization class
#include "B1ActionInitialization.hh"
#include "B1PrimaryGeneratorAction.hh"
#include "B1RunAction.hh"
#include "B1EventAction.hh"
#include "B1SteppingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1ActionInitialization::B1ActionInitialization()
: G4VUserActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1ActionInitialization::~B1ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1ActionInitialization::BuildForMaster() const
{
SetUserAction(new B1RunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1ActionInitialization::Build() const
{
SetUserAction(new B1PrimaryGeneratorAction);
SetUserAction(new B1RunAction);
B1EventAction* eventAction = new B1EventAction;
SetUserAction(eventAction);
SetUserAction(new B1SteppingAction(eventAction));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,14 +23,12 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B1DetectorConstruction.cc 75117 2013-10-28 09:38:37Z gcosmo $
//
/// \file B1DetectorConstruction.cc
/// \brief Implementation of the B1DetectorConstruction class
#include "B1DetectorConstruction.hh"
#include "B1SteppingAction.hh"
// use of stepping action to set the accounting volume
#include "G4RunManager.hh"
#include "G4NistManager.hh"
@@ -46,7 +44,8 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1DetectorConstruction::B1DetectorConstruction()
: G4VUserDetectorConstruction()
: G4VUserDetectorConstruction(),
fScoringVolume(0)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -119,8 +118,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//
// Shape 1
//
//
G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE");
G4ThreeVector pos1 = G4ThreeVector(0, 2*cm, -7*cm);
@@ -133,29 +131,6 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
new G4Cons("Shape1",
shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb, shape1_hz,
shape1_phimin, shape1_phimax);
/*
// Full sphere shape
G4double shape1_rmax = 4*cm;
G4Orb* solidShape1 =
new G4Orb("Shape1", //its name
shape1_rmax); //its size
// Sphere shape
G4double shape1_rmin = 0*cm, shape1_rmax = 4*cm;
G4double shape1_thetamin = 0.*deg, shape1_thetamax = 180.*deg;
G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg;
G4Sphere* solidShape1 =
new G4Sphere("Shape1", //its name
shape1_rmin, shape1_rmax, //its size
shape1_phimin, shape1_phimax, //phi angle
shape1_thetamin, shape1_thetamax); //theta angle
// Box shape
G4double shape1_dx = 8*cm, shape1_dy = 8*cm, shape1_dz = 8*cm;
G4Box* solidShape1 =
new G4Box("Shape1", //its name
0.5*shape1_dx, 0.5*shape1_dy, 0.5*shape1_dz); //its size
*/
G4LogicalVolume* logicShape1 =
new G4LogicalVolume(solidShape1, //its solid
@@ -177,17 +152,6 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
//
G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_BONE_COMPACT_ICRU");
G4ThreeVector pos2 = G4ThreeVector(0, -1*cm, 7*cm);
/*
// Shape 2 - conical section shape
G4double shape2_rmina = 0.*cm, shape2_rmaxa = 5.*cm;
G4double shape2_rminb = 0.*cm, shape2_rmaxb = 8.*cm;
G4double shape2_hz = 3.*cm;
G4double shape2_phimin = 0.*deg, shape2_phimax = 360.*deg;
G4Cons* solidShape2 =
new G4Cons("Shape2",
shape2_rmina, shape2_rmaxa, shape2_rminb, shape2_rmaxb, shape2_hz,
shape2_phimin, shape2_phimax);
*/
// Trapezoid shape
G4double shape2_dxa = 12*cm, shape2_dxb = 12*cm;
@@ -212,13 +176,9 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
0, //copy number
checkOverlaps); //overlaps checking
// Set scoring volume to stepping action
// (where we will account energy deposit)
// Set Shape2 as scoring volume
//
B1SteppingAction* steppingAction = B1SteppingAction::Instance();
////steppingAction->SetVolume(logicShape1);
steppingAction->SetVolume(logicShape2);
fScoringVolume = logicShape2;
//
//always return the physical World
+19 -56
View File
@@ -23,82 +23,45 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B1EventAction.cc 75117 2013-10-28 09:38:37Z gcosmo $
//
/// \file B1EventAction.cc
/// \brief Implementation of the B1EventAction class
#include "B1EventAction.hh"
#include "B1Run.hh"
#include "B1RunAction.hh"
#include "B1SteppingAction.hh"
// use of stepping action to get and reset accumulated energy
#include "G4RunManager.hh"
#include "G4Event.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1EventAction* B1EventAction::fgInstance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1EventAction* B1EventAction::Instance()
{
// Static acces function via G4RunManager
return fgInstance;
}
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1EventAction::B1EventAction()
: G4UserEventAction(),
fPrintModulo(100),
fEnergySum(0.),
fEnergy2Sum(0.)
{
fgInstance = this;
}
fEdep(0.)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1EventAction::~B1EventAction()
{
fgInstance = 0;
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1EventAction::BeginOfEventAction(const G4Event*)
{
fEdep = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1EventAction::BeginOfEventAction(const G4Event* event)
{
G4int eventNb = event->GetEventID();
if (eventNb%fPrintModulo == 0) {
G4cout << "\n---> Begin of event: " << eventNb << G4endl;
}
// Reset accounted energy in stepping action
B1SteppingAction::Instance()->Reset();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1EventAction::EndOfEventAction(const G4Event* /*event*/)
{
// accumulate statistics
G4double energy = B1SteppingAction::Instance()->GetEnergy();
fEnergySum += energy;
fEnergy2Sum += energy*energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1EventAction::Reset()
{
//reset cumulative quantities
//
fEnergySum = 0.;
fEnergy2Sum = 0.;
void B1EventAction::EndOfEventAction(const G4Event*)
{
// accumulate statistics in B1Run
B1Run* run
= static_cast<B1Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->AddEdep(fEdep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B1PrimaryGeneratorAction.cc 69565 2013-05-08 12:35:31Z gcosmo $
//
/// \file B1PrimaryGeneratorAction.cc
/// \brief Implementation of the B1PrimaryGeneratorAction class
@@ -42,22 +42,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1PrimaryGeneratorAction* B1PrimaryGeneratorAction::fgInstance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const B1PrimaryGeneratorAction* B1PrimaryGeneratorAction::Instance()
{
// Static acces function via G4RunManager
return fgInstance;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1PrimaryGeneratorAction::B1PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0)
fParticleGun(0),
fEnvelopeBox(0)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
@@ -70,8 +58,6 @@ B1PrimaryGeneratorAction::B1PrimaryGeneratorAction()
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(6.*MeV);
fgInstance = this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -79,7 +65,6 @@ B1PrimaryGeneratorAction::B1PrimaryGeneratorAction()
B1PrimaryGeneratorAction::~B1PrimaryGeneratorAction()
{
delete fParticleGun;
fgInstance = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -95,18 +80,25 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
G4double envSizeXY = 0;
G4double envSizeZ = 0;
G4LogicalVolume* envLV
= G4LogicalVolumeStore::GetInstance()->GetVolume("Envelope");
G4Box* envBox = NULL;
if ( envLV ) envBox = dynamic_cast<G4Box*>(envLV->GetSolid());
if ( envBox ) {
envSizeXY = envBox->GetXHalfLength()*2.;
envSizeZ = envBox->GetZHalfLength()*2.;
if (!fEnvelopeBox)
{
G4LogicalVolume* envLV
= G4LogicalVolumeStore::GetInstance()->GetVolume("Envelope");
if ( envLV ) fEnvelopeBox = dynamic_cast<G4Box*>(envLV->GetSolid());
}
if ( fEnvelopeBox ) {
envSizeXY = fEnvelopeBox->GetXHalfLength()*2.;
envSizeZ = fEnvelopeBox->GetZHalfLength()*2.;
}
else {
G4cerr << "Envelope volume of box shape not found." << G4endl;
G4cerr << "Perhaps you have changed geometry." << G4endl;
G4cerr << "The gun will be place in the center." << G4endl;
G4ExceptionDescription msg;
msg << "Envelope volume of box shape not found.\n";
msg << "Perhaps you have changed geometry.\n";
msg << "The gun will be place at the center.";
G4Exception("B1PrimaryGeneratorAction::GeneratePrimaries()",
"MyCode0002",JustWarning,msg);
}
G4double size = 0.8;
+67
View File
@@ -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: B1Run.cc 66536 2012-12-19 14:32:36Z ihrivnac $
//
/// \file B1Run.cc
/// \brief Implementation of the B1Run class
#include "B1Run.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1Run::B1Run()
: G4Run(),
fEdep(0.),
fEdep2(0.)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1Run::~B1Run()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1Run::Merge(const G4Run* run)
{
const B1Run* localRun = static_cast<const B1Run*>(run);
fEdep += localRun->fEdep;
fEdep2 += localRun->fEdep2;
G4Run::Merge(run);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1Run::AddEdep (G4double edep)
{
fEdep += edep;
fEdep2 += edep*edep;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+55 -38
View File
@@ -23,22 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B1RunAction.cc 75216 2013-10-29 16:08:11Z gcosmo $
//
/// \file B1RunAction.cc
/// \brief Implementation of the B1RunAction class
#include "B1RunAction.hh"
#include "B1PrimaryGeneratorAction.hh"
#include "B1EventAction.hh"
#include "B1SteppingAction.hh"
// use of other actions
// - primary generator: to get info for printing about the primary
// - event action: to get and reset accumulated energy sums
// - stepping action: to get info about accounting volume
#include "B1DetectorConstruction.hh"
#include "B1Run.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
@@ -46,7 +43,7 @@
B1RunAction::B1RunAction()
: G4UserRunAction()
{
{
// add new units for dose
//
const G4double milligray = 1.e-3*gray;
@@ -67,53 +64,73 @@ B1RunAction::~B1RunAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
//inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
//initialize event cumulative quantities
B1EventAction::Instance()->Reset();
G4Run* B1RunAction::GenerateRun()
{
return new B1Run;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1RunAction::EndOfRunAction(const G4Run* aRun)
void B1RunAction::BeginOfRunAction(const G4Run*)
{
//inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1RunAction::EndOfRunAction(const G4Run* run)
{
G4int nofEvents = aRun->GetNumberOfEvent();
G4int nofEvents = run->GetNumberOfEvent();
if (nofEvents == 0) return;
const B1Run* b1Run = static_cast<const B1Run*>(run);
// Compute dose
//
G4double energySum = B1EventAction::Instance()->GetEnergySum();
G4double energy2Sum = B1EventAction::Instance()->GetEnergy2Sum();
G4double rms = energy2Sum - energySum*energySum/nofEvents;
G4double edep = b1Run->GetEdep();
G4double edep2 = b1Run->GetEdep2();
G4double rms = edep2 - edep*edep/nofEvents;
if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
G4double mass = B1SteppingAction::Instance()->GetVolume()->GetMass();
G4double dose = energySum/mass;
const B1DetectorConstruction* detectorConstruction
= static_cast<const B1DetectorConstruction*>
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
G4double dose = edep/mass;
G4double rmsDose = rms/mass;
// Run conditions
//
const G4ParticleGun* particleGun
= B1PrimaryGeneratorAction::Instance()->GetParticleGun();
G4String particleName
= particleGun->GetParticleDefinition()->GetParticleName();
G4double particleEnergy = particleGun->GetParticleEnergy();
// note: There is no primary generator action object for "master"
// run manager for multi-threaded mode.
const B1PrimaryGeneratorAction* generatorAction
= static_cast<const B1PrimaryGeneratorAction*>
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
G4String runCondition;
if (generatorAction)
{
const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
runCondition += particleGun->GetParticleDefinition()->GetParticleName();
runCondition += " of ";
G4double particleEnergy = particleGun->GetParticleEnergy();
runCondition += G4BestUnit(particleEnergy,"Energy");
}
// Print
//
if (IsMaster()) {
G4cout
<< "\n--------------------End of Global Run-----------------------";
}
else {
G4cout
<< "\n--------------------End of Local Run------------------------";
}
G4cout
<< "\n--------------------End of Run------------------------------\n"
<< " The run consists of " << nofEvents << " "<< particleName << " of "
<< G4BestUnit(particleEnergy,"Energy")
<< "\n Dose in scoring volume "
<< B1SteppingAction::Instance()->GetVolume()->GetName() << " : "
<< G4BestUnit(dose,"Dose")
<< " +- " << G4BestUnit(rmsDose,"Dose")
<< "\n The run consists of " << nofEvents << " "<< runCondition
<< "\n Dose in scoring volume : "
<< G4BestUnit(dose,"Dose") << " +- " << G4BestUnit(rmsDose,"Dose")
<< "\n------------------------------------------------------------\n"
<< G4endl;
}
+20 -34
View File
@@ -23,70 +23,56 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B1SteppingAction.cc 74483 2013-10-09 13:37:06Z gcosmo $
//
/// \file B1SteppingAction.cc
/// \brief Implementation of the B1SteppingAction class
#include "B1SteppingAction.hh"
#include "B1EventAction.hh"
#include "B1DetectorConstruction.hh"
#include "G4Step.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4LogicalVolume.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1SteppingAction* B1SteppingAction::fgInstance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1SteppingAction* B1SteppingAction::Instance()
{
// Static acces function via G4RunManager
return fgInstance;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1SteppingAction::B1SteppingAction()
B1SteppingAction::B1SteppingAction(B1EventAction* eventAction)
: G4UserSteppingAction(),
fVolume(0),
fEnergy(0.)
{
fgInstance = this;
}
fEventAction(eventAction),
fScoringVolume(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1SteppingAction::~B1SteppingAction()
{
fgInstance = 0;
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1SteppingAction::UserSteppingAction(const G4Step* step)
{
if (!fScoringVolume) {
const B1DetectorConstruction* detectorConstruction
= static_cast<const B1DetectorConstruction*>
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
fScoringVolume = detectorConstruction->GetScoringVolume();
}
// get volume of the current step
G4LogicalVolume* volume
= step->GetPreStepPoint()->GetTouchableHandle()
->GetVolume()->GetLogicalVolume();
// check if we are in scoring volume
if (volume != fVolume ) return;
if (volume != fScoringVolume) return;
// collect energy and track length step by step
G4double edep = step->GetTotalEnergyDeposit();
fEnergy += edep;
// collect energy deposited in this step
G4double edepStep = step->GetTotalEnergyDeposit();
fEventAction->AddEdep(edepStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1SteppingAction::Reset()
{
fEnergy = 0.;
}