Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/hadrontherapy/src/LaserDrivenBeamLine.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/hadrontherapy/src/LaserDrivenBeamLine.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/LaserDrivenBeamLine.cc (Version 10.4.p2)


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