Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/hadrontherapy/src/PassiveProtonBeamLine.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/PassiveProtonBeamLine.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/PassiveProtonBeamLine.cc (Version 11.2.1)


  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 "G4VisAttributes.hh"                      33 #include "G4VisAttributes.hh"
 34 #include "G4Colour.hh"                             34 #include "G4Colour.hh"
 35 #include "G4RunManager.hh"                         35 #include "G4RunManager.hh"
 36 #include "G4LogicalVolume.hh"                      36 #include "G4LogicalVolume.hh"
 37 #include "G4PVPlacement.hh"                        37 #include "G4PVPlacement.hh"
 38 #include "G4RotationMatrix.hh"                     38 #include "G4RotationMatrix.hh"
 39 #include "G4NistManager.hh"                        39 #include "G4NistManager.hh"
 40 #include "G4NistElementBuilder.hh"                 40 #include "G4NistElementBuilder.hh"
 41 #include "HadrontherapyDetectorConstruction.hh     41 #include "HadrontherapyDetectorConstruction.hh"
 42 #include "HadrontherapyModulator.hh"               42 #include "HadrontherapyModulator.hh"
 43 #include "PassiveProtonBeamLine.hh"                43 #include "PassiveProtonBeamLine.hh"
 44 #include "PassiveProtonBeamLineMessenger.hh"       44 #include "PassiveProtonBeamLineMessenger.hh"
 45                                                    45 
 46                                                    46 
 47 //G4bool PassiveProtonBeamLine::doCalculation      47 //G4bool PassiveProtonBeamLine::doCalculation = false;
 48 //////////////////////////////////////////////     48 /////////////////////////////////////////////////////////////////////////////
 49 PassiveProtonBeamLine::PassiveProtonBeamLine()     49 PassiveProtonBeamLine::PassiveProtonBeamLine():
 50 modulator(0), physicalTreatmentRoom(0),hadront     50 modulator(0), physicalTreatmentRoom(0),hadrontherapyDetectorConstruction(0),
 51 physiBeamLineSupport(0), physiBeamLineCover(0)     51 physiBeamLineSupport(0), physiBeamLineCover(0), physiBeamLineCover2(0),
 52 firstScatteringFoil(0), physiFirstScatteringFo     52 firstScatteringFoil(0), physiFirstScatteringFoil(0), physiKaptonWindow(0),
 53 solidStopper(0), physiStopper(0), secondScatte     53 solidStopper(0), physiStopper(0), secondScatteringFoil(0), physiSecondScatteringFoil(0),
 54 physiFirstCollimator(0), solidRangeShifterBox(     54 physiFirstCollimator(0), solidRangeShifterBox(0), logicRangeShifterBox(0),
 55 physiRangeShifterBox(0), physiSecondCollimator     55 physiRangeShifterBox(0), physiSecondCollimator(0), physiFirstCollimatorModulatorBox(0),
 56 physiHoleFirstCollimatorModulatorBox(0), physi     56 physiHoleFirstCollimatorModulatorBox(0), physiSecondCollimatorModulatorBox(0),
 57 physiHoleSecondCollimatorModulatorBox(0), phys     57 physiHoleSecondCollimatorModulatorBox(0), physiMOPIMotherVolume(0),
 58 physiFirstMonitorLayer1(0), physiFirstMonitorL     58 physiFirstMonitorLayer1(0), physiFirstMonitorLayer2(0), physiFirstMonitorLayer3(0),
 59 physiFirstMonitorLayer4(0), physiSecondMonitor     59 physiFirstMonitorLayer4(0), physiSecondMonitorLayer1(0), physiSecondMonitorLayer2(0),
 60 physiSecondMonitorLayer3(0), physiSecondMonito     60 physiSecondMonitorLayer3(0), physiSecondMonitorLayer4(0), physiNozzleSupport(0), physiBrassTube(0), solidFinalCollimator(0), physiFinalCollimator(0)
 61 {                                                  61 {
 62     // Messenger to change parameters of the p     62     // Messenger to change parameters of the passiveProtonBeamLine geometry
 63     passiveMessenger = new PassiveProtonBeamLi     63     passiveMessenger = new PassiveProtonBeamLineMessenger(this);
 64                                                    64     
 65     //***************************** PW *******     65     //***************************** PW ***************************************
 66     static G4String ROGeometryName = "Detector     66     static G4String ROGeometryName = "DetectorROGeometry";
 67     RO = new HadrontherapyDetectorROGeometry(R     67     RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
 68                                                    68     
 69     G4cout << "Going to register Parallel worl     69     G4cout << "Going to register Parallel world...";
 70     RegisterParallelWorld(RO);                     70     RegisterParallelWorld(RO);
 71     G4cout << "... done" << G4endl;                71     G4cout << "... done" << G4endl;
 72                                                    72 
 73 }                                                  73 }
 74 //////////////////////////////////////////////     74 /////////////////////////////////////////////////////////////////////////////
 75 PassiveProtonBeamLine::~PassiveProtonBeamLine(     75 PassiveProtonBeamLine::~PassiveProtonBeamLine()
 76 {                                                  76 {
 77     delete passiveMessenger;                       77     delete passiveMessenger;
 78     delete hadrontherapyDetectorConstruction;      78     delete hadrontherapyDetectorConstruction;
 79                                                    79 
 80 }                                                  80 }
 81                                                    81 
 82 //////////////////////////////////////////////     82 /////////////////////////////////////////////////////////////////////////////
 83 G4VPhysicalVolume* PassiveProtonBeamLine::Cons     83 G4VPhysicalVolume* PassiveProtonBeamLine::Construct()
 84 {                                                  84 {
 85     // Sets default geometry and materials         85     // Sets default geometry and materials
 86     SetDefaultDimensions();                        86     SetDefaultDimensions();
 87                                                    87     
 88     // Construct the whole Passive Beam Line       88     // Construct the whole Passive Beam Line
 89     ConstructPassiveProtonBeamLine();              89     ConstructPassiveProtonBeamLine();
 90                                                    90     
 91     //***************************** PW *******     91     //***************************** PW ***************************************
 92     if (!hadrontherapyDetectorConstruction)        92     if (!hadrontherapyDetectorConstruction)
 93                                                    93         
 94         //***************************** PW ***     94         //***************************** PW ***************************************
 95                                                    95         
 96         // HadrontherapyDetectorConstruction b     96         // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
 97         hadrontherapyDetectorConstruction = ne     97         hadrontherapyDetectorConstruction = new HadrontherapyDetectorConstruction(physicalTreatmentRoom);
 98                                                    98     
 99                                                    99     
100     //***************************** PW *******    100     //***************************** PW ***************************************
101                                                   101     
102     hadrontherapyDetectorConstruction->Initial    102     hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
103                                                   103     
104     //***************************** PW *******    104     //***************************** PW ***************************************
105                                                   105 
106     return physicalTreatmentRoom;                 106     return physicalTreatmentRoom;
107 }                                                 107 }
108                                                   108 
109 // In the following method the DEFAULTS used i    109 // In the following method the DEFAULTS used in the geometry of
110 // passive beam line are provided                 110 // passive beam line are provided
111 // HERE THE USER CAN CHANGE THE GEOMETRY CHARA    111 // HERE THE USER CAN CHANGE THE GEOMETRY CHARACTERISTICS OF BEAM
112 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE    112 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE THE MACRO FILE (IF A
113 // MESSENGER IS PROVIDED)                         113 // MESSENGER IS PROVIDED)
114 //                                                114 //
115 // DEFAULT MATERIAL ARE ALSO PROVIDED             115 // DEFAULT MATERIAL ARE ALSO PROVIDED
116 // and COLOURS ARE ALSO DEFINED                   116 // and COLOURS ARE ALSO DEFINED
117 // -------------------------------------------    117 // ----------------------------------------------------------
118 //////////////////////////////////////////////    118 /////////////////////////////////////////////////////////////////////////////
119 void PassiveProtonBeamLine::SetDefaultDimensio    119 void PassiveProtonBeamLine::SetDefaultDimensions()
120 {                                                 120 {
121     // Set of coulors that can be used            121     // Set of coulors that can be used
122     white = new G4VisAttributes( G4Colour());     122     white = new G4VisAttributes( G4Colour());
123     white -> SetVisibility(true);                 123     white -> SetVisibility(true);
124     white -> SetForceSolid(true);                 124     white -> SetForceSolid(true);
125                                                   125   
126     blue = new G4VisAttributes(G4Colour(0. ,0.    126     blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
127     blue -> SetVisibility(true);                  127     blue -> SetVisibility(true);
128     blue -> SetForceSolid(true);                  128     blue -> SetForceSolid(true);
129                                                   129   
130     gray = new G4VisAttributes( G4Colour(0.5,     130     gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5 ));
131     gray-> SetVisibility(true);                   131     gray-> SetVisibility(true);
132     gray-> SetForceSolid(true);                   132     gray-> SetForceSolid(true);
133                                                   133   
134     red = new G4VisAttributes(G4Colour(1. ,0.     134     red = new G4VisAttributes(G4Colour(1. ,0. ,0.));
135     red-> SetVisibility(true);                    135     red-> SetVisibility(true);
136     red-> SetForceSolid(true);                    136     red-> SetForceSolid(true);
137                                                   137   
138     yellow = new G4VisAttributes(G4Colour(1.,     138     yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
139     yellow-> SetVisibility(true);                 139     yellow-> SetVisibility(true);
140     yellow-> SetForceSolid(true);                 140     yellow-> SetForceSolid(true);
141                                                   141   
142     green = new G4VisAttributes( G4Colour(25/2    142     green = new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
143     green -> SetVisibility(true);                 143     green -> SetVisibility(true);
144     green -> SetForceSolid(true);                 144     green -> SetForceSolid(true);
145                                                   145   
146     darkGreen = new G4VisAttributes( G4Colour(    146     darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. ,  0/255. ));
147     darkGreen -> SetVisibility(true);             147     darkGreen -> SetVisibility(true);
148     darkGreen -> SetForceSolid(true);             148     darkGreen -> SetForceSolid(true);
149                                                   149     
150     darkOrange3 = new G4VisAttributes( G4Colou    150     darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. ,  000/255. ));
151     darkOrange3 -> SetVisibility(true);           151     darkOrange3 -> SetVisibility(true);
152     darkOrange3 -> SetForceSolid(true);           152     darkOrange3 -> SetForceSolid(true);
153                                                   153   
154     skyBlue = new G4VisAttributes( G4Colour(13    154     skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. ,  235/255. ));
155     skyBlue -> SetVisibility(true);               155     skyBlue -> SetVisibility(true);
156     skyBlue -> SetForceSolid(true);               156     skyBlue -> SetForceSolid(true);
157                                                   157     
158                                                   158     
159     // VACUUM PIPE: first track of the beam li    159     // VACUUM PIPE: first track of the beam line is inside vacuum;
160     // The PIPE contains the FIRST SCATTERING     160     // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
161     G4double defaultVacuumZoneXSize = 100.0 *m    161     G4double defaultVacuumZoneXSize = 100.0 *mm;
162     vacuumZoneXSize = defaultVacuumZoneXSize;     162     vacuumZoneXSize = defaultVacuumZoneXSize;
163                                                   163     
164     G4double defaultVacuumZoneYSize = 52.5 *mm    164     G4double defaultVacuumZoneYSize = 52.5 *mm;
165     vacuumZoneYSize = defaultVacuumZoneYSize;     165     vacuumZoneYSize = defaultVacuumZoneYSize;
166                                                   166     
167     G4double defaultVacuumZoneZSize = 52.5 *mm    167     G4double defaultVacuumZoneZSize = 52.5 *mm;
168     vacuumZoneZSize = defaultVacuumZoneZSize;     168     vacuumZoneZSize = defaultVacuumZoneZSize;
169                                                   169     
170     G4double defaultVacuumZoneXPosition = -301    170     G4double defaultVacuumZoneXPosition = -3010.0 *mm;
171     vacuumZoneXPosition = defaultVacuumZoneXPo    171     vacuumZoneXPosition = defaultVacuumZoneXPosition;
172                                                   172     
173     // FIRST SCATTERING FOIL: a thin foil perf    173     // FIRST SCATTERING FOIL: a thin foil performing a first scattering
174     // of the original beam                       174     // of the original beam
175     G4double defaultFirstScatteringFoilXSize =    175     G4double defaultFirstScatteringFoilXSize = 0.0075 *mm;
176     firstScatteringFoilXSize = defaultFirstSca    176     firstScatteringFoilXSize = defaultFirstScatteringFoilXSize;
177                                                   177     
178     G4double defaultFirstScatteringFoilYSize =    178     G4double defaultFirstScatteringFoilYSize = 52.5   *mm;
179     firstScatteringFoilYSize = defaultFirstSca    179     firstScatteringFoilYSize = defaultFirstScatteringFoilYSize;
180                                                   180     
181     G4double defaultFirstScatteringFoilZSize =    181     G4double defaultFirstScatteringFoilZSize = 52.5   *mm;
182     firstScatteringFoilZSize = defaultFirstSca    182     firstScatteringFoilZSize = defaultFirstScatteringFoilZSize;
183                                                   183     
184     G4double defaultFirstScatteringFoilXPositi    184     G4double defaultFirstScatteringFoilXPosition = 0.0 *mm;
185     firstScatteringFoilXPosition = defaultFirs    185     firstScatteringFoilXPosition = defaultFirstScatteringFoilXPosition;
186                                                   186     
187     // KAPTON WINDOW: it prmits the passage of    187     // KAPTON WINDOW: it prmits the passage of the beam from vacuum to air
188     G4double defaultKaptonWindowXSize = 0.010*    188     G4double defaultKaptonWindowXSize = 0.010*mm;
189     kaptonWindowXSize = defaultKaptonWindowXSi    189     kaptonWindowXSize = defaultKaptonWindowXSize;
190                                                   190     
191     G4double defaultKaptonWindowYSize = 5.25*c    191     G4double defaultKaptonWindowYSize = 5.25*cm;
192     kaptonWindowYSize = defaultKaptonWindowYSi    192     kaptonWindowYSize = defaultKaptonWindowYSize;
193                                                   193     
194     G4double defaultKaptonWindowZSize = 5.25*c    194     G4double defaultKaptonWindowZSize = 5.25*cm;
195     kaptonWindowZSize = defaultKaptonWindowZSi    195     kaptonWindowZSize = defaultKaptonWindowZSize;
196                                                   196     
197     G4double defaultKaptonWindowXPosition = 10    197     G4double defaultKaptonWindowXPosition = 100.0*mm - defaultKaptonWindowXSize;
198     kaptonWindowXPosition = defaultKaptonWindo    198     kaptonWindowXPosition = defaultKaptonWindowXPosition;
199                                                   199     
200     // STOPPER: is a small cylinder able to st    200     // STOPPER: is a small cylinder able to stop the central component
201     // of the beam (having a gaussian shape).     201     // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
202     // and represent the second element of the    202     // and represent the second element of the scattering system
203     G4double defaultInnerRadiusStopper = 0.*cm    203     G4double defaultInnerRadiusStopper = 0.*cm;
204     innerRadiusStopper = defaultInnerRadiusSto    204     innerRadiusStopper = defaultInnerRadiusStopper;
205                                                   205     
206     G4double defaultHeightStopper = 3.5*mm;       206     G4double defaultHeightStopper = 3.5*mm;
207     heightStopper = defaultHeightStopper;         207     heightStopper = defaultHeightStopper;
208                                                   208     
209     G4double defaultStartAngleStopper = 0.*deg    209     G4double defaultStartAngleStopper = 0.*deg;
210     startAngleStopper = defaultStartAngleStopp    210     startAngleStopper = defaultStartAngleStopper;
211                                                   211     
212     G4double defaultSpanningAngleStopper = 360    212     G4double defaultSpanningAngleStopper = 360.*deg;
213     spanningAngleStopper = defaultSpanningAngl    213     spanningAngleStopper = defaultSpanningAngleStopper;
214                                                   214     
215     G4double defaultStopperXPosition = -2705.0    215     G4double defaultStopperXPosition = -2705.0 *mm;
216     stopperXPosition = defaultStopperXPosition    216     stopperXPosition = defaultStopperXPosition;
217                                                   217     
218     G4double defaultStopperYPosition = 0.*m;      218     G4double defaultStopperYPosition = 0.*m;
219     stopperYPosition = defaultStopperYPosition    219     stopperYPosition = defaultStopperYPosition;
220                                                   220     
221     G4double defaultStopperZPosition = 0.*m;      221     G4double defaultStopperZPosition = 0.*m;
222     stopperZPosition = defaultStopperZPosition    222     stopperZPosition = defaultStopperZPosition;
223                                                   223     
224     G4double defaultOuterRadiusStopper = 2 *mm    224     G4double defaultOuterRadiusStopper = 2 *mm;
225     outerRadiusStopper = defaultOuterRadiusSto    225     outerRadiusStopper = defaultOuterRadiusStopper;
226                                                   226     
227     // SECOND SCATTERING FOIL: it is another t    227     // SECOND SCATTERING FOIL: it is another thin foil and provides the
228     // final diffusion of the beam. It represe    228     // final diffusion of the beam. It represents the third element of the scattering
229     // system;                                    229     // system;
230     G4double defaultSecondScatteringFoilXSize     230     G4double defaultSecondScatteringFoilXSize = 0.0125 *mm;
231     secondScatteringFoilXSize = defaultSecondS    231     secondScatteringFoilXSize = defaultSecondScatteringFoilXSize;
232                                                   232     
233     G4double defaultSecondScatteringFoilYSize     233     G4double defaultSecondScatteringFoilYSize = 52.5   *mm;
234     secondScatteringFoilYSize = defaultSecondS    234     secondScatteringFoilYSize = defaultSecondScatteringFoilYSize;
235                                                   235     
236     G4double defaultSecondScatteringFoilZSize     236     G4double defaultSecondScatteringFoilZSize = 52.5   *mm;
237     secondScatteringFoilZSize = defaultSecondS    237     secondScatteringFoilZSize = defaultSecondScatteringFoilZSize;
238                                                   238     
239     G4double defaultSecondScatteringFoilXPosit    239     G4double defaultSecondScatteringFoilXPosition = defaultStopperXPosition + defaultHeightStopper + defaultSecondScatteringFoilXSize;
240     secondScatteringFoilXPosition = defaultSec    240     secondScatteringFoilXPosition = defaultSecondScatteringFoilXPosition;
241                                                   241     
242     G4double defaultSecondScatteringFoilYPosit    242     G4double defaultSecondScatteringFoilYPosition =  0 *mm;
243     secondScatteringFoilYPosition = defaultSec    243     secondScatteringFoilYPosition = defaultSecondScatteringFoilYPosition;
244                                                   244     
245     G4double defaultSecondScatteringFoilZPosit    245     G4double defaultSecondScatteringFoilZPosition =  0 *mm;
246     secondScatteringFoilZPosition = defaultSec    246     secondScatteringFoilZPosition = defaultSecondScatteringFoilZPosition;
247                                                   247     
248     // RANGE SHIFTER: is a slab of PMMA acting    248     // RANGE SHIFTER: is a slab of PMMA acting as energy degreader of
249     // primary beam                               249     // primary beam
250                                                   250     
251     //Default material of the range shifter       251     //Default material of the range shifter
252                                                   252     
253     G4double defaultRangeShifterXSize = 5. *mm    253     G4double defaultRangeShifterXSize = 5. *mm;
254     rangeShifterXSize = defaultRangeShifterXSi    254     rangeShifterXSize = defaultRangeShifterXSize;
255                                                   255     
256     G4double defaultRangeShifterYSize = 176. *    256     G4double defaultRangeShifterYSize = 176. *mm;
257     rangeShifterYSize = defaultRangeShifterYSi    257     rangeShifterYSize = defaultRangeShifterYSize;
258                                                   258     
259     G4double defaultRangeShifterZSize = 176. *    259     G4double defaultRangeShifterZSize = 176. *mm;
260     rangeShifterZSize = defaultRangeShifterZSi    260     rangeShifterZSize = defaultRangeShifterZSize;
261                                                   261     
262     G4double defaultRangeShifterXPosition = -2    262     G4double defaultRangeShifterXPosition = -2393.0 *mm;
263     rangeShifterXPosition = defaultRangeShifte    263     rangeShifterXPosition = defaultRangeShifterXPosition;
264                                                   264     
265     G4double defaultRangeShifterYPosition = 0.    265     G4double defaultRangeShifterYPosition = 0. *mm;
266     rangeShifterYPosition = defaultRangeShifte    266     rangeShifterYPosition = defaultRangeShifterYPosition;
267                                                   267     
268     G4double defaultRangeShifterZPosition = 0.    268     G4double defaultRangeShifterZPosition = 0. *mm;
269     rangeShifterZPosition = defaultRangeShifte    269     rangeShifterZPosition = defaultRangeShifterZPosition;
270                                                   270     
271     // MOPI DETECTOR: two orthogonal microstri    271     // MOPI DETECTOR: two orthogonal microstrip gas detectors developed
272     // by the INFN Section of Turin in collabo    272     // by the INFN Section of Turin in collaboration with some
273     // of the author of this example. It permi    273     // of the author of this example. It permits the
274     // on-line check of the beam simmetry via     274     // on-line check of the beam simmetry via the signal
275     // integration of the collected charge for    275     // integration of the collected charge for each strip.
276                                                   276     
277     // Mother volume of MOPI                      277     // Mother volume of MOPI
278                                                   278     
279     G4double defaultMOPIMotherVolumeXSize = 12    279     G4double defaultMOPIMotherVolumeXSize = 12127.0 *um;
280     MOPIMotherVolumeXSize = defaultMOPIMotherV    280     MOPIMotherVolumeXSize = defaultMOPIMotherVolumeXSize;
281                                                   281     
282     G4double defaultMOPIMotherVolumeYSize = 40    282     G4double defaultMOPIMotherVolumeYSize = 40.0 *cm;
283     MOPIMotherVolumeYSize = defaultMOPIMotherV    283     MOPIMotherVolumeYSize = defaultMOPIMotherVolumeYSize;
284                                                   284     
285     G4double defaultMOPIMotherVolumeZSize = 40    285     G4double defaultMOPIMotherVolumeZSize = 40.0 *cm;
286     MOPIMotherVolumeZSize = defaultMOPIMotherV    286     MOPIMotherVolumeZSize = defaultMOPIMotherVolumeZSize;
287                                                   287     
288     G4double defaultMOPIMotherVolumeXPosition     288     G4double defaultMOPIMotherVolumeXPosition = -1000.0 *mm;
289     MOPIMotherVolumeXPosition = defaultMOPIMot    289     MOPIMotherVolumeXPosition = defaultMOPIMotherVolumeXPosition;
290                                                   290     
291     G4double defaultMOPIMotherVolumeYPosition     291     G4double defaultMOPIMotherVolumeYPosition = 0.0 *mm;
292     MOPIMotherVolumeYPosition = defaultMOPIMot    292     MOPIMotherVolumeYPosition = defaultMOPIMotherVolumeYPosition;
293                                                   293     
294     G4double defaultMOPIMotherVolumeZPosition     294     G4double defaultMOPIMotherVolumeZPosition = 0.0 *mm;
295     MOPIMotherVolumeZPosition = defaultMOPIMot    295     MOPIMotherVolumeZPosition = defaultMOPIMotherVolumeZPosition;
296                                                   296     
297     // First Kapton Layer of MOPI                 297     // First Kapton Layer of MOPI
298     G4double defaultMOPIFirstKaptonLayerXSize     298     G4double defaultMOPIFirstKaptonLayerXSize = 35 *um;
299     MOPIFirstKaptonLayerXSize = defaultMOPIFir    299     MOPIFirstKaptonLayerXSize = defaultMOPIFirstKaptonLayerXSize;
300                                                   300     
301     G4double defaultMOPIFirstKaptonLayerYSize     301     G4double defaultMOPIFirstKaptonLayerYSize = 30 *cm;
302     MOPIFirstKaptonLayerYSize = defaultMOPIFir    302     MOPIFirstKaptonLayerYSize = defaultMOPIFirstKaptonLayerYSize;
303                                                   303     
304     G4double defaultMOPIFirstKaptonLayerZSize     304     G4double defaultMOPIFirstKaptonLayerZSize = 30 *cm;
305     MOPIFirstKaptonLayerZSize = defaultMOPIFir    305     MOPIFirstKaptonLayerZSize = defaultMOPIFirstKaptonLayerZSize;
306                                                   306     
307     G4double defaultMOPIFirstKaptonLayerXPosit    307     G4double defaultMOPIFirstKaptonLayerXPosition = -(MOPIMotherVolumeXSize/2 - (MOPIFirstKaptonLayerXSize/2));
308     MOPIFirstKaptonLayerXPosition = defaultMOP    308     MOPIFirstKaptonLayerXPosition = defaultMOPIFirstKaptonLayerXPosition;
309                                                   309     
310     G4double defaultMOPIFirstKaptonLayerYPosit    310     G4double defaultMOPIFirstKaptonLayerYPosition = 0.0 *mm;
311     MOPIFirstKaptonLayerYPosition = defaultMOP    311     MOPIFirstKaptonLayerYPosition = defaultMOPIFirstKaptonLayerYPosition;
312                                                   312     
313     G4double defaultMOPIFirstKaptonLayerZPosit    313     G4double defaultMOPIFirstKaptonLayerZPosition = 0.0 *mm;
314     MOPIFirstKaptonLayerZPosition = defaultMOP    314     MOPIFirstKaptonLayerZPosition = defaultMOPIFirstKaptonLayerZPosition;
315                                                   315     
316     //First Aluminum  Layer of MOPI               316     //First Aluminum  Layer of MOPI
317     G4double defaultMOPIFirstAluminumLayerXSiz    317     G4double defaultMOPIFirstAluminumLayerXSize = 15 *um;
318     MOPIFirstAluminumLayerXSize = defaultMOPIF    318     MOPIFirstAluminumLayerXSize = defaultMOPIFirstAluminumLayerXSize;
319                                                   319     
320     G4double defaultMOPIFirstAluminumLayerYSiz    320     G4double defaultMOPIFirstAluminumLayerYSize = 30 *cm;
321     MOPIFirstAluminumLayerYSize = defaultMOPIF    321     MOPIFirstAluminumLayerYSize = defaultMOPIFirstAluminumLayerYSize;
322                                                   322     
323     G4double defaultMOPIFirstAluminumLayerZSiz    323     G4double defaultMOPIFirstAluminumLayerZSize = 30 *cm;
324     MOPIFirstAluminumLayerZSize = defaultMOPIF    324     MOPIFirstAluminumLayerZSize = defaultMOPIFirstAluminumLayerZSize;
325                                                   325     
326     G4double defaultMOPIFirstAluminumLayerXPos    326     G4double defaultMOPIFirstAluminumLayerXPosition =
327     MOPIFirstKaptonLayerXPosition + MOPIFirstK    327     MOPIFirstKaptonLayerXPosition + MOPIFirstKaptonLayerXSize/2 + MOPIFirstAluminumLayerXSize/2;
328     MOPIFirstAluminumLayerXPosition = defaultM    328     MOPIFirstAluminumLayerXPosition = defaultMOPIFirstAluminumLayerXPosition;
329                                                   329     
330     G4double defaultMOPIFirstAluminumLayerYPos    330     G4double defaultMOPIFirstAluminumLayerYPosition = 0.0 *mm;
331     MOPIFirstAluminumLayerYPosition = defaultM    331     MOPIFirstAluminumLayerYPosition = defaultMOPIFirstAluminumLayerYPosition;
332                                                   332     
333     G4double defaultMOPIFirstAluminumLayerZPos    333     G4double defaultMOPIFirstAluminumLayerZPosition = 0.0 *mm;
334     MOPIFirstAluminumLayerZPosition = defaultM    334     MOPIFirstAluminumLayerZPosition = defaultMOPIFirstAluminumLayerZPosition;
335                                                   335     
336     // First Air gap of MOPI                      336     // First Air gap of MOPI
337     G4double defaultMOPIFirstAirGapXSize = 600    337     G4double defaultMOPIFirstAirGapXSize = 6000 *um;
338     MOPIFirstAirGapXSize = defaultMOPIFirstAir    338     MOPIFirstAirGapXSize = defaultMOPIFirstAirGapXSize;
339                                                   339     
340     G4double defaultMOPIFirstAirGapYSize = 30     340     G4double defaultMOPIFirstAirGapYSize = 30 *cm;
341     MOPIFirstAirGapYSize = defaultMOPIFirstAir    341     MOPIFirstAirGapYSize = defaultMOPIFirstAirGapYSize;
342                                                   342     
343     G4double defaultMOPIFirstAirGapZSize = 30     343     G4double defaultMOPIFirstAirGapZSize = 30 *cm;
344     MOPIFirstAirGapZSize = defaultMOPIFirstAir    344     MOPIFirstAirGapZSize = defaultMOPIFirstAirGapZSize;
345                                                   345     
346     G4double defaultMOPIFirstAirGapXPosition =    346     G4double defaultMOPIFirstAirGapXPosition =
347     MOPIFirstAluminumLayerXPosition + MOPIFirs    347     MOPIFirstAluminumLayerXPosition + MOPIFirstAluminumLayerXSize/2 + MOPIFirstAirGapXSize/2;
348     MOPIFirstAirGapXPosition = defaultMOPIFirs    348     MOPIFirstAirGapXPosition = defaultMOPIFirstAirGapXPosition;
349                                                   349     
350     G4double defaultMOPIFirstAirGapYPosition =    350     G4double defaultMOPIFirstAirGapYPosition = 0.0 *mm;
351     MOPIFirstAirGapYPosition = defaultMOPIFirs    351     MOPIFirstAirGapYPosition = defaultMOPIFirstAirGapYPosition;
352                                                   352     
353     G4double defaultMOPIFirstAirGapZPosition =    353     G4double defaultMOPIFirstAirGapZPosition = 0.0 *mm;
354     MOPIFirstAirGapZPosition = defaultMOPIFirs    354     MOPIFirstAirGapZPosition = defaultMOPIFirstAirGapZPosition;
355                                                   355     
356     // Cathode of MOPI                            356     // Cathode of MOPI
357     G4double defaultMOPICathodeXSize = 25.0 *u    357     G4double defaultMOPICathodeXSize = 25.0 *um;
358     MOPICathodeXSize = defaultMOPICathodeXSize    358     MOPICathodeXSize = defaultMOPICathodeXSize;
359                                                   359     
360     G4double defaultMOPICathodeYSize = 30.0 *c    360     G4double defaultMOPICathodeYSize = 30.0 *cm;
361     MOPICathodeYSize = defaultMOPICathodeYSize    361     MOPICathodeYSize = defaultMOPICathodeYSize;
362                                                   362     
363     G4double defaultMOPICathodeZSize = 30.0 *c    363     G4double defaultMOPICathodeZSize = 30.0 *cm;
364     MOPICathodeZSize = defaultMOPICathodeZSize    364     MOPICathodeZSize = defaultMOPICathodeZSize;
365                                                   365     
366     G4double defaultMOPICathodeXPosition =        366     G4double defaultMOPICathodeXPosition =
367     MOPIFirstAirGapXPosition + MOPIFirstAirGap    367     MOPIFirstAirGapXPosition + MOPIFirstAirGapXSize/2 + MOPICathodeXSize/2;
368     MOPICathodeXPosition = defaultMOPICathodeX    368     MOPICathodeXPosition = defaultMOPICathodeXPosition;
369                                                   369     
370     G4double defaultMOPICathodeYPosition = 0.0    370     G4double defaultMOPICathodeYPosition = 0.0 *mm;
371     MOPICathodeYPosition = defaultMOPICathodeY    371     MOPICathodeYPosition = defaultMOPICathodeYPosition;
372                                                   372     
373     G4double defaultMOPICathodeZPosition = 0.0    373     G4double defaultMOPICathodeZPosition = 0.0 *mm;
374     MOPICathodeZPosition = defaultMOPICathodeZ    374     MOPICathodeZPosition = defaultMOPICathodeZPosition;
375                                                   375     
376     // Second Air gap of MOPI                     376     // Second Air gap of MOPI
377     G4double defaultMOPISecondAirGapXSize = 60    377     G4double defaultMOPISecondAirGapXSize = 6000 *um;
378     MOPISecondAirGapXSize = defaultMOPISecondA    378     MOPISecondAirGapXSize = defaultMOPISecondAirGapXSize;
379                                                   379     
380     G4double defaultMOPISecondAirGapYSize = 30    380     G4double defaultMOPISecondAirGapYSize = 30 *cm;
381     MOPISecondAirGapYSize = defaultMOPISecondA    381     MOPISecondAirGapYSize = defaultMOPISecondAirGapYSize;
382                                                   382     
383     G4double defaultMOPISecondAirGapZSize = 30    383     G4double defaultMOPISecondAirGapZSize = 30 *cm;
384     MOPISecondAirGapZSize = defaultMOPISecondA    384     MOPISecondAirGapZSize = defaultMOPISecondAirGapZSize;
385                                                   385     
386     G4double defaultMOPISecondAirGapXPosition     386     G4double defaultMOPISecondAirGapXPosition =
387     MOPICathodeXPosition + MOPICathodeXSize/2     387     MOPICathodeXPosition + MOPICathodeXSize/2 + MOPISecondAirGapXSize/2;
388     MOPISecondAirGapXPosition = defaultMOPISec    388     MOPISecondAirGapXPosition = defaultMOPISecondAirGapXPosition;
389                                                   389     
390     G4double defaultMOPISecondAirGapYPosition     390     G4double defaultMOPISecondAirGapYPosition = 0.0 *mm;
391     MOPISecondAirGapYPosition = defaultMOPISec    391     MOPISecondAirGapYPosition = defaultMOPISecondAirGapYPosition;
392                                                   392     
393     G4double defaultMOPISecondAirGapZPosition     393     G4double defaultMOPISecondAirGapZPosition = 0.0 *mm;
394     MOPISecondAirGapZPosition = defaultMOPISec    394     MOPISecondAirGapZPosition = defaultMOPISecondAirGapZPosition;
395                                                   395     
396     //Second Aluminum  Layer of MOPI              396     //Second Aluminum  Layer of MOPI
397     G4double defaultMOPISecondAluminumLayerXSi    397     G4double defaultMOPISecondAluminumLayerXSize = 15 *um;
398     MOPISecondAluminumLayerXSize = defaultMOPI    398     MOPISecondAluminumLayerXSize = defaultMOPISecondAluminumLayerXSize;
399                                                   399     
400     G4double defaultMOPISecondAluminumLayerYSi    400     G4double defaultMOPISecondAluminumLayerYSize = 30 *cm;
401     MOPISecondAluminumLayerYSize = defaultMOPI    401     MOPISecondAluminumLayerYSize = defaultMOPISecondAluminumLayerYSize;
402                                                   402     
403     G4double defaultMOPISecondAluminumLayerZSi    403     G4double defaultMOPISecondAluminumLayerZSize = 30 *cm;
404     MOPISecondAluminumLayerZSize = defaultMOPI    404     MOPISecondAluminumLayerZSize = defaultMOPISecondAluminumLayerZSize;
405                                                   405     
406     G4double defaultMOPISecondAluminumLayerXPo    406     G4double defaultMOPISecondAluminumLayerXPosition =
407     MOPISecondAirGapXPosition + MOPISecondAirG    407     MOPISecondAirGapXPosition + MOPISecondAirGapXSize/2 + MOPISecondAluminumLayerXSize/2;
408     MOPISecondAluminumLayerXPosition = default    408     MOPISecondAluminumLayerXPosition = defaultMOPISecondAluminumLayerXPosition;
409                                                   409     
410     G4double defaultMOPISecondAluminumLayerYPo    410     G4double defaultMOPISecondAluminumLayerYPosition = 0.0 *mm;
411     MOPISecondAluminumLayerYPosition = default    411     MOPISecondAluminumLayerYPosition = defaultMOPISecondAluminumLayerYPosition;
412                                                   412     
413     G4double defaultMOPISecondAluminumLayerZPo    413     G4double defaultMOPISecondAluminumLayerZPosition = 0.0 *mm;
414     MOPISecondAluminumLayerZPosition = default    414     MOPISecondAluminumLayerZPosition = defaultMOPISecondAluminumLayerZPosition;
415                                                   415     
416     // Second Kapton Layer of MOPI                416     // Second Kapton Layer of MOPI
417     G4double defaultMOPISecondKaptonLayerXSize    417     G4double defaultMOPISecondKaptonLayerXSize = 35 *um;
418     MOPISecondKaptonLayerXSize = defaultMOPISe    418     MOPISecondKaptonLayerXSize = defaultMOPISecondKaptonLayerXSize;
419                                                   419     
420     G4double defaultMOPISecondKaptonLayerYSize    420     G4double defaultMOPISecondKaptonLayerYSize = 30 *cm;
421     MOPISecondKaptonLayerYSize = defaultMOPISe    421     MOPISecondKaptonLayerYSize = defaultMOPISecondKaptonLayerYSize;
422                                                   422     
423     G4double defaultMOPISecondKaptonLayerZSize    423     G4double defaultMOPISecondKaptonLayerZSize = 30 *cm;
424     MOPISecondKaptonLayerZSize = defaultMOPISe    424     MOPISecondKaptonLayerZSize = defaultMOPISecondKaptonLayerZSize;
425                                                   425     
426     G4double defaultMOPISecondKaptonLayerXPosi    426     G4double defaultMOPISecondKaptonLayerXPosition =
427     MOPISecondAluminumLayerXPosition + MOPISec    427     MOPISecondAluminumLayerXPosition + MOPISecondAluminumLayerXSize/2 + MOPISecondKaptonLayerXSize/2;
428     MOPISecondKaptonLayerXPosition = defaultMO    428     MOPISecondKaptonLayerXPosition = defaultMOPISecondKaptonLayerXPosition;
429                                                   429     
430     G4double defaultMOPISecondKaptonLayerYPosi    430     G4double defaultMOPISecondKaptonLayerYPosition = 0.0 *mm;
431     MOPISecondKaptonLayerYPosition = defaultMO    431     MOPISecondKaptonLayerYPosition = defaultMOPISecondKaptonLayerYPosition;
432                                                   432     
433     G4double defaultMOPISecondKaptonLayerZPosi    433     G4double defaultMOPISecondKaptonLayerZPosition = 0.0 *mm;
434     MOPISecondKaptonLayerZPosition = defaultMO    434     MOPISecondKaptonLayerZPosition = defaultMOPISecondKaptonLayerZPosition;
435                                                   435     
436                                                   436     
437     // FINAL COLLIMATOR: is the collimator giv    437     // FINAL COLLIMATOR: is the collimator giving the final transversal shape
438     // of the beam                                438     // of the beam
439     G4double defaultinnerRadiusFinalCollimator    439     G4double defaultinnerRadiusFinalCollimator = 7.5 *mm;
440     innerRadiusFinalCollimator = defaultinnerR    440     innerRadiusFinalCollimator = defaultinnerRadiusFinalCollimator;
441                                                   441     
442     // DEFAULT DEFINITION OF THE MATERIALS        442     // DEFAULT DEFINITION OF THE MATERIALS
443     // All elements and compound definition fo    443     // All elements and compound definition follows the NIST database
444                                                   444     
445     // ELEMENTS                                   445     // ELEMENTS
446     G4bool isotopes = false;                      446     G4bool isotopes = false;
447     G4Material* aluminumNist = G4NistManager::    447     G4Material* aluminumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al", isotopes);
448     G4Material* tantalumNist = G4NistManager::    448     G4Material* tantalumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ta", isotopes);
449     G4Material* copperNistAsMaterial = G4NistM    449     G4Material* copperNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu", isotopes);
450     G4Element* zincNist = G4NistManager::Insta    450     G4Element* zincNist = G4NistManager::Instance()->FindOrBuildElement("Zn");
451     G4Element* copperNist = G4NistManager::Ins    451     G4Element* copperNist = G4NistManager::Instance()->FindOrBuildElement("Cu");
452                                                   452     
453     // COMPOUND                                   453     // COMPOUND
454     G4Material* airNist =  G4NistManager::Inst    454     G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
455     G4Material* kaptonNist = G4NistManager::In    455     G4Material* kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
456     G4Material* galacticNist = G4NistManager::    456     G4Material* galacticNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic", isotopes);
457     G4Material* PMMANist = G4NistManager::Inst    457     G4Material* PMMANist = G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS", isotopes);
458     G4Material* mylarNist = G4NistManager::Ins    458     G4Material* mylarNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_MYLAR", isotopes);
459                                                   459     
460     G4double d; // Density                        460     G4double d; // Density
461     G4int nComponents;// Number of components     461     G4int nComponents;// Number of components
462     G4double fractionmass; // Fraction in mass    462     G4double fractionmass; // Fraction in mass of an element in a material
463                                                   463     
464     d = 8.40*g/cm3;                               464     d = 8.40*g/cm3;
465     nComponents = 2;                              465     nComponents = 2;
466     G4Material* brass = new G4Material("Brass"    466     G4Material* brass = new G4Material("Brass", d, nComponents);
467     brass -> AddElement(zincNist, fractionmass    467     brass -> AddElement(zincNist, fractionmass = 30 *perCent);
468     brass -> AddElement(copperNist, fractionma    468     brass -> AddElement(copperNist, fractionmass = 70 *perCent);
469                                                   469     
470                                                   470     
471     //***************************** PW *******    471     //***************************** PW ***************************************
472                                                   472     
473     // DetectorROGeometry Material                473     // DetectorROGeometry Material
474     new G4Material("dummyMat", 1., 1.*g/mole,     474     new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
475                                                   475     
476     //***************************** PW *******    476     //***************************** PW ***************************************
477                                                   477     
478                                                   478     
479                                                   479     
480     // MATERIAL ASSIGNMENT                        480     // MATERIAL ASSIGNMENT
481     // Range shifter                              481     // Range shifter
482     rangeShifterMaterial = airNist;               482     rangeShifterMaterial = airNist;
483                                                   483     
484     // Support of the beam line                   484     // Support of the beam line
485     beamLineSupportMaterial = aluminumNist;       485     beamLineSupportMaterial = aluminumNist;
486                                                   486     
487     // Vacuum pipe                                487     // Vacuum pipe
488     vacuumZoneMaterial = galacticNist;            488     vacuumZoneMaterial = galacticNist;
489                                                   489     
490     // Material of the fisrt scattering foil      490     // Material of the fisrt scattering foil
491     firstScatteringFoilMaterial = tantalumNist    491     firstScatteringFoilMaterial = tantalumNist;
492                                                   492     
493     // Material of kapton window                  493     // Material of kapton window
494     kaptonWindowMaterial = kaptonNist;            494     kaptonWindowMaterial = kaptonNist;
495                                                   495     
496     // Material of the stopper                    496     // Material of the stopper
497     stopperMaterial = brass;                      497     stopperMaterial = brass;
498                                                   498     
499     // Material of the second scattering foil     499     // Material of the second scattering foil
500     secondScatteringFoilMaterial = tantalumNis    500     secondScatteringFoilMaterial = tantalumNist;
501                                                   501     
502     // Materials of the collimators               502     // Materials of the collimators
503     firstCollimatorMaterial = PMMANist;           503     firstCollimatorMaterial = PMMANist;
504     holeFirstCollimatorMaterial = airNist;        504     holeFirstCollimatorMaterial = airNist;
505                                                   505     
506     // Box containing the modulator wheel         506     // Box containing the modulator wheel
507     modulatorBoxMaterial = aluminumNist;          507     modulatorBoxMaterial = aluminumNist;
508     holeModulatorBoxMaterial = airNist;           508     holeModulatorBoxMaterial = airNist;
509                                                   509     
510     // Materials of the monitor chamber           510     // Materials of the monitor chamber
511     layer1MonitorChamberMaterial = kaptonNist;    511     layer1MonitorChamberMaterial = kaptonNist;
512     layer2MonitorChamberMaterial = copperNistA    512     layer2MonitorChamberMaterial = copperNistAsMaterial;
513     layer3MonitorChamberMaterial = airNist;       513     layer3MonitorChamberMaterial = airNist;
514     layer4MonitorChamberMaterial = copperNistA    514     layer4MonitorChamberMaterial = copperNistAsMaterial;
515                                                   515     
516     // Mother volume of the MOPI detector         516     // Mother volume of the MOPI detector
517     MOPIMotherVolumeMaterial = airNist;           517     MOPIMotherVolumeMaterial = airNist;
518     MOPIFirstKaptonLayerMaterial = kaptonNist;    518     MOPIFirstKaptonLayerMaterial = kaptonNist;
519     MOPIFirstAluminumLayerMaterial = aluminumN    519     MOPIFirstAluminumLayerMaterial = aluminumNist;
520     MOPIFirstAirGapMaterial = airNist;            520     MOPIFirstAirGapMaterial = airNist;
521     MOPICathodeMaterial = mylarNist;              521     MOPICathodeMaterial = mylarNist;
522     MOPISecondAirGapMaterial = airNist;           522     MOPISecondAirGapMaterial = airNist;
523     MOPISecondAluminumLayerMaterial = aluminum    523     MOPISecondAluminumLayerMaterial = aluminumNist;
524     MOPISecondKaptonLayerMaterial = kaptonNist    524     MOPISecondKaptonLayerMaterial = kaptonNist;
525                                                   525     
526     // material of the final nozzle               526     // material of the final nozzle
527     nozzleSupportMaterial = PMMANist;             527     nozzleSupportMaterial = PMMANist;
528     brassTubeMaterial = brassTube2Material = b    528     brassTubeMaterial = brassTube2Material = brassTube3Material = brass;
529     holeNozzleSupportMaterial = airNist;          529     holeNozzleSupportMaterial = airNist;
530                                                   530     
531     // Material of the final collimator           531     // Material of the final collimator
532     finalCollimatorMaterial = brass;              532     finalCollimatorMaterial = brass;
533 }                                                 533 }
534                                                   534 
535 //////////////////////////////////////////////    535 /////////////////////////////////////////////////////////////////////////////
536 void PassiveProtonBeamLine::ConstructPassivePr    536 void PassiveProtonBeamLine::ConstructPassiveProtonBeamLine()
537 {                                                 537 {
538     // -----------------------------              538     // -----------------------------
539     // Treatment room - World volume              539     // Treatment room - World volume
540     //------------------------------              540     //------------------------------
541     // Treatment room sizes                       541     // Treatment room sizes
542     const G4double worldX = 400.0 *cm;            542     const G4double worldX = 400.0 *cm;
543     const G4double worldY = 400.0 *cm;            543     const G4double worldY = 400.0 *cm;
544     const G4double worldZ = 400.0 *cm;            544     const G4double worldZ = 400.0 *cm;
545     G4bool isotopes = false;                      545     G4bool isotopes = false;
546                                                   546     
547     G4Material* airNist =  G4NistManager::Inst    547     G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
548     G4Box* treatmentRoom = new G4Box("Treatmen    548     G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
549     G4LogicalVolume* logicTreatmentRoom = new     549     G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom,
550                                                   550                                                               airNist,
551                                                   551                                                               "logicTreatmentRoom",
552                                                   552                                                               0,0,0);
553     physicalTreatmentRoom = new G4PVPlacement(    553     physicalTreatmentRoom = new G4PVPlacement(0,
554                                                   554                                               G4ThreeVector(),
555                                                   555                                               "physicalTreatmentRoom",
556                                                   556                                               logicTreatmentRoom,
557                                                   557                                               0,false,0);
558                                                   558     
559                                                   559     
560     // The treatment room is invisible in the     560     // The treatment room is invisible in the Visualisation
561     logicTreatmentRoom -> SetVisAttributes(G4V << 561     //logicTreatmentRoom -> SetVisAttributes(G4VisAttributes::GetInvisible());
562                                                   562     
563     // Components of the Passive Proton Beam L    563     // Components of the Passive Proton Beam Line
564     HadrontherapyBeamLineSupport();               564     HadrontherapyBeamLineSupport();
565     HadrontherapyBeamScatteringFoils();           565     HadrontherapyBeamScatteringFoils();
566     HadrontherapyRangeShifter();                  566     HadrontherapyRangeShifter();
567     HadrontherapyBeamCollimators();               567     HadrontherapyBeamCollimators();
568     HadrontherapyBeamMonitoring();                568     HadrontherapyBeamMonitoring();
569     HadrontherapyMOPIDetector();                  569     HadrontherapyMOPIDetector();
570     HadrontherapyBeamNozzle();                    570     HadrontherapyBeamNozzle();
571     HadrontherapyBeamFinalCollimator();           571     HadrontherapyBeamFinalCollimator();
572                                                   572     
573     // The following lines construc a typical     573     // The following lines construc a typical modulator wheel inside the Passive Beam line.
574     // Please remember to set the nodulator ma    574     // Please remember to set the nodulator material (default is air, i.e. no modulator!)
575     // in the HadrontherapyModulator.cc file      575     // in the HadrontherapyModulator.cc file
576     modulator = new HadrontherapyModulator();     576     modulator = new HadrontherapyModulator();
577     modulator -> BuildModulator(physicalTreatm    577     modulator -> BuildModulator(physicalTreatmentRoom);
578 }                                                 578 }
579                                                   579 
580 //////////////////////////////////////////////    580 /////////////////////////////////////////////////////////////////////////////
581 void PassiveProtonBeamLine::HadrontherapyBeamL    581 void PassiveProtonBeamLine::HadrontherapyBeamLineSupport()
582 {                                                 582 {
583     // ------------------//                       583     // ------------------//
584     // BEAM LINE SUPPORT //                       584     // BEAM LINE SUPPORT //
585     //-------------------//                       585     //-------------------//
586     const G4double beamLineSupportXSize = 1.5*    586     const G4double beamLineSupportXSize = 1.5*m;
587     const G4double beamLineSupportYSize = 20.*    587     const G4double beamLineSupportYSize = 20.*mm;
588     const G4double beamLineSupportZSize = 600.    588     const G4double beamLineSupportZSize = 600.*mm;
589                                                   589     
590     const G4double beamLineSupportXPosition =     590     const G4double beamLineSupportXPosition = -1745.09 *mm;
591     const G4double beamLineSupportYPosition =     591     const G4double beamLineSupportYPosition = -230. *mm;
592     const G4double beamLineSupportZPosition =     592     const G4double beamLineSupportZPosition = 0.*mm;
593                                                   593     
594   G4Box* beamLineSupport = new G4Box("BeamLine    594   G4Box* beamLineSupport = new G4Box("BeamLineSupport",
595                                        beamLin    595                                        beamLineSupportXSize,
596                                        beamLin    596                                        beamLineSupportYSize,
597                                        beamLin    597                                        beamLineSupportZSize);
598                                                   598     
599     G4LogicalVolume* logicBeamLineSupport = ne    599     G4LogicalVolume* logicBeamLineSupport = new G4LogicalVolume(beamLineSupport,
600                                                   600                                                                 beamLineSupportMaterial,
601                                                   601                                                                 "BeamLineSupport");
602     physiBeamLineSupport = new G4PVPlacement(0    602     physiBeamLineSupport = new G4PVPlacement(0, G4ThreeVector(beamLineSupportXPosition,
603                                                   603                                                               beamLineSupportYPosition,
604                                                   604                                                               beamLineSupportZPosition),
605                                              "    605                                              "BeamLineSupport",
606                                              l    606                                              logicBeamLineSupport,
607                                              p    607                                              physicalTreatmentRoom, false, 0);
608                                                   608     
609     // Visualisation attributes of the beam li    609     // Visualisation attributes of the beam line support
610                                                   610     
611     logicBeamLineSupport -> SetVisAttributes(g    611     logicBeamLineSupport -> SetVisAttributes(gray);
612                                                   612 
613     //---------------------------------//         613     //---------------------------------//
614     //  Beam line cover 1 (left panel) //         614     //  Beam line cover 1 (left panel) //
615     //---------------------------------//         615     //---------------------------------//
616     const G4double beamLineCoverXSize = 1.5*m;    616     const G4double beamLineCoverXSize = 1.5*m;
617     const G4double beamLineCoverYSize = 750.*m    617     const G4double beamLineCoverYSize = 750.*mm;
618     const G4double beamLineCoverZSize = 10.*mm    618     const G4double beamLineCoverZSize = 10.*mm;
619                                                   619     
620     const G4double beamLineCoverXPosition = -1    620     const G4double beamLineCoverXPosition = -1745.09 *mm;
621     const G4double beamLineCoverYPosition = -1    621     const G4double beamLineCoverYPosition = -1000.*mm;
622     const G4double beamLineCoverZPosition = 60    622     const G4double beamLineCoverZPosition = 600.*mm;
623                                                   623     
624    G4Box* beamLineCover = new G4Box("BeamLineC    624    G4Box* beamLineCover = new G4Box("BeamLineCover",
625                                      beamLineC    625                                      beamLineCoverXSize,
626                                      beamLineC    626                                      beamLineCoverYSize,
627                                      beamLineC    627                                      beamLineCoverZSize);
628                                                   628     
629     G4LogicalVolume* logicBeamLineCover = new     629     G4LogicalVolume* logicBeamLineCover = new G4LogicalVolume(beamLineCover,
630                                                   630                                                               beamLineSupportMaterial,
631                                                   631                                                               "BeamLineCover");
632                                                   632     
633     physiBeamLineCover = new G4PVPlacement(0,     633     physiBeamLineCover = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
634                                                   634                                                             beamLineCoverYPosition,
635                                                   635                                                             beamLineCoverZPosition),
636                                            "Be    636                                            "BeamLineCover",
637                                            log    637                                            logicBeamLineCover,
638                                            phy    638                                            physicalTreatmentRoom,
639                                            fal    639                                            false,
640                                            0);    640                                            0);
641                                                   641     
642     // ---------------------------------//        642     // ---------------------------------//
643     //  Beam line cover 2 (rigth panel) //        643     //  Beam line cover 2 (rigth panel) //
644     // ---------------------------------//        644     // ---------------------------------//
645     // It has the same characteristic of beam     645     // It has the same characteristic of beam line cover 1 but set in a different position
646     physiBeamLineCover2 = new G4PVPlacement(0,    646     physiBeamLineCover2 = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
647                                                   647                                                              beamLineCoverYPosition,
648                                                   648                                                              - beamLineCoverZPosition),
649                                             "B    649                                             "BeamLineCover2",
650                                             lo    650                                             logicBeamLineCover,
651                                             ph    651                                             physicalTreatmentRoom,
652                                             fa    652                                             false,
653                                             0)    653                                             0);
654                                                   654     
655     logicBeamLineCover -> SetVisAttributes(blu    655     logicBeamLineCover -> SetVisAttributes(blue);
656                                                   656 
657     }                                             657     }
658                                                   658 
659 //////////////////////////////////////////////    659 /////////////////////////////////////////////////////////////////////////////
660 void PassiveProtonBeamLine::HadrontherapyBeamS    660 void PassiveProtonBeamLine::HadrontherapyBeamScatteringFoils()
661 {                                                 661 {
662    // ------------//                              662    // ------------//
663     // VACUUM PIPE //                             663     // VACUUM PIPE //
664     //-------------//                             664     //-------------//
665     //                                            665     //
666     // First track of the beam line is inside     666     // First track of the beam line is inside vacuum;
667     // The PIPE contains the FIRST SCATTERING     667     // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
668     G4Box* vacuumZone = new G4Box("VacuumZone"    668     G4Box* vacuumZone = new G4Box("VacuumZone", vacuumZoneXSize, vacuumZoneYSize, vacuumZoneZSize);
669     G4LogicalVolume* logicVacuumZone = new G4L    669     G4LogicalVolume* logicVacuumZone = new G4LogicalVolume(vacuumZone, vacuumZoneMaterial, "VacuumZone");
670     G4VPhysicalVolume* physiVacuumZone = new G    670     G4VPhysicalVolume* physiVacuumZone = new G4PVPlacement(0, G4ThreeVector(vacuumZoneXPosition, 0., 0.),
671                                                   671                                                            "VacuumZone", logicVacuumZone, physicalTreatmentRoom, false, 0);
672     // --------------------------//               672     // --------------------------//
673     // THE FIRST SCATTERING FOIL //               673     // THE FIRST SCATTERING FOIL //
674     // --------------------------//               674     // --------------------------//
675     // A thin foil performing a first scatteri    675     // A thin foil performing a first scattering
676     // of the original beam                       676     // of the original beam
677     firstScatteringFoil = new G4Box("FirstScat    677     firstScatteringFoil = new G4Box("FirstScatteringFoil",
678                                     firstScatt    678                                     firstScatteringFoilXSize,
679                                     firstScatt    679                                     firstScatteringFoilYSize,
680                                     firstScatt    680                                     firstScatteringFoilZSize);
681                                                   681     
682     G4LogicalVolume* logicFirstScatteringFoil     682     G4LogicalVolume* logicFirstScatteringFoil = new G4LogicalVolume(firstScatteringFoil,
683                                                   683                                                                     firstScatteringFoilMaterial,
684                                                   684                                                                     "FirstScatteringFoil");
685                                                   685     
686     physiFirstScatteringFoil = new G4PVPlaceme    686     physiFirstScatteringFoil = new G4PVPlacement(0, G4ThreeVector(firstScatteringFoilXPosition, 0.,0.),
687                                                   687                                                  "FirstScatteringFoil", logicFirstScatteringFoil, physiVacuumZone,
688                                                   688                                                  false, 0);
689                                                   689     
690     logicFirstScatteringFoil -> SetVisAttribut    690     logicFirstScatteringFoil -> SetVisAttributes(skyBlue);
691     // -------------------//                      691     // -------------------//
692     // THE KAPTON WINDOWS //                      692     // THE KAPTON WINDOWS //
693     //--------------------//                      693     //--------------------//
694     //It prmits the passage of the beam from v    694     //It prmits the passage of the beam from vacuum to air
695                                                   695  
696     G4Box* solidKaptonWindow = new G4Box("Kapt    696     G4Box* solidKaptonWindow = new G4Box("KaptonWindow",
697                                          kapto    697                                          kaptonWindowXSize,
698                                          kapto    698                                          kaptonWindowYSize,
699                                          kapto    699                                          kaptonWindowZSize);
700                                                   700     
701     G4LogicalVolume* logicKaptonWindow = new G    701     G4LogicalVolume* logicKaptonWindow = new G4LogicalVolume(solidKaptonWindow,
702                                                   702                                                              kaptonWindowMaterial,
703                                                   703                                                              "KaptonWindow");
704                                                   704     
705     physiKaptonWindow = new G4PVPlacement(0, G    705     physiKaptonWindow = new G4PVPlacement(0, G4ThreeVector(kaptonWindowXPosition, 0., 0.),
706                                           "Kap    706                                           "KaptonWindow", logicKaptonWindow,
707                                           phys    707                                           physiVacuumZone, false, 0);
708                                                   708     
709     logicKaptonWindow -> SetVisAttributes(dark    709     logicKaptonWindow -> SetVisAttributes(darkOrange3);
710                                                   710     
711     // ------------//                             711     // ------------//
712     // THE STOPPER //                             712     // THE STOPPER //
713     //-------------//                             713     //-------------//
714     // Is a small cylinder able to stop the ce    714     // Is a small cylinder able to stop the central component
715     // of the beam (having a gaussian shape).     715     // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
716     // and represent the second element of the    716     // and represent the second element of the scattering system
717     G4double phi = 90. *deg;                      717     G4double phi = 90. *deg;
718     // Matrix definition for a 90 deg rotation    718     // Matrix definition for a 90 deg rotation with respect to Y axis
719     G4RotationMatrix rm;                          719     G4RotationMatrix rm;
720     rm.rotateY(phi);                              720     rm.rotateY(phi);
721                                                   721     
722     solidStopper = new G4Tubs("Stopper",          722     solidStopper = new G4Tubs("Stopper",
723                               innerRadiusStopp    723                               innerRadiusStopper,
724                               outerRadiusStopp    724                               outerRadiusStopper,
725                               heightStopper,      725                               heightStopper,
726                               startAngleStoppe    726                               startAngleStopper,
727                               spanningAngleSto    727                               spanningAngleStopper);
728                                                   728     
729     logicStopper = new G4LogicalVolume(solidSt    729     logicStopper = new G4LogicalVolume(solidStopper,
730                                        stopper    730                                        stopperMaterial,
731                                        "Stoppe    731                                        "Stopper",
732                                        0, 0, 0    732                                        0, 0, 0);
733                                                   733     
734     physiStopper = new G4PVPlacement(G4Transfo    734     physiStopper = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(stopperXPosition,
735                                                   735                                                                      stopperYPosition,
736                                                   736                                                                      stopperZPosition)),
737                                      "Stopper"    737                                      "Stopper",
738                                      logicStop    738                                      logicStopper,
739                                      physicalT    739                                      physicalTreatmentRoom,
740                                      false,       740                                      false,
741                                      0);          741                                      0);
742                                                   742     
743     logicStopper -> SetVisAttributes(red);        743     logicStopper -> SetVisAttributes(red);
744                                                   744     
745     // ---------------------------//              745     // ---------------------------//
746     // THE SECOND SCATTERING FOIL //              746     // THE SECOND SCATTERING FOIL //
747     // ---------------------------//              747     // ---------------------------//
748     // It is another thin foil and provides th    748     // It is another thin foil and provides the
749     // final diffusion of the beam. It represe    749     // final diffusion of the beam. It represents the third element of the scattering
750     // system;                                    750     // system;
751                                                   751     
752     secondScatteringFoil = new G4Box("SecondSc    752     secondScatteringFoil = new G4Box("SecondScatteringFoil",
753                                      secondSca    753                                      secondScatteringFoilXSize,
754                                      secondSca    754                                      secondScatteringFoilYSize,
755                                      secondSca    755                                      secondScatteringFoilZSize);
756                                                   756     
757     G4LogicalVolume* logicSecondScatteringFoil    757     G4LogicalVolume* logicSecondScatteringFoil = new G4LogicalVolume(secondScatteringFoil,
758                                                   758                                                                      secondScatteringFoilMaterial,
759                                                   759                                                                      "SecondScatteringFoil");
760                                                   760     
761     physiSecondScatteringFoil = new G4PVPlacem    761     physiSecondScatteringFoil = new G4PVPlacement(0, G4ThreeVector(secondScatteringFoilXPosition,
762                                                   762                                                                    secondScatteringFoilYPosition,
763                                                   763                                                                    secondScatteringFoilZPosition),
764                                                   764                                                   "SeconScatteringFoil",
765                                                   765                                                   logicSecondScatteringFoil,
766                                                   766                                                   physicalTreatmentRoom,
767                                                   767                                                   false,
768                                                   768                                                   0);
769                                                   769     
770     logicSecondScatteringFoil -> SetVisAttribu    770     logicSecondScatteringFoil -> SetVisAttributes(skyBlue);
771                                                   771  
772                                                   772  
773 }                                                 773 }
774 //////////////////////////////////////////////    774 /////////////////////////////////////////////////////////////////////////////
775 void PassiveProtonBeamLine::HadrontherapyRange    775 void PassiveProtonBeamLine::HadrontherapyRangeShifter()
776 {                                                 776 {
777     // ---------------------------- //            777     // ---------------------------- //
778     //         THE RANGE SHIFTER    //            778     //         THE RANGE SHIFTER    //
779     // -----------------------------//            779     // -----------------------------//
780     // It is a slab of PMMA acting as energy d    780     // It is a slab of PMMA acting as energy degreader of
781     // primary beam                               781     // primary beam
782                                                   782  
783                                                   783     
784     solidRangeShifterBox = new G4Box("RangeShi    784     solidRangeShifterBox = new G4Box("RangeShifterBox",
785                                      rangeShif    785                                      rangeShifterXSize,
786                                      rangeShif    786                                      rangeShifterYSize,
787                                      rangeShif    787                                      rangeShifterZSize);
788                                                   788     
789     logicRangeShifterBox = new G4LogicalVolume    789     logicRangeShifterBox = new G4LogicalVolume(solidRangeShifterBox,
790                                                   790                                                rangeShifterMaterial,
791                                                   791                                                "RangeShifterBox");
792     physiRangeShifterBox = new G4PVPlacement(0    792     physiRangeShifterBox = new G4PVPlacement(0,
793                                              G    793                                              G4ThreeVector(rangeShifterXPosition, 0., 0.),
794                                              "    794                                              "RangeShifterBox",
795                                              l    795                                              logicRangeShifterBox,
796                                              p    796                                              physicalTreatmentRoom,
797                                              f    797                                              false,
798                                              0    798                                              0);
799                                                   799     
800                                                   800     
801     logicRangeShifterBox -> SetVisAttributes(y    801     logicRangeShifterBox -> SetVisAttributes(yellow);
802                                                   802      
803                                                   803     
804 }                                                 804 }
805 //////////////////////////////////////////////    805 /////////////////////////////////////////////////////////////////////////////
806 void PassiveProtonBeamLine::HadrontherapyBeamC    806 void PassiveProtonBeamLine::HadrontherapyBeamCollimators()
807 {                                                 807 {
808                                                   808     
809                                                   809     
810     // -----------------//                        810     // -----------------//
811     // FIRST COLLIMATOR //                        811     // FIRST COLLIMATOR //
812     // -----------------//                        812     // -----------------//
813     // It is a slab of PMMA with an hole in it    813     // It is a slab of PMMA with an hole in its center
814     const G4double firstCollimatorXSize = 20.*    814     const G4double firstCollimatorXSize = 20.*mm;
815     const G4double firstCollimatorYSize = 100.    815     const G4double firstCollimatorYSize = 100.*mm;
816     const G4double firstCollimatorZSize = 100.    816     const G4double firstCollimatorZSize = 100.*mm;
817                                                   817     
818     const G4double firstCollimatorXPosition =     818     const G4double firstCollimatorXPosition = -2673.00*mm;
819     const G4double firstCollimatorYPosition =     819     const G4double firstCollimatorYPosition = 0.*mm;
820     const G4double firstCollimatorZPosition =     820     const G4double firstCollimatorZPosition = 0.*mm;
821                                                   821     
822                                                   822     
823     G4Box* solidFirstCollimator = new G4Box("F    823     G4Box* solidFirstCollimator = new G4Box("FirstCollimator",
824                                             fi    824                                             firstCollimatorXSize,
825                                             fi    825                                             firstCollimatorYSize,
826                                             fi    826                                             firstCollimatorZSize);
827                                                   827     
828     G4LogicalVolume* logicFirstCollimator = ne    828     G4LogicalVolume* logicFirstCollimator = new G4LogicalVolume(solidFirstCollimator,
829                                                   829                                                                 firstCollimatorMaterial,
830                                                   830                                                                 "FirstCollimator");
831                                                   831     
832     physiFirstCollimator = new G4PVPlacement(0    832     physiFirstCollimator = new G4PVPlacement(0, G4ThreeVector(firstCollimatorXPosition,
833                                                   833                                                               firstCollimatorYPosition,
834                                                   834                                                               firstCollimatorZPosition),
835                                              "    835                                              "FirstCollimator",
836                                              l    836                                              logicFirstCollimator,
837                                              p    837                                              physicalTreatmentRoom,
838                                              f    838                                              false,
839                                              0    839                                              0);
840     // ----------------------------//             840     // ----------------------------//
841     // Hole of the first collimator//             841     // Hole of the first collimator//
842     //-----------------------------//             842     //-----------------------------//
843     G4double innerRadiusHoleFirstCollimator       843     G4double innerRadiusHoleFirstCollimator   = 0.*mm;
844     G4double outerRadiusHoleFirstCollimator       844     G4double outerRadiusHoleFirstCollimator   = 15.*mm;
845     G4double hightHoleFirstCollimator             845     G4double hightHoleFirstCollimator         = 20.*mm;
846     G4double startAngleHoleFirstCollimator        846     G4double startAngleHoleFirstCollimator    = 0.*deg;
847     G4double spanningAngleHoleFirstCollimator     847     G4double spanningAngleHoleFirstCollimator = 360.*deg;
848                                                   848     
849     G4Tubs* solidHoleFirstCollimator = new G4T    849     G4Tubs* solidHoleFirstCollimator = new G4Tubs("HoleFirstCollimator",
850                                                   850                                                   innerRadiusHoleFirstCollimator,
851                                                   851                                                   outerRadiusHoleFirstCollimator,
852                                                   852                                                   hightHoleFirstCollimator,
853                                                   853                                                   startAngleHoleFirstCollimator,
854                                                   854                                                   spanningAngleHoleFirstCollimator);
855                                                   855     
856     G4LogicalVolume* logicHoleFirstCollimator     856     G4LogicalVolume* logicHoleFirstCollimator = new G4LogicalVolume(solidHoleFirstCollimator,
857                                                   857                                                                     holeFirstCollimatorMaterial,
858                                                   858                                                                     "HoleFirstCollimator",
859                                                   859                                                                     0, 0, 0);
860     G4double phi = 90. *deg;                      860     G4double phi = 90. *deg;
861     // Matrix definition for a 90 deg rotation    861     // Matrix definition for a 90 deg rotation. Also used for other volumes
862     G4RotationMatrix rm;                          862     G4RotationMatrix rm;
863     rm.rotateY(phi);                              863     rm.rotateY(phi);
864                                                   864     
865     physiHoleFirstCollimator = new G4PVPlaceme    865     physiHoleFirstCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
866                                                   866                                                  "HoleFirstCollimator",
867                                                   867                                                  logicHoleFirstCollimator,
868                                                   868                                                  physiFirstCollimator,
869                                                   869                                                  false,
870                                                   870                                                  0);
871     // ------------------//                       871     // ------------------//
872     // SECOND COLLIMATOR //                       872     // SECOND COLLIMATOR //
873     //-------------------//                       873     //-------------------//
874     // It is a slab of PMMA with an hole in it    874     // It is a slab of PMMA with an hole in its center
875     const G4double secondCollimatorXPosition =    875     const G4double secondCollimatorXPosition = -1900.00*mm;
876     const G4double secondCollimatorYPosition =    876     const G4double secondCollimatorYPosition =  0*mm;
877     const G4double secondCollimatorZPosition =    877     const G4double secondCollimatorZPosition =  0*mm;
878                                                   878     
879     physiSecondCollimator = new G4PVPlacement(    879     physiSecondCollimator = new G4PVPlacement(0, G4ThreeVector(secondCollimatorXPosition,
880                                                   880                                                                secondCollimatorYPosition,
881                                                   881                                                                secondCollimatorZPosition),
882                                                   882                                               "SecondCollimator",
883                                                   883                                               logicFirstCollimator,
884                                                   884                                               physicalTreatmentRoom,
885                                                   885                                               false,
886                                                   886                                               0);
887                                                   887     
888     // ------------------------------//           888     // ------------------------------//
889     // Hole of the second collimator //           889     // Hole of the second collimator //
890     // ------------------------------//           890     // ------------------------------//
891     physiHoleSecondCollimator = new G4PVPlacem    891     physiHoleSecondCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
892                                                   892                                                   "HoleSecondCollimator",
893                                                   893                                                   logicHoleFirstCollimator,
894                                                   894                                                   physiSecondCollimator,
895                                                   895                                                   false,
896                                                   896                                                   0);
897                                                   897     
898     // --------------------------------------/    898     // --------------------------------------//
899     // FIRST SIDE OF THE MODULATOR BOX      //    899     // FIRST SIDE OF THE MODULATOR BOX      //
900     // --------------------------------------/    900     // --------------------------------------//
901     // The modulator box is an aluminum box in    901     // The modulator box is an aluminum box in which
902     // the range shifter and the energy modula    902     // the range shifter and the energy modulator are located
903     // In this example only the entrance and e    903     // In this example only the entrance and exit
904     // faces of the box are simulated.            904     // faces of the box are simulated.
905     // Each face is an aluminum slab with an h    905     // Each face is an aluminum slab with an hole in its center
906                                                   906     
907     const G4double firstCollimatorModulatorXSi    907     const G4double firstCollimatorModulatorXSize = 10.*mm;
908     const G4double firstCollimatorModulatorYSi    908     const G4double firstCollimatorModulatorYSize = 200.*mm;
909     const G4double firstCollimatorModulatorZSi    909     const G4double firstCollimatorModulatorZSize = 200.*mm;
910                                                   910     
911     const G4double firstCollimatorModulatorXPo    911     const G4double firstCollimatorModulatorXPosition = -2523.00*mm;
912     const G4double firstCollimatorModulatorYPo    912     const G4double firstCollimatorModulatorYPosition = 0.*mm;
913     const G4double firstCollimatorModulatorZPo    913     const G4double firstCollimatorModulatorZPosition = 0.*mm;
914                                                   914     
915    G4Box* solidFirstCollimatorModulatorBox = n    915    G4Box* solidFirstCollimatorModulatorBox = new G4Box("FirstCollimatorModulatorBox",
916                                                   916                                                         firstCollimatorModulatorXSize,
917                                                   917                                                         firstCollimatorModulatorYSize,
918                                                   918                                                         firstCollimatorModulatorZSize);
919                                                   919     
920     G4LogicalVolume* logicFirstCollimatorModul    920     G4LogicalVolume* logicFirstCollimatorModulatorBox = new G4LogicalVolume(solidFirstCollimatorModulatorBox,
921                                                   921                                                                             modulatorBoxMaterial,
922                                                   922                                                                             "FirstCollimatorModulatorBox");
923                                                   923     
924     physiFirstCollimatorModulatorBox = new G4P    924     physiFirstCollimatorModulatorBox = new G4PVPlacement(0, G4ThreeVector(firstCollimatorModulatorXPosition,
925                                                   925                                                                           firstCollimatorModulatorYPosition,
926                                                   926                                                                           firstCollimatorModulatorZPosition),
927                                                   927                                                          "FirstCollimatorModulatorBox",
928                                                   928                                                          logicFirstCollimatorModulatorBox,
929                                                   929                                                          physicalTreatmentRoom, false, 0);
930                                                   930     
931     // ---------------------------------------    931     // ----------------------------------------------------//
932     //   Hole of the first collimator of the m    932     //   Hole of the first collimator of the modulator box //
933     // ---------------------------------------    933     // ----------------------------------------------------//
934     const G4double innerRadiusHoleFirstCollima    934     const G4double innerRadiusHoleFirstCollimatorModulatorBox = 0.*mm;
935     const G4double outerRadiusHoleFirstCollima    935     const G4double outerRadiusHoleFirstCollimatorModulatorBox = 31.*mm;
936     const G4double hightHoleFirstCollimatorMod    936     const G4double hightHoleFirstCollimatorModulatorBox = 10.*mm;
937     const G4double startAngleHoleFirstCollimat    937     const G4double startAngleHoleFirstCollimatorModulatorBox = 0.*deg;
938     const G4double spanningAngleHoleFirstColli    938     const G4double spanningAngleHoleFirstCollimatorModulatorBox = 360.*deg;
939                                                   939     
940     G4Tubs* solidHoleFirstCollimatorModulatorB    940     G4Tubs* solidHoleFirstCollimatorModulatorBox  = new G4Tubs("HoleFirstCollimatorModulatorBox",
941                                                   941                                                                innerRadiusHoleFirstCollimatorModulatorBox,
942                                                   942                                                                outerRadiusHoleFirstCollimatorModulatorBox,
943                                                   943                                                                hightHoleFirstCollimatorModulatorBox ,
944                                                   944                                                                startAngleHoleFirstCollimatorModulatorBox,
945                                                   945                                                                spanningAngleHoleFirstCollimatorModulatorBox);
946                                                   946     
947     G4LogicalVolume* logicHoleFirstCollimatorM    947     G4LogicalVolume* logicHoleFirstCollimatorModulatorBox = new G4LogicalVolume(solidHoleFirstCollimatorModulatorBox,
948                                                   948                                                                                 holeModulatorBoxMaterial,
949                                                   949                                                                                 "HoleFirstCollimatorModulatorBox",
950                                                   950                                                                                 0, 0, 0);
951                                                   951     
952     physiHoleFirstCollimatorModulatorBox = new    952     physiHoleFirstCollimatorModulatorBox = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
953                                                   953                                                              "HoleFirstCollimatorModulatorBox",
954                                                   954                                                              logicHoleFirstCollimatorModulatorBox,
955                                                   955                                                              physiFirstCollimatorModulatorBox, false, 0);
956                                                   956     
957     // ---------------------------------------    957     // --------------------------------------------------//
958     //       SECOND SIDE OF THE MODULATOR BOX     958     //       SECOND SIDE OF THE MODULATOR BOX            //
959     // ---------------------------------------    959     // --------------------------------------------------//
960     const G4double secondCollimatorModulatorXS    960     const G4double secondCollimatorModulatorXSize = 10.*mm;
961     const G4double secondCollimatorModulatorYS    961     const G4double secondCollimatorModulatorYSize = 200.*mm;
962     const G4double secondCollimatorModulatorZS    962     const G4double secondCollimatorModulatorZSize = 200.*mm;
963                                                   963     
964     const G4double secondCollimatorModulatorXP    964     const G4double secondCollimatorModulatorXPosition = -1953.00 *mm;
965                                                   965     
966     const G4double secondCollimatorModulatorYP    966     const G4double secondCollimatorModulatorYPosition = 0.*mm;
967     const G4double secondCollimatorModulatorZP    967     const G4double secondCollimatorModulatorZPosition = 0.*mm;
968                                                   968     
969     G4Box* solidSecondCollimatorModulatorBox =    969     G4Box* solidSecondCollimatorModulatorBox = new G4Box("SecondCollimatorModulatorBox",
970                                                   970                                                          secondCollimatorModulatorXSize,
971                                                   971                                                          secondCollimatorModulatorYSize,
972                                                   972                                                          secondCollimatorModulatorZSize);
973                                                   973     
974     G4LogicalVolume* logicSecondCollimatorModu    974     G4LogicalVolume* logicSecondCollimatorModulatorBox = new G4LogicalVolume(solidSecondCollimatorModulatorBox,
975                                                   975                                                                              modulatorBoxMaterial,
976                                                   976                                                                              "SecondCollimatorModulatorBox");
977                                                   977     
978     physiSecondCollimatorModulatorBox = new G4    978     physiSecondCollimatorModulatorBox = new G4PVPlacement(0, G4ThreeVector(secondCollimatorModulatorXPosition,
979                                                   979                                                                            secondCollimatorModulatorYPosition,
980                                                   980                                                                            secondCollimatorModulatorZPosition),
981                                                   981                                                           "SecondCollimatorModulatorBox",
982                                                   982                                                           logicSecondCollimatorModulatorBox,
983                                                   983                                                           physicalTreatmentRoom, false, 0);
984                                                   984     
985     // ---------------------------------------    985     // ----------------------------------------------//
986     //   Hole of the second collimator modulat    986     //   Hole of the second collimator modulator box //
987     // ---------------------------------------    987     // ----------------------------------------------//
988     const G4double innerRadiusHoleSecondCollim    988     const G4double innerRadiusHoleSecondCollimatorModulatorBox = 0.*mm;
989     const G4double outerRadiusHoleSecondCollim    989     const G4double outerRadiusHoleSecondCollimatorModulatorBox = 31.*mm;
990     const G4double hightHoleSecondCollimatorMo    990     const G4double hightHoleSecondCollimatorModulatorBox = 10.*mm;
991     const G4double startAngleHoleSecondCollima    991     const G4double startAngleHoleSecondCollimatorModulatorBox = 0.*deg;
992     const G4double spanningAngleHoleSecondColl    992     const G4double spanningAngleHoleSecondCollimatorModulatorBox = 360.*deg;
993                                                   993     
994     G4Tubs* solidHoleSecondCollimatorModulator    994     G4Tubs* solidHoleSecondCollimatorModulatorBox  = new G4Tubs("HoleSecondCollimatorModulatorBox",
995                                                   995                                                                 innerRadiusHoleSecondCollimatorModulatorBox,
996                                                   996                                                                 outerRadiusHoleSecondCollimatorModulatorBox,
997                                                   997                                                                 hightHoleSecondCollimatorModulatorBox ,
998                                                   998                                                                 startAngleHoleSecondCollimatorModulatorBox,
999                                                   999                                                                 spanningAngleHoleSecondCollimatorModulatorBox);
1000                                                  1000     
1001     G4LogicalVolume* logicHoleSecondCollimato    1001     G4LogicalVolume* logicHoleSecondCollimatorModulatorBox = new G4LogicalVolume(solidHoleSecondCollimatorModulatorBox,
1002                                                  1002                                                                                  holeModulatorBoxMaterial,
1003                                                  1003                                                                                  "HoleSecondCollimatorModulatorBox",
1004                                                  1004                                                                                  0, 0, 0);
1005                                                  1005     
1006     physiHoleSecondCollimatorModulatorBox = n    1006     physiHoleSecondCollimatorModulatorBox = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
1007                                                  1007                                                               "HoleSecondCollimatorModulatorBox",
1008                                                  1008                                                               logicHoleSecondCollimatorModulatorBox,
1009                                                  1009                                                               physiSecondCollimatorModulatorBox, false, 0);
1010                                                  1010     
1011     logicFirstCollimator -> SetVisAttributes(    1011     logicFirstCollimator -> SetVisAttributes(yellow);
1012     logicFirstCollimatorModulatorBox -> SetVi    1012     logicFirstCollimatorModulatorBox -> SetVisAttributes(blue);
1013     logicSecondCollimatorModulatorBox -> SetV    1013     logicSecondCollimatorModulatorBox -> SetVisAttributes(blue);
1014                                                  1014 
1015                                                  1015 
1016                                                  1016   
1017   }                                              1017   }
1018                                                  1018 
1019 /////////////////////////////////////////////    1019 /////////////////////////////////////////////////////////////////////////////
1020 void PassiveProtonBeamLine::HadrontherapyBeam    1020 void PassiveProtonBeamLine::HadrontherapyBeamMonitoring()
1021 {                                                1021 {
1022     // ----------------------------              1022     // ----------------------------
1023     //   THE FIRST MONITOR CHAMBER               1023     //   THE FIRST MONITOR CHAMBER
1024     // ----------------------------              1024     // ----------------------------
1025     // A monitor chamber is a free-air  ionis    1025     // A monitor chamber is a free-air  ionisation chamber
1026     // able to measure do proton fluence duri    1026     // able to measure do proton fluence during the treatment.
1027     // Here its responce is not simulated in     1027     // Here its responce is not simulated in terms of produced
1028     // charge but only the energy losses are     1028     // charge but only the energy losses are taked into account.
1029     // Each chamber consist of 9 mm of air in    1029     // Each chamber consist of 9 mm of air in a box
1030     // that has two layers one of kapton and     1030     // that has two layers one of kapton and one
1031     // of copper                                 1031     // of copper
1032     const G4double monitor1XSize = 4.525022*m    1032     const G4double monitor1XSize = 4.525022*mm;
1033     const G4double monitor2XSize = 0.000011*m    1033     const G4double monitor2XSize = 0.000011*mm;
1034     const G4double monitor3XSize = 4.5*mm;       1034     const G4double monitor3XSize = 4.5*mm;
1035     const G4double monitorYSize = 10.*cm;        1035     const G4double monitorYSize = 10.*cm;
1036     const G4double monitorZSize = 10.*cm;        1036     const G4double monitorZSize = 10.*cm;
1037     const G4double monitor1XPosition = -1262.    1037     const G4double monitor1XPosition = -1262.47498 *mm;
1038     const G4double monitor2XPosition = -4.500    1038     const G4double monitor2XPosition = -4.500011*mm;
1039     const G4double monitor4XPosition = 4.5000    1039     const G4double monitor4XPosition = 4.500011*mm;
1040                                                  1040   
1041                                                  1041     
1042                                                  1042 
1043     G4Box* solidFirstMonitorLayer1 = new G4Bo    1043     G4Box* solidFirstMonitorLayer1 = new G4Box("FirstMonitorLayer1",
1044                                                  1044                                                monitor1XSize,
1045                                                  1045                                                monitorYSize,
1046                                                  1046                                                monitorZSize);
1047                                                  1047     
1048     G4LogicalVolume* logicFirstMonitorLayer1     1048     G4LogicalVolume* logicFirstMonitorLayer1 = new G4LogicalVolume(solidFirstMonitorLayer1,
1049                                                  1049                                                                    layer1MonitorChamberMaterial,
1050                                                  1050                                                                    "FirstMonitorLayer1");
1051                                                  1051     
1052     physiFirstMonitorLayer1 = new G4PVPlaceme    1052     physiFirstMonitorLayer1 = new G4PVPlacement(0,
1053                                                  1053                                                 G4ThreeVector(monitor1XPosition,0.*cm,0.*cm),
1054                                                  1054                                                 "FirstMonitorLayer1",
1055                                                  1055                                                 logicFirstMonitorLayer1,
1056                                                  1056                                                 physicalTreatmentRoom,
1057                                                  1057                                                 false,
1058                                                  1058                                                 0);
1059                                                  1059     
1060     G4Box* solidFirstMonitorLayer2 = new G4Bo    1060     G4Box* solidFirstMonitorLayer2 = new G4Box("FirstMonitorLayer2",
1061                                                  1061                                                monitor2XSize,
1062                                                  1062                                                monitorYSize,
1063                                                  1063                                                monitorZSize);
1064                                                  1064     
1065     G4LogicalVolume* logicFirstMonitorLayer2     1065     G4LogicalVolume* logicFirstMonitorLayer2 = new G4LogicalVolume(solidFirstMonitorLayer2,
1066                                                  1066                                                                    layer2MonitorChamberMaterial,
1067                                                  1067                                                                    "FirstMonitorLayer2");
1068                                                  1068     
1069     physiFirstMonitorLayer2 = new G4PVPlaceme    1069     physiFirstMonitorLayer2 = new G4PVPlacement(0, G4ThreeVector(monitor2XPosition,0.*cm,0.*cm),
1070                                                  1070                                                 "FirstMonitorLayer2",
1071                                                  1071                                                 logicFirstMonitorLayer2,
1072                                                  1072                                                 physiFirstMonitorLayer1,
1073                                                  1073                                                 false,
1074                                                  1074                                                 0);
1075                                                  1075     
1076     G4Box* solidFirstMonitorLayer3 = new G4Bo    1076     G4Box* solidFirstMonitorLayer3 = new G4Box("FirstMonitorLayer3",
1077                                                  1077                                                monitor3XSize,
1078                                                  1078                                                monitorYSize,
1079                                                  1079                                                monitorZSize);
1080                                                  1080     
1081     G4LogicalVolume* logicFirstMonitorLayer3     1081     G4LogicalVolume* logicFirstMonitorLayer3 = new G4LogicalVolume(solidFirstMonitorLayer3,
1082                                                  1082                                                                    layer3MonitorChamberMaterial,
1083                                                  1083                                                                    "FirstMonitorLayer3");
1084                                                  1084     
1085     physiFirstMonitorLayer3 = new G4PVPlaceme    1085     physiFirstMonitorLayer3 = new G4PVPlacement(0,
1086                                                  1086                                                 G4ThreeVector(0.*mm,0.*cm,0.*cm),
1087                                                  1087                                                 "MonitorLayer3",
1088                                                  1088                                                 logicFirstMonitorLayer3,
1089                                                  1089                                                 physiFirstMonitorLayer1,
1090                                                  1090                                                 false,
1091                                                  1091                                                 0);
1092                                                  1092     
1093     G4Box* solidFirstMonitorLayer4 = new G4Bo    1093     G4Box* solidFirstMonitorLayer4 = new G4Box("FirstMonitorLayer4",
1094                                                  1094                                                monitor2XSize,
1095                                                  1095                                                monitorYSize,
1096                                                  1096                                                monitorZSize);
1097                                                  1097     
1098     G4LogicalVolume* logicFirstMonitorLayer4     1098     G4LogicalVolume* logicFirstMonitorLayer4 = new G4LogicalVolume(solidFirstMonitorLayer4,
1099                                                  1099                                                                    layer4MonitorChamberMaterial,
1100                                                  1100                                                                    "FirstMonitorLayer4");
1101                                                  1101     
1102     physiFirstMonitorLayer4 = new G4PVPlaceme    1102     physiFirstMonitorLayer4 = new G4PVPlacement(0, G4ThreeVector(monitor4XPosition,0.*cm,0.*cm),
1103                                                  1103                                                 "FirstMonitorLayer4",
1104                                                  1104                                                 logicFirstMonitorLayer4,
1105                                                  1105                                                 physiFirstMonitorLayer1, false, 0);
1106     // ----------------------------//            1106     // ----------------------------//
1107     // THE SECOND MONITOR CHAMBER  //            1107     // THE SECOND MONITOR CHAMBER  //
1108     // ----------------------------//            1108     // ----------------------------//
1109     physiSecondMonitorLayer1 = new G4PVPlacem    1109     physiSecondMonitorLayer1 = new G4PVPlacement(0, G4ThreeVector(-1131.42493 *mm,0.*cm,0.*cm),
1110                                                  1110                                                  "SecondMonitorLayer1", logicFirstMonitorLayer1,physicalTreatmentRoom, false, 0);
1111                                                  1111     
1112     physiSecondMonitorLayer2 = new G4PVPlacem    1112     physiSecondMonitorLayer2 = new G4PVPlacement(0, G4ThreeVector( monitor2XPosition,0.*cm,0.*cm), "SecondMonitorLayer2",
1113                                                  1113                                                  logicFirstMonitorLayer2, physiSecondMonitorLayer1, false, 0);
1114                                                  1114     
1115     physiSecondMonitorLayer3 = new G4PVPlacem    1115     physiSecondMonitorLayer3 = new G4PVPlacement(0, G4ThreeVector(0.*mm,0.*cm,0.*cm), "MonitorLayer3",
1116                                                  1116                                                  logicFirstMonitorLayer3, physiSecondMonitorLayer1, false, 0);
1117                                                  1117     
1118     physiSecondMonitorLayer4 = new G4PVPlacem    1118     physiSecondMonitorLayer4 = new G4PVPlacement(0, G4ThreeVector(monitor4XPosition,0.*cm,0.*cm), "SecondMonitorLayer4",
1119                                                  1119                                                  logicFirstMonitorLayer4, physiSecondMonitorLayer1, false, 0);
1120                                                  1120     
1121     logicFirstMonitorLayer3 -> SetVisAttribut    1121     logicFirstMonitorLayer3 -> SetVisAttributes(white);
1122                                                  1122     
1123                                                  1123 
1124                                                  1124     
1125      }                                           1125      }
1126 /////////////////////////////////////////////    1126 /////////////////////////////////////////////////////////////////////////////
1127 void PassiveProtonBeamLine::HadrontherapyMOPI    1127 void PassiveProtonBeamLine::HadrontherapyMOPIDetector()
1128 {                                                1128 {
1129                                                  1129 
1130     // --------------------------------//        1130     // --------------------------------//
1131     //        THE MOPI DETECTOR        //        1131     //        THE MOPI DETECTOR        //
1132     // --------------------------------//        1132     // --------------------------------//
1133     // MOPI DETECTOR: two orthogonal microstr    1133     // MOPI DETECTOR: two orthogonal microstrip gas detectors developed
1134     // by the INFN Section of Turin in collab    1134     // by the INFN Section of Turin in collaboration with some
1135     // of the author of this example. It perm    1135     // of the author of this example. It permits the
1136     // on-line check of the beam simmetry via    1136     // on-line check of the beam simmetry via the signal
1137     // integration of the collected charge fo    1137     // integration of the collected charge for each strip.
1138     //                                           1138     //
1139     // In this example it is simulated as:       1139     // In this example it is simulated as:
1140     // 1. First anode: 35 mu of kapton + 15 m    1140     // 1. First anode: 35 mu of kapton + 15 mu of aluminum,
1141     // 2. First air gap: 6 mm of air,            1141     // 2. First air gap: 6 mm of air,
1142     // 3. The cathode: 1 mu Al + 25 mu mylar     1142     // 3. The cathode: 1 mu Al + 25 mu mylar + 1 mu Al
1143     //    (in common with the two air gap),      1143     //    (in common with the two air gap),
1144     // 4. Second air gap: 6 mm of air,           1144     // 4. Second air gap: 6 mm of air,
1145     // 5  Second anode: 15 mu Al + 35 mu kapt    1145     // 5  Second anode: 15 mu Al + 35 mu kapton
1146     // Color used in the graphical output        1146     // Color used in the graphical output
1147                                                  1147     
1148                                                  1148     
1149     // Mother volume                             1149     // Mother volume
1150     solidMOPIMotherVolume = new G4Box("MOPIMo    1150     solidMOPIMotherVolume = new G4Box("MOPIMotherVolume",
1151                                       MOPIMot    1151                                       MOPIMotherVolumeXSize/2,
1152                                       MOPIMot    1152                                       MOPIMotherVolumeYSize/2,
1153                                       MOPIMot    1153                                       MOPIMotherVolumeYSize/2);
1154                                                  1154     
1155     logicMOPIMotherVolume = new G4LogicalVolu    1155     logicMOPIMotherVolume = new G4LogicalVolume(solidMOPIMotherVolume,
1156                                                  1156                                                 MOPIMotherVolumeMaterial,
1157                                                  1157                                                 "MOPIMotherVolume");
1158     physiMOPIMotherVolume = new G4PVPlacement    1158     physiMOPIMotherVolume = new G4PVPlacement(0,
1159                                                  1159                                               G4ThreeVector(MOPIMotherVolumeXPosition,
1160                                                  1160                                                             MOPIMotherVolumeYPosition,
1161                                                  1161                                                             MOPIMotherVolumeZPosition),
1162                                                  1162                                               "MOPIMotherVolume",
1163                                                  1163                                               logicMOPIMotherVolume,
1164                                                  1164                                               physicalTreatmentRoom,
1165                                                  1165                                               false,
1166                                                  1166                                               0);
1167                                                  1167     
1168     // First Kapton layer                        1168     // First Kapton layer
1169     solidMOPIFirstKaptonLayer = new G4Box("MO    1169     solidMOPIFirstKaptonLayer = new G4Box("MOPIFirstKaptonLayer",
1170                                           MOP    1170                                           MOPIFirstKaptonLayerXSize/2,
1171                                           MOP    1171                                           MOPIFirstKaptonLayerYSize/2 ,
1172                                           MOP    1172                                           MOPIFirstKaptonLayerZSize/2);
1173                                                  1173     
1174     logicMOPIFirstKaptonLayer = new G4Logical    1174     logicMOPIFirstKaptonLayer = new G4LogicalVolume(solidMOPIFirstKaptonLayer,
1175                                                  1175                                                     MOPIFirstKaptonLayerMaterial,
1176                                                  1176                                                     "MOPIFirstKaptonLayer");
1177                                                  1177     
1178     physiMOPIFirstKaptonLayer = new G4PVPlace    1178     physiMOPIFirstKaptonLayer = new G4PVPlacement(0,
1179                                                  1179                                                   G4ThreeVector(MOPIFirstKaptonLayerXPosition,
1180                                                  1180                                                                 MOPIFirstKaptonLayerYPosition ,
1181                                                  1181                                                                 MOPIFirstKaptonLayerZPosition),
1182                                                  1182                                                   "MOPIFirstKaptonLayer",
1183                                                  1183                                                   logicMOPIFirstKaptonLayer,
1184                                                  1184                                                   physiMOPIMotherVolume,
1185                                                  1185                                                   false,
1186                                                  1186                                                   0);
1187                                                  1187     
1188     // First Aluminum layer                      1188     // First Aluminum layer
1189     solidMOPIFirstAluminumLayer = new G4Box("    1189     solidMOPIFirstAluminumLayer = new G4Box("MOPIFirstAluminumLayer",
1190                                             M    1190                                             MOPIFirstAluminumLayerXSize/2,
1191                                             M    1191                                             MOPIFirstAluminumLayerYSize/2 ,
1192                                             M    1192                                             MOPIFirstAluminumLayerZSize/2);
1193                                                  1193     
1194     logicMOPIFirstAluminumLayer = new G4Logic    1194     logicMOPIFirstAluminumLayer = new G4LogicalVolume(solidMOPIFirstAluminumLayer,
1195                                                  1195                                                       MOPIFirstAluminumLayerMaterial,
1196                                                  1196                                                       "MOPIFirstAluminumLayer");
1197                                                  1197     
1198     physiMOPIFirstAluminumLayer = new G4PVPla    1198     physiMOPIFirstAluminumLayer = new G4PVPlacement(0,
1199                                                  1199                                                     G4ThreeVector(MOPIFirstAluminumLayerXPosition,
1200                                                  1200                                                                   MOPIFirstAluminumLayerYPosition ,
1201                                                  1201                                                                   MOPIFirstAluminumLayerZPosition),
1202                                                  1202                                                     "MOPIFirstAluminumLayer",
1203                                                  1203                                                     logicMOPIFirstAluminumLayer, physiMOPIMotherVolume, false, 0);
1204                                                  1204     
1205     // First Air GAP                             1205     // First Air GAP
1206     solidMOPIFirstAirGap = new G4Box("MOPIFir    1206     solidMOPIFirstAirGap = new G4Box("MOPIFirstAirGap",
1207                                      MOPIFirs    1207                                      MOPIFirstAirGapXSize/2,
1208                                      MOPIFirs    1208                                      MOPIFirstAirGapYSize/2,
1209                                      MOPIFirs    1209                                      MOPIFirstAirGapZSize/2);
1210                                                  1210     
1211     logicMOPIFirstAirGap = new G4LogicalVolum    1211     logicMOPIFirstAirGap = new G4LogicalVolume(solidMOPIFirstAirGap,
1212                                                  1212                                                MOPIFirstAirGapMaterial,
1213                                                  1213                                                "MOPIFirstAirgap");
1214                                                  1214     
1215     physiMOPIFirstAirGap = new G4PVPlacement(    1215     physiMOPIFirstAirGap = new G4PVPlacement(0,
1216                                                  1216                                              G4ThreeVector(MOPIFirstAirGapXPosition,
1217                                                  1217                                                            MOPIFirstAirGapYPosition ,
1218                                                  1218                                                            MOPIFirstAirGapZPosition),
1219                                                  1219                                              "MOPIFirstAirGap",
1220                                                  1220                                              logicMOPIFirstAirGap, physiMOPIMotherVolume, false, 0);
1221                                                  1221     
1222                                                  1222     
1223     // The Cathode                               1223     // The Cathode
1224     solidMOPICathode = new G4Box("MOPICathode    1224     solidMOPICathode = new G4Box("MOPICathode",
1225                                  MOPICathodeX    1225                                  MOPICathodeXSize/2,
1226                                  MOPICathodeY    1226                                  MOPICathodeYSize/2,
1227                                  MOPICathodeZ    1227                                  MOPICathodeZSize/2);
1228                                                  1228     
1229     logicMOPICathode = new G4LogicalVolume(so    1229     logicMOPICathode = new G4LogicalVolume(solidMOPICathode,
1230                                            MO    1230                                            MOPICathodeMaterial,
1231                                            "M    1231                                            "MOPICathode");
1232                                                  1232     
1233     physiMOPICathode = new G4PVPlacement(0,      1233     physiMOPICathode = new G4PVPlacement(0,
1234                                          G4Th    1234                                          G4ThreeVector(MOPICathodeXPosition,
1235                                                  1235                                                        MOPICathodeYPosition ,
1236                                                  1236                                                        MOPICathodeZPosition),
1237                                          "MOP    1237                                          "MOPICathode",
1238                                          logi    1238                                          logicMOPICathode,
1239                                          phys    1239                                          physiMOPIMotherVolume, false, 0);
1240                                                  1240     
1241     // Second Air GAP                            1241     // Second Air GAP
1242     solidMOPISecondAirGap = new G4Box("MOPISe    1242     solidMOPISecondAirGap = new G4Box("MOPISecondAirGap",
1243                                       MOPISec    1243                                       MOPISecondAirGapXSize/2,
1244                                       MOPISec    1244                                       MOPISecondAirGapYSize/2,
1245                                       MOPISec    1245                                       MOPISecondAirGapZSize/2);
1246                                                  1246     
1247     logicMOPISecondAirGap = new G4LogicalVolu    1247     logicMOPISecondAirGap = new G4LogicalVolume(solidMOPISecondAirGap,
1248                                                  1248                                                 MOPISecondAirGapMaterial,
1249                                                  1249                                                 "MOPISecondAirgap");
1250                                                  1250     
1251     physiMOPISecondAirGap = new G4PVPlacement    1251     physiMOPISecondAirGap = new G4PVPlacement(0,
1252                                                  1252                                               G4ThreeVector(MOPISecondAirGapXPosition,
1253                                                  1253                                                             MOPISecondAirGapYPosition ,
1254                                                  1254                                                             MOPISecondAirGapZPosition),
1255                                                  1255                                               "MOPISecondAirGap",
1256                                                  1256                                               logicMOPISecondAirGap, physiMOPIMotherVolume, false, 0);
1257                                                  1257     
1258     // Second Aluminum layer                     1258     // Second Aluminum layer
1259     solidMOPISecondAluminumLayer = new G4Box(    1259     solidMOPISecondAluminumLayer = new G4Box("MOPISecondAluminumLayer",
1260                                                  1260                                              MOPISecondAluminumLayerXSize/2,
1261                                                  1261                                              MOPISecondAluminumLayerYSize/2 ,
1262                                                  1262                                              MOPISecondAluminumLayerZSize/2);
1263                                                  1263     
1264     logicMOPISecondAluminumLayer = new G4Logi    1264     logicMOPISecondAluminumLayer = new G4LogicalVolume(solidMOPISecondAluminumLayer,
1265                                                  1265                                                        MOPISecondAluminumLayerMaterial,
1266                                                  1266                                                        "MOPISecondAluminumLayer");
1267                                                  1267     
1268     physiMOPISecondAluminumLayer = new G4PVPl    1268     physiMOPISecondAluminumLayer = new G4PVPlacement(0,
1269                                                  1269                                                      G4ThreeVector(MOPISecondAluminumLayerXPosition,
1270                                                  1270                                                                    MOPISecondAluminumLayerYPosition ,
1271                                                  1271                                                                    MOPISecondAluminumLayerZPosition),
1272                                                  1272                                                      "MOPISecondAluminumLayer",
1273                                                  1273                                                      logicMOPISecondAluminumLayer,
1274                                                  1274                                                      physiMOPIMotherVolume,
1275                                                  1275                                                      false,
1276                                                  1276                                                      0);
1277                                                  1277     
1278     // Second Kapton layer                       1278     // Second Kapton layer
1279     solidMOPISecondKaptonLayer = new G4Box("M    1279     solidMOPISecondKaptonLayer = new G4Box("MOPISecondKaptonLayer",
1280                                            MO    1280                                            MOPISecondKaptonLayerXSize/2,
1281                                            MO    1281                                            MOPISecondKaptonLayerYSize/2 ,
1282                                            MO    1282                                            MOPISecondKaptonLayerZSize/2);
1283                                                  1283     
1284     logicMOPISecondKaptonLayer = new G4Logica    1284     logicMOPISecondKaptonLayer = new G4LogicalVolume(solidMOPISecondKaptonLayer,
1285                                                  1285                                                      MOPIFirstKaptonLayerMaterial,
1286                                                  1286                                                      "MOPISecondKaptonLayer");
1287                                                  1287     
1288     physiMOPISecondKaptonLayer = new G4PVPlac    1288     physiMOPISecondKaptonLayer = new G4PVPlacement(0,
1289                                                  1289                                                    G4ThreeVector(MOPISecondKaptonLayerXPosition,
1290                                                  1290                                                                  MOPISecondKaptonLayerYPosition ,
1291                                                  1291                                                                  MOPISecondKaptonLayerZPosition),
1292                                                  1292                                                    "MOPISecondKaptonLayer",
1293                                                  1293                                                    logicMOPISecondKaptonLayer,
1294                                                  1294                                                    physiMOPIMotherVolume,
1295                                                  1295                                                    false,
1296                                                  1296                                                    0);
1297                                                  1297     
1298     logicMOPIFirstAirGap -> SetVisAttributes(    1298     logicMOPIFirstAirGap -> SetVisAttributes(darkGreen);
1299     logicMOPISecondAirGap -> SetVisAttributes    1299     logicMOPISecondAirGap -> SetVisAttributes(darkGreen);
1300                                                  1300     
1301                                                  1301     
1302     }                                            1302     }
1303 /////////////////////////////////////////////    1303 /////////////////////////////////////////////////////////////////////////////
1304 void PassiveProtonBeamLine::HadrontherapyBeam    1304 void PassiveProtonBeamLine::HadrontherapyBeamNozzle()
1305 {                                                1305 {
1306     // ------------------------------//          1306     // ------------------------------//
1307     // THE FINAL TUBE AND COLLIMATOR //          1307     // THE FINAL TUBE AND COLLIMATOR //
1308     //-------------------------------//          1308     //-------------------------------//
1309     // The last part of the transport beam li    1309     // The last part of the transport beam line consists of
1310     // a 59 mm thick PMMA slab (to stop all t    1310     // a 59 mm thick PMMA slab (to stop all the diffused radiation), a 370 mm brass tube
1311     // (to well collimate the proton beam) an    1311     // (to well collimate the proton beam) and a final collimator with 25 mm diameter
1312     // aperture (that provide the final trasv    1312     // aperture (that provide the final trasversal shape of the beam)
1313                                                  1313     
1314     // -------------------//                     1314     // -------------------//
1315     //     PMMA SUPPORT   //                     1315     //     PMMA SUPPORT   //
1316     // -------------------//                     1316     // -------------------//
1317     const G4double nozzleSupportXSize = 29.5     1317     const G4double nozzleSupportXSize = 29.5 *mm;
1318     const G4double nozzleSupportYSize = 180.     1318     const G4double nozzleSupportYSize = 180. *mm;
1319     const G4double nozzleSupportZSize = 180.     1319     const G4double nozzleSupportZSize = 180. *mm;
1320                                                  1320     
1321     const G4double nozzleSupportXPosition = -    1321     const G4double nozzleSupportXPosition = -397.50 *mm;
1322                                                  1322     
1323     G4double phi = 90. *deg;                     1323     G4double phi = 90. *deg;
1324     // Matrix definition for a 90 deg rotatio    1324     // Matrix definition for a 90 deg rotation. Also used for other volumes
1325     G4RotationMatrix rm;                         1325     G4RotationMatrix rm;
1326     rm.rotateY(phi);                             1326     rm.rotateY(phi);
1327                                                  1327     
1328     G4Box* solidNozzleSupport = new G4Box("No    1328     G4Box* solidNozzleSupport = new G4Box("NozzleSupport",
1329                                           noz    1329                                           nozzleSupportXSize,
1330                                           noz    1330                                           nozzleSupportYSize,
1331                                           noz    1331                                           nozzleSupportZSize);
1332                                                  1332     
1333     G4LogicalVolume* logicNozzleSupport = new    1333     G4LogicalVolume* logicNozzleSupport = new G4LogicalVolume(solidNozzleSupport,
1334                                                  1334                                                               nozzleSupportMaterial,
1335                                                  1335                                                               "NozzleSupport");
1336                                                  1336     
1337     physiNozzleSupport = new G4PVPlacement(0,    1337     physiNozzleSupport = new G4PVPlacement(0, G4ThreeVector(nozzleSupportXPosition,0., 0.),
1338                                            "N    1338                                            "NozzleSupport",
1339                                            lo    1339                                            logicNozzleSupport,
1340                                            ph    1340                                            physicalTreatmentRoom,
1341                                            fa    1341                                            false,
1342                                            0)    1342                                            0);
1343                                                  1343     
1344     logicNozzleSupport -> SetVisAttributes(ye    1344     logicNozzleSupport -> SetVisAttributes(yellow);
1345                                                  1345     
1346                                                  1346     
1347                                                  1347     
1348     //------------------------------------//     1348     //------------------------------------//
1349     // HOLE IN THE SUPPORT                //     1349     // HOLE IN THE SUPPORT                //
1350     //------------------------------------//     1350     //------------------------------------//
1351     const G4double innerRadiusHoleNozzleSuppo    1351     const G4double innerRadiusHoleNozzleSupport = 0.*mm;
1352     const G4double outerRadiusHoleNozzleSuppo    1352     const G4double outerRadiusHoleNozzleSupport = 21.5*mm;
1353     const G4double hightHoleNozzleSupport = 2    1353     const G4double hightHoleNozzleSupport = 29.5 *mm;
1354     const G4double startAngleHoleNozzleSuppor    1354     const G4double startAngleHoleNozzleSupport = 0.*deg;
1355     const G4double spanningAngleHoleNozzleSup    1355     const G4double spanningAngleHoleNozzleSupport = 360.*deg;
1356                                                  1356     
1357     G4Tubs* solidHoleNozzleSupport = new G4Tu    1357     G4Tubs* solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport",
1358                                                  1358                                                 innerRadiusHoleNozzleSupport,
1359                                                  1359                                                 outerRadiusHoleNozzleSupport,
1360                                                  1360                                                 hightHoleNozzleSupport,
1361                                                  1361                                                 startAngleHoleNozzleSupport,
1362                                                  1362                                                 spanningAngleHoleNozzleSupport);
1363                                                  1363     
1364     G4LogicalVolume* logicHoleNozzleSupport =    1364     G4LogicalVolume* logicHoleNozzleSupport = new G4LogicalVolume(solidHoleNozzleSupport,
1365                                                  1365                                                                   holeNozzleSupportMaterial,
1366                                                  1366                                                                   "HoleNozzleSupport",
1367                                                  1367                                                                   0,
1368                                                  1368                                                                   0,
1369                                                  1369                                                                   0);
1370                                                  1370     
1371                                                  1371     
1372     physiHoleNozzleSupport = new G4PVPlacemen    1372     physiHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
1373                                                  1373                                                "HoleNozzleSupport",
1374                                                  1374                                                logicHoleNozzleSupport,
1375                                                  1375                                                physiNozzleSupport,
1376                                                  1376                                                false, 0);
1377                                                  1377     
1378     logicHoleNozzleSupport -> SetVisAttribute    1378     logicHoleNozzleSupport -> SetVisAttributes(darkOrange3);
1379                                                  1379     
1380     // ---------------------------------//       1380     // ---------------------------------//
1381     //     BRASS TUBE 1 (phantom side)    //     1381     //     BRASS TUBE 1 (phantom side)    //
1382     // ---------------------------------//       1382     // ---------------------------------//
1383     const G4double innerRadiusBrassTube= 18.*    1383     const G4double innerRadiusBrassTube= 18.*mm;
1384     const G4double outerRadiusBrassTube = 21.    1384     const G4double outerRadiusBrassTube = 21.5 *mm;
1385     const G4double hightBrassTube = 140.5*mm;    1385     const G4double hightBrassTube = 140.5*mm;
1386     const G4double startAngleBrassTube = 0.*d    1386     const G4double startAngleBrassTube = 0.*deg;
1387     const G4double spanningAngleBrassTube = 3    1387     const G4double spanningAngleBrassTube = 360.*deg;
1388                                                  1388     
1389     const G4double brassTubeXPosition = -227.    1389     const G4double brassTubeXPosition = -227.5 *mm;
1390                                                  1390     
1391     G4Tubs* solidBrassTube = new G4Tubs("Bras    1391     G4Tubs* solidBrassTube = new G4Tubs("BrassTube",
1392                                         inner    1392                                         innerRadiusBrassTube,
1393                                         outer    1393                                         outerRadiusBrassTube,
1394                                         hight    1394                                         hightBrassTube,
1395                                         start    1395                                         startAngleBrassTube,
1396                                         spann    1396                                         spanningAngleBrassTube);
1397                                                  1397     
1398     G4LogicalVolume* logicBrassTube = new G4L    1398     G4LogicalVolume* logicBrassTube = new G4LogicalVolume(solidBrassTube,
1399                                                  1399                                                           brassTubeMaterial,
1400                                                  1400                                                           "BrassTube",
1401                                                  1401                                                           0, 0, 0);
1402                                                  1402     
1403     physiBrassTube = new G4PVPlacement(G4Tran    1403     physiBrassTube = new G4PVPlacement(G4Transform3D(rm,
1404                                                  1404                                                      G4ThreeVector(brassTubeXPosition,
1405                                                  1405                                                                    0.,
1406                                                  1406                                                                    0.)),
1407                                        "Brass    1407                                        "BrassTube",
1408                                        logicB    1408                                        logicBrassTube,
1409                                        physic    1409                                        physicalTreatmentRoom,
1410                                        false,    1410                                        false,
1411                                        0);       1411                                        0);
1412                                                  1412     
1413     logicBrassTube -> SetVisAttributes(darkOr    1413     logicBrassTube -> SetVisAttributes(darkOrange3);
1414                                                  1414     
1415     // --------------------------------------    1415     // ----------------------------------------------//
1416     //     BRASS TUBE 2 (inside the PMMA supp    1416     //     BRASS TUBE 2 (inside the PMMA support)    //
1417     // --------------------------------------    1417     // ----------------------------------------------//
1418     const G4double innerRadiusBrassTube2= 18.    1418     const G4double innerRadiusBrassTube2= 18.*mm;
1419     const G4double outerRadiusBrassTube2 = 21    1419     const G4double outerRadiusBrassTube2 = 21.5 *mm;
1420     const G4double hightBrassTube2 = 29.5*mm;    1420     const G4double hightBrassTube2 = 29.5*mm;
1421     const G4double startAngleBrassTube2 = 0.*    1421     const G4double startAngleBrassTube2 = 0.*deg;
1422     const G4double spanningAngleBrassTube2 =     1422     const G4double spanningAngleBrassTube2 = 360.*deg;
1423                                                  1423     
1424                                                  1424     
1425     G4Tubs* solidBrassTube2 = new G4Tubs("Bra    1425     G4Tubs* solidBrassTube2 = new G4Tubs("BrassTube2",
1426                                          inne    1426                                          innerRadiusBrassTube2,
1427                                          oute    1427                                          outerRadiusBrassTube2,
1428                                          high    1428                                          hightBrassTube2,
1429                                          star    1429                                          startAngleBrassTube2,
1430                                          span    1430                                          spanningAngleBrassTube2);
1431                                                  1431     
1432     G4LogicalVolume* logicBrassTube2 = new G4    1432     G4LogicalVolume* logicBrassTube2 = new G4LogicalVolume(solidBrassTube2,
1433                                                  1433                                                            brassTube2Material,
1434                                                  1434                                                            "BrassTube2",
1435                                                  1435                                                            0, 0, 0);
1436                                                  1436     
1437     physiBrassTube2 = new G4PVPlacement(0,       1437     physiBrassTube2 = new G4PVPlacement(0,
1438                                         G4Thr    1438                                         G4ThreeVector(0,0.,0.),
1439                                         logic    1439                                         logicBrassTube2,
1440                                         "Bras    1440                                         "BrassTube2",
1441                                         logic    1441                                         logicHoleNozzleSupport,
1442                                         false    1442                                         false,
1443                                         0);      1443                                         0);
1444                                                  1444     
1445     logicBrassTube2 -> SetVisAttributes(darkO    1445     logicBrassTube2 -> SetVisAttributes(darkOrange3);
1446                                                  1446     
1447                                                  1447     
1448     // --------------------------------------    1448     // --------------------------------------//
1449     //     BRASS TUBE 3 (beam line side)    /    1449     //     BRASS TUBE 3 (beam line side)    //
1450     // -------------------------------------/    1450     // -------------------------------------//
1451     const G4double innerRadiusBrassTube3= 18.    1451     const G4double innerRadiusBrassTube3= 18.*mm;
1452     const G4double outerRadiusBrassTube3 = 21    1452     const G4double outerRadiusBrassTube3 = 21.5 *mm;
1453     const G4double hightBrassTube3 = 10.0 *mm    1453     const G4double hightBrassTube3 = 10.0 *mm;
1454     const G4double startAngleBrassTube3 = 0.*    1454     const G4double startAngleBrassTube3 = 0.*deg;
1455     const G4double spanningAngleBrassTube3 =     1455     const G4double spanningAngleBrassTube3 = 360.*deg;
1456                                                  1456     
1457     const G4double brassTube3XPosition = -437    1457     const G4double brassTube3XPosition = -437 *mm;
1458                                                  1458     
1459     G4Tubs* solidBrassTube3 = new G4Tubs("Bra    1459     G4Tubs* solidBrassTube3 = new G4Tubs("BrassTube3",
1460                                          inne    1460                                          innerRadiusBrassTube3,
1461                                          oute    1461                                          outerRadiusBrassTube3,
1462                                          high    1462                                          hightBrassTube3,
1463                                          star    1463                                          startAngleBrassTube3,
1464                                          span    1464                                          spanningAngleBrassTube3);
1465                                                  1465     
1466     G4LogicalVolume* logicBrassTube3 = new G4    1466     G4LogicalVolume* logicBrassTube3 = new G4LogicalVolume(solidBrassTube3,
1467                                                  1467                                                            brassTube3Material,
1468                                                  1468                                                            "BrassTube3",
1469                                                  1469                                                            0, 0, 0);
1470                                                  1470     
1471     physiBrassTube3 = new G4PVPlacement(G4Tra    1471     physiBrassTube3 = new G4PVPlacement(G4Transform3D(rm,
1472                                                  1472                                                       G4ThreeVector(brassTube3XPosition,
1473                                                  1473                                                                     0.,
1474                                                  1474                                                                     0.)),
1475                                         "Bras    1475                                         "BrassTube3",
1476                                         logic    1476                                         logicBrassTube3,
1477                                         physi    1477                                         physicalTreatmentRoom,
1478                                         false    1478                                         false,
1479                                         0);      1479                                         0);
1480                                                  1480     
1481     logicBrassTube3 -> SetVisAttributes(darkO    1481     logicBrassTube3 -> SetVisAttributes(darkOrange3);
1482 }                                                1482 }
1483                                                  1483 
1484 /////////////////////////////////////////////    1484 /////////////////////////////////////////////////////////////////////////////
1485 void PassiveProtonBeamLine::HadrontherapyBeam    1485 void PassiveProtonBeamLine::HadrontherapyBeamFinalCollimator()
1486 {                                                1486 {
1487     // -----------------------//                 1487     // -----------------------//
1488     //     FINAL COLLIMATOR   //                 1488     //     FINAL COLLIMATOR   //
1489     //------------------------//                 1489     //------------------------//
1490     const G4double outerRadiusFinalCollimator    1490     const G4double outerRadiusFinalCollimator = 21.5*mm;
1491     const G4double hightFinalCollimator = 3.5    1491     const G4double hightFinalCollimator = 3.5*mm;
1492     const G4double startAngleFinalCollimator     1492     const G4double startAngleFinalCollimator = 0.*deg;
1493     const G4double spanningAngleFinalCollimat    1493     const G4double spanningAngleFinalCollimator = 360.*deg;
1494     const G4double finalCollimatorXPosition =    1494     const G4double finalCollimatorXPosition = -83.5 *mm;
1495                                                  1495     
1496     G4double phi = 90. *deg;                     1496     G4double phi = 90. *deg;
1497                                                  1497     
1498     // Matrix definition for a 90 deg rotatio    1498     // Matrix definition for a 90 deg rotation. Also used for other volumes
1499     G4RotationMatrix rm;                         1499     G4RotationMatrix rm;
1500     rm.rotateY(phi);                             1500     rm.rotateY(phi);
1501                                                  1501     
1502     solidFinalCollimator = new G4Tubs("FinalC    1502     solidFinalCollimator = new G4Tubs("FinalCollimator",
1503                                       innerRa    1503                                       innerRadiusFinalCollimator,
1504                                       outerRa    1504                                       outerRadiusFinalCollimator,
1505                                       hightFi    1505                                       hightFinalCollimator,
1506                                       startAn    1506                                       startAngleFinalCollimator,
1507                                       spannin    1507                                       spanningAngleFinalCollimator);
1508                                                  1508     
1509     G4LogicalVolume* logicFinalCollimator = n    1509     G4LogicalVolume* logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator,
1510                                                  1510                                                                 finalCollimatorMaterial,
1511                                                  1511                                                                 "FinalCollimator",
1512                                                  1512                                                                 0,
1513                                                  1513                                                                 0,
1514                                                  1514                                                                 0);
1515                                                  1515     
1516     physiFinalCollimator = new G4PVPlacement(    1516     physiFinalCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(finalCollimatorXPosition,0.,0.)),
1517                                                  1517                                              "FinalCollimator", logicFinalCollimator, physicalTreatmentRoom, false, 0);
1518                                                  1518     
1519     logicFinalCollimator -> SetVisAttributes(    1519     logicFinalCollimator -> SetVisAttributes(yellow);
1520 }                                                1520 }
1521 /////////////////////////// MESSENGER ///////    1521 /////////////////////////// MESSENGER ///////////////////////////////////////
1522 /////////////////////////////////////////////    1522 /////////////////////////////////////////////////////////////////////////////
1523 void PassiveProtonBeamLine::SetRangeShifterXP    1523 void PassiveProtonBeamLine::SetRangeShifterXPosition(G4double value)
1524 {                                                1524 {
1525     physiRangeShifterBox -> SetTranslation(G4    1525     physiRangeShifterBox -> SetTranslation(G4ThreeVector(value, 0., 0.));
1526     G4RunManager::GetRunManager() -> Geometry    1526     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1527     G4cout << "The Range Shifter is translate    1527     G4cout << "The Range Shifter is translated to"<< value/mm <<"mm along the X axis" <<G4endl;
1528 }                                                1528 }
1529                                                  1529 
1530 /////////////////////////////////////////////    1530 /////////////////////////////////////////////////////////////////////////////
1531 void PassiveProtonBeamLine::SetRangeShifterXS    1531 void PassiveProtonBeamLine::SetRangeShifterXSize(G4double value)
1532 {                                                1532 {
1533     solidRangeShifterBox -> SetXHalfLength(va    1533     solidRangeShifterBox -> SetXHalfLength(value) ;
1534     G4cout << "RangeShifter size X (mm): "<<     1534     G4cout << "RangeShifter size X (mm): "<< ((solidRangeShifterBox -> GetXHalfLength())*2.)/mm
1535     << G4endl;                                   1535     << G4endl;
1536     G4RunManager::GetRunManager() -> Geometry    1536     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1537 }                                                1537 }
1538                                                  1538 
1539 /////////////////////////////////////////////    1539 /////////////////////////////////////////////////////////////////////////////
1540 void PassiveProtonBeamLine::SetFirstScatterin    1540 void PassiveProtonBeamLine::SetFirstScatteringFoilXSize(G4double value)
1541 {                                                1541 {
1542     firstScatteringFoil -> SetXHalfLength(val    1542     firstScatteringFoil -> SetXHalfLength(value);
1543     G4RunManager::GetRunManager() -> Geometry    1543     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1544     G4cout <<"The X size of the first scatter    1544     G4cout <<"The X size of the first scattering foil is (mm):"<<
1545     ((firstScatteringFoil -> GetXHalfLength()    1545     ((firstScatteringFoil -> GetXHalfLength())*2.)/mm
1546     << G4endl;                                   1546     << G4endl;
1547 }                                                1547 }
1548                                                  1548 
1549 /////////////////////////////////////////////    1549 /////////////////////////////////////////////////////////////////////////////
1550 void PassiveProtonBeamLine::SetSecondScatteri    1550 void PassiveProtonBeamLine::SetSecondScatteringFoilXSize(G4double value)
1551 {                                                1551 {
1552     secondScatteringFoil -> SetXHalfLength(va    1552     secondScatteringFoil -> SetXHalfLength(value);
1553     G4RunManager::GetRunManager() -> Geometry    1553     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1554     G4cout <<"The X size of the second scatte    1554     G4cout <<"The X size of the second scattering foil is (mm):"<<
1555     ((secondScatteringFoil -> GetXHalfLength(    1555     ((secondScatteringFoil -> GetXHalfLength())*2.)/mm
1556     << G4endl;                                   1556     << G4endl;
1557 }                                                1557 }
1558                                                  1558 
1559 /////////////////////////////////////////////    1559 /////////////////////////////////////////////////////////////////////////////
1560 void PassiveProtonBeamLine::SetOuterRadiusSto    1560 void PassiveProtonBeamLine::SetOuterRadiusStopper(G4double value)
1561 {                                                1561 {
1562     solidStopper -> SetOuterRadius(value);       1562     solidStopper -> SetOuterRadius(value);
1563     G4RunManager::GetRunManager() -> Geometry    1563     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1564     G4cout << "OuterRadius od the Stopper is     1564     G4cout << "OuterRadius od the Stopper is (mm):"
1565     << solidStopper -> GetOuterRadius()/mm       1565     << solidStopper -> GetOuterRadius()/mm
1566     << G4endl;                                   1566     << G4endl;
1567 }                                                1567 }
1568                                                  1568 
1569 /////////////////////////////////////////////    1569 /////////////////////////////////////////////////////////////////////////////
1570 void PassiveProtonBeamLine::SetInnerRadiusFin    1570 void PassiveProtonBeamLine::SetInnerRadiusFinalCollimator(G4double value)
1571 {                                                1571 {
1572     solidFinalCollimator -> SetInnerRadius(va    1572     solidFinalCollimator -> SetInnerRadius(value);
1573     G4RunManager::GetRunManager() -> Geometry    1573     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1574     G4cout<<"Inner Radius of the final collim    1574     G4cout<<"Inner Radius of the final collimator is (mm):"
1575   << solidFinalCollimator -> GetInnerRadius()    1575   << solidFinalCollimator -> GetInnerRadius()/mm
1576   << G4endl;                                     1576   << G4endl;
1577 }                                                1577 }
1578                                                  1578 
1579 /////////////////////////////////////////////    1579 /////////////////////////////////////////////////////////////////////////////
1580 void PassiveProtonBeamLine::SetRSMaterial(G4S    1580 void PassiveProtonBeamLine::SetRSMaterial(G4String materialChoice)
1581 {                                                1581 {
1582     if (G4Material* pttoMaterial = G4NistMana    1582     if (G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice, false) )
1583     {                                            1583     {
1584         if (pttoMaterial)                        1584         if (pttoMaterial)
1585         {                                        1585         {
1586             rangeShifterMaterial  = pttoMater    1586             rangeShifterMaterial  = pttoMaterial;
1587             logicRangeShifterBox -> SetMateri    1587             logicRangeShifterBox -> SetMaterial(pttoMaterial);
1588             G4cout << "The material of the Ra    1588             G4cout << "The material of the Range Shifter has been changed to " << materialChoice << G4endl;
1589         }                                        1589         }
1590     }                                            1590     }
1591     else                                         1591     else
1592     {                                            1592     {
1593         G4cout << "WARNING: material \"" << m    1593         G4cout << "WARNING: material \"" << materialChoice << "\" doesn't exist in NIST elements/materials"
1594       " table [located in $G4INSTALL/source/m    1594       " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
1595         G4cout << "Use command \"/parameter/n    1595         G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
1596     }                                            1596     }
1597 }                                                1597 }
1598                                                  1598 
1599 /////////////////////////////////////////////    1599 /////////////////////////////////////////////////////////////////////////////
1600 void PassiveProtonBeamLine::SetModulatorAngle    1600 void PassiveProtonBeamLine::SetModulatorAngle(G4double value)
1601 {                                                1601 {
1602     modulator -> SetModulatorAngle(value);       1602     modulator -> SetModulatorAngle(value);
1603     //G4RunManager::GetRunManager() -> Geomet    1603     //G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1604 }                                                1604 }
1605 /////////////////////////////////////////////    1605 /////////////////////////////////////////////////////////////////////////////
1606                                                  1606