Loading...
Searching...
No Matches
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//
27/// \file field/field04/src/F04DetectorConstruction.cc
28/// \brief Implementation of the F04DetectorConstruction class
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33#include "globals.hh"
34
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
80
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
87
88//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89
91{
92
93 if (fPhysiWorld) {
94 G4GeometryManager::GetInstance()->OpenGeometry();
95 G4PhysicalVolumeStore::GetInstance()->Clean();
96 G4LogicalVolumeStore::GetInstance()->Clean();
97 G4SolidStore::GetInstance()->Clean();
98 }
99
101
103
104 return ConstructDetector();
105}
106
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108
110{
111 //define materials for the experiment
112
113 fVacuum = fMaterials->GetMaterial("G4_Galactic");
114
118}
119
120//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121
123{
124 fSolidWorld = new G4Tubs("World",
125 0.,GetWorldSizeR(),GetWorldSizeZ()/2.,0.,twopi);
126
129 "World");
130
131 fPhysiWorld = new G4PVPlacement(nullptr,
132 G4ThreeVector(),
133 "World",
135 nullptr,
136 false,
137 0);
138
139 // Capture Magnet
140
141 fSolidCaptureMgnt = new G4Tubs("CaptureMgnt",
143 GetCaptureMgntLength()/2.,0.,twopi);
144
146 fVacuum,
147 "CaptureMgnt");
148
149 fCaptureMgntCenter = G4ThreeVector();
150
151 fPhysiCaptureMgnt = new G4PVPlacement(nullptr,
153 "CaptureMgnt",
156 false,
157 0);
158
159 // Transfer Magnet
160
161 fSolidTransferMgnt = new G4Tubs("TransferMgnt",
163 GetTransferMgntLength()/2.,0.,twopi);
164
166 fVacuum,
167 "TransferMgnt");
168
169 G4double z = GetCaptureMgntLength()/2. + GetTransferMgntLength()/2.
171 G4double x = GetTransferMgntPos()/2.;
172
173 fTransferMgntCenter = G4ThreeVector(x,0.,z);
174
175 auto g4rot = new G4RotationMatrix();
176 *g4rot = StringToRotationMatrix("Y30,X10");
177 *g4rot = g4rot->inverse();
178 if (*g4rot == G4RotationMatrix()) g4rot = nullptr;
179
182 "TransferMgnt",
185 false,
186 0);
187
188 // Test Plane
189
190 auto solidTestPlane = new G4Tubs("TestPlane",
192 1.*mm,0.,twopi);
193
194 auto logicTestPlane = new G4LogicalVolume(solidTestPlane,
195 fVacuum,
196 "TestPlane");
197
198 z = GetTransferMgntLength()/2. - 1.*mm;
199
200 G4ThreeVector testPlaneCenter = G4ThreeVector(0.,0.,z);
201
202 new G4PVPlacement(nullptr,
203 testPlaneCenter,
204 "TestPlane",
205 logicTestPlane,
207 false,
208 0);
209
210 // Target
211
212 if (GetTargetThickness() > 0.)
213 {
214 fSolidTarget = new G4Tubs("Target",
215 0.,GetTargetRadius(),
216 GetTargetThickness()/2.,0.,twopi);
217
220 "Target");
221
222 G4int i = GetTargetAngle();
223
224 G4String angle = std::to_string(i);
225 G4StrUtil::strip(angle);
226 angle = "Y" + angle;
227
228 g4rot = new G4RotationMatrix();
229 *g4rot = StringToRotationMatrix(angle);
230 *g4rot = g4rot->inverse();
231 if (*g4rot == G4RotationMatrix()) g4rot = nullptr;
232
233 G4ThreeVector targetCenter(0.,0.,GetTargetPos());
234
235 fPhysiTarget = new G4PVPlacement(g4rot,
236 targetCenter,
237 "Target",
240 false,
241 0);
242 }
243
244 // Degrader
245
246 if (GetDegraderThickness() > 0.)
247 {
248 fSolidDegrader = new G4Tubs("Degrader",
249 0., GetDegraderRadius(),
250 GetDegraderThickness()/2., 0.,twopi);
251
254 "Degrader");
255
256 G4ThreeVector degraderCenter = G4ThreeVector(0.,0.,GetDegraderPos());
257
258 fPhysiDegrader = new G4PVPlacement(nullptr,
259 degraderCenter,
260 "Degrader",
263 false,
264 0);
265 }
266
267 return fPhysiWorld;
268}
269
270//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
271
273{
274 G4Material* pttoMaterial =
275 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
276
277 if (pttoMaterial != fWorldMaterial) {
278 if ( pttoMaterial ) {
279 fWorldMaterial = pttoMaterial;
280 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
281 } else {
282 G4cout << "\n--> WARNING from SetWorldMaterial : "
283 << materialChoice << " not found" << G4endl;
284 }
285 }
286}
287
288//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
289
291{
292 G4Material* pttoMaterial =
293 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
294
295 if (pttoMaterial != fTargetMaterial) {
296 if ( pttoMaterial ) {
297 fTargetMaterial = pttoMaterial;
298 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
299 } else {
300 G4cout << "\n--> WARNING from SetTargetMaterial : "
301 << materialChoice << " not found" << G4endl;
302 }
303 }
304}
305
306//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
307
309
310{
311 G4Material* pttoMaterial =
312 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
313
314 if (pttoMaterial != fDegraderMaterial) {
315 if ( pttoMaterial ) {
316 fDegraderMaterial = pttoMaterial;
317 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
318 } else {
319 G4cout << "\n--> WARNING from SetDegraderMaterial : "
320 << materialChoice << " not found" << G4endl;
321 }
322 }
323}
324
325//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
326
328{
329 fWorldSizeZ = val;
330
331 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
332 G4RunManager::GetRunManager()->ReinitializeGeometry();
333 }
334}
335
336//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
337
339{
340 fWorldSizeR = val;
341 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
342 G4RunManager::GetRunManager()->ReinitializeGeometry();
343 }
344}
345
346//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
347
349{
350 fCaptureMgntRadius = val;
351 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
352 G4RunManager::GetRunManager()->ReinitializeGeometry();
353 }
354}
355
356//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
357
359{
360 fCaptureMgntLength = val;
361 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
362 G4RunManager::GetRunManager()->ReinitializeGeometry();
363 }
364}
365
366//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
367
369{
370 fCaptureMgntB1 = val;
371 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
372 G4RunManager::GetRunManager()->ReinitializeGeometry();
373 }
374}
375
376//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
377
379{
380 fCaptureMgntB2 = val;
381 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
382 G4RunManager::GetRunManager()->ReinitializeGeometry();
383 }
384}
385
386//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
387
389{
391 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
392 G4RunManager::GetRunManager()->ReinitializeGeometry();
393 }
394}
395
396//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
397
399{
401 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
402 G4RunManager::GetRunManager()->ReinitializeGeometry();
403 }
404}
405
406//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
407
409{
410 fTransferMgntB = val;
411 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
412 G4RunManager::GetRunManager()->ReinitializeGeometry();
413 }
414}
415
416//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
417
419{
420 fTransferMgntPos = val;
421 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
422 G4RunManager::GetRunManager()->ReinitializeGeometry();
423 }
424}
425
426//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
427
429{
430 fTargetRadius = val;
431 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
432 G4RunManager::GetRunManager()->ReinitializeGeometry();
433 }
434}
435
436//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
437
439{
440 fTargetThickness = val;
441 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
442 G4RunManager::GetRunManager()->ReinitializeGeometry();
443 }
444}
445
446//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
447
449{
450 fTargetPos = val;
451 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
452 G4RunManager::GetRunManager()->ReinitializeGeometry();
453 }
454}
455
456//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
457
459{
460 fTargetAngle = val;
461 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
462 G4RunManager::GetRunManager()->ReinitializeGeometry();
463 }
464}
465
466//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
467
469{
470 fDegraderRadius = val;
471 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
472 G4RunManager::GetRunManager()->ReinitializeGeometry();
473 }
474}
475
476//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
477
479{
480 fDegraderThickness = val;
481 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
482 G4RunManager::GetRunManager()->ReinitializeGeometry();
483 }
484}
485
486//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
487
489{
490 fDegraderPos = val;
491 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
492 G4RunManager::GetRunManager()->ReinitializeGeometry();
493 }
494}
495
496//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
497
499{
500 if (!fFieldSetUp.Get()) {
502 G4AutoDelete::Register(field); // Kernel will delete the F04GlobalField
503 fFieldSetUp.Put(field);
504 }
505}
506
507//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
508
509G4RotationMatrix
511{
512 // We apply successive rotations OF THE OBJECT around the FIXED
513 // axes of the parent's local coordinates; rotations are applied
514 // left-to-right (rotation="r1,r2,r3" => r1 then r2 then r3).
515
516 G4RotationMatrix rot;
517
518 unsigned int place = 0;
519
520 while (place < rotation.size()) {
521
522 G4double angle;
523 char* p(nullptr);
524 G4String current=rotation.substr(place+1);
525 angle = strtod(current.c_str(),&p) * deg;
526
527 if (!p || (*p != ',' && *p != '\0')) {
528 G4cerr << "Invalid rotation specification: " <<
529 rotation.c_str() << G4endl;
530
531 return rot;
532 }
533
534 G4RotationMatrix thisRotation;
535
536 switch(rotation.substr(place,1).c_str()[0]) {
537 case 'X': case 'x':
538 thisRotation = G4RotationMatrix(CLHEP::HepRotationX(angle));
539 break;
540 case 'Y': case 'y':
541 thisRotation = G4RotationMatrix(CLHEP::HepRotationY(angle));
542 break;
543 case 'Z': case 'z':
544 thisRotation = G4RotationMatrix(CLHEP::HepRotationZ(angle));
545 break;
546 default:
547 G4cerr << " Invalid rotation specification: "
548 << rotation << G4endl;
549 return rot;
550 }
551
552 rot = thisRotation * rot;
553 place = rotation.find(',',place);
554 if (place > rotation.size()) break;
555 ++place;
556 }
557
558 return rot;
559
560}
Definition of the F04DetectorConstruction class.
Definition of the F04DetectorMessenger class.
Definition of the F04FocusSolenoid class.
Definition of the F04GlobalField class.
Definition of the F04Materials class.
Definition of the F04SimpleSolenoid class.
G4VPhysicalVolume * Construct() override
G4VPhysicalVolume * ConstructDetector()
G4VPhysicalVolume * fPhysiTransferMgnt
F04DetectorMessenger * fDetectorMessenger
G4Cache< F04GlobalField * > fFieldSetUp
static G4RotationMatrix StringToRotationMatrix(G4String rotation)
G4VPhysicalVolume * fPhysiCaptureMgnt
static F04GlobalField * GetObject()
G4Material * GetMaterial(G4String)
static F04Materials * GetInstance()
void strip(G4String &str, char ch=' ')

Applications | User Support | Publications | Collaboration