Geant4  10.03.p03
 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 // Please cite the following paper if you use this software
27 // Nucl.Instrum.Meth.B260:20-27, 2007
28 
29 #include "DetectorConstruction.hh"
30 #include "G4PhysicalConstants.hh"
31 #include "G4SystemOfUnits.hh"
32 #include "G4NistManager.hh"
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
35 
36 G4ThreadLocal TabulatedField3D* DetectorConstruction::fField = 0;
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39 
41 {
42  fDetectorMessenger = new DetectorMessenger(this);
43  fGradientsInitialized=false;
44 
45  //Default values (square field, coef calculation, profile)
46 
47  fModel=1;
48  fG1=-11.964623;
49  fG2=16.494652;
50  fG3=9.866770;
51  fG4=-6.244493;
52  fCoef=1;
53  fProfile=1;
54  fGrid=0;
55 
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
61 { delete fDetectorMessenger;}
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
64 
66 
67 {
68  DefineMaterials();
69  return ConstructVolumes();
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73 
74 void DetectorConstruction::DefineMaterials()
75 {
76  G4String name, symbol;
77  G4double density;
78 
79  G4double z, a;
80 
81  // Vacuum standard definition...
82  density = universe_mean_density;
83  G4Material* vacuum = new G4Material(name="Vacuum", z=1., a=1.01*g/mole,
84  density);
85 
86  // NIST
88  man->SetVerbose(1);
89 
90  //
92 
93  // Default materials in setup.
94  fDefaultMaterial = vacuum;
95  fGridMaterial = man->FindOrBuildMaterial("G4_Ni");
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
99 
100 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
101 {
102 
103  fSolidWorld = new G4Box("World", //its name
104  12*m/2,12*m/2,22*m/2); //its size
105 
106 
107  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
108  fDefaultMaterial, //its material
109  "World"); //its name
110 
111  fPhysiWorld = new G4PVPlacement(0, //no rotation
112  G4ThreeVector(), //at (0,0,0)
113  "World", //its name
114  fLogicWorld, //its logical volume
115  NULL, //its mother volume
116  false, //no boolean operation
117  0); //copy number
118 
119 
120  // MAGNET VOLUME
121 
122  fSolidVol = new G4Box("Vol", //its name
123  10*m/2,10*m/2,9.120*m/2); //its size
124 
125 
126  fLogicVol = new G4LogicalVolume(fSolidVol, //its solid
127  fDefaultMaterial, //its material
128  "Vol"); //its name
129 
130  fPhysiVol = new G4PVPlacement(0, //no rotation
131  G4ThreeVector(0,0,-4310*mm), //at (0,0,0)
132  "Vol", //its name
133  fLogicVol, //its logical volume
134  fPhysiWorld, //its mother volume
135  false, //no boolean operation
136  0); //copy number
137 
138  // GRID
139 
140  if (fGrid==1)
141  {
142 
143  G4cout << G4endl;
144 
145  G4cout << " ********************** " << G4endl;
146  G4cout << " **** GRID IN PLACE *** " << G4endl;
147  G4cout << " ********************** " << G4endl;
148 
149  G4double x_grid=5.0*mm;
150  G4double y_grid=5.0*mm;
151  G4double grid_Zpos=(250+200)*mm; // 250+10 mm for object size of 50µm diam
152 
153  //G4double thickness_grid=10*micrometer;
154  G4double thickness_grid=100*micrometer;
155 
156  G4double z_grid=thickness_grid/2.0;
157 
158  fSolidGridVol= new G4Box("GridVolume",x_grid,y_grid,z_grid); //its size
159 
160  fLogicGridVol = new G4LogicalVolume(fSolidGridVol, //its solid
161  fGridMaterial, //its material
162  "GridVolume"); //its name
163 
164  fPhysiGridVol = new G4PVPlacement(0, //no rotation
165  G4ThreeVector(0,0,grid_Zpos), // origin
166  fLogicGridVol, //its logical volume
167  "GridVolume", //its name
168  fLogicWorld, //its mother volume
169  false, //no boolean operation
170  0);
171 
172  // Holes in grid
173 
174  G4double holeSize= 9e-3*mm;
175  G4double pix_grid=1.3e-2*mm;
176  G4int num_half_grid=100;
177 
178  fSolidGridVol_Hole= new G4Box("GridHole",holeSize/2,holeSize/2,z_grid); //its size
179 
180  fLogicGridVol_Hole = new G4LogicalVolume(fSolidGridVol_Hole, //its solid
181  fDefaultMaterial, //its material
182  "GridHole"); //its name
183 
184 
185  for(int i=-num_half_grid;i<num_half_grid;i++)
186  {
187  for (int j=-num_half_grid;j<num_half_grid;j++)
188  {
189 
190  G4double x0_grid,y0_grid,z0_grid;
191  G4int number_index_grid;
192 
193  x0_grid=pix_grid*i;
194  y0_grid=pix_grid*j;
195  z0_grid=0.0*mm;
196 
197  number_index_grid=(i+num_half_grid)*1000+(j+num_half_grid);
198 
199  fPhysiGridVol_Hole = new G4PVPlacement(0, //no rotation
200  G4ThreeVector(x0_grid,y0_grid,z0_grid),//origin
201  fLogicGridVol_Hole, //its logical volume
202  "GridHole", //its name
203  fLogicGridVol, //its mother volume
204  false, //no boolean operation
205  number_index_grid);
206  }
207  }
208 
209  // Grid imaging plane
210 
211  G4double ContVolSizeXY = 1*m;
212  G4double ImPlaneWidth = 0.001*mm;
213 
214  fSolidControlVol_GridShadow =
215  new G4Box
216  ("ControlVol_GridShadow", ContVolSizeXY/2, ContVolSizeXY/2 , ImPlaneWidth/2);
217 
218  fLogicControlVol_GridShadow =
219  new G4LogicalVolume
220  (fSolidControlVol_GridShadow, fDefaultMaterial, "ControlVol_GridShadow");
221 
222  fPhysiControlVol_GridShadow =
223  new G4PVPlacement
224  ( 0, G4ThreeVector(0,0,(250+300)*mm), fLogicControlVol_GridShadow, "ControlVol_GridShadow",
225  fLogicWorld, false, 0);
226 
227 
228  } // end GRID
229 
230  // STEP MINIMUM SIZE
231  fLogicVol->SetUserLimits(new G4UserLimits(1*mm));
232 
233  return fPhysiWorld;
234 }
235 
236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
237 
239 {
240  fG1 = value;
241 }
242 
243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
244 
246 {
247  fG2 = value;
248 }
249 
250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
251 
253 {
254  fG3 = value;
255 }
256 
257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
258 
260 {
261  fG4 = value;
262 }
263 
264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
265 
267 {
268 if (modelChoice==1) fModel=1;
269 if (modelChoice==2) fModel=2;
270 if (modelChoice==3) fModel=3;
271 }
272 
273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
274 
275 #include "G4RunManager.hh"
276 
278 {
279  fGradientsInitialized=true;
280  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
281 }
282 
283 
284 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
285 
287 {
288  fCoef=val;
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
292 
294 {
295  return fCoef;
296 }
297 
298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
299 
301 {
302  fProfile=myProfile;
303 }
304 
305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
306 
308 {
309  fGrid=myGrid;
310 }
311 
312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
313 
315 {
316 // static G4bool fieldIsInitialized = false;
317 // if(!fieldIsInitialized && fGradientsInitialized)
318 
319  if(!fField) fField = new TabulatedField3D(fG1, fG2, fG3, fG4, fModel);
320 
321  fEquation = new G4Mag_UsualEqRhs (fField);
322 
323  fStepper = new G4ClassicalRK4 (fEquation);
324 
326 
327  fChordFinder = new G4ChordFinder(fField,1e-9*m,fStepper);
328 
329  fFieldMgr->SetChordFinder(fChordFinder);
330  fFieldMgr->SetDetectorField(fField);
331  fFieldMgr->GetChordFinder()->SetDeltaChord(1e-9*m);
332  fFieldMgr->SetDeltaIntersection(1e-9*m);
333  fFieldMgr->SetDeltaOneStep(1e-9*m);
334 
335  fPropInField =
337  fPropInField->SetMinimumEpsilonStep(1e-11);
338  fPropInField->SetMaximumEpsilonStep(1e-10);
339 
340 }
341 
const XML_Char * name
Definition: expat.h:151
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4ChordFinder * GetChordFinder()
void SetProfile(G4int myProfile)
static constexpr double mm
Definition: G4SIunits.hh:115
CLHEP::Hep3Vector G4ThreeVector
G4bool SetDetectorField(G4Field *detectorField)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
int universe_mean_density
Definition: hepunit.py:307
Definition: G4Box.hh:64
G4VPhysicalVolume * Construct()
float G4float
Definition: G4Types.hh:77
void SetUserLimits(G4UserLimits *pULimits)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
void SetGrid(G4int myGrid)
#define G4ThreadLocal
Definition: tls.hh:89
void SetChordFinder(G4ChordFinder *aChordFinder)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
virtual void ConstructSDandField()
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4GLOB_DLL std::ostream G4cout
static constexpr double m
Definition: G4SIunits.hh:129
const XML_Char int const XML_Char * value
Definition: expat.h:331
void SetVerbose(G4int)
static G4TransportationManager * GetTransportationManager()
G4FieldManager * GetFieldManager() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetDeltaIntersection(G4double valueDintersection)
void SetMinimumEpsilonStep(G4double newEpsMin)
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetMaximumEpsilonStep(G4double newEpsMax)
void SetDeltaOneStep(G4double valueD1step)
G4PropagatorInField * GetPropagatorInField() const
static constexpr double micrometer
Definition: G4SIunits.hh:100
static constexpr double mole
Definition: G4SIunits.hh:286
void SetDeltaChord(G4double newval)