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


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