Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Common::DetectorConstruction0 Class Reference

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

#include <Doxymodules_common.h>

Inheritance diagram for Common::DetectorConstruction0:
G4VUserDetectorConstruction

Public Member Functions

 DetectorConstruction0 (const G4String &materialName="G4_AIR", G4double hx=50 *CLHEP::cm, G4double hy=50 *CLHEP::cm, G4double hz=50 *CLHEP::cm)
 
 ~DetectorConstruction0 () override
 
G4VPhysicalVolumeConstruct () override
 
void SetMaterial (const G4String &materialName)
 
void SetDimensions (G4ThreeVector dimensions)
 

Private Member Functions

void DefineCommands ()
 

Private Attributes

G4GenericMessengerfMessenger = nullptr
 
G4String fMaterialName
 
G4ThreeVector fDimensions
 
G4LogicalVolumefWorldVolume = nullptr
 

Detailed Description

Simple detector construction with only a world volume.

Definition at line 13 of file Doxymodules_common.h.

Constructor & Destructor Documentation

◆ DetectorConstruction0()

Common::DetectorConstruction0::DetectorConstruction0 ( const G4String materialName = "G4_AIR",
G4double  hx = 50*CLHEP::cm,
G4double  hy = 50*CLHEP::cm,
G4double  hz = 50*CLHEP::cm 
)

Definition at line 44 of file DetectorConstruction0.cc.

◆ ~DetectorConstruction0()

Common::DetectorConstruction0::~DetectorConstruction0 ( )
override

Definition at line 55 of file DetectorConstruction0.cc.

56{
57 delete fMessenger;
58}

Member Function Documentation

◆ Construct()

G4VPhysicalVolume * Common::DetectorConstruction0::Construct ( )
override

Definition at line 62 of file DetectorConstruction0.cc.

63{
64 // Define materials via NIST manager
65 //
66 auto nistManager = G4NistManager::Instance();
67
68 auto material = nistManager->FindOrBuildMaterial(fMaterialName);
69
70 // World
71 //
72 auto sWorld
73 = new G4Box("World", //name
74 fDimensions.x(), //dimensions (half-lentghs)
75 fDimensions.y(),
76 fDimensions.z());
77
79 = new G4LogicalVolume(sWorld, //shape
80 material, //material
81 "World"); //name
82
83 auto pWorld
84 = new G4PVPlacement(0, //no rotation
85 G4ThreeVector(), //at (0,0,0)
86 fWorldVolume, //logical volume
87 "World", //name
88 0, //mother volume
89 false, //no boolean operation
90 0); //copy number
91
92 //always return the root volume
93 //
94 return pWorld;
95}

◆ SetMaterial()

void Common::DetectorConstruction0::SetMaterial ( const G4String materialName)

Definition at line 99 of file DetectorConstruction0.cc.

100{
101 auto nistManager = G4NistManager::Instance();
102
103 auto newMaterial = nistManager->FindOrBuildMaterial(materialName);
104 if ( ! newMaterial ) {
105 G4cerr << "Material " << materialName << " not found." << G4endl;
106 G4cerr << "The box material was not changed." << G4endl;
107 return;
108 }
109
110 if ( fWorldVolume ) fWorldVolume->SetMaterial(newMaterial);
111 G4cout << "Material of box changed to " << materialName << G4endl;
112}

◆ SetDimensions()

void Common::DetectorConstruction0::SetDimensions ( G4ThreeVector  dimensions)

Set world dimension (in half lengths). This setting has effect only if called in PreInit> phase

Definition at line 116 of file DetectorConstruction0.cc.

117{
118/// Set world dimension (in half lengths).
119/// This setting has effect only if called in PreInit> phase
120
121 fDimensions = dimensions;
122}

◆ DefineCommands()

void Common::DetectorConstruction0::DefineCommands ( )
private

Definition at line 126 of file DetectorConstruction0.cc.

127{
128 // Define /B5/detector command directory using generic messenger class
130 "/detector/",
131 "Detector control");
132
133 // setMaterial command
134 auto& setMaterialCmd
135 = fMessenger->DeclareMethod("setMaterial",
137 "Set world material name.");
138 setMaterialCmd.SetParameterName("materialName", false);
139 setMaterialCmd.SetDefaultValue("G4_AIR");
140 setMaterialCmd.SetStates(G4State_PreInit);
141
142 // setDimensions command
143 auto& setDimensionsCmd
144 = fMessenger->DeclareMethodWithUnit("setDimensions", "mm",
146 "Set world dimensions (in half lentgh).");
147 setDimensionsCmd.SetParameterName("dimensions", false);
148 setDimensionsCmd.SetStates(G4State_PreInit);
149}
void SetDimensions(G4ThreeVector dimensions)
void SetMaterial(const G4String &materialName)

Member Data Documentation

◆ fMessenger

G4GenericMessenger* Common::DetectorConstruction0::fMessenger = nullptr
private

Definition at line 67 of file DetectorConstruction0.hh.

◆ fMaterialName

G4String Common::DetectorConstruction0::fMaterialName
private

Definition at line 68 of file DetectorConstruction0.hh.

◆ fDimensions

G4ThreeVector Common::DetectorConstruction0::fDimensions
private

Definition at line 69 of file DetectorConstruction0.hh.

◆ fWorldVolume

G4LogicalVolume* Common::DetectorConstruction0::fWorldVolume = nullptr
private

Definition at line 70 of file DetectorConstruction0.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration