Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/hadrontherapy/src/PassiveCarbonBeamLine.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/PassiveCarbonBeamLine.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/PassiveCarbonBeamLine.cc (Version 10.0.p4)


  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 // **************************************************************************************
 27 // See more at: https://twiki.cern.ch/twiki/bi <<  27 //
 28 // Simulation of the "Zero degree" experimenta <<  28 // HADRONTHERAPY:  a Geant4-based application for proton/ion-therapy studies
                                                   >>  29 // _________________________________________________________________________
                                                   >>  30 //
                                                   >>  31 // This is the FULL version of the Hadrontherapy application.
                                                   >>  32 // It is based on the Geant4 toolkit classes and released under the GPL3 license.
                                                   >>  33 //
                                                   >>  34 // Its basic version is released and maintained inside the Geant4 code
                                                   >>  35 // as Advanced Example.
                                                   >>  36 //
                                                   >>  37 // To compile and run Hadrontherapy you only require the installation of Geant4 and,
                                                   >>  38 // if you wish, the ROOT ananlysis program.
                                                   >>  39 //
                                                   >>  40 // For more information see the documentation at http://sites.google.com/site/hadrontherapy/
                                                   >>  41 // or contact cirrone@lns.infn.it
                                                   >>  42 //
                                                   >>  43 // **************************************************************************************
                                                   >>  44 
 29                                                    45 
 30 #include "G4Box.hh"                                46 #include "G4Box.hh"
 31 #include "G4Tubs.hh"                               47 #include "G4Tubs.hh"
 32 #include "G4VisAttributes.hh"                      48 #include "G4VisAttributes.hh"
 33 #include "G4Colour.hh"                             49 #include "G4Colour.hh"
 34 #include "globals.hh"                              50 #include "globals.hh"
 35 #include "G4RunManager.hh"                         51 #include "G4RunManager.hh"
 36 #include "G4LogicalVolume.hh"                      52 #include "G4LogicalVolume.hh"
 37 #include "G4PVPlacement.hh"                        53 #include "G4PVPlacement.hh"
 38 #include "G4RotationMatrix.hh"                     54 #include "G4RotationMatrix.hh"
 39 #include "G4NistManager.hh"                        55 #include "G4NistManager.hh"
 40 #include "G4NistElementBuilder.hh"                 56 #include "G4NistElementBuilder.hh"
 41 #include "HadrontherapyDetectorConstruction.hh     57 #include "HadrontherapyDetectorConstruction.hh"
 42 #include "HadrontherapyModulator.hh"               58 #include "HadrontherapyModulator.hh"
 43 #include "PassiveCarbonBeamLine.hh"                59 #include "PassiveCarbonBeamLine.hh"
 44 #include "G4SystemOfUnits.hh"                      60 #include "G4SystemOfUnits.hh"
 45 #include "G4Trd.hh"                            << 
 46 #include "PassiveCarbonBeamLineMessenger.hh"   << 
 47 #include "G4UnionSolid.hh"                     << 
 48                                                    61 
 49 using namespace std;                           << 
 50                                                    62 
 51 //G4bool PassiveCarbonBeamLine::doCalculation  <<  63 
                                                   >>  64 
 52 //////////////////////////////////////////////     65 /////////////////////////////////////////////////////////////////////////////
 53 PassiveCarbonBeamLine::PassiveCarbonBeamLine()     66 PassiveCarbonBeamLine::PassiveCarbonBeamLine():
 54 physicalTreatmentRoom(0),hadrontherapyDetector <<  67 physicalTreatmentRoom(0), hadrontherapyDetectorConstruction(0),
 55 physiBeamLineSupport(0), physiBeamLineCover(0) <<  68 physiBeamLineSupport(0), physiBeamLineCover(0), physiBeamLineCover2(0), 
 56 physiKaptonWindow(0),PhysiRippleFilter(0),Phys <<  69 physiKaptonWindow(0), 
 57 physiFirstMonitorLayer1(0), physiFirstMonitorL     70 physiFirstMonitorLayer1(0), physiFirstMonitorLayer2(0),
 58 physiFirstMonitorLayer3(0), physiFirstMonitorL     71 physiFirstMonitorLayer3(0), physiFirstMonitorLayer4(0),
 59 physiNozzleSupport(0), physiHoleNozzleSupport( <<  72 physiNozzleSupport(0), physiHoleNozzleSupport(0),
 60 {                                              <<  73 physiSecondHoleNozzleSupport(0),
 61                                                <<  74 solidFinalCollimator(0),
 62     // Messenger to change parameters of the p <<  75 physiFinalCollimator(0)
 63     PassiveCarbonMessenger = new PassiveCarbon <<  76 {
 64                                                <<  77   // Messenger to change parameters of the passiveProtonBeamLine geometry
 65     //***************************** PW ******* <<  78   //passiveMessenger = new PassiveProtonBeamLineMessenger(this);
 66                                                <<  79   
 67     static G4String ROGeometryName = "Detector <<  80 //***************************** PW ***************************************
 68     RO = new HadrontherapyDetectorROGeometry(R <<  81 
 69                                                <<  82   static G4String ROGeometryName = "DetectorROGeometry";
 70                                                <<  83   RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
 71     G4cout << "Going to register Parallel worl <<  84   
 72     RegisterParallelWorld(RO);                 <<  85   
 73     G4cout << "... done" << G4endl;            <<  86 
 74     //***************************** PW ******* <<  87   G4cout << "Going to register Parallel world...";
                                                   >>  88   RegisterParallelWorld(RO);
                                                   >>  89   G4cout << "... done" << G4endl;
                                                   >>  90 //***************************** PW ***************************************
                                                   >>  91 
                                                   >>  92 
                                                   >>  93 
 75 }                                                  94 }
 76                                                    95 
 77 //////////////////////////////////////////////     96 /////////////////////////////////////////////////////////////////////////////
 78 PassiveCarbonBeamLine::~PassiveCarbonBeamLine(     97 PassiveCarbonBeamLine::~PassiveCarbonBeamLine()
 79 {                                                  98 {
 80     delete hadrontherapyDetectorConstruction;  <<  99   //delete passiveMessenger;
 81     delete PassiveCarbonMessenger;             << 100   delete hadrontherapyDetectorConstruction;
 82 }                                                 101 }
 83                                                   102 
 84 //////////////////////////////////////////////    103 /////////////////////////////////////////////////////////////////////////////
 85 G4VPhysicalVolume* PassiveCarbonBeamLine::Cons    104 G4VPhysicalVolume* PassiveCarbonBeamLine::Construct()
 86 {                                              << 105 { 
 87     // Sets default geometry and materials     << 106   // Sets default geometry and materials
 88     SetDefaultDimensions();                    << 107   SetDefaultDimensions();
 89                                                << 108   
 90     // Construct the whole CarbonPassive Beam  << 109   // Construct the whole CarbonPassive Beam Line 
 91     ConstructPassiveCarbonBeamLine();          << 110   ConstructPassiveCarbonBeamLine();
 92                                                << 111   
 93                                                << 112   
 94     //***************************** PW ******* << 113 //***************************** PW ***************************************
 95     if (!hadrontherapyDetectorConstruction)    << 114   if (!hadrontherapyDetectorConstruction)
 96                                                << 115 
 97         //***************************** PW *** << 116 //***************************** PW ***************************************
 98         // HadrontherapyDetectorConstruction b << 117   
 99         hadrontherapyDetectorConstruction = ne << 118   // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
100                                                << 119   hadrontherapyDetectorConstruction = new HadrontherapyDetectorConstruction(physicalTreatmentRoom); 
101     //***************************** PW ******* << 120   
102                                                << 121 //***************************** PW ***************************************
103     hadrontherapyDetectorConstruction->Initial << 122 
104                                                << 123  hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
105     //***************************** PW ******* << 124 
106     return physicalTreatmentRoom;              << 125 //***************************** PW ***************************************
                                                   >> 126   
                                                   >> 127   
                                                   >> 128   return physicalTreatmentRoom;
107 }                                                 129 }
108                                                   130 
109 // In the following method the DEFAULTS used i << 131 // In the following method the DEFAULTS used in the geometry of 
110 // passive beam line are provided                 132 // passive beam line are provided
111 // HERE THE USER CAN CHANGE THE GEOMETRY CHARA    133 // HERE THE USER CAN CHANGE THE GEOMETRY CHARACTERISTICS OF BEAM
112 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE << 134 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE THE MACRO FILE (IF A 
113 // MESSENGER IS PROVIDED)                         135 // MESSENGER IS PROVIDED)
114 //                                                136 //
115 // DEFAULT MATERIAL ARE ALSO PROVIDED          << 137 // DEFAULT MATERIAL ARE ALSO PROVIDED 
116 // and COLOURS ARE ALSO DEFINED                   138 // and COLOURS ARE ALSO DEFINED
117 // -------------------------------------------    139 // ----------------------------------------------------------
118 //////////////////////////////////////////////    140 /////////////////////////////////////////////////////////////////////////////
119 void PassiveCarbonBeamLine::SetDefaultDimensio    141 void PassiveCarbonBeamLine::SetDefaultDimensions()
120 {                                                 142 {
121     // Set of coulors that can be used         << 143   // Set of coulors that can be used
122     white = new G4VisAttributes( G4Colour());  << 144   white = new G4VisAttributes( G4Colour());
123     white -> SetVisibility(true);              << 145   white -> SetVisibility(true);
124     white -> SetForceSolid(true);              << 146   white -> SetForceSolid(true);
125                                                << 147   
126     black = new G4VisAttributes( G4Colour(1.,  << 148   blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
127     black -> SetVisibility(true);              << 149   blue -> SetVisibility(true);
128     black -> SetForceSolid(true);              << 150   blue -> SetForceSolid(true);
129                                                << 151   
130                                                << 152   gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5 ));
131     blue = new G4VisAttributes(G4Colour(0. ,0. << 153   gray-> SetVisibility(true);
132     blue -> SetVisibility(true);               << 154   gray-> SetForceSolid(true);
133     blue -> SetForceSolid(true);               << 155   
134                                                << 156   red = new G4VisAttributes(G4Colour(1. ,0. ,0.));
135     gray = new G4VisAttributes( G4Colour(0.5,  << 157   red-> SetVisibility(true);
136     gray-> SetVisibility(true);                << 158   red-> SetForceSolid(true);
137     gray-> SetForceSolid(true);                << 159   
138                                                << 160   yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
139     red = new G4VisAttributes(G4Colour(1. ,0.  << 161   yellow-> SetVisibility(true);
140     red-> SetVisibility(true);                 << 162   yellow-> SetForceSolid(true);
141     red-> SetForceSolid(true);                 << 163   
142                                                << 164   green = new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
143     yellow = new G4VisAttributes(G4Colour(1.,  << 165   green -> SetVisibility(true);
144     yellow-> SetVisibility(true);              << 166   green -> SetForceSolid(true);
145     yellow-> SetForceSolid(true);              << 167   
146                                                << 168   darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. ,  0/255. ));
147     green = new G4VisAttributes( G4Colour(25/2 << 169   darkGreen -> SetVisibility(true);
148     green -> SetVisibility(true);              << 170   darkGreen -> SetForceSolid(true);
149     green -> SetForceSolid(true);              << 171   
150                                                << 172   darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. ,  000/255. ));
151     darkGreen = new G4VisAttributes( G4Colour( << 173   darkOrange3 -> SetVisibility(true);
152     darkGreen -> SetVisibility(true);          << 174   darkOrange3 -> SetForceSolid(true);
153     darkGreen -> SetForceSolid(true);          << 175   
154                                                << 176   skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. ,  235/255. ));
155     darkOrange3 = new G4VisAttributes( G4Colou << 177   skyBlue -> SetVisibility(true);
156     darkOrange3 -> SetVisibility(true);        << 178   skyBlue -> SetForceSolid(true);
157     darkOrange3 -> SetForceSolid(true);        << 179   
158                                                << 180   
159     skyBlue = new G4VisAttributes( G4Colour(13 << 181   // VACUUM PIPE: first track of the beam line is inside vacuum;
160     skyBlue -> SetVisibility(true);            << 182   // The PIPE contains  KAPTON WINDOW
161     skyBlue -> SetForceSolid(true);            << 183   G4double defaultVacuumZoneXSize = 80.5325 *mm;
162                                                << 184   vacuumZoneXSize = defaultVacuumZoneXSize;
163                                                << 185   
164     // FINAL COLLIMATOR: is the collimator giv << 186   G4double defaultVacuumZoneYSize = 52.5 *mm;
165     // of the beam                             << 187   vacuumZoneYSize = defaultVacuumZoneYSize;
166                                                << 188   
167     G4double defaultinnerRadiusFinalCollimator << 189   G4double defaultVacuumZoneZSize = 52.5 *mm;
168     innerRadiusFinalCollimator = defaultinnerR << 190   vacuumZoneZSize = defaultVacuumZoneZSize;
169                                                << 191   
170     // DEFAULT DEFINITION OF THE MATERIALS     << 192   // XXX -1775 mm (xKapton to WORLD) - 80.5075 (xKapton to vacuumZone) 
171     // All elements and compound definition fo << 193   G4double defaultVacuumZoneXPosition = -1855.5075 *mm;
172                                                << 194   vacuumZoneXPosition = defaultVacuumZoneXPosition;
173     // ELEMENTS                                << 195   
174     G4bool isotopes = false;                   << 196   
175     aluminumNist = G4NistManager::Instance()-> << 197   // KAPTON WINDOW: it permits the passage of the beam from vacuum to air
176     G4Element* zincNist = G4NistManager::Insta << 198   G4double defaultKaptonWindowXSize = 0.025*mm;
177     G4Element* copperNist = G4NistManager::Ins << 199   kaptonWindowXSize = defaultKaptonWindowXSize;
178                                                << 200   
179     // MATERIAL (Including compounds)          << 201   G4double defaultKaptonWindowYSize = 5.25*cm;
180     copperNistMaterial = G4NistManager::Instan << 202   kaptonWindowYSize = defaultKaptonWindowYSize;
181     airNist =  G4NistManager::Instance()->Find << 203   
182     kaptonNist = G4NistManager::Instance()->Fi << 204   G4double defaultKaptonWindowZSize = 5.25*cm;
183     galacticNist = G4NistManager::Instance()-> << 205   kaptonWindowZSize = defaultKaptonWindowZSize;
184     PMMANist = G4NistManager::Instance()->Find << 206   
185     tantalumNist = G4NistManager::Instance()-> << 207   G4double defaultKaptonWindowXPosition = 80.5075*mm;
186                                                << 208   kaptonWindowXPosition = defaultKaptonWindowXPosition;
187     G4double d; // Density                     << 209   
188     G4int nComponents;// Number of components  << 210   // FIRST SCATTERING FOIL: a thin foil performing a first scattering
189     G4double fractionmass; // Fraction in mass << 211   // of the original beam
190                                                << 212   G4double defaultFirstScatteringFoilXSize = 0.025 *mm;
191     d = 8.40*g/cm3;                            << 213   firstScatteringFoilXSize = defaultFirstScatteringFoilXSize; 
192     nComponents = 2;                           << 214   
193     brass = new G4Material("Brass", d, nCompon << 215   G4double defaultFirstScatteringFoilYSize = 105.0   *mm;
194     brass -> AddElement(zincNist, fractionmass << 216   firstScatteringFoilYSize = defaultFirstScatteringFoilYSize;
195     brass -> AddElement(copperNist, fractionma << 217   
196                                                << 218   G4double defaultFirstScatteringFoilZSize = 105   *mm;
197     //***************************** PW ******* << 219   firstScatteringFoilZSize = defaultFirstScatteringFoilZSize;
198                                                << 220   
199     // DetectorROGeometry Material             << 221   G4double defaultFirstScatteringFoilXPosition = 0.0 *mm;
200     new G4Material("dummyMat", 1., 1.*g/mole,  << 222   firstScatteringFoilXPosition = defaultFirstScatteringFoilXPosition;
201                                                << 223   
202     //***************************** PW ******* << 224   
203                                                << 225   
204     // MATERIAL ASSIGNMENT                     << 226   // STOPPER AND SCATTERING FOIL SIMULATED TO TEST THEIR EFFECT
205     // Support of the beam line                << 227   // IN THE LATERAL DOSE DISTRIBUTION
206     beamLineSupportMaterial = aluminumNist;    << 228   // STOPPER: is a small cylinder able to stop the central component
207                                                << 229   // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
208     // Vacuum pipe                             << 230   // and represent the second element of the scattering system
209     vacuumZoneMaterial = galacticNist;         << 231   G4double defaultInnerRadiusStopper = 0.*cm;
210     firstScatteringFoilMaterial = tantalumNist << 232   innerRadiusStopper = defaultInnerRadiusStopper;
211                                                << 233   
212     // Material of kapton window               << 234   G4double defaultHeightStopper = 7.0 *mm;
213     kaptonWindowMaterial = kaptonNist;         << 235   heightStopper = defaultHeightStopper;
214                                                << 236   
215     // Material of ripple filter               << 237   G4double defaultStartAngleStopper = 0.*deg;
216     rippleFilterMaterial = PMMANist;           << 238   startAngleStopper = defaultStartAngleStopper;
217     rippleFilterBoxMaterial = airNist;         << 239   
218                                                << 240   G4double defaultSpanningAngleStopper = 360.*deg;
219     // Materials of the monitor chamber        << 241   spanningAngleStopper = defaultSpanningAngleStopper;
220     layer1MonitorChamberMaterial = kaptonNist; << 242   
221     layer2MonitorChamberMaterial = copperNistM << 243   G4double defaultStopperXPosition = -1675.0 *mm;
222     layer3MonitorChamberMaterial = airNist;    << 244   stopperXPosition = defaultStopperXPosition;
223     layer4MonitorChamberMaterial = copperNistM << 245   
224                                                << 246   G4double defaultStopperYPosition = 0.*m;
225     // Material of the final nozzle            << 247   stopperYPosition = defaultStopperYPosition;
226     nozzleSupportMaterial = PMMANist;          << 248   
227     holeNozzleSupportMaterial = airNist;       << 249   G4double defaultStopperZPosition = 0.*m;
228     seconHoleNozzleSupportMaterial = airNist;  << 250   stopperZPosition = defaultStopperZPosition;
229                                                << 251   
230     // Material of the final collimator        << 252   G4double defaultOuterRadiusStopper = 2 *mm;
231     brassTubeMaterial = brassTube2Material = b << 253   outerRadiusStopper = defaultOuterRadiusStopper; 
232                                                << 254   
233     // Material of the final collimator        << 255   // SECOND SCATTERING FOIL: it is another thin foil and provides the
234     finalCollimatorMaterial = brass;           << 256   // final diffusion of the beam. It represents the third element of the scattering
235                                                << 257   // system;
236     // Material of the PMMA collimator         << 258   G4double defaultSecondScatteringFoilXSize = 0.025 *mm;  
237     PMMACollimatorMaterial = airNist;          << 259   secondScatteringFoilXSize = defaultSecondScatteringFoilXSize;
238                                                << 260   
239                                                << 261   G4double defaultSecondScatteringFoilYSize = 105.0   *mm;
240     G4Element* hydrogenNist = G4NistManager::I << 262   secondScatteringFoilYSize = defaultSecondScatteringFoilYSize;
241     G4Element* oxygenNist = G4NistManager::Ins << 263   
242     G4Element* carbonNist = G4NistManager::Ins << 264   G4double defaultSecondScatteringFoilZSize = 105.0   *mm;
243                                                << 265   secondScatteringFoilZSize = defaultSecondScatteringFoilZSize;
244     G4Material* plastic = new G4Material("Plas << 266   
245     plastic -> AddElement(carbonNist, 21);     << 267   G4double defaultSecondScatteringFoilXPosition = defaultStopperXPosition + defaultHeightStopper + defaultSecondScatteringFoilXSize/2;
246     plastic -> AddElement(oxygenNist, 4);      << 268   secondScatteringFoilXPosition = defaultSecondScatteringFoilXPosition;
247     plastic -> AddElement(hydrogenNist, 24);   << 269   
248     PMMANist = plastic;                        << 270   G4double defaultSecondScatteringFoilYPosition =  0 *mm;
249                                                << 271   secondScatteringFoilYPosition = defaultSecondScatteringFoilYPosition;
250                                                << 272   
251                                                << 273   G4double defaultSecondScatteringFoilZPosition =  0 *mm;
                                                   >> 274   secondScatteringFoilZPosition = defaultSecondScatteringFoilZPosition;
                                                   >> 275   
                                                   >> 276   
                                                   >> 277   // FINAL COLLIMATOR: is the collimator giving the final transversal shape
                                                   >> 278   // of the beam 
                                                   >> 279   G4double defaultinnerRadiusFinalCollimator = 12.5 *mm;
                                                   >> 280   innerRadiusFinalCollimator = defaultinnerRadiusFinalCollimator;
                                                   >> 281   
                                                   >> 282   // DEFAULT DEFINITION OF THE MATERIALS
                                                   >> 283   // All elements and compound definition follows the NIST database
                                                   >> 284   
                                                   >> 285   // ELEMENTS
                                                   >> 286   G4bool isotopes = false;
                                                   >> 287   G4Material* aluminumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al", isotopes);
                                                   >> 288   G4Material* copperNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu", isotopes);
                                                   >> 289   G4Element* zincNist = G4NistManager::Instance()->FindOrBuildElement("Zn");
                                                   >> 290   G4Element* copperNist = G4NistManager::Instance()->FindOrBuildElement("Cu");
                                                   >> 291   G4Material* tantalumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ta", isotopes); 
                                                   >> 292   
                                                   >> 293   // COMPOUND
                                                   >> 294   G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
                                                   >> 295   G4Material* kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
                                                   >> 296   G4Material* galacticNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic", isotopes);
                                                   >> 297   G4Material* PMMANist = G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS", isotopes);
                                                   >> 298   
                                                   >> 299   G4double d; // Density
                                                   >> 300   G4int nComponents;// Number of components 
                                                   >> 301   G4double fractionmass; // Fraction in mass of an element in a material
                                                   >> 302   
                                                   >> 303   d = 8.40*g/cm3;
                                                   >> 304   nComponents = 2;
                                                   >> 305   G4Material* brass = new G4Material("Brass", d, nComponents);  
                                                   >> 306   brass -> AddElement(zincNist, fractionmass = 30 *perCent);
                                                   >> 307   brass -> AddElement(copperNist, fractionmass = 70 *perCent);
                                                   >> 308   
                                                   >> 309 //***************************** PW ***************************************
                                                   >> 310 
                                                   >> 311 // DetectorROGeometry Material
                                                   >> 312   new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
                                                   >> 313 
                                                   >> 314 //***************************** PW ***************************************
                                                   >> 315   
                                                   >> 316   
                                                   >> 317   // MATERIAL ASSIGNMENT
                                                   >> 318   // Support of the beam line
                                                   >> 319   beamLineSupportMaterial = aluminumNist;
                                                   >> 320   
                                                   >> 321   // Vacuum pipe
                                                   >> 322   vacuumZoneMaterial = galacticNist;
                                                   >> 323   
                                                   >> 324   // Material of the firt scattering foil
                                                   >> 325   firstScatteringFoilMaterial = tantalumNist;
                                                   >> 326   
                                                   >> 327   // Material of kapton window 
                                                   >> 328   kaptonWindowMaterial = kaptonNist;
                                                   >> 329   
                                                   >> 330   // Material of the stopper
                                                   >> 331   stopperMaterial = brass;
                                                   >> 332   
                                                   >> 333   // Material of the second scattering foil 
                                                   >> 334   secondScatteringFoilMaterial = tantalumNist; 
                                                   >> 335   
                                                   >> 336   // Materials of the monitor chamber
                                                   >> 337   layer1MonitorChamberMaterial = kaptonNist;
                                                   >> 338   layer2MonitorChamberMaterial = copperNistAsMaterial;
                                                   >> 339   layer3MonitorChamberMaterial = airNist;
                                                   >> 340   layer4MonitorChamberMaterial = copperNistAsMaterial;
                                                   >> 341   
                                                   >> 342   
                                                   >> 343   // material of the final nozzle
                                                   >> 344   nozzleSupportMaterial = PMMANist;
                                                   >> 345   holeNozzleSupportMaterial = brass;
                                                   >> 346   seconHoleNozzleSupportMaterial = airNist;
                                                   >> 347   
                                                   >> 348   // Material of the final collimator
                                                   >> 349   finalCollimatorMaterial = brass;
252 }                                                 350 }
253                                                   351 
254 //////////////////////////////////////////////    352 /////////////////////////////////////////////////////////////////////////////
255 void PassiveCarbonBeamLine::ConstructPassiveCa    353 void PassiveCarbonBeamLine::ConstructPassiveCarbonBeamLine()
256 {                                              << 354 { 
257     // -----------------------------           << 355   // -----------------------------
258     // Treatment room - World volume           << 356   // Treatment room - World volume
259     //------------------------------           << 357   //------------------------------
260     // Treatment room sizes                    << 358   // Treatment room sizes
261                                                << 359   const G4double worldX = 400.0 *cm;
262     const G4double worldX = 400.0 *cm;         << 360   const G4double worldY = 400.0 *cm;
263     const G4double worldY = 400.0 *cm;         << 361   const G4double worldZ = 400.0 *cm;
264     const G4double worldZ = 400.0 *cm;         << 362   G4bool isotopes = false;
265     G4bool isotopes = false;                   << 363   
266                                                << 364   G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
267     airNist =  G4NistManager::Instance()->Find << 365   G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
268     treatmentRoom = new G4Box("TreatmentRoom", << 366   G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, 
269     logicTreatmentRoom = new G4LogicalVolume(t << 367                                 airNist, 
270                                              a << 368                                 "logicTreatmentRoom", 
271                                              " << 369                                 0,0,0);
272                                              0 << 370   physicalTreatmentRoom = new G4PVPlacement(0,
273     physicalTreatmentRoom = new G4PVPlacement( << 371                         G4ThreeVector(),
274                                                << 372                         "physicalTreatmentRoom", 
275                                                << 373                         logicTreatmentRoom, 
276                                                << 374                         0,false,0);
277                                                << 375   
278                                                << 376   
279                                                << 377   // The treatment room is invisible in the Visualisation
280     // The treatment room is invisible in the  << 378   logicTreatmentRoom -> SetVisAttributes (G4VisAttributes::Invisible);
281     logicTreatmentRoom -> SetVisAttributes (G4 << 379   
282                                                << 380   // Components of the Passive Carbon Beam Line
283     // Components of the Passive Carbon Beam L << 381   HadrontherapyBeamLineSupport();
284     HadrontherapyBeamLineSupport();            << 382   VacuumToAirInterface();
285     VacuumToAirInterface();                    << 383   ScatteringSystem();
286     HadrontherapyBeamMonitoring();             << 384   HadrontherapyBeamMonitoring();
287     HadrontherapyBeamNozzle();                 << 385   HadrontherapyBeamNozzle();
288     HadrontherapyBeamFinalCollimator();        << 386   HadrontherapyBeamFinalCollimator();
289     HadrontherapyPMMACollimator();             << 
290    // HadrontherapyRippleFilter();             << 
291                                                << 
292                                                << 
293    // StopperCostruction();                    << 
294                                                << 
295                                                << 
296    HadrontherapyRidgeFilter();                 << 
297 }                                                 387 }
298                                                   388 
299 //////////////////////////////////////////////    389 /////////////////////////////////////////////////////////////////////////////
300 void PassiveCarbonBeamLine::HadrontherapyBeamL    390 void PassiveCarbonBeamLine::HadrontherapyBeamLineSupport()
301 {                                                 391 {
302     // ------------------//                    << 392   // ------------------//
303     // BEAM LINE SUPPORT //                    << 393   // BEAM LINE SUPPORT //
304     //-------------------//                    << 394   //-------------------//
305                                                << 395   const G4double beamLineSupportXSize = 1.5*m;
306     beamLineSupportXSize = 1.5*m;              << 396   const G4double beamLineSupportYSize = 20.*mm;
307     beamLineSupportYSize = 20.*mm;             << 397   const G4double beamLineSupportZSize = 600.*mm;
308     beamLineSupportZSize = 600.*mm;            << 398   
309                                                << 399   const G4double beamLineSupportXPosition = -1745.09 *mm;
310     beamLineSupportXPosition = -1745.09 *mm;   << 400   const G4double beamLineSupportYPosition = -230. *mm; 
311     beamLineSupportYPosition = -230. *mm;      << 401   const G4double beamLineSupportZPosition = 0.*mm;
312     beamLineSupportZPosition = 0.*mm;          << 402   
313                                                << 403   G4Box* beamLineSupport = new G4Box("BeamLineSupport", 
314     beamLineSupport = new G4Box("BeamLineSuppo << 404                      beamLineSupportXSize, 
315                                 beamLineSuppor << 405                      beamLineSupportYSize, 
316                                 beamLineSuppor << 406                      beamLineSupportZSize);
317                                 beamLineSuppor << 407   
318                                                << 408   G4LogicalVolume* logicBeamLineSupport = new G4LogicalVolume(beamLineSupport, 
319     logicBeamLineSupport = new G4LogicalVolume << 409                                 beamLineSupportMaterial, 
320                                                << 410                                 "BeamLineSupport");
321                                                << 411   physiBeamLineSupport = new G4PVPlacement(0, G4ThreeVector(beamLineSupportXPosition, 
322     physiBeamLineSupport = new G4PVPlacement(0 << 412                                 beamLineSupportYPosition,
323                                                << 413                                 beamLineSupportZPosition),
324                                                << 414                        "BeamLineSupport", 
325                                              " << 415                        logicBeamLineSupport, 
326                                              l << 416                        physicalTreatmentRoom, false, 0);
327                                              p << 417   
328                                                << 418   // Visualisation attributes of the beam line support
329     // Visualisation attributes of the beam li << 419   
330     logicBeamLineSupport -> SetVisAttributes(g << 420   logicBeamLineSupport -> SetVisAttributes(gray);
331                                                << 421   
332     //---------------------------------//      << 422   //---------------------------------//
333     //  Beam line cover 1 (left panel) //      << 423   //  Beam line cover 1 (left panel) //
334     //---------------------------------//      << 424   //---------------------------------//
335     beamLineCoverXSize = 1.5*m;                << 425   const G4double beamLineCoverXSize = 1.5*m;
336     beamLineCoverYSize = 750.*mm;              << 426   const G4double beamLineCoverYSize = 750.*mm;
337     beamLineCoverZSize = 10.*mm;               << 427   const G4double beamLineCoverZSize = 10.*mm; 
338                                                << 428   
339     beamLineCoverXPosition = -1745.09 *mm;     << 429   const G4double beamLineCoverXPosition = -1745.09 *mm;
340     beamLineCoverYPosition = -1000.*mm;        << 430   const G4double beamLineCoverYPosition = -980.*mm; 
341     beamLineCoverZPosition = 610.*mm;          << 431   const G4double beamLineCoverZPosition = 600.*mm;
342                                                << 432   
343     beamLineCover = new G4Box("BeamLineCover", << 433   G4Box* beamLineCover = new G4Box("BeamLineCover",
344                               beamLineCoverXSi << 434                    beamLineCoverXSize, 
345                               beamLineCoverYSi << 435                    beamLineCoverYSize, 
346                               beamLineCoverZSi << 436                    beamLineCoverZSize);
347                                                << 437   
348     logicBeamLineCover = new G4LogicalVolume(b << 438   G4LogicalVolume* logicBeamLineCover = new G4LogicalVolume(beamLineCover,
349                                              b << 439                                 beamLineSupportMaterial, 
350                                              " << 440                                 "BeamLineCover");
351                                                << 441   
352     physiBeamLineCover = new G4PVPlacement(0,  << 442   physiBeamLineCover = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
353                                                << 443                               beamLineCoverYPosition,
354                                                << 444                               beamLineCoverZPosition),
355                                            "Be << 445                        "BeamLineCover", 
356                                            log << 446                        logicBeamLineCover, 
357                                            phy << 447                        physicalTreatmentRoom,
358                                            fal << 448                        false, 
359                                            0); << 449                        0);
360                                                << 450   
361     // ---------------------------------//     << 451   // ---------------------------------//
362     //  Beam line cover 2 (rigth panel) //     << 452   //  Beam line cover 2 (rigth panel) //
363     // ---------------------------------//     << 453   // ---------------------------------//
364     // It has the same characteristic of beam  << 454   // It has the same characteristic of beam line cover 1 but set in a different position
365     physiBeamLineCover2 = new G4PVPlacement(0, << 455   physiBeamLineCover2 = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
366                                                << 456                                beamLineCoverYPosition,
367                                                << 457                                - beamLineCoverZPosition),
368                                             "B << 458                       "BeamLineCover2", 
369                                             lo << 459                       logicBeamLineCover, 
370                                             ph << 460                       physicalTreatmentRoom, 
371                                             fa << 461                       false, 
372                                             0) << 462                       0);
373                                                << 463   
374                                                << 464   
375     logicBeamLineCover -> SetVisAttributes(blu << 465   logicBeamLineCover -> SetVisAttributes(blue);
376 }                                                 466 }
377                                                   467 
378 //////////////////////////////////////////////    468 /////////////////////////////////////////////////////////////////////////////
379 void PassiveCarbonBeamLine::VacuumToAirInterfa    469 void PassiveCarbonBeamLine::VacuumToAirInterface()
380 {                                                 470 {
381     // ------------//                          << 471   // ------------//
382     // VACUUM PIPE //                          << 472   // VACUUM PIPE //
383     //-------------//                          << 473   //-------------//
384     //                                         << 474   //
385     // First track of the beam line is inside  << 475   // First track of the beam line is inside vacuum;
386                                                << 476   // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
387     vacuumZoneXSize = 100 *mm;                 << 477   G4Box* vacuumZone = new G4Box("VacuumZone", 
388     vacuumZoneYSize = 52.5 *mm;                << 478                   vacuumZoneXSize, 
389     vacuumZoneZSize = 52.5 *mm;                << 479                   vacuumZoneYSize, 
390     vacuumPipeXPosition = -1708.0 *mm;         << 480                   vacuumZoneZSize);
391                                                << 481   
392                                                << 482   G4LogicalVolume* logicVacuumZone = new G4LogicalVolume(vacuumZone, 
393     vacuumZone = new G4Box("VacuumZone",       << 483                                vacuumZoneMaterial, 
394                            vacuumZoneXSize/2,  << 484                                "VacuumZone");
395                            vacuumZoneYSize/2,  << 485   
396                            vacuumZoneZSize/2); << 486   G4VPhysicalVolume* physiVacuumZone = new G4PVPlacement(0, 
397                                                << 487                                G4ThreeVector(vacuumZoneXPosition, 0., 0.),
398     logicVacuumZone = new G4LogicalVolume(vacu << 488                                "VacuumZone",
399                                                << 489                                logicVacuumZone, 
400     physiVacuumZone = new G4PVPlacement(0, G4T << 490                                physicalTreatmentRoom, 
401                                         "Vacuu << 491                                false, 
402                                         logicV << 492                                0);
403                                         physic << 493   
404                                         false, << 494   
405                                         0);    << 495   
406                                                << 496   
407     // --------------------------//            << 497   
408     // THE FIRST SCATTERING FOIL //            << 498   // --------------------------//
409     // --------------------------//            << 499   // THE FIRST SCATTERING FOIL //
410     // A thin foil performing a first scatteri << 500   // --------------------------//
411     // of the original beam                    << 501   // A thin foil performing a first scattering
412                                                << 502   // of the original beam
413     firstScatteringFoilXSize = 0.015 *mm;      << 503   
414     firstScatteringFoilYSize = 52.5 *mm;       << 504   firstScatteringFoil = new G4Box("FirstScatteringFoil", 
415     firstScatteringFoilZSize = 52.5 *mm;       << 505                   firstScatteringFoilXSize/2, 
416     firstScatteringFoilXPosition = 0.0 *mm;    << 506                   firstScatteringFoilYSize/2, 
417                                                << 507                   firstScatteringFoilZSize/2);
418     firstScatteringFoil = new G4Box("FirstScat << 508   
419                                     firstScatt << 509   G4LogicalVolume* logicFirstScatteringFoil = new G4LogicalVolume(firstScatteringFoil,
420                                     firstScatt << 510                                   firstScatteringFoilMaterial,
421                                     firstScatt << 511                                   "FirstScatteringFoil");
422                                                << 512   
423     logicFirstScatteringFoil = new G4LogicalVo << 513   physiFirstScatteringFoil = new G4PVPlacement(0, 
424                                                << 514                          G4ThreeVector(firstScatteringFoilXPosition, 0.,0.),
425                                                << 515                          "FirstScatteringFoil", 
426                                                << 516                          logicFirstScatteringFoil, 
427     physiFirstScatteringFoil = new G4PVPlaceme << 517                          physiVacuumZone, 
428                                                << 518                          false, 0); 
429                                                << 519   
430                                                << 520   logicFirstScatteringFoil -> SetVisAttributes(skyBlue);
431     logicFirstScatteringFoil -> SetVisAttribut << 521   
432                                                << 522   
433     // -------------------//                   << 523   
434     // THE KAPTON WINDOWS //                   << 524   // -------------------//
435     //--------------------//                   << 525   // THE KAPTON WINDOWS //
436     //It permits the passage of the beam from  << 526   //--------------------//
437                                                << 527   //It permits the passage of the beam from vacuum to air
438     // KAPTON WINDOW: it permits the passage o << 528   
439     kaptonWindowXSize = 0.050 *mm;             << 529   G4Box* solidKaptonWindow = new G4Box("KaptonWindow", 
440     kaptonWindowYSize = 52.5 *mm;              << 530                      kaptonWindowXSize,
441     kaptonWindowZSize = 52.5 *mm;              << 531                      kaptonWindowYSize,
442     kaptonWindowXPosition = vacuumZoneXSize/2  << 532                      kaptonWindowZSize);
443                                                << 533   
444     solidKaptonWindow = new G4Box("KaptonWindo << 534   G4LogicalVolume* logicKaptonWindow = new G4LogicalVolume(solidKaptonWindow, 
445                                   kaptonWindow << 535                                kaptonWindowMaterial,
446                                   kaptonWindow << 536                                "KaptonWindow");
447                                   kaptonWindow << 537   
448                                                << 538   physiKaptonWindow = new G4PVPlacement(0, G4ThreeVector(kaptonWindowXPosition, 0., 0.), 
449     logicKaptonWindow = new G4LogicalVolume(so << 539                       "KaptonWindow", logicKaptonWindow,
450                                             ka << 540                       physiVacuumZone, false, 0); 
451                                             "K << 541   
452                                                << 542   logicKaptonWindow -> SetVisAttributes(darkOrange3);
453     physiKaptonWindow = new G4PVPlacement(0, G << 543 }
454                                           "Kap << 544 
455                                           phys << 545 /////////////////////////////////////////////////////////////////////////////  
456                                                << 546 void PassiveCarbonBeamLine::ScatteringSystem()
457     logicKaptonWindow -> SetVisAttributes(dark << 547 {
458 }                                              << 548   // ------------//
459 ////////////////////////////////////////////// << 549   // THE STOPPER //
460 void PassiveCarbonBeamLine::HadrontherapyRippl << 550   //-------------//
461 {                                              << 551   // Is a small cylinder able to stop the central component
462                                                << 552   // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
463     G4double defaultRippleFilterXPosition = -1 << 553   // and represent the second element of the scattering system
464     G4double ripple_position=(defaultRippleFil << 554   
465     G4double RF_x = 200.0 * mm;                << 555   G4double phi = 90. *deg;
466     G4double RF_y = 200.0 * mm;                << 556     // Matrix definition for a 90 deg rotation with respect to Y axis
467     G4double RF_z = 1.4 * mm;                  << 557   G4RotationMatrix rm;
468     G4double RFbase_z = 0.2 * mm;              << 558   rm.rotateY(phi);
469     G4double RFtrd_z = RF_z - RFbase_z;        << 559   
470     G4double RFtrd_top = 1e-4 * mm;            << 560   solidStopper = new G4Tubs("Stopper", 
471     G4double RFtrd_bottom = 1.5 * mm;          << 561                 innerRadiusStopper, 
472     G4double distanceBetweenTrd = 0.1*mm;      << 562                 outerRadiusStopper,
473                                                << 563                 heightStopper/2, 
474                                                << 564                 startAngleStopper,
475                                                << 565                 spanningAngleStopper);
476                                                << 566   
477     G4double theta = -90. *deg;                << 567   logicStopper = new G4LogicalVolume(solidStopper, 
478     // Matrix definition for a "theta" deg rot << 568                      stopperMaterial, 
479     G4RotationMatrix rot;                      << 569                      "Stopper", 
480     rot.rotateY(theta);                        << 570                      0, 0, 0);
481                                                << 571   
482                                                << 572   physiStopper = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(stopperXPosition, 
483     SolidRippleFilter= new G4Box("RippleFilter << 573                                    stopperYPosition, 
484                                  RF_x/2 + 1*mm << 574                                    stopperZPosition)),
485                                  RF_y/2 + 1*mm << 575                    "Stopper", 
486                                  RF_z/2 + 1*mm << 576                    logicStopper, 
487                                                << 577                    physicalTreatmentRoom, 
488     LogicRippleFilter = new G4LogicalVolume(So << 578                    false, 
489                                             ri << 579                    0);
490                                             "L << 580   
491                                             0, << 581   logicStopper -> SetVisAttributes(red);
492                                                << 582   
493     PhysiRippleFilter = new G4PVPlacement(G4Tr << 583   // ---------------------------//
494                                           "Phy << 584   // THE SECOND SCATTERING FOIL //
495                                           Logi << 585   // ---------------------------//
496                                           phys << 586   // It is another thin foil and provides the
497                                           fals << 587   // final diffusion of the beam. It represents the third element of the scattering
498                                           1,   << 588   // system;
499                                           true << 589   
500                                                << 590   secondScatteringFoil = new G4Box("SecondScatteringFoil", 
501     PhysiRippleFilter = new G4PVPlacement(G4Tr << 591                    secondScatteringFoilXSize/2, 
502                                           "Phy << 592                    secondScatteringFoilYSize/2,
503                                           Logi << 593                    secondScatteringFoilZSize/2);
504                                           phys << 594   
505                                           fals << 595   G4LogicalVolume* logicSecondScatteringFoil = new G4LogicalVolume(secondScatteringFoil, 
506                                           2,   << 596                                    secondScatteringFoilMaterial,
507                                           true << 597                                    "SecondScatteringFoil");
508                                                << 598   
509     LogicRippleFilter -> SetVisAttributes(G4Vi << 599   physiSecondScatteringFoil = new G4PVPlacement(0, G4ThreeVector(secondScatteringFoilXPosition,
510                                                << 600                                    secondScatteringFoilYPosition,
511     SolidRippleFilterBase = new G4Box("RippleF << 601                                    secondScatteringFoilZPosition),
512                                       RF_x/2,  << 602                           "SeconScatteringFoil", 
513                                       RF_y/2,  << 603                           logicSecondScatteringFoil, 
514                                       RFbase_z << 604                           physicalTreatmentRoom, 
515                                                << 605                           false, 
516     LogicRippleFilterBase = new G4LogicalVolum << 606                           0);
517                                                << 607   
518                                                << 608   logicSecondScatteringFoil -> SetVisAttributes(skyBlue);
519                                                << 609   
520                                                << 
521     LogicRippleFilterBase -> SetVisAttributes( << 
522                                                << 
523     PhysiRippleFilterBase = new G4PVPlacement( << 
524                                                << 
525                                                << 
526                                                << 
527                                                << 
528                                                << 
529                                                << 
530                                                << 
531                                                << 
532     SolidRippleFilterTrd = new G4Trd("SolidRip << 
533                                      RF_x/2,   << 
534                                      RF_x/2,   << 
535                                      RFtrd_bot << 
536                                      RFtrd_top << 
537                                      RFtrd_z/2 << 
538                                                << 
539     LogicRippleFilterTrd = new G4LogicalVolume << 
540                                                << 
541                                                << 
542                                                << 
543                                                << 
544     LogicRippleFilterTrd -> SetVisAttributes(g << 
545                                                << 
546     G4int numberOfTrd = static_cast<int>(std:: << 
547                                                << 
548     G4int N = static_cast<int>( std::floor(num << 
549                                                << 
550     G4int copyNumber = 0;                      << 
551                                                << 
552     for( int i = -N; i <= N; i++ )             << 
553     {                                          << 
554         PhysiRippleFilterTrd = new G4PVPlaceme << 
555                                                << 
556                                                << 
557                                                << 
558                                                << 
559                                                << 
560                                                << 
561                                                << 
562                                                << 
563                                                << 
564                                                << 
565         copyNumber++;                          << 
566     }                                          << 
567                                                << 
568 }                                              << 
569 ////////////////////////////////////////////// << 
570                                                << 
571 void PassiveCarbonBeamLine::StopperCostruction << 
572                                                << 
573     supportFoil= new G4Box("supportFoil",25/2* << 
574     LogicSupportFoil = new G4LogicalVolume(sup << 
575     PhysiSupportFoil = new G4PVPlacement(0,G4T << 
576     LogicSupportFoil -> SetVisAttributes(skyBl << 
577                                                << 
578                                                << 
579                                                << 
580     stopper = new G4Tubs("Stopper",0*mm,3*mm,3 << 
581     LogicStopper= new G4LogicalVolume(stopper, << 
582                                                << 
583     G4double ti = -270. *deg;                  << 
584     G4RotationMatrix rt;                       << 
585     rt.rotateY(ti);                            << 
586                                                << 
587     PhysicStopper= new G4PVPlacement(G4Transfo << 
588                                                << 
589     LogicStopper -> SetVisAttributes(red);     << 
590                                                << 
591                                                << 
592 }                                                 610 }
593                                                   611 
594 void PassiveCarbonBeamLine::HadrontherapyRidge << 
595                                                << 
596                                                << 
597     G4double defaultRidgeXPosition= -1270.0*mm << 
598     const G4double XBase = 0.5 *mm;            << 
599     const G4double YBase =6.03*cm;             << 
600     const G4double ZBase =6.03*cm;             << 
601                                                << 
602                                                << 
603                                                << 
604     SolidRidgeBase = new G4Box("BaseRidgeFilte << 
605                                XBase,          << 
606                                YBase/2,        << 
607                                ZBase/2);       << 
608                                                << 
609     LogicRidgeBase = new G4LogicalVolume(Solid << 
610                                          PMMAN << 
611                                          "Base << 
612                                                << 
613     PhysiRidgeFilterBase = new G4PVPlacement(0 << 
614                                              G << 
615                                                << 
616                                                << 
617                                                << 
618                                              " << 
619                                              L << 
620                                              p << 
621                                              f << 
622                                              0 << 
623                                                << 
624     LogicRidgeBase->SetVisAttributes(red);     << 
625                                                << 
626                                                << 
627     SolidRidgeMother = new G4Box("MotherRidgeS << 
628     LogicRidgeMother = new G4LogicalVolume(Sol << 
629                                                << 
630     G4Trd* trapp1=new G4Trd("Trapp1SOL",1.7*mm << 
631     G4LogicalVolume* LogicTrapp1=new G4Logical << 
632  PhysiTrapp1=new G4PVPlacement(0,G4ThreeVector << 
633                                                << 
634     G4Trd* trapp2=new G4Trd("Trapp2SOL",1.68*m << 
635     G4LogicalVolume* LogicTrapp2=new G4Logical << 
636   PhysiTrapp2=new G4PVPlacement(0,G4ThreeVecto << 
637                                                << 
638     G4Trd* trapp3=new G4Trd("Trapp3SOL",1.64*m << 
639     G4LogicalVolume* LogicTrapp3=new G4Logical << 
640  PhysiTrapp3=new G4PVPlacement(0,G4ThreeVector << 
641                                                << 
642     G4Trd* trapp4=new G4Trd("Trapp4SOL",1.58*m << 
643     G4LogicalVolume* LogicTrapp4=new G4Logical << 
644     PhysiTrapp4=new G4PVPlacement(0,G4ThreeVec << 
645                                                << 
646     G4Trd* trapp5=new G4Trd("Trapp5SOL",1.50*m << 
647     G4LogicalVolume* LogicTrapp5=new G4Logical << 
648    PhysiTrapp5=new G4PVPlacement(0,G4ThreeVect << 
649                                                << 
650     G4Trd* trapp6=new G4Trd("Trapp6SOL",1.40*m << 
651     G4LogicalVolume* LogicTrapp6=new G4Logical << 
652    PhysiTrapp6=new G4PVPlacement(0,G4ThreeVect << 
653                                                << 
654     G4Trd* trapp7=new G4Trd("Trapp7SOL",1.26*m << 
655     G4LogicalVolume* LogicTrapp7=new G4Logical << 
656 PhysiTrapp7=new G4PVPlacement(0,G4ThreeVector( << 
657                                                << 
658     G4Trd* trapp8=new G4Trd("Trapp8SOL",0.94*m << 
659     G4LogicalVolume* LogicTrapp8=new G4Logical << 
660     PhysiTrapp8=new G4PVPlacement(0,G4ThreeVec << 
661                                                << 
662     G4Trd* trapp9=new G4Trd("Trapp9SOL",0.78*m << 
663     G4LogicalVolume* LogicTrapp9=new G4Logical << 
664   PhysiTrapp9=new G4PVPlacement(0,G4ThreeVecto << 
665                                                << 
666     G4Trd* trapp10=new G4Trd("Trapp10SOL",0.66 << 
667     G4LogicalVolume* LogicTrapp10=new G4Logica << 
668  PhysiTrapp10=new G4PVPlacement(0,G4ThreeVecto << 
669                                                << 
670     G4Trd* trapp11=new G4Trd("Trapp11SOL",0.56 << 
671     G4LogicalVolume* LogicTrapp11=new G4Logica << 
672 PhysiTrapp11=new G4PVPlacement(0,G4ThreeVector << 
673                                                << 
674     G4Trd* trapp12=new G4Trd("Trapp12SOL",0.46 << 
675     G4LogicalVolume* LogicTrapp12=new G4Logica << 
676    PhysiTrapp12=new G4PVPlacement(0,G4ThreeVec << 
677                                                << 
678     G4Trd* trapp13=new G4Trd("Trapp13SOL",0.38 << 
679     G4LogicalVolume* LogicTrapp13=new G4Logica << 
680    PhysiTrapp13=new G4PVPlacement(0,G4ThreeVec << 
681                                                << 
682     G4Trd* trapp14=new G4Trd("Trapp14SOL",0.30 << 
683     G4LogicalVolume* LogicTrapp14=new G4Logica << 
684 PhysiTrapp14=new G4PVPlacement(0,G4ThreeVector << 
685                                                << 
686     G4Trd* trapp15=new G4Trd("Trapp14SOL",0.24 << 
687     G4LogicalVolume* LogicTrapp15=new G4Logica << 
688     PhysiTrapp15=new G4PVPlacement(0,G4ThreeVe << 
689                                                << 
690     G4Trd* trapp16=new G4Trd("Trapp16SOL",0.18 << 
691     G4LogicalVolume* LogicTrapp16=new G4Logica << 
692   PhysiTrapp16=new G4PVPlacement(0,G4ThreeVect << 
693                                                << 
694     LogicTrapp1->SetVisAttributes(green);      << 
695     LogicTrapp2->SetVisAttributes(green);      << 
696     LogicTrapp3->SetVisAttributes(green);      << 
697     LogicTrapp4->SetVisAttributes(green);      << 
698     LogicTrapp5->SetVisAttributes(green);      << 
699     LogicTrapp6->SetVisAttributes(green);      << 
700     LogicTrapp7->SetVisAttributes(green);      << 
701     LogicTrapp8->SetVisAttributes(green);      << 
702     LogicTrapp9->SetVisAttributes(green);      << 
703     LogicTrapp10->SetVisAttributes(green);     << 
704     LogicTrapp11->SetVisAttributes(green);     << 
705     LogicTrapp12->SetVisAttributes(green);     << 
706     LogicTrapp13->SetVisAttributes(green);     << 
707     LogicTrapp14->SetVisAttributes(green);     << 
708     LogicTrapp15->SetVisAttributes(green);     << 
709     LogicTrapp16->SetVisAttributes(green);     << 
710     G4VisAttributes* visAttr = new G4VisAttrib << 
711     visAttr->SetVisibility(false);             << 
712     LogicRidgeMother->SetVisAttributes(visAttr << 
713                                                << 
714                                                << 
715                                                << 
716                                                << 
717                                                << 
718                                                << 
719     G4int numberOfLayers = 30;                 << 
720     G4double minZ = 30.15*mm-0.3*mm-1.70/2*mm; << 
721     G4double minY = 30.15*mm-0.3*mm-1.70/2*mm; << 
722     G4double sum_space = 0.3*mm+1.70*mm;       << 
723                                                << 
724                                                << 
725     std::vector<G4ThreeVector> singleTrapPosit << 
726                                                << 
727     for (int i = 0; i < numberOfLayers; i++)   << 
728     {                                          << 
729         for (int j = 0; j < numberOfLayers; j+ << 
730         {                                      << 
731             singleTrapPositions.push_back({def << 
732                 minY - i*sum_space,            << 
733                 minZ - j*sum_space,            << 
734                                                << 
735             });                                << 
736         }                                      << 
737     }                                          << 
738                                                << 
739     G4double ti = -  90. *deg;                 << 
740     G4RotationMatrix rt;                       << 
741     rt.rotateY(ti);                            << 
742                                                << 
743                                                << 
744     G4int peaks = numberOfLayers*numberOfLayer << 
745     for (int i = 0; i < peaks; i++)            << 
746     {                                          << 
747                                                << 
748         std::ostringstream tName;tName << "sin << 
749         new G4PVPlacement(G4Transform3D(rt,    << 
750                                         single << 
751                           LogicRidgeMother,    << 
752                           "tName.str()",       << 
753                           logicTreatmentRoom,  << 
754                           0,                   << 
755                           i);                  << 
756                                                << 
757     }                                          << 
758                                                << 
759 }                                              << 
760                                                << 
761                                                << 
762                                                << 
763                                                << 
764                                                << 
765                                                << 
766 ////////////////////////////////////////////// << 
767 void PassiveCarbonBeamLine::HadrontherapyPMMAC << 
768 {                                              << 
769                                                << 
770     // ----------------------//                << 
771     //   PMMA COLLIMATOR     //                << 
772     // ----------------------//                << 
773     PMMACollimatorSupportXSize = 25.0 *mm;     << 
774     PMMACollimatorSupportYSize = 200. *mm;     << 
775     PMMACollimatorSupportZSize = 200. *mm;     << 
776                                                << 
777                                                << 
778     PMMACollimatorXPosition = -1257.0 *mm;     << 
779                                                << 
780     G4double phi = 90. *deg;                   << 
781     G4RotationMatrix rm;                       << 
782     rm.rotateY(phi);                           << 
783                                                << 
784     solidPMMACollimatorSupport = new G4Box("PM << 
785                                            PMM << 
786                                            PMM << 
787                                            PMM << 
788                                                << 
789     logicPMMACollimatorSupport = new G4Logical << 
790                                                << 
791                                                << 
792                                                << 
793     physiPMMACollimatorSupport = new G4PVPlace << 
794                                                << 
795                                                << 
796                                                << 
797                                                << 
798                                                << 
799                                                << 
800                                                << 
801     yellow = new G4VisAttributes(G4Colour(1.,  << 
802     yellow-> SetVisibility(true);              << 
803     yellow-> SetForceWireframe(true);          << 
804                                                << 
805     logicPMMACollimatorSupport -> SetVisAttrib << 
806                                                << 
807     // ----------------------//                << 
808     //     PMMA COLLIMATOR   //                << 
809     //-----------------------//                << 
810     innerRadiusPMMACollimator= 4.5 *cm;        << 
811     outerRadiusPMMACollimator = 4.6 *cm;       << 
812     hightPMMACollimator = PMMACollimatorSuppor << 
813     startAnglePMMACollimator = 0.*deg;         << 
814     spanningAnglePMMACollimator = 360.*deg;    << 
815                                                << 
816                                                << 
817     solidPMMACollimator = new G4Tubs("PMMAColl << 
818                                      innerRadi << 
819                                      outerRadi << 
820                                      hightPMMA << 
821                                      startAngl << 
822                                      spanningA << 
823                                                << 
824     logicPMMACollimator = new G4LogicalVolume( << 
825                                                << 
826                                                << 
827                                                << 
828                                                << 
829                                                << 
830                                                << 
831     physiPMMACollimator = new G4PVPlacement(G4 << 
832                                                << 
833                                             "P << 
834                                             lo << 
835                                             ph << 
836                                             fa << 
837                                             0) << 
838                                                << 
839     logicPMMACollimator -> SetVisAttributes(ye << 
840                                                << 
841                                                << 
842                                                << 
843                                                << 
844 }                                              << 
845 //////////////////////////////////////////////    612 /////////////////////////////////////////////////////////////////////////////
846 void PassiveCarbonBeamLine::HadrontherapyBeamM    613 void PassiveCarbonBeamLine::HadrontherapyBeamMonitoring()
847 {                                                 614 {
848     // ----------------------------            << 615   // ----------------------------
849     //       MONITOR CHAMBER                   << 616   //   THE FIRST MONITOR CHAMBER
850     // ----------------------------            << 617   // ----------------------------  
851     // A monitor chamber is a free-air  ionisa << 618   // A monitor chamber is a free-air  ionisation chamber
852     // able to measure do carbon fluence durin << 619   // able to measure do carbon fluence during the treatment.
853     // Here its responce is not simulated in t << 620   // Here its responce is not simulated in terms of produced 
854     // charge but only the energy losses are t << 621   // charge but only the energy losses are taked into account.
855     // Each chamber consist of 9 mm of air in  << 622   // Each chamber consist of 9 mm of air in a box
856     // that has two layers one of kapton and o << 623   // that has two layers one of kapton and one
857     // of copper                               << 624   // of copper
858                                                << 625   const G4double monitor1XSize = 4.525022*mm;
859     monitor1XSize = 4.525022*mm;               << 626   const G4double monitor2XSize = 0.000011*mm;
860     monitor2XSize = 0.000011*mm;               << 627   const G4double monitor3XSize = 4.5*mm;
861     monitor3XSize = 4.5*mm;                    << 628   const G4double monitorYSize = 10.*cm; 
862     monitorYSize = 10.*cm;                     << 629   const G4double monitorZSize = 10.*cm;
863     monitorZSize = 10.*cm;                     << 630     // XXX (Camera monitor size = 9.050088 mm)
864     monitor1XPosition = -1239.974978 *mm;      << 631   const G4double monitor1XPosition = -1450.474956 *mm;
865     monitor2XPosition = -4.500011*mm;          << 632   const G4double monitor2XPosition = -4.500011*mm;
866     monitor4XPosition = 4.500011*mm;           << 633   const G4double monitor4XPosition = 4.500011*mm;
867                                                << 634   
868     solidFirstMonitorLayer1 = new G4Box("First << 635   G4Box* solidFirstMonitorLayer1 = new G4Box("FirstMonitorLayer1", 
869                                         monito << 636                          monitor1XSize, 
870                                         monito << 637                          monitorYSize, 
871                                         monito << 638                          monitorZSize);
872                                                << 639   
873     logicFirstMonitorLayer1 = new G4LogicalVol << 640   G4LogicalVolume* logicFirstMonitorLayer1 = new G4LogicalVolume(solidFirstMonitorLayer1, 
874                                                << 641                                    layer1MonitorChamberMaterial,
875                                                << 642                                    "FirstMonitorLayer1");
876                                                << 643   
877     physiFirstMonitorLayer1 = new G4PVPlacemen << 644   physiFirstMonitorLayer1 = new G4PVPlacement(0,
878                                                << 645                         G4ThreeVector(monitor1XPosition,0.*cm,0.*cm),
879                                                << 646                         "FirstMonitorLayer1", 
880                                                << 647                         logicFirstMonitorLayer1, 
881                                                << 648                         physicalTreatmentRoom, 
882                                                << 649                         false, 
883                                                << 650                         0);
884                                                << 651   
885     solidFirstMonitorLayer2 = new G4Box("First << 652   G4Box* solidFirstMonitorLayer2 = new G4Box("FirstMonitorLayer2", 
886                                         monito << 653                          monitor2XSize, 
887                                         monito << 654                          monitorYSize, 
888                                         monito << 655                          monitorZSize);
889                                                << 656   
890     logicFirstMonitorLayer2 = new G4LogicalVol << 657   G4LogicalVolume* logicFirstMonitorLayer2 = new G4LogicalVolume(solidFirstMonitorLayer2,
891                                                << 658                                    layer2MonitorChamberMaterial,
892                                                << 659                                    "FirstMonitorLayer2");
893                                                << 660   
894     physiFirstMonitorLayer2 = new G4PVPlacemen << 661   physiFirstMonitorLayer2 = new G4PVPlacement(0, G4ThreeVector(monitor2XPosition,0.*cm,0.*cm),
895                                                << 662                         "FirstMonitorLayer2", 
896                                                << 663                         logicFirstMonitorLayer2, 
897                                                << 664                         physiFirstMonitorLayer1,
898                                                << 665                         false, 
899                                                << 666                         0);
900                                                << 667   
901     solidFirstMonitorLayer3 = new G4Box("First << 668   G4Box* solidFirstMonitorLayer3 = new G4Box("FirstMonitorLayer3", 
902                                         monito << 669                          monitor3XSize, 
903                                         monito << 670                          monitorYSize, 
904                                         monito << 671                          monitorZSize);
905                                                << 672   
906     logicFirstMonitorLayer3 = new G4LogicalVol << 673   G4LogicalVolume* logicFirstMonitorLayer3 = new G4LogicalVolume(solidFirstMonitorLayer3, 
907                                                << 674                                    layer3MonitorChamberMaterial, 
908                                                << 675                                    "FirstMonitorLayer3");
909                                                << 676   
910     physiFirstMonitorLayer3 = new G4PVPlacemen << 677   physiFirstMonitorLayer3 = new G4PVPlacement(0, 
911                                                << 678                         G4ThreeVector(0.*mm,0.*cm,0.*cm), 
912                                                << 679                         "MonitorLayer3",
913                                                << 680                         logicFirstMonitorLayer3, 
914                                                << 681                         physiFirstMonitorLayer1, 
915                                                << 682                         false, 
916                                                << 683                         0);
917                                                << 684     
918     solidFirstMonitorLayer4 = new G4Box("First << 685   G4Box* solidFirstMonitorLayer4 = new G4Box("FirstMonitorLayer4", 
919                                         monito << 686                          monitor2XSize, 
920                                         monito << 687                          monitorYSize, 
921                                         monito << 688                          monitorZSize);
922                                                << 689   
923     logicFirstMonitorLayer4 = new G4LogicalVol << 690   G4LogicalVolume* logicFirstMonitorLayer4 = new G4LogicalVolume(solidFirstMonitorLayer4, 
924                                                << 691                                    layer4MonitorChamberMaterial, 
925                                                << 692                                    "FirstMonitorLayer4");
926                                                << 693   
927     physiFirstMonitorLayer4 = new G4PVPlacemen << 694   physiFirstMonitorLayer4 = new G4PVPlacement(0, G4ThreeVector(monitor4XPosition,0.*cm,0.*cm), 
928                                                << 695                         "FirstMonitorLayer4",
929                                                << 696                         logicFirstMonitorLayer4,
930                                                << 697                         physiFirstMonitorLayer1, false, 0);
931                                                << 698   
932     logicFirstMonitorLayer3 -> SetVisAttribute << 699   logicFirstMonitorLayer3 -> SetVisAttributes(white);
933                                                << 700   
934 }                                                 701 }
935                                                   702 
936 //////////////////////////////////////////////    703 /////////////////////////////////////////////////////////////////////////////
937 //////////////////////////////////////////////    704 /////////////////////////////////////////////////////////////////////////////
938 void PassiveCarbonBeamLine::HadrontherapyBeamN    705 void PassiveCarbonBeamLine::HadrontherapyBeamNozzle()
939 {                                                 706 {
940     // ------------------------------//        << 707   // ------------------------------//
941     // THE FINAL TUBE AND COLLIMATOR //        << 708   // THE FINAL TUBE AND COLLIMATOR //
942     //-------------------------------//        << 709   //-------------------------------//
943     // The last part of the transport beam lin << 710   // The last part of the transport beam line consists of
944     // a 59 mm thick PMMA slab (to stop all th << 711   // a 59 mm thick PMMA slab (to stop all the diffused radiation), a 285 mm brass tube
945     // (to well collimate the proton beam) and << 712   // (to well collimate the carbon beam) and a final collimator with 25 mm diameter
946     // aperture (that provide the final trasve << 713   // aperture (that provide the final trasversal shape of the beam)
947                                                << 714   
948     // -------------------//                   << 715   // -------------------//
949     //     PMMA SUPPORT   //                   << 716   //     PMMA SUPPORT   //
950     // -------------------//                   << 717   // -------------------//
951                                                << 718 
952     nozzleSupportXSize = 50 *mm;               << 719   const G4double nozzleSupportXSize = 29.5 *mm;
953     nozzleSupportYSize = 360. *mm;             << 720   const G4double nozzleSupportYSize = 180. *mm;
954     nozzleSupportZSize = 360. *mm;             << 721   const G4double nozzleSupportZSize = 180. *mm;
955     nozzleSupportXPosition = -423.0 *mm;       << 722   //XXX Placed at 
956                                                << 723   const G4double nozzleSupportXPosition = -558. *mm;
957     G4double phi = 90. *deg;                   << 724   
958     // Matrix definition for a 90 deg rotation << 725   G4double phi = 90. *deg;     
959     G4RotationMatrix rm;                       << 726   // Matrix definition for a 90 deg rotation. Also used for other volumes       
960     rm.rotateY(phi);                           << 727   G4RotationMatrix rm;               
961                                                << 728   rm.rotateY(phi);
962     solidNozzleSupport = new G4Box("NozzleSupp << 729   
963                                    nozzleSuppo << 730   G4Box* solidNozzleSupport = new G4Box("NozzleSupport", 
964                                    nozzleSuppo << 731                       nozzleSupportXSize, 
965                                    nozzleSuppo << 732                       nozzleSupportYSize, 
966                                                << 733                       nozzleSupportZSize);
967     logicNozzleSupport = new G4LogicalVolume(s << 734   
968                                              n << 735   G4LogicalVolume* logicNozzleSupport = new G4LogicalVolume(solidNozzleSupport, 
969                                              " << 736                                 nozzleSupportMaterial, 
970                                                << 737                                 "NozzleSupport");
971     physiNozzleSupport = new G4PVPlacement(0,  << 738   
972                                            "No << 739   physiNozzleSupport = new G4PVPlacement(0, G4ThreeVector(nozzleSupportXPosition,0., 0.),
973                                            log << 740                        "NozzleSupport", 
974                                            phy << 741                        logicNozzleSupport, 
975                                            fal << 742                        physicalTreatmentRoom, 
976                                            0); << 743                        false, 
977                                                << 744                        0);
978     yellow = new G4VisAttributes(G4Colour(1.,  << 745   
979     yellow-> SetVisibility(true);              << 746   logicNozzleSupport -> SetVisAttributes(yellow);
980     yellow-> SetForceWireframe(true);          << 747   
981                                                << 748   // -------------------//
982     //------------------------------------//   << 749   //     BRASS TUBE     //
983     // HOLE IN THE SUPPORT                //   << 750   // -------------------//
984     //------------------------------------//   << 751   const G4double innerRadiusHoleNozzleSupport = 18.*mm;
985     innerRadiusHoleNozzleSupport = 0.*mm;      << 752   const G4double outerRadiusHoleNozzleSupport = 21.5 *mm;
986     outerRadiusHoleNozzleSupport = 22.0*mm;    << 753   //XXX h/2 = 142.5 mm
987     hightHoleNozzleSupport = nozzleSupportXSiz << 754   const G4double hightHoleNozzleSupport = 142.5*mm;
988     startAngleHoleNozzleSupport = 0.*deg;      << 755   const G4double startAngleHoleNozzleSupport = 0.*deg;
989     spanningAngleHoleNozzleSupport = 360.*deg; << 756   const G4double spanningAngleHoleNozzleSupport = 360.*deg;
990                                                << 757   //XXX -(320+142.5)mm
991     solidHoleNozzleSupport = new G4Tubs("HoleN << 758   const G4double holeNozzleSupportXPosition = -462.50 *mm;
992                                         innerR << 759   
993                                         outerR << 760   G4Tubs* solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport", 
994                                         hightH << 761                         innerRadiusHoleNozzleSupport, 
995                                         startA << 762                         outerRadiusHoleNozzleSupport,
996                                         spanni << 763                         hightHoleNozzleSupport, 
997                                                << 764                         startAngleHoleNozzleSupport, 
998     logicHoleNozzleSupport = new G4LogicalVolu << 765                         spanningAngleHoleNozzleSupport);
999                                                << 766   
1000                                               << 767   G4LogicalVolume* logicHoleNozzleSupport = new G4LogicalVolume(solidHoleNozzleSupport, 
1001                                               << 768                                   holeNozzleSupportMaterial, 
1002                                               << 769                                   "HoleNozzleSupport", 
1003                                               << 770                                   0, 0, 0);
1004                                               << 771   
1005     physiHoleNozzleSupport = new G4PVPlacemen << 772   physiHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(holeNozzleSupportXPosition, 0., 0.)),
1006                                               << 773                          "HoleNozzleSupport", 
1007                                               << 774                          logicHoleNozzleSupport, 
1008                                               << 775                          physicalTreatmentRoom, false, 0); 
1009                                               << 776   
1010                                               << 777   logicHoleNozzleSupport -> SetVisAttributes(darkOrange3);
1011                                               << 778   
1012     // -------------------------------------- << 779   //--------------------------------------------------------------//
1013     //     BRASS TUBE 3 (beam line side)    / << 780   // HOLE OF THE BRASS TUBE (otherwise we'll have PMMA)           //
1014     // -------------------------------------/ << 781   //--------------------------------------------------------------//
1015     innerRadiusBrassTube3 = 13.5 *mm;         << 782   const G4double innerRadiusSecondHoleNozzleSupport = 0.*mm;
1016     outerRadiusBrassTube3 = 21.5 *mm;         << 783   const G4double outerRadiusSecondHoleNozzleSupport = 18.*mm;
1017     hightBrassTube3 = 20.0 *mm;               << 784   const G4double hightSecondHoleNozzleSupport = 29.5 *mm;
1018     startAngleBrassTube3 = 0.*deg;            << 785   const G4double startAngleSecondHoleNozzleSupport = 0.*deg;
1019     spanningAngleBrassTube3 = 360.*deg;       << 786   const G4double spanningAngleSecondHoleNozzleSupport = 360.*deg;
1020     brassTube3XPosition = -458.0 *mm;         << 787   
1021                                               << 788   G4Tubs* solidSecondHoleNozzleSupport = new G4Tubs("SecondHoleNozzleSupport",
1022     solidBrassTube3 = new G4Tubs("BrassTube3" << 789                             innerRadiusSecondHoleNozzleSupport,
1023                                  innerRadiusB << 790                             outerRadiusSecondHoleNozzleSupport, 
1024                                  outerRadiusB << 791                             hightSecondHoleNozzleSupport,
1025                                  hightBrassTu << 792                             startAngleSecondHoleNozzleSupport, 
1026                                  startAngleBr << 793                             spanningAngleSecondHoleNozzleSupport);
1027                                  spanningAngl << 794   
1028                                               << 795   G4LogicalVolume* logicSecondHoleNozzleSupport = new G4LogicalVolume(solidSecondHoleNozzleSupport, 
1029     logicBrassTube3 = new G4LogicalVolume(sol << 796                                     seconHoleNozzleSupportMaterial,
1030                                           bra << 797                                     "SecondHoleNozzleSupport",
1031                                           "Br << 798                                     0, 
1032                                           0,  << 799                                     0,
1033                                               << 800                                     0);
1034     physiBrassTube3 = new G4PVPlacement(G4Tra << 801   
1035                                               << 802   physiSecondHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()), 
1036                                               << 803                            "SecondHoleNozzleSupport",
1037                                               << 804                            logicSecondHoleNozzleSupport, 
1038                                         "Bras << 805                            physiNozzleSupport, 
1039                                         logic << 806                            false, 0); 
1040                                         physi << 807   
1041                                         false << 808   
1042                                         0);   << 809   logicHoleNozzleSupport -> SetVisAttributes(darkOrange3); 
1043                                               << 
1044     logicBrassTube3 -> SetVisAttributes(darkO << 
1045                                               << 
1046     // -------------------------------------- << 
1047     //     BRASS TUBE 2 (inside the PMMA supp << 
1048     // -------------------------------------- << 
1049                                               << 
1050     innerRadiusBrassTube2 = 13.5 *mm;         << 
1051     outerRadiusBrassTube2 = 21.5 *mm;         << 
1052     hightBrassTube2 = nozzleSupportXSize;     << 
1053     startAngleBrassTube2 = 0.*deg;            << 
1054     spanningAngleBrassTube2 = 360.*deg;       << 
1055                                               << 
1056                                               << 
1057     solidBrassTube2 = new G4Tubs("BrassTube2" << 
1058                                  innerRadiusB << 
1059                                  outerRadiusB << 
1060                                  hightBrassTu << 
1061                                  startAngleBr << 
1062                                  spanningAngl << 
1063                                               << 
1064     logicBrassTube2 = new G4LogicalVolume(sol << 
1065                                           bra << 
1066                                           "Br << 
1067                                           0,  << 
1068     physiBrassTube2 = new G4PVPlacement(0,    << 
1069                                         G4Thr << 
1070                                         logic << 
1071                                         "Bras << 
1072                                         logic << 
1073                                         false << 
1074                                         0);   << 
1075                                               << 
1076     logicBrassTube2 -> SetVisAttributes(darkO << 
1077                                               << 
1078     // ---------------------------------//    << 
1079     //     BRASS TUBE 1 (phantom side)    //  << 
1080     // ---------------------------------//    << 
1081     innerRadiusBrassTube= 18.*mm;             << 
1082     outerRadiusBrassTube = 21.5 *mm;          << 
1083     hightBrassTube = 208.0 *mm;               << 
1084     startAngleBrassTube = 0.*deg;             << 
1085     spanningAngleBrassTube = 360.*deg;        << 
1086     brassTubeXPosition = -294 *mm;            << 
1087     solidBrassTube = new G4Tubs("BrassTube",  << 
1088                                 innerRadiusBr << 
1089                                 outerRadiusBr << 
1090                                 hightBrassTub << 
1091                                 startAngleBra << 
1092                                 spanningAngle << 
1093                                               << 
1094     logicBrassTube = new G4LogicalVolume(soli << 
1095                                          bras << 
1096                                          "Bra << 
1097                                          0, 0 << 
1098                                               << 
1099     physiBrassTube = new G4PVPlacement(G4Tran << 
1100                                               << 
1101                                               << 
1102                                               << 
1103                                        "Brass << 
1104                                        logicB << 
1105                                        physic << 
1106                                        false, << 
1107                                        0);    << 
1108                                               << 
1109     logicBrassTube -> SetVisAttributes(darkOr << 
1110 }                                                810 }
1111                                                  811 
1112 /////////////////////////////////////////////    812 /////////////////////////////////////////////////////////////////////////////
1113 void PassiveCarbonBeamLine::HadrontherapyBeam    813 void PassiveCarbonBeamLine::HadrontherapyBeamFinalCollimator()
1114 {                                                814 {
1115     // -----------------------//              << 815   // -----------------------//
1116     //     FINAL COLLIMATOR   //              << 816   //     FINAL COLLIMATOR   //
1117     //------------------------//              << 817   //------------------------//
1118     outerRadiusFinalCollimator = 21.5*mm;     << 818   const G4double outerRadiusFinalCollimator = 21.5*mm;
1119     hightFinalCollimator = 7.0 *mm;           << 819   const G4double hightFinalCollimator = 3.5*mm;
1120     startAngleFinalCollimator = 0.*deg;       << 820   const G4double startAngleFinalCollimator = 0.*deg;
1121     spanningAngleFinalCollimator = 360.*deg;  << 821   const G4double spanningAngleFinalCollimator = 360.*deg;
1122     finalCollimatorXPosition = -186.5 *mm;    << 822   //XXX
1123                                               << 823   const G4double finalCollimatorXPosition = -323.50 *mm;  
1124     G4double phi = 90. *deg;                  << 824   
1125                                               << 825   G4double phi = 90. *deg;     
1126     // Matrix definition for a 90 deg rotatio << 826   
1127     G4RotationMatrix rm;                      << 827   // Matrix definition for a 90 deg rotation. Also used for other volumes       
1128     rm.rotateY(phi);                          << 828   G4RotationMatrix rm;
1129                                               << 829   rm.rotateY(phi);
1130     solidFinalCollimator = new G4Tubs("FinalC << 830   
1131                                       innerRa << 831   solidFinalCollimator = new G4Tubs("FinalCollimator", 
1132                                       outerRa << 832                     innerRadiusFinalCollimator, 
1133                                       hightFi << 833                     outerRadiusFinalCollimator,
1134                                       startAn << 834                     hightFinalCollimator, 
1135                                       spannin << 835                     startAngleFinalCollimator, 
1136                                               << 836                     spanningAngleFinalCollimator);
1137     logicFinalCollimator = new G4LogicalVolum << 837   
1138                                               << 838   G4LogicalVolume* logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator, 
1139                                               << 839                                 finalCollimatorMaterial, 
1140                                               << 840                                 "FinalCollimator", 
1141                                               << 841                                 0,
1142                                               << 842                                 0, 
1143                                               << 843                                 0);
1144     physiFinalCollimator = new G4PVPlacement( << 844   
1145                                               << 845   physiFinalCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(finalCollimatorXPosition,0.,0.)),
1146                                               << 846                        "FinalCollimator", logicFinalCollimator, physicalTreatmentRoom, false, 0); 
1147                                               << 847   
1148                                               << 848   logicFinalCollimator -> SetVisAttributes(yellow); 
1149                                               << 
1150                                               << 
1151                                               << 
1152     logicFinalCollimator -> SetVisAttributes( << 
1153 }                                             << 
1154                                               << 
1155                                               << 
1156 ///////////////////////////////////////////// << 
1157 /////////////////////////// MESSENGER /////// << 
1158 ///////////////////////////////////////////// << 
1159                                               << 
1160 void PassiveCarbonBeamLine::SetRippleFilterXP << 
1161 {                                             << 
1162     PhysiRippleFilter -> SetTranslation(G4Thr << 
1163     G4RunManager::GetRunManager() -> Geometry << 
1164     G4cout << "The Ripple Filter is translate << 
1165 }                                                849 }
1166                                               << 
1167                                               << 
1168 ///////////////////////////////////////////// << 
1169 void PassiveCarbonBeamLine::SetInnerRadiusFin << 
1170 {                                             << 
1171     solidFinalCollimator -> SetInnerRadius(va << 
1172     G4RunManager::GetRunManager() -> Geometry << 
1173     G4cout<<"Inner Radius of the final collim << 
1174     << solidFinalCollimator -> GetInnerRadius << 
1175     << G4endl;                                << 
1176 }                                             << 
1177                                               << 
1178 ///////////////////////////////////////////// << 
1179 void PassiveCarbonBeamLine::SetRippleFilterMa << 
1180 {                                             << 
1181     if (G4Material* RFMaterial = G4NistManage << 
1182     {                                         << 
1183         if (RFMaterial)                       << 
1184         {                                     << 
1185             rippleFilterMaterial  = RFMateria << 
1186             LogicRippleFilter -> SetMaterial( << 
1187             LogicRippleFilterBase -> SetMater << 
1188             LogicRippleFilterTrd -> SetMateri << 
1189             G4cout << "The material of the Ri << 
1190         }                                     << 
1191     }                                         << 
1192     else                                      << 
1193     {                                         << 
1194         G4cout << "WARNING: material \"" << m << 
1195         " table [located in $G4INSTALL/source << 
1196         G4cout << "Use command \"/parameter/n << 
1197     }                                         << 
1198 }                                             << 
1199                                               << 
1200                                               << 
1201                                                  850 
1202                                                  851