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 10.2.p3)


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