Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/hadrontherapy/src/BESTPassiveProtonBeamline.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 "BESTPassiveProtonBeamLine.hh"
 44 #include "BESTPassiveProtonBeamLineMessenger.hh"
 45 
 46 
 47 //G4bool PassiveProtonBeamLine::doCalculation = false;
 48 /////////////////////////////////////////////////////////////////////////////
 49 BESTPassiveProtonBeamLine::BESTPassiveProtonBeamLine():
 50 modulator(0), physicalTreatmentRoom(0),hadrontherapyDetectorConstruction(0),
 51 physiBeamLineSupport(0), physiBeamLineCover(0), physiBeamLineCover2(0),
 52 BESTfirstScatteringFoil(0), physiBESTFirstScatteringFoil(0), physiBESTKaptonWindow(0),
 53 solidBESTStopper(0), physiBESTStopper(0), BESTsecondScatteringFoil(0), physiBESTSecondScatteringFoil(0),
 54 physiBESTFirstCollimator(0), solidBESTRangeShifterBox(0), logicBESTRangeShifterBox(0),
 55 physiBESTRangeShifterBox(0), physiBESTSecondCollimator(0), physiBESTFirstCollimatorModulatorBox(0),
 56 physiBESTHoleFirstCollimatorModulatorBox(0), physiBESTSecondCollimatorModulatorBox(0),
 57 physiBESTHoleSecondCollimatorModulatorBox(0),
 58 chamberPhys(0),innerchamberPhys(0),enterWindowPhys(0),enterElectrodePhys(0),kaptonLayerPhys1(0),copperLayerPhys1(0),nickelLayerPhys1(0),fFirstCavityPhys(0),centralElectrode1Phys(0), centralWindowPhys(0), centralElectrode2Phys(0),fSecondCavityPhys(0),exitElectrodePhys(0),kaptonLayerPhys2(0),copperLayerPhys2(0),nickelLayerPhys2(0),exitWindowPhys(0),physiNozzleSupport(0), physiBrassTube(0), solidFinalCollimator(0), physiFinalCollimator(0)
 59 {
 60     // Messenger to change parameters of the passiveProtonBeamLine geometry
 61     passiveMessenger = new BESTPassiveProtonBeamLineMessenger(this);
 62     
 63     //***************************** PW ***************************************
 64     static G4String ROGeometryName = "DetectorROGeometry";
 65     RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
 66     
 67     G4cout << "Going to register Parallel world...";
 68     RegisterParallelWorld(RO);
 69     G4cout << "... done" << G4endl;
 70 
 71 }
 72 /////////////////////////////////////////////////////////////////////////////
 73 BESTPassiveProtonBeamLine::~BESTPassiveProtonBeamLine()
 74 {
 75    // delete passiveMessenger;
 76     delete hadrontherapyDetectorConstruction;
 77 
 78 }
 79 
 80 /////////////////////////////////////////////////////////////////////////////
 81 G4VPhysicalVolume* BESTPassiveProtonBeamLine::Construct()
 82 {
 83     // Sets default geometry and materials
 84     SetDefaultDimensions();
 85     
 86     // Construct the whole BEST Passive Beam Line
 87     ConstructBESTPassiveProtonBeamLine();
 88     
 89     //***************************** PW ***************************************
 90     if (!hadrontherapyDetectorConstruction)
 91         
 92         //***************************** PW ***************************************
 93         
 94         // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
 95         hadrontherapyDetectorConstruction = new HadrontherapyDetectorConstruction(physicalTreatmentRoom);
 96     
 97     
 98     //***************************** PW ***************************************
 99     
100     hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
101     
102     //***************************** PW ***************************************
103 
104     return physicalTreatmentRoom;
105 }
106 
107 // In the following method the DEFAULTS used in the geometry of
108 // passive beam line are provided
109 // HERE THE USER CAN CHANGE THE GEOMETRY CHARACTERISTICS OF BEAM
110 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE THE MACRO FILE (IF A
111 // MESSENGER IS PROVIDED)
112 //
113 // DEFAULT MATERIAL ARE ALSO PROVIDED
114 // and COLOURS ARE ALSO DEFINED
115 // ----------------------------------------------------------
116 /////////////////////////////////////////////////////////////////////////////
117 void BESTPassiveProtonBeamLine::SetDefaultDimensions()
118 {
119     // Set of coulors that can be used
120     white = new G4VisAttributes( G4Colour());
121     white -> SetVisibility(true);
122     white -> SetForceSolid(true);
123   
124     blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
125     blue -> SetVisibility(true);
126     blue -> SetForceSolid(true);
127   
128     gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5 ));
129     gray-> SetVisibility(true);
130     gray-> SetForceSolid(true);
131   
132     red = new G4VisAttributes(G4Colour(1. ,0. ,0.));
133     red-> SetVisibility(true);
134     red-> SetForceSolid(true);
135   
136     yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
137     yellow-> SetVisibility(true);
138     yellow-> SetForceSolid(true);
139   
140     green = new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
141     green -> SetVisibility(true);
142     green -> SetForceSolid(true);
143   
144     darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. ,  0/255. ));
145     darkGreen -> SetVisibility(true);
146     darkGreen -> SetForceSolid(true);
147     
148     darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. ,  000/255. ));
149     darkOrange3 -> SetVisibility(true);
150     darkOrange3 -> SetForceSolid(true);
151   
152     skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. ,  235/255. ));
153     skyBlue -> SetVisibility(true);
154     skyBlue -> SetForceSolid(true);
155     
156     
157     // VACUUM PIPE: first track of the beam line is inside vacuum;
158     // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
159     G4double defaultBESTVacuumZoneXSize = 100.0 *mm;
160     BESTvacuumZoneXSize = defaultBESTVacuumZoneXSize;
161     
162     G4double defaultBESTVacuumZoneYSize = 52.5 *mm;
163     BESTvacuumZoneYSize = defaultBESTVacuumZoneYSize;
164     
165     G4double defaultBESTVacuumZoneZSize = 52.5 *mm;
166     BESTvacuumZoneZSize = defaultBESTVacuumZoneZSize;
167     
168     G4double defaultBESTVacuumZoneXPosition = -3010.0 *mm;
169     BESTvacuumZoneXPosition = defaultBESTVacuumZoneXPosition;
170     
171     // FIRST SCATTERING FOIL: a thin foil performing a first scattering
172     // of the original beam
173     G4double defaultBESTFirstScatteringFoilXSize = 0.0075 *mm;
174     BESTfirstScatteringFoilXSize = defaultBESTFirstScatteringFoilXSize;
175     
176     G4double defaultBESTFirstScatteringFoilYSize = 52.5   *mm;
177    BESTfirstScatteringFoilYSize = defaultBESTFirstScatteringFoilYSize;
178     
179     G4double defaultBESTFirstScatteringFoilZSize = 52.5   *mm;
180     BESTfirstScatteringFoilZSize = defaultBESTFirstScatteringFoilZSize;
181     
182     G4double defaultBESTFirstScatteringFoilXPosition = 0.0 *mm;
183     BESTfirstScatteringFoilXPosition = defaultBESTFirstScatteringFoilXPosition;
184     
185     // KAPTON WINDOW: it prmits the passage of the beam from vacuum to air
186     G4double defaultBESTKaptonWindowXSize = 0.010*mm;
187     BESTkaptonWindowXSize = defaultBESTKaptonWindowXSize;
188     
189     G4double defaultBESTKaptonWindowYSize = 5.25*cm;
190     BESTkaptonWindowYSize = defaultBESTKaptonWindowYSize;
191     
192     G4double defaultBESTKaptonWindowZSize = 5.25*cm;
193     BESTkaptonWindowZSize = defaultBESTKaptonWindowZSize;
194     
195     G4double defaultBESTKaptonWindowXPosition = 100.0*mm - defaultBESTKaptonWindowXSize;
196     BESTkaptonWindowXPosition = defaultBESTKaptonWindowXPosition;
197     
198     // STOPPER: is a small cylinder able to stop the central component
199     // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
200     // and represent the second element of the scattering system
201     G4double defaultBESTInnerRadiusStopper = 0.*cm;
202     BESTinnerRadiusStopper = defaultBESTInnerRadiusStopper;
203     
204     G4double defaultBESTHeightStopper = 4.5*mm;
205     BESTheightStopper = defaultBESTHeightStopper;
206     
207     G4double defaultBESTStartAngleStopper = 0.*deg;
208     BESTstartAngleStopper = defaultBESTStartAngleStopper;
209     
210     G4double defaultBESTSpanningAngleStopper = 360.*deg;
211     BESTspanningAngleStopper = defaultBESTSpanningAngleStopper;
212     
213     G4double defaultBESTStopperXPosition = -2705.0 *mm;
214     BESTstopperXPosition = defaultBESTStopperXPosition;
215     
216     G4double defaultBESTStopperYPosition = 0.*m;
217     BESTstopperYPosition = defaultBESTStopperYPosition;
218     
219     G4double defaultBESTStopperZPosition = 0.*m;
220     BESTstopperZPosition = defaultBESTStopperZPosition;
221     
222     G4double defaultBESTOuterRadiusStopper = 3 *mm;
223     BESTouterRadiusStopper = defaultBESTOuterRadiusStopper;
224     
225     // SECOND SCATTERING FOIL: it is another thin foil and provides the
226     // final diffusion of the beam. It represents the third element of the scattering
227     // system;
228     G4double defaultBESTSecondScatteringFoilXSize = 0.0125 *mm;
229    BESTsecondScatteringFoilXSize = defaultBESTSecondScatteringFoilXSize;
230     
231     G4double defaultBESTSecondScatteringFoilYSize = 52.5   *mm;
232     BESTsecondScatteringFoilYSize = defaultBESTSecondScatteringFoilYSize;
233     
234     G4double defaultBESTSecondScatteringFoilZSize = 52.5   *mm;
235     BESTsecondScatteringFoilZSize = defaultBESTSecondScatteringFoilZSize;
236     
237     G4double defaultBESTSecondScatteringFoilXPosition = defaultBESTStopperXPosition + defaultBESTHeightStopper + defaultBESTSecondScatteringFoilXSize;
238     BESTsecondScatteringFoilXPosition = defaultBESTSecondScatteringFoilXPosition;
239     
240     G4double defaultBESTSecondScatteringFoilYPosition =  0 *mm;
241     BESTsecondScatteringFoilYPosition = defaultBESTSecondScatteringFoilYPosition;
242     
243     G4double defaultBESTSecondScatteringFoilZPosition =  0 *mm;
244     BESTsecondScatteringFoilZPosition = defaultBESTSecondScatteringFoilZPosition;
245     
246     // RANGE SHIFTER: is a slab of PMMA acting as energy degreader of
247     // primary beam
248     
249     //Default material of the range shifter
250     
251     G4double defaultBESTRangeShifterXSize = 5. *mm;
252     BESTrangeShifterXSize = defaultBESTRangeShifterXSize;
253     
254     G4double defaultBESTRangeShifterYSize = 176. *mm;
255     BESTrangeShifterYSize = defaultBESTRangeShifterYSize;
256     
257     G4double defaultBESTRangeShifterZSize = 176. *mm;
258     BESTrangeShifterZSize = defaultBESTRangeShifterZSize;
259     
260     G4double defaultBESTRangeShifterXPosition = -2393.0 *mm;
261     BESTrangeShifterXPosition = defaultBESTRangeShifterXPosition;
262     
263     G4double defaultBESTRangeShifterYPosition = 0. *mm;
264     BESTrangeShifterYPosition = defaultBESTRangeShifterYPosition;
265     
266     G4double defaultBESTRangeShifterZPosition = 0. *mm;
267     BESTrangeShifterZPosition = defaultBESTRangeShifterZPosition;
268     
269    
270     
271     // FINAL COLLIMATOR: is the collimator giving the final transversal shape
272     // of the beam
273     G4double defaultBESTinnerRadiusFinalCollimator = 7.5 *mm;
274     BESTinnerRadiusFinalCollimator = defaultBESTinnerRadiusFinalCollimator;
275     
276     // DEFAULT DEFINITION OF THE MATERIALS
277     // All elements and compound definition follows the NIST database
278     
279     // ELEMENTS
280     G4bool isotopes = false;
281     G4Material* aluminumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al", isotopes);
282     G4Material* tantalumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ta", isotopes);
283     G4Material* copperNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu", isotopes);
284     G4Element* zincNist = G4NistManager::Instance()->FindOrBuildElement("Zn");
285     G4Element* copperNist = G4NistManager::Instance()->FindOrBuildElement("Cu");
286     
287     // COMPOUND
288     G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
289     G4Material* kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
290     G4Material* galacticNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic", isotopes);
291     G4Material* PMMANist = G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS", isotopes);
292     G4Material* mylarNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_MYLAR", isotopes);
293     
294 G4Material* nichelNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ni", isotopes);
295 
296     
297 
298 
299     G4double d; // Density
300     G4int nComponents;// Number of components
301     G4double fractionmass; // Fraction in mass of an element in a material
302     
303     d = 8.40*g/cm3;
304     nComponents = 2;
305     G4Material* brass = new G4Material("Brass", d, nComponents);
306     brass -> AddElement(zincNist, fractionmass = 30 *perCent);
307     brass -> AddElement(copperNist, fractionmass = 70 *perCent);
308     
309     
310     //***************************** PW ***************************************
311     
312     // DetectorROGeometry Material
313     new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
314     
315     //***************************** PW ***************************************
316     
317     
318     
319     // MATERIAL ASSIGNMENT
320     // Range shifter
321     rangeShifterMaterial = airNist;
322     
323     // Support of the beam line
324     beamLineSupportMaterial = aluminumNist;
325     
326     // Vacuum pipe
327     vacuumZoneMaterial = galacticNist;
328     
329     // Material of the fisrt scattering foil
330     firstScatteringFoilMaterial = tantalumNist;
331     
332     // Material of kapton window
333     kaptonWindowMaterial = kaptonNist;
334     
335     // Material of the stopper
336     stopperMaterial = brass;
337     
338     // Material of the second scattering foil
339     secondScatteringFoilMaterial = tantalumNist;
340     
341     // Materials of the collimators
342     firstCollimatorMaterial = PMMANist;
343     holeFirstCollimatorMaterial = airNist;
344     
345     // Box containing the modulator wheel
346     modulatorBoxMaterial = aluminumNist;
347     holeModulatorBoxMaterial = airNist;
348     
349     // Materials of the monitor chamber
350   CopperLayerMaterial=copperNistAsMaterial;
351     NichelLayerMaterial=nichelNistAsMaterial;
352     KaptonLayerMaterial=kaptonNist;
353     WindowMaterial=mylarNist;
354     CentralWindowMaterial=mylarNist;
355     wallMaterial=aluminumNist;
356     ElectrodeMaterial=aluminumNist;
357     CavityMaterial=airNist;
358       
359     
360     // material of the final nozzle
361     nozzleSupportMaterial = PMMANist;
362     brassTubeMaterial = brassTube2Material = brassTube3Material = brass;
363     holeNozzleSupportMaterial = airNist;
364     
365     // Material of the final collimator
366     finalCollimatorMaterial = brass;
367 }
368 
369 /////////////////////////////////////////////////////////////////////////////
370 void BESTPassiveProtonBeamLine::ConstructBESTPassiveProtonBeamLine()
371 {
372     // -----------------------------
373     // Treatment room - World volume
374     //------------------------------
375     // Treatment room sizes
376     const G4double worldX = 400.0 *cm;
377     const G4double worldY = 400.0 *cm;
378     const G4double worldZ = 400.0 *cm;
379     G4bool isotopes = false;
380     
381     G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
382     G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
383     G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom,
384                                                               airNist,
385                                                               "logicTreatmentRoom",
386                                                               0,0,0);
387     physicalTreatmentRoom = new G4PVPlacement(0,
388                                               G4ThreeVector(),
389                                               "physicalTreatmentRoom",
390                                               logicTreatmentRoom,
391                                               0,false,0);
392     
393     
394     // The treatment room is invisible in the Visualisation
395     //logicTreatmentRoom -> SetVisAttributes(G4VisAttributes::GetInvisible());
396     
397     // Components of the BEST Passive Proton Beam Line
398    BESTBeamLineSupport();
399     BESTBeamScatteringFoils();
400     BESTRangeShifter();
401     BESTBeamCollimators();
402     BESTBeamMonitoring();
403     BESTBeamNozzle();
404     BESTBeamFinalCollimator();
405     
406     // The following lines construc a typical modulator wheel inside the Passive Beam line.
407     // Please remember to set the nodulator material (default is air, i.e. no modulator!)
408     // in the HadrontherapyModulator.cc file
409     modulator = new HadrontherapyModulator();
410     modulator -> BuildModulator(physicalTreatmentRoom);
411 }
412 
413 /////////////////////////////////////////////////////////////////////////////
414 void BESTPassiveProtonBeamLine::BESTBeamLineSupport()
415 {
416     // ------------------//
417     // BEAM LINE SUPPORT //
418     //-------------------//
419     const G4double beamLineSupportXSize = 1.5*m;
420     const G4double beamLineSupportYSize = 20.*mm;
421     const G4double beamLineSupportZSize = 600.*mm;
422     
423     const G4double beamLineSupportXPosition = -1745.09 *mm;
424     const G4double beamLineSupportYPosition = -230. *mm;
425     const G4double beamLineSupportZPosition = 0.*mm;
426     
427   G4Box* beamLineSupport = new G4Box("BeamLineSupport",
428                                        beamLineSupportXSize,
429                                        beamLineSupportYSize,
430                                        beamLineSupportZSize);
431     
432     G4LogicalVolume* logicBeamLineSupport = new G4LogicalVolume(beamLineSupport,
433                                                                 beamLineSupportMaterial,
434                                                                 "BeamLineSupport");
435     physiBeamLineSupport = new G4PVPlacement(0, G4ThreeVector(beamLineSupportXPosition,
436                                                               beamLineSupportYPosition,
437                                                               beamLineSupportZPosition),
438                                              "BeamLineSupport",
439                                              logicBeamLineSupport,
440                                              physicalTreatmentRoom, false, 0);
441     
442     // Visualisation attributes of the beam line support
443     
444     logicBeamLineSupport -> SetVisAttributes(gray);
445 
446     //---------------------------------//
447     //  Beam line cover 1 (left panel) //
448     //---------------------------------//
449     const G4double beamLineCoverXSize = 1.5*m;
450     const G4double beamLineCoverYSize = 750.*mm;
451     const G4double beamLineCoverZSize = 10.*mm;
452     
453     const G4double beamLineCoverXPosition = -1745.09 *mm;
454     const G4double beamLineCoverYPosition = -1000.*mm;
455     const G4double beamLineCoverZPosition = 600.*mm;
456     
457    G4Box* beamLineCover = new G4Box("BeamLineCover",
458                                      beamLineCoverXSize,
459                                      beamLineCoverYSize,
460                                      beamLineCoverZSize);
461     
462     G4LogicalVolume* logicBeamLineCover = new G4LogicalVolume(beamLineCover,
463                                                               beamLineSupportMaterial,
464                                                               "BeamLineCover");
465     
466     physiBeamLineCover = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
467                                                             beamLineCoverYPosition,
468                                                             beamLineCoverZPosition),
469                                            "BeamLineCover",
470                                            logicBeamLineCover,
471                                            physicalTreatmentRoom,
472                                            false,
473                                            0);
474     
475     // ---------------------------------//
476     //  Beam line cover 2 (rigth panel) //
477     // ---------------------------------//
478     // It has the same characteristic of beam line cover 1 but set in a different position
479     physiBeamLineCover2 = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
480                                                              beamLineCoverYPosition,
481                                                              - beamLineCoverZPosition),
482                                             "BeamLineCover2",
483                                             logicBeamLineCover,
484                                             physicalTreatmentRoom,
485                                             false,
486                                             0);
487     
488     logicBeamLineCover -> SetVisAttributes(blue);
489 
490     }
491 
492 /////////////////////////////////////////////////////////////////////////////
493 void BESTPassiveProtonBeamLine::BESTBeamScatteringFoils()
494 {
495    // ------------//
496     // VACUUM PIPE //
497     //-------------//
498     //
499     // First track of the beam line is inside vacuum;
500     // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
501     G4Box* BESTvacuumZone = new G4Box("VacuumZone", BESTvacuumZoneXSize, BESTvacuumZoneYSize, BESTvacuumZoneZSize);
502     G4LogicalVolume* logicBESTVacuumZone = new G4LogicalVolume(BESTvacuumZone, vacuumZoneMaterial, "VacuumZone");
503     G4VPhysicalVolume* physiBESTVacuumZone = new G4PVPlacement(0, G4ThreeVector(BESTvacuumZoneXPosition, 0., 0.),
504                                                            "VacuumZone",logicBESTVacuumZone, physicalTreatmentRoom, false, 0);
505     // --------------------------//
506     // THE FIRST SCATTERING FOIL //
507     // --------------------------//
508     // A thin foil performing a first scattering
509     // of the original beam
510     BESTfirstScatteringFoil = new G4Box("FirstScatteringFoil",
511                                     BESTfirstScatteringFoilXSize,
512                                     BESTfirstScatteringFoilYSize,
513                                     BESTfirstScatteringFoilZSize);
514     
515     G4LogicalVolume* logicBESTFirstScatteringFoil = new G4LogicalVolume(BESTfirstScatteringFoil,
516                                                                     firstScatteringFoilMaterial,
517                                                                     "FirstScatteringFoil");
518     
519     physiBESTFirstScatteringFoil = new G4PVPlacement(0, G4ThreeVector(BESTfirstScatteringFoilXPosition, 0.,0.),
520                                                  "FirstScatteringFoil", logicBESTFirstScatteringFoil, physiBESTVacuumZone,
521                                                  false, 0);
522     
523     logicBESTFirstScatteringFoil -> SetVisAttributes(skyBlue);
524     // -------------------//
525     // THE KAPTON WINDOWS //
526     //--------------------//
527     //It prmits the passage of the beam from vacuum to air
528  
529     G4Box* solidBESTKaptonWindow = new G4Box("BESTKaptonWindow",
530                                          BESTkaptonWindowXSize,
531                                          BESTkaptonWindowYSize,
532                                          BESTkaptonWindowZSize);
533     
534     G4LogicalVolume* logicBESTKaptonWindow = new G4LogicalVolume(solidBESTKaptonWindow,
535                                                              kaptonWindowMaterial,
536                                                              "BESTKaptonWindow");
537     
538     physiBESTKaptonWindow = new G4PVPlacement(0, G4ThreeVector(BESTkaptonWindowXPosition, 0., 0.),
539                                           "BESTKaptonWindow", logicBESTKaptonWindow,
540                                           physiBESTVacuumZone, false, 0);
541     
542     logicBESTKaptonWindow -> SetVisAttributes(darkOrange3);
543     
544     // ------------//
545     // THE STOPPER //
546     //-------------//
547     // Is a small cylinder able to stop the central component
548     // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
549     // and represent the second element of the scattering system
550     G4double phi = 90. *deg;
551     // Matrix definition for a 90 deg rotation with respect to Y axis
552     G4RotationMatrix rm;
553     rm.rotateY(phi);
554     
555     solidBESTStopper = new G4Tubs("Stopper",
556                               BESTinnerRadiusStopper,
557                               BESTouterRadiusStopper,
558                               BESTheightStopper,
559                               BESTstartAngleStopper,
560                               BESTspanningAngleStopper);
561     
562     logicBESTStopper = new G4LogicalVolume(solidBESTStopper,
563                                        stopperMaterial,
564                                        "Stopper",
565                                        0, 0, 0);
566     
567     physiBESTStopper = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(BESTstopperXPosition,
568                                                                      BESTstopperYPosition,
569                                                                      BESTstopperZPosition)),
570                                      "BESTStopper",
571                                      logicBESTStopper,
572                                      physicalTreatmentRoom,
573                                      false,
574                                      0);
575     
576     logicBESTStopper -> SetVisAttributes(red);
577     
578     // ---------------------------//
579     // THE SECOND SCATTERING FOIL //
580     // ---------------------------//
581     // It is another thin foil and provides the
582     // final diffusion of the beam. It represents the third element of the scattering
583     // system;
584     
585     BESTsecondScatteringFoil = new G4Box("SecondScatteringFoil",
586                                      BESTsecondScatteringFoilXSize,
587                                      BESTsecondScatteringFoilYSize,
588                                      BESTsecondScatteringFoilZSize);
589     
590     G4LogicalVolume* logicBESTSecondScatteringFoil = new G4LogicalVolume(BESTsecondScatteringFoil,
591                                                                      secondScatteringFoilMaterial,
592                                                                      "SecondScatteringFoil");
593     
594     physiBESTSecondScatteringFoil = new G4PVPlacement(0, G4ThreeVector(BESTsecondScatteringFoilXPosition,
595                                                                    BESTsecondScatteringFoilYPosition,
596                                                                    BESTsecondScatteringFoilZPosition),
597                                                   "SeconScatteringFoil",
598                                                   logicBESTSecondScatteringFoil,
599                                                   physicalTreatmentRoom,
600                                                   false,
601                                                   0);
602     
603     logicBESTSecondScatteringFoil -> SetVisAttributes(skyBlue);
604  
605  
606 }
607 /////////////////////////////////////////////////////////////////////////////
608 void BESTPassiveProtonBeamLine::BESTRangeShifter()
609 {
610     // ---------------------------- //
611     //         THE RANGE SHIFTER    //
612     // -----------------------------//
613     // It is a slab of PMMA acting as energy degreader of
614     // primary beam
615  
616     
617     solidBESTRangeShifterBox = new G4Box("RangeShifterBox",
618                                      BESTrangeShifterXSize,
619                                      BESTrangeShifterYSize,
620                                      BESTrangeShifterZSize);
621     
622     logicBESTRangeShifterBox = new G4LogicalVolume(solidBESTRangeShifterBox,
623                                                rangeShifterMaterial,
624                                                "RangeShifterBox");
625     physiBESTRangeShifterBox = new G4PVPlacement(0,
626                                              G4ThreeVector(BESTrangeShifterXPosition, 0., 0.),
627                                              "RangeShifterBox",
628                                              logicBESTRangeShifterBox,
629                                              physicalTreatmentRoom,
630                                              false,
631                                              0);
632     
633     
634     logicBESTRangeShifterBox -> SetVisAttributes(yellow);
635      
636     
637 }
638 /////////////////////////////////////////////////////////////////////////////
639 void BESTPassiveProtonBeamLine::BESTBeamCollimators()
640 {
641     
642     
643     // -----------------//
644     // FIRST COLLIMATOR //
645     // -----------------//
646     // It is a slab of PMMA with an hole in its center
647     const G4double firstCollimatorXSize = 20.*mm;
648     const G4double firstCollimatorYSize = 100.*mm;
649     const G4double firstCollimatorZSize = 100.*mm;
650     
651     const G4double firstCollimatorXPosition = -2673.00*mm;
652     const G4double firstCollimatorYPosition = 0.*mm;
653     const G4double firstCollimatorZPosition = 0.*mm;
654     
655     
656     G4Box* solidBESTFirstCollimator = new G4Box("FirstCollimator",
657                                             firstCollimatorXSize,
658                                             firstCollimatorYSize,
659                                             firstCollimatorZSize);
660     
661     G4LogicalVolume* logicBESTFirstCollimator = new G4LogicalVolume(solidBESTFirstCollimator,
662                                                                 firstCollimatorMaterial,
663                                                                 "FirstCollimator");
664     
665     physiBESTFirstCollimator = new G4PVPlacement(0, G4ThreeVector(firstCollimatorXPosition,
666                                                               firstCollimatorYPosition,
667                                                               firstCollimatorZPosition),
668                                              "FirstCollimator",
669                                              logicBESTFirstCollimator,
670                                              physicalTreatmentRoom,
671                                              false,
672                                              0);
673     // ----------------------------//
674     // Hole of the first collimator//
675     //-----------------------------//
676     G4double innerRadiusHoleFirstCollimator   = 0.*mm;
677     G4double outerRadiusHoleFirstCollimator   = 15.*mm;
678     G4double hightHoleFirstCollimator         = 20.*mm;
679     G4double startAngleHoleFirstCollimator    = 0.*deg;
680     G4double spanningAngleHoleFirstCollimator = 360.*deg;
681     
682     G4Tubs* solidBESTHoleFirstCollimator = new G4Tubs("HoleFirstCollimator",
683                                                   innerRadiusHoleFirstCollimator,
684                                                   outerRadiusHoleFirstCollimator,
685                                                   hightHoleFirstCollimator,
686                                                   startAngleHoleFirstCollimator,
687                                                   spanningAngleHoleFirstCollimator);
688     
689     G4LogicalVolume* logicBESTHoleFirstCollimator = new G4LogicalVolume(solidBESTHoleFirstCollimator,
690                                                                     holeFirstCollimatorMaterial,
691                                                                     "HoleFirstCollimator",
692                                                                     0, 0, 0);
693     G4double phi = 90. *deg;
694     // Matrix definition for a 90 deg rotation. Also used for other volumes
695     G4RotationMatrix rm;
696     rm.rotateY(phi);
697     
698     physiBESTHoleFirstCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
699                                                  "HoleFirstCollimator",
700                                                  logicBESTHoleFirstCollimator,
701                                                  physiBESTFirstCollimator,
702                                                  false,
703                                                  0);
704     // ------------------//
705     // SECOND COLLIMATOR //
706     //-------------------//
707     // It is a slab of PMMA with an hole in its center
708     const G4double secondCollimatorXPosition = -1900.00*mm;
709     const G4double secondCollimatorYPosition =  0*mm;
710     const G4double secondCollimatorZPosition =  0*mm;
711     
712     physiBESTSecondCollimator = new G4PVPlacement(0, G4ThreeVector(secondCollimatorXPosition,
713                                                                secondCollimatorYPosition,
714                                                                secondCollimatorZPosition),
715                                               "SecondCollimator",
716                                               logicBESTFirstCollimator,
717                                               physicalTreatmentRoom,
718                                               false,
719                                               0);
720     
721     // ------------------------------//
722     // Hole of the second collimator //
723     // ------------------------------//
724     physiBESTHoleSecondCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
725                                                   "HoleSecondCollimator",
726                                                   logicBESTHoleFirstCollimator,
727                                                   physiBESTSecondCollimator,
728                                                   false,
729                                                   0);
730     
731     // --------------------------------------//
732     // FIRST SIDE OF THE MODULATOR BOX      //
733     // --------------------------------------//
734     // The modulator box is an aluminum box in which
735     // the range shifter and the energy modulator are located
736     // In this example only the entrance and exit
737     // faces of the box are simulated.
738     // Each face is an aluminum slab with an hole in its center
739     
740     const G4double firstCollimatorModulatorXSize = 10.*mm;
741     const G4double firstCollimatorModulatorYSize = 200.*mm;
742     const G4double firstCollimatorModulatorZSize = 200.*mm;
743     
744     const G4double firstCollimatorModulatorXPosition = -2523.00*mm;
745     const G4double firstCollimatorModulatorYPosition = 0.*mm;
746     const G4double firstCollimatorModulatorZPosition = 0.*mm;
747     
748    G4Box* solidBESTFirstCollimatorModulatorBox = new G4Box("FirstCollimatorModulatorBox",
749                                                         firstCollimatorModulatorXSize,
750                                                         firstCollimatorModulatorYSize,
751                                                         firstCollimatorModulatorZSize);
752     
753     G4LogicalVolume* logicBESTFirstCollimatorModulatorBox = new G4LogicalVolume(solidBESTFirstCollimatorModulatorBox,
754                                                                             modulatorBoxMaterial,
755                                                                             "FirstCollimatorModulatorBox");
756     
757     physiBESTFirstCollimatorModulatorBox = new G4PVPlacement(0, G4ThreeVector(firstCollimatorModulatorXPosition,
758                                                                           firstCollimatorModulatorYPosition,
759                                                                           firstCollimatorModulatorZPosition),
760                                                          "FirstCollimatorModulatorBox",
761                                                          logicBESTFirstCollimatorModulatorBox,
762                                                          physicalTreatmentRoom, false, 0);
763     
764     // ----------------------------------------------------//
765     //   Hole of the first collimator of the modulator box //
766     // ----------------------------------------------------//
767     const G4double innerRadiusHoleFirstCollimatorModulatorBox = 0.*mm;
768     const G4double outerRadiusHoleFirstCollimatorModulatorBox = 31.*mm;
769     const G4double hightHoleFirstCollimatorModulatorBox = 10.*mm;
770     const G4double startAngleHoleFirstCollimatorModulatorBox = 0.*deg;
771     const G4double spanningAngleHoleFirstCollimatorModulatorBox = 360.*deg;
772     
773     G4Tubs* solidBESTHoleFirstCollimatorModulatorBox  = new G4Tubs("HoleFirstCollimatorModulatorBox",
774                                                                innerRadiusHoleFirstCollimatorModulatorBox,
775                                                                outerRadiusHoleFirstCollimatorModulatorBox,
776                                                                hightHoleFirstCollimatorModulatorBox ,
777                                                                startAngleHoleFirstCollimatorModulatorBox,
778                                                                spanningAngleHoleFirstCollimatorModulatorBox);
779     
780     G4LogicalVolume* logicBESTHoleFirstCollimatorModulatorBox = new G4LogicalVolume(solidBESTHoleFirstCollimatorModulatorBox,
781                                                                                 holeModulatorBoxMaterial,
782                                                                                 "HoleFirstCollimatorModulatorBox",
783                                                                                 0, 0, 0);
784     
785     physiBESTHoleFirstCollimatorModulatorBox = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
786                                                              "HoleFirstCollimatorModulatorBox",
787                                                              logicBESTHoleFirstCollimatorModulatorBox,
788                                                              physiBESTFirstCollimatorModulatorBox, false, 0);
789     
790     // --------------------------------------------------//
791     //       SECOND SIDE OF THE MODULATOR BOX            //
792     // --------------------------------------------------//
793     const G4double secondCollimatorModulatorXSize = 10.*mm;
794     const G4double secondCollimatorModulatorYSize = 200.*mm;
795     const G4double secondCollimatorModulatorZSize = 200.*mm;
796     
797     const G4double secondCollimatorModulatorXPosition = -1953.00 *mm;
798     
799     const G4double secondCollimatorModulatorYPosition = 0.*mm;
800     const G4double secondCollimatorModulatorZPosition = 0.*mm;
801     
802     G4Box* solidBESTSecondCollimatorModulatorBox = new G4Box("SecondCollimatorModulatorBox",
803                                                          secondCollimatorModulatorXSize,
804                                                          secondCollimatorModulatorYSize,
805                                                          secondCollimatorModulatorZSize);
806     
807     G4LogicalVolume* logicBESTSecondCollimatorModulatorBox = new G4LogicalVolume(solidBESTSecondCollimatorModulatorBox,
808                                                                              modulatorBoxMaterial,
809                                                                              "SecondCollimatorModulatorBox");
810     
811     physiBESTSecondCollimatorModulatorBox = new G4PVPlacement(0, G4ThreeVector(secondCollimatorModulatorXPosition,
812                                                                            secondCollimatorModulatorYPosition,
813                                                                            secondCollimatorModulatorZPosition),
814                                                           "SecondCollimatorModulatorBox",
815                                                           logicBESTSecondCollimatorModulatorBox,
816                                                           physicalTreatmentRoom, false, 0);
817     
818     // ----------------------------------------------//
819     //   Hole of the second collimator modulator box //
820     // ----------------------------------------------//
821     const G4double innerRadiusHoleSecondCollimatorModulatorBox = 0.*mm;
822     const G4double outerRadiusHoleSecondCollimatorModulatorBox = 31.*mm;
823     const G4double hightHoleSecondCollimatorModulatorBox = 10.*mm;
824     const G4double startAngleHoleSecondCollimatorModulatorBox = 0.*deg;
825     const G4double spanningAngleHoleSecondCollimatorModulatorBox = 360.*deg;
826     
827     G4Tubs* solidBESTHoleSecondCollimatorModulatorBox  = new G4Tubs("HoleSecondCollimatorModulatorBox",
828                                                                 innerRadiusHoleSecondCollimatorModulatorBox,
829                                                                 outerRadiusHoleSecondCollimatorModulatorBox,
830                                                                 hightHoleSecondCollimatorModulatorBox ,
831                                                                 startAngleHoleSecondCollimatorModulatorBox,
832                                                                 spanningAngleHoleSecondCollimatorModulatorBox);
833     
834     G4LogicalVolume* logicHBESToleSecondCollimatorModulatorBox = new G4LogicalVolume(solidBESTHoleSecondCollimatorModulatorBox,
835                                                                                  holeModulatorBoxMaterial,
836                                                                                  "HoleSecondCollimatorModulatorBox",
837                                                                                  0, 0, 0);
838     
839     physiBESTHoleSecondCollimatorModulatorBox = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
840                                                               "HoleSecondCollimatorModulatorBox",
841                                                              logicHBESToleSecondCollimatorModulatorBox,
842                                                               physiBESTSecondCollimatorModulatorBox, false, 0);
843     
844     logicBESTFirstCollimator -> SetVisAttributes(yellow);
845     logicBESTFirstCollimatorModulatorBox -> SetVisAttributes(blue);
846     logicBESTSecondCollimatorModulatorBox -> SetVisAttributes(blue);
847 
848 
849   
850   }
851 
852 /////////////////////////////////////////////////////////////////////////////
853 void BESTPassiveProtonBeamLine::BESTBeamMonitoring()
854 {
855 
856 //////// Double-GAP Monitor Chamber ////////////
857   
858     G4double fBoxOuterThickness { 100 * mm };
859     G4double fBoxOuterHeight { 42 * cm };
860     G4double fBoxOuterWidth { 42 * cm };
861     G4double fEnterWindowThickness { 25 * um };
862     G4double fCentralWindowThickness { 20 * um };
863     G4double fExitWindowThickness { 25 * um };
864     G4double fBoxInnerThickness { fBoxOuterThickness - fEnterWindowThickness - fExitWindowThickness };
865     G4double fBoxInnerHeight { 41.95 * cm };
866     G4double fBoxInnerWidth { 41.95 * cm };
867     G4double fInnerHeight { 16 * cm };
868     G4double fInnerWidth { 16 * cm };
869     G4double fCentralElectrodeThickness { 2 * um };
870     G4double fCopperLayerThickness { 5 * um };
871     G4double fKaptonLayerThickness { 25 * um };
872     G4double fNickelLayerThickness { 2 * um };
873     G4double fFirstCavityThickness { 5 * mm };
874     G4double fSecondCavityThickness { 10 * mm };
875 
876     G4double monitor1XPosition = -1059.0 *mm;
877     G4String name;
878 
879 G4double phi = 90. *deg;
880     // Matrix definition for a 90 deg rotation. Also used for other volumes
881     G4RotationMatrix rm;
882     rm.rotateY(phi);
883     
884   
885     name = "monitorChamber-externalBox";
886     G4Box* chamberSolid = new G4Box(name, fBoxOuterWidth / 2, fBoxOuterHeight / 2, fBoxOuterThickness / 2);
887     G4LogicalVolume* chamberLog = new G4LogicalVolume(chamberSolid, wallMaterial, name);
888     chamberPhys=new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(monitor1XPosition-10*cm,0.*cm,0.*cm)),name,chamberLog,physicalTreatmentRoom,
889                                                 false,
890                                                 0);
891    // chamberLog->SetVisAttributes(green);
892 
893     name = "monitorChamber-innerBox";
894    
895     G4Box* innerchamberSolid = new G4Box(name, fBoxInnerWidth / 2, fBoxInnerHeight / 2, fBoxInnerThickness / 2);
896     G4LogicalVolume* innerchamberLog = new G4LogicalVolume(innerchamberSolid, CavityMaterial, name);
897     innerchamberPhys=new G4PVPlacement(0, G4ThreeVector(0,0,0), name,innerchamberLog, chamberPhys, false, 0);
898    // innerchamberLog->SetVisAttributes(green);
899 
900     name = "monitorChamber-enterWindow";
901  
902 
903     G4Box* enterWindowSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fEnterWindowThickness / 2);
904     G4LogicalVolume* enterWindowLog = new G4LogicalVolume(enterWindowSolid, WindowMaterial, name);
905     enterWindowPhys= new G4PVPlacement(0,  G4ThreeVector((-fBoxOuterThickness + fEnterWindowThickness) / 2,0, 0), name,enterWindowLog, chamberPhys, false, 0);
906     enterWindowLog->SetVisAttributes(green);
907 
908     name = "monitorChamber-enterElectrode";
909     G4double enterElectrodeThickness = fCopperLayerThickness + fKaptonLayerThickness + fNickelLayerThickness;
910     G4double exitElectrodeThickness = enterElectrodeThickness;
911    
912     G4Box* enterElectrodeSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, enterElectrodeThickness / 2);
913     G4LogicalVolume* enterElectrodeLog = new G4LogicalVolume(enterElectrodeSolid, CavityMaterial, name);
914 
915     enterElectrodePhys=new G4PVPlacement(0, G4ThreeVector(-(fCentralWindowThickness + enterElectrodeThickness) / 2 - (fCentralElectrodeThickness + fFirstCavityThickness),0,0),  name,enterElectrodeLog, innerchamberPhys, false, 0);
916     enterElectrodeLog->SetVisAttributes(green);
917 
918     name = "monitorChamber-kaptonLayer1";
919     G4double position_kaptonLayer1 =-enterElectrodeThickness+fKaptonLayerThickness / 2;
920     G4Box* kaptonLayerSolid1 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fKaptonLayerThickness / 2);
921     G4LogicalVolume* kaptonLayerLog1 = new G4LogicalVolume(kaptonLayerSolid1,  KaptonLayerMaterial, name);
922     kaptonLayerPhys1= new G4PVPlacement(0, G4ThreeVector(position_kaptonLayer1,0,0),  name,kaptonLayerLog1, enterElectrodePhys, false, 0);
923     kaptonLayerLog1->SetVisAttributes(green);
924 
925     name = "monitorChamber-copperLayer1";
926  
927 G4double position_copperLayer1=position_kaptonLayer1+(fKaptonLayerThickness+fCopperLayerThickness)/2;
928     G4Box* copperLayerSolid1 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCopperLayerThickness / 2);
929     G4LogicalVolume* copperLayerLog1 = new G4LogicalVolume(copperLayerSolid1, CopperLayerMaterial, name);
930     copperLayerPhys1=new G4PVPlacement(0, G4ThreeVector(position_copperLayer1,0,0), name,copperLayerLog1, enterElectrodePhys, false, 0);
931 
932     name = "monitorChamber-nickelLayer1";
933  
934 G4double position_nichelLayer1=position_copperLayer1+(fCopperLayerThickness + fNickelLayerThickness)/2;
935 
936     G4Box* nickelLayerSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fNickelLayerThickness / 2);
937     G4LogicalVolume* nickelLayerLog1 = new G4LogicalVolume(nickelLayerSolid,  NichelLayerMaterial, name);
938     nickelLayerPhys1=new G4PVPlacement(0,  G4ThreeVector(position_nichelLayer1,0,0), name,nickelLayerLog1, enterElectrodePhys, false, 0);
939 
940     name = "monitorChamber-firstCavity";
941   
942   
943 G4double position_firstCavity=-fCentralWindowThickness/2-fCentralElectrodeThickness-(fFirstCavityThickness) / 2;
944     G4Box* firstCavitySolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fFirstCavityThickness / 2);
945     G4LogicalVolume*fFirstCavityLog = new G4LogicalVolume(firstCavitySolid, CavityMaterial, name);
946     fFirstCavityPhys=new G4PVPlacement(0,  G4ThreeVector( position_firstCavity,0,0), name, fFirstCavityLog, innerchamberPhys, false, 0);
947 
948     name = "monitorChamber-centralElectrode1";
949  
950 G4double position_centralElectrode1=(-fCentralWindowThickness-fCentralElectrodeThickness) / 2;
951     G4Box* centralElectrode1Solid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCentralElectrodeThickness / 2);
952     G4LogicalVolume* centralElectrode1Log = new G4LogicalVolume(centralElectrode1Solid, ElectrodeMaterial, name);
953     centralElectrode1Phys=new G4PVPlacement(0, G4ThreeVector(position_centralElectrode1,0,0), name,centralElectrode1Log, innerchamberPhys, false, 0);
954 
955     name = "monitorChamber-centralWindow";
956   //  position={0,0,0};
957     G4Box* centralWindowSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCentralWindowThickness / 2);
958     G4LogicalVolume* centralWindowLog = new G4LogicalVolume(centralWindowSolid, CentralWindowMaterial, name);
959     centralWindowPhys =new G4PVPlacement(0, G4ThreeVector(0,0,0),  name,centralWindowLog, innerchamberPhys, false, 0);
960     centralWindowLog->SetVisAttributes(green);
961 
962     name = "monitorChamber-centralElectrode2";
963  
964 G4double position_centralElectrode2=(fCentralWindowThickness+fCentralElectrodeThickness) / 2;
965     G4Box* centralElectrode2Solid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCentralElectrodeThickness / 2);
966     G4LogicalVolume* centralElectrode2Log = new G4LogicalVolume(centralElectrode2Solid, ElectrodeMaterial, name);
967    centralElectrode2Phys= new G4PVPlacement(0, G4ThreeVector(position_centralElectrode2,0,0),name, centralElectrode2Log,innerchamberPhys, false, 0);
968 
969     name = "monitorChamber-secondCavity";
970  
971 G4double position_secondCavity=(fCentralWindowThickness)/2+fCentralElectrodeThickness+(fSecondCavityThickness) / 2;
972     G4Box* secondCavitySolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fSecondCavityThickness / 2);
973     G4LogicalVolume*fSecondCavityLog = new G4LogicalVolume(secondCavitySolid, CavityMaterial, name);
974     fSecondCavityPhys=new G4PVPlacement(0, G4ThreeVector(position_secondCavity,0,0), name, fSecondCavityLog, innerchamberPhys, false, 0);
975 
976     name="monitorChamber-exitElectrode";
977   
978 G4double position_exitElectrode=(fCentralWindowThickness)/2+fCentralElectrodeThickness+fSecondCavityThickness+(exitElectrodeThickness) / 2;
979     G4Box* exitElectrodeSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, exitElectrodeThickness / 2);
980     G4LogicalVolume* exitElectrodeLog = new G4LogicalVolume(exitElectrodeSolid, ElectrodeMaterial, name);
981     exitElectrodePhys=new G4PVPlacement(0, G4ThreeVector(position_exitElectrode,0,0), name,exitElectrodeLog,innerchamberPhys, false, 0);
982     exitElectrodeLog->SetVisAttributes(green);
983 
984     name = "monitorChamber-kaptonLayer2";
985    
986 G4double position_kaptonLayer2=(exitElectrodeThickness-fKaptonLayerThickness) / 2;
987     G4Box* kaptonLayerSolid2 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fKaptonLayerThickness / 2);
988     G4LogicalVolume* kaptonLayerLog2 = new G4LogicalVolume(kaptonLayerSolid2,  KaptonLayerMaterial, name);
989     kaptonLayerPhys2=new G4PVPlacement(0, G4ThreeVector(position_kaptonLayer2,0,0), name,kaptonLayerLog2, exitElectrodePhys, false, 0);
990 
991     name = "monitorChamber-copperLayer2";
992   
993 G4double position_copperLayer2=(exitElectrodeThickness)/2-fKaptonLayerThickness-(fCopperLayerThickness)/2;
994     G4Box* copperLayerSolid2 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCopperLayerThickness / 2);
995     G4LogicalVolume* copperLayerLog2 = new G4LogicalVolume(copperLayerSolid2,  CopperLayerMaterial, name);
996     copperLayerPhys2=new G4PVPlacement(0, G4ThreeVector(position_copperLayer2,0,0), name, copperLayerLog2, exitElectrodePhys, false, 0);
997 
998     name = "monitorChamber-nickelLayer2";
999   
1000 G4double position_nichelLayer2=(exitElectrodeThickness)/2-fKaptonLayerThickness-fCopperLayerThickness-fNickelLayerThickness/2;
1001 
1002     G4Box* nickelLayerSolid2 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fNickelLayerThickness / 2);
1003     G4LogicalVolume* nickelLayerLog2 = new G4LogicalVolume(nickelLayerSolid2,  NichelLayerMaterial, name);
1004      nickelLayerPhys2=new G4PVPlacement(0, G4ThreeVector(position_nichelLayer2,0,0), name,nickelLayerLog2, exitElectrodePhys, false, 0);
1005 
1006     name = "monitorChamber-exitWindow";
1007  
1008 G4double position_exitWindow=(fBoxOuterThickness - fEnterWindowThickness) / 2;
1009     G4Box* exitWindowSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fExitWindowThickness / 2);
1010     G4LogicalVolume* exitWindowLog = new G4LogicalVolume(exitWindowSolid, WindowMaterial, name);
1011    exitWindowPhys= new G4PVPlacement(0, G4ThreeVector(position_exitWindow,0,0), name,exitWindowLog, chamberPhys, false, 0);
1012     exitWindowLog->SetVisAttributes(green);
1013 
1014     
1015      }
1016 /////////////////////////////////////////////////////////////////////////////
1017 void BESTPassiveProtonBeamLine::BESTBeamNozzle()
1018 {
1019     // ------------------------------//
1020     // THE FINAL TUBE AND COLLIMATOR //
1021     //-------------------------------//
1022     // The last part of the transport beam line consists of
1023     // a 59 mm thick PMMA slab (to stop all the diffused radiation), a 370 mm brass tube
1024     // (to well collimate the proton beam) and a final collimator with 25 mm diameter
1025     // aperture (that provide the final trasversal shape of the beam)
1026     
1027     // -------------------//
1028     //     PMMA SUPPORT   //
1029     // -------------------//
1030     const G4double nozzleSupportXSize = 29.5 *mm;
1031     const G4double nozzleSupportYSize = 180. *mm;
1032     const G4double nozzleSupportZSize = 180. *mm;
1033     
1034     const G4double nozzleSupportXPosition = -397.50 *mm;
1035     
1036     G4double phi = 90. *deg;
1037     // Matrix definition for a 90 deg rotation. Also used for other volumes
1038     G4RotationMatrix rm;
1039     rm.rotateY(phi);
1040     
1041     G4Box* solidNozzleSupport = new G4Box("NozzleSupport",
1042                                           nozzleSupportXSize,
1043                                           nozzleSupportYSize,
1044                                           nozzleSupportZSize);
1045     
1046     G4LogicalVolume* logicNozzleSupport = new G4LogicalVolume(solidNozzleSupport,
1047                                                               nozzleSupportMaterial,
1048                                                               "NozzleSupport");
1049     
1050     physiNozzleSupport = new G4PVPlacement(0, G4ThreeVector(nozzleSupportXPosition,0., 0.),
1051                                            "NozzleSupport",
1052                                            logicNozzleSupport,
1053                                            physicalTreatmentRoom,
1054                                            false,
1055                                            0);
1056     
1057     logicNozzleSupport -> SetVisAttributes(yellow);
1058     
1059     
1060     
1061     //------------------------------------//
1062     // HOLE IN THE SUPPORT                //
1063     //------------------------------------//
1064     const G4double innerRadiusHoleNozzleSupport = 0.*mm;
1065     const G4double outerRadiusHoleNozzleSupport = 21.5*mm;
1066     const G4double hightHoleNozzleSupport = 29.5 *mm;
1067     const G4double startAngleHoleNozzleSupport = 0.*deg;
1068     const G4double spanningAngleHoleNozzleSupport = 360.*deg;
1069     
1070     G4Tubs* solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport",
1071                                                 innerRadiusHoleNozzleSupport,
1072                                                 outerRadiusHoleNozzleSupport,
1073                                                 hightHoleNozzleSupport,
1074                                                 startAngleHoleNozzleSupport,
1075                                                 spanningAngleHoleNozzleSupport);
1076     
1077     G4LogicalVolume* logicHoleNozzleSupport = new G4LogicalVolume(solidHoleNozzleSupport,
1078                                                                   holeNozzleSupportMaterial,
1079                                                                   "HoleNozzleSupport",
1080                                                                   0,
1081                                                                   0,
1082                                                                   0);
1083     
1084     
1085     physiHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
1086                                                "HoleNozzleSupport",
1087                                                logicHoleNozzleSupport,
1088                                                physiNozzleSupport,
1089                                                false, 0);
1090     
1091     logicHoleNozzleSupport -> SetVisAttributes(darkOrange3);
1092     
1093     // ---------------------------------//
1094     //     BRASS TUBE 1 (phantom side)    //
1095     // ---------------------------------//
1096     const G4double innerRadiusBrassTube= 18.*mm;
1097     const G4double outerRadiusBrassTube = 21.5 *mm;
1098     const G4double hightBrassTube = 140.5*mm;
1099     const G4double startAngleBrassTube = 0.*deg;
1100     const G4double spanningAngleBrassTube = 360.*deg;
1101     
1102     const G4double brassTubeXPosition = -227.5 *mm;
1103     
1104     G4Tubs* solidBrassTube = new G4Tubs("BrassTube",
1105                                         innerRadiusBrassTube,
1106                                         outerRadiusBrassTube,
1107                                         hightBrassTube,
1108                                         startAngleBrassTube,
1109                                         spanningAngleBrassTube);
1110     
1111     G4LogicalVolume* logicBrassTube = new G4LogicalVolume(solidBrassTube,
1112                                                           brassTubeMaterial,
1113                                                           "BrassTube",
1114                                                           0, 0, 0);
1115     
1116     physiBrassTube = new G4PVPlacement(G4Transform3D(rm,
1117                                                      G4ThreeVector(brassTubeXPosition,
1118                                                                    0.,
1119                                                                    0.)),
1120                                        "BrassTube",
1121                                        logicBrassTube,
1122                                        physicalTreatmentRoom,
1123                                        false,
1124                                        0);
1125     
1126     logicBrassTube -> SetVisAttributes(darkOrange3);
1127     
1128     // ----------------------------------------------//
1129     //     BRASS TUBE 2 (inside the PMMA support)    //
1130     // ----------------------------------------------//
1131     const G4double innerRadiusBrassTube2= 18.*mm;
1132     const G4double outerRadiusBrassTube2 = 21.5 *mm;
1133     const G4double hightBrassTube2 = 29.5*mm;
1134     const G4double startAngleBrassTube2 = 0.*deg;
1135     const G4double spanningAngleBrassTube2 = 360.*deg;
1136     
1137     
1138     G4Tubs* solidBrassTube2 = new G4Tubs("BrassTube2",
1139                                          innerRadiusBrassTube2,
1140                                          outerRadiusBrassTube2,
1141                                          hightBrassTube2,
1142                                          startAngleBrassTube2,
1143                                          spanningAngleBrassTube2);
1144     
1145     G4LogicalVolume* logicBrassTube2 = new G4LogicalVolume(solidBrassTube2,
1146                                                            brassTube2Material,
1147                                                            "BrassTube2",
1148                                                            0, 0, 0);
1149     
1150     physiBrassTube2 = new G4PVPlacement(0,
1151                                         G4ThreeVector(0,0.,0.),
1152                                         logicBrassTube2,
1153                                         "BrassTube2",
1154                                         logicHoleNozzleSupport,
1155                                         false,
1156                                         0);
1157     
1158     logicBrassTube2 -> SetVisAttributes(darkOrange3);
1159     
1160     
1161     // --------------------------------------//
1162     //     BRASS TUBE 3 (beam line side)    //
1163     // -------------------------------------//
1164     const G4double innerRadiusBrassTube3= 18.*mm;
1165     const G4double outerRadiusBrassTube3 = 21.5 *mm;
1166     const G4double hightBrassTube3 = 10.0 *mm;
1167     const G4double startAngleBrassTube3 = 0.*deg;
1168     const G4double spanningAngleBrassTube3 = 360.*deg;
1169     
1170     const G4double brassTube3XPosition = -437 *mm;
1171     
1172     G4Tubs* solidBrassTube3 = new G4Tubs("BrassTube3",
1173                                          innerRadiusBrassTube3,
1174                                          outerRadiusBrassTube3,
1175                                          hightBrassTube3,
1176                                          startAngleBrassTube3,
1177                                          spanningAngleBrassTube3);
1178     
1179     G4LogicalVolume* logicBrassTube3 = new G4LogicalVolume(solidBrassTube3,
1180                                                            brassTube3Material,
1181                                                            "BrassTube3",
1182                                                            0, 0, 0);
1183     
1184     physiBrassTube3 = new G4PVPlacement(G4Transform3D(rm,
1185                                                       G4ThreeVector(brassTube3XPosition,
1186                                                                     0.,
1187                                                                     0.)),
1188                                         "BrassTube3",
1189                                         logicBrassTube3,
1190                                         physicalTreatmentRoom,
1191                                         false,
1192                                         0);
1193     
1194     logicBrassTube3 -> SetVisAttributes(darkOrange3);
1195 }
1196 
1197 /////////////////////////////////////////////////////////////////////////////
1198 void BESTPassiveProtonBeamLine::BESTBeamFinalCollimator()
1199 {
1200     // -----------------------//
1201     //     FINAL COLLIMATOR   //
1202     //------------------------//
1203     const G4double outerRadiusFinalCollimator = 21.5*mm;
1204     const G4double hightFinalCollimator = 4.5*mm;
1205     const G4double startAngleFinalCollimator = 0.*deg;
1206     const G4double spanningAngleFinalCollimator = 360.*deg;
1207     const G4double finalCollimatorXPosition = -82.5 *mm;
1208     
1209     G4double phi = 90. *deg;
1210     
1211     // Matrix definition for a 90 deg rotation. Also used for other volumes
1212     G4RotationMatrix rm;
1213     rm.rotateY(phi);
1214     
1215     solidFinalCollimator = new G4Tubs("FinalCollimator",
1216                                       BESTinnerRadiusFinalCollimator,
1217                                       outerRadiusFinalCollimator,
1218                                       hightFinalCollimator,
1219                                       startAngleFinalCollimator,
1220                                       spanningAngleFinalCollimator);
1221     
1222     G4LogicalVolume* logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator,
1223                                                                 finalCollimatorMaterial,
1224                                                                 "FinalCollimator",
1225                                                                 0,
1226                                                                 0,
1227                                                                 0);
1228     
1229     physiFinalCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(finalCollimatorXPosition,0.,0.)),
1230                                              "FinalCollimator", logicFinalCollimator, physicalTreatmentRoom, false, 0);
1231     
1232     logicFinalCollimator -> SetVisAttributes(yellow);
1233 }
1234 /////////////////////////// MESSENGER ///////////////////////////////////////
1235 /////////////////////////////////////////////////////////////////////////////
1236 
1237 
1238 /////////////////////////////////////////////////////////////////////////////
1239 void BESTPassiveProtonBeamLine::SetRangeShifterXSize(G4double value)
1240 {
1241     solidBESTRangeShifterBox -> SetXHalfLength(value) ;
1242     G4cout << "RangeShifter size X (mm): "<< ((solidBESTRangeShifterBox -> GetXHalfLength())*2.)/mm
1243     << G4endl;
1244     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1245 }
1246 
1247 /////////////////////////////////////////////////////////////////////////////
1248 void BESTPassiveProtonBeamLine::SetFirstScatteringFoilXSize(G4double value)
1249 {
1250     BESTfirstScatteringFoil -> SetXHalfLength(value);
1251     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1252     G4cout <<"The X size of the first scattering foil is (mm):"<<
1253     ((BESTfirstScatteringFoil -> GetXHalfLength())*2.)/mm
1254     << G4endl;
1255 }
1256 
1257 /////////////////////////////////////////////////////////////////////////////
1258 void BESTPassiveProtonBeamLine::SetSecondScatteringFoilXSize(G4double value)
1259 {
1260     BESTsecondScatteringFoil -> SetXHalfLength(value);
1261     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1262     G4cout <<"The X size of the second scattering foil is (mm):"<<
1263     ((BESTsecondScatteringFoil -> GetXHalfLength())*2.)/mm
1264     << G4endl;
1265 }
1266 
1267 /////////////////////////////////////////////////////////////////////////////
1268 void BESTPassiveProtonBeamLine::SetOuterRadiusStopper(G4double value)
1269 {
1270     solidBESTStopper -> SetOuterRadius(value);
1271     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1272     G4cout << "OuterRadius od the Stopper is (mm):"
1273     << solidBESTStopper -> GetOuterRadius()/mm
1274     << G4endl;
1275 }
1276 
1277 /////////////////////////////////////////////////////////////////////////////
1278 void BESTPassiveProtonBeamLine::SetInnerRadiusFinalCollimator(G4double value)
1279 {
1280     solidFinalCollimator -> SetInnerRadius(value);
1281     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1282     G4cout<<"Inner Radius of the final collimator is (mm):"
1283   << solidFinalCollimator -> GetInnerRadius()/mm
1284   << G4endl;
1285 }
1286 
1287 /////////////////////////////////////////////////////////////////////////////
1288 void BESTPassiveProtonBeamLine::SetRSMaterial(G4String materialChoice)
1289 {
1290     if (G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice, false) )
1291     {
1292         if (pttoMaterial)
1293         {
1294             rangeShifterMaterial  = pttoMaterial;
1295             logicBESTRangeShifterBox -> SetMaterial(pttoMaterial);
1296             G4cout << "The material of the Range Shifter has been changed to " << materialChoice << G4endl;
1297         }
1298     }
1299     else
1300     {
1301         G4cout << "WARNING: material \"" << materialChoice << "\" doesn't exist in NIST elements/materials"
1302       " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
1303         G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
1304     }
1305 }
1306 
1307 /////////////////////////////////////////////////////////////////////////////
1308 void BESTPassiveProtonBeamLine::SetModulatorAngle(G4double value)
1309 {
1310     modulator -> SetModulatorAngle(value);
1311     //G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1312 }
1313 /////////////////////////////////////////////////////////////////////////////
1314