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 9.6.p1)


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