|
Geant4 examples
|
Simple detector construction with only a world volume. More...
#include <Doxymodules_common.h>
Public Member Functions | |
| ExG4DetectorConstruction01 (const G4String &materialName="G4_AIR", G4double hx=50 *cm, G4double hy=50 *cm, G4double hz=50 *cm) | |
| ~ExG4DetectorConstruction01 () | |
| virtual G4VPhysicalVolume * | Construct () |
| void | SetMaterial (const G4String &materialName) |
| void | SetDimensions (G4double hx, G4double hy, G4double hz) |
Private Attributes | |
| ExG4DetectorConstruction01Messenger | fMessenger |
| G4String | fMaterialName |
| G4ThreeVector | fDimensions |
| G4LogicalVolume * | fWorldVolume |
Simple detector construction with only a world volume.
Definition at line 29 of file Doxymodules_common.h.
| ExG4DetectorConstruction01::ExG4DetectorConstruction01 | ( | const G4String & | materialName = "G4_AIR", |
| G4double | hx = 50*cm, |
||
| G4double | hy = 50*cm, |
||
| G4double | hz = 50*cm |
||
| ) |
Definition at line 43 of file ExG4DetectorConstruction01.cc.
: G4VUserDetectorConstruction(), fMessenger(this), fMaterialName(materialName), fDimensions(hx, hy, hz), fWorldVolume(0) { }
| ExG4DetectorConstruction01::~ExG4DetectorConstruction01 | ( | ) |
Definition at line 56 of file ExG4DetectorConstruction01.cc.
{
}
| G4VPhysicalVolume * ExG4DetectorConstruction01::Construct | ( | ) | [virtual] |
Implements G4VUserDetectorConstruction.
Definition at line 62 of file ExG4DetectorConstruction01.cc.
{
// Define materials via NIST manager
//
G4NistManager* nistManager = G4NistManager::Instance();
G4bool fromIsotopes = false;
G4Material* material
= nistManager->FindOrBuildMaterial(fMaterialName, fromIsotopes);
// World
//
G4Box* sWorld
= new G4Box("World", //name
fDimensions.x(), //dimensions (half-lentghs)
fDimensions.y(),
fDimensions.z());
fWorldVolume
= new G4LogicalVolume(sWorld, //shape
material, //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
//always return the root volume
//
return pWorld;
}
Definition at line 102 of file ExG4DetectorConstruction01.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 world dimension (in half lengths). This setting has effect only if called in PreInit> phase
Definition at line 122 of file ExG4DetectorConstruction01.cc.
{
fDimensions = G4ThreeVector(hx, hy, hz);
}
Definition at line 66 of file ExG4DetectorConstruction01.hh.
Definition at line 68 of file ExG4DetectorConstruction01.hh.
Definition at line 69 of file ExG4DetectorConstruction01.hh.
Definition at line 70 of file ExG4DetectorConstruction01.hh.
1.7.4