Import Geant4 11.0.0.beta source tree
This commit is contained in:
@@ -60,11 +60,11 @@ void B1ActionInitialization::Build() const
|
||||
|
||||
B1RunAction* runAction = new B1RunAction;
|
||||
SetUserAction(runAction);
|
||||
|
||||
|
||||
B1EventAction* eventAction = new B1EventAction(runAction);
|
||||
SetUserAction(eventAction);
|
||||
|
||||
|
||||
SetUserAction(new B1SteppingAction(eventAction));
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
B1DetectorConstruction::B1DetectorConstruction()
|
||||
: G4VUserDetectorConstruction(),
|
||||
fScoringVolume(0)
|
||||
fScoringVolume(nullptr)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -55,36 +55,36 @@ 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 =
|
||||
|
||||
G4Box* solidWorld =
|
||||
new G4Box("World", //its name
|
||||
0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size
|
||||
|
||||
G4LogicalVolume* logicWorld =
|
||||
|
||||
G4LogicalVolume* logicWorld =
|
||||
new G4LogicalVolume(solidWorld, //its solid
|
||||
world_mat, //its material
|
||||
"World"); //its name
|
||||
|
||||
G4VPhysicalVolume* physWorld =
|
||||
|
||||
G4VPhysicalVolume* physWorld =
|
||||
new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
logicWorld, //its logical volume
|
||||
@@ -93,19 +93,19 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
|
||||
false, //no boolean operation
|
||||
0, //copy number
|
||||
checkOverlaps); //overlaps checking
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Envelope
|
||||
//
|
||||
G4Box* solidEnv =
|
||||
//
|
||||
G4Box* solidEnv =
|
||||
new G4Box("Envelope", //its name
|
||||
0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); //its size
|
||||
|
||||
G4LogicalVolume* logicEnv =
|
||||
|
||||
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
|
||||
@@ -114,28 +114,28 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
|
||||
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
|
||||
|
||||
// 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",
|
||||
G4Cons* solidShape1 =
|
||||
new G4Cons("Shape1",
|
||||
shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb, shape1_hz,
|
||||
shape1_phimin, shape1_phimax);
|
||||
|
||||
G4LogicalVolume* logicShape1 =
|
||||
|
||||
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
|
||||
@@ -145,26 +145,26 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
|
||||
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
|
||||
// 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 =
|
||||
G4double shape2_dz = 6*cm;
|
||||
G4Trd* solidShape2 =
|
||||
new G4Trd("Shape2", //its name
|
||||
0.5*shape2_dxa, 0.5*shape2_dxb,
|
||||
0.5*shape2_dxa, 0.5*shape2_dxb,
|
||||
0.5*shape2_dya, 0.5*shape2_dyb, 0.5*shape2_dz); //its size
|
||||
|
||||
G4LogicalVolume* logicShape2 =
|
||||
|
||||
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
|
||||
@@ -173,7 +173,7 @@ G4VPhysicalVolume* B1DetectorConstruction::Construct()
|
||||
false, //no boolean operation
|
||||
0, //copy number
|
||||
checkOverlaps); //overlaps checking
|
||||
|
||||
|
||||
// Set Shape2 as scoring volume
|
||||
//
|
||||
fScoringVolume = logicShape2;
|
||||
|
||||
@@ -39,7 +39,7 @@ B1EventAction::B1EventAction(B1RunAction* runAction)
|
||||
: G4UserEventAction(),
|
||||
fRunAction(runAction),
|
||||
fEdep(0.)
|
||||
{}
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -49,14 +49,14 @@ B1EventAction::~B1EventAction()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1EventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
{
|
||||
fEdep = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
{
|
||||
// accumulate statistics in run action
|
||||
fRunAction->AddEdep(fEdep);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
|
||||
B1PrimaryGeneratorAction::B1PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),
|
||||
fEnvelopeBox(0)
|
||||
fParticleGun(nullptr),
|
||||
fEnvelopeBox(nullptr)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
@@ -76,7 +76,7 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
// In order to avoid dependence of PrimaryGeneratorAction
|
||||
// on DetectorConstruction class we get Envelope volume
|
||||
// from G4LogicalVolumeStore.
|
||||
|
||||
|
||||
G4double envSizeXY = 0;
|
||||
G4double envSizeZ = 0;
|
||||
|
||||
@@ -90,21 +90,21 @@ void B1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
if ( fEnvelopeBox ) {
|
||||
envSizeXY = fEnvelopeBox->GetXHalfLength()*2.;
|
||||
envSizeZ = fEnvelopeBox->GetZHalfLength()*2.;
|
||||
}
|
||||
}
|
||||
else {
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Envelope volume of box shape not found.\n";
|
||||
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;
|
||||
G4double size = 0.8;
|
||||
G4double x0 = size * envSizeXY * (G4UniformRand()-0.5);
|
||||
G4double y0 = size * envSizeXY * (G4UniformRand()-0.5);
|
||||
G4double z0 = -0.5 * envSizeZ;
|
||||
|
||||
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
|
||||
@@ -46,23 +46,23 @@ B1RunAction::B1RunAction()
|
||||
: G4UserRunAction(),
|
||||
fEdep(0.),
|
||||
fEdep2(0.)
|
||||
{
|
||||
{
|
||||
// add new units for dose
|
||||
//
|
||||
//
|
||||
const G4double milligray = 1.e-3*gray;
|
||||
const G4double microgray = 1.e-6*gray;
|
||||
const G4double nanogray = 1.e-9*gray;
|
||||
const G4double nanogray = 1.e-9*gray;
|
||||
const G4double picogray = 1.e-12*gray;
|
||||
|
||||
|
||||
new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
|
||||
new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
|
||||
new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
|
||||
new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
|
||||
new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
|
||||
|
||||
// Register accumulable to the accumulable manager
|
||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
||||
accumulableManager->RegisterAccumulable(fEdep);
|
||||
accumulableManager->RegisterAccumulable(fEdep2);
|
||||
accumulableManager->RegisterAccumulable(fEdep2);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -73,7 +73,7 @@ B1RunAction::~B1RunAction()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B1RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
{
|
||||
// inform the runManager to save random number seed
|
||||
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
|
||||
|
||||
@@ -90,7 +90,7 @@ void B1RunAction::EndOfRunAction(const G4Run* run)
|
||||
G4int nofEvents = run->GetNumberOfEvent();
|
||||
if (nofEvents == 0) return;
|
||||
|
||||
// Merge accumulables
|
||||
// Merge accumulables
|
||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
||||
accumulableManager->Merge();
|
||||
|
||||
@@ -98,9 +98,9 @@ void B1RunAction::EndOfRunAction(const G4Run* run)
|
||||
//
|
||||
G4double edep = fEdep.GetValue();
|
||||
G4double edep2 = fEdep2.GetValue();
|
||||
|
||||
|
||||
G4double rms = edep2 - edep*edep/nofEvents;
|
||||
if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
|
||||
if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
|
||||
|
||||
const B1DetectorConstruction* detectorConstruction
|
||||
= static_cast<const B1DetectorConstruction*>
|
||||
@@ -124,9 +124,9 @@ void B1RunAction::EndOfRunAction(const G4Run* run)
|
||||
G4double particleEnergy = particleGun->GetParticleEnergy();
|
||||
runCondition += G4BestUnit(particleEnergy,"Energy");
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
//
|
||||
//
|
||||
if (IsMaster()) {
|
||||
G4cout
|
||||
<< G4endl
|
||||
@@ -137,12 +137,12 @@ void B1RunAction::EndOfRunAction(const G4Run* run)
|
||||
<< G4endl
|
||||
<< "--------------------End of Local Run------------------------";
|
||||
}
|
||||
|
||||
|
||||
G4cout
|
||||
<< G4endl
|
||||
<< " The run consists of " << nofEvents << " "<< runCondition
|
||||
<< G4endl
|
||||
<< " Cumulated dose per run, in scoring volume : "
|
||||
<< " Cumulated dose per run, in scoring volume : "
|
||||
<< G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose")
|
||||
<< G4endl
|
||||
<< "------------------------------------------------------------"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
B1SteppingAction::B1SteppingAction(B1EventAction* eventAction)
|
||||
: G4UserSteppingAction(),
|
||||
fEventAction(eventAction),
|
||||
fScoringVolume(0)
|
||||
fScoringVolume(nullptr)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -53,24 +53,24 @@ B1SteppingAction::~B1SteppingAction()
|
||||
|
||||
void B1SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
{
|
||||
if (!fScoringVolume) {
|
||||
if (!fScoringVolume) {
|
||||
const B1DetectorConstruction* detectorConstruction
|
||||
= static_cast<const B1DetectorConstruction*>
|
||||
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
||||
fScoringVolume = detectorConstruction->GetScoringVolume();
|
||||
fScoringVolume = detectorConstruction->GetScoringVolume();
|
||||
}
|
||||
|
||||
// get volume of the current step
|
||||
G4LogicalVolume* volume
|
||||
G4LogicalVolume* volume
|
||||
= step->GetPreStepPoint()->GetTouchableHandle()
|
||||
->GetVolume()->GetLogicalVolume();
|
||||
|
||||
|
||||
// check if we are in scoring volume
|
||||
if (volume != fScoringVolume) return;
|
||||
|
||||
// collect energy deposited in this step
|
||||
G4double edepStep = step->GetTotalEnergyDeposit();
|
||||
fEventAction->AddEdep(edepStep);
|
||||
fEventAction->AddEdep(edepStep);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user