Import Geant4 11.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2022-12-09 14:43:28 +01:00
parent c07cea1fe0
commit 9f34590941
3810 changed files with 200490 additions and 182326 deletions
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
/// \file DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
/// \file common/src/DetectorConstruction.cc
/// \brief Implementation of the Common::DetectorConstruction class
#include "DetectorConstruction.hh"
@@ -36,6 +36,9 @@
#include "G4PVPlacement.hh"
#include "G4GenericMessenger.hh"
namespace Common
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction(
@@ -43,14 +46,10 @@ DetectorConstruction::DetectorConstruction(
G4double boxHx, G4double boxHy, G4double boxHz,
const G4String& worldMaterialName,
G4double worldSizeFactor)
: G4VUserDetectorConstruction(),
fMessenger(nullptr),
fBoxMaterialName(boxMaterialName),
: fBoxMaterialName(boxMaterialName),
fWorldMaterialName(worldMaterialName),
fBoxDimensions(boxHx*2, boxHy*2, boxHz*2),
fWorldSizeFactor(worldSizeFactor),
fBoxVolume(nullptr),
fWorldVolume(nullptr)
fWorldSizeFactor(worldSizeFactor)
{
DefineCommands();
}
@@ -72,25 +71,25 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
auto worldMaterial = nistManager->FindOrBuildMaterial(fWorldMaterialName);
auto boxMaterial = nistManager->FindOrBuildMaterial(fBoxMaterialName);
// Geometry parameters
//
G4ThreeVector worldDimensions = fBoxDimensions * fWorldSizeFactor;
// World
//
auto sWorld
auto sWorld
= new G4Box("World", //name
worldDimensions.x(), //dimensions (half-lentghs)
worldDimensions.y(),
worldDimensions.y(),
worldDimensions.z());
fWorldVolume
fWorldVolume
= new G4LogicalVolume(sWorld, //shape
worldMaterial, //material
"World"); //name
auto pWorld
auto pWorld
= new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
@@ -98,23 +97,23 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
0, //mother volume
false, //no boolean operation
0); //copy number
// Box
//
auto sBox
//
auto sBox
= new G4Box("Box", //its name
fBoxDimensions.x(), //dimensions (half-lengths)
fBoxDimensions.y(),
fBoxDimensions.y(),
fBoxDimensions.z());
fBoxVolume
fBoxVolume
= new G4LogicalVolume(sBox, //its shape
boxMaterial, //its material
"Box"); //its name
new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fBoxVolume, //its logical volume
fBoxVolume, //its logical volume
"Box", //its name
fWorldVolume, //its mother volume
false, //no boolean operation
@@ -126,7 +125,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetBoxMaterial(const G4String& materialName)
{
auto nistManager = G4NistManager::Instance();
@@ -136,14 +135,14 @@ void DetectorConstruction::SetBoxMaterial(const G4String& materialName)
G4cerr << "Material " << materialName << " not found." << G4endl;
G4cerr << "The box material was not changed." << G4endl;
return;
}
}
if ( fBoxVolume ) fBoxVolume->SetMaterial(newMaterial);
G4cout << "Material of box changed to " << materialName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldMaterial(const G4String& materialName)
{
auto nistManager = G4NistManager::Instance();
@@ -153,45 +152,45 @@ void DetectorConstruction::SetWorldMaterial(const G4String& materialName)
G4cerr << "Material " << materialName << " not found." << G4endl;
G4cerr << "The box material was not changed." << G4endl;
return;
}
}
if ( fWorldVolume ) fWorldVolume->SetMaterial(newMaterial);
G4cout << "Material of box changed to " << materialName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetBoxDimensions(G4ThreeVector dimensions)
void DetectorConstruction::SetBoxDimensions(G4ThreeVector dimensions)
{
/// Set box dimension (in half lengths).
/// This setting has effect only if called in PreInit> phase
fBoxDimensions = dimensions;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldSizeFactor(G4double factor)
void DetectorConstruction::SetWorldSizeFactor(G4double factor)
{
/// Set the multiplication factor from box dimensions to world dimensions.
/// This setting has effect only if called in PreInit> phase
fWorldSizeFactor = factor;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineCommands()
{
// Define /B5/detector command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/detector/",
fMessenger = new G4GenericMessenger(this,
"/detector/",
"Detector control");
// setBoxMaterial command
auto& setBoxMaterialCmd
= fMessenger->DeclareMethod("setBoxMaterial",
&DetectorConstruction::SetBoxMaterial,
&DetectorConstruction::SetBoxMaterial,
"Set box material name.");
setBoxMaterialCmd.SetParameterName("boxMaterialName", false);
setBoxMaterialCmd.SetDefaultValue("G4_AIR");
@@ -199,7 +198,7 @@ void DetectorConstruction::DefineCommands()
// setWorldMaterial command
auto& setWorldMaterialCmd
= fMessenger->DeclareMethod("setWorldMaterial",
&DetectorConstruction::SetWorldMaterial,
&DetectorConstruction::SetWorldMaterial,
"Set world material name.");
setWorldMaterialCmd.SetParameterName("worldMaterialName", false);
setWorldMaterialCmd.SetDefaultValue("G4_AIR");
@@ -207,19 +206,21 @@ void DetectorConstruction::DefineCommands()
// setBoxDimensions command
auto& setBoxDimensionsCmd
= fMessenger->DeclareMethodWithUnit("setBoxDimensions", "mm",
&DetectorConstruction::SetBoxDimensions,
&DetectorConstruction::SetBoxDimensions,
"Set box dimensions (in half lentgh).");
setBoxDimensionsCmd.SetParameterName("boxDimensions", false);
setBoxDimensionsCmd.SetStates(G4State_PreInit);
// setWorldSizeFactor command
auto& setWorldSizeFactorCmd
auto& setWorldSizeFactorCmd
= fMessenger->DeclareMethod("setWorldSizeFactor",
&DetectorConstruction::SetWorldSizeFactor,
&DetectorConstruction::SetWorldSizeFactor,
"Set the multiplication factor from box dimensions to world dimensions.");
setWorldSizeFactorCmd.SetParameterName("worldSizeFactor", false);
setWorldSizeFactorCmd.SetRange("WorldSizeFactor >= 1");
setWorldSizeFactorCmd.SetStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}