Geant4 examples
Public Member Functions | Private Attributes
ExG4DetectorConstruction02 Class Reference

Simple detector construction with a box volume placed in a world. More...

#include <Doxymodules_common.h>

Inheritance diagram for ExG4DetectorConstruction02:
G4VUserDetectorConstruction

List of all members.

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 G4VPhysicalVolumeConstruct ()
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
G4LogicalVolumefBoxVolume
G4LogicalVolumefWorldVolume

Detailed Description

Simple detector construction with a box volume placed in a world.

Definition at line 31 of file Doxymodules_common.h.


Constructor & Destructor Documentation

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.

{ 
}

Member Function Documentation

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

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

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

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

Member Data Documentation

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.


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