QwGeant4
DetectorConstruction Class Reference

#include <DetectorConstruction.hh>

Inherits G4VUserDetectorConstruction.

+ Collaboration diagram for DetectorConstruction:

Public Member Functions

 DetectorConstruction ()
 
virtual ~DetectorConstruction ()
 
virtual G4VPhysicalVolume * Construct ()
 
void SetWorldMaterial (const G4String &)
 
void SetTargetMaterial (const G4String &)
 
void SetTargetRadius (G4double val)
 
void SetTargetLength (G4double val)
 
void UpdateGeometry ()
 

Private Member Functions

DetectorConstructionoperator= (const DetectorConstruction &right)
 
 DetectorConstruction (const DetectorConstruction &)
 

Private Attributes

G4double fRadius
 
G4double fLength
 
G4Material * fTargetMaterial
 
G4Material * fWorldMaterial
 
G4LogicalVolume * fLogicTarget
 
G4LogicalVolume * fLogicWorld
 
DetectorMessengerfDetectorMessenger
 

Detailed Description

Definition at line 54 of file DetectorConstruction.hh.

Constructor & Destructor Documentation

DetectorConstruction::DetectorConstruction ( )

Definition at line 69 of file DetectorConstruction.cc.

References fDetectorMessenger, fLength, fLogicTarget, fLogicWorld, fRadius, fTargetMaterial, and fWorldMaterial.

70 {
71  fLogicTarget = 0;
72  fLogicWorld = 0;
74 
75  fRadius = 5.*cm;
76  fLength = 10.*cm;
77 
78  fTargetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
79  fWorldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
80 }
G4LogicalVolume * fLogicWorld
DetectorMessenger * fDetectorMessenger
G4LogicalVolume * fLogicTarget
DetectorConstruction::~DetectorConstruction ( )
virtual

Definition at line 84 of file DetectorConstruction.cc.

References fDetectorMessenger.

85 {
86  delete fDetectorMessenger;
87 }
DetectorMessenger * fDetectorMessenger
DetectorConstruction::DetectorConstruction ( const DetectorConstruction )
private

Member Function Documentation

G4VPhysicalVolume * DetectorConstruction::Construct ( )
virtual

Definition at line 89 of file DetectorConstruction.cc.

References fLength, fLogicTarget, fLogicWorld, fRadius, fTargetMaterial, and fWorldMaterial.

Referenced by UpdateGeometry().

90 {
91  // Cleanup old geometry
92 
93  G4GeometryManager::GetInstance()->OpenGeometry();
94  G4PhysicalVolumeStore::GetInstance()->Clean();
95  G4LogicalVolumeStore::GetInstance()->Clean();
96  G4SolidStore::GetInstance()->Clean();
97 
98  // Sizes
99  G4double worldR = fRadius + cm;
100  G4double worldZ = fLength + cm;
101 
102  //
103  // World
104  //
105  G4Tubs* solidW = new G4Tubs("World", 0., worldR, 0.5*worldZ, 0., twopi);
106  fLogicWorld = new G4LogicalVolume(solidW, fWorldMaterial,"World");
107  G4VPhysicalVolume* world = new G4PVPlacement(0, G4ThreeVector(),
108  fLogicWorld, "World",
109  0, false, 0);
110 
111  //
112  // Target volume
113  //
114  G4Tubs* solidA = new G4Tubs("Target", 0., fRadius, 0.5*fLength, 0.,twopi);
115  fLogicTarget = new G4LogicalVolume( solidA, fTargetMaterial, "Target");
116  new G4PVPlacement(0, G4ThreeVector(), fLogicTarget, "Target",
117  fLogicWorld, false, 0);
118 
119  G4cout << "### Target consist of "
120  << fTargetMaterial->GetName()
121  << " disks with R(mm)= " << fRadius/mm
122  << " fLength(mm)= " << fLength/mm
123  << " ###" << G4endl;
124 
125  // colors
126  fLogicWorld->SetVisAttributes(G4VisAttributes::Invisible);
127 
128  G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
129  fLogicTarget->SetVisAttributes(regCcolor);
130 
131  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
132 
133  return world;
134 }
G4LogicalVolume * fLogicWorld
G4LogicalVolume * fLogicTarget

+ Here is the caller graph for this function:

DetectorConstruction& DetectorConstruction::operator= ( const DetectorConstruction right)
private
void DetectorConstruction::SetTargetLength ( G4double  val)

Definition at line 183 of file DetectorConstruction.cc.

References fLength.

Referenced by DetectorMessenger::SetNewValue().

184 {
185  if(val > 0.0 && val != fLength) {
186  fLength = val;
187  G4RunManager::GetRunManager()->GeometryHasBeenModified();
188  }
189 }

+ Here is the caller graph for this function:

void DetectorConstruction::SetTargetMaterial ( const G4String &  mat)

Definition at line 138 of file DetectorConstruction.cc.

References fLogicTarget, and fTargetMaterial.

Referenced by DetectorMessenger::SetNewValue().

139 {
140  // search the material by its name
141  G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat);
142 
143  if (material && material != fTargetMaterial) {
144  fTargetMaterial = material;
145  if(fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
146  G4RunManager::GetRunManager()->PhysicsHasBeenModified();
147  }
148 }
G4LogicalVolume * fLogicTarget

+ Here is the caller graph for this function:

void DetectorConstruction::SetTargetRadius ( G4double  val)

Definition at line 173 of file DetectorConstruction.cc.

References fRadius.

Referenced by DetectorMessenger::SetNewValue().

174 {
175  if(val > 0.0 && val != fRadius) {
176  fRadius = val;
177  G4RunManager::GetRunManager()->GeometryHasBeenModified();
178  }
179 }

+ Here is the caller graph for this function:

void DetectorConstruction::SetWorldMaterial ( const G4String &  mat)

Definition at line 152 of file DetectorConstruction.cc.

References fLogicWorld, and fWorldMaterial.

Referenced by DetectorMessenger::SetNewValue().

153 {
154  // search the material by its name
155  G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat);
156 
157  if (material && material != fWorldMaterial) {
158  fWorldMaterial = material;
159  if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial);
160  G4RunManager::GetRunManager()->PhysicsHasBeenModified();
161  }
162 }
G4LogicalVolume * fLogicWorld

+ Here is the caller graph for this function:

void DetectorConstruction::UpdateGeometry ( )

Definition at line 166 of file DetectorConstruction.cc.

References Construct().

Referenced by DetectorMessenger::SetNewValue().

167 {
168  G4RunManager::GetRunManager()->DefineWorldVolume(Construct());
169 }
virtual G4VPhysicalVolume * Construct()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

DetectorMessenger* DetectorConstruction::fDetectorMessenger
private

Definition at line 85 of file DetectorConstruction.hh.

Referenced by DetectorConstruction(), and ~DetectorConstruction().

G4double DetectorConstruction::fLength
private

Definition at line 77 of file DetectorConstruction.hh.

Referenced by Construct(), DetectorConstruction(), and SetTargetLength().

G4LogicalVolume* DetectorConstruction::fLogicTarget
private

Definition at line 82 of file DetectorConstruction.hh.

Referenced by Construct(), DetectorConstruction(), and SetTargetMaterial().

G4LogicalVolume* DetectorConstruction::fLogicWorld
private

Definition at line 83 of file DetectorConstruction.hh.

Referenced by Construct(), DetectorConstruction(), and SetWorldMaterial().

G4double DetectorConstruction::fRadius
private

Definition at line 76 of file DetectorConstruction.hh.

Referenced by Construct(), DetectorConstruction(), and SetTargetRadius().

G4Material* DetectorConstruction::fTargetMaterial
private

Definition at line 79 of file DetectorConstruction.hh.

Referenced by Construct(), DetectorConstruction(), and SetTargetMaterial().

G4Material* DetectorConstruction::fWorldMaterial
private

Definition at line 80 of file DetectorConstruction.hh.

Referenced by Construct(), DetectorConstruction(), and SetWorldMaterial().


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