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 11.1.1)


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