ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F04DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file F04DetectorConstruction.cc
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 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "globals.hh"
34 
36 #include "F04DetectorMessenger.hh"
37 
38 #include "G4Tubs.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 
42 #include "G4Material.hh"
43 #include "G4NistManager.hh"
44 
45 #include "F04GlobalField.hh"
46 
47 #include "G4GeometryManager.hh"
48 #include "G4SolidStore.hh"
49 #include "G4LogicalVolumeStore.hh"
50 #include "G4PhysicalVolumeStore.hh"
51 
52 #include "G4RunManager.hh"
53 #include "G4StateManager.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();
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;
357 
358  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
360  }
361 }
362 
363 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
364 
366 {
367  fWorldSizeR = val;
368  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
370  }
371 }
372 
373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
374 
376 {
377  fCaptureMgntRadius = val;
378  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
380  }
381 }
382 
383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
384 
386 {
387  fCaptureMgntLength = val;
388  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
390  }
391 }
392 
393 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
394 
396 {
397  fCaptureMgntB1 = val;
398  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
400  }
401 }
402 
403 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
404 
406 {
407  fCaptureMgntB2 = val;
408  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
410  }
411 }
412 
413 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
414 
416 {
417  fTransferMgntRadius = val;
418  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
420  }
421 }
422 
423 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
424 
426 {
427  fTransferMgntLength = val;
428  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
430  }
431 }
432 
433 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
434 
436 {
437  fTransferMgntB = val;
438  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
440  }
441 }
442 
443 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
444 
446 {
447  fTransferMgntPos = val;
448  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
450  }
451 }
452 
453 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
454 
456 {
457  fTargetRadius = val;
458  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
460  }
461 }
462 
463 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
464 
466 {
467  fTargetThickness = val;
468  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
470  }
471 }
472 
473 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
474 
476 {
477  fTargetPos = val;
478  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
480  }
481 }
482 
483 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
484 
486 {
487  fTargetAngle = val;
488  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
490  }
491 }
492 
493 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
494 
496 {
497  fDegraderRadius = val;
498  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
500  }
501 }
502 
503 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
504 
506 {
507  fDegraderThickness = val;
508  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
510  }
511 }
512 
513 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
514 
516 {
517  fDegraderPos = val;
518  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
520  }
521 }
522 
523 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
524 
526 {
527  if (!fFieldSetUp.Get()) {
529  G4AutoDelete::Register(field); // Kernel will delete the F04GlobalField
530  fFieldSetUp.Put(field);
531  }
532 }
533 
534 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
535 
538 {
539  // We apply successive rotations OF THE OBJECT around the FIXED
540  // axes of the parent's local coordinates; rotations are applied
541  // left-to-right (rotation="r1,r2,r3" => r1 then r2 then r3).
542 
543  G4RotationMatrix rot;
544 
545  unsigned int place = 0;
546 
547  while (place < rotation.size()) {
548 
549  G4double angle;
550  char* p(0);
551  G4String current=rotation.substr(place+1);
552  angle = strtod(current.c_str(),&p) * deg;
553 
554  if (!p || (*p != ',' && *p != '\0')) {
555  G4cerr << "Invalid rotation specification: " <<
556  rotation.c_str() << G4endl;
557 
558  return rot;
559  }
560 
561  G4RotationMatrix thisRotation;
562 
563  switch(rotation.substr(place,1).c_str()[0]) {
564  case 'X': case 'x':
565  thisRotation = G4RotationMatrix(CLHEP::HepRotationX(angle));
566  break;
567  case 'Y': case 'y':
568  thisRotation = G4RotationMatrix(CLHEP::HepRotationY(angle));
569  break;
570  case 'Z': case 'z':
571  thisRotation = G4RotationMatrix(CLHEP::HepRotationZ(angle));
572  break;
573  default:
574  G4cerr << " Invalid rotation specification: "
575  << rotation << G4endl;
576  return rot;
577  }
578 
579  rot = thisRotation * rot;
580  place = rotation.find(',',place);
581  if (place > rotation.size()) break;
582  ++place;
583  }
584 
585  return rot;
586 
587 }