Geant4 examples
Public Member Functions | Private Attributes
ExG4DetectorConstruction01 Class Reference

Simple detector construction with only a world volume. More...

#include <Doxymodules_common.h>

Inheritance diagram for ExG4DetectorConstruction01:
G4VUserDetectorConstruction

List of all members.

Public Member Functions

 ExG4DetectorConstruction01 (const G4String &materialName="G4_AIR", G4double hx=50 *cm, G4double hy=50 *cm, G4double hz=50 *cm)
 ~ExG4DetectorConstruction01 ()
virtual G4VPhysicalVolumeConstruct ()
void SetMaterial (const G4String &materialName)
void SetDimensions (G4double hx, G4double hy, G4double hz)

Private Attributes

ExG4DetectorConstruction01Messenger fMessenger
G4String fMaterialName
G4ThreeVector fDimensions
G4LogicalVolumefWorldVolume

Detailed Description

Simple detector construction with only a world volume.

Definition at line 29 of file Doxymodules_common.h.


Constructor & Destructor Documentation

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.

{ 
}

Member Function Documentation

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;
}
void ExG4DetectorConstruction01::SetMaterial ( const G4String materialName)

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;
}
void ExG4DetectorConstruction01::SetDimensions ( G4double  hx,
G4double  hy,
G4double  hz 
)

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);
}  

Member Data Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines