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 ]

Diff markup

Differences between /examples/advanced/hadrontherapy/src/BESTPassiveProtonBeamline.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/BESTPassiveProtonBeamline.cc (Version 11.2.2)


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