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 ]

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