Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/gammaknife/src/GammaKnifeDetectorConstruction.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/gammaknife/src/GammaKnifeDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/gammaknife/src/GammaKnifeDetectorConstruction.cc (Version 10.2.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26                                                    26 
 27 #include "G4SDManager.hh"                          27 #include "G4SDManager.hh"
 28 #include "G4RunManager.hh"                         28 #include "G4RunManager.hh"
 29 #include "G4Box.hh"                                29 #include "G4Box.hh"
 30 #include "G4Tubs.hh"                               30 #include "G4Tubs.hh"
 31 #include "G4Cons.hh"                               31 #include "G4Cons.hh"
 32 #include "G4Orb.hh"                                32 #include "G4Orb.hh"
 33 #include "G4LogicalVolume.hh"                      33 #include "G4LogicalVolume.hh"
 34 #include "G4ThreeVector.hh"                        34 #include "G4ThreeVector.hh"
 35 #include "G4PVPlacement.hh"                        35 #include "G4PVPlacement.hh"
 36 #include "globals.hh"                              36 #include "globals.hh"
 37 #include "G4RotationMatrix.hh"                     37 #include "G4RotationMatrix.hh"
 38 #include "G4Colour.hh"                             38 #include "G4Colour.hh"
 39 #include "G4UserLimits.hh"                         39 #include "G4UserLimits.hh"
 40 #include "G4VisAttributes.hh"                      40 #include "G4VisAttributes.hh"
 41 #include "G4NistManager.hh"                        41 #include "G4NistManager.hh"
 42                                                    42 
 43 #include "GammaKnifeDetectorMessenger.hh"          43 #include "GammaKnifeDetectorMessenger.hh"
 44 #include "GammaKnifeDetectorConstruction.hh"       44 #include "GammaKnifeDetectorConstruction.hh"
 45                                                    45 
 46 #include "G4SystemOfUnits.hh"                      46 #include "G4SystemOfUnits.hh"
 47                                                    47 
 48 GammaKnifeDetectorConstruction::GammaKnifeDete     48 GammaKnifeDetectorConstruction::GammaKnifeDetectorConstruction()
 49   : physicalTreatmentRoom(0),                      49   : physicalTreatmentRoom(0),
 50     patientPhysicalVolume(0),                      50     patientPhysicalVolume(0), 
 51     patientLogicalVolume(0),                       51     patientLogicalVolume(0),
 52     solidColl_helmet(0),                           52     solidColl_helmet(0),
 53     helmetSize(4)                                  53     helmetSize(4)
 54 {                                                  54 {
 55   // Messenger to change parameters of the geo     55   // Messenger to change parameters of the geometry
 56   detectorMessenger = new GammaKnifeDetectorMe     56   detectorMessenger = new GammaKnifeDetectorMessenger(this);
 57 }                                                  57 }
 58                                                    58 
 59 GammaKnifeDetectorConstruction::~GammaKnifeDet     59 GammaKnifeDetectorConstruction::~GammaKnifeDetectorConstruction()
 60 {                                                  60 {
 61   delete detectorMessenger;                        61   delete detectorMessenger;
 62 }                                                  62 }
 63                                                    63 
 64 G4VPhysicalVolume* GammaKnifeDetectorConstruct     64 G4VPhysicalVolume* GammaKnifeDetectorConstruction::Construct()
 65 {                                                  65 {
 66   // Define the geometry components                66   // Define the geometry components
 67   ConstructBeamLine();                             67   ConstructBeamLine();
 68                                                    68  
 69   return physicalTreatmentRoom;                    69   return physicalTreatmentRoom;
 70 }                                                  70 }
 71                                                    71 
 72 void GammaKnifeDetectorConstruction::Construct     72 void GammaKnifeDetectorConstruction::ConstructBeamLine()
 73 {                                                  73 {
 74     // NIST Materials                              74     // NIST Materials
 75     G4Material* air = G4NistManager::Instance(     75     G4Material* air = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
 76     G4Material* water = G4NistManager::Instanc     76     G4Material* water = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
 77     G4Material* cobalt = G4NistManager::Instan     77     G4Material* cobalt = G4NistManager::Instance()->FindOrBuildMaterial("G4_Co");
 78     G4Material* Pb = G4NistManager::Instance()     78     G4Material* Pb = G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb");
 79     G4Material* tungsten = G4NistManager::Inst     79     G4Material* tungsten = G4NistManager::Instance()->FindOrBuildMaterial("G4_W");
 80     G4Material* Al = G4NistManager::Instance()     80     G4Material* Al = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
 81     G4Material* Fe = G4NistManager::Instance()     81     G4Material* Fe = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe");
 82                                                    82 
 83     // Steel as non-NIST material                  83     // Steel as non-NIST material
 84     G4Element* elFe = G4NistManager::Instance(     84     G4Element* elFe = G4NistManager::Instance()->FindOrBuildElement("Fe");
 85     G4Element* elNi = G4NistManager::Instance(     85     G4Element* elNi = G4NistManager::Instance()->FindOrBuildElement("Ni");
 86     G4Element* elCr = G4NistManager::Instance(     86     G4Element* elCr = G4NistManager::Instance()->FindOrBuildElement("Cr");
 87     G4Material* steel = new G4Material("Stainl     87     G4Material* steel = new G4Material("StainlessSteel", 7.80 * g/cm3, 3 /* components */);
 88     steel -> AddElement(elFe, 70 * perCent);       88     steel -> AddElement(elFe, 70 * perCent);
 89     steel -> AddElement(elCr, 18 * perCent);       89     steel -> AddElement(elCr, 18 * perCent);
 90     steel -> AddElement(elNi, 12 * perCent);       90     steel -> AddElement(elNi, 12 * perCent);
 91                                                    91 
 92   // -----------------------------                 92   // -----------------------------
 93   // Treatment room - World volume                 93   // Treatment room - World volume
 94   // -----------------------------                 94   // -----------------------------
 95                                                    95 
 96   // Treatment room sizes                          96   // Treatment room sizes
 97   const G4double worldX = 400.0 *cm;               97   const G4double worldX = 400.0 *cm;
 98   const G4double worldY = 400.0 *cm;               98   const G4double worldY = 400.0 *cm;
 99   const G4double worldZ = 400.0 *cm;               99   const G4double worldZ = 400.0 *cm;
100                                                   100 
101   G4Box* treatmentRoom = new G4Box("TreatmentR    101   G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
102                                                   102 
103   G4LogicalVolume* logicTreatmentRoom = new G4    103   G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, 
104                                                   104                                                             air, 
105                                                   105                                                             "logicTreatmentRoom", 
106                   0,0,0);                         106                   0,0,0);
107                                                   107 
108   physicalTreatmentRoom = new G4PVPlacement(0,    108   physicalTreatmentRoom = new G4PVPlacement(0,
109               G4ThreeVector(),                    109               G4ThreeVector(),
110               "physicalTreatmentRoom",            110               "physicalTreatmentRoom", 
111               logicTreatmentRoom,                 111               logicTreatmentRoom, 
112               0,false,0);                         112               0,false,0);
113                                                   113 
114                                                   114 
115   // The treatment room is invisible in the Vi    115   // The treatment room is invisible in the Visualisation
116   logicTreatmentRoom -> SetVisAttributes (G4Vi << 116   logicTreatmentRoom -> SetVisAttributes (G4VisAttributes::Invisible);
117                                                   117 
118                                                   118 
119   // Visualisation attributes of all elements     119   // Visualisation attributes of all elements colours 
120   G4VisAttributes * grayFe = new G4VisAttribut    120   G4VisAttributes * grayFe = new G4VisAttributes(G4Colour(0.5 ,0.5 ,0.5));
121   grayFe -> SetVisibility(true);                  121   grayFe -> SetVisibility(true);
122   grayFe -> SetForceSolid(true);                  122   grayFe -> SetForceSolid(true);
123                                                   123 
124   G4VisAttributes * blueCobalt = new G4VisAttr    124   G4VisAttributes * blueCobalt = new G4VisAttributes(G4Colour(0. ,0. ,0.7));
125   blueCobalt -> SetVisibility(true);              125   blueCobalt -> SetVisibility(true);
126   blueCobalt -> SetForceSolid(true);              126   blueCobalt -> SetForceSolid(true);
127                                                   127 
128   G4VisAttributes * graySS = new G4VisAttribut    128   G4VisAttributes * graySS = new G4VisAttributes(G4Colour(0.9 ,0.9 ,0.9));
129   graySS -> SetVisibility(true);                  129   graySS -> SetVisibility(true);
130   graySS -> SetForceSolid(true);                  130   graySS -> SetForceSolid(true);
131                                                   131 
132   G4VisAttributes * grayAl = new G4VisAttribut    132   G4VisAttributes * grayAl = new G4VisAttributes(G4Colour(0.7 ,0.7 ,0.7));
133   grayAl -> SetVisibility(true);                  133   grayAl -> SetVisibility(true);
134   grayAl -> SetForceSolid(true);                  134   grayAl -> SetForceSolid(true);
135                                                   135 
136   G4VisAttributes * blackLead = new G4VisAttri    136   G4VisAttributes * blackLead = new G4VisAttributes(G4Colour(0.2 ,0.2 ,0.2));
137   blackLead -> SetVisibility(true);               137   blackLead -> SetVisibility(true);
138   blackLead -> SetForceSolid(true);               138   blackLead -> SetForceSolid(true);
139                                                   139  
140                                                   140 
141   G4VisAttributes * colorTungsten = new G4VisA    141   G4VisAttributes * colorTungsten = new G4VisAttributes(G4Colour(0.3 ,0.3 ,0.3));
142   colorTungsten -> SetVisibility(true);           142   colorTungsten -> SetVisibility(true);
143   colorTungsten -> SetForceSolid(true);           143   colorTungsten -> SetForceSolid(true);
144                                                   144  
145                                                   145 
146                                                   146 
147                                                   147 
148                                                   148 
149   //------------------------------------------    149   //--------------------------------------------
150   // Cylinder source "Tube_source"                150   // Cylinder source "Tube_source"
151   //------------------------------------------    151   //--------------------------------------------
152   G4double innerRadiusOfTheTube_source = 0.;      152   G4double innerRadiusOfTheTube_source = 0.;
153   G4double outerRadiusOfTheTube_source = 0.5*m    153   G4double outerRadiusOfTheTube_source = 0.5*mm;
154   G4double hightOfTheTube_source = 1*cm;          154   G4double hightOfTheTube_source = 1*cm;
155   G4double startAngleOfTheTube = 0.*deg;          155   G4double startAngleOfTheTube = 0.*deg;
156   G4double spanningAngleOfTheTube = 360.*deg;     156   G4double spanningAngleOfTheTube = 360.*deg;
157                                                   157 
158   G4ThreeVector positionTube_source = G4ThreeV    158   G4ThreeVector positionTube_source = G4ThreeVector(0,0,-40.1*cm);
159                                                   159   
160   solidTube_source = new G4Tubs("solidTube_sou    160   solidTube_source = new G4Tubs("solidTube_source",    
161          innerRadiusOfTheTube_source,             161          innerRadiusOfTheTube_source,    
162          outerRadiusOfTheTube_source,             162          outerRadiusOfTheTube_source,   
163          hightOfTheTube_source,                   163          hightOfTheTube_source,       
164          startAngleOfTheTube,                     164          startAngleOfTheTube,             
165          spanningAngleOfTheTube);                 165          spanningAngleOfTheTube);          
166   logicTube_source = new G4LogicalVolume(solid    166   logicTube_source = new G4LogicalVolume(solidTube_source,cobalt,"logicTube_source",0,0,0);
167   physiTube_source = new G4PVPlacement(0,         167   physiTube_source = new G4PVPlacement(0,           
168         positionTube_source,                      168         positionTube_source,
169         logicTube_source,                         169         logicTube_source,
170         "Tube_source",                            170         "Tube_source",
171         logicTreatmentRoom,                       171         logicTreatmentRoom,
172         false,                                    172         false,
173         0);                                       173         0);
174                                                   174 
175   logicTube_source -> SetVisAttributes(blueCob    175   logicTube_source -> SetVisAttributes(blueCobalt);
176                                                   176 
177                                                   177 
178   //-------------------------------------         178   //-------------------------------------
179   // Cylinder covering source "Tube"              179   // Cylinder covering source "Tube"
180   //-------------------------------------         180   //-------------------------------------
181   G4double innerRadiusOfTheTube = 0.5*mm;         181   G4double innerRadiusOfTheTube = 0.5*mm;
182   G4double outerRadiusOfTheTube = 4.*mm;          182   G4double outerRadiusOfTheTube = 4.*mm;
183   G4double hightOfTheTube = 1*cm;                 183   G4double hightOfTheTube = 1*cm;
184                                                   184   
185                                                   185 
186   G4ThreeVector positionTube = G4ThreeVector(0    186   G4ThreeVector positionTube = G4ThreeVector(0,0,-40.1*cm);
187                                                   187   
188   solidTube = new G4Tubs("solidTube",             188   solidTube = new G4Tubs("solidTube",    
189          innerRadiusOfTheTube,                    189          innerRadiusOfTheTube,    
190          outerRadiusOfTheTube,                    190          outerRadiusOfTheTube,  
191          hightOfTheTube,                          191          hightOfTheTube,          
192          startAngleOfTheTube,                     192          startAngleOfTheTube,    
193          spanningAngleOfTheTube);                 193          spanningAngleOfTheTube);
194   logicTube = new G4LogicalVolume(solidTube,st    194   logicTube = new G4LogicalVolume(solidTube,steel,"logicTube",0,0,0);
195   physiTube = new G4PVPlacement(0,                195   physiTube = new G4PVPlacement(0,          
196         positionTube,                             196         positionTube,
197         logicTube,                                197         logicTube,
198         "Tube",                                   198         "Tube",
199         logicTreatmentRoom,                       199         logicTreatmentRoom,
200         false,                                    200         false,
201         0);                                       201         0);
202                                                   202 
203   logicTube -> SetVisAttributes(graySS);          203   logicTube -> SetVisAttributes(graySS);
204                                                   204 
205   //---------------------------------------       205   //---------------------------------------
206   // Cylinder covering source "Tube_Al"           206   // Cylinder covering source "Tube_Al"
207   //---------------------------------------       207   //---------------------------------------
208   G4double innerRadiusOfTheTube_Al = 4.*mm;       208   G4double innerRadiusOfTheTube_Al = 4.*mm;
209   G4double outerRadiusOfTheTube_Al = 15.*mm;      209   G4double outerRadiusOfTheTube_Al = 15.*mm;
210   G4double hightOfTheTube_Al = 1*cm;              210   G4double hightOfTheTube_Al = 1*cm;
211                                                   211  
212   G4ThreeVector positionTube_Al = G4ThreeVecto    212   G4ThreeVector positionTube_Al = G4ThreeVector(0,0,-40.1*cm);
213                                                   213   
214   solidTube_Al = new G4Tubs("solidTube_Al",       214   solidTube_Al = new G4Tubs("solidTube_Al",    
215          innerRadiusOfTheTube_Al,                 215          innerRadiusOfTheTube_Al,   
216          outerRadiusOfTheTube_Al,                 216          outerRadiusOfTheTube_Al,    
217          hightOfTheTube_Al,                       217          hightOfTheTube_Al,         
218          startAngleOfTheTube,                     218          startAngleOfTheTube,     
219          spanningAngleOfTheTube);                 219          spanningAngleOfTheTube); 
220   logicTube_Al = new G4LogicalVolume(solidTube    220   logicTube_Al = new G4LogicalVolume(solidTube_Al,Al,"logicTube_Al",0,0,0);
221   physiTube_Al = new G4PVPlacement(0,             221   physiTube_Al = new G4PVPlacement(0,          
222         positionTube_Al,                          222         positionTube_Al,
223         logicTube_Al,                             223         logicTube_Al,
224         "Tube_Al",                                224         "Tube_Al",
225         logicTreatmentRoom,                       225         logicTreatmentRoom,
226         false,                                    226         false,
227         0);                                       227         0);
228                                                   228 
229   logicTube_Al -> SetVisAttributes(grayAl);       229   logicTube_Al -> SetVisAttributes(grayAl);
230                                                   230 
231   //------------------------------------------    231   //----------------------------------------------
232   // Cylinder covering external part of the so    232   // Cylinder covering external part of the source "Tube_Fe"
233   //------------------------------------------    233   //----------------------------------------------
234   G4double innerRadiusOfTheTube_Fe = 15.*mm;      234   G4double innerRadiusOfTheTube_Fe = 15.*mm;
235   G4double outerRadiusOfTheTube_Fe = 50.*mm;      235   G4double outerRadiusOfTheTube_Fe = 50.*mm;
236   G4double hightOfTheTube_Fe = 1*cm;              236   G4double hightOfTheTube_Fe = 1*cm;
237                                                   237   
238                                                   238 
239   G4ThreeVector positionTube_Fe = G4ThreeVecto    239   G4ThreeVector positionTube_Fe = G4ThreeVector(0,0,-40.1*cm);
240                                                   240   
241   solidTube_Fe = new G4Tubs("solidTube_Fe",       241   solidTube_Fe = new G4Tubs("solidTube_Fe",    
242          innerRadiusOfTheTube_Fe,                 242          innerRadiusOfTheTube_Fe,    
243          outerRadiusOfTheTube_Fe,                 243          outerRadiusOfTheTube_Fe,   
244          hightOfTheTube_Fe,                       244          hightOfTheTube_Fe,          
245          startAngleOfTheTube,                     245          startAngleOfTheTube,     
246          spanningAngleOfTheTube);                 246          spanningAngleOfTheTube); 
247   logicTube_Fe = new G4LogicalVolume(solidTube    247   logicTube_Fe = new G4LogicalVolume(solidTube_Fe,Fe,"logicTube_Fe",0,0,0);
248   physiTube_Fe = new G4PVPlacement(0,             248   physiTube_Fe = new G4PVPlacement(0,           
249         positionTube_Fe,                          249         positionTube_Fe,
250         logicTube_Fe,                             250         logicTube_Fe,
251         "Tube_Fe",                                251         "Tube_Fe",
252         logicTreatmentRoom,                       252         logicTreatmentRoom,
253         false,                                    253         false,
254         0);                                       254         0);
255                                                   255 
256   logicTube_Fe -> SetVisAttributes(grayFe);       256   logicTube_Fe -> SetVisAttributes(grayFe);
257                                                   257 
258                                                   258 
259                                                   259 
260                                                   260 
261  //-------------------------------------------    261  //------------------------------------------------
262  // Cylinder covering posterior part "Tube_pos    262  // Cylinder covering posterior part "Tube_post"
263  //-------------------------------------------    263  //------------------------------------------------
264                                                   264 
265   G4double innerRadiusOfTheTube_post = 0;         265   G4double innerRadiusOfTheTube_post = 0;
266   G4double outerRadiusOfTheTube_post = 50*mm;     266   G4double outerRadiusOfTheTube_post = 50*mm;
267   G4double hightOfTheTube_post = 1*cm;            267   G4double hightOfTheTube_post = 1*cm;
268                                                   268  
269   G4ThreeVector positionTube_post = G4ThreeVec    269   G4ThreeVector positionTube_post = G4ThreeVector(0,0,-42.2*cm);
270                                                   270   
271   solidTube_post = new G4Tubs("solidTube_post"    271   solidTube_post = new G4Tubs("solidTube_post",    
272          innerRadiusOfTheTube_post,               272          innerRadiusOfTheTube_post,   
273          outerRadiusOfTheTube_post,               273          outerRadiusOfTheTube_post,   
274          hightOfTheTube_post,                     274          hightOfTheTube_post,          
275          startAngleOfTheTube,                     275          startAngleOfTheTube,     
276          spanningAngleOfTheTube);                 276          spanningAngleOfTheTube); 
277  logicTube_post = new G4LogicalVolume(solidTub    277  logicTube_post = new G4LogicalVolume(solidTube_post,Fe,"logicTube_post",0,0,0);
278  physiTube_post = new G4PVPlacement(0,            278  physiTube_post = new G4PVPlacement(0,           
279         positionTube_post,                        279         positionTube_post,
280         logicTube_post,                           280         logicTube_post,
281         "Tube_post",                              281         "Tube_post",
282               logicTreatmentRoom,                 282               logicTreatmentRoom,
283         false,                                    283         false,
284         0);                                       284         0);
285                                                   285 
286  logicTube_post -> SetVisAttributes(grayFe);      286  logicTube_post -> SetVisAttributes(grayFe);
287                                                   287 
288                                                   288 
289  //-------------------------------------------    289  //------------------------------------------------
290  // Fixed cylinder collimator "Tube_coll"         290  // Fixed cylinder collimator "Tube_coll"
291  //-------------------------------------------    291  //------------------------------------------------
292                                                   292 
293   G4double innerRadiusOfTheTube_coll = 2.5*mm;    293   G4double innerRadiusOfTheTube_coll = 2.5*mm;
294   G4double outerRadiusOfTheTube_coll = 15.*mm;    294   G4double outerRadiusOfTheTube_coll = 15.*mm;
295   G4double hightOfTheTube_coll = 3.25*cm;         295   G4double hightOfTheTube_coll = 3.25*cm;
296                                                   296  
297   G4ThreeVector positionTube_coll = G4ThreeVec    297   G4ThreeVector positionTube_coll = G4ThreeVector(0,0,-35.2*cm);
298                                                   298   
299   solidTube_coll = new G4Tubs("solidTube_coll"    299   solidTube_coll = new G4Tubs("solidTube_coll",    
300          innerRadiusOfTheTube_coll,               300          innerRadiusOfTheTube_coll,    
301          outerRadiusOfTheTube_coll,               301          outerRadiusOfTheTube_coll,    
302          hightOfTheTube_coll,                     302          hightOfTheTube_coll,         
303          startAngleOfTheTube,                     303          startAngleOfTheTube,     
304          spanningAngleOfTheTube);                 304          spanningAngleOfTheTube); 
305  logicTube_coll = new G4LogicalVolume(solidTub    305  logicTube_coll = new G4LogicalVolume(solidTube_coll,tungsten,"logicTube_coll",0,0,0);
306  physiTube_coll = new G4PVPlacement(0,            306  physiTube_coll = new G4PVPlacement(0,           
307         positionTube_coll,                        307         positionTube_coll,
308         logicTube_coll,                           308         logicTube_coll,
309         "Tube_coll",                              309         "Tube_coll",
310         logicTreatmentRoom,                       310         logicTreatmentRoom,
311         false,                                    311         false,
312         0);                                       312         0);
313                                                   313 
314  logicTube_coll -> SetVisAttributes(colorTungs    314  logicTube_coll -> SetVisAttributes(colorTungsten);
315                                                   315 
316                                                   316 
317  //-------------------------------------------    317  //------------------------------------------------
318  // Cylinder covering fixed collimator "Tube_c    318  // Cylinder covering fixed collimator "Tube_coll_Fe"
319  //-------------------------------------------    319  //------------------------------------------------
320                                                   320 
321   G4double innerRadiusOfTheTube_coll_Fe = 15.*    321   G4double innerRadiusOfTheTube_coll_Fe = 15.*mm;
322   G4double outerRadiusOfTheTube_coll_Fe = 50.*    322   G4double outerRadiusOfTheTube_coll_Fe = 50.*mm;
323   G4double hightOfTheTube_coll_Fe = 3.25*cm;      323   G4double hightOfTheTube_coll_Fe = 3.25*cm;
324                                                   324  
325   G4ThreeVector positionTube_coll_Fe = G4Three    325   G4ThreeVector positionTube_coll_Fe = G4ThreeVector(0,0,-35.2*cm);
326                                                   326   
327   solidTube_coll_Fe = new G4Tubs("solidTube_co    327   solidTube_coll_Fe = new G4Tubs("solidTube_coll_Fe",    
328          innerRadiusOfTheTube_coll_Fe,            328          innerRadiusOfTheTube_coll_Fe,    
329          outerRadiusOfTheTube_coll_Fe,            329          outerRadiusOfTheTube_coll_Fe,    
330          hightOfTheTube_coll_Fe,                  330          hightOfTheTube_coll_Fe,          
331          startAngleOfTheTube,                     331          startAngleOfTheTube,     
332          spanningAngleOfTheTube);                 332          spanningAngleOfTheTube); 
333  logicTube_coll_Fe = new G4LogicalVolume(solid    333  logicTube_coll_Fe = new G4LogicalVolume(solidTube_coll_Fe,Fe,"logicTube_coll_Fe",0,0,0);
334  physiTube_coll_Fe = new G4PVPlacement(0,         334  physiTube_coll_Fe = new G4PVPlacement(0,          
335         positionTube_coll_Fe,                     335         positionTube_coll_Fe,
336         logicTube_coll_Fe,                        336         logicTube_coll_Fe,
337         "Tube_coll_Fe",                           337         "Tube_coll_Fe",
338         logicTreatmentRoom,                       338         logicTreatmentRoom,
339         false,                                    339         false,
340         0);                                       340         0);
341                                                   341 
342  logicTube_coll_Fe -> SetVisAttributes(grayFe)    342  logicTube_coll_Fe -> SetVisAttributes(grayFe);
343                                                   343 
344                                                   344 
345  //-------------------------------------------    345  //------------------------------------------------
346  // Fixed truncated cone collimator "Coll_fixe    346  // Fixed truncated cone collimator "Coll_fixed"
347  //-------------------------------------------    347  //------------------------------------------------
348                                                   348 
349   G4double Rmin1Coll_fixed = 2.5*mm;              349   G4double Rmin1Coll_fixed = 2.5*mm;
350   G4double Rmax1Coll_fixed = 15.*mm;              350   G4double Rmax1Coll_fixed = 15.*mm;
351   G4double Rmin2Coll_fixed = 4.25*mm;             351   G4double Rmin2Coll_fixed = 4.25*mm;
352   G4double Rmax2Coll_fixed = 15.*mm;              352   G4double Rmax2Coll_fixed = 15.*mm;
353   G4double hightColl_fixed = 4.625*cm;            353   G4double hightColl_fixed = 4.625*cm;
354                                                   354  
355                                                   355 
356   G4ThreeVector positionColl_fixed = G4ThreeVe    356   G4ThreeVector positionColl_fixed = G4ThreeVector(0,0,-27.325*cm);
357                                                   357 
358   solidColl_fixed = new G4Cons("solidColl_fixe    358   solidColl_fixed = new G4Cons("solidColl_fixed",
359              Rmin1Coll_fixed,                     359              Rmin1Coll_fixed,  
360              Rmax1Coll_fixed,                     360              Rmax1Coll_fixed, 
361              Rmin2Coll_fixed,                     361              Rmin2Coll_fixed,  
362              Rmax2Coll_fixed,                     362              Rmax2Coll_fixed, 
363              hightColl_fixed,                     363              hightColl_fixed,  
364              startAngleOfTheTube,                 364              startAngleOfTheTube,    
365              spanningAngleOfTheTube);             365              spanningAngleOfTheTube);
366   logicColl_fixed = new G4LogicalVolume(solidC    366   logicColl_fixed = new G4LogicalVolume(solidColl_fixed,Pb,"logicColl_fixed",0,0,0);
367   physiColl_fixed = new G4PVPlacement(0,          367   physiColl_fixed = new G4PVPlacement(0,
368               positionColl_fixed,                 368               positionColl_fixed,
369               logicColl_fixed,                    369               logicColl_fixed,
370               "Coll_fixed",                       370               "Coll_fixed",
371               logicTreatmentRoom,                 371               logicTreatmentRoom,
372               false,                              372               false,
373               0);                                 373               0);
374                                                   374 
375  logicColl_fixed -> SetVisAttributes(blackLead    375  logicColl_fixed -> SetVisAttributes(blackLead);
376                                                   376 
377                                                   377 
378  //-------------------------------------------    378  //-----------------------------------------------------------
379  // Cilinder covering fixed collimator "Coll_f    379  // Cilinder covering fixed collimator "Coll_fixed_Fe"
380  //-------------------------------------------    380  //-----------------------------------------------------------
381                                                   381 
382   G4double Rmin1Coll_fixed_Fe = 15.*mm;           382   G4double Rmin1Coll_fixed_Fe = 15.*mm;
383   G4double Rmax1Coll_fixed_Fe = 50.*mm;           383   G4double Rmax1Coll_fixed_Fe = 50.*mm;
384   G4double Rmin2Coll_fixed_Fe = 15.*mm;           384   G4double Rmin2Coll_fixed_Fe = 15.*mm;
385   G4double Rmax2Coll_fixed_Fe = 40.*mm;           385   G4double Rmax2Coll_fixed_Fe = 40.*mm;
386   G4double hightColl_fixed_Fe = 4.625*cm;         386   G4double hightColl_fixed_Fe = 4.625*cm;
387                                                   387  
388                                                   388 
389   G4ThreeVector positionColl_fixed_Fe = G4Thre    389   G4ThreeVector positionColl_fixed_Fe = G4ThreeVector(0,0,-27.325*cm);
390                                                   390 
391   solidColl_fixed_Fe = new G4Cons("solidColl_f    391   solidColl_fixed_Fe = new G4Cons("solidColl_fixed_Fe",
392              Rmin1Coll_fixed_Fe,                  392              Rmin1Coll_fixed_Fe,  
393              Rmax1Coll_fixed_Fe,                  393              Rmax1Coll_fixed_Fe,  
394              Rmin2Coll_fixed_Fe,                  394              Rmin2Coll_fixed_Fe,  
395              Rmax2Coll_fixed_Fe,                  395              Rmax2Coll_fixed_Fe,  
396              hightColl_fixed_Fe,                  396              hightColl_fixed_Fe,  
397              startAngleOfTheTube,    //           397              startAngleOfTheTube,    // 
398              spanningAngleOfTheTube);             398              spanningAngleOfTheTube);
399   logicColl_fixed_Fe = new G4LogicalVolume(sol    399   logicColl_fixed_Fe = new G4LogicalVolume(solidColl_fixed_Fe,Fe,"logicColl_fixed_Fe",0,0,0);
400   physiColl_fixed_Fe = new G4PVPlacement(0,       400   physiColl_fixed_Fe = new G4PVPlacement(0,
401               positionColl_fixed_Fe,              401               positionColl_fixed_Fe,
402               logicColl_fixed_Fe,                 402               logicColl_fixed_Fe,
403               "Coll_fixed_Fe",                    403               "Coll_fixed_Fe",
404               logicTreatmentRoom,                 404               logicTreatmentRoom,
405               false,                              405               false,
406               0);                                 406               0);
407                                                   407 
408   logicColl_fixed_Fe -> SetVisAttributes(grayF    408   logicColl_fixed_Fe -> SetVisAttributes(grayFe);
409                                                   409 
410                                                   410 
411  //-------------------------------------------    411  //------------------------------------------------
412  // Mobile truncate cone collimator "Coll_helm    412  // Mobile truncate cone collimator "Coll_helmet"
413  //-------------------------------------------    413  //------------------------------------------------
414   G4double Rmax1Coll_helmet = 15.*mm;             414   G4double Rmax1Coll_helmet = 15.*mm;
415   G4double Rmax2Coll_helmet = 15.*mm;             415   G4double Rmax2Coll_helmet = 15.*mm;
416   G4double hightColl_helmet = 3.0*cm;             416   G4double hightColl_helmet = 3.0*cm;
417                                                   417  
418                                                   418 
419   G4ThreeVector positionColl_helmet = G4ThreeV    419   G4ThreeVector positionColl_helmet = G4ThreeVector(0,0,-19.5*cm);
420                                                   420 
421   solidColl_helmet = new G4Cons("solidColl_hel    421   solidColl_helmet = new G4Cons("solidColl_helmet",
422                                0.0,  // will b    422                                0.0,  // will be set later
423                                Rmax1Coll_helme    423                                Rmax1Coll_helmet, 
424                                0.0,  // will b    424                                0.0,  // will be set later
425              Rmax2Coll_helmet,                    425              Rmax2Coll_helmet,  
426              hightColl_helmet,                    426              hightColl_helmet, 
427              startAngleOfTheTube,                 427              startAngleOfTheTube,   
428                                spanningAngleOf    428                                spanningAngleOfTheTube);
429   UpdateHelmet(); // Set the proper inner radi    429   UpdateHelmet(); // Set the proper inner radii
430                                                   430 
431   logicColl_helmet = new G4LogicalVolume(solid    431   logicColl_helmet = new G4LogicalVolume(solidColl_helmet,tungsten,"logicColl_helmet",0,0,0);
432   physiColl_helmet = new G4PVPlacement(0,         432   physiColl_helmet = new G4PVPlacement(0,
433               positionColl_helmet,                433               positionColl_helmet,
434               logicColl_helmet,                   434               logicColl_helmet,
435               "Coll_helmet",                      435               "Coll_helmet",
436               logicTreatmentRoom,                 436               logicTreatmentRoom,
437               false,                              437               false,
438               0);                                 438               0);
439                                                   439 
440   logicColl_helmet -> SetVisAttributes(colorTu    440   logicColl_helmet -> SetVisAttributes(colorTungsten);
441                                                   441 
442  //-------------------------------------------    442  //--------------------------------------------------------------
443  // Truncated cone covering mobile collimator     443  // Truncated cone covering mobile collimator "Coll_helmet_Fe"
444  //-------------------------------------------    444  //--------------------------------------------------------------
445                                                   445 
446   G4double Rmin1Coll_helmet_Fe = 15.*mm;          446   G4double Rmin1Coll_helmet_Fe = 15.*mm;
447   G4double Rmax1Coll_helmet_Fe = 40.*mm;          447   G4double Rmax1Coll_helmet_Fe = 40.*mm;
448   G4double Rmin2Coll_helmet_Fe = 15.*mm;          448   G4double Rmin2Coll_helmet_Fe = 15.*mm;
449   G4double Rmax2Coll_helmet_Fe = 30.*mm;          449   G4double Rmax2Coll_helmet_Fe = 30.*mm;
450   G4double hightColl_helmet_Fe = 3.0*cm;          450   G4double hightColl_helmet_Fe = 3.0*cm;
451                                                   451 
452   G4ThreeVector positionColl_helmet_Fe = G4Thr    452   G4ThreeVector positionColl_helmet_Fe = G4ThreeVector(0,0,-19.5*cm);
453                                                   453 
454   solidColl_helmet_Fe = new G4Cons("solidColl_    454   solidColl_helmet_Fe = new G4Cons("solidColl_helmet_Fe",
455              Rmin1Coll_helmet_Fe,                 455              Rmin1Coll_helmet_Fe, 
456              Rmax1Coll_helmet_Fe,                 456              Rmax1Coll_helmet_Fe,  
457              Rmin2Coll_helmet_Fe,                 457              Rmin2Coll_helmet_Fe,  
458              Rmax2Coll_helmet_Fe,                 458              Rmax2Coll_helmet_Fe,  
459              hightColl_helmet_Fe,                 459              hightColl_helmet_Fe, 
460              startAngleOfTheTube,                 460              startAngleOfTheTube,   
461              spanningAngleOfTheTube);             461              spanningAngleOfTheTube);
462   logicColl_helmet_Fe = new G4LogicalVolume(so    462   logicColl_helmet_Fe = new G4LogicalVolume(solidColl_helmet_Fe,Fe,"logicColl_helmet_Fe",0,0,0);
463   physiColl_helmet_Fe = new G4PVPlacement(0,      463   physiColl_helmet_Fe = new G4PVPlacement(0,
464               positionColl_helmet_Fe,             464               positionColl_helmet_Fe,
465               logicColl_helmet_Fe,                465               logicColl_helmet_Fe,
466               "Coll_helmet_Fe",                   466               "Coll_helmet_Fe",
467               logicTreatmentRoom,                 467               logicTreatmentRoom,
468               false,                              468               false,
469               0);                                 469               0);
470                                                   470 
471   logicColl_helmet_Fe -> SetVisAttributes(gray    471   logicColl_helmet_Fe -> SetVisAttributes(grayFe);
472                                                   472 
473   //-----------------------------------------     473   //-----------------------------------------
474   // Patient --> water spherical phantom          474   // Patient --> water spherical phantom
475   //-----------------------------------------     475   //-----------------------------------------
476                                                   476 
477                                                   477  
478   G4Orb* patient = new G4Orb("patient",8.*cm);    478   G4Orb* patient = new G4Orb("patient",8.*cm);
479   patientLogicalVolume = new G4LogicalVolume(p    479   patientLogicalVolume = new G4LogicalVolume(patient,
480                     water,                        480                     water, 
481                     "patientLog", 0, 0, 0);       481                     "patientLog", 0, 0, 0);
482   patientPhysicalVolume = new G4PVPlacement( n    482   patientPhysicalVolume = new G4PVPlacement( new G4RotationMatrix(),
483                                             G4    483                                             G4ThreeVector(0., 0., 0.),
484               "patientPhys",                      484               "patientPhys",
485               patientLogicalVolume,               485               patientLogicalVolume,
486               physicalTreatmentRoom,              486               physicalTreatmentRoom,
487               false,0);                           487               false,0);
488                                                   488 
489   // Visualisation attributes of the patient      489   // Visualisation attributes of the patient 
490   G4VisAttributes * redWire = new G4VisAttribu    490   G4VisAttributes * redWire = new G4VisAttributes(G4Colour(0.8 ,0. ,0.));
491   redWire -> SetVisibility(true);                 491   redWire -> SetVisibility(true);
492   redWire -> SetForceWireframe(true);             492   redWire -> SetForceWireframe(true);
493   redWire -> SetForceAuxEdgeVisible(true);        493   redWire -> SetForceAuxEdgeVisible(true);
494   patientLogicalVolume -> SetVisAttributes(red    494   patientLogicalVolume -> SetVisAttributes(redWire); 
495                                                   495 
496 }                                                 496 }
497                                                   497 
498 void GammaKnifeDetectorConstruction::UpdateHel    498 void GammaKnifeDetectorConstruction::UpdateHelmet()
499 {                                                 499 {
500     if (solidColl_helmet)                         500     if (solidColl_helmet)
501     {                                             501     {
502         switch( helmetSize )                      502         switch( helmetSize )
503         {                                         503         {
504         case 18:                                  504         case 18:
505             solidColl_helmet->SetInnerRadiusMi    505             solidColl_helmet->SetInnerRadiusMinusZ( 4.15 * mm );
506             solidColl_helmet->SetInnerRadiusPl    506             solidColl_helmet->SetInnerRadiusPlusZ( 5.3  * mm );
507             break;                                507             break;
508                                                   508 
509         case 14:                                  509         case 14:
510             solidColl_helmet->SetInnerRadiusMi    510             solidColl_helmet->SetInnerRadiusMinusZ( 3.15 * mm );
511             solidColl_helmet->SetInnerRadiusPl    511             solidColl_helmet->SetInnerRadiusPlusZ( 4.25  * mm );
512             break;                                512             break;
513                                                   513 
514         case 8:                                   514         case 8:
515             solidColl_helmet->SetInnerRadiusMi    515             solidColl_helmet->SetInnerRadiusMinusZ( 1.9 * mm );
516             solidColl_helmet->SetInnerRadiusPl    516             solidColl_helmet->SetInnerRadiusPlusZ( 2.5  * mm );
517             break;                                517             break;
518                                                   518 
519         case 4:                                   519         case 4:
520             solidColl_helmet->SetInnerRadiusMi    520             solidColl_helmet->SetInnerRadiusMinusZ( 1. * mm );
521             solidColl_helmet->SetInnerRadiusPl    521             solidColl_helmet->SetInnerRadiusPlusZ( 1.25  * mm );
522             break;                                522             break;
523         }                                         523         }
524         // Inform the run manager about change    524         // Inform the run manager about change in the geometry
525         G4RunManager::GetRunManager()->Geometr    525         G4RunManager::GetRunManager()->GeometryHasBeenModified();
526     }                                             526     }
527 }                                                 527 }
528                                                   528 
529 void GammaKnifeDetectorConstruction::SetHelmet    529 void GammaKnifeDetectorConstruction::SetHelmetSize(G4int size)
530 {                                                 530 {
531     if (size != helmetSize) // Only if the siz    531     if (size != helmetSize) // Only if the size changes
532     {                                             532     {
533         // Allow only valid numbers               533         // Allow only valid numbers
534         switch( size )                            534         switch( size )
535         {                                         535         {
536         case 18:                                  536         case 18:
537         case 14:                                  537         case 14:
538         case 8:                                   538         case 8:
539         case 4:                                   539         case 4:
540             helmetSize = size;                    540             helmetSize = size;
541             G4cout << "Helmet size set to " <<    541             G4cout << "Helmet size set to " << helmetSize << std::endl;
542             UpdateHelmet();                       542             UpdateHelmet();
543             break;                                543             break;
544         default:                                  544         default:
545       G4Exception("GammaKnifeDetectorConstruct    545       G4Exception("GammaKnifeDetectorConstruction::SetHelmetSize()", 
546       "GammaKnife001", FatalException,            546       "GammaKnife001", FatalException, 
547       "Error: Invalid helmet size.");             547       "Error: Invalid helmet size.");
548             return;                               548             return;
549         }                                         549         }
550     }                                             550     }
551 }                                                 551 }
552                                                   552 
553                                                   553 
554                                                   554 
555                                                   555