Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/medical/GammaTherapy/src/DetectorConstruction.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/extended/medical/GammaTherapy/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/medical/GammaTherapy/src/DetectorConstruction.cc (Version 10.4.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 // $Id: DetectorConstruction.cc 103469 2017-04-11 07:29:36Z gcosmo $
 26 //                                                 27 //
 27 /// \file medical/GammaTherapy/src/DetectorCon     28 /// \file medical/GammaTherapy/src/DetectorConstruction.cc
 28 /// \brief Implementation of the DetectorConst     29 /// \brief Implementation of the DetectorConstruction class
 29 //                                                 30 //
 30 //                                                 31 //
 31 // -------------------------------------------     32 // -------------------------------------------------------------
 32 //      GEANT4 ibrem test                          33 //      GEANT4 ibrem test
 33 //                                                 34 //
 34 // Authors: V.Grichine, V.Ivanchenko               35 // Authors: V.Grichine, V.Ivanchenko
 35 //                                                 36 //
 36 // Modified:                                       37 // Modified:
 37 //                                                 38 //
 38 // 18-02-03 V.Ivanchenko create                    39 // 18-02-03 V.Ivanchenko create
 39 //                                                 40 //
 40 // -------------------------------------------     41 // -------------------------------------------------------------
 41                                                    42 
 42 //....oooOO0OOooo........oooOO0OOooo........oo     43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 43 //....oooOO0OOooo........oooOO0OOooo........oo     44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 44                                                    45 
 45 #include "DetectorConstruction.hh"                 46 #include "DetectorConstruction.hh"
 46                                                << 
 47 #include "CheckVolumeSD.hh"                    << 
 48 #include "DetectorMessenger.hh"                    47 #include "DetectorMessenger.hh"
 49 #include "PhantomSD.hh"                            48 #include "PhantomSD.hh"
 50 #include "TargetSD.hh"                             49 #include "TargetSD.hh"
                                                   >>  50 #include "CheckVolumeSD.hh"
 51                                                    51 
 52 #include "G4Box.hh"                                52 #include "G4Box.hh"
 53 #include "G4Colour.hh"                         <<  53 #include "G4Tubs.hh"
 54 #include "G4GeometryManager.hh"                << 
 55 #include "G4LogicalVolume.hh"                      54 #include "G4LogicalVolume.hh"
 56 #include "G4LogicalVolumeStore.hh"             <<  55 #include "G4VPhysicalVolume.hh"
                                                   >>  56 #include "G4PVPlacement.hh"
 57 #include "G4Material.hh"                           57 #include "G4Material.hh"
                                                   >>  58 #include "G4SDManager.hh"
                                                   >>  59 #include "PhantomSD.hh"
 58 #include "G4NistManager.hh"                        60 #include "G4NistManager.hh"
 59 #include "G4PVPlacement.hh"                    <<  61 
 60 #include "G4PhysicalConstants.hh"              << 
 61 #include "G4PhysicalVolumeStore.hh"                62 #include "G4PhysicalVolumeStore.hh"
 62 #include "G4RunManager.hh"                     <<  63 #include "G4LogicalVolumeStore.hh"
 63 #include "G4SDManager.hh"                      << 
 64 #include "G4SolidStore.hh"                         64 #include "G4SolidStore.hh"
 65 #include "G4SystemOfUnits.hh"                  <<  65 #include "G4RunManager.hh"
 66 #include "G4Tubs.hh"                           <<  66 #include "G4GeometryManager.hh"
 67 #include "G4VPhysicalVolume.hh"                <<  67 
 68 #include "G4VisAttributes.hh"                      68 #include "G4VisAttributes.hh"
 69 #include "G4ios.hh"                            <<  69 #include "G4Colour.hh"
                                                   >>  70 
 70 #include "globals.hh"                              71 #include "globals.hh"
                                                   >>  72 #include "G4PhysicalConstants.hh"
                                                   >>  73 #include "G4SystemOfUnits.hh"
                                                   >>  74 #include "G4ios.hh"
 71                                                    75 
 72 //....oooOO0OOooo........oooOO0OOooo........oo     76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 73                                                    77 
 74 DetectorConstruction::DetectorConstruction()       78 DetectorConstruction::DetectorConstruction()
 75 {                                                  79 {
 76   fLogicTarget1 = 0;                               80   fLogicTarget1 = 0;
 77   fLogicTarget2 = 0;                               81   fLogicTarget2 = 0;
 78                                                    82 
 79   fMessenger = new DetectorMessenger(this);        83   fMessenger = new DetectorMessenger(this);
 80   fVerbose = false;                                84   fVerbose = false;
 81                                                    85 
 82   fNumZ = 60;                                  <<  86   fNumZ    = 60;
 83   fNumR = 80;                                  <<  87   fNumR    = 80;
 84                                                    88 
 85   fNumE = 200;                                 <<  89   fNumE    = 200;
 86   fMaxEnergy = 50.0 * MeV;                     <<  90   fMaxEnergy = 50.0*MeV;
 87                                                    91 
 88   fDistanceVacuumTarget = 30. * mm,            <<  92   fDistanceVacuumTarget = 30.*mm,
 89                                                    93 
 90   fDelta = 0.001 * mm;                         <<  94   fDelta                = 0.001*mm;
 91                                                    95 
 92   fTargetRadius = 100. * mm;                   <<  96   fTargetRadius         = 100.*mm;
 93   fTarget1Z = 9. * mm;                         <<  97   fTarget1Z             = 9.*mm;
 94   fTarget2Z = 6. * mm;                         <<  98   fTarget2Z             = 6.*mm;
 95                                                    99 
 96   fGasVolumeRadius = 210. * mm;                << 100   fGasVolumeRadius      = 210.*mm;
 97   fGasVolumeZ = 690. * mm;                     << 101   fGasVolumeZ           = 690.*mm;
 98   fMylarVolumeZ = 0.02 * mm;                   << 102   fMylarVolumeZ         = 0.02*mm;
 99                                                   103 
100   fCheckVolumeZ = 0.1 * mm;                    << 104   fCheckVolumeZ         = 0.1*mm;
101   fCheckShiftZ = 200. * mm;                    << 105   fCheckShiftZ          = 200.*mm;
102                                                   106 
103   fAbsorberRadius = 200. * mm;                 << 107   fAbsorberRadius       = 200.*mm;
104   fPhantomRadius = 300. * mm;                  << 108   fPhantomRadius        = 300.*mm;
105   fPhantomZ = 300. * mm;                       << 109   fPhantomZ             = 300.*mm;
106                                                   110 
107   fAirZ = 210. * mm;                           << 111   fAirZ                 = 210.*mm;
108   fAbsorberShiftZ = 70. * mm;                  << 112   fAbsorberShiftZ       = 70.*mm;
109   fWindowZ = 0.05 * mm;                        << 113   fWindowZ              = 0.05*mm;
110                                                   114 
111   G4NistManager* man = G4NistManager::Instance    115   G4NistManager* man = G4NistManager::Instance();
112   // man->SetVerbose(1);                       << 116   //man->SetVerbose(1);
113                                                   117 
114   fTarget1Material = man->FindOrBuildMaterial(    118   fTarget1Material = man->FindOrBuildMaterial("G4_Be");
115   fWindowMaterial = fTarget1Material;          << 119   fWindowMaterial  = fTarget1Material;
116   fTarget2Material = man->FindOrBuildMaterial(    120   fTarget2Material = man->FindOrBuildMaterial("G4_W");
117   fLightMaterial = man->FindOrBuildMaterial("G << 121   fLightMaterial   = man->FindOrBuildMaterial("G4_He");
118   fAbsorberMaterial = man->FindOrBuildMaterial << 122   fAbsorberMaterial= man->FindOrBuildMaterial("G4_WATER");
119   fWorldMaterial = man->FindOrBuildMaterial("G << 123   fWorldMaterial   = man->FindOrBuildMaterial("G4_AIR");
120   fMylar = man->FindOrBuildMaterial("G4_MYLAR" << 124   fMylar           = man->FindOrBuildMaterial("G4_MYLAR");
121                                                   125 
122   G4cout << *(G4Material::GetMaterialTable())     126   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
123 }                                                 127 }
124                                                   128 
125 //....oooOO0OOooo........oooOO0OOooo........oo    129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126                                                   130 
127 DetectorConstruction::~DetectorConstruction()     131 DetectorConstruction::~DetectorConstruction()
128 {                                                 132 {
129   delete fMessenger;                              133   delete fMessenger;
130 }                                                 134 }
131                                                   135 
132 //....oooOO0OOooo........oooOO0OOooo........oo    136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133                                                   137 
134 void DetectorConstruction::InitialiseGeometryP    138 void DetectorConstruction::InitialiseGeometryParameters()
135 {                                                 139 {
136   // Volumee sizes                                140   // Volumee sizes
137                                                   141 
138   G4double factor = 1.2;                          142   G4double factor = 1.2;
139                                                   143 
140   fWorldXY = factor * std::max(fPhantomRadius, << 144   fWorldXY       = factor*std::max(fPhantomRadius,fGasVolumeRadius);
141   fAbsorberZ = fPhantomZ / fNumZ;              << 145   fAbsorberZ     = fPhantomZ/fNumZ;
142   fGasVolumeZ = 1000. * mm - fAbsorberShiftZ - << 146   fGasVolumeZ    = 1000.*mm - fAbsorberShiftZ - fAirZ - fTarget1Z - fTarget2Z;
143                                                   147 
144   G4double ztot = fGasVolumeZ + fAirZ + fPhant << 148   G4double ztot  = fGasVolumeZ + fAirZ + fPhantomZ + fDistanceVacuumTarget;
145   fTargetVolumeZ = fDistanceVacuumTarget + fTa    149   fTargetVolumeZ = fDistanceVacuumTarget + fTarget2Z + fTarget1Z + fDelta;
146   fWorldZ = factor * ztot * 0.5;               << 150   fWorldZ  = factor*ztot*0.5;
147                                                   151 
148   if (fCheckShiftZ < fDelta) {                 << 152   if(fCheckShiftZ < fDelta) { fCheckShiftZ = fDelta; }
149     fCheckShiftZ = fDelta;                     << 153   if(fCheckShiftZ > fAirZ - fCheckVolumeZ -fDelta) {
150   }                                            << 154     fCheckShiftZ = fAirZ - fCheckVolumeZ -fDelta;
151   if (fCheckShiftZ > fAirZ - fCheckVolumeZ - f << 
152     fCheckShiftZ = fAirZ - fCheckVolumeZ - fDe << 
153   }                                               155   }
154                                                   156 
155   // Z position of volumes from upstream to do    157   // Z position of volumes from upstream to downstream
156                                                   158 
157   fWindowPosZ = -(ztot + fWindowZ) * 0.5;      << 159   fWindowPosZ      =  -(ztot + fWindowZ)*0.5;
158   fGeneratorPosZ = fWindowPosZ - 0.5 * fWindow << 160   fGeneratorPosZ   =  fWindowPosZ - 0.5*fWindowZ - fDelta;
159                                                << 
160   fTargetVolumePosZ = -0.5 * (ztot - fTargetVo << 
161   fTarget1PosZ = -0.5 * (fTargetVolumeZ - fTar << 
162   fTarget2PosZ = fTarget1PosZ + 0.5 * (fTarget << 
163                                                   161 
164   fGasVolumePosZ = fTargetVolumePosZ + 0.5 * ( << 162   fTargetVolumePosZ=  -0.5*(ztot - fTargetVolumeZ);
165   fCheckVolumePosZ = fGasVolumePosZ + 0.5 * (f << 163   fTarget1PosZ     =  -0.5*(fTargetVolumeZ - fTarget1Z) + fDistanceVacuumTarget;
166   fMylarPosZ = fGasVolumePosZ + 0.5 * (fGasVol << 164   fTarget2PosZ     =  fTarget1PosZ + 0.5*(fTarget2Z + fTarget1Z);
                                                   >> 165 
                                                   >> 166   fGasVolumePosZ   =  fTargetVolumePosZ + 0.5*(fTargetVolumeZ + fGasVolumeZ);
                                                   >> 167   fCheckVolumePosZ =  fGasVolumePosZ + 0.5*(fGasVolumeZ + fCheckVolumeZ)
                                                   >> 168                                 +  fCheckShiftZ;
                                                   >> 169   fMylarPosZ =  fGasVolumePosZ + 0.5*(fGasVolumeZ + fMylarVolumeZ) + fDelta;
167                                                   170 
168   fPhantomPosZ = fGasVolumePosZ + 0.5 * (fGasV << 171   fPhantomPosZ     =  fGasVolumePosZ + 0.5*(fGasVolumeZ + fPhantomZ) + fAirZ;
169   fAbsorberPosZ = fAbsorberShiftZ - 0.5 * (fPh << 172   fAbsorberPosZ    =  fAbsorberShiftZ - 0.5*(fPhantomZ - fAbsorberZ);
170                                                   173 
171   fShiftZPh = fPhantomPosZ - 0.5 * fPhantomZ;  << 174   fShiftZPh = fPhantomPosZ-0.5*fPhantomZ;
172                                                   175 
173   DumpGeometryParameters();                       176   DumpGeometryParameters();
174 }                                                 177 }
175                                                   178 
176 //....oooOO0OOooo........oooOO0OOooo........oo    179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177                                                   180 
178 G4VPhysicalVolume* DetectorConstruction::Const    181 G4VPhysicalVolume* DetectorConstruction::Construct()
179 {                                                 182 {
180   InitialiseGeometryParameters();                 183   InitialiseGeometryParameters();
181                                                   184 
182   G4GeometryManager::GetInstance()->OpenGeomet    185   G4GeometryManager::GetInstance()->OpenGeometry();
183   G4PhysicalVolumeStore::GetInstance()->Clean(    186   G4PhysicalVolumeStore::GetInstance()->Clean();
184   G4LogicalVolumeStore::GetInstance()->Clean()    187   G4LogicalVolumeStore::GetInstance()->Clean();
185   G4SolidStore::GetInstance()->Clean();           188   G4SolidStore::GetInstance()->Clean();
186   //                                              189   //
187   // World                                        190   // World
188   //                                              191   //
189                                                   192 
190   G4Box* solidWorld = new G4Box("World", fWorl << 193   G4Box* solidWorld = new G4Box("World",fWorldXY,fWorldXY,fWorldZ);
191   G4LogicalVolume* logicWorld = new G4LogicalV << 194   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld,
192   G4VPhysicalVolume* physWorld =               << 195                                                     fWorldMaterial,"World");
193     new G4PVPlacement(0, G4ThreeVector(), "Wor << 196   G4VPhysicalVolume* physWorld = new G4PVPlacement(0,G4ThreeVector(),"World",
                                                   >> 197                                                    logicWorld,0,false,0);
194                                                   198 
195   // Be Vacuum window                             199   // Be Vacuum window
196   G4Tubs* solidWin = new G4Tubs("Window", 0.,  << 200   G4Tubs* solidWin = new G4Tubs("Window",0.,fTargetRadius*0.25,0.5*fWindowZ,
197   G4LogicalVolume* logicWin = new G4LogicalVol << 201                                 0.,twopi);
198   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 202   G4LogicalVolume* logicWin = new G4LogicalVolume(solidWin,
                                                   >> 203                                                   fWindowMaterial,"Window");
                                                   >> 204   new G4PVPlacement(0,G4ThreeVector(0.,0.,fWindowPosZ),"Window",logicWin,
                                                   >> 205                          physWorld,false,0);
199                                                   206 
200   // Target Volume                                207   // Target Volume
201   G4Tubs* solidTGVolume =                      << 208   G4Tubs* solidTGVolume = new G4Tubs("TargetVolume",0.,fTargetRadius,
202     new G4Tubs("TargetVolume", 0., fTargetRadi << 209                                      0.5*fTargetVolumeZ,0.,twopi);
203   G4LogicalVolume* logicTGVolume =             << 210   G4LogicalVolume* logicTGVolume = new G4LogicalVolume(solidTGVolume,
204     new G4LogicalVolume(solidTGVolume, fLightM << 211                                                        fLightMaterial,
205   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 212                                                        "TargetVolume");
206                     logicWorld, false, 0);     << 213   new G4PVPlacement(0,G4ThreeVector(0.,0.,fTargetVolumePosZ),
                                                   >> 214                          logicTGVolume,"TargetVolume",
                                                   >> 215                          logicWorld,false,0);
207                                                   216 
208   // Target 1                                     217   // Target 1
209   G4Tubs* solidTarget1 = new G4Tubs("Target1", << 218   G4Tubs* solidTarget1 = new G4Tubs("Target1",0.,fTargetRadius*0.5,
210   fLogicTarget1 = new G4LogicalVolume(solidTar << 219                                     0.5*fTarget1Z,0.,twopi);
211   fTarget1 = new G4PVPlacement(0, G4ThreeVecto << 220   fLogicTarget1 = new G4LogicalVolume(solidTarget1,fTarget1Material,"Target1");
212                                logicTGVolume,  << 221   fTarget1 = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget1PosZ),
                                                   >> 222                                fLogicTarget1,"Target1",
                                                   >> 223                                logicTGVolume,false,0);
213   //  fLogicTarget1->SetSensitiveDetector(fTar    224   //  fLogicTarget1->SetSensitiveDetector(fTargetSD);
214                                                   225 
215   // Target 2 (for combined targets)              226   // Target 2 (for combined targets)
216   G4Tubs* solidTarget2 = new G4Tubs("Target2", << 227   G4Tubs* solidTarget2 = new G4Tubs("Target2",0.,fTargetRadius*0.5,
217   fLogicTarget2 = new G4LogicalVolume(solidTar << 228                                     0.5*fTarget2Z,0.,twopi);
218   fTarget2 = new G4PVPlacement(0, G4ThreeVecto << 229   fLogicTarget2 = new G4LogicalVolume(solidTarget2,fTarget2Material,"Target2");
219                                logicTGVolume,  << 230   fTarget2 = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget2PosZ),
220                                                << 231                                fLogicTarget2,"Target2",
                                                   >> 232                                logicTGVolume,false,0);
                                                   >> 233   
221   //  fLogicTarget2->SetSensitiveDetector(fTar    234   //  fLogicTarget2->SetSensitiveDetector(fTargetSD);
222                                                   235 
223   // Gas Volume                                   236   // Gas Volume
224   G4Tubs* solidGasVolume =                     << 237   G4Tubs* solidGasVolume = new G4Tubs("GasVolume",0.,fGasVolumeRadius,
225     new G4Tubs("GasVolume", 0., fGasVolumeRadi << 238                                       0.5*fGasVolumeZ,0.,twopi);
226   G4LogicalVolume* logicGasVolume =            << 239   G4LogicalVolume* logicGasVolume = new G4LogicalVolume(solidGasVolume,
227     new G4LogicalVolume(solidGasVolume, fLight << 240                                                         fLightMaterial,
228   fGasVolume = new G4PVPlacement(0, G4ThreeVec << 241                                                         "GasVolume");
229                                  logicGasVolum << 242   fGasVolume = new G4PVPlacement(0,G4ThreeVector(0.,0.,fGasVolumePosZ),
                                                   >> 243                          "GasVolume",logicGasVolume,
                                                   >> 244                          physWorld,false,0);
230                                                   245 
231   // Mylar window                                 246   // Mylar window
232   G4Tubs* sMylarVolume = new G4Tubs("Mylar", 0 << 247   G4Tubs* sMylarVolume = new G4Tubs("Mylar",0.,fGasVolumeRadius,
233   G4LogicalVolume* lMylarVolume = new G4Logica << 248                                     0.5*fMylarVolumeZ,0.,twopi);
234   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 249   G4LogicalVolume* lMylarVolume = new G4LogicalVolume(sMylarVolume,
235                     0);                        << 250                                                       fMylar,"Mylar");
                                                   >> 251   new G4PVPlacement(0,G4ThreeVector(0.,0.,fMylarPosZ),"Mylar",lMylarVolume,
                                                   >> 252                          physWorld,false,0);
236                                                   253 
237   // Check Volume                                 254   // Check Volume
238   G4Tubs* solidCheckVolume =                   << 255   G4Tubs* solidCheckVolume = new G4Tubs("CheckVolume",0.,fGasVolumeRadius,
239     new G4Tubs("CheckVolume", 0., fGasVolumeRa << 256                                         0.5*fCheckVolumeZ,0.,twopi);
240   fLogicCheckVolume = new G4LogicalVolume(soli << 257   fLogicCheckVolume = new G4LogicalVolume(solidCheckVolume,
241   fCheckVolume = new G4PVPlacement(0, G4ThreeV << 258                                          fWorldMaterial,
242                                    fLogicCheck << 259                                          "CheckVolume");
                                                   >> 260   fCheckVolume = new G4PVPlacement(0,G4ThreeVector(0.,0.,fCheckVolumePosZ),
                                                   >> 261                          "CheckVolume",fLogicCheckVolume,
                                                   >> 262                          physWorld,false,0);
243   //  logicCheckVolume->SetSensitiveDetector(f    263   //  logicCheckVolume->SetSensitiveDetector(fCheckSD);
244                                                   264 
245   // Phantom                                      265   // Phantom
246   G4Box* solidPhantom = new G4Box("Phantom", f << 266   G4Box* solidPhantom = new G4Box("Phantom",fPhantomRadius,fPhantomRadius,
247   G4LogicalVolume* logicPhantom = new G4Logica << 267                                   0.5*fPhantomZ);
248   G4VPhysicalVolume* physPhantom = new G4PVPla << 268   G4LogicalVolume* logicPhantom = new G4LogicalVolume(solidPhantom,
249                                                << 269                                                       fAbsorberMaterial,
250                                                << 270                                                       "Phantom");
251   G4Tubs* solidPh = new G4Tubs("PhantomSD", 0. << 271   G4VPhysicalVolume* physPhantom = 
252   fLogicPh = new G4LogicalVolume(solidPh, fAbs << 272     new G4PVPlacement(0, G4ThreeVector(0.,0.,fPhantomPosZ),
253   fPhantom =                                   << 273                       "Phantom",logicPhantom,
254     new G4PVPlacement(0, G4ThreeVector(0., 0., << 274                       physWorld,false,0);
255   G4cout << "Phantom R= " << fAbsorberRadius < << 275 
                                                   >> 276   G4Tubs* solidPh = new G4Tubs("PhantomSD",0.,fAbsorberRadius,
                                                   >> 277                                0.5*fPhantomZ,0.,twopi);
                                                   >> 278   fLogicPh = new G4LogicalVolume(solidPh,
                                                   >> 279                                  fAbsorberMaterial,"PhantomSD");
                                                   >> 280   fPhantom = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),
                                                   >> 281                                                 "Phantom",fLogicPh,
                                                   >> 282                                                 physPhantom,false,0);
                                                   >> 283   G4cout << "Phantom R= " << fAbsorberRadius << " dz= " << 0.5*fPhantomZ 
                                                   >> 284          << G4endl;
256                                                   285 
257   // Sensitive Absorber                           286   // Sensitive Absorber
258   G4double absWidth = 0.5 * fAbsorberZ;        << 287   G4double absWidth = 0.5*fAbsorberZ;
259   G4Tubs* solidAbsorber = new G4Tubs("Absorber << 288   G4Tubs* solidAbsorber = new G4Tubs("Absorber",0.,fAbsorberRadius,absWidth,
260   fLogicAbsorber = new G4LogicalVolume(solidAb << 289                                      0.,twopi);
261   G4cout << "Absorber R= " << fAbsorberRadius  << 290   fLogicAbsorber = new G4LogicalVolume(solidAbsorber,
262          << G4endl;                            << 291                                        fAbsorberMaterial,
                                                   >> 292                                        "Absorber");
                                                   >> 293   G4cout << "Absorber R= " << fAbsorberRadius << " dz= " << absWidth 
                                                   >> 294          << " posZ= " << fAbsorberPosZ<< G4endl;
263                                                   295 
264   new G4PVPlacement(0, G4ThreeVector(0., 0., f << 296   new G4PVPlacement(0,G4ThreeVector(0.,0.,fAbsorberPosZ),"Absorber",
265                     false, 0);                 << 297                          fLogicAbsorber,fPhantom,false,0);
266                                                   298 
267   G4double stepR = fAbsorberRadius / (G4double << 299   G4double stepR = fAbsorberRadius/(G4double)fNumR;
268                                                   300 
269   G4double r1 = 0.0;                              301   G4double r1 = 0.0;
270   G4double r2 = 0.0;                              302   G4double r2 = 0.0;
271   G4Tubs* solidRing;                              303   G4Tubs* solidRing;
272                                                   304 
273   G4VisAttributes* VisAtt_ring = new G4VisAttr << 305   G4VisAttributes* VisAtt_ring = 
274   for (G4int k = 0; k < fNumR; k++) {          << 306                     new G4VisAttributes(G4VisAttributes::GetInvisible());
                                                   >> 307   for(G4int k=0; k<fNumR; k++) {
275     r2 = r1 + stepR;                              308     r2 = r1 + stepR;
276     if (k == fNumR - 1) r2 = fAbsorberRadius;  << 309     if(k == fNumR-1) r2 = fAbsorberRadius;
277     //    G4cout << "New ring r1= " << r1 << " << 310     //    G4cout << "New ring r1= " << r1 << " r2= " << r2 
278     //  << " dz= " << absWidth << G4endl;         311     //  << " dz= " << absWidth << G4endl;
279     solidRing = new G4Tubs("Ring", r1, r2, abs << 312     solidRing = new G4Tubs("Ring",r1,r2,absWidth,0.,twopi);
280     G4LogicalVolume* logicRing = new G4Logical << 313     G4LogicalVolume* logicRing = new G4LogicalVolume(solidRing,
                                                   >> 314                                                      fAbsorberMaterial,"Ring");
281     //    logicRing->SetSensitiveDetector(fPha    315     //    logicRing->SetSensitiveDetector(fPhantomSD);
282     logicRing->SetVisAttributes(VisAtt_ring);     316     logicRing->SetVisAttributes(VisAtt_ring);
283     fLogicRing.push_back(logicRing);              317     fLogicRing.push_back(logicRing);
284     new G4PVPlacement(0, G4ThreeVector(0., 0., << 318     new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),logicRing,"Ring",
                                                   >> 319                            fLogicAbsorber,false,k);
285     r1 = r2;                                      320     r1 = r2;
286   }                                               321   }
287                                                   322 
288   //                                              323   //
289   // Visualization attributes                     324   // Visualization attributes
290   //                                              325   //
291   G4VisAttributes* VisAtt = 0;                    326   G4VisAttributes* VisAtt = 0;
292   VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 327   VisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
293   VisAtt->SetVisibility(true);                    328   VisAtt->SetVisibility(true);
294   fLogicAbsorber->SetVisAttributes(VisAtt);       329   fLogicAbsorber->SetVisAttributes(VisAtt);
295                                                   330 
296   VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 331   VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,2.0));
297   VisAtt->SetVisibility(true);                    332   VisAtt->SetVisibility(true);
298   logicPhantom->SetVisAttributes(VisAtt);         333   logicPhantom->SetVisAttributes(VisAtt);
299                                                   334 
300   VisAtt = new G4VisAttributes(G4Colour(1.0, 0 << 335   VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,2.0));
301   VisAtt->SetVisibility(true);                    336   VisAtt->SetVisibility(true);
302   fLogicPh->SetVisAttributes(VisAtt);             337   fLogicPh->SetVisAttributes(VisAtt);
303                                                   338 
304   VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 339   VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0));
305   VisAtt->SetVisibility(true);                    340   VisAtt->SetVisibility(true);
306   fLogicAbsorber->SetVisAttributes(VisAtt);       341   fLogicAbsorber->SetVisAttributes(VisAtt);
307                                                   342 
308   VisAtt = new G4VisAttributes(G4Colour(0.1, 1 << 343   VisAtt= new G4VisAttributes(G4Colour(0.1,1.0,2.0));
309   VisAtt->SetVisibility(true);                    344   VisAtt->SetVisibility(true);
310   logicWorld->SetVisAttributes(VisAtt);           345   logicWorld->SetVisAttributes(VisAtt);
311                                                   346 
312   VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 347   VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0));
313   VisAtt->SetVisibility(true);                    348   VisAtt->SetVisibility(true);
314   logicGasVolume->SetVisAttributes(VisAtt);       349   logicGasVolume->SetVisAttributes(VisAtt);
315                                                   350 
316   VisAtt = new G4VisAttributes(G4Colour(0.0, 0 << 351   VisAtt= new G4VisAttributes(G4Colour(0.0,0.5,1.0));
317   VisAtt->SetVisibility(true);                    352   VisAtt->SetVisibility(true);
318   fLogicTarget1->SetVisAttributes(VisAtt);        353   fLogicTarget1->SetVisAttributes(VisAtt);
319   fLogicTarget2->SetVisAttributes(VisAtt);        354   fLogicTarget2->SetVisAttributes(VisAtt);
320   logicTGVolume->SetVisAttributes(VisAtt);        355   logicTGVolume->SetVisAttributes(VisAtt);
321                                                   356 
322   return physWorld;                               357   return physWorld;
323 }                                                 358 }
324                                                   359 
                                                   >> 360 
325 void DetectorConstruction::ConstructSDandField    361 void DetectorConstruction::ConstructSDandField()
326 {                                                 362 {
327   static G4ThreadLocal G4bool initialized = fa    363   static G4ThreadLocal G4bool initialized = false;
328   if (!initialized) {                          << 364   if ( ! initialized ) {
329     // Prepare sensitive detectors                365     // Prepare sensitive detectors
330     CheckVolumeSD* fCheckSD = new CheckVolumeS    366     CheckVolumeSD* fCheckSD = new CheckVolumeSD("checkSD");
331     (G4SDManager::GetSDMpointer())->AddNewDete << 367     (G4SDManager::GetSDMpointer())->AddNewDetector( fCheckSD );
332     fLogicCheckVolume->SetSensitiveDetector(fC    368     fLogicCheckVolume->SetSensitiveDetector(fCheckSD);
333                                                << 369     
334     TargetSD* fTargetSD = new TargetSD("target    370     TargetSD* fTargetSD = new TargetSD("targetSD");
335     (G4SDManager::GetSDMpointer())->AddNewDete << 371     (G4SDManager::GetSDMpointer())->AddNewDetector( fTargetSD );
336     fLogicTarget1->SetSensitiveDetector(fTarge    372     fLogicTarget1->SetSensitiveDetector(fTargetSD);
337     fLogicTarget2->SetSensitiveDetector(fTarge    373     fLogicTarget2->SetSensitiveDetector(fTargetSD);
338                                                   374 
339     PhantomSD* fPhantomSD = new PhantomSD("pha    375     PhantomSD* fPhantomSD = new PhantomSD("phantomSD");
340     (G4SDManager::GetSDMpointer())->AddNewDete << 376     (G4SDManager::GetSDMpointer())->AddNewDetector( fPhantomSD );
341     fPhantomSD->SetShiftZ(fShiftZPh);             377     fPhantomSD->SetShiftZ(fShiftZPh);
342     for (auto& v : fLogicRing)                 << 378     for(auto& v : fLogicRing)
343       v->SetSensitiveDetector(fPhantomSD);        379       v->SetSensitiveDetector(fPhantomSD);
344     fLogicPh->SetSensitiveDetector(fPhantomSD)    380     fLogicPh->SetSensitiveDetector(fPhantomSD);
345     fLogicAbsorber->SetSensitiveDetector(fPhan    381     fLogicAbsorber->SetSensitiveDetector(fPhantomSD);
346     initialized = true;                        << 382     initialized=true;
347   }                                               383   }
348 }                                                 384 }
349                                                   385 
350 //....oooOO0OOooo........oooOO0OOooo........oo    386 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
351                                                   387 
352 void DetectorConstruction::SetTarget1Material(    388 void DetectorConstruction::SetTarget1Material(const G4String& mat)
353 {                                                 389 {
354   // search the material by its name              390   // search the material by its name
355   G4Material* pttoMaterial = G4NistManager::In << 391   G4Material* pttoMaterial = 
356   if (!pttoMaterial) {                         << 392     G4NistManager::Instance()->FindOrBuildMaterial(mat);
                                                   >> 393   if(!pttoMaterial) {
357     G4cout << "Material " << mat << " is not f    394     G4cout << "Material " << mat << " is not found out!" << G4endl;
358   }                                            << 395   } else if (pttoMaterial != fTarget1Material) {
359   else if (pttoMaterial != fTarget1Material) { << 
360     G4cout << "New target1 material " << mat <    396     G4cout << "New target1 material " << mat << G4endl;
361     if (fLogicTarget1) {                       << 397     if(fLogicTarget1) { fLogicTarget1->SetMaterial(fTarget1Material); }
362       fLogicTarget1->SetMaterial(fTarget1Mater << 
363     }                                          << 
364     G4RunManager::GetRunManager()->PhysicsHasB    398     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
365   }                                               399   }
366 }                                                 400 }
367                                                   401 
368 //....oooOO0OOooo........oooOO0OOooo........oo    402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
369                                                   403 
370 void DetectorConstruction::SetTarget2Material(    404 void DetectorConstruction::SetTarget2Material(const G4String& mat)
371 {                                                 405 {
372   // search the material by its name              406   // search the material by its name
373   G4Material* pttoMaterial = G4NistManager::In << 407   G4Material* pttoMaterial = 
                                                   >> 408     G4NistManager::Instance()->FindOrBuildMaterial(mat);
374                                                   409 
375   if (!pttoMaterial) {                         << 410   if(!pttoMaterial) {
376     G4cout << "Material " << mat << " is not f    411     G4cout << "Material " << mat << " is not found out!" << G4endl;
377   }                                            << 412   } else if (pttoMaterial != fTarget2Material) {
378   else if (pttoMaterial != fTarget2Material) { << 
379     fTarget2Material = pttoMaterial;              413     fTarget2Material = pttoMaterial;
380     G4cout << "New target2 material " << mat <    414     G4cout << "New target2 material " << mat << G4endl;
381     if (fLogicTarget2) {                       << 415     if(fLogicTarget2) { fLogicTarget2->SetMaterial(fTarget2Material); }
382       fLogicTarget2->SetMaterial(fTarget2Mater << 
383     }                                          << 
384     G4RunManager::GetRunManager()->PhysicsHasB    416     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
385   }                                            << 417   } 
386 }                                                 418 }
387                                                   419 
388 //....oooOO0OOooo........oooOO0OOooo........oo    420 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
389                                                   421 
390 void DetectorConstruction::DumpGeometryParamet    422 void DetectorConstruction::DumpGeometryParameters()
391 {                                                 423 {
                                                   >> 424 
392   G4cout << "=================================    425   G4cout << "===================================================" << G4endl;
393   G4cout << "#           GammaTherapy Geometry    426   G4cout << "#           GammaTherapy Geometry                 #" << G4endl;
394   G4cout << "=================================    427   G4cout << "===================================================" << G4endl;
395   G4cout << "  World   width= " << fWorldZ / m << 428   G4cout << "  World   width= " << fWorldZ/mm << " mm " << G4endl;
396   G4cout << "  Window  width= " << fWindowZ /  << 429   G4cout << "  Window  width= " << fWindowZ/mm << " mm    position = "
397          << " mm:" << G4endl;                  << 430                                 << fWindowPosZ/mm << " mm:" << G4endl;
398   G4cout << "  TargetV width= " << fTargetVolu << 431   G4cout << "  TargetV width= " << fTargetVolumeZ/mm << " mm  position = "
399          << " mm  position = " << fTargetVolum << 432                                 << fTargetVolumePosZ/mm << " mm:" << G4endl;
400   G4cout << "  Target1 width= " << fTarget1Z / << 433   G4cout << "  Target1 width= " << fTarget1Z/mm << " mm       position = "
401          << " mm:" << G4endl;                  << 434                                 << fTarget1PosZ/mm << " mm:" << G4endl;
402   G4cout << "  Target2 width= " << fTarget2Z / << 435   G4cout << "  Target2 width= " << fTarget2Z/mm << " mm       position = "
403          << " mm:" << G4endl;                  << 436                                 << fTarget2PosZ/mm << " mm:" << G4endl;
404   G4cout << "  Gas     width= " << fGasVolumeZ << 437   G4cout << "  Gas     width= " << fGasVolumeZ/mm << " mm     position = "
405          << " mm:" << G4endl;                  << 438                                 << fGasVolumePosZ/mm << " mm:" << G4endl;
406   G4cout << "  Mylar   width= " << fMylarVolum << 439   G4cout << "  Mylar   width= " << fMylarVolumeZ/mm << " mm    position = "
407          << " mm:" << G4endl;                  << 440                                 << fMylarPosZ/mm << " mm:" << G4endl;
408   G4cout << "  Check   width= " << fCheckVolum << 441   G4cout << "  Check   width= " << fCheckVolumeZ/mm << " mm     position = "
409          << " mm     position = " << fCheckVol << 442                                 << fCheckVolumePosZ/mm << " mm:" << G4endl;
410   G4cout << "  Air     width= " << fAirZ / mm  << 443   G4cout << "  Air     width= " << fAirZ/mm << " mm " << G4endl;
411   G4cout << "  Phantom width= " << fPhantomZ / << 444   G4cout << "  Phantom width= " << fPhantomZ/mm << " mm     position = "
412          << " mm:" << G4endl;                  << 445                                 << fPhantomPosZ/mm << " mm:" << G4endl;
413   G4cout << "  Absorb  width= " << fAbsorberZ  << 446   G4cout << "  Absorb  width= " << fAbsorberZ/mm << " mm       position = "
414          << " mm:" << G4endl;                  << 447                                 << fAbsorberPosZ/mm << " mm:" << G4endl;
415   G4cout << "  Absorb  shift= " << fShiftZPh / << 448   G4cout << "  Absorb  shift= " << fShiftZPh/mm << " mm " << G4endl;
416   G4cout << "  Target1        " << fTarget1Mat    449   G4cout << "  Target1        " << fTarget1Material->GetName() << G4endl;
417   G4cout << "  Target2        " << fTarget2Mat    450   G4cout << "  Target2        " << fTarget2Material->GetName() << G4endl;
418   G4cout << "  Phantom        " << fAbsorberMa    451   G4cout << "  Phantom        " << fAbsorberMaterial->GetName() << G4endl;
419   G4cout << "=================================    452   G4cout << "===================================================" << G4endl;
                                                   >> 453 
420 }                                                 454 }
421                                                   455