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


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