Geant4 Cross Reference

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

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

Diff markup

Differences between /examples/advanced/hadrontherapy/src/PassiveProtonBeamLine.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/PassiveProtonBeamLine.cc (Version 9.5.p2)


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