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


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