Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // -------------------------------------------------------------------
27 // $Id$
28 // -------------------------------------------------------------------
29 
30 #include "DetectorConstruction.hh"
31 #include "G4PhysicalConstants.hh"
32 #include "G4SystemOfUnits.hh"
33 #include "G4NistManager.hh"
34 
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36 
38 {
39  detectorMessenger = new DetectorMessenger(this);
40  gradientsInitialized=false;
41  G1=0; G2=0; G3=0; G4=0; coef=0; profile=0; grid=0;
42 }
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
45 
47 { delete detectorMessenger;}
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
52 
53 {
54  DefineMaterials();
55  return ConstructVolumes();
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
60 void DetectorConstruction::DefineMaterials()
61 {
64 
65  G4double z, a;
66 
67  // Vacuum standard definition...
68  density = universe_mean_density;
69  G4Material* vacuum = new G4Material(name="Vacuum", z=1., a=1.01*g/mole,
70  density);
71 
72  // NIST
74  man->SetVerbose(1);
75 
77 
78  // Default materials in setup.
79  defaultMaterial = vacuum;
80  gridMaterial = man->FindOrBuildMaterial("G4_Ni");
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
84 
85 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
86 {
87 
88  static G4bool fieldIsInitialized = false;
89  if(!fieldIsInitialized && gradientsInitialized)
90  {
91  G4FieldManager* pFieldMgr;
92  G4MagIntegratorStepper* pStepper;
93  G4Mag_UsualEqRhs* pEquation;
94 
95  G4MagneticField* Field= new TabulatedField3D(G1, G2, G3, G4, model);
96 
97  pEquation = new G4Mag_UsualEqRhs (Field);
98  pStepper = new G4ClassicalRK4 (pEquation);
100 
101  G4ChordFinder *pChordFinder = new G4ChordFinder(Field,1e-9*m,pStepper);
102  pFieldMgr->SetChordFinder( pChordFinder );
103 
104  pFieldMgr->SetDetectorField(Field);
105 
106  fieldIsInitialized = true;
107 
108  // tuned parameters
109  pFieldMgr->GetChordFinder()->SetDeltaChord(1.e-9*m);
110  pFieldMgr->SetDeltaIntersection(1.e-9*m);
111  pFieldMgr->SetDeltaOneStep(1.e-9*m);
112 
113  G4PropagatorInField *propInField;
114  propInField =
116  propInField->SetMinimumEpsilonStep(1e-11);
117  propInField->SetMaximumEpsilonStep(1e-10);
118 
119  }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
122 
123  solidWorld = new G4Box("World", //its name
124  12*m/2,12*m/2,22*m/2); //its size
125 
126 
127  logicWorld = new G4LogicalVolume(solidWorld, //its solid
128  defaultMaterial, //its material
129  "World"); //its name
130 
131  physiWorld = new G4PVPlacement(0, //no rotation
132  G4ThreeVector(), //at (0,0,0)
133  "World", //its name
134  logicWorld, //its logical volume
135  NULL, //its mother volume
136  false, //no boolean operation
137  0); //copy number
138 
139 
140  // MAGNET VOLUME
141 
142  solidVol = new G4Box("Vol", //its name
143  10*m/2,10*m/2,9.120*m/2); //its size
144 
145 
146  logicVol = new G4LogicalVolume(solidVol, //its solid
147  defaultMaterial, //its material
148  "Vol"); //its name
149 
150  physiVol = new G4PVPlacement(0, //no rotation
151  G4ThreeVector(0,0,-4310*mm), //at (0,0,0)
152  "Vol", //its name
153  logicVol, //its logical volume
154  physiWorld, //its mother volume
155  false, //no boolean operation
156  0); //copy number
157 
158  // GRID
159 
160  if (grid==1)
161  {
162 
163  G4cout << G4endl;
164 
165  G4cout << " ********************** " << G4endl;
166  G4cout << " **** GRID IN PLACE *** " << G4endl;
167  G4cout << " ********************** " << G4endl;
168 
169  G4double x_grid=5.0*mm;
170  G4double y_grid=5.0*mm;
171  G4double grid_Zpos=(250+200)*mm; // 250+10 mm for object size of 50µm diam
172 
173  //G4double thickness_grid=10*micrometer;
174  G4double thickness_grid=100*micrometer;
175 
176  G4double z_grid=thickness_grid/2.0;
177 
178  solidGridVol= new G4Box("GridVolume",x_grid,y_grid,z_grid); //its size
179 
180  logicGridVol = new G4LogicalVolume(solidGridVol, //its solid
181  gridMaterial, //its material
182  "GridVolume"); //its name
183 
184  physiGridVol = new G4PVPlacement(0, //no rotation
185  G4ThreeVector(0,0,grid_Zpos), // origin
186  logicGridVol, //its logical volume
187  "GridVolume", //its name
188  logicWorld, //its mother volume
189  false, //no boolean operation
190  0);
191 
192  // Holes in grid
193 
194  G4double holeSize= 9e-3*mm;
195  G4double pix_grid=1.3e-2*mm;
196  G4int num_half_grid=100;
197 
198  solidGridVol_Hole= new G4Box("GridHole",holeSize/2,holeSize/2,z_grid); //its size
199 
200  logicGridVol_Hole = new G4LogicalVolume(solidGridVol_Hole, //its solid
201  defaultMaterial, //its material
202  "GridHole"); //its name
203 
204 
205  for(int i=-num_half_grid;i<num_half_grid;i++)
206  {
207  for (int j=-num_half_grid;j<num_half_grid;j++)
208  {
209 
210  G4double x0_grid,y0_grid,z0_grid;
211  G4int number_index_grid;
212 
213  x0_grid=pix_grid*i;
214  y0_grid=pix_grid*j;
215  z0_grid=0.0*mm;
216 
217  number_index_grid=(i+num_half_grid)*1000+(j+num_half_grid);
218 
219  physiGridVol_Hole = new G4PVPlacement(0, //no rotation
220  G4ThreeVector(x0_grid,y0_grid,z0_grid),//origin
221  logicGridVol_Hole, //its logical volume
222  "GridHole", //its name
223  logicGridVol, //its mother volume
224  false, //no boolean operation
225  number_index_grid);
226  }
227  }
228 
229  // Grid imaging plane
230 
231  G4double ContVolSizeXY = 1*m;
232  G4double ImPlaneWidth = 0.001*mm;
233 
234  solidControlVol_GridShadow =
235  new G4Box
236  ("ControlVol_GridShadow", ContVolSizeXY/2, ContVolSizeXY/2 , ImPlaneWidth/2);
237 
238  logicControlVol_GridShadow =
239  new G4LogicalVolume
240  (solidControlVol_GridShadow, defaultMaterial, "ControlVol_GridShadow");
241 
242  physiControlVol_GridShadow =
243  new G4PVPlacement
244  ( 0, G4ThreeVector(0,0,(250+300)*mm), logicControlVol_GridShadow, "ControlVol_GridShadow",logicWorld, false, 0);
245 
246 
247  } // end GRID
248 
249  // STEP MINIMUM SIZE
250  logicVol->SetUserLimits(new G4UserLimits(1*mm));
251 
252  return physiWorld;
253 }
254 
255 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
256 
258 {
259  G1 = value;
260 }
261 
262 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
263 
265 {
266  G2 = value;
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
270 
272 {
273  G3 = value;
274 }
275 
276 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
277 
279 {
280  G4 = value;
281 }
282 
283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
284 
286 {
287 if (modelChoice==1) model=1;
288 if (modelChoice==2) model=2;
289 if (modelChoice==3) model=3;
290 }
291 
292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
293 
294 #include "G4RunManager.hh"
295 
297 {
298  gradientsInitialized=true;
299  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
300 }
301 
302 
303 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
304 
306 {
307  coef=1;
308 }
309 
310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
311 
313 {
314  return coef;
315 }
316 
317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
318 
320 {
321  profile=myProfile;
322 }
323 
324 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
325 
327 {
328  grid=myGrid;
329 }
330