Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/polarisation/Pol01/src/DetectorConstruction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /// \file polarisation/Pol01/src/DetectorConstruction.cc
27 /// \brief Implementation of the DetectorConstruction class
28 //
29 // $Id: DetectorConstruction.cc 68753 2013-04-05 10:26:04Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4Material.hh"
38 #include "G4Box.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 
42 #include "G4GeometryManager.hh"
43 #include "G4PhysicalVolumeStore.hh"
44 #include "G4LogicalVolumeStore.hh"
45 #include "G4SolidStore.hh"
46 
47 #include "G4UnitsTable.hh"
48 
49 #include "G4PolarizationManager.hh"
50 #include "G4NistManager.hh"
51 #include "G4SystemOfUnits.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 :pWorld(0), pBox(0), aMaterial(0)
57 {
58  boxSizeXY = 50*mm;
59  boxSizeZ = 5*mm;
60  worldSize = 1.*m;
61  aMaterial = 0;
62  wMaterial = 0;
63  SetTargetMaterial("G4_Fe");
64  SetWorldMaterial("G4_Galactic");
65  detectorMessenger = new DetectorMessenger(this);
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 {
72  delete detectorMessenger;
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  // Cleanup old geometry
84 
86 
87  // World
88  //
89  G4Box*
90  sWorld = new G4Box("World", //name
91  worldSize/2,worldSize/2,worldSize/2); //dimensions
92 
94  lWorld = new G4LogicalVolume(sWorld, //shape
95  wMaterial, //material
96  "World"); //name
97 
98  pWorld = new G4PVPlacement(0, //no rotation
99  G4ThreeVector(), //at (0,0,0)
100  lWorld, //logical volume
101  "World", //name
102  0, //mother volume
103  false, //no boolean operation
104  0); //copy number
105 
106  // Box
107  //
108  G4Box*
109  sBox = new G4Box("Container", //its name
110  boxSizeXY/2.,boxSizeXY/2.,boxSizeZ/2.);//its dimensions
111 
113  lBox = new G4LogicalVolume(sBox, //its shape
114  aMaterial, //its material
115  "theBox"); //its name
116 
117  pBox = new G4PVPlacement(0, //no rotation
118  G4ThreeVector(), //at (0,0,0)
119  lBox, //its logical volume
120  aMaterial->GetName(), //its name
121  lWorld, //its mother volume
122  false, //no boolean operation
123  0); //copy number
124 
125  // register logical Volume in PolarizationManager with zero polarization
127  polMgr->SetVolumePolarization(lBox,G4ThreeVector(0.,0.,0.));
128 
129  PrintParameters();
130 
131  //always return the root volume
132  //
133  return pWorld;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
139 {
140  G4cout << "\n The Box is " << G4BestUnit(boxSizeXY,"Length")
141  << " x " << G4BestUnit(boxSizeXY,"Length")
142  << " x " << G4BestUnit(boxSizeZ,"Length")
143  << " of " << aMaterial->GetName() << G4endl;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147 
149 {
150  // search the material by its name
151  G4Material* mat =
152  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
153  if (mat != aMaterial) {
154  if(mat) {
155  aMaterial = mat;
156  UpdateGeometry();
157  } else {
158  G4cout << "### Warning! Target material: <"
159  << materialChoice << "> not found" << G4endl;
160  }
161  }
162 }
163 
164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165 
167 {
168  // search the material by its name
169  G4Material* mat =
170  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
171  if (mat != wMaterial) {
172  if(mat) {
173  wMaterial = mat;
174  UpdateGeometry();
175  } else {
176  G4cout << "### Warning! World material: <"
177  << materialChoice << "> not found" << G4endl;
178  }
179  }
180 }
181 
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183 
185 {
186  boxSizeXY = value;
187  if (worldSize<boxSizeXY) worldSize = 1.2*boxSizeXY;
188  UpdateGeometry();
189 }
190 
192 {
193  boxSizeZ = value;
194  if (worldSize<boxSizeZ) worldSize = 1.2*boxSizeZ;
195  UpdateGeometry();
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199 
200 #include "G4RunManager.hh"
201 
203 {
204  if (pWorld)
206 }
207 
208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
void SetWorldMaterial(G4Material *amaterial)
Definition: pyEzgeom.cc:69
Definition: G4Box.hh:63
const G4String & GetName() const
Definition: G4Material.hh:176
static G4PolarizationManager * GetInstance()
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4NistManager * Instance()
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
static G4PhysicalVolumeStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
const XML_Char int const XML_Char * value
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
double G4double
Definition: G4Types.hh:76