Geant4  10.00.p02
F04DetectorConstruction.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 // $Id: F04DetectorConstruction.cc 79251 2014-02-20 16:16:23Z gcosmo $
27 //
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "globals.hh"
35 
37 #include "F04DetectorMessenger.hh"
38 
39 #include "G4Tubs.hh"
40 #include "G4LogicalVolume.hh"
41 #include "G4PVPlacement.hh"
42 
43 #include "G4Material.hh"
44 #include "G4NistManager.hh"
45 
46 #include "F04GlobalField.hh"
47 
48 #include "G4GeometryManager.hh"
49 #include "G4SolidStore.hh"
50 #include "G4LogicalVolumeStore.hh"
51 #include "G4PhysicalVolumeStore.hh"
52 
53 #include "G4RunManager.hh"
54 
55 #include "G4PhysicalConstants.hh"
56 #include "G4SystemOfUnits.hh"
57 
58 #include "F04Materials.hh"
59 
60 #include "G4RotationMatrix.hh"
61 
62 #include "F04SimpleSolenoid.hh"
63 #include "F04FocusSolenoid.hh"
64 
65 #include "G4AutoDelete.hh"
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
71  fDetectorMessenger(0),
72  fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
73  fSolidTarget(0), fLogicTarget(0), fPhysiTarget(0),
74  fSolidDegrader(0), fLogicDegrader(0), fPhysiDegrader(0),
75  fSolidCaptureMgnt(0), fLogicCaptureMgnt(0), fPhysiCaptureMgnt(0),
76  fSolidTransferMgnt(0), fLogicTransferMgnt(0), fPhysiTransferMgnt(0),
77  fWorldMaterial(0), fTargetMaterial(0), fDegraderMaterial(0)
78 {
79  fWorldSizeZ = 50.*m;
80  fWorldSizeR = 5.*m;
81 
82  fTargetRadius = 0.4*cm;
83  fTargetThickness = 16.0*cm;
84 
85  SetTargetAngle(170);
86 
87  fDegraderRadius = 30.0*cm;
88  fDegraderThickness = 0.1*cm;
89 
90  fCaptureMgntRadius = 0.6*m;
91  fCaptureMgntLength = 4.0*m;
92 
95 
96  fTransferMgntRadius = 0.3*m;
97  fTransferMgntLength = 15.0*m;
98 
100 
102 
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107 
109 {
110  delete fDetectorMessenger;
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116 {
117 
118  if (fPhysiWorld) {
123  }
124 
126 
127  DefineMaterials();
128 
129  return ConstructDetector();
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133 
135 {
136  //define materials for the experiment
137 
138  fVacuum = fMaterials->GetMaterial("G4_Galactic");
139 
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
148 {
149  fSolidWorld = new G4Tubs("World",
150  0.,GetWorldSizeR(),GetWorldSizeZ()/2.,0.,twopi);
151 
154  "World");
155 
156  fPhysiWorld = new G4PVPlacement(0,
157  G4ThreeVector(),
158  "World",
159  fLogicWorld,
160  0,
161  false,
162  0);
163 
164  // Capture Magnet
165 
166  fSolidCaptureMgnt = new G4Tubs("CaptureMgnt",
168  GetCaptureMgntLength()/2.,0.,twopi);
169 
171  fVacuum,
172  "CaptureMgnt");
173 
175 
178  "CaptureMgnt",
180  fPhysiWorld,
181  false,
182  0);
183 
184  // Transfer Magnet
185 
186  fSolidTransferMgnt = new G4Tubs("TransferMgnt",
188  GetTransferMgntLength()/2.,0.,twopi);
189 
191  fVacuum,
192  "TransferMgnt");
193 
195  + GetTransferMgntPos();
196  G4double x = GetTransferMgntPos()/2.;
197 
199 
200  G4RotationMatrix* g4rot = new G4RotationMatrix();
201  *g4rot = StringToRotationMatrix("Y30,X10");
202  *g4rot = g4rot->inverse();
203  if (*g4rot == G4RotationMatrix()) g4rot = NULL;
204 
205  fPhysiTransferMgnt = new G4PVPlacement(g4rot,
207  "TransferMgnt",
209  fPhysiWorld,
210  false,
211  0);
212 
213  // Test Plane
214 
215  G4Tubs* solidTestPlane = new G4Tubs("TestPlane",
217  1.*mm,0.,twopi);
218 
219  G4LogicalVolume* logicTestPlane = new G4LogicalVolume(solidTestPlane,
220  fVacuum,
221  "TestPlane");
222 
223  z = GetTransferMgntLength()/2. - 1.*mm;
224 
225  G4ThreeVector testPlaneCenter = G4ThreeVector(0.,0.,z);
226 
227  new G4PVPlacement(0,
228  testPlaneCenter,
229  "TestPlane",
230  logicTestPlane,
232  false,
233  0);
234 
235  // Target
236 
237  if (GetTargetThickness() > 0.)
238  {
239  fSolidTarget = new G4Tubs("Target",
240  0.,GetTargetRadius(),
241  GetTargetThickness()/2.,0.,twopi);
242 
245  "Target");
246 
247  G4int i = GetTargetAngle();
248 
249  char c[4];
250  sprintf(c,"%d",i);
251  G4String angle = c;
252  angle = angle.strip(G4String::both,' ');
253  angle = "Y" + angle;
254 
255  g4rot = new G4RotationMatrix();
256  *g4rot = StringToRotationMatrix(angle);
257  *g4rot = g4rot->inverse();
258  if (*g4rot == G4RotationMatrix()) g4rot = NULL;
259 
260  G4ThreeVector targetCenter(0.,0.,GetTargetPos());
261 
262  fPhysiTarget = new G4PVPlacement(g4rot,
263  targetCenter,
264  "Target",
265  fLogicTarget,
267  false,
268  0);
269  }
270 
271  // Degrader
272 
273  if (GetDegraderThickness() > 0.)
274  {
275  fSolidDegrader = new G4Tubs("Degrader",
276  0., GetDegraderRadius(),
277  GetDegraderThickness()/2., 0.,twopi);
278 
281  "Degrader");
282 
283  G4ThreeVector degraderCenter = G4ThreeVector(0.,0.,GetDegraderPos());
284 
286  degraderCenter,
287  "Degrader",
290  false,
291  0);
292  }
293 
294  return fPhysiWorld;
295 }
296 
297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
298 
300 {
301  G4Material* pttoMaterial =
302  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
303 
304  if (pttoMaterial != fWorldMaterial) {
305  if ( pttoMaterial ) {
306  fWorldMaterial = pttoMaterial;
308  } else {
309  G4cout << "\n--> WARNING from SetWorldMaterial : "
310  << materialChoice << " not found" << G4endl;
311  }
312  }
313 }
314 
315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
316 
318 {
319  G4Material* pttoMaterial =
320  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
321 
322  if (pttoMaterial != fTargetMaterial) {
323  if ( pttoMaterial ) {
324  fTargetMaterial = pttoMaterial;
326  } else {
327  G4cout << "\n--> WARNING from SetTargetMaterial : "
328  << materialChoice << " not found" << G4endl;
329  }
330  }
331 }
332 
333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
334 
336 
337 {
338  G4Material* pttoMaterial =
339  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
340 
341  if (pttoMaterial != fDegraderMaterial) {
342  if ( pttoMaterial ) {
343  fDegraderMaterial = pttoMaterial;
345  } else {
346  G4cout << "\n--> WARNING from SetDegraderMaterial : "
347  << materialChoice << " not found" << G4endl;
348  }
349  }
350 }
351 
352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
353 
355 {
356  fWorldSizeZ = val;
358 }
359 
360 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
361 
363 {
364  fWorldSizeR = val;
366 }
367 
368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
369 
371 {
372  fCaptureMgntRadius = val;
374 }
375 
376 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
377 
379 {
380  fCaptureMgntLength = val;
382 }
383 
384 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
385 
387 {
388  fCaptureMgntB1 = val;
390 }
391 
392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
393 
395 {
396  fCaptureMgntB2 = val;
398 }
399 
400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
401 
403 {
404  fTransferMgntRadius = val;
406 }
407 
408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
409 
411 {
412  fTransferMgntLength = val;
414 }
415 
416 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
417 
419 {
420  fTransferMgntB = val;
422 }
423 
424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
425 
427 {
428  fTransferMgntPos = val;
430 }
431 
432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
433 
435 {
436  fTargetRadius = val;
438 }
439 
440 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
441 
443 {
444  fTargetThickness = val;
446 }
447 
448 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
449 
451 {
452  fTargetPos = val;
454 }
455 
456 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
457 
459 {
460  fTargetAngle = val;
462 }
463 
464 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
465 
467 {
468  fDegraderRadius = val;
470 }
471 
472 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
473 
475 {
476  fDegraderThickness = val;
478 }
479 
480 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
481 
483 {
484  fDegraderPos = val;
486 }
487 
488 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
489 
491 {
492  if (!fFieldSetUp.Get()) {
494  G4AutoDelete::Register(field); // Kernel will delete the F04GlobalField
495  fFieldSetUp.Put(field);
496  }
497 }
498 
499 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
500 
503 {
504  // We apply successive rotations OF THE OBJECT around the FIXED
505  // axes of the parent's local coordinates; rotations are applied
506  // left-to-right (rotation="r1,r2,r3" => r1 then r2 then r3).
507 
508  G4RotationMatrix rot;
509 
510  unsigned int place = 0;
511 
512  while (place < rotation.size()) {
513 
514  G4double angle;
515  char* p(0);
516  G4String current=rotation.substr(place+1);
517  angle = strtod(current.c_str(),&p) * deg;
518 
519  if (!p || (*p != ',' && *p != '\0')) {
520  G4cerr << "Invalid rotation specification: " <<
521  rotation.c_str() << G4endl;
522 
523  return rot;
524  }
525 
526  G4RotationMatrix thisRotation;
527 
528  switch(rotation.substr(place,1).c_str()[0]) {
529  case 'X': case 'x':
530  thisRotation = G4RotationMatrix(CLHEP::HepRotationX(angle));
531  break;
532  case 'Y': case 'y':
533  thisRotation = G4RotationMatrix(CLHEP::HepRotationY(angle));
534  break;
535  case 'Z': case 'z':
536  thisRotation = G4RotationMatrix(CLHEP::HepRotationZ(angle));
537  break;
538  default:
539  G4cerr << " Invalid rotation specification: "
540  << rotation << G4endl;
541  return rot;
542  }
543 
544  rot = thisRotation * rot;
545  place = rotation.find(',',place);
546  if (place > rotation.size()) break;
547  ++place;
548  }
549 
550  return rot;
551 
552 }
static const double cm
Definition: G4SIunits.hh:106
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4VPhysicalVolume * fPhysiDegrader
Definition of the F04Materials class.
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4VPhysicalVolume * ConstructDetector()
Definition of the F04GlobalField class.
G4double z
Definition: TRTMaterials.hh:39
G4String strip(G4int strip_Type=trailing, char c=' ')
G4Cache< F04GlobalField * > fFieldSetUp
value_type & Get() const
Definition: G4Cache.hh:253
Definition: G4Tubs.hh:85
static void Clean()
Definition: G4SolidStore.cc:79
G4Material * GetMaterial(G4String)
Definition: F04Materials.cc:71
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
F04DetectorMessenger * fDetectorMessenger
static F04GlobalField * GetObject()
Definition of the F04DetectorConstruction class.
virtual G4VPhysicalVolume * Construct()
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
Definition of the F04DetectorMessenger class.
void PhysicsHasBeenModified()
static const double deg
Definition: G4SIunits.hh:133
G4VPhysicalVolume * fPhysiTransferMgnt
Definition of the F04FocusSolenoid class.
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
G4VPhysicalVolume * fPhysiCaptureMgnt
static G4GeometryManager * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
static F04Materials * GetInstance()
Definition: F04Materials.cc:60
Definition of the F04SimpleSolenoid class.
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:110
void OpenGeometry(G4VPhysicalVolume *vol=0)
static const double tesla
Definition: G4SIunits.hh:247
double G4double
Definition: G4Types.hh:76
static G4RotationMatrix StringToRotationMatrix(G4String rotation)
void Put(const value_type &val) const
Definition: G4Cache.hh:257
static const double mm
Definition: G4SIunits.hh:102
G4GLOB_DLL std::ostream G4cerr