Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LaserDrivenBeamLine.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 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 
29 #include "globals.hh"
30 #include "G4SystemOfUnits.hh"
31 #include "G4Box.hh"
32 #include "G4Tubs.hh"
33 #include "G4Sphere.hh"
34 #include "G4NistManager.hh"
35 #include "G4NistElementBuilder.hh"
36 #include "G4VisAttributes.hh"
37 #include "G4Colour.hh"
38 #include "G4RunManager.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4RotationMatrix.hh"
43 #include "LaserDrivenBeamLine.hh"
45 //
46 #include "G4PhysicalConstants.hh"
47 #include "G4ThreeVector.hh"
48 #include "G4Material.hh"
49 //
50 #include "G4FieldManager.hh"
52 #include "G4Mag_UsualEqRhs.hh"
53 #include "G4ExplicitEuler.hh"
54 #include "G4ChordFinder.hh"
55 //#include "G4TransportationManager.hh"
56 #include "G4EqMagElectricField.hh"
57 #include "G4UniformMagField.hh"
58 #include "G4PropagatorInField.hh"
59 #include "G4VisCommandsViewer.hh"
60 #include "G4UImanager.hh"
61 #include "G4ExplicitEuler.hh"
62 #include "G4ImplicitEuler.hh"
63 #include "G4SimpleRunge.hh"
64 #include "G4SimpleHeum.hh"
65 #include "G4ClassicalRK4.hh"
66 #include "G4HelixExplicitEuler.hh"
67 #include "G4HelixImplicitEuler.hh"
68 #include "G4HelixSimpleRunge.hh"
69 #include "G4CashKarpRKF45.hh"
70 #include "G4RKG3_Stepper.hh"
71 #include "G4SubtractionSolid.hh"
72 
73 //
75 #include "G4ElectricField.hh"
77 
79 //
80 //G4bool LaserDrivenBeamLine::doCalculation = false;
83  hadrontherapydetectorconstruction(0), physicTreatmentRoom(0),
84 PFirstTriplet(0),PSecondTriplet(0),PThirdTriplet(0),PFourthTriplet(0), physicFirstQuad(0),physicSecondQuad(0),physicThirdQuad(0),physicFourthQuad(0),
85 solidExternalChamber(0),logicExternalChamber(0),physicExternalChamber(0),
86 solidInternalChamber(0),logicInternalChamber(0),physicInternalChamber(0),
87 solidCollimator(0),logicCollimator(0),physicCollimator(0),
88 solidCollimatorHole(0),logicCollimatorHole(0),physicCollimatorHole(0),
89 solidFinalCollimator(0), logicFinalCollimator(0),physicFinalCollimator(0),
90 solidFinalCollimatorHole(0),logicFinalCollimatorHole(0),physicFinalCollimatorHole(0),
91 solidExternalMagnet_1(0),logicExternalMagnet_1(0),physicExternalMagnet_1(0), physicExternalMagnet_1Down(0),
92 solidMagnet_1(0),logicMagnet_1(0),physicMagnet_1Right(0),physicMagnet_1Left(0), solidExternalMagnet_2(0),logicExternalMagnet_2(0),
93 physicExternalMagnet_2(0),physicExternalMagnet_2Down(0),solidMagnet_2(0),logicMagnet_2(0),physicMagnet_2Right(0),physicMagnet_2Left(0), solidExternalMagnet_3(0),logicExternalMagnet_3(0),physicExternalMagnet_3(0),physicExternalMagnet_3Down(0),
94 solidMagnet_3(0),logicMagnet_3(0),physicMagnet_3Right(0),physicMagnet_3Left(0),
95 solidExternalMagnet_4(0),logicExternalMagnet_4(0),physicExternalMagnet_4(0),physicExternalMagnet_4Down(0),
96 solidMagnet_4(0),logicMagnet_4(0),physicMagnet_4Right(0),physicMagnet_4Left(0),
97 solidExternalSlit(0), logicExternalSlit(0), physicExternalSlit(0),
98 solidInternalSlit(0),logicInternalSlit(0),physicInternalSlit(0),
99  physicExitPipe(0),physicExitWindow(0),physicExithole(0),physicEntrancePipe(0),physicEntrancehole(0)
100 {
101  laserDrivenMessenger = new LaserDrivenBeamLineMessenger(this);
102 
103  //***************************** PW ***************************************
104 
105  static G4String ROGeometryName = "DetectorROGeometry";
106  RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
107 
108  G4cout << "Going to register Parallel world...";
110  G4cout << "... done" << G4endl;
111  //***************************** PW ***************************************
112 }
113 
116 {
117  //delete laserDrivenMessenger;
118  delete hadrontherapydetectorconstruction;
119 }
120 
123 {
124  // Sets default geometry and materials
125  SetDefaultDimensions();
126 
127  // Construct the energyselector (magnetic part and slit) and detector plane
128  ConstructLaserDrivenBeamLine();
129 
130  //***************************** PW ***************************************
131  if (!hadrontherapydetectorconstruction)
132 
133  //***************************** PW ***************************************
134 
135  // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
136  hadrontherapydetectorconstruction = new HadrontherapyDetectorConstruction(physicTreatmentRoom);
137  G4cout<<"HadrontherapyDetectorConstruction"<<G4endl;
138  //***************************** PW ***************************************
139 
140  hadrontherapydetectorconstruction->InitializeDetectorROGeometry(RO,hadrontherapydetectorconstruction->GetDetectorToWorldPosition());
141 
142  //***************************** PW ***************************************
143  return physicTreatmentRoom;
144 }
146 void LaserDrivenBeamLine::SetDefaultDimensions()
147 {
149  // Definition of the colour sets
150  white = new G4VisAttributes( G4Colour(1.,1.,1., 0.2));
151  white -> SetVisibility(true);
152  white -> SetForceSolid(true);
153  white -> SetForceWireframe(true);
154 
155  blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
156  blue -> SetVisibility(true);
157  //blue -> SetForceSolid(true);
158 
159  gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5, 0.5 ));
160  gray-> SetVisibility(true);
161  gray-> SetForceSolid(true);
162 
163  red = new G4VisAttributes(G4Colour(1. ,0. ,0., 0.2));
164  red-> SetVisibility(true);
165  red-> SetForceSolid(true);
166  //red -> SetForceWireframe(true);
167 
168  yellow = new G4VisAttributes(G4Colour(1., 1., 0., 0.2));
169  yellow-> SetVisibility(true);
170  yellow-> SetForceSolid(true);
171 
172  green = new G4VisAttributes( G4Colour(25/255. , 255/255. , 25/255., 0.4));
173  green -> SetVisibility(true);
174  green -> SetForceWireframe(true);
175  green -> SetForceSolid(true);
176 
177  black = new G4VisAttributes( G4Colour(255/255. , 255/255., 255/255.));
178  black -> SetVisibility(true);
179  black -> SetForceSolid(true);
180 
181  darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. , 0/255.));
182  darkGreen -> SetVisibility(true);
183  darkGreen -> SetForceSolid(true);
184 
185  darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. , 000/255., 0.7));
186  darkOrange3 -> SetVisibility(true);
187  darkOrange3 -> SetForceSolid(true);
188 
189  skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. , 235/255., 0.1));
190  skyBlue -> SetVisibility(true);
191  skyBlue -> SetForceSolid(true);
192 
193  // DEFAULT DIMENSIONS AND POSITIONS ARE PROVIDED HERE.
195  G4double defaultInnerRadiusExitWindow=0. *mm;
196  InnerRadiusExitWindow=defaultInnerRadiusExitWindow;
197 
198  G4double defaultExternalRadiusExitWindow=55*mm;
199  ExternalRadiusExitWindow=defaultExternalRadiusExitWindow;
200 
201  G4double defaultExitWindowThickness=25 *um;
202  ExitWindowThickness=defaultExitWindowThickness;
203 
204  G4double defaultExitWindowXPosition=-ExitWindowThickness/2.;
205  ExitWindowXPosition=defaultExitWindowXPosition;
206 
207  G4double defaultExitWindowYPosition=0.;
208  ExitWindowYPosition=defaultExitWindowYPosition;
209 
210  G4double defaultExitWindowZPosition=0.0*mm;
211  ExitWindowZPosition=defaultExitWindowZPosition;
212 
213  G4double defaultStartAngleExitWindow = 0.0 *deg;
214  startAngleExitWindow = defaultStartAngleExitWindow;
215 
216  G4double defaultSpanningAngleExitWindow = 360.*deg;
217  spanningAngleExitWindow = defaultSpanningAngleExitWindow;
219  G4double defaultExitPipeheight=105. *mm;
220  ExitPipeheight=defaultExitPipeheight;
221 
222  G4double defaultInnerRadiusExitPipe=50. *mm;
223  InnerRadiusExitPipe=defaultInnerRadiusExitPipe;
224 
225  G4double defaultExternalRadiusExitPipe=55 *mm;
226  ExternalRadiusExitPipe=defaultExternalRadiusExitPipe;
227 
228  G4double defaultExitPipeXPosition=-ExitPipeheight/2-ExitWindowThickness;
229  ExitPipeXPosition=defaultExitPipeXPosition;
230 
231  G4double defaultExitPipeYPosition=0;
232  ExitPipeYPosition=defaultExitPipeYPosition;
233 
234  G4double defaultExitPipeZPosition=0.0*mm;
235  ExitPipeZPosition=defaultExitPipeZPosition;
236 
237  G4double defaultStartAngleExitPipe = 0.0 *deg;
238  startAngleExitPipe = defaultStartAngleExitPipe;
239 
240  G4double defaultSpanningAngleExitPipe = 360.*deg;
241  spanningAngleExitPipe = defaultSpanningAngleExitPipe;
243  G4double defaultExternalChamberXSize = 79.6*cm;
244  externalChamberXSize = defaultExternalChamberXSize;
245 
246  G4double defaultExternalChamberYSize = 50. *cm;
247  externalChamberYSize = defaultExternalChamberYSize;
248 
249  G4double defaultExternalChamberZSize = 50. *cm;
250  externalChamberZSize = defaultExternalChamberZSize;
251 
252  G4double defaultExternalChamberXPosition = -(externalChamberXSize/2.+ExitPipeheight/2.)+ ExitPipeXPosition;
253  externalChamberXPosition = defaultExternalChamberXPosition;
254 
255  G4double defaultExternalChamberYPosition = 0.0 *mm;
256  externalChamberYPosition = defaultExternalChamberYPosition;
257 
258  G4double defaultExternalChamberZPosition = 0.0 *mm;
259  externalChamberZPosition = defaultExternalChamberZPosition;
260 
261  // Defaults of the internal chamber dimensions
262  // The position of its center is in the center
263  // of the internal chamber while the dimension are
264  // authomatically calculated respect to the external chamber ones
265  G4double defaultVaccumChamberWallThickness=5 *mm;
266  VaccumChamberWallThickness=defaultVaccumChamberWallThickness;
267 
268  G4double defaultInternalChamberXSize =externalChamberXSize - 2*VaccumChamberWallThickness;
269  internalChamberXSize = defaultInternalChamberXSize;
270 
271  G4double defaultInternalChamberYSize =externalChamberYSize - 2*VaccumChamberWallThickness;
272  internalChamberYSize = defaultInternalChamberYSize;
273 
274  G4double defaultInternalChamberZSize = externalChamberZSize - 2*VaccumChamberWallThickness;
275  internalChamberZSize = defaultInternalChamberZSize;
277  G4double defaultInnerRadiusExithole=0.*mm;
278  InnerRadiusExithole=defaultInnerRadiusExithole;
279 
280  G4double defaultExternalRadiusExithole=50.*mm;
281  ExternalRadiusExithole=defaultExternalRadiusExithole;
282 
283  G4double defaultExitholeThickness=VaccumChamberWallThickness;
284  ExitholeThickness=defaultExitholeThickness;
285 
286  G4double defaultExitholeXPosition=(externalChamberXSize/2.-ExitholeThickness/2.);
287  ExitholeXPosition=defaultExitholeXPosition;
288 
289  G4double defaultExitholeYPosition=0.;
290  ExitholeYPosition=defaultExitholeYPosition;
291 
292  G4double defaultExitholeZPosition=0.*mm;
293  ExitholeZPosition=defaultExitholeZPosition;
294 
295  G4double defaultStartAngleExithole = 0.0 *deg;
296  startAngleExithole= defaultStartAngleExithole;
297 
298  G4double defaultSpanningAngleExithole = 360.*deg;
299  spanningAngleExithole = defaultSpanningAngleExithole;
301  // The Final Collimator is located after the 4th magnet
302  G4double defaultExitholeToFinalCollimator=70 *mm;
303  ExitholeToFinalCollimator=defaultExitholeToFinalCollimator;
304 
305  defaultInnerRadiusFinalCollimator = 0.0 *mm;
306  innerRadiusFinalCollimator = defaultInnerRadiusFinalCollimator;
307 
308  defaultOuterRadiusFinalCollimator = 2.50 *mm;
309  outerRadiusFinalCollimator = defaultOuterRadiusFinalCollimator;
310 
311  defaultFinalCollimatorThickness = 3.0 *mm;
312  FinalCollimatorThickness = defaultFinalCollimatorThickness;
313 
314  defaultStartAngleFinalCollimator = 0.0 *deg;
315  startAngleFinalCollimator = defaultStartAngleFinalCollimator;
316 
317  defaultSpanningAngleFinalCollimator = 360.*deg;
318  spanningAngleFinalCollimator = defaultSpanningAngleFinalCollimator;
319 
320  defaultFinalCollimatorXPosition = internalChamberXSize/2.-ExitholeToFinalCollimator-FinalCollimatorThickness/2.;
321  collimatorFinalBox_XPosition=defaultFinalCollimatorXPosition;
322  FinalcollimatorXPosition = 0.0*mm; //HOLE IN THE FINAL COLLIMATOR
323 
324  defaultFinalCollimatorYPosition = 0.0*mm;
325  collimatorFinalBox_YPosition=defaultFinalCollimatorYPosition;
326  FinalcollimatorYPosition = defaultFinalCollimatorYPosition;
327 
328  defaultFinalCollimatorZPosition = 0.0*mm;
329  collimatorFinalBox_ZPosition=0.0*mm;
330  FinalcollimatorZPosition =defaultFinalCollimatorZPosition;
331 
332  defaultThicknessCollimator =3.0 *mm;
333  collimatorFinalBoxXSize=defaultFinalCollimatorThickness;
334  collimatorFinalBoxYSize=82.0*mm;
335  collimatorFinalBoxZSize=210.0*mm;
337 
338  //Magnet characteristics
339  G4double defaultExternalMagnet_XSize = 88.0*mm;
340  G4double defaultExternalMagnet_YSizeTotal=87.*mm;
341  G4double defaultInternalMagnet_YSize = 10. *mm;
342  G4double defaultExternalMagnet_YSize =(defaultExternalMagnet_YSizeTotal-defaultInternalMagnet_YSize)/2.;
343  G4double defaultExternalMagnet_ZSize = 104 *mm;
344 
345  G4double defaultExternalMagnet_YPosition =defaultInternalMagnet_YSize/2.+defaultExternalMagnet_YSize/2.;
346  G4double defaultExternalMagnet_ZPosition = 0.0 *mm;
347 
348  G4double defaultMagnet_XSize=defaultExternalMagnet_XSize;
349  G4double defaultMagnet_YSize=defaultExternalMagnet_YSizeTotal;
350  G4double defaultMagnet_ZSize=19*mm;
351 
352  // Defaults of the external part of the magnet 4:
353  G4double defaultFinalCollimatorToMagnet4=25.*mm;
354  FinalCollimatorToMagnet4=defaultFinalCollimatorToMagnet4;
355 
356  externalMagnet_4XSize = defaultExternalMagnet_XSize;
357  externalMagnet_4YSize = defaultExternalMagnet_YSize;
358  externalMagnet_4ZSize = defaultExternalMagnet_ZSize;
359 
360  Magnet_4XSize=defaultMagnet_XSize;
361  Magnet_4YSize=defaultMagnet_YSize;
362  Magnet_4ZSize=defaultMagnet_ZSize;
363 
364  G4double defaultExternalMagnet_4XPosition = -(FinalCollimatorThickness/2.+FinalCollimatorToMagnet4+defaultExternalMagnet_XSize/2.)+ collimatorFinalBox_XPosition;
365  externalMagnet_4XPosition = defaultExternalMagnet_4XPosition;
366 
367  externalMagnet_4YPosition = defaultExternalMagnet_YPosition;
368  externalMagnet_4ZPosition = defaultExternalMagnet_ZPosition;
369 
370  Magnet_4XPosition=externalMagnet_4XPosition;
371  Magnet_4YPosition=0.0*mm;
372  Magnet_4ZPosition=(defaultExternalMagnet_ZSize+defaultMagnet_ZSize)/2.;
374  // Defaults of the external part of the magnet 3:
375  externalMagnet_3XSize = defaultExternalMagnet_XSize;
376  externalMagnet_3YSize = defaultExternalMagnet_YSize;
377  externalMagnet_3ZSize = defaultExternalMagnet_ZSize;
378 
379  Magnet_3XSize=defaultMagnet_XSize;
380  Magnet_3YSize=defaultMagnet_YSize;
381  Magnet_3ZSize=defaultMagnet_ZSize;
382 
383  G4double defaultMagnet4ToMagnet3=65.*mm; //85.*mm ANTONELLA
384  Magnet4ToMagnet3=defaultMagnet4ToMagnet3;
385 
386  G4double defaultExternalMagnet_3XPosition =-(Magnet4ToMagnet3+defaultExternalMagnet_XSize/2.+defaultExternalMagnet_XSize/2.)+externalMagnet_4XPosition;
387  externalMagnet_3XPosition = defaultExternalMagnet_3XPosition;
388 
389  externalMagnet_3YPosition =defaultExternalMagnet_YPosition;
390  externalMagnet_3ZPosition = defaultExternalMagnet_ZPosition;
391 
392 
393  Magnet_3XPosition=externalMagnet_3XPosition;
394  Magnet_3YPosition=0.0*mm;
395  Magnet_3ZPosition=(defaultExternalMagnet_ZSize+defaultMagnet_ZSize)/2.;
397  // Defaults of the external part of the magnet 2:
398  externalMagnet_2XSize = defaultExternalMagnet_XSize;
399  externalMagnet_2YSize = defaultExternalMagnet_YSize;
400  externalMagnet_2ZSize = defaultExternalMagnet_ZSize;
401 
402  Magnet_2XSize=defaultMagnet_XSize;
403  Magnet_2YSize=defaultMagnet_YSize;
404  Magnet_2ZSize=defaultMagnet_ZSize;
405 
406  G4double defaultMagnet3ToMagnet2=10 *mm;
407  Magnet3ToMagnet2=defaultMagnet3ToMagnet2;
408 
409  G4double defaultExternalMagnet_2XPosition =-(Magnet3ToMagnet2+defaultExternalMagnet_XSize/2.+defaultExternalMagnet_XSize/2.)+externalMagnet_3XPosition;
410  externalMagnet_2XPosition = defaultExternalMagnet_2XPosition;
411 
412  externalMagnet_2YPosition = defaultExternalMagnet_YPosition;
413  externalMagnet_2ZPosition = defaultExternalMagnet_ZPosition;
414 
415  Magnet_2XPosition=externalMagnet_2XPosition;
416  Magnet_2YPosition=0.0*mm;
417  Magnet_2ZPosition=(defaultExternalMagnet_ZSize+defaultMagnet_ZSize)/2.;
419  // Defaults of the external part of the magnet 1:
420  externalMagnet_1XSize=defaultExternalMagnet_XSize;
421  externalMagnet_1YSize = defaultExternalMagnet_YSize;
422  externalMagnet_1ZSize = defaultExternalMagnet_ZSize;
423 
424  Magnet_1XSize=defaultMagnet_XSize;
425  Magnet_1YSize=defaultMagnet_YSize;
426  Magnet_1ZSize=defaultMagnet_ZSize;
427 
428  G4double defaultMagnet2ToMagnet1=85 *mm;
429  Magnet2ToMagnet1=defaultMagnet2ToMagnet1;
430 
431  G4double defaultExternalMagnet_1XPosition = -(Magnet2ToMagnet1+defaultExternalMagnet_XSize/2.+defaultExternalMagnet_XSize/2.)+externalMagnet_2XPosition;
432  externalMagnet_1XPosition = defaultExternalMagnet_1XPosition;
433 
434  externalMagnet_1YPosition = defaultExternalMagnet_YPosition;
435  externalMagnet_1ZPosition = defaultExternalMagnet_ZPosition;
436 
437  Magnet_1XPosition=defaultExternalMagnet_1XPosition;
438  Magnet_1YPosition=0.0*mm;
439  Magnet_1ZPosition=(defaultExternalMagnet_ZSize+defaultMagnet_ZSize)/2.;
440 
441  // Defaults of the external part of the Slit
442  G4double defaultExternalSlitXSize = 8.0 *mm;
443  externalSlitXSize = defaultExternalSlitXSize;
444 
445  G4double defaultExternalSlitYSize = 82. *mm;
446  externalSlitYSize = defaultExternalSlitYSize;
447 
448  G4double defaultExternalSlitZSize = 210. *mm;
449  externalSlitZSize = defaultExternalSlitZSize;
450 
451  G4double defaultExternalSlitXPosition = -(Magnet3ToMagnet2/2.+defaultExternalMagnet_XSize/2.)+externalMagnet_3XPosition;
452  externalSlitXPosition = defaultExternalSlitXPosition;
453 
454  G4double defaultExternalSlitYPosition = 0.0 *mm;
455  externalSlitYPosition = defaultExternalSlitYPosition;
456 
457  G4double defaultExternalSlitZPosition = 0.0 *mm;
458  externalSlitZPosition = defaultExternalSlitZPosition;
459 
460  // Defaults of the internal part of the Slit:
461  internalSlitXSize = defaultExternalSlitXSize;
462 
463  G4double defaultInternalSlitYSize = 3 *mm;
464  internalSlitYSize = defaultInternalSlitYSize;
465 
466  G4double defaultInternalSlitZSize = 3 *mm;
467  internalSlitZSize = defaultInternalSlitZSize;
468 
469  G4double defaultInternalSlitXPosition = 0.0 *mm;
470  internalSlitXPosition = defaultInternalSlitXPosition;
471 
472  G4double defaultInternalSlitYPosition = 0.0 *mm;
473  internalSlitYPosition = defaultInternalSlitYPosition;
474 
475  G4double defaultInternalSlitZPosition = 40.0 *mm;
476  internalSlitZPosition = defaultInternalSlitZPosition;
477 
478  // Defaults of the particle collimator (First collimator).
479  // The Collimator should be located before the 1st magnet
480  //
481  defaultInnerRadiusCollimator = 0.0 *mm;
482  innerRadiusCollimator = defaultInnerRadiusCollimator;
483 
484  defaultOuterRadiusCollimator = 2.5 *mm;
485  outerRadiusCollimator = defaultOuterRadiusCollimator;
486 
487  thicknessCollimator = defaultThicknessCollimator;
488 
489  defaultStartAngleCollimator = 0.0 *deg;
490  startAngleCollimator = defaultStartAngleCollimator;
491 
492  defaultSpanningAngleCollimator = 360.*deg;
493  spanningAngleCollimator = defaultSpanningAngleCollimator;
494 
495  G4double defultMagnet1ToFirstCollimator=25.*mm;
496  Magnet1ToFirstCollimator=defultMagnet1ToFirstCollimator;
497 
498  defaultCollimatorXPosition = -(thicknessCollimator/2.+Magnet1ToFirstCollimator+defaultExternalMagnet_XSize/2.)+externalMagnet_1XPosition;
499  collimatorBox_XPosition=defaultCollimatorXPosition;
500  collimatorXPosition = 0.0*mm;
501 
502  defaultCollimatorYPosition = 0.0*mm;
503  collimatorBox_YPosition=defaultCollimatorYPosition;
504  collimatorYPosition = 0.0*mm;
505 
506  defaultCollimatorZPosition = 0.0*mm;
507  collimatorBox_ZPosition=defaultCollimatorZPosition;
508  collimatorZPosition = 0.*mm;
509 
510  collimatorBoxYSize=82.0* mm;
511  collimatorBoxZSize=210.0* mm;
512 
514  G4double defaultInnerRadiusEntrancehole=0. *mm;
515  InnerRadiusEntrancehole=defaultInnerRadiusEntrancehole;
516 
517  G4double defaultExternalRadiusEntrancehole=50.*mm;
518  ExternalRadiusEntrancehole=defaultExternalRadiusEntrancehole;
519 
520  G4double defaultEntranceholeThickness=VaccumChamberWallThickness;
521  EntranceholeThickness=defaultEntranceholeThickness;
522 
523  G4double defaultEntranceholeXPosition=-(externalChamberXSize/2.-EntranceholeThickness/2.);
524  EntranceholeXPosition=defaultEntranceholeXPosition;
525 
526  G4double defaultEntranceholeQuadXPosition=+(externalChamberXSize/2.-EntranceholeThickness/2.);
527  EntranceholeQuadXPosition=defaultEntranceholeQuadXPosition;
528 
529  G4double defaultEntranceholeYPosition=0.;
530  EntranceholeYPosition=defaultEntranceholeYPosition;
531 
532  G4double defaultEntranceholeZPosition=0.0*mm;
533  EntranceholeZPosition=defaultEntranceholeZPosition;
534 
535  G4double defaultStartAngleEntrancehole= 0.0 *deg;
536  startAngleEntrancehole= defaultStartAngleEntrancehole;
537 
538  G4double defaultSpanningAngleEntrancehole= 360.*deg;
539  spanningAngleEntrancehole=defaultSpanningAngleEntrancehole;
540 
542 
543  G4double defaultEntrancePipeheight=105. *mm;
544  EntrancePipeheight=defaultEntrancePipeheight;
545 
546  G4double defaultInnerRadiusEntrancePipe=50. *mm;
547  InnerRadiusEntrancePipe=defaultInnerRadiusEntrancePipe;
548 
549  G4double defaultExternalRadiusEntrancePipe=55 *mm;
550  ExternalRadiusEntrancePipe=defaultExternalRadiusEntrancePipe;
551 
552  G4double defaultEntrancePipeXPosition=-EntrancePipeheight/2-externalChamberXSize/2+externalChamberXPosition;
553  EntrancePipeXPosition=defaultEntrancePipeXPosition;
554 
555  G4double defaultEntrancePipeYPosition=0;
556  EntrancePipeYPosition=defaultEntrancePipeYPosition;
557 
558  G4double defaultEntrancePipeZPosition=0.0*mm;
559  EntrancePipeZPosition=defaultEntrancePipeZPosition;
560 
561  G4double defaultStartAngleEntrancePipe= 0.0 *deg;
562  startAngleEntrancePipe= defaultStartAngleEntrancePipe;
563 
564  G4double defaultSpanningAngleEntrancePipe= 360.*deg;
565  spanningAngleEntrancePipe=defaultSpanningAngleEntrancePipe;
566 
568  G4double defaultQuadChamberWallPosX=-(externalChamberXSize/2.)-EntrancePipeheight/2.+EntrancePipeXPosition;
569  QuadChamberWallPosX=defaultQuadChamberWallPosX;
570  G4double defaultQuadChamberWallPosY=0.0*cm;
571  QuadChamberWallPosY=defaultQuadChamberWallPosY;
572  G4double defaultQuadChamberWallPosZ=0.0*cm;
573  QuadChamberWallPosZ=defaultQuadChamberWallPosZ;
574 
575  G4double defaultInnerRadiusQuad=10.0*mm;
576  InnerRadiusQuad=defaultInnerRadiusQuad;
577 
578  G4double defaultInnerRadiusTriplet=0.0*mm;
579  InnerRadiusTriplet=defaultInnerRadiusTriplet;
580 
581  G4double defaultExternalRadiusQuad=30.0*mm;
582  ExternalRadiusQuad=defaultExternalRadiusQuad;
583 
584  G4double defaultFirstQuadThickness=80.0*mm;
585  FirstQuadThickness=defaultFirstQuadThickness;
586  G4double defaultSecondQuadThickness=40.0*mm;
587  SecondQuadThickness=defaultSecondQuadThickness;
588  G4double defaultThirdQuadThickness=40.0*mm;
589  ThirdQuadThickness=defaultThirdQuadThickness;
590  G4double defaultFourthQuadThickness=80.0*mm;
591  FourthQuadThickness=defaultFourthQuadThickness;
592 
593  G4double defaultStartAngleQuad = 0.0 *deg;
594  startAngleQuad = defaultStartAngleQuad;
595 
596  G4double defaultSpanningAngleQuad = 360.*deg;
597  spanningAngleQuad = defaultSpanningAngleQuad;
598 
599  G4double distancefromQuadChamber=100.0*mm;
600  G4double defaultFourthQuadXPosition= internalChamberXSize/2.-distancefromQuadChamber-FourthQuadThickness/2.;
601  FourthQuadXPosition=defaultFourthQuadXPosition;
602  FourthQXPosition=0.0*mm;
603 
604  G4double distanceFQuadTQuad=100.0*mm;
605  G4double defaultThirdQuadXPosition=-ThirdQuadThickness/2.-distanceFQuadTQuad-FourthQuadThickness/2.+FourthQuadXPosition;
606  ThirdQuadXPosition=defaultThirdQuadXPosition;
607  ThirdQXPosition=0.0*mm;
608 
609  G4double distanceTQuadSQuad=100.0*mm;
610  G4double defaultSecondQuadXPosition=-SecondQuadThickness/2.-distanceTQuadSQuad-ThirdQuadThickness/2.+ThirdQuadXPosition;
611  SecondQuadXPosition=defaultSecondQuadXPosition;
612  SecondQXPosition=0.0*mm;
613 
614  G4double distanceSQuadFQuad=100.0*mm;
615  G4double defaultFirstQuadXPosition=-FirstQuadThickness/2.-distanceSQuadFQuad-SecondQuadThickness/2.+SecondQuadXPosition;
616  FirstQuadXPosition=defaultFirstQuadXPosition;
617  FirstQXPosition=0.0*mm;
618 
619  G4double defaultQuadYPosition=0.0*mm;
620  QuadYPosition=defaultQuadYPosition;
621  QYPosition=defaultQuadYPosition;
622 
623  G4double defaultQuadTZPosition= 0.*mm;
624  QuadZPosition=defaultQuadTZPosition;
625  G4double defaultQuadZPosition=0.0*mm;
626  QZPosition=defaultQuadZPosition;
627 
628  // DEFAULT DEFINITION OF THE MATERIALS
629  // All elements and compound definition follows the NIST database
630 
631  //ELEMENTS
632  G4bool isotopes = false;
635 
636  //COMPOUNDS
637  G4Material* ironNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe", isotopes);
638  G4Material* aluminiumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
639  G4Material* kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
640  //G4Material* waterNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER", isotopes);
641  G4Material* stainless_steelNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_STAINLESS-STEEL", isotopes);
642 
643  // Elements and compunds not pre-defined in Geant4
644  G4double d; // Density
645  G4int nComponents;// Number of components
646  G4double fractionmass; // Fraction in mass of an element in a material
647  d = 8.40*g/cm3;
648  nComponents = 2;
649  G4Material* brass = new G4Material("Brass", d, nComponents);
650  brass -> AddElement(zincNist, fractionmass = 30 *perCent);
651  brass -> AddElement(copperNist, fractionmass = 70 *perCent);
652 
653  G4double atomicNumber = 1.;
654  G4double massOfMole = 1.008*g/mole;
655  d = 1.e-25*g/cm3;
656  G4double temperature = 2.73*kelvin;
657  G4double pressure = 3.e-18*pascal;
658  G4Material* vacuum = new G4Material("interGalactic", atomicNumber,massOfMole, d, kStateGas,temperature, pressure);
659 
660  //***************************** PW ***************************************
661 
662  // DetectorROGeometry Material
663  new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
664 
665  //***************************** PW ***************************************
666 
667  // MATERIAL ASSIGNMENT
668  MotherMaterial=vacuum;
669  QuadMaterial=ironNist;
670  externalChamberMaterial = stainless_steelNist;
671  internalChamberMaterial = vacuum;
672  collimatorMaterial = aluminiumNist;
673  collimatorHoleMaterial=vacuum;
674  FinalcollimatorMaterial=aluminiumNist;
675  FinalcollimatorHoleMaterial=vacuum;
676  WindowMaterial=kaptonNist;
677  PipeMaterial=stainless_steelNist;
678 
679  externalMagnet_1Material = ironNist;
680  externalMagnet_2Material = ironNist;
681  externalMagnet_3Material = ironNist;
682  externalMagnet_4Material = ironNist;
683 
684  externalSlitMaterial = brass;
685  internalSlitMaterial =vacuum;
686 
687  //FC Material
688 
689  KaptonEntranceWindowMaterial=kaptonNist;
690  GuardRingMaterial=stainless_steelNist;
691  FaradayCupBottomMaterial=aluminiumNist;
692  CupMaterial=FaradayCupBottomMaterial;
693  MassRingMaterial=GuardRingMaterial;
694 
695 }
696 
698 void LaserDrivenBeamLine::ConstructLaserDrivenBeamLine()
699 {
700  // -----------------------------
701  // Treatment room - World volume
702  //------------------------------
703 
704  const G4double worldX = 800.0 *cm;
705  const G4double worldY = 400.0 *cm;
706  const G4double worldZ = 400.0 *cm;
707 
708  solidTreatmentRoom = new G4Box("TreatmentRoom",
709  worldX,
710  worldY,
711  worldZ);
712 
713  logicTreatmentRoom = new G4LogicalVolume(solidTreatmentRoom,
714  MotherMaterial,
715  "logicTreatmentRoom",
716  0,
717  0,
718  0);
719 
720  physicTreatmentRoom = new G4PVPlacement(0,
721  G4ThreeVector(),
722  "physicalTreatmentRoom",
723  logicTreatmentRoom,
724  0,
725  false,
726  0);
727 
728 
729  // The treatment room is invisible in the Visualisation
730  logicTreatmentRoom -> SetVisAttributes (G4VisAttributes::Invisible);
731 
732  // The various components of the energyselector are constructed calling
733  // the following methods
734 
735  // This method constructs the chamber where the energyselector is located
736  EnergySelectorChamber();
737  // This method construct the exit window
738  ExitWindow();
739  // This method construct the exit pipe
740  ExitPipe();
741  // This method construct the exit hole
742  Exithole();
743 
744  // This method constructs a circular collimator of variable thickness and
745  // aperture. It is placed befor the magnet to collimate particles caming from the
746  // plasma;
747  Collimator();
748 
749  // This method constructs the magnet 1 and its associated magnetic field
750  Magnet_1();
751 
752  // This method constructs the magnet 2 and its associated magnetic field
753  Magnet_2();
754 
755  // This method constructs the magnet 3 and its associated magnetic field
756  Magnet_3();
757 
758  // This method constructs the magnet 4 and its associated magnetic field
759  Magnet_4();
760 
761  // The selection slit is a square hole moveable inside a metallic plate
762  Slit();
763 
764  FinalCollimator();
765 
766  // This method construct the quadrupoles
767  Quadrupole();
768  // This method construct the entrance hole
769  Entrancehole();
770  // This method construct the entrance pipe
771  EntrancePipe();
772 
773  FaradayCup();
774 
775 }
776 
777 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
778 
780 {
781  G4double minEps=1.0e-5; // Minimum & value for smallest steps
782  G4double maxEps=1.0e-4;
783  G4bool allLocal = true;
784  // G4int nvar = 8; For pure magnetic field, the number of integration variables is the default!
785 
786  //....oooOO0OOooo..........ENERGY SELECTOR SYSTEM FIELD..........oooOO0OOooo....
787  if(logicInternalChamber){G4double xOffset =(internalChamberXSize/2.0)+externalSlitXPosition;
788  PurgMagField = new HadrontherapyMagneticField3D("field/ESSMagneticField.TABLE", xOffset);
789  pFieldMgr =new G4FieldManager();
790  pFieldMgr -> SetDetectorField(PurgMagField);
791  G4cout << "DeltaStep "<< pFieldMgr -> GetDeltaOneStep()/mm <<"mm" <<endl;
792  pFieldMgr -> CreateChordFinder(PurgMagField);
793  fEquation = new G4Mag_UsualEqRhs(PurgMagField);
794  fstepper = new G4ClassicalRK4(fEquation);
796  pIntgrDriver = new G4MagInt_Driver(1*mm,fstepper,fstepper-> GetNumberOfVariables());
797  //the first parameter is the minimum step
798  pChordFinder = new G4ChordFinder(pIntgrDriver);
799  pFieldMgr->SetChordFinder(pChordFinder);
800  pFieldMgr->SetMinimumEpsilonStep(minEps);
801  pFieldMgr->SetMaximumEpsilonStep(maxEps);
802  pFieldMgr->SetDeltaOneStep(0.5e-3*mm);//default value of DeltaChord is 0.25 mm
803  logicInternalChamber -> SetFieldManager(pFieldMgr, allLocal);}
804  //....oooOO0OOooo..........QUADS FIELDS..........oooOO0OOooo....
805  //....oooOO0OOooo..........FOURTH QUAD FIELD..........oooOO0OOooo....
806  if(LFourthTriplet){G4double xOffsetFQ =-(QuadChamberWallPosX+FourthQuadXPosition);
807  PurgMagFieldQuadFourth = new HadrontherapyMagneticField3D("field/Quad80MagneticField.TABLE", xOffsetFQ);
808  pFieldMgrQuadFourth = new G4FieldManager();
809  pFieldMgrQuadFourth -> SetDetectorField(PurgMagFieldQuadFourth);
810 
811  pFieldMgrQuadFourth -> CreateChordFinder(PurgMagFieldQuadFourth);
812  fEquationQuadFourth = new G4Mag_UsualEqRhs(PurgMagFieldQuadFourth);
813  fstepperQuadFourth = new G4ClassicalRK4(fEquationQuadFourth);
814  pIntgrDriverQuadFourth = new G4MagInt_Driver(1*mm,fstepperQuadFourth,fstepperQuadFourth-> GetNumberOfVariables());
815  //the first parameter is the minimum step
816  pChordFinderQuadFourth = new G4ChordFinder(pIntgrDriverQuadFourth);
817  pFieldMgrQuadFourth->SetChordFinder(pChordFinderQuadFourth);
818  pFieldMgrQuadFourth->SetMinimumEpsilonStep(minEps);
819  pFieldMgrQuadFourth->SetMaximumEpsilonStep(maxEps);
820  pFieldMgrQuadFourth->SetDeltaOneStep(0.5e-3*mm);//default value of DeltaChord is 0.25 mm
821  LFourthTriplet -> SetFieldManager(pFieldMgrQuadFourth, allLocal);}
822  //....oooOO0OOooo..........THIRD QUAD FIELD..........oooOO0OOooo....
823  if(LThirdTriplet){ G4double xOffsetTQ =-(QuadChamberWallPosX+ThirdQuadXPosition);
824  PurgMagFieldQuadThird = new HadrontherapyMagneticField3D("field/Quad40MagneticField.TABLE", xOffsetTQ);
825  pFieldMgrQuadThird = new G4FieldManager();
826  pFieldMgrQuadThird -> SetDetectorField(PurgMagFieldQuadThird);
827  pFieldMgrQuadThird -> CreateChordFinder(PurgMagFieldQuadThird);
828  fEquationQuadThird = new G4Mag_UsualEqRhs(PurgMagFieldQuadThird);
829  fstepperQuadThird = new G4ClassicalRK4(fEquationQuadThird);
830  pIntgrDriverQuadThird = new G4MagInt_Driver(1*mm,fstepperQuadThird,fstepperQuadThird-> GetNumberOfVariables());
831  //the first parameter is the minimum step
832  pChordFinderQuadThird = new G4ChordFinder(pIntgrDriverQuadThird);
833  pFieldMgrQuadThird->SetChordFinder(pChordFinderQuadThird);
834  pFieldMgrQuadThird->SetMinimumEpsilonStep(minEps);
835  pFieldMgrQuadThird->SetMaximumEpsilonStep(maxEps);
836  pFieldMgrQuadThird->SetDeltaOneStep(0.5e-3*mm);//default value of DeltaChord is 0.25 mm
837  LThirdTriplet -> SetFieldManager(pFieldMgrQuadThird, allLocal);}
838  //....oooOO0OOooo..........SECOND QUAD FIELD..........oooOO0OOooo....
839  if(LSecondTriplet){G4double xOffsetSQ =-(QuadChamberWallPosX+SecondQuadXPosition);
840  PurgMagFieldQuadSecond = new HadrontherapyMagneticField3D("field/Quad40MagneticField.TABLE", xOffsetSQ);
841  pFieldMgrQuadSecond = new G4FieldManager();
842  pFieldMgrQuadSecond -> SetDetectorField(PurgMagFieldQuadSecond);
843  pFieldMgrQuadSecond -> CreateChordFinder(PurgMagFieldQuadSecond);
844  fEquationQuadSecond = new G4Mag_UsualEqRhs(PurgMagFieldQuadSecond);
845  fstepperQuadSecond = new G4ClassicalRK4(fEquationQuadSecond);
846  pIntgrDriverQuadSecond = new G4MagInt_Driver(1*mm,fstepperQuadSecond,fstepperQuadSecond-> GetNumberOfVariables());
847  //the first parameter is the minimum step
848  pChordFinderQuadSecond = new G4ChordFinder(pIntgrDriverQuadSecond);
849  pFieldMgrQuadSecond->SetChordFinder(pChordFinderQuadSecond);
850  pFieldMgrQuadSecond->SetMinimumEpsilonStep(minEps);
851  pFieldMgrQuadSecond->SetMaximumEpsilonStep(maxEps);
852  pFieldMgrQuadSecond->SetDeltaOneStep(0.5e-3*mm);//default value of DeltaChord is 0.25 mm
853  LSecondTriplet -> SetFieldManager(pFieldMgrQuadSecond, allLocal);}
854  //....oooOO0OOooo..........FIRST QUAD FIELD..........oooOO0OOooo....
855  if(LFirstTriplet) {G4double xOffsetFirstQ =-(QuadChamberWallPosX+FirstQuadXPosition);
856  PurgMagFieldQuadFirst = new HadrontherapyMagneticField3D("field/Quad80MagneticField.TABLE", xOffsetFirstQ);
857  pFieldMgrQuadFirst = new G4FieldManager();
858  pFieldMgrQuadFirst -> SetDetectorField(PurgMagFieldQuadFirst);
859  pFieldMgrQuadFirst -> CreateChordFinder(PurgMagFieldQuadFirst);
860  fEquationQuadFirst = new G4Mag_UsualEqRhs(PurgMagFieldQuadFirst);
861  fstepperQuadFirst = new G4ClassicalRK4(fEquationQuadFirst);
862  pIntgrDriverQuadFirst = new G4MagInt_Driver(1*mm,fstepperQuadFirst,fstepperQuadFirst-> GetNumberOfVariables());
863  //the first parameter is the minimum step
864  pChordFinderQuadFirst = new G4ChordFinder(pIntgrDriverQuadFirst);
865  pFieldMgrQuadFirst->SetChordFinder(pChordFinderQuadFirst);
866  pFieldMgrQuadFirst->SetMinimumEpsilonStep(minEps);
867  pFieldMgrQuadFirst->SetMaximumEpsilonStep(maxEps);
868  pFieldMgrQuadFirst->SetDeltaOneStep(0.5e-3*mm);//default value of DeltaChord is 0.25 mm
869  LFirstTriplet -> SetFieldManager(pFieldMgrQuadFirst, allLocal);}
870  //....oooOO0OOooo..........FARADAY CUP FIELD..........oooOO0OOooo....
871  if(logicVirtualMag) {G4double exOffset= -20*cm;
872  G4double eyOffset= 0*cm;
873  G4double ezOffset= 0*cm;
874  G4FieldManager *pEFieldmanager = new G4FieldManager();
875  G4ElectricField *ElectricField = new HadrontherapyElectricTabulatedField3D("field/ElectricFieldFC-600V.TABLE", exOffset, eyOffset, ezOffset);
876  // UNIFORM FIELD
877  // G4ElectroMagneticField* ElectricField = new G4UniformElectricField(G4ThreeVector(0.0, 10.0*volt/m, 0.0)); //G4UniformElectricField
878  // The following is only for global field in the whole geometry
879  //pEFieldmanager = G4TransportationManager::GetTransportationManager() -> GetFieldManager();
880 
881  const G4int nvarElectric=8; // The Equation of motion for Electric (or combined Electric/Magnetic)
882  // field requires 8 integration variables
883 
884  G4EqMagElectricField *fLocalEquation = new G4EqMagElectricField(ElectricField);
885  G4MagIntegratorStepper* fLocalStepper = new G4ClassicalRK4(fLocalEquation, nvarElectric);
886  G4MagInt_Driver *pIntgrDriver_E = new G4MagInt_Driver(0.02*mm, fLocalStepper, fLocalStepper -> GetNumberOfVariables() );
887  G4ChordFinder *fLocalChordFinder = new G4ChordFinder(pIntgrDriver_E);
888  pEFieldmanager -> SetDetectorField(ElectricField);
889  pEFieldmanager -> SetChordFinder(fLocalChordFinder);
890  //G4double deltainter=0.0001*mm;
891  //G4double missdist=0.1*mm;
892  //pEFieldmanager->SetDeltaIntersection(deltainter);
893  //fLocalChordFinder->SetDeltaChord(missdist);
894  pEFieldmanager->SetMinimumEpsilonStep(minEps);
895  pEFieldmanager->SetMaximumEpsilonStep(maxEps);
896  pEFieldmanager->SetDeltaOneStep( 0.5e-3 * mm );
897  //pEFieldmanager -> SetFieldChangesEnergy(true);
898  logicVirtualMag -> SetFieldManager(pEFieldmanager, allLocal);}
899  //....oooOO0OOooo....................oooOO0OOooo....
900  G4cout<<" //....oooOO0OOooo.......... FIELDS HAVE BEEN IMPLEMENTED..........oooOO0OOooo...."<<G4endl;
901  return;
902 }
903 
905 void LaserDrivenBeamLine::FaradayCup()
906 {
908 
909 G4double InnerRadiusFC=25*mm;
910 G4double OuterRadiusFC=45*mm;
911 G4double MassRingThickness=5*mm;
912 G4double GuardRingThickness=180*mm;
913 G4double FaradayCupBottomThickness=120*mm;
914 G4double CupThickness=10*cm;
915 G4double KaptonEntranceWindowThickness=25*um;
916 
918 
919 G4double VirtualWindowThickness=1.*um ;
920 G4double VirtualMiddleThickness= 1.*um ;
921 G4double VirtualBottomThickness= 1. *um ;
922 G4double VirtualOverBottomThickness=1. *um ;
923 G4double VirtualLateralLength=FaradayCupBottomThickness+CupThickness+VirtualBottomThickness;
924 
925 
927 
928 G4double virtualMagPosX=31*cm;
929 G4double FC_XOffset=20*cm;
930 G4double KaptonEntranceWindowPosX=-virtualMagPosX+KaptonEntranceWindowThickness/2+FC_XOffset;
931 G4double MassRingPosX=KaptonEntranceWindowPosX+KaptonEntranceWindowThickness/2+MassRingThickness/2;
932 G4double VirtualWindowPosX=MassRingPosX+MassRingThickness/2+VirtualWindowThickness/2;
933 G4double GuardRingPosX=MassRingPosX+MassRingThickness/2+GuardRingThickness/2+2*mm;
934 G4double VirtualMiddlePosX=GuardRingPosX+GuardRingThickness/2+VirtualMiddleThickness/2;
935 G4double FaradayCupBottomPosX=GuardRingPosX+GuardRingThickness/2+FaradayCupBottomThickness/2+1*cm;
936 G4double VirtualBottomPosX=FaradayCupBottomPosX+FaradayCupBottomThickness/2+VirtualBottomThickness/2;
937 G4double CupPosX=VirtualBottomPosX+VirtualBottomThickness/2+CupThickness/2;
938 G4double VirtualOverBottomPosX=CupPosX+CupThickness/2+VirtualOverBottomThickness/2;
939 G4double VirtualLateralPosX=GuardRingPosX+GuardRingThickness/2+1*cm+(FaradayCupBottomThickness+CupThickness+VirtualBottomThickness)/2;
940  G4double phi = 90. *deg;
941  G4RotationMatrix rm;
942  rm.rotateY(phi);
943 
944  virtualMag= new G4Box("virtualMag", 31.*cm, 6*cm, 6*cm );
945 
946  logicVirtualMag= new G4LogicalVolume( virtualMag,
947  internalChamberMaterial,
948  "LVirtualMag",
949  0,0,0);
950  physicVirtualMag = new G4PVPlacement(0,
951  G4ThreeVector(virtualMagPosX, 0.*cm, 0*mm),
952  "PVirtualMag",
953  logicVirtualMag,
954  physicTreatmentRoom,
955  true, 0);
956 
957 
958  logicVirtualMag -> SetVisAttributes(blue);
959 
961 
963  Rot->rotateX(14*deg);
964  G4ThreeVector trans(0.,22.5*mm,-15*mm);
965  Cylinder= new G4Tubs("cylinder",20*mm,22.5*mm,90*mm,0.,2*pi);
966  Box= new G4Box("Box",22.5*mm,22.5*mm,90*mm);
967 
968  G4SubtractionSolid* BeveledCylinder=new G4SubtractionSolid("Cylinder-Box",
969  Cylinder,
970  Box,
971  Rot,
972  trans);
973 
974  logicBeveledCylinder= new G4LogicalVolume (BeveledCylinder,
975  GuardRingMaterial,
976  "LBeveledCylinder",
977  0,0,0);
978 
979  physicBeveledCylinder =new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(GuardRingPosX,0,0)),
980  "physicBeveledCylinder",
981  logicBeveledCylinder,
982  physicVirtualMag,
983  true,0);
984 
985  logicBeveledCylinder->SetVisAttributes(green);
986 
987 
989 
990  KaptonEntranceWindow= new G4Tubs("KaptonEntranceWindow",
991  0,
992  OuterRadiusFC,
993  KaptonEntranceWindowThickness/2,
994  0*deg,360*deg);
995 
996  logicKaptonEntranceWindow=new G4LogicalVolume( KaptonEntranceWindow,
997  // internalChamberMaterial, for track control
998  KaptonEntranceWindowMaterial,
999  "LKaptonEntranceWindow",
1000  0,0,0);
1001 
1002  physicKaptonEntranceWindow=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(KaptonEntranceWindowPosX,0,0)),
1003  "PhysicEntranceWindow",
1004  logicKaptonEntranceWindow,
1005  physicVirtualMag,true,0);
1006  logicKaptonEntranceWindow -> SetVisAttributes(gray);
1007 
1009 
1010  MassRing=new G4Tubs ("MassRing",
1011  InnerRadiusFC,
1012  OuterRadiusFC,
1013  MassRingThickness/2,
1014  0*deg,360*deg);
1015 
1016  logicMassRing=new G4LogicalVolume( MassRing,
1017  MassRingMaterial,
1018  "logicMassRing",
1019  0,0,0);
1020 
1021  physicMassRing=new G4PVPlacement( G4Transform3D(rm,G4ThreeVector(MassRingPosX,0,0)),
1022 
1023  "PhysicMassRing",logicMassRing,
1024 
1025  physicVirtualMag,
1026  true,0);
1027  logicMassRing -> SetVisAttributes(green);
1028 
1029 
1030 
1031 
1033 
1034 
1035  VirtualWindow=new G4Tubs("VirtualWindow",
1036  0,
1037  OuterRadiusFC,
1038  VirtualWindowThickness/2,
1039  0*deg,360*deg);
1040 
1041  logicVirtualWindow=new G4LogicalVolume( VirtualWindow,
1042  internalChamberMaterial,
1043  "logicVirtualWindow",
1044  0,0,0);
1045 
1046  physicVirtualWindow=new G4PVPlacement( G4Transform3D(rm,G4ThreeVector(VirtualWindowPosX,0,0)),
1047 
1048  "PhysicVirtualWindow",
1049  logicVirtualWindow,
1050  physicVirtualMag,
1051  true,0);
1052  logicVirtualWindow->SetVisAttributes (G4VisAttributes::Invisible);
1053 
1055 
1056  GuardRing=new G4Tubs ("GuardRing",
1057  InnerRadiusFC,
1058  OuterRadiusFC,
1059  GuardRingThickness/2,
1060  0*deg,360*deg);
1061 
1062  logicGuardRing=new G4LogicalVolume( GuardRing,
1063  GuardRingMaterial,
1064  "logicGuardRing",
1065  0,0,0);
1066 
1067  physicGuardRing=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(GuardRingPosX,0,0)),
1068 
1069  "PhysicGuardRing", logicGuardRing,
1070 
1071  physicVirtualMag,
1072  true,0);
1073  logicGuardRing -> SetVisAttributes(red);
1074 
1075 
1077 
1078 
1079  VirtualMiddle=new G4Tubs ("VirtualMiddle",
1080  0,
1081  OuterRadiusFC,
1082  VirtualMiddleThickness/2,
1083  0*deg,360*deg);
1084 
1085  logicVirtualMiddle=new G4LogicalVolume( VirtualMiddle,
1086  internalChamberMaterial,
1087  "logicVirtualMiddle",
1088  0,0,0);
1089 
1090  physicVirtualMiddle=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(VirtualMiddlePosX,0,0)),
1091 
1092  "PhysicVirtualMiddle", logicVirtualMiddle,
1093 
1094  physicVirtualMag,
1095  true,0);
1096 
1097  logicVirtualMiddle->SetVisAttributes (G4VisAttributes::Invisible);
1098 
1100 
1101  FaradayCupBottom=new G4Tubs ("FaradayCupBottom",
1102  InnerRadiusFC,
1103  OuterRadiusFC,
1104  FaradayCupBottomThickness/2,
1105  0*deg,360*deg);
1106 
1107  logicFaradayCupBottom=new G4LogicalVolume( FaradayCupBottom,
1108  FaradayCupBottomMaterial,
1109  "logicFaradayCupBottom",
1110  0,0,0);
1111 
1112  physicFaradayCupBottom=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(FaradayCupBottomPosX,0,0)),
1113  "PhysicFaradayCupBottom",logicFaradayCupBottom,
1114  physicVirtualMag,
1115  true,0);
1116  logicFaradayCupBottom -> SetVisAttributes(yellow);
1117 
1118 
1120 
1121  VirtualBottom=new G4Tubs ("VirtualBottom",
1122  0,
1123  OuterRadiusFC,
1124  VirtualBottomThickness/2,
1125  0*deg,360*deg);
1126 
1127  logicVirtualBottom=new G4LogicalVolume( VirtualBottom,
1128  internalChamberMaterial,
1129  "logicVirtualBottom",
1130  0,0,0);
1131 
1132  physicVirtualBottom=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(VirtualBottomPosX,0,0)),
1133  "PhysicVirtualBottom",
1134  logicVirtualBottom,
1135  physicVirtualMag,
1136  true,0);
1137 
1138  logicVirtualBottom->SetVisAttributes (G4VisAttributes::Invisible);
1139 
1141 
1142  Cup=new G4Tubs ("Cup",
1143  0,
1144  OuterRadiusFC,
1145  CupThickness/2,
1146  0*deg,360*deg);
1147 
1148  logicCup=new G4LogicalVolume( Cup,
1149  CupMaterial,
1150  "logicCup",
1151  0,0,0);
1152 
1153  physicCup=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(CupPosX,0,0)),
1154  "PhysicCup", logicCup,
1155 
1156  physicVirtualMag,
1157  true,0);
1158 
1159  logicCup -> SetVisAttributes(darkGreen);
1160 
1161 
1163 
1164  VirtualOverBottom=new G4Tubs ("VirtualOverBottom",
1165  0,
1166  OuterRadiusFC,
1167  VirtualOverBottomThickness/2,
1168  0*deg,360*deg);
1169 
1170  logicVirtualOverBottom=new G4LogicalVolume( VirtualOverBottom,
1171  internalChamberMaterial,
1172  "logicVirtualOverBottom",
1173  0,0,0);
1174 
1175  physicVirtualOverBottom=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(VirtualOverBottomPosX,0,0)),
1176  "PhysicVirtualOverBottom",logicVirtualOverBottom,
1177 
1178  physicVirtualMag,
1179  true,0);
1180 logicVirtualOverBottom->SetVisAttributes (G4VisAttributes::Invisible);
1181 
1182 
1184 
1185 
1186  VirtualLateral=new G4Tubs ("VirtualLateral",
1187  OuterRadiusFC,
1188  OuterRadiusFC+1*um,// the VirtualLateralThickness is 1*um
1189  VirtualLateralLength/2,
1190  0*deg,360*deg);
1191 
1192 logicVirtualLateral=new G4LogicalVolume( VirtualLateral,
1193  internalChamberMaterial,
1194  "logicVirtualLateral",
1195  0,0,0);
1196 
1197  physicVirtualLateral=new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(VirtualLateralPosX,0,0)),
1198  "VirtualLateral",logicVirtualLateral,
1199 
1200  physicVirtualMag,
1201  true,0);
1202 
1203 
1204 
1205  logicVirtualLateral->SetVisAttributes (G4VisAttributes::Invisible);
1206  }
1207 
1209 void LaserDrivenBeamLine::Quadrupole()
1210 {
1211  // To rotate the quadrupoles putting their axis (along X direction) parallel to the beam axis
1212  G4double phi = 90. *deg;
1213  G4RotationMatrix rm;
1214  rm.rotateY(phi);
1215 
1216  SQuadChamberWall = new G4Box("solidQuadChamberWall",externalChamberXSize/2., externalChamberYSize/2.,externalChamberZSize/2.);
1217 
1218  LQuadChamberWall = new G4LogicalVolume(SQuadChamberWall, externalChamberMaterial,"logicQuadChamberWall");
1219 
1220  PQuadChamberWall = new G4PVPlacement(0, G4ThreeVector(QuadChamberWallPosX, QuadChamberWallPosY, QuadChamberWallPosZ),
1221  "physQuadChamberWall", LQuadChamberWall,physicTreatmentRoom, false, 0);
1222 
1223 
1224  SQuadChamber = new G4Box("solidQuadChamber", internalChamberXSize/2., internalChamberYSize/2.,internalChamberZSize/2.);
1225 
1226  LQuadChamber = new G4LogicalVolume(SQuadChamber, internalChamberMaterial,"logicQuadChamber");
1227 
1228  PQuadChamber = new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0),
1229  "physQuadChamber", LQuadChamber,PQuadChamberWall, false, 0);
1230 
1231  LQuadChamberWall -> SetVisAttributes(red);
1232  LQuadChamber -> SetVisAttributes(white);
1234  SFourthTriplet = new G4Tubs("SolidTQuad", InnerRadiusTriplet, ExternalRadiusQuad,((FourthQuadThickness/2.)+1*mm),
1235  startAngleQuad, spanningAngleQuad);
1236 
1237  LFourthTriplet = new G4LogicalVolume(SFourthTriplet, internalChamberMaterial,"LogicTQuad", 0, 0, 0);
1238 
1239  PFourthTriplet = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(FourthQuadXPosition, QuadYPosition, QuadZPosition)),
1240  "PhysFourthTQuad", LFourthTriplet, PQuadChamber, false, 0);
1241 
1242  solidFourthQuad = new G4Tubs("SolidQuad", InnerRadiusQuad, ExternalRadiusQuad, FourthQuadThickness/2.,
1243  startAngleQuad, spanningAngleQuad);
1244 
1245  logicFourthQuad = new G4LogicalVolume(solidFourthQuad, QuadMaterial, "LogicQuad", 0, 0, 0);
1246 
1247  physicFourthQuad = new G4PVPlacement(0, G4ThreeVector(FourthQXPosition, QYPosition, QZPosition),
1248  "PhysFourthQuad",logicFourthQuad, PFourthTriplet, false, 0);
1249 
1250  LFourthTriplet -> SetVisAttributes(yellow);
1251  logicFourthQuad -> SetVisAttributes(green);
1253  SThirdTriplet = new G4Tubs("SolidTTQuad", InnerRadiusTriplet, ExternalRadiusQuad, (ThirdQuadThickness/2.)+1*mm,
1254  startAngleQuad, spanningAngleQuad);
1255 
1256  LThirdTriplet = new G4LogicalVolume(SThirdTriplet, internalChamberMaterial,"LogicTTQuad", 0, 0, 0);
1257 
1258  PThirdTriplet = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(ThirdQuadXPosition, QuadYPosition, QuadZPosition)),
1259  "PhysThirdTQuad",LThirdTriplet,PQuadChamber, false, 0);
1260 
1261  solidThirdQuad = new G4Tubs("SolidTQuad", InnerRadiusQuad, ExternalRadiusQuad, ThirdQuadThickness/2.,
1262  startAngleQuad, spanningAngleQuad);
1263 
1264  logicThirdQuad = new G4LogicalVolume(solidThirdQuad, QuadMaterial, "LogicTQuad", 0, 0, 0);
1265 
1266  physicThirdQuad = new G4PVPlacement(0, G4ThreeVector(ThirdQXPosition, QYPosition, QZPosition),
1267  "PhysThirdQuad",logicThirdQuad, PThirdTriplet, false, 0);
1268 
1269  LThirdTriplet -> SetVisAttributes(yellow);
1270  logicThirdQuad -> SetVisAttributes(green);
1272  SSecondTriplet = new G4Tubs("SolidTSQuad", InnerRadiusTriplet, ExternalRadiusQuad, (SecondQuadThickness/2.)+1*mm,
1273  startAngleQuad, spanningAngleQuad);
1274 
1275  LSecondTriplet = new G4LogicalVolume(SSecondTriplet, internalChamberMaterial,"LogicTSQuad", 0, 0, 0);
1276 
1277  PSecondTriplet = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(SecondQuadXPosition, QuadYPosition, QuadZPosition)),
1278  "PhysSecondTQuad", LSecondTriplet, PQuadChamber, false, 0);
1279 
1280  solidSecondQuad = new G4Tubs("SolidSQuad", InnerRadiusQuad, ExternalRadiusQuad, SecondQuadThickness/2.,
1281  startAngleQuad, spanningAngleQuad);
1282 
1283  logicSecondQuad = new G4LogicalVolume(solidSecondQuad, QuadMaterial, "LogicSQuad", 0, 0, 0);
1284 
1285  physicSecondQuad = new G4PVPlacement(0, G4ThreeVector(SecondQXPosition, QYPosition, QZPosition),
1286  "PhysSecondQuad", logicSecondQuad, PSecondTriplet, false, 0);
1287 
1288  LSecondTriplet -> SetVisAttributes(yellow);
1289  logicSecondQuad -> SetVisAttributes(green);
1291  SFirstTriplet = new G4Tubs("SolidTQuad", InnerRadiusTriplet, ExternalRadiusQuad, (FirstQuadThickness/2.)+1*mm,
1292  startAngleQuad, spanningAngleQuad);
1293 
1294  LFirstTriplet = new G4LogicalVolume(SFirstTriplet, internalChamberMaterial,"LogicTQuad", 0, 0, 0);
1295 
1296  PFirstTriplet = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(FirstQuadXPosition, QuadYPosition, QuadZPosition)),
1297  "PhysFirstTQuad", LFirstTriplet, PQuadChamber, false, 0);
1298 
1299  solidFirstQuad = new G4Tubs("SolidQuad", InnerRadiusQuad, ExternalRadiusQuad, FirstQuadThickness/2.,
1300  startAngleQuad, spanningAngleQuad);
1301 
1302  logicFirstQuad = new G4LogicalVolume(solidFirstQuad, QuadMaterial, "LogicQuad", 0, 0, 0);
1303 
1304  physicFirstQuad = new G4PVPlacement(0, G4ThreeVector(FirstQXPosition, QYPosition, QZPosition),
1305  "PhysFirstQuad",logicFirstQuad, PFirstTriplet, false, 0);
1306 
1307  LFirstTriplet -> SetVisAttributes(yellow);
1308  logicFirstQuad -> SetVisAttributes(green);
1309 }
1310 
1312 void LaserDrivenBeamLine::EnergySelectorChamber()
1313 {
1314  // The whole energyselector is mounted inside a
1315  // a vacuum chamber (called 'ExternalChamber')
1316  // inside which a vacuum box is inserted.
1317 
1318  solidExternalChamber = new G4Box("ExternalChamber",
1319  externalChamberXSize/2.0,
1320  externalChamberYSize/2.0,
1321  externalChamberZSize/2.0);
1322 
1323  logicExternalChamber = new G4LogicalVolume(solidExternalChamber,
1324  externalChamberMaterial,
1325  "ExternalChamber");
1326 
1327  physicExternalChamber = new G4PVPlacement(0,
1328  G4ThreeVector(externalChamberXPosition,
1329  externalChamberYPosition,
1330  externalChamberZPosition),
1331  "ExternalChamber",
1332  logicExternalChamber,
1333  physicTreatmentRoom,
1334  false,
1335  0);
1336 
1337  // Visualisation of the External part
1338  logicExternalChamber -> SetVisAttributes(red);
1339 
1340  // This is a vacuum box inside the steel box
1341  solidInternalChamber = new G4Box("SInternalChamber",
1342  internalChamberXSize/2.0,
1343  internalChamberYSize/2.0,
1344  internalChamberZSize/2.0);
1345 
1346  logicInternalChamber = new G4LogicalVolume(solidInternalChamber,
1347  internalChamberMaterial,
1348  "LInternalChamber");
1349 
1350  physicInternalChamber = new G4PVPlacement(0,
1351  G4ThreeVector(0,0,0),
1352  "InternalChamber",
1353  logicInternalChamber,
1354  physicExternalChamber,
1355  false,
1356  0);
1357  logicInternalChamber -> SetVisAttributes(white);
1358 }
1359 
1361 void LaserDrivenBeamLine::EntrancePipe()
1362 {
1363  // To rotate the EntrancePipe putting its axis (along X direction) parallel to the beam axis
1364  G4double phi = 90. *deg;
1365  G4RotationMatrix rm;
1366  rm.rotateY(phi);
1367 
1368  solidEntrancePipe = new G4Tubs("EntrancePipe",
1369  InnerRadiusEntrancePipe,
1370  ExternalRadiusEntrancePipe,
1371  EntrancePipeheight/2.,
1372  startAngleEntrancePipe,
1373  spanningAngleEntrancePipe);
1374 
1375  logicEntrancePipe = new G4LogicalVolume(solidEntrancePipe,
1376  PipeMaterial,
1377  "EntrancePipe",
1378  0,
1379  0,
1380  0);
1381 
1382  physicEntrancePipe = new G4PVPlacement(G4Transform3D(rm,
1383  G4ThreeVector(EntrancePipeXPosition,
1384  EntrancePipeYPosition,
1385  EntrancePipeZPosition)),
1386  "EntrancePipe",
1387  logicEntrancePipe,
1388  physicTreatmentRoom,
1389  false,
1390  0);
1391 
1392  logicEntrancePipe -> SetVisAttributes(red);
1393 
1394 }
1395 
1397 void LaserDrivenBeamLine::Entrancehole()
1398 {
1399  // To rotate the ExitPipe putting its axis (along X direction) parallel to the beam axis
1400  G4double phi = 90. *deg;
1401  G4RotationMatrix rm;
1402  rm.rotateY(phi);
1403 
1404  solidEntrancehole = new G4Tubs("Entrancehole",
1405  InnerRadiusEntrancehole,
1406  ExternalRadiusEntrancehole,
1407  EntranceholeThickness/2.,
1408  startAngleEntrancehole,
1409  spanningAngleEntrancehole);
1410 
1411  logicEntrancehole = new G4LogicalVolume(solidEntrancehole,
1412  internalChamberMaterial,
1413  "Entrancehole",
1414  0,
1415  0,
1416  0);
1417  //the hole in the energy selector chamber
1418  physicEntranceholeESSChamber = new G4PVPlacement(G4Transform3D(rm,
1419  G4ThreeVector(EntranceholeXPosition,
1420  EntranceholeYPosition,
1421  EntranceholeZPosition)),
1422  "Entrancehole",
1423  logicEntrancehole,
1424  physicExternalChamber,
1425  false,
1426  0);
1427  //the hole in the quadrupoles chamber
1428  physicEntrancehole = new G4PVPlacement(G4Transform3D(rm,
1429  G4ThreeVector(EntranceholeQuadXPosition,
1430  EntranceholeYPosition,
1431  EntranceholeZPosition)),
1432  "EntranceholeQuad",
1433  logicEntrancehole,
1434  PQuadChamberWall,
1435  false,
1436  0);
1437 
1438  logicEntrancehole -> SetVisAttributes(skyBlue);
1439 
1440 
1441 }
1443 void LaserDrivenBeamLine::Collimator()
1444 {
1445  // To rotate the collimator putting its axis (along X direction) parallel to the beam axis
1446  G4double phi = 90. *deg;
1447  G4RotationMatrix rm;
1448  rm.rotateY(phi);
1449  //8x82x210 mm are the collimator default dimensions
1450  solidCollimator = new G4Box("collimator",
1451  thicknessCollimator/2.0,
1452  collimatorBoxYSize/2.0,
1453  collimatorBoxZSize/2.0);
1454 
1455  logicCollimator = new G4LogicalVolume(solidCollimator,
1456  collimatorMaterial,
1457  "collimator");
1458 
1459  physicCollimator = new G4PVPlacement(0,
1460  G4ThreeVector(collimatorBox_XPosition,
1461  collimatorBox_YPosition,
1462  collimatorBox_ZPosition),
1463  "collimator",
1464  logicCollimator,
1465  physicInternalChamber,
1466  false,
1467  0);
1468 
1469  logicCollimator -> SetVisAttributes(darkOrange3);
1470 
1471  solidCollimatorHole = new G4Tubs("CollimatorHole",
1472  innerRadiusCollimator,
1473  outerRadiusCollimator,
1474  thicknessCollimator/2.,
1475  startAngleCollimator,
1476  spanningAngleCollimator);
1477 
1478  logicCollimatorHole = new G4LogicalVolume(solidCollimatorHole,
1479  collimatorHoleMaterial,
1480  "CollimatorHole",
1481  0,
1482  0,
1483  0);
1484 
1485  physicCollimatorHole = new G4PVPlacement(G4Transform3D(rm,
1486  G4ThreeVector(collimatorXPosition,
1487  collimatorYPosition,
1488  collimatorZPosition)),
1489  "CollimatorHole",
1490  logicCollimatorHole,
1491  physicCollimator,
1492  false,
1493  0);
1494 
1495  logicCollimatorHole -> SetVisAttributes(skyBlue);
1496 }
1497 
1499 // Magnet number 1
1500 void LaserDrivenBeamLine::Magnet_1()
1501 { // The positions of the external and internal partes are given as respect the external chamber.
1502  solidExternalMagnet_1 = new G4Box("SolidExternalMagnet_1",
1503  externalMagnet_1XSize/2.0,
1504  externalMagnet_1YSize/2.0,
1505  externalMagnet_1ZSize/2.0);
1506 
1507  logicExternalMagnet_1 = new G4LogicalVolume(solidExternalMagnet_1,
1508  externalMagnet_1Material,
1509  "LogicExternalMagnet_1");
1510 
1511  physicExternalMagnet_1 = new G4PVPlacement(0,
1512  G4ThreeVector(externalMagnet_1XPosition,
1513  externalMagnet_2YPosition,
1514  externalMagnet_2ZPosition),
1515  "PhysicExternalMagnet_1",
1516  logicExternalMagnet_1,
1517  physicInternalChamber,
1518  false,
1519  0);
1520  physicExternalMagnet_1Down = new G4PVPlacement(0,
1521  G4ThreeVector(externalMagnet_1XPosition,
1522  -externalMagnet_2YPosition,
1523  externalMagnet_2ZPosition),
1524  "PhysicExternalMagnet_1Down",
1525  logicExternalMagnet_1,
1526  physicInternalChamber,
1527  false,
1528  0);
1529 
1530 
1531  logicExternalMagnet_1 -> SetVisAttributes(gray);
1532 
1533  // The right and left part of the magnet
1534  solidMagnet_1 = new G4Box("SolidMagnet_1",
1535  Magnet_1XSize/2.0,
1536  Magnet_1YSize/2.0,
1537  Magnet_1ZSize/2.0);
1538 
1539  logicMagnet_1 = new G4LogicalVolume(solidMagnet_1,
1540  externalMagnet_1Material,
1541  "LogicMagnet_1");
1542 
1543  physicMagnet_1Right = new G4PVPlacement(0,
1544  G4ThreeVector(Magnet_1XPosition,Magnet_1YPosition,
1545  Magnet_1ZPosition),
1546  "PhysicMagnet_1Right",
1547  logicMagnet_1,
1548  physicInternalChamber,
1549  false,
1550  0);
1551  physicMagnet_1Left = new G4PVPlacement(0,
1552  G4ThreeVector(Magnet_1XPosition,Magnet_1YPosition,
1553  -Magnet_1ZPosition),
1554  "PhysicMagnet_1Left",
1555  logicMagnet_1,
1556  physicInternalChamber,
1557  false,
1558  0);
1559 
1560  logicMagnet_1 -> SetVisAttributes(gray);
1561 }
1562 
1564 // Magnet number 2
1565 void LaserDrivenBeamLine::Magnet_2()
1566 { // The position of the external part are given as respect the external chamber.
1567 
1568  solidExternalMagnet_2 = new G4Box("SolidExternalMagnet_2",
1569  externalMagnet_2XSize/2.0,
1570  externalMagnet_2YSize/2.0,
1571  externalMagnet_2ZSize/2.0);
1572 
1573  logicExternalMagnet_2 = new G4LogicalVolume(solidExternalMagnet_2,
1574  externalMagnet_2Material,
1575  "LogicExternalMagnet_2");
1576 
1577  physicExternalMagnet_2 = new G4PVPlacement(0,
1578  G4ThreeVector(externalMagnet_2XPosition,
1579  externalMagnet_2YPosition,
1580  (externalMagnet_2ZPosition+32*mm)),
1581  "PhysicExternalMagnet_2",
1582  logicExternalMagnet_2,
1583  physicInternalChamber,
1584  false,
1585  0);
1586 
1587  physicExternalMagnet_2Down = new G4PVPlacement(0,
1588  G4ThreeVector(externalMagnet_2XPosition,
1589  -externalMagnet_2YPosition,
1590  (externalMagnet_2ZPosition+32*mm)),
1591  "PhysicExternalMagnet_2Down",
1592  logicExternalMagnet_2,
1593  physicInternalChamber,
1594  false,
1595  0);
1596 
1597 
1598  logicExternalMagnet_2 -> SetVisAttributes(gray);
1599 
1600  // The right and left part of the magnet
1601  solidMagnet_2 = new G4Box("SolidMagnet_2",
1602  Magnet_2XSize/2.0,
1603  Magnet_2YSize/2.0,
1604  Magnet_2ZSize/2.0);
1605 
1606  logicMagnet_2 = new G4LogicalVolume(solidMagnet_2,
1607  externalMagnet_2Material,
1608  "LogicMagnet_2");
1609 
1610  physicMagnet_2Right = new G4PVPlacement(0,
1611  G4ThreeVector(Magnet_2XPosition,Magnet_2YPosition,
1612  (Magnet_2ZPosition)+32*mm),
1613  "PhysicMagnet_2Right",
1614  logicMagnet_2,
1615  physicInternalChamber,
1616  false,
1617  0);
1618  physicMagnet_2Left = new G4PVPlacement(0,
1619  G4ThreeVector(Magnet_2XPosition,Magnet_2YPosition,
1620  (-(Magnet_2ZPosition)+32*mm)),
1621  "PhysicMagnet_2Left",
1622  logicMagnet_2,
1623  physicInternalChamber,
1624  false,
1625  0);
1626  logicMagnet_2 -> SetVisAttributes(gray);
1627 }
1628 
1630 // Magnet number 3
1631 void LaserDrivenBeamLine::Magnet_3()
1632 { // The position of the external part are given as respect the external chamber.
1633 
1634  solidExternalMagnet_3 = new G4Box("SolidExternalMagnet_3",
1635  externalMagnet_3XSize/2.0,
1636  externalMagnet_3YSize/2.0,
1637  externalMagnet_3ZSize/2.0);
1638 
1639  logicExternalMagnet_3 = new G4LogicalVolume(solidExternalMagnet_3,
1640  externalMagnet_3Material,
1641  "LogicExternalMagnet_3");
1642 
1643  physicExternalMagnet_3 = new G4PVPlacement(0,
1644  G4ThreeVector((externalMagnet_3XPosition),
1645  externalMagnet_3YPosition,
1646  (externalMagnet_3ZPosition+32*mm)),
1647  "PhysicExternalMagnet_3",
1648  logicExternalMagnet_3,
1649  physicInternalChamber,
1650  false,
1651  0);
1652 
1653  physicExternalMagnet_3Down = new G4PVPlacement(0,
1654  G4ThreeVector((externalMagnet_3XPosition),
1655  -externalMagnet_3YPosition,
1656  (externalMagnet_3ZPosition+32*mm)),
1657  "PhysicExternalMagnet_3Down",
1658  logicExternalMagnet_3,
1659  physicInternalChamber,
1660  false,
1661  0);
1662 
1663  logicExternalMagnet_3 -> SetVisAttributes(gray);
1664 
1665  // The right and left part of the magnet
1666  solidMagnet_3 = new G4Box("SolidMagnet_3",
1667  Magnet_3XSize/2.0,
1668  Magnet_3YSize/2.0,
1669  Magnet_3ZSize/2.0);
1670 
1671  logicMagnet_3 = new G4LogicalVolume(solidMagnet_3,
1672  externalMagnet_3Material,
1673  "LogicMagnet_3");
1674 
1675  physicMagnet_3Right = new G4PVPlacement(0,
1676  G4ThreeVector(Magnet_3XPosition,Magnet_3YPosition,
1677  (Magnet_3ZPosition+32*mm)),
1678  "PhysicMagnet_3Right",
1679  logicMagnet_3,
1680  physicInternalChamber,
1681  false,
1682  0);
1683  physicMagnet_3Left = new G4PVPlacement(0,
1684  G4ThreeVector(Magnet_3XPosition,Magnet_3YPosition,
1685  (-(Magnet_3ZPosition)+32*mm)),
1686  "PhysicMagnet_3Left",
1687  logicMagnet_3,
1688  physicInternalChamber,
1689  false,
1690  0);
1691  logicMagnet_3 -> SetVisAttributes(gray);
1692 
1693 }
1694 
1696 // Magnet number 4
1697 void LaserDrivenBeamLine::Magnet_4()
1698 { // The position of the external part are given as respect the external chamber.
1699 
1700  solidExternalMagnet_4 = new G4Box("SolidExternalMagnet_4",
1701  externalMagnet_4XSize/2.0,
1702  externalMagnet_4YSize/2.0,
1703  externalMagnet_4ZSize/2.0);
1704 
1705  logicExternalMagnet_4 = new G4LogicalVolume(solidExternalMagnet_4,
1706  externalMagnet_4Material,
1707  "LogicExternalMagnet_4");
1708 
1709  physicExternalMagnet_4 = new G4PVPlacement(0,
1710  G4ThreeVector(externalMagnet_4XPosition,
1711  externalMagnet_4YPosition,
1712  externalMagnet_4ZPosition),
1713  "PhysicExternalMagnet_4",
1714  logicExternalMagnet_4,
1715  physicInternalChamber,
1716  false,
1717  0);
1718 
1719  physicExternalMagnet_4Down = new G4PVPlacement(0,
1720  G4ThreeVector(externalMagnet_4XPosition,
1721  -externalMagnet_4YPosition,
1722  externalMagnet_4ZPosition),
1723  "PhysicExternalMagnet_4Down",
1724  logicExternalMagnet_4,
1725  physicInternalChamber,
1726  false,
1727  0);
1728 
1729  logicExternalMagnet_4 -> SetVisAttributes(gray);
1730 
1731  // The right and left part of the magnet
1732  solidMagnet_4 = new G4Box("SolidMagnet_4",
1733  Magnet_4XSize/2.0,
1734  Magnet_4YSize/2.0,
1735  Magnet_4ZSize/2.0);
1736 
1737  logicMagnet_4 = new G4LogicalVolume(solidMagnet_4,
1738  externalMagnet_4Material,
1739  "LogicMagnet_4");
1740 
1741  physicMagnet_4Right = new G4PVPlacement(0,
1742  G4ThreeVector(Magnet_4XPosition,Magnet_4YPosition,
1743  Magnet_4ZPosition),
1744  "PhysicMagnet_4Right",
1745  logicMagnet_4,
1746  physicInternalChamber,
1747  false,
1748  0);
1749  physicMagnet_4Left = new G4PVPlacement(0,
1750  G4ThreeVector(Magnet_4XPosition,Magnet_4YPosition,
1751  -Magnet_4ZPosition),
1752  "PhysicMagnet_4Left",
1753  logicMagnet_4,
1754  physicInternalChamber,
1755  false,
1756  0);
1757  logicMagnet_4 -> SetVisAttributes(gray);
1758 }
1759 
1761 // Slit
1762 void LaserDrivenBeamLine::Slit()
1763 {
1764  solidExternalSlit = new G4Box("ExternalSlit",
1765  externalSlitXSize/2.0,
1766  externalSlitYSize/2.0,
1767  externalSlitZSize/2.0);
1768 
1769  logicExternalSlit = new G4LogicalVolume(solidExternalSlit,
1770  externalSlitMaterial,
1771  "ExternalSlit");
1772 
1773  physicExternalSlit = new G4PVPlacement(0,
1774  G4ThreeVector(externalSlitXPosition,
1775  externalSlitYPosition,
1776  externalSlitZPosition),
1777  "ExternalSlit",
1778  logicExternalSlit,
1779  physicInternalChamber,
1780  false,
1781  0);
1782 
1783  logicExternalSlit -> SetVisAttributes(green);
1784  // The hole
1785  solidInternalSlit = new G4Box("InternalSlit",
1786  internalSlitXSize/2.0,
1787  internalSlitYSize/2.0,
1788  internalSlitZSize/2.0);
1789 
1790  logicInternalSlit = new G4LogicalVolume(solidInternalSlit,
1791  internalSlitMaterial,
1792  "InternalSlit");
1793 
1794  physicInternalSlit = new G4PVPlacement(0,
1795  G4ThreeVector(internalSlitXPosition,
1796  internalSlitYPosition,
1797  internalSlitZPosition),
1798  "InternalSlit",
1799  logicInternalSlit,
1800  physicExternalSlit,
1801  false,
1802  0);
1803 
1804  logicInternalSlit -> SetVisAttributes(skyBlue);
1805 
1806 }
1808 void LaserDrivenBeamLine::FinalCollimator()
1809 {
1810  // To rotate the collimator putting its axis (along X direction) parallel to the beam axis
1811  G4double phi = 90. *deg;
1812  G4RotationMatrix rm;
1813  rm.rotateY(phi);
1814 
1815  solidFinalCollimator = new G4Box("collimatorFinal",
1816  collimatorFinalBoxXSize/2.0,
1817  collimatorFinalBoxYSize/2.0,
1818  collimatorFinalBoxZSize/2.0);
1819 
1820  logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator,
1821  FinalcollimatorMaterial,
1822  "collimatorFinal");
1823 
1824  physicFinalCollimator = new G4PVPlacement(0,
1825  G4ThreeVector(collimatorFinalBox_XPosition,
1826  collimatorFinalBox_YPosition,
1827  collimatorFinalBox_ZPosition),
1828  "collimatorFinal",
1829  logicFinalCollimator,
1830  physicInternalChamber,
1831  false,
1832  0);
1833  logicFinalCollimator -> SetVisAttributes(darkOrange3);
1834 
1835  solidFinalCollimatorHole= new G4Tubs("FinalCollimatorHole",
1836  innerRadiusFinalCollimator,
1837  outerRadiusFinalCollimator,
1838  FinalCollimatorThickness/2.,
1839  startAngleFinalCollimator,
1840  spanningAngleFinalCollimator);
1841 
1842  logicFinalCollimatorHole = new G4LogicalVolume(solidFinalCollimatorHole,
1843  FinalcollimatorHoleMaterial,
1844  "FinalCollimatorHole",
1845  0,
1846  0,
1847  0);
1848 
1849  physicFinalCollimatorHole = new G4PVPlacement(G4Transform3D(rm,
1850  G4ThreeVector(FinalcollimatorXPosition,
1851  FinalcollimatorYPosition,
1852  FinalcollimatorZPosition)),
1853  "FinalCollimatorHole",
1854  logicFinalCollimatorHole,
1855  physicFinalCollimator,
1856  false,
1857  0);
1858  logicFinalCollimatorHole -> SetVisAttributes(skyBlue);
1859 }
1861 void LaserDrivenBeamLine::ExitWindow()
1862 {
1863  // To rotate the ExitWindow putting its axis (along X direction) parallel to the beam axis
1864  G4double phi = 90. *deg;
1865  G4RotationMatrix rm;
1866  rm.rotateY(phi);
1867 
1868  solidExitWindow = new G4Tubs("ExitWindow",
1869  InnerRadiusExitWindow,
1870  ExternalRadiusExitWindow,
1871  ExitWindowThickness/2.,
1872  startAngleExitWindow,
1873  spanningAngleExitWindow);
1874 
1875  logicExitWindow = new G4LogicalVolume(solidExitWindow,
1876  WindowMaterial,
1877  "ExitWindow",
1878  0,
1879  0,
1880  0);
1881 
1882  physicExitWindow = new G4PVPlacement(G4Transform3D(rm,
1883  G4ThreeVector(ExitWindowXPosition,
1884  ExitWindowYPosition,
1885  ExitWindowZPosition)),
1886  "ExitWindow",
1887  logicExitWindow,
1888  physicTreatmentRoom,
1889  false,
1890  0);
1891 
1892  logicExitWindow -> SetVisAttributes(skyBlue);
1893 
1894 }
1895 
1897 void LaserDrivenBeamLine::ExitPipe()
1898 {
1899  // To rotate the ExitPipe putting its axis (along X direction) parallel to the beam axis
1900  G4double phi = 90. *deg;
1901  G4RotationMatrix rm;
1902  rm.rotateY(phi);
1903 
1904  solidExitPipe = new G4Tubs("ExitPipe",
1905  InnerRadiusExitPipe,
1906  ExternalRadiusExitPipe,
1907  ExitPipeheight/2.,
1908  startAngleExitPipe,
1909  spanningAngleExitPipe);
1910 
1911  logicExitPipe = new G4LogicalVolume(solidExitPipe,
1912  PipeMaterial,
1913  "ExitPipe",
1914  0,
1915  0,
1916  0);
1917 
1918  physicExitPipe = new G4PVPlacement(G4Transform3D(rm,
1919  G4ThreeVector(ExitPipeXPosition,
1920  ExitPipeYPosition,
1921  ExitPipeZPosition)),
1922  "ExitPipe",
1923  logicExitPipe,
1924  physicTreatmentRoom,
1925  false,
1926  0);
1927 
1928  logicExitPipe -> SetVisAttributes(red);
1929 
1930 }
1931 
1933 void LaserDrivenBeamLine::Exithole()
1934 {
1935  // To rotate the ExitPipe putting its axis (along X direction) parallel to the beam axis
1936  G4double phi = 90. *deg;
1937  G4RotationMatrix rm;
1938  rm.rotateY(phi);
1939 
1940  solidExithole = new G4Tubs("Exithole",
1941  InnerRadiusExithole,
1942  ExternalRadiusExithole,
1943  ExitholeThickness/2.,
1944  startAngleExithole,
1945  spanningAngleExithole);
1946 
1947  logicExithole = new G4LogicalVolume(solidExithole,
1948  internalChamberMaterial,
1949  "Exithole",
1950  0,
1951  0,
1952  0);
1953 
1954  physicExithole = new G4PVPlacement(G4Transform3D(rm,
1955  G4ThreeVector(ExitholeXPosition,
1956  ExitholeYPosition,
1957  ExitholeZPosition)),
1958  "Exithole",
1959  logicExithole,
1960  physicExternalChamber,
1961  false,
1962  0);
1963 
1964  logicExithole -> SetVisAttributes(skyBlue);
1965 
1966 }
1969 // Disable via external macro command the Energy Selector System
1971 {
1972  if(physicMagnet_1Left) {delete physicMagnet_1Left; delete physicMagnet_1Right; delete logicMagnet_1; delete solidMagnet_1;}
1973  if(physicExternalMagnet_1Down){delete physicExternalMagnet_1Down; delete physicExternalMagnet_1; delete logicExternalMagnet_1; delete solidExternalMagnet_1;}
1974  if(physicMagnet_2Left){delete physicMagnet_2Left; delete physicMagnet_2Right; delete logicMagnet_2; delete solidMagnet_2;}
1975  if(physicExternalMagnet_2Down){ delete physicExternalMagnet_2Down; delete physicExternalMagnet_2; delete logicExternalMagnet_2; delete solidExternalMagnet_2; }
1976  if(physicMagnet_3Left){delete physicMagnet_3Left; delete physicMagnet_3Right; delete logicMagnet_3; delete solidMagnet_3; }
1977  if(physicExternalMagnet_3Down){delete physicExternalMagnet_3Down; delete physicExternalMagnet_3; delete logicExternalMagnet_3; delete solidExternalMagnet_3; }
1978  if(physicMagnet_4Left) {delete physicMagnet_4Left; delete physicMagnet_4Right; delete logicMagnet_4; delete solidMagnet_4; }
1979  if(physicExternalMagnet_4Down){delete physicExternalMagnet_4Down; delete physicExternalMagnet_4; delete logicExternalMagnet_4; delete solidExternalMagnet_4; }
1980  if(physicCollimatorHole){delete physicCollimatorHole; delete logicCollimatorHole; delete solidCollimatorHole; }
1981  if(physicCollimator) {delete physicCollimator; delete logicCollimator; delete solidCollimator; }
1982  if(physicFinalCollimatorHole) {delete physicFinalCollimatorHole; delete logicFinalCollimatorHole; delete solidFinalCollimatorHole; }
1983  if(physicFinalCollimator){delete physicFinalCollimator; delete logicFinalCollimator; delete solidFinalCollimator; }
1984  if(physicInternalSlit){ delete physicInternalSlit; delete logicInternalSlit; delete solidInternalSlit; }
1985  if(physicExternalSlit){delete physicExternalSlit; delete logicExternalSlit; delete solidExternalSlit; }
1986  if(physicExithole){delete physicExithole; delete logicExithole; delete solidExithole;}
1987  if(physicExitWindow){delete physicExitWindow; delete logicExitWindow; delete solidExitWindow;}
1988  if(physicExitPipe){delete physicExitPipe; delete logicExitPipe; delete solidExitPipe;}
1989  if(physicEntranceholeESSChamber){delete physicEntranceholeESSChamber;}
1990  if(physicInternalChamber){delete physicInternalChamber; delete logicInternalChamber; delete solidInternalChamber;}
1991  if(physicExternalChamber) {delete physicExternalChamber; delete logicExternalChamber; delete solidExternalChamber;}
1992  if(pFieldMgr) {delete pFieldMgr;}
1993 
1994 
1995 
1996  G4cout << "****************************************************" << G4endl;
1997  G4cout << "************ The ESS has been disabled *************" << G4endl;
1998  G4cout << "****************************************************" << G4endl;
2000  #ifdef G4VIS_USE
2001  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2002  #endif
2003 }
2004 // Change via external macro command the diameter of the first collimator
2006 {
2007  G4double radius = valueR;
2008  solidCollimatorHole -> SetOuterRadius(radius);
2010  #ifdef G4VIS_USE
2011  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2012  #endif
2013  G4cout << "The first collimator aperture has been modified to "<< valueR/mm <<"mm in diameter" << G4endl;
2014 }
2016 // Change via external macro command the thickness of the first collimator
2018 {
2019  G4double thickness = valueC/2;
2020  solidCollimator -> SetXHalfLength(thickness);
2021  solidCollimatorHole -> SetZHalfLength(thickness);
2023  #ifdef G4VIS_USE
2024  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2025  #endif
2026  G4cout << "The first collimator thickness has been modified to "<< valueC/mm <<" mm in thickness" << G4endl;
2027 }
2028 
2029 // Change via external macro command the Z position of the first collimator hole
2031 {
2032  physicCollimatorHole -> SetTranslation(G4ThreeVector(0., 0., valueQ));
2034  #ifdef G4VIS_USE
2035  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2036  #endif
2037  G4cout << "The first collimator has been translated to "<< valueQ/mm <<"mm (along the z axis)" << G4endl;
2038 }
2039 
2040 // Change via external macro command the diameter of the second collimator
2042 {
2043  G4double radius = value;
2044  solidFinalCollimatorHole -> SetOuterRadius(radius);
2046  #ifdef G4VIS_USE
2047  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2048  #endif
2049  G4cout << "The second collimator aperture has been modified to "<< value/mm <<"mm in diameter" << G4endl;
2050 }
2051 
2053 // Change via external macro command the thickness of the second collimator
2055 {
2056  G4double thickness = value/2;
2057  solidFinalCollimator -> SetXHalfLength(thickness);
2058  solidFinalCollimatorHole -> SetZHalfLength(thickness);
2060  #ifdef G4VIS_USE
2061  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2062  #endif
2063  G4cout << "The second collimator thickness has been modified to "<< value/mm <<" mm in thickness" << G4endl;
2064 }
2065 
2066 // Change via external macro command the Z position of the second collimator hole
2068 {
2069  physicFinalCollimatorHole -> SetTranslation(G4ThreeVector(0., 0., value));
2071  #ifdef G4VIS_USE
2072  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2073  #endif
2074  G4cout << "The second collimator has been translated to "<< value/mm <<"mm (along the z axis)" << G4endl;
2075 }
2076 // THE SLIT MESSENGERS
2078 // Change the thickness of the Slit
2080 {
2081  if (value >(10.0*mm)) {
2082  G4cout <<"***************************************"<< G4endl;
2083  G4cout <<"******This is a warning messenger******"<< G4endl;
2084  G4cout <<"***************************************"<< G4endl;
2085  G4cout <<"The maximum value of the thickness of the slit is 10 mm, your value is >10 mm." << G4endl;
2086  G4cout <<"The default thickness value is used, it is: " << ((solidExternalSlit -> GetXHalfLength())*2.)/mm
2087  << G4endl;
2088  G4cout <<"***************************************"<< G4endl;
2089 
2090  }
2091  else {
2092  G4double dimension = value/2;
2093  solidExternalSlit -> SetXHalfLength(dimension);
2094  solidInternalSlit -> SetXHalfLength(dimension);
2096  #ifdef G4VIS_USE
2097  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2098  #endif
2099  G4cout <<"The thickness of the slit is:" << ((solidExternalSlit -> GetXHalfLength())*2.)/mm
2100  << G4endl;
2101  }
2102 }
2104 // Change the hole size (in Y direction) of the Slit
2106 {
2107  G4double hole = value/2;
2108  solidInternalSlit -> SetYHalfLength(hole);
2110  #ifdef G4VIS_USE
2111  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2112  #endif
2113  G4cout << "The hole of the Slit has been changed in the Y direction to "<< value/mm <<" mm" <<G4endl;
2114 }
2115 
2117 // Change the hole size (in Z direction) of the Slit
2119 {
2120  G4double hole = value/2;
2121  solidInternalSlit -> SetZHalfLength(hole);
2123  #ifdef G4VIS_USE
2124  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2125  #endif
2126  G4cout << "The hole of the Slit has been changed in the Z direction to "<< value/mm <<" mm" <<G4endl;
2127 }
2129 // Change the Z position of the hole of the Slit
2131 {
2132  physicInternalSlit -> SetTranslation(G4ThreeVector(0., 0., value));
2134  #ifdef G4VIS_USE
2135  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2136  #endif
2137  G4cout << "The hole of the slit has been translated to "<< value/mm <<" mm (along the Z axis)" <<G4endl;
2138 }
2139 
2140 // QUADRUPOLES
2141 
2142 // Disable via external macro command all quadrupoles
2144 {
2145  if(physicFirstQuad)
2146  {delete solidFirstQuad; delete logicFirstQuad; delete physicFirstQuad;delete SFirstTriplet; delete LFirstTriplet; delete PFirstTriplet;}
2147  if(physicSecondQuad)
2148  {delete solidSecondQuad; delete logicSecondQuad; delete physicSecondQuad;delete SSecondTriplet; delete LSecondTriplet; delete PSecondTriplet;}
2149  if(physicThirdQuad)
2150 {delete solidThirdQuad; delete logicThirdQuad; delete physicThirdQuad;delete SThirdTriplet; delete LThirdTriplet; delete PThirdTriplet;}
2151  if(physicFourthQuad)
2152  {delete solidFourthQuad; delete logicFourthQuad; delete physicFourthQuad;delete SFourthTriplet; delete LFourthTriplet; delete PFourthTriplet;}
2153  if(pFieldMgrQuadFourth) {delete pFieldMgrQuadFourth;}
2154  if(pFieldMgrQuadThird) {delete pFieldMgrQuadThird;}
2155  if(pFieldMgrQuadSecond) {delete pFieldMgrQuadSecond;}
2156  if(pFieldMgrQuadFirst) {delete pFieldMgrQuadFirst;}
2157 
2158 
2159  G4cout << "******************************************************************" << G4endl;
2160  G4cout << "************ The Quadrupoles system has been disabled *************" << G4endl;
2161  G4cout << "******************************************************************" << G4endl;
2163  #ifdef G4VIS_USE
2164  G4UImanager::GetUIpointer() -> ApplyCommand("/vis/viewer/flush");
2165  #endif
2166 }
2167 
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double mm
Definition: G4SIunits.hh:115
CLHEP::Hep3Vector G4ThreeVector
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
CLHEP::HepRotation G4RotationMatrix
void SetSecondCollimatorRadius(G4double value)
Definition: G4Box.hh:64
static constexpr double perCent
Definition: G4SIunits.hh:332
Definition: G4Tubs.hh:85
HepRotation & rotateY(double delta)
Definition: Rotation.cc:79
void SetSecondCollimatorThickness(G4double value)
void SetChordFinder(G4ChordFinder *aChordFinder)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
void RegisterParallelWorld(G4VUserParallelWorld *)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
void SetSlitHolePositionZ(G4double value)
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void SetMinimumEpsilonStep(G4double newEpsMin)
G4GLOB_DLL std::ostream G4cout
static constexpr double um
Definition: G4SIunits.hh:113
const XML_Char int const XML_Char * value
Definition: expat.h:331
void SetThicknessSlit(G4double value)
#define minEps
bool G4bool
Definition: G4Types.hh:79
static constexpr double cm
Definition: G4SIunits.hh:119
#define pascal
void SetSecondCollimatorPositionZ(G4double value)
HepGeom::Transform3D G4Transform3D
void SetSlitHoleDimensionZ(G4double value)
static constexpr double kelvin
Definition: G4SIunits.hh:281
void SetFirstCollimatorPositionZ(G4double value)
G4VPhysicalVolume * Construct()
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetSlitHoleDimensionY(G4double value)
static const G4VisAttributes Invisible
void SetFirstCollimatorThickness(G4double value)
#define G4endl
Definition: G4ios.hh:61
void SetMaximumEpsilonStep(G4double newEpsMax)
static constexpr double pi
Definition: G4SIunits.hh:75
void InitializeDetectorROGeometry(HadrontherapyDetectorROGeometry *, G4ThreeVector detectorToWorldPosition)
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
void SetDeltaOneStep(G4double valueD1step)
static constexpr double mole
Definition: G4SIunits.hh:286
void SetVisAttributes(const G4VisAttributes *pVA)
void SetFirstCollimatorRadius(G4double value)