|
Geant4 examples
|
Simple detector construction with a box volume placed in a world. More...
#include <Doxymodules_common.h>
Public Member Functions | |
| ExG4DetectorConstruction02 (const G4String &boxMaterialName="G4_AIR", G4double boxHx=40 *cm, G4double boxHy=40 *cm, G4double boxHz=40 *cm, const G4String &worldMaterialName="G4_AIR", G4double worldSizeFactor=1.25) | |
| ~ExG4DetectorConstruction02 () | |
| virtual G4VPhysicalVolume * | Construct () |
| void | SetBoxMaterial (const G4String &materialName) |
| void | SetWorldMaterial (const G4String &materialName) |
| void | SetBoxDimensions (G4double hx, G4double hy, G4double hz) |
| void | SetWorldSizeFactor (G4double factor) |
Private Attributes | |
| ExG4DetectorConstruction02Messenger | fMessenger |
| G4String | fBoxMaterialName |
| G4String | fWorldMaterialName |
| G4ThreeVector | fBoxDimensions |
| G4double | fWorldSizeFactor |
| G4LogicalVolume * | fBoxVolume |
| G4LogicalVolume * | fWorldVolume |
Simple detector construction with a box volume placed in a world.
Definition at line 31 of file Doxymodules_common.h.
| ExG4DetectorConstruction02::ExG4DetectorConstruction02 | ( | const G4String & | boxMaterialName = "G4_AIR", |
| G4double | boxHx = 40*cm, |
||
| G4double | boxHy = 40*cm, |
||
| G4double | boxHz = 40*cm, |
||
| const G4String & | worldMaterialName = "G4_AIR", |
||
| G4double | worldSizeFactor = 1.25 |
||
| ) |
Definition at line 43 of file ExG4DetectorConstruction02.cc.
: G4VUserDetectorConstruction(), fMessenger(this), fBoxMaterialName(boxMaterialName), fWorldMaterialName(worldMaterialName), fBoxDimensions(boxHx*2, boxHy*2, boxHz*2), fWorldSizeFactor(worldSizeFactor), fBoxVolume(0), fWorldVolume(0) { }
| ExG4DetectorConstruction02::~ExG4DetectorConstruction02 | ( | ) |
Definition at line 61 of file ExG4DetectorConstruction02.cc.
{
}
| G4VPhysicalVolume * ExG4DetectorConstruction02::Construct | ( | ) | [virtual] |
Implements G4VUserDetectorConstruction.
Definition at line 67 of file ExG4DetectorConstruction02.cc.
{
// Define materials via NIST manager
//
G4NistManager* nistManager = G4NistManager::Instance();
G4bool fromIsotopes = false;
G4Material* worldMaterial
= nistManager->FindOrBuildMaterial(fWorldMaterialName, fromIsotopes);
G4Material* boxMaterial
= nistManager->FindOrBuildMaterial(fBoxMaterialName, fromIsotopes);
// Geometry parameters
//
G4ThreeVector worldDimensions = fBoxDimensions * fWorldSizeFactor;
// World
//
G4Box* sWorld
= new G4Box("World", //name
worldDimensions.x(), //dimensions (half-lentghs)
worldDimensions.y(),
worldDimensions.z());
fWorldVolume
= new G4LogicalVolume(sWorld, //shape
worldMaterial, //material
"World"); //name
G4VPhysicalVolume* pWorld
= new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
"World", //name
0, //mother volume
false, //no boolean operation
0); //copy number
// Box
//
G4Box* sBox
= new G4Box("Box", //its name
fBoxDimensions.x(), //dimensions (half-lengths)
fBoxDimensions.y(),
fBoxDimensions.z());
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
"Box", //its name
fWorldVolume, //its mother volume
false, //no boolean operation
0); //copy number
//always return the root volume
//
return pWorld;
}
Definition at line 136 of file ExG4DetectorConstruction02.cc.
{
G4NistManager* nistManager = G4NistManager::Instance();
G4bool fromIsotopes = false;
G4Material* newMaterial
= nistManager->FindOrBuildMaterial(materialName, fromIsotopes);
if ( ! newMaterial ) {
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;
}
Definition at line 156 of file ExG4DetectorConstruction02.cc.
{
G4NistManager* nistManager = G4NistManager::Instance();
G4bool fromIsotopes = false;
G4Material* newMaterial
= nistManager->FindOrBuildMaterial(materialName, fromIsotopes);
if ( ! newMaterial ) {
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;
}
Set box dimension (in half lengths). This setting has effect only if called in PreInit> phase
Definition at line 176 of file ExG4DetectorConstruction02.cc.
{
fBoxDimensions = G4ThreeVector(hx, hy, hz);
}
| void ExG4DetectorConstruction02::SetWorldSizeFactor | ( | G4double | factor | ) |
Set the multiplication factor from box dimensions to world dimensions. This setting has effect only if called in PreInit> phase
Definition at line 187 of file ExG4DetectorConstruction02.cc.
{
fWorldSizeFactor = factor;
}
Definition at line 70 of file ExG4DetectorConstruction02.hh.
Definition at line 72 of file ExG4DetectorConstruction02.hh.
Definition at line 73 of file ExG4DetectorConstruction02.hh.
Definition at line 74 of file ExG4DetectorConstruction02.hh.
Definition at line 75 of file ExG4DetectorConstruction02.hh.
Definition at line 76 of file ExG4DetectorConstruction02.hh.
Definition at line 77 of file ExG4DetectorConstruction02.hh.
1.7.4