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


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