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.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Hadrontherapy advanced example for Geant4       26 // Hadrontherapy advanced example for Geant4
 27 // See more at: https://twiki.cern.ch/twiki/bi     27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
 28 // Simulation of the "Zero degree" experimenta << 
 29                                                    28 
 30 #include "G4Box.hh"                                29 #include "G4Box.hh"
 31 #include "G4Tubs.hh"                               30 #include "G4Tubs.hh"
 32 #include "G4VisAttributes.hh"                      31 #include "G4VisAttributes.hh"
 33 #include "G4Colour.hh"                             32 #include "G4Colour.hh"
 34 #include "globals.hh"                              33 #include "globals.hh"
 35 #include "G4RunManager.hh"                         34 #include "G4RunManager.hh"
 36 #include "G4LogicalVolume.hh"                      35 #include "G4LogicalVolume.hh"
 37 #include "G4PVPlacement.hh"                        36 #include "G4PVPlacement.hh"
 38 #include "G4RotationMatrix.hh"                     37 #include "G4RotationMatrix.hh"
 39 #include "G4NistManager.hh"                        38 #include "G4NistManager.hh"
 40 #include "G4NistElementBuilder.hh"                 39 #include "G4NistElementBuilder.hh"
 41 #include "HadrontherapyDetectorConstruction.hh     40 #include "HadrontherapyDetectorConstruction.hh"
 42 #include "HadrontherapyModulator.hh"               41 #include "HadrontherapyModulator.hh"
 43 #include "PassiveCarbonBeamLine.hh"                42 #include "PassiveCarbonBeamLine.hh"
 44 #include "G4SystemOfUnits.hh"                      43 #include "G4SystemOfUnits.hh"
 45 #include "G4Trd.hh"                            <<  44 //#include "FaradayCup.hh"
 46 #include "PassiveCarbonBeamLineMessenger.hh"   << 
 47 #include "G4UnionSolid.hh"                     << 
 48                                                << 
 49 using namespace std;                           << 
 50                                                    45 
 51 //G4bool PassiveCarbonBeamLine::doCalculation      46 //G4bool PassiveCarbonBeamLine::doCalculation = false;
 52 //////////////////////////////////////////////     47 /////////////////////////////////////////////////////////////////////////////
 53 PassiveCarbonBeamLine::PassiveCarbonBeamLine()     48 PassiveCarbonBeamLine::PassiveCarbonBeamLine():
 54 physicalTreatmentRoom(0),hadrontherapyDetector <<  49 physicalTreatmentRoom(0), hadrontherapyDetectorConstruction(0),
 55 physiBeamLineSupport(0), physiBeamLineCover(0) <<  50 physiBeamLineSupport(0), physiBeamLineCover(0), physiBeamLineCover2(0), 
 56 physiKaptonWindow(0),PhysiRippleFilter(0),Phys <<  51 physiKaptonWindow(0), 
 57 physiFirstMonitorLayer1(0), physiFirstMonitorL     52 physiFirstMonitorLayer1(0), physiFirstMonitorLayer2(0),
 58 physiFirstMonitorLayer3(0), physiFirstMonitorL     53 physiFirstMonitorLayer3(0), physiFirstMonitorLayer4(0),
 59 physiNozzleSupport(0), physiHoleNozzleSupport( <<  54 physiNozzleSupport(0), physiHoleNozzleSupport(0),
 60 {                                              <<  55 physiSecondHoleNozzleSupport(0),
 61                                                <<  56 solidFinalCollimator(0),
 62     // Messenger to change parameters of the p <<  57 physiFinalCollimator(0)
 63     PassiveCarbonMessenger = new PassiveCarbon <<  58 {
 64                                                <<  59 
 65     //***************************** PW ******* <<  60 //***************************** PW ***************************************
 66                                                <<  61 
 67     static G4String ROGeometryName = "Detector <<  62   static G4String ROGeometryName = "DetectorROGeometry";
 68     RO = new HadrontherapyDetectorROGeometry(R <<  63   RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
 69                                                <<  64   
 70                                                <<  65   
 71     G4cout << "Going to register Parallel worl <<  66 
 72     RegisterParallelWorld(RO);                 <<  67   G4cout << "Going to register Parallel world...";
 73     G4cout << "... done" << G4endl;            <<  68   RegisterParallelWorld(RO);
 74     //***************************** PW ******* <<  69   G4cout << "... done" << G4endl;
                                                   >>  70 //***************************** PW ***************************************
 75 }                                                  71 }
 76                                                    72 
 77 //////////////////////////////////////////////     73 /////////////////////////////////////////////////////////////////////////////
 78 PassiveCarbonBeamLine::~PassiveCarbonBeamLine(     74 PassiveCarbonBeamLine::~PassiveCarbonBeamLine()
 79 {                                                  75 {
 80     delete hadrontherapyDetectorConstruction;  <<  76   delete hadrontherapyDetectorConstruction;
 81     delete PassiveCarbonMessenger;             << 
 82 }                                                  77 }
 83                                                    78 
 84 //////////////////////////////////////////////     79 /////////////////////////////////////////////////////////////////////////////
 85 G4VPhysicalVolume* PassiveCarbonBeamLine::Cons     80 G4VPhysicalVolume* PassiveCarbonBeamLine::Construct()
 86 {                                              <<  81 { 
 87     // Sets default geometry and materials     <<  82   // Sets default geometry and materials
 88     SetDefaultDimensions();                    <<  83   SetDefaultDimensions();
 89                                                <<  84   
 90     // Construct the whole CarbonPassive Beam  <<  85   // Construct the whole CarbonPassive Beam Line 
 91     ConstructPassiveCarbonBeamLine();          <<  86   ConstructPassiveCarbonBeamLine();
 92                                                <<  87   
 93                                                <<  88   
 94     //***************************** PW ******* <<  89 //***************************** PW ***************************************
 95     if (!hadrontherapyDetectorConstruction)    <<  90   if (!hadrontherapyDetectorConstruction)
 96                                                <<  91 
 97         //***************************** PW *** <<  92 //***************************** PW ***************************************
 98         // HadrontherapyDetectorConstruction b <<  93   
 99         hadrontherapyDetectorConstruction = ne <<  94   // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
100                                                <<  95   hadrontherapyDetectorConstruction = new HadrontherapyDetectorConstruction(physicalTreatmentRoom); 
101     //***************************** PW ******* <<  96   
102                                                <<  97 //***************************** PW ***************************************
103     hadrontherapyDetectorConstruction->Initial <<  98 
104                                                <<  99  hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
105     //***************************** PW ******* << 100 
106     return physicalTreatmentRoom;              << 101 //***************************** PW ***************************************    
                                                   >> 102   return physicalTreatmentRoom;
107 }                                                 103 }
108                                                   104 
109 // In the following method the DEFAULTS used i << 105 // In the following method the DEFAULTS used in the geometry of 
110 // passive beam line are provided                 106 // passive beam line are provided
111 // HERE THE USER CAN CHANGE THE GEOMETRY CHARA    107 // HERE THE USER CAN CHANGE THE GEOMETRY CHARACTERISTICS OF BEAM
112 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE << 108 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE THE MACRO FILE (IF A 
113 // MESSENGER IS PROVIDED)                         109 // MESSENGER IS PROVIDED)
114 //                                                110 //
115 // DEFAULT MATERIAL ARE ALSO PROVIDED          << 111 // DEFAULT MATERIAL ARE ALSO PROVIDED 
116 // and COLOURS ARE ALSO DEFINED                   112 // and COLOURS ARE ALSO DEFINED
117 // -------------------------------------------    113 // ----------------------------------------------------------
118 //////////////////////////////////////////////    114 /////////////////////////////////////////////////////////////////////////////
119 void PassiveCarbonBeamLine::SetDefaultDimensio    115 void PassiveCarbonBeamLine::SetDefaultDimensions()
120 {                                                 116 {
121     // Set of coulors that can be used         << 117   // Set of coulors that can be used
122     white = new G4VisAttributes( G4Colour());  << 118   white = new G4VisAttributes( G4Colour());
123     white -> SetVisibility(true);              << 119   white -> SetVisibility(true);
124     white -> SetForceSolid(true);              << 120   white -> SetForceSolid(true);
125                                                << 121   
126     black = new G4VisAttributes( G4Colour(1.,  << 122   blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
127     black -> SetVisibility(true);              << 123   blue -> SetVisibility(true);
128     black -> SetForceSolid(true);              << 124   blue -> SetForceSolid(true);
129                                                << 125   
130                                                << 126   gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5 ));
131     blue = new G4VisAttributes(G4Colour(0. ,0. << 127   gray-> SetVisibility(true);
132     blue -> SetVisibility(true);               << 128   gray-> SetForceSolid(true);
133     blue -> SetForceSolid(true);               << 129   
134                                                << 130   red = new G4VisAttributes(G4Colour(1. ,0. ,0.));
135     gray = new G4VisAttributes( G4Colour(0.5,  << 131   red-> SetVisibility(true);
136     gray-> SetVisibility(true);                << 132   red-> SetForceSolid(true);
137     gray-> SetForceSolid(true);                << 133   
138                                                << 134   yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
139     red = new G4VisAttributes(G4Colour(1. ,0.  << 135   yellow-> SetVisibility(true);
140     red-> SetVisibility(true);                 << 136   yellow-> SetForceSolid(true);
141     red-> SetForceSolid(true);                 << 137   
142                                                << 138   green = new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
143     yellow = new G4VisAttributes(G4Colour(1.,  << 139   green -> SetVisibility(true);
144     yellow-> SetVisibility(true);              << 140   green -> SetForceSolid(true);
145     yellow-> SetForceSolid(true);              << 141   
146                                                << 142   darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. ,  0/255. ));
147     green = new G4VisAttributes( G4Colour(25/2 << 143   darkGreen -> SetVisibility(true);
148     green -> SetVisibility(true);              << 144   darkGreen -> SetForceSolid(true);
149     green -> SetForceSolid(true);              << 145   
150                                                << 146   darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. ,  000/255. ));
151     darkGreen = new G4VisAttributes( G4Colour( << 147   darkOrange3 -> SetVisibility(true);
152     darkGreen -> SetVisibility(true);          << 148   darkOrange3 -> SetForceSolid(true);
153     darkGreen -> SetForceSolid(true);          << 149   
154                                                << 150   skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. ,  235/255. ));
155     darkOrange3 = new G4VisAttributes( G4Colou << 151   skyBlue -> SetVisibility(true);
156     darkOrange3 -> SetVisibility(true);        << 152   skyBlue -> SetForceSolid(true);
157     darkOrange3 -> SetForceSolid(true);        << 153   
158                                                << 154   
159     skyBlue = new G4VisAttributes( G4Colour(13 << 155   // VACUUM PIPE: first track of the beam line is inside vacuum;
160     skyBlue -> SetVisibility(true);            << 156   // The PIPE contains  KAPTON WINDOW
161     skyBlue -> SetForceSolid(true);            << 157   G4double defaultVacuumZoneXSize = 80.5325 *mm;
162                                                << 158   vacuumZoneXSize = defaultVacuumZoneXSize;
163                                                << 159   
164     // FINAL COLLIMATOR: is the collimator giv << 160   G4double defaultVacuumZoneYSize = 52.5 *mm;
165     // of the beam                             << 161   vacuumZoneYSize = defaultVacuumZoneYSize;
166                                                << 162   
167     G4double defaultinnerRadiusFinalCollimator << 163   G4double defaultVacuumZoneZSize = 52.5 *mm;
168     innerRadiusFinalCollimator = defaultinnerR << 164   vacuumZoneZSize = defaultVacuumZoneZSize;
169                                                << 165   
170     // DEFAULT DEFINITION OF THE MATERIALS     << 166   // XXX -1775 mm (xKapton to WORLD) - 80.5075 (xKapton to vacuumZone) 
171     // All elements and compound definition fo << 167   G4double defaultVacuumZoneXPosition = -1855.5075 *mm;
172                                                << 168   vacuumZoneXPosition = defaultVacuumZoneXPosition;
173     // ELEMENTS                                << 169   
174     G4bool isotopes = false;                   << 170   
175     aluminumNist = G4NistManager::Instance()-> << 171   // KAPTON WINDOW: it permits the passage of the beam from vacuum to air
176     G4Element* zincNist = G4NistManager::Insta << 172   G4double defaultKaptonWindowXSize = 0.025*mm;
177     G4Element* copperNist = G4NistManager::Ins << 173   kaptonWindowXSize = defaultKaptonWindowXSize;
178                                                << 174   
179     // MATERIAL (Including compounds)          << 175   G4double defaultKaptonWindowYSize = 5.25*cm;
180     copperNistMaterial = G4NistManager::Instan << 176   kaptonWindowYSize = defaultKaptonWindowYSize;
181     airNist =  G4NistManager::Instance()->Find << 177   
182     kaptonNist = G4NistManager::Instance()->Fi << 178   G4double defaultKaptonWindowZSize = 5.25*cm;
183     galacticNist = G4NistManager::Instance()-> << 179   kaptonWindowZSize = defaultKaptonWindowZSize;
184     PMMANist = G4NistManager::Instance()->Find << 180   
185     tantalumNist = G4NistManager::Instance()-> << 181   G4double defaultKaptonWindowXPosition = 80.5075*mm;
186                                                << 182   kaptonWindowXPosition = defaultKaptonWindowXPosition;
187     G4double d; // Density                     << 183   
188     G4int nComponents;// Number of components  << 184   // FIRST SCATTERING FOIL: a thin foil performing a first scattering
189     G4double fractionmass; // Fraction in mass << 185   // of the original beam
190                                                << 186   G4double defaultFirstScatteringFoilXSize = 0.025 *mm;
191     d = 8.40*g/cm3;                            << 187   firstScatteringFoilXSize = defaultFirstScatteringFoilXSize; 
192     nComponents = 2;                           << 188   
193     brass = new G4Material("Brass", d, nCompon << 189   G4double defaultFirstScatteringFoilYSize = 105.0   *mm;
194     brass -> AddElement(zincNist, fractionmass << 190   firstScatteringFoilYSize = defaultFirstScatteringFoilYSize;
195     brass -> AddElement(copperNist, fractionma << 191   
196                                                << 192   G4double defaultFirstScatteringFoilZSize = 105   *mm;
197     //***************************** PW ******* << 193   firstScatteringFoilZSize = defaultFirstScatteringFoilZSize;
198                                                << 194   
199     // DetectorROGeometry Material             << 195   G4double defaultFirstScatteringFoilXPosition = 0.0 *mm;
200     new G4Material("dummyMat", 1., 1.*g/mole,  << 196   firstScatteringFoilXPosition = defaultFirstScatteringFoilXPosition;
201                                                << 197   
202     //***************************** PW ******* << 198   
203                                                << 199   
204     // MATERIAL ASSIGNMENT                     << 200   // STOPPER AND SCATTERING FOIL SIMULATED TO TEST THEIR EFFECT
205     // Support of the beam line                << 201   // IN THE LATERAL DOSE DISTRIBUTION
206     beamLineSupportMaterial = aluminumNist;    << 202   // STOPPER: is a small cylinder able to stop the central component
207                                                << 203   // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
208     // Vacuum pipe                             << 204   // and represent the second element of the scattering system
209     vacuumZoneMaterial = galacticNist;         << 205   G4double defaultInnerRadiusStopper = 0.*cm;
210     firstScatteringFoilMaterial = tantalumNist << 206   innerRadiusStopper = defaultInnerRadiusStopper;
211                                                << 207   
212     // Material of kapton window               << 208   G4double defaultHeightStopper = 7.0 *mm;
213     kaptonWindowMaterial = kaptonNist;         << 209   heightStopper = defaultHeightStopper;
214                                                << 210   
215     // Material of ripple filter               << 211   G4double defaultStartAngleStopper = 0.*deg;
216     rippleFilterMaterial = PMMANist;           << 212   startAngleStopper = defaultStartAngleStopper;
217     rippleFilterBoxMaterial = airNist;         << 213   
218                                                << 214   G4double defaultSpanningAngleStopper = 360.*deg;
219     // Materials of the monitor chamber        << 215   spanningAngleStopper = defaultSpanningAngleStopper;
220     layer1MonitorChamberMaterial = kaptonNist; << 216   
221     layer2MonitorChamberMaterial = copperNistM << 217   G4double defaultStopperXPosition = -1675.0 *mm;
222     layer3MonitorChamberMaterial = airNist;    << 218   stopperXPosition = defaultStopperXPosition;
223     layer4MonitorChamberMaterial = copperNistM << 219   
224                                                << 220   G4double defaultStopperYPosition = 0.*m;
225     // Material of the final nozzle            << 221   stopperYPosition = defaultStopperYPosition;
226     nozzleSupportMaterial = PMMANist;          << 222   
227     holeNozzleSupportMaterial = airNist;       << 223   G4double defaultStopperZPosition = 0.*m;
228     seconHoleNozzleSupportMaterial = airNist;  << 224   stopperZPosition = defaultStopperZPosition;
229                                                << 225   
230     // Material of the final collimator        << 226   G4double defaultOuterRadiusStopper = 2 *mm;
231     brassTubeMaterial = brassTube2Material = b << 227   outerRadiusStopper = defaultOuterRadiusStopper; 
232                                                << 228   
233     // Material of the final collimator        << 229   // SECOND SCATTERING FOIL: it is another thin foil and provides the
234     finalCollimatorMaterial = brass;           << 230   // final diffusion of the beam. It represents the third element of the scattering
235                                                << 231   // system;
236     // Material of the PMMA collimator         << 232   G4double defaultSecondScatteringFoilXSize = 0.025 *mm;  
237     PMMACollimatorMaterial = airNist;          << 233   secondScatteringFoilXSize = defaultSecondScatteringFoilXSize;
238                                                << 234   
239                                                << 235   G4double defaultSecondScatteringFoilYSize = 105.0   *mm;
240     G4Element* hydrogenNist = G4NistManager::I << 236   secondScatteringFoilYSize = defaultSecondScatteringFoilYSize;
241     G4Element* oxygenNist = G4NistManager::Ins << 237   
242     G4Element* carbonNist = G4NistManager::Ins << 238   G4double defaultSecondScatteringFoilZSize = 105.0   *mm;
243                                                << 239   secondScatteringFoilZSize = defaultSecondScatteringFoilZSize;
244     G4Material* plastic = new G4Material("Plas << 240   
245     plastic -> AddElement(carbonNist, 21);     << 241   G4double defaultSecondScatteringFoilXPosition = defaultStopperXPosition + defaultHeightStopper + defaultSecondScatteringFoilXSize/2;
246     plastic -> AddElement(oxygenNist, 4);      << 242   secondScatteringFoilXPosition = defaultSecondScatteringFoilXPosition;
247     plastic -> AddElement(hydrogenNist, 24);   << 243   
248     PMMANist = plastic;                        << 244   G4double defaultSecondScatteringFoilYPosition =  0 *mm;
249                                                << 245   secondScatteringFoilYPosition = defaultSecondScatteringFoilYPosition;
250                                                << 246   
251                                                << 247   G4double defaultSecondScatteringFoilZPosition =  0 *mm;
                                                   >> 248   secondScatteringFoilZPosition = defaultSecondScatteringFoilZPosition;
                                                   >> 249   
                                                   >> 250   
                                                   >> 251   // FINAL COLLIMATOR: is the collimator giving the final transversal shape
                                                   >> 252   // of the beam 
                                                   >> 253   G4double defaultinnerRadiusFinalCollimator = 12.5 *mm;
                                                   >> 254   innerRadiusFinalCollimator = defaultinnerRadiusFinalCollimator;
                                                   >> 255   
                                                   >> 256   // DEFAULT DEFINITION OF THE MATERIALS
                                                   >> 257   // All elements and compound definition follows the NIST database
                                                   >> 258   
                                                   >> 259   // ELEMENTS
                                                   >> 260   G4bool isotopes = false;
                                                   >> 261   G4Material* aluminumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al", isotopes);
                                                   >> 262   G4Material* copperNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu", isotopes);
                                                   >> 263   G4Element* zincNist = G4NistManager::Instance()->FindOrBuildElement("Zn");
                                                   >> 264   G4Element* copperNist = G4NistManager::Instance()->FindOrBuildElement("Cu");
                                                   >> 265   G4Material* tantalumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ta", isotopes); 
                                                   >> 266   
                                                   >> 267   // COMPOUND
                                                   >> 268   G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
                                                   >> 269   G4Material* kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
                                                   >> 270   G4Material* galacticNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic", isotopes);
                                                   >> 271   G4Material* PMMANist = G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS", isotopes);
                                                   >> 272   
                                                   >> 273   G4double d; // Density
                                                   >> 274   G4int nComponents;// Number of components 
                                                   >> 275   G4double fractionmass; // Fraction in mass of an element in a material
                                                   >> 276   
                                                   >> 277   d = 8.40*g/cm3;
                                                   >> 278   nComponents = 2;
                                                   >> 279   G4Material* brass = new G4Material("Brass", d, nComponents);  
                                                   >> 280   brass -> AddElement(zincNist, fractionmass = 30 *perCent);
                                                   >> 281   brass -> AddElement(copperNist, fractionmass = 70 *perCent);
                                                   >> 282   
                                                   >> 283 //***************************** PW ***************************************
                                                   >> 284 
                                                   >> 285 // DetectorROGeometry Material
                                                   >> 286   new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
                                                   >> 287 
                                                   >> 288 //***************************** PW ***************************************
                                                   >> 289   
                                                   >> 290   
                                                   >> 291   // MATERIAL ASSIGNMENT
                                                   >> 292   // Support of the beam line
                                                   >> 293   beamLineSupportMaterial = aluminumNist;
                                                   >> 294   
                                                   >> 295   // Vacuum pipe
                                                   >> 296   vacuumZoneMaterial = galacticNist;
                                                   >> 297   
                                                   >> 298   // Material of the firt scattering foil
                                                   >> 299   firstScatteringFoilMaterial = tantalumNist;
                                                   >> 300   
                                                   >> 301   // Material of kapton window 
                                                   >> 302   kaptonWindowMaterial = kaptonNist;
                                                   >> 303   
                                                   >> 304   // Material of the stopper
                                                   >> 305   stopperMaterial = brass;
                                                   >> 306   
                                                   >> 307   // Material of the second scattering foil 
                                                   >> 308   secondScatteringFoilMaterial = tantalumNist; 
                                                   >> 309   
                                                   >> 310   // Materials of the monitor chamber
                                                   >> 311   layer1MonitorChamberMaterial = kaptonNist;
                                                   >> 312   layer2MonitorChamberMaterial = copperNistAsMaterial;
                                                   >> 313   layer3MonitorChamberMaterial = airNist;
                                                   >> 314   layer4MonitorChamberMaterial = copperNistAsMaterial;
                                                   >> 315   
                                                   >> 316   
                                                   >> 317   // material of the final nozzle
                                                   >> 318   nozzleSupportMaterial = PMMANist;
                                                   >> 319   holeNozzleSupportMaterial = brass;
                                                   >> 320   seconHoleNozzleSupportMaterial = airNist;
                                                   >> 321   
                                                   >> 322   // Material of the final collimator
                                                   >> 323   finalCollimatorMaterial = brass;
252 }                                                 324 }
253                                                   325 
254 //////////////////////////////////////////////    326 /////////////////////////////////////////////////////////////////////////////
255 void PassiveCarbonBeamLine::ConstructPassiveCa    327 void PassiveCarbonBeamLine::ConstructPassiveCarbonBeamLine()
256 {                                              << 328 { 
257     // -----------------------------           << 329   // -----------------------------
258     // Treatment room - World volume           << 330   // Treatment room - World volume
259     //------------------------------           << 331   //------------------------------
260     // Treatment room sizes                    << 332   // Treatment room sizes
261                                                << 333   const G4double worldX = 400.0 *cm;
262     const G4double worldX = 400.0 *cm;         << 334   const G4double worldY = 400.0 *cm;
263     const G4double worldY = 400.0 *cm;         << 335   const G4double worldZ = 400.0 *cm;
264     const G4double worldZ = 400.0 *cm;         << 336   G4bool isotopes = false;
265     G4bool isotopes = false;                   << 337   
266                                                << 338   G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
267     airNist =  G4NistManager::Instance()->Find << 339   G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
268     treatmentRoom = new G4Box("TreatmentRoom", << 340   G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, 
269     logicTreatmentRoom = new G4LogicalVolume(t << 341                                 airNist, 
270                                              a << 342                                 "logicTreatmentRoom", 
271                                              " << 343                                 0,0,0);
272                                              0 << 344   physicalTreatmentRoom = new G4PVPlacement(0,
273     physicalTreatmentRoom = new G4PVPlacement( << 345                         G4ThreeVector(),
274                                                << 346                         "physicalTreatmentRoom", 
275                                                << 347                         logicTreatmentRoom, 
276                                                << 348                         0,false,0);
277                                                << 349   
278                                                << 350   
279                                                << 351   // The treatment room is invisible in the Visualisation
280     // The treatment room is invisible in the  << 352   logicTreatmentRoom -> SetVisAttributes (G4VisAttributes::GetInvisible());
281     logicTreatmentRoom -> SetVisAttributes (G4 << 353   
282                                                << 354   // Components of the Passive Carbon Beam Line
283     // Components of the Passive Carbon Beam L << 355   HadrontherapyBeamLineSupport();
284     HadrontherapyBeamLineSupport();            << 356   VacuumToAirInterface();
285     VacuumToAirInterface();                    << 357   ScatteringSystem();
286     HadrontherapyBeamMonitoring();             << 358   HadrontherapyBeamMonitoring();
287     HadrontherapyBeamNozzle();                 << 359   HadrontherapyBeamNozzle();
288     HadrontherapyBeamFinalCollimator();        << 360   HadrontherapyBeamFinalCollimator();
289     HadrontherapyPMMACollimator();             << 
290    // HadrontherapyRippleFilter();             << 
291                                                << 
292                                                << 
293    // StopperCostruction();                    << 
294                                                << 
295                                                << 
296    HadrontherapyRidgeFilter();                 << 
297 }                                                 361 }
298                                                   362 
299 //////////////////////////////////////////////    363 /////////////////////////////////////////////////////////////////////////////
300 void PassiveCarbonBeamLine::HadrontherapyBeamL    364 void PassiveCarbonBeamLine::HadrontherapyBeamLineSupport()
301 {                                                 365 {
302     // ------------------//                    << 366   // ------------------//
303     // BEAM LINE SUPPORT //                    << 367   // BEAM LINE SUPPORT //
304     //-------------------//                    << 368   //-------------------//
305                                                << 369   const G4double beamLineSupportXSize = 1.5*m;
306     beamLineSupportXSize = 1.5*m;              << 370   const G4double beamLineSupportYSize = 20.*mm;
307     beamLineSupportYSize = 20.*mm;             << 371   const G4double beamLineSupportZSize = 600.*mm;
308     beamLineSupportZSize = 600.*mm;            << 372   
309                                                << 373   const G4double beamLineSupportXPosition = -1745.09 *mm;
310     beamLineSupportXPosition = -1745.09 *mm;   << 374   const G4double beamLineSupportYPosition = -230. *mm; 
311     beamLineSupportYPosition = -230. *mm;      << 375   const G4double beamLineSupportZPosition = 0.*mm;
312     beamLineSupportZPosition = 0.*mm;          << 376   
313                                                << 377   G4Box* beamLineSupport = new G4Box("BeamLineSupport", 
314     beamLineSupport = new G4Box("BeamLineSuppo << 378                      beamLineSupportXSize, 
315                                 beamLineSuppor << 379                      beamLineSupportYSize, 
316                                 beamLineSuppor << 380                      beamLineSupportZSize);
317                                 beamLineSuppor << 381   
318                                                << 382   G4LogicalVolume* logicBeamLineSupport = new G4LogicalVolume(beamLineSupport, 
319     logicBeamLineSupport = new G4LogicalVolume << 383                                 beamLineSupportMaterial, 
320                                                << 384                                 "BeamLineSupport");
321                                                << 385   physiBeamLineSupport = new G4PVPlacement(0, G4ThreeVector(beamLineSupportXPosition, 
322     physiBeamLineSupport = new G4PVPlacement(0 << 386                                 beamLineSupportYPosition,
323                                                << 387                                 beamLineSupportZPosition),
324                                                << 388                        "BeamLineSupport", 
325                                              " << 389                        logicBeamLineSupport, 
326                                              l << 390                        physicalTreatmentRoom, false, 0);
327                                              p << 391   
328                                                << 392   // Visualisation attributes of the beam line support
329     // Visualisation attributes of the beam li << 393   
330     logicBeamLineSupport -> SetVisAttributes(g << 394   logicBeamLineSupport -> SetVisAttributes(gray);
331                                                << 395   
332     //---------------------------------//      << 396   //---------------------------------//
333     //  Beam line cover 1 (left panel) //      << 397   //  Beam line cover 1 (left panel) //
334     //---------------------------------//      << 398   //---------------------------------//
335     beamLineCoverXSize = 1.5*m;                << 399   const G4double beamLineCoverXSize = 1.5*m;
336     beamLineCoverYSize = 750.*mm;              << 400   const G4double beamLineCoverYSize = 750.*mm;
337     beamLineCoverZSize = 10.*mm;               << 401   const G4double beamLineCoverZSize = 10.*mm; 
338                                                << 402   
339     beamLineCoverXPosition = -1745.09 *mm;     << 403   const G4double beamLineCoverXPosition = -1745.09 *mm;
340     beamLineCoverYPosition = -1000.*mm;        << 404   const G4double beamLineCoverYPosition = -1000.*mm; 
341     beamLineCoverZPosition = 610.*mm;          << 405   const G4double beamLineCoverZPosition = 610.*mm;
342                                                << 406   
343     beamLineCover = new G4Box("BeamLineCover", << 407   G4Box* beamLineCover = new G4Box("BeamLineCover",
344                               beamLineCoverXSi << 408                    beamLineCoverXSize, 
345                               beamLineCoverYSi << 409                    beamLineCoverYSize, 
346                               beamLineCoverZSi << 410                    beamLineCoverZSize);
347                                                << 411   
348     logicBeamLineCover = new G4LogicalVolume(b << 412   G4LogicalVolume* logicBeamLineCover = new G4LogicalVolume(beamLineCover,
349                                              b << 413                                 beamLineSupportMaterial, 
350                                              " << 414                                 "BeamLineCover");
351                                                << 415   
352     physiBeamLineCover = new G4PVPlacement(0,  << 416   physiBeamLineCover = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
353                                                << 417                               beamLineCoverYPosition,
354                                                << 418                               beamLineCoverZPosition),
355                                            "Be << 419                        "BeamLineCover", 
356                                            log << 420                        logicBeamLineCover, 
357                                            phy << 421                        physicalTreatmentRoom,
358                                            fal << 422                        false, 
359                                            0); << 423                        0);
360                                                << 424   
361     // ---------------------------------//     << 425   // ---------------------------------//
362     //  Beam line cover 2 (rigth panel) //     << 426   //  Beam line cover 2 (rigth panel) //
363     // ---------------------------------//     << 427   // ---------------------------------//
364     // It has the same characteristic of beam  << 428   // It has the same characteristic of beam line cover 1 but set in a different position
365     physiBeamLineCover2 = new G4PVPlacement(0, << 429   physiBeamLineCover2 = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
366                                                << 430                                beamLineCoverYPosition,
367                                                << 431                                - beamLineCoverZPosition),
368                                             "B << 432                       "BeamLineCover2", 
369                                             lo << 433                       logicBeamLineCover, 
370                                             ph << 434                       physicalTreatmentRoom, 
371                                             fa << 435                       false, 
372                                             0) << 436                       0);
373                                                << 437   
374                                                << 438   
375     logicBeamLineCover -> SetVisAttributes(blu << 439   logicBeamLineCover -> SetVisAttributes(blue);
376 }                                                 440 }
377                                                   441 
378 //////////////////////////////////////////////    442 /////////////////////////////////////////////////////////////////////////////
379 void PassiveCarbonBeamLine::VacuumToAirInterfa    443 void PassiveCarbonBeamLine::VacuumToAirInterface()
380 {                                                 444 {
381     // ------------//                          << 445   // ------------//
382     // VACUUM PIPE //                          << 446   // VACUUM PIPE //
383     //-------------//                          << 447   //-------------//
384     //                                         << 448   //
385     // First track of the beam line is inside  << 449   // First track of the beam line is inside vacuum;
386                                                << 450   // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
387     vacuumZoneXSize = 100 *mm;                 << 451   G4Box* vacuumZone = new G4Box("VacuumZone", 
388     vacuumZoneYSize = 52.5 *mm;                << 452                   vacuumZoneXSize, 
389     vacuumZoneZSize = 52.5 *mm;                << 453                   vacuumZoneYSize, 
390     vacuumPipeXPosition = -1708.0 *mm;         << 454                   vacuumZoneZSize);
391                                                << 455   
392                                                << 456   G4LogicalVolume* logicVacuumZone = new G4LogicalVolume(vacuumZone, 
393     vacuumZone = new G4Box("VacuumZone",       << 457                                vacuumZoneMaterial, 
394                            vacuumZoneXSize/2,  << 458                                "VacuumZone");
395                            vacuumZoneYSize/2,  << 459   
396                            vacuumZoneZSize/2); << 460   G4VPhysicalVolume* physiVacuumZone = new G4PVPlacement(0, 
397                                                << 461                                G4ThreeVector(vacuumZoneXPosition, 0., 0.),
398     logicVacuumZone = new G4LogicalVolume(vacu << 462                                "VacuumZone",
399                                                << 463                                logicVacuumZone, 
400     physiVacuumZone = new G4PVPlacement(0, G4T << 464                                physicalTreatmentRoom, 
401                                         "Vacuu << 465                                false, 
402                                         logicV << 466                                0);
403                                         physic << 467   
404                                         false, << 468   
405                                         0);    << 469   
406                                                << 470   
407     // --------------------------//            << 471   
408     // THE FIRST SCATTERING FOIL //            << 472   // --------------------------//
409     // --------------------------//            << 473   // THE FIRST SCATTERING FOIL //
410     // A thin foil performing a first scatteri << 474   // --------------------------//
411     // of the original beam                    << 475   // A thin foil performing a first scattering
412                                                << 476   // of the original beam
413     firstScatteringFoilXSize = 0.015 *mm;      << 477   
414     firstScatteringFoilYSize = 52.5 *mm;       << 478   firstScatteringFoil = new G4Box("FirstScatteringFoil", 
415     firstScatteringFoilZSize = 52.5 *mm;       << 479                   firstScatteringFoilXSize/2, 
416     firstScatteringFoilXPosition = 0.0 *mm;    << 480                   firstScatteringFoilYSize/2, 
417                                                << 481                   firstScatteringFoilZSize/2);
418     firstScatteringFoil = new G4Box("FirstScat << 482   
419                                     firstScatt << 483   G4LogicalVolume* logicFirstScatteringFoil = new G4LogicalVolume(firstScatteringFoil,
420                                     firstScatt << 484                                   firstScatteringFoilMaterial,
421                                     firstScatt << 485                                   "FirstScatteringFoil");
422                                                << 486   
423     logicFirstScatteringFoil = new G4LogicalVo << 487   physiFirstScatteringFoil = new G4PVPlacement(0, 
424                                                << 488                          G4ThreeVector(firstScatteringFoilXPosition, 0.,0.),
425                                                << 489                          "FirstScatteringFoil", 
426                                                << 490                          logicFirstScatteringFoil, 
427     physiFirstScatteringFoil = new G4PVPlaceme << 491                          physiVacuumZone, 
428                                                << 492                          false, 0); 
429                                                << 493   
430                                                << 494   logicFirstScatteringFoil -> SetVisAttributes(skyBlue);
431     logicFirstScatteringFoil -> SetVisAttribut << 495   
432                                                << 496   
433     // -------------------//                   << 497   
434     // THE KAPTON WINDOWS //                   << 498   // -------------------//
435     //--------------------//                   << 499   // THE KAPTON WINDOWS //
436     //It permits the passage of the beam from  << 500   //--------------------//
437                                                << 501   //It permits the passage of the beam from vacuum to air
438     // KAPTON WINDOW: it permits the passage o << 502   
439     kaptonWindowXSize = 0.050 *mm;             << 503   G4Box* solidKaptonWindow = new G4Box("KaptonWindow", 
440     kaptonWindowYSize = 52.5 *mm;              << 504                      kaptonWindowXSize,
441     kaptonWindowZSize = 52.5 *mm;              << 505                      kaptonWindowYSize,
442     kaptonWindowXPosition = vacuumZoneXSize/2  << 506                      kaptonWindowZSize);
443                                                << 507   
444     solidKaptonWindow = new G4Box("KaptonWindo << 508   G4LogicalVolume* logicKaptonWindow = new G4LogicalVolume(solidKaptonWindow, 
445                                   kaptonWindow << 509                                kaptonWindowMaterial,
446                                   kaptonWindow << 510                                "KaptonWindow");
447                                   kaptonWindow << 511   
448                                                << 512   physiKaptonWindow = new G4PVPlacement(0, G4ThreeVector(kaptonWindowXPosition, 0., 0.), 
449     logicKaptonWindow = new G4LogicalVolume(so << 513                       "KaptonWindow", logicKaptonWindow,
450                                             ka << 514                       physiVacuumZone, false, 0); 
451                                             "K << 515   
452                                                << 516   logicKaptonWindow -> SetVisAttributes(darkOrange3);
453     physiKaptonWindow = new G4PVPlacement(0, G << 517 }
454                                           "Kap << 518 
455                                           phys << 519 /////////////////////////////////////////////////////////////////////////////  
456                                                << 520 void PassiveCarbonBeamLine::ScatteringSystem()
457     logicKaptonWindow -> SetVisAttributes(dark << 521 {
458 }                                              << 522   // ------------//
459 ////////////////////////////////////////////// << 523   // THE STOPPER //
460 void PassiveCarbonBeamLine::HadrontherapyRippl << 524   //-------------//
461 {                                              << 525   // Is a small cylinder able to stop the central component
462                                                << 526   // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
463     G4double defaultRippleFilterXPosition = -1 << 527   // and represent the second element of the scattering system
464     G4double ripple_position=(defaultRippleFil << 528   
465     G4double RF_x = 200.0 * mm;                << 529   G4double phi = 90. *deg;
466     G4double RF_y = 200.0 * mm;                << 530     // Matrix definition for a 90 deg rotation with respect to Y axis
467     G4double RF_z = 1.4 * mm;                  << 531   G4RotationMatrix rm;
468     G4double RFbase_z = 0.2 * mm;              << 532   rm.rotateY(phi);
469     G4double RFtrd_z = RF_z - RFbase_z;        << 533   
470     G4double RFtrd_top = 1e-4 * mm;            << 534   solidStopper = new G4Tubs("Stopper", 
471     G4double RFtrd_bottom = 1.5 * mm;          << 535                 innerRadiusStopper, 
472     G4double distanceBetweenTrd = 0.1*mm;      << 536                 outerRadiusStopper,
473                                                << 537                 heightStopper/2, 
474                                                << 538                 startAngleStopper,
475                                                << 539                 spanningAngleStopper);
476                                                << 540   
477     G4double theta = -90. *deg;                << 541   logicStopper = new G4LogicalVolume(solidStopper, 
478     // Matrix definition for a "theta" deg rot << 542                      stopperMaterial, 
479     G4RotationMatrix rot;                      << 543                      "Stopper", 
480     rot.rotateY(theta);                        << 544                      0, 0, 0);
481                                                << 545   
482                                                << 546   physiStopper = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(stopperXPosition, 
483     SolidRippleFilter= new G4Box("RippleFilter << 547                                    stopperYPosition, 
484                                  RF_x/2 + 1*mm << 548                                    stopperZPosition)),
485                                  RF_y/2 + 1*mm << 549                    "Stopper", 
486                                  RF_z/2 + 1*mm << 550                    logicStopper, 
487                                                << 551                    physicalTreatmentRoom, 
488     LogicRippleFilter = new G4LogicalVolume(So << 552                    false, 
489                                             ri << 553                    0);
490                                             "L << 554   
491                                             0, << 555   logicStopper -> SetVisAttributes(red);
492                                                << 556   
493     PhysiRippleFilter = new G4PVPlacement(G4Tr << 557   // ---------------------------//
494                                           "Phy << 558   // THE SECOND SCATTERING FOIL //
495                                           Logi << 559   // ---------------------------//
496                                           phys << 560   // It is another thin foil and provides the
497                                           fals << 561   // final diffusion of the beam. It represents the third element of the scattering
498                                           1,   << 562   // system;
499                                           true << 563   
500                                                << 564   secondScatteringFoil = new G4Box("SecondScatteringFoil", 
501     PhysiRippleFilter = new G4PVPlacement(G4Tr << 565                    secondScatteringFoilXSize/2, 
502                                           "Phy << 566                    secondScatteringFoilYSize/2,
503                                           Logi << 567                    secondScatteringFoilZSize/2);
504                                           phys << 568   
505                                           fals << 569   G4LogicalVolume* logicSecondScatteringFoil = new G4LogicalVolume(secondScatteringFoil, 
506                                           2,   << 570                                    secondScatteringFoilMaterial,
507                                           true << 571                                    "SecondScatteringFoil");
508                                                << 572   
509     LogicRippleFilter -> SetVisAttributes(G4Vi << 573   physiSecondScatteringFoil = new G4PVPlacement(0, G4ThreeVector(secondScatteringFoilXPosition,
510                                                << 574                                    secondScatteringFoilYPosition,
511     SolidRippleFilterBase = new G4Box("RippleF << 575                                    secondScatteringFoilZPosition),
512                                       RF_x/2,  << 576                           "SeconScatteringFoil", 
513                                       RF_y/2,  << 577                           logicSecondScatteringFoil, 
514                                       RFbase_z << 578                           physicalTreatmentRoom, 
515                                                << 579                           false, 
516     LogicRippleFilterBase = new G4LogicalVolum << 580                           0);
517                                                << 581   
518                                                << 582   logicSecondScatteringFoil -> SetVisAttributes(skyBlue);
519                                                << 583   
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 }                                                 584 }
593                                                   585 
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 //////////////////////////////////////////////    586 /////////////////////////////////////////////////////////////////////////////
846 void PassiveCarbonBeamLine::HadrontherapyBeamM    587 void PassiveCarbonBeamLine::HadrontherapyBeamMonitoring()
847 {                                                 588 {
848     // ----------------------------            << 589   // ----------------------------
849     //       MONITOR CHAMBER                   << 590   //   THE FIRST MONITOR CHAMBER
850     // ----------------------------            << 591   // ----------------------------  
851     // A monitor chamber is a free-air  ionisa << 592   // A monitor chamber is a free-air  ionisation chamber
852     // able to measure do carbon fluence durin << 593   // able to measure do carbon fluence during the treatment.
853     // Here its responce is not simulated in t << 594   // Here its responce is not simulated in terms of produced 
854     // charge but only the energy losses are t << 595   // charge but only the energy losses are taked into account.
855     // Each chamber consist of 9 mm of air in  << 596   // Each chamber consist of 9 mm of air in a box
856     // that has two layers one of kapton and o << 597   // that has two layers one of kapton and one
857     // of copper                               << 598   // of copper
858                                                << 599   const G4double monitor1XSize = 4.525022*mm;
859     monitor1XSize = 4.525022*mm;               << 600   const G4double monitor2XSize = 0.000011*mm;
860     monitor2XSize = 0.000011*mm;               << 601   const G4double monitor3XSize = 4.5*mm;
861     monitor3XSize = 4.5*mm;                    << 602   const G4double monitorYSize = 10.*cm; 
862     monitorYSize = 10.*cm;                     << 603   const G4double monitorZSize = 10.*cm;
863     monitorZSize = 10.*cm;                     << 604     // XXX (Camera monitor size = 9.050088 mm)
864     monitor1XPosition = -1239.974978 *mm;      << 605   const G4double monitor1XPosition = -1450.474956 *mm;
865     monitor2XPosition = -4.500011*mm;          << 606   const G4double monitor2XPosition = -4.500011*mm;
866     monitor4XPosition = 4.500011*mm;           << 607   const G4double monitor4XPosition = 4.500011*mm;
867                                                << 608   
868     solidFirstMonitorLayer1 = new G4Box("First << 609   G4Box* solidFirstMonitorLayer1 = new G4Box("FirstMonitorLayer1", 
869                                         monito << 610                          monitor1XSize, 
870                                         monito << 611                          monitorYSize, 
871                                         monito << 612                          monitorZSize);
872                                                << 613   
873     logicFirstMonitorLayer1 = new G4LogicalVol << 614   G4LogicalVolume* logicFirstMonitorLayer1 = new G4LogicalVolume(solidFirstMonitorLayer1, 
874                                                << 615                                    layer1MonitorChamberMaterial,
875                                                << 616                                    "FirstMonitorLayer1");
876                                                << 617   
877     physiFirstMonitorLayer1 = new G4PVPlacemen << 618   physiFirstMonitorLayer1 = new G4PVPlacement(0,
878                                                << 619                         G4ThreeVector(monitor1XPosition,0.*cm,0.*cm),
879                                                << 620                         "FirstMonitorLayer1", 
880                                                << 621                         logicFirstMonitorLayer1, 
881                                                << 622                         physicalTreatmentRoom, 
882                                                << 623                         false, 
883                                                << 624                         0);
884                                                << 625   
885     solidFirstMonitorLayer2 = new G4Box("First << 626   G4Box* solidFirstMonitorLayer2 = new G4Box("FirstMonitorLayer2", 
886                                         monito << 627                          monitor2XSize, 
887                                         monito << 628                          monitorYSize, 
888                                         monito << 629                          monitorZSize);
889                                                << 630   
890     logicFirstMonitorLayer2 = new G4LogicalVol << 631   G4LogicalVolume* logicFirstMonitorLayer2 = new G4LogicalVolume(solidFirstMonitorLayer2,
891                                                << 632                                    layer2MonitorChamberMaterial,
892                                                << 633                                    "FirstMonitorLayer2");
893                                                << 634   
894     physiFirstMonitorLayer2 = new G4PVPlacemen << 635   physiFirstMonitorLayer2 = new G4PVPlacement(0, G4ThreeVector(monitor2XPosition,0.*cm,0.*cm),
895                                                << 636                         "FirstMonitorLayer2", 
896                                                << 637                         logicFirstMonitorLayer2, 
897                                                << 638                         physiFirstMonitorLayer1,
898                                                << 639                         false, 
899                                                << 640                         0);
900                                                << 641   
901     solidFirstMonitorLayer3 = new G4Box("First << 642   G4Box* solidFirstMonitorLayer3 = new G4Box("FirstMonitorLayer3", 
902                                         monito << 643                          monitor3XSize, 
903                                         monito << 644                          monitorYSize, 
904                                         monito << 645                          monitorZSize);
905                                                << 646   
906     logicFirstMonitorLayer3 = new G4LogicalVol << 647   G4LogicalVolume* logicFirstMonitorLayer3 = new G4LogicalVolume(solidFirstMonitorLayer3, 
907                                                << 648                                    layer3MonitorChamberMaterial, 
908                                                << 649                                    "FirstMonitorLayer3");
909                                                << 650   
910     physiFirstMonitorLayer3 = new G4PVPlacemen << 651   physiFirstMonitorLayer3 = new G4PVPlacement(0, 
911                                                << 652                         G4ThreeVector(0.*mm,0.*cm,0.*cm), 
912                                                << 653                         "MonitorLayer3",
913                                                << 654                         logicFirstMonitorLayer3, 
914                                                << 655                         physiFirstMonitorLayer1, 
915                                                << 656                         false, 
916                                                << 657                         0);
917                                                << 658     
918     solidFirstMonitorLayer4 = new G4Box("First << 659   G4Box* solidFirstMonitorLayer4 = new G4Box("FirstMonitorLayer4", 
919                                         monito << 660                          monitor2XSize, 
920                                         monito << 661                          monitorYSize, 
921                                         monito << 662                          monitorZSize);
922                                                << 663   
923     logicFirstMonitorLayer4 = new G4LogicalVol << 664   G4LogicalVolume* logicFirstMonitorLayer4 = new G4LogicalVolume(solidFirstMonitorLayer4, 
924                                                << 665                                    layer4MonitorChamberMaterial, 
925                                                << 666                                    "FirstMonitorLayer4");
926                                                << 667   
927     physiFirstMonitorLayer4 = new G4PVPlacemen << 668   physiFirstMonitorLayer4 = new G4PVPlacement(0, G4ThreeVector(monitor4XPosition,0.*cm,0.*cm), 
928                                                << 669                         "FirstMonitorLayer4",
929                                                << 670                         logicFirstMonitorLayer4,
930                                                << 671                         physiFirstMonitorLayer1, false, 0);
931                                                << 672   
932     logicFirstMonitorLayer3 -> SetVisAttribute << 673   logicFirstMonitorLayer3 -> SetVisAttributes(white);
933                                                << 674   
934 }                                                 675 }
935                                                   676 
936 //////////////////////////////////////////////    677 /////////////////////////////////////////////////////////////////////////////
937 //////////////////////////////////////////////    678 /////////////////////////////////////////////////////////////////////////////
938 void PassiveCarbonBeamLine::HadrontherapyBeamN    679 void PassiveCarbonBeamLine::HadrontherapyBeamNozzle()
939 {                                                 680 {
940     // ------------------------------//        << 681   // ------------------------------//
941     // THE FINAL TUBE AND COLLIMATOR //        << 682   // THE FINAL TUBE AND COLLIMATOR //
942     //-------------------------------//        << 683   //-------------------------------//
943     // The last part of the transport beam lin << 684   // The last part of the transport beam line consists of
944     // a 59 mm thick PMMA slab (to stop all th << 685   // 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 << 686   // (to well collimate the carbon beam) and a final collimator with 25 mm diameter
946     // aperture (that provide the final trasve << 687   // aperture (that provide the final trasversal shape of the beam)
947                                                << 688   
948     // -------------------//                   << 689   // -------------------//
949     //     PMMA SUPPORT   //                   << 690   //     PMMA SUPPORT   //
950     // -------------------//                   << 691   // -------------------//
951                                                << 692 
952     nozzleSupportXSize = 50 *mm;               << 693   const G4double nozzleSupportXSize = 29.5 *mm;
953     nozzleSupportYSize = 360. *mm;             << 694   const G4double nozzleSupportYSize = 180. *mm;
954     nozzleSupportZSize = 360. *mm;             << 695   const G4double nozzleSupportZSize = 180. *mm;
955     nozzleSupportXPosition = -423.0 *mm;       << 696   //XXX Placed at 
956                                                << 697   const G4double nozzleSupportXPosition = -558. *mm;
957     G4double phi = 90. *deg;                   << 698   
958     // Matrix definition for a 90 deg rotation << 699   G4double phi = 90. *deg;     
959     G4RotationMatrix rm;                       << 700   // Matrix definition for a 90 deg rotation. Also used for other volumes       
960     rm.rotateY(phi);                           << 701   G4RotationMatrix rm;               
961                                                << 702   rm.rotateY(phi);
962     solidNozzleSupport = new G4Box("NozzleSupp << 703   
963                                    nozzleSuppo << 704   G4Box* solidNozzleSupport = new G4Box("NozzleSupport", 
964                                    nozzleSuppo << 705                       nozzleSupportXSize, 
965                                    nozzleSuppo << 706                       nozzleSupportYSize, 
966                                                << 707                       nozzleSupportZSize);
967     logicNozzleSupport = new G4LogicalVolume(s << 708   
968                                              n << 709   G4LogicalVolume* logicNozzleSupport = new G4LogicalVolume(solidNozzleSupport, 
969                                              " << 710                                 nozzleSupportMaterial, 
970                                                << 711                                 "NozzleSupport");
971     physiNozzleSupport = new G4PVPlacement(0,  << 712   
972                                            "No << 713   physiNozzleSupport = new G4PVPlacement(0, G4ThreeVector(nozzleSupportXPosition,0., 0.),
973                                            log << 714                        "NozzleSupport", 
974                                            phy << 715                        logicNozzleSupport, 
975                                            fal << 716                        physicalTreatmentRoom, 
976                                            0); << 717                        false, 
977                                                << 718                        0);
978     yellow = new G4VisAttributes(G4Colour(1.,  << 719   
979     yellow-> SetVisibility(true);              << 720   logicNozzleSupport -> SetVisAttributes(yellow);
980     yellow-> SetForceWireframe(true);          << 721   // -------------------//
981                                                << 722   //     BRASS TUBE     //
982     //------------------------------------//   << 723   // -------------------//
983     // HOLE IN THE SUPPORT                //   << 724   const G4double innerRadiusHoleNozzleSupport = 18.*mm;
984     //------------------------------------//   << 725   const G4double outerRadiusHoleNozzleSupport = 21.5 *mm;
985     innerRadiusHoleNozzleSupport = 0.*mm;      << 726   //XXX h/2 = 142.5 mm
986     outerRadiusHoleNozzleSupport = 22.0*mm;    << 727   const G4double hightHoleNozzleSupportFirst = nozzleSupportXSize;
987     hightHoleNozzleSupport = nozzleSupportXSiz << 728   const G4double hightHoleNozzleSupport = 113.0*mm;
988     startAngleHoleNozzleSupport = 0.*deg;      << 729   const G4double startAngleHoleNozzleSupport = 0.*deg;
989     spanningAngleHoleNozzleSupport = 360.*deg; << 730   const G4double spanningAngleHoleNozzleSupport = 360.*deg;
990                                                << 731   const G4double holeNozzleSupportXPosition = -415.5 *mm;
991     solidHoleNozzleSupport = new G4Tubs("HoleN << 732   G4Tubs* solidNozzleSupportHole = new G4Tubs("NozzleSupportHole1",   innerRadiusHoleNozzleSupport, 
992                                         innerR << 733                         outerRadiusHoleNozzleSupport,
993                                         outerR << 734                         hightHoleNozzleSupportFirst, 
994                                         hightH << 735                         startAngleHoleNozzleSupport, 
995                                         startA << 736                         spanningAngleHoleNozzleSupport);
996                                         spanni << 737   
997                                                << 738   G4LogicalVolume* logicNozzleSupportHole = new G4LogicalVolume(solidNozzleSupportHole, 
998     logicHoleNozzleSupport = new G4LogicalVolu << 739                                 holeNozzleSupportMaterial, 
999                                                << 740                                 "NozzleSupportHole1");
1000                                               << 741   
1001                                               << 742   physiNozzleSupportHole = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(0, 0., 0.)),
1002                                               << 743                          "HoleNozzleSupportHole1", 
1003                                               << 744                          logicNozzleSupportHole, 
1004                                               << 745                          physiNozzleSupport, false, 0);
1005     physiHoleNozzleSupport = new G4PVPlacemen << 746     
1006                                               << 747   G4Tubs* solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport", 
1007                                               << 748                         innerRadiusHoleNozzleSupport, 
1008                                               << 749                         outerRadiusHoleNozzleSupport,
1009                                               << 750                         hightHoleNozzleSupport, 
1010                                               << 751                         startAngleHoleNozzleSupport, 
1011                                               << 752                         spanningAngleHoleNozzleSupport);
1012     // -------------------------------------- << 753   
1013     //     BRASS TUBE 3 (beam line side)    / << 754   G4LogicalVolume* logicHoleNozzleSupport = new G4LogicalVolume(solidHoleNozzleSupport, 
1014     // -------------------------------------/ << 755                                   holeNozzleSupportMaterial, 
1015     innerRadiusBrassTube3 = 13.5 *mm;         << 756                                   "HoleNozzleSupport", 
1016     outerRadiusBrassTube3 = 21.5 *mm;         << 757                                   0, 0, 0);
1017     hightBrassTube3 = 20.0 *mm;               << 758   
1018     startAngleBrassTube3 = 0.*deg;            << 759   physiHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(holeNozzleSupportXPosition, 0., 0.)),
1019     spanningAngleBrassTube3 = 360.*deg;       << 760                          "HoleNozzleSupport", 
1020     brassTube3XPosition = -458.0 *mm;         << 761                          logicHoleNozzleSupport, 
1021                                               << 762                          physicalTreatmentRoom, false, 0); 
1022     solidBrassTube3 = new G4Tubs("BrassTube3" << 763   logicNozzleSupportHole -> SetVisAttributes(darkOrange3);    
1023                                  innerRadiusB << 764   logicHoleNozzleSupport -> SetVisAttributes(darkOrange3);
1024                                  outerRadiusB << 765   
1025                                  hightBrassTu << 766   //--------------------------------------------------------------//
1026                                  startAngleBr << 767   // HOLE OF THE BRASS TUBE (otherwise we'll have PMMA)           //
1027                                  spanningAngl << 768   //--------------------------------------------------------------//
1028                                               << 769   const G4double innerRadiusSecondHoleNozzleSupport = 0.*mm;
1029     logicBrassTube3 = new G4LogicalVolume(sol << 770   const G4double outerRadiusSecondHoleNozzleSupport = 18.*mm;
1030                                           bra << 771   const G4double hightSecondHoleNozzleSupport = 29.5 *mm;
1031                                           "Br << 772   const G4double startAngleSecondHoleNozzleSupport = 0.*deg;
1032                                           0,  << 773   const G4double spanningAngleSecondHoleNozzleSupport = 360.*deg;
1033                                               << 774   
1034     physiBrassTube3 = new G4PVPlacement(G4Tra << 775   G4Tubs* solidSecondHoleNozzleSupport = new G4Tubs("SecondHoleNozzleSupport",
1035                                               << 776                             innerRadiusSecondHoleNozzleSupport,
1036                                               << 777                             outerRadiusSecondHoleNozzleSupport, 
1037                                               << 778                             hightSecondHoleNozzleSupport,
1038                                         "Bras << 779                             startAngleSecondHoleNozzleSupport, 
1039                                         logic << 780                             spanningAngleSecondHoleNozzleSupport);
1040                                         physi << 781   
1041                                         false << 782   G4LogicalVolume* logicSecondHoleNozzleSupport = new G4LogicalVolume(solidSecondHoleNozzleSupport, 
1042                                         0);   << 783                                     seconHoleNozzleSupportMaterial,
1043                                               << 784                                     "SecondHoleNozzleSupport",
1044     logicBrassTube3 -> SetVisAttributes(darkO << 785                                     0, 
1045                                               << 786                                     0,
1046     // -------------------------------------- << 787                                     0);
1047     //     BRASS TUBE 2 (inside the PMMA supp << 788   
1048     // -------------------------------------- << 789   physiSecondHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()), 
1049                                               << 790                            "SecondHoleNozzleSupport",
1050     innerRadiusBrassTube2 = 13.5 *mm;         << 791                            logicSecondHoleNozzleSupport, 
1051     outerRadiusBrassTube2 = 21.5 *mm;         << 792                            physiNozzleSupport, 
1052     hightBrassTube2 = nozzleSupportXSize;     << 793                            false, 0); 
1053     startAngleBrassTube2 = 0.*deg;            << 794   
1054     spanningAngleBrassTube2 = 360.*deg;       << 795   
1055                                               << 796   logicHoleNozzleSupport -> SetVisAttributes(darkOrange3); 
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 }                                                797 }
1111                                                  798 
1112 /////////////////////////////////////////////    799 /////////////////////////////////////////////////////////////////////////////
1113 void PassiveCarbonBeamLine::HadrontherapyBeam    800 void PassiveCarbonBeamLine::HadrontherapyBeamFinalCollimator()
1114 {                                                801 {
1115     // -----------------------//              << 802   // -----------------------//
1116     //     FINAL COLLIMATOR   //              << 803   //     FINAL COLLIMATOR   //
1117     //------------------------//              << 804   //------------------------//
1118     outerRadiusFinalCollimator = 21.5*mm;     << 805   const G4double outerRadiusFinalCollimator = 21.5*mm;
1119     hightFinalCollimator = 7.0 *mm;           << 806   const G4double hightFinalCollimator = 3.5*mm;
1120     startAngleFinalCollimator = 0.*deg;       << 807   const G4double startAngleFinalCollimator = 0.*deg;
1121     spanningAngleFinalCollimator = 360.*deg;  << 808   const G4double spanningAngleFinalCollimator = 360.*deg;
1122     finalCollimatorXPosition = -186.5 *mm;    << 809   //XXX
1123                                               << 810   const G4double finalCollimatorXPosition = -299.0 *mm;  
1124     G4double phi = 90. *deg;                  << 811   
1125                                               << 812   G4double phi = 90. *deg;     
1126     // Matrix definition for a 90 deg rotatio << 813   
1127     G4RotationMatrix rm;                      << 814   // Matrix definition for a 90 deg rotation. Also used for other volumes       
1128     rm.rotateY(phi);                          << 815   G4RotationMatrix rm;
1129                                               << 816   rm.rotateY(phi);
1130     solidFinalCollimator = new G4Tubs("FinalC << 817   
1131                                       innerRa << 818   solidFinalCollimator = new G4Tubs("FinalCollimator", 
1132                                       outerRa << 819                     innerRadiusFinalCollimator, 
1133                                       hightFi << 820                     outerRadiusFinalCollimator,
1134                                       startAn << 821                     hightFinalCollimator, 
1135                                       spannin << 822                     startAngleFinalCollimator, 
1136                                               << 823                     spanningAngleFinalCollimator);
1137     logicFinalCollimator = new G4LogicalVolum << 824   
1138                                               << 825   G4LogicalVolume* logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator, 
1139                                               << 826                                 finalCollimatorMaterial, 
1140                                               << 827                                 "FinalCollimator", 
1141                                               << 828                                 0,
1142                                               << 829                                 0, 
1143                                               << 830                                 0);
1144     physiFinalCollimator = new G4PVPlacement( << 831   
1145                                               << 832   physiFinalCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(finalCollimatorXPosition,0.,0.)),
1146                                               << 833                        "FinalCollimator", logicFinalCollimator, physicalTreatmentRoom, false, 0); 
1147                                               << 834   
1148                                               << 835   logicFinalCollimator -> SetVisAttributes(yellow); 
1149                                               << 
1150                                               << 
1151                                               << 
1152     logicFinalCollimator -> SetVisAttributes( << 
1153 }                                                836 }
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 }                                             << 
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                                                  837 
1202                                                  838