Import Geant4 11.2.0 source tree
This commit is contained in:
+24
-28
@@ -24,45 +24,41 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1ConRun.cc
|
||||
/// \brief Implementation of the B1ConRun class
|
||||
/// \file B1/src/ActionInitialization.cc
|
||||
/// \brief Implementation of the B1::ActionInitialization class
|
||||
|
||||
#include "B1ConRun.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1ConRun::B1ConRun()
|
||||
: B1Run(),
|
||||
fEdepEventVector()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1ConRun::~B1ConRun()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1ConRun::Merge(const G4Run* aRun)
|
||||
namespace B1Con
|
||||
{
|
||||
// Merge data in base class
|
||||
B1Run::Merge(aRun);
|
||||
|
||||
const B1ConRun* localRun = static_cast<const B1ConRun*>(aRun);
|
||||
for ( size_t i = 0 ; i != localRun->fEdepEventVector.size() ; i++ ) {
|
||||
fEdepEventVector.push_back( localRun->fEdepEventVector[i] );
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
auto runAction = new RunAction;
|
||||
SetUserAction(runAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1ConRun::AddEdep (G4double edep)
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
// Update data in base class
|
||||
B1Run::AddEdep(edep);
|
||||
SetUserAction(new B1::PrimaryGeneratorAction);
|
||||
|
||||
fEdepEventVector.push_back(edep);
|
||||
auto runAction = new RunAction;
|
||||
SetUserAction(runAction);
|
||||
|
||||
auto eventAction = new B1::EventAction(runAction);
|
||||
SetUserAction(eventAction);
|
||||
|
||||
SetUserAction(new B1::SteppingAction(eventAction));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1ConActionInitialization.cc
|
||||
/// \brief Implementation of the B1ConActionInitialization class
|
||||
|
||||
#include "B1ConActionInitialization.hh"
|
||||
#include "B1PrimaryGeneratorAction.hh"
|
||||
#include "B1ConRunAction.hh"
|
||||
#include "B1EventAction.hh"
|
||||
#include "B1SteppingAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1ConActionInitialization::B1ConActionInitialization()
|
||||
: G4VUserActionInitialization()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1ConActionInitialization::~B1ConActionInitialization()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1ConActionInitialization::BuildForMaster() const
|
||||
{
|
||||
SetUserAction(new B1ConRunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1ConActionInitialization::Build() const
|
||||
{
|
||||
SetUserAction(new B1PrimaryGeneratorAction);
|
||||
SetUserAction(new B1ConRunAction);
|
||||
|
||||
B1EventAction* eventAction = new B1EventAction;
|
||||
SetUserAction(eventAction);
|
||||
|
||||
SetUserAction(new B1SteppingAction(eventAction));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -1,223 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1DetectorConstruction.cc
|
||||
/// \brief Implementation of the B1DetectorConstruction class
|
||||
|
||||
#include "B1DetectorConstruction.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4Orb.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4Trd.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1DetectorConstruction::B1DetectorConstruction()
|
||||
: G4VUserDetectorConstruction(),
|
||||
fScoringVolume(0)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1DetectorConstruction::~B1DetectorConstruction()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* B1DetectorConstruction::Construct()
|
||||
{
|
||||
// Get nist material manager
|
||||
G4NistManager* nist = G4NistManager::Instance();
|
||||
|
||||
// Envelope parameters
|
||||
//
|
||||
G4double env_sizeXY = 20*cm, env_sizeZ = 30*cm;
|
||||
G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");
|
||||
|
||||
// Option to switch on/off checking of volumes overlaps
|
||||
//
|
||||
G4bool checkOverlaps = true;
|
||||
|
||||
//
|
||||
// World
|
||||
//
|
||||
G4double world_sizeXY = 1.2*env_sizeXY;
|
||||
G4double world_sizeZ = 1.2*env_sizeZ;
|
||||
G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
|
||||
|
||||
G4Box* solidWorld =
|
||||
new G4Box("World", //its name
|
||||
0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size
|
||||
|
||||
G4LogicalVolume* logicWorld =
|
||||
new G4LogicalVolume(solidWorld, //its solid
|
||||
world_mat, //its material
|
||||
"World"); //its name
|
||||
|
||||
G4VPhysicalVolume* physWorld =
|
||||
new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
logicWorld, //its logical volume
|
||||
"World", //its name
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0, //copy number
|
||||
checkOverlaps); //overlaps checking
|
||||
|
||||
//
|
||||
// Envelope
|
||||
//
|
||||
G4Box* solidEnv =
|
||||
new G4Box("Envelope", //its name
|
||||
0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); //its size
|
||||
|
||||
G4LogicalVolume* logicEnv =
|
||||
new G4LogicalVolume(solidEnv, //its solid
|
||||
env_mat, //its material
|
||||
"Envelope"); //its name
|
||||
|
||||
new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
logicEnv, //its logical volume
|
||||
"Envelope", //its name
|
||||
logicWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0, //copy number
|
||||
checkOverlaps); //overlaps checking
|
||||
|
||||
//
|
||||
// Shape 1
|
||||
//
|
||||
|
||||
G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE");
|
||||
G4ThreeVector pos1 = G4ThreeVector(0, 2*cm, -7*cm);
|
||||
|
||||
// Conical section shape
|
||||
G4double shape1_rmina = 0.*cm, shape1_rmaxa = 2.*cm;
|
||||
G4double shape1_rminb = 0.*cm, shape1_rmaxb = 4.*cm;
|
||||
G4double shape1_hz = 3.*cm;
|
||||
G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg;
|
||||
G4Cons* solidShape1 =
|
||||
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
|
||||
shape1_mat, //its material
|
||||
"Shape1"); //its name
|
||||
|
||||
new G4PVPlacement(0, //no rotation
|
||||
pos1, //at position
|
||||
logicShape1, //its logical volume
|
||||
"Shape1", //its name
|
||||
logicEnv, //its mother volume
|
||||
false, //no boolean operation
|
||||
0, //copy number
|
||||
checkOverlaps); //overlaps checking
|
||||
|
||||
|
||||
//
|
||||
// Shape 2
|
||||
//
|
||||
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;
|
||||
G4double shape2_dya = 10*cm, shape2_dyb = 16*cm;
|
||||
G4double shape2_dz = 6*cm;
|
||||
G4Trd* solidShape2 =
|
||||
new G4Trd("Shape2", //its name
|
||||
0.5*shape2_dxa, 0.5*shape2_dxb,
|
||||
0.5*shape2_dya, 0.5*shape2_dyb, 0.5*shape2_dz); //its size
|
||||
|
||||
G4LogicalVolume* logicShape2 =
|
||||
new G4LogicalVolume(solidShape2, //its solid
|
||||
shape2_mat, //its material
|
||||
"Shape2"); //its name
|
||||
|
||||
new G4PVPlacement(0, //no rotation
|
||||
pos2, //at position
|
||||
logicShape2, //its logical volume
|
||||
"Shape2", //its name
|
||||
logicEnv, //its mother volume
|
||||
false, //no boolean operation
|
||||
0, //copy number
|
||||
checkOverlaps); //overlaps checking
|
||||
|
||||
// Set Shape2 as scoring volume
|
||||
//
|
||||
fScoringVolume = logicShape2;
|
||||
|
||||
//
|
||||
//always return the physical World
|
||||
//
|
||||
return physWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -1,72 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1EventAction.cc
|
||||
/// \brief Implementation of the B1EventAction class
|
||||
|
||||
#include "B1EventAction.hh"
|
||||
#include "B1Run.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1EventAction::B1EventAction()
|
||||
: G4UserEventAction(),
|
||||
fPrintModulo(100),
|
||||
fEdep(0.)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1EventAction::~B1EventAction()
|
||||
{}
|
||||
|
||||
//....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;
|
||||
}
|
||||
|
||||
fEdep = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
// accumulate statistics in B1Run
|
||||
B1Run* run
|
||||
= static_cast<B1Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
run->AddEdep(fEdep);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,170 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1/src/DetectorConstruction.cc
|
||||
/// \brief Implementation of the B1::DetectorConstruction class
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4Orb.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4Trd.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
namespace B1
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
// Get nist material manager
|
||||
G4NistManager* nist = G4NistManager::Instance();
|
||||
|
||||
// Envelope parameters
|
||||
//
|
||||
G4double env_sizeXY = 20*cm, env_sizeZ = 30*cm;
|
||||
G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");
|
||||
|
||||
// Option to switch on/off checking of volumes overlaps
|
||||
//
|
||||
G4bool checkOverlaps = true;
|
||||
|
||||
//
|
||||
// World
|
||||
//
|
||||
G4double world_sizeXY = 1.2*env_sizeXY;
|
||||
G4double world_sizeZ = 1.2*env_sizeZ;
|
||||
G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
|
||||
|
||||
auto solidWorld = new G4Box("World", // its name
|
||||
0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ); // its size
|
||||
|
||||
auto logicWorld = new G4LogicalVolume(solidWorld, // its solid
|
||||
world_mat, // its material
|
||||
"World"); // its name
|
||||
|
||||
auto physWorld = new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
logicWorld, // its logical volume
|
||||
"World", // its name
|
||||
nullptr, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
checkOverlaps); // overlaps checking
|
||||
|
||||
//
|
||||
// Envelope
|
||||
//
|
||||
auto solidEnv = new G4Box("Envelope", // its name
|
||||
0.5 * env_sizeXY, 0.5 * env_sizeXY, 0.5 * env_sizeZ); // its size
|
||||
|
||||
auto logicEnv = new G4LogicalVolume(solidEnv, // its solid
|
||||
env_mat, // its material
|
||||
"Envelope"); // its name
|
||||
|
||||
new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
logicEnv, // its logical volume
|
||||
"Envelope", // its name
|
||||
logicWorld, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
checkOverlaps); // overlaps checking
|
||||
|
||||
//
|
||||
// Shape 1
|
||||
//
|
||||
G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE");
|
||||
G4ThreeVector pos1 = G4ThreeVector(0, 2*cm, -7*cm);
|
||||
|
||||
// Conical section shape
|
||||
G4double shape1_rmina = 0.*cm, shape1_rmaxa = 2.*cm;
|
||||
G4double shape1_rminb = 0.*cm, shape1_rmaxb = 4.*cm;
|
||||
G4double shape1_hz = 3.*cm;
|
||||
G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg;
|
||||
auto solidShape1 = new G4Cons("Shape1", shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb,
|
||||
shape1_hz, shape1_phimin, shape1_phimax);
|
||||
|
||||
auto logicShape1 = new G4LogicalVolume(solidShape1, // its solid
|
||||
shape1_mat, // its material
|
||||
"Shape1"); // its name
|
||||
|
||||
new G4PVPlacement(nullptr, // no rotation
|
||||
pos1, // at position
|
||||
logicShape1, // its logical volume
|
||||
"Shape1", // its name
|
||||
logicEnv, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
checkOverlaps); // overlaps checking
|
||||
|
||||
//
|
||||
// Shape 2
|
||||
//
|
||||
G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_BONE_COMPACT_ICRU");
|
||||
G4ThreeVector pos2 = G4ThreeVector(0, -1*cm, 7*cm);
|
||||
|
||||
// Trapezoid shape
|
||||
G4double shape2_dxa = 12*cm, shape2_dxb = 12*cm;
|
||||
G4double shape2_dya = 10*cm, shape2_dyb = 16*cm;
|
||||
G4double shape2_dz = 6*cm;
|
||||
auto solidShape2 = new G4Trd("Shape2", // its name
|
||||
0.5 * shape2_dxa, 0.5 * shape2_dxb, 0.5 * shape2_dya, 0.5 * shape2_dyb,
|
||||
0.5 * shape2_dz); // its size
|
||||
|
||||
auto logicShape2 = new G4LogicalVolume(solidShape2, // its solid
|
||||
shape2_mat, // its material
|
||||
"Shape2"); // its name
|
||||
|
||||
new G4PVPlacement(nullptr, // no rotation
|
||||
pos2, // at position
|
||||
logicShape2, // its logical volume
|
||||
"Shape2", // its name
|
||||
logicEnv, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
checkOverlaps); // overlaps checking
|
||||
|
||||
// Set Shape2 as scoring volume
|
||||
//
|
||||
fScoringVolume = logicShape2;
|
||||
|
||||
//
|
||||
//always return the physical World
|
||||
//
|
||||
return physWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
+18
-22
@@ -24,43 +24,39 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1Run.cc
|
||||
/// \brief Implementation of the B1Run class
|
||||
/// \file B1/src/EventAction.cc
|
||||
/// \brief Implementation of the B1::EventAction class
|
||||
|
||||
#include "B1Run.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "RunAction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
namespace B1
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1Run::B1Run()
|
||||
: G4Run(),
|
||||
fEdep(0.),
|
||||
fEdep2(0.)
|
||||
EventAction::EventAction(B1Con::RunAction* runAction)
|
||||
: fRunAction(runAction)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1Run::~B1Run()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1Run::Merge(const G4Run* run)
|
||||
void EventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
const B1Run* localRun = static_cast<const B1Run*>(run);
|
||||
fEdep += localRun->fEdep;
|
||||
fEdep2 += localRun->fEdep2;
|
||||
|
||||
G4Run::Merge(run);
|
||||
fEdep = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1Run::AddEdep (G4double edep)
|
||||
void EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
fEdep += edep;
|
||||
fEdep2 += edep*edep;
|
||||
// accumulate statistics in run action
|
||||
fRunAction->AddEdep(fEdep);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
}
|
||||
+13
-10
@@ -24,10 +24,10 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the B1PrimaryGeneratorAction class
|
||||
/// \file B1/src/PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the B1::PrimaryGeneratorAction class
|
||||
|
||||
#include "B1PrimaryGeneratorAction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
@@ -39,12 +39,12 @@
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
namespace B1
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1PrimaryGeneratorAction::B1PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),
|
||||
fEnvelopeBox(0)
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
@@ -61,14 +61,14 @@ B1PrimaryGeneratorAction::B1PrimaryGeneratorAction()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1PrimaryGeneratorAction::~B1PrimaryGeneratorAction()
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
//this function is called at the begining of ecah event
|
||||
//
|
||||
@@ -96,7 +96,7 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
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()",
|
||||
G4Exception("PrimaryGeneratorAction::GeneratePrimaries()",
|
||||
"MyCode0002",JustWarning,msg);
|
||||
}
|
||||
|
||||
@@ -112,3 +112,6 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
|
||||
|
||||
+72
-59
@@ -24,24 +24,27 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1ConRunAction.cc
|
||||
/// \brief Implementation of the B1ConRunAction class
|
||||
/// \file B1/src/RunAction.cc
|
||||
/// \brief Implementation of the B1::RunAction class
|
||||
|
||||
#include "B1ConRunAction.hh"
|
||||
#include "B1PrimaryGeneratorAction.hh"
|
||||
#include "B1DetectorConstruction.hh"
|
||||
#include "B1ConRun.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4AccumulableManager.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
namespace B1Con
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1ConRunAction::B1ConRunAction()
|
||||
: G4UserRunAction()
|
||||
RunAction::RunAction()
|
||||
{
|
||||
// add new units for dose
|
||||
//
|
||||
@@ -55,65 +58,60 @@ B1ConRunAction::B1ConRunAction()
|
||||
new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
|
||||
new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
|
||||
|
||||
// Register accumulable to the accumulable manager
|
||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
||||
accumulableManager->RegisterAccumulable(fEdep);
|
||||
accumulableManager->RegisterAccumulable(fEdep2);
|
||||
accumulableManager->RegisterAccumulable(&fEdepPerEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1ConRunAction::~B1ConRunAction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* B1ConRunAction::GenerateRun()
|
||||
void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
return new B1ConRun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1ConRunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
|
||||
//inform the runManager to save random number seed
|
||||
// inform the runManager to save random number seed
|
||||
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
|
||||
|
||||
if (IsMaster()) {
|
||||
fdose_tally = new G4ConvergenceTester("DOSE_TALLY");
|
||||
//fdose_tally = new G4ConvergenceTester();
|
||||
}
|
||||
// reset accumulables to their initial values
|
||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
||||
accumulableManager->Reset();
|
||||
|
||||
if (IsMaster()) {
|
||||
fDoseTally = new G4ConvergenceTester("DOSE_TALLY");
|
||||
//fDoseTally = new G4ConvergenceTester();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1ConRunAction::EndOfRunAction(const G4Run* aRun)
|
||||
void RunAction::EndOfRunAction(const G4Run* run)
|
||||
{
|
||||
G4int nofEvents = aRun->GetNumberOfEvent();
|
||||
G4int nofEvents = run->GetNumberOfEvent();
|
||||
if (nofEvents == 0) return;
|
||||
|
||||
const B1ConRun* b1ConRun = static_cast<const B1ConRun*>(aRun);
|
||||
// Merge accumulables
|
||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
||||
accumulableManager->Merge();
|
||||
|
||||
// Compute dose
|
||||
// Compute dose = total energy deposit in a run and its variance
|
||||
//
|
||||
G4double edep = b1ConRun->GetEdep();
|
||||
G4double edep2 = b1ConRun->GetEdep2();
|
||||
G4double edep = fEdep.GetValue();
|
||||
G4double edep2 = fEdep2.GetValue();
|
||||
|
||||
G4double rms = edep2 - edep*edep/nofEvents;
|
||||
if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
|
||||
|
||||
const B1DetectorConstruction* detectorConstruction
|
||||
= static_cast<const B1DetectorConstruction*>
|
||||
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
||||
G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
|
||||
const auto detConstruction = static_cast<const B1::DetectorConstruction*>(
|
||||
G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
||||
G4double mass = detConstruction->GetScoringVolume()->GetMass();
|
||||
G4double dose = edep/mass;
|
||||
G4double rmsDose = rms/mass;
|
||||
|
||||
// Run conditions
|
||||
// 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());
|
||||
const auto generatorAction = static_cast<const B1::PrimaryGeneratorAction*>(
|
||||
G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
||||
G4String runCondition;
|
||||
if (generatorAction)
|
||||
{
|
||||
@@ -126,33 +124,48 @@ void B1ConRunAction::EndOfRunAction(const G4Run* aRun)
|
||||
|
||||
// Print
|
||||
//
|
||||
if (IsMaster())
|
||||
{
|
||||
|
||||
for ( G4int i = 0 ; i != b1ConRun->GetNumberOfEvent(); i++ ) {
|
||||
G4double aDose = b1ConRun->GetEdepPerEvent(i)/mass/gray;
|
||||
fdose_tally->AddScore( aDose );
|
||||
if (IsMaster()) {
|
||||
for (auto edepPerEvent : fEdepPerEvent.GetVector()) {
|
||||
G4double dosePerEvent = edepPerEvent/mass/gray;
|
||||
fDoseTally->AddScore(dosePerEvent);
|
||||
}
|
||||
|
||||
fdose_tally->ShowResult();
|
||||
fdose_tally->ShowHistory();
|
||||
delete fdose_tally;
|
||||
fDoseTally->ShowResult();
|
||||
fDoseTally->ShowHistory();
|
||||
delete fDoseTally;
|
||||
fDoseTally = nullptr;
|
||||
|
||||
G4cout
|
||||
<< "\n--------------------End of Global Run-----------------------";
|
||||
<< G4endl
|
||||
<< "--------------------End of Global Run-----------------------";
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
G4cout
|
||||
<< "\n--------------------End of Local Run------------------------";
|
||||
<< G4endl
|
||||
<< "--------------------End of Local Run------------------------";
|
||||
}
|
||||
|
||||
G4cout
|
||||
<< "\n The run consists of " << nofEvents << " "<< runCondition
|
||||
<< "\n Dose in scoring volume : "
|
||||
<< G4BestUnit(dose,"Dose") << " +- " << G4BestUnit(rmsDose,"Dose")
|
||||
<< "\n------------------------------------------------------------\n"
|
||||
<< G4endl
|
||||
<< " The run consists of " << nofEvents << " "<< runCondition
|
||||
<< G4endl
|
||||
<< " Cumulated dose per run, in scoring volume : "
|
||||
<< G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose")
|
||||
<< G4endl
|
||||
<< "------------------------------------------------------------"
|
||||
<< G4endl
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::AddEdep(G4double edep)
|
||||
{
|
||||
fEdep += edep;
|
||||
fEdep2 += edep*edep;
|
||||
fEdepPerEvent.AddValue(edep);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
+15
-19
@@ -24,40 +24,35 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file B1SteppingAction.cc
|
||||
/// \brief Implementation of the B1SteppingAction class
|
||||
/// \file B1/src/SteppingAction.cc
|
||||
/// \brief Implementation of the B1::SteppingAction class
|
||||
|
||||
#include "B1SteppingAction.hh"
|
||||
#include "B1EventAction.hh"
|
||||
#include "B1DetectorConstruction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4Step.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
namespace B1
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1SteppingAction::B1SteppingAction(B1EventAction* eventAction)
|
||||
: G4UserSteppingAction(),
|
||||
fEventAction(eventAction),
|
||||
fScoringVolume(0)
|
||||
SteppingAction::SteppingAction(EventAction* eventAction)
|
||||
: fEventAction(eventAction)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B1SteppingAction::~B1SteppingAction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
void SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
{
|
||||
if (!fScoringVolume) {
|
||||
const B1DetectorConstruction* detectorConstruction
|
||||
= static_cast<const B1DetectorConstruction*>
|
||||
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
||||
fScoringVolume = detectorConstruction->GetScoringVolume();
|
||||
const auto detConstruction = static_cast<const DetectorConstruction*>(
|
||||
G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
||||
fScoringVolume = detConstruction->GetScoringVolume();
|
||||
}
|
||||
|
||||
// get volume of the current step
|
||||
@@ -75,3 +70,4 @@ void B1SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user