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 ] [ 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/dna/dnaphysics/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/medical/dna/dnaphysics/src/DetectorConstruction.cc (Version 10.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // This example is provided by the Geant4-DNA      26 // This example is provided by the Geant4-DNA collaboration
 27 // Any report or published results obtained us <<  27 // Any report or published results obtained using the Geant4-DNA software 
 28 // shall cite the following Geant4-DNA collabo <<  28 // shall cite the following Geant4-DNA collaboration publication:
 29 // Med. Phys. 45 (2018) e722-e739              << 
 30 // Phys. Med. 31 (2015) 861-874                << 
 31 // Med. Phys. 37 (2010) 4692-4708                  29 // Med. Phys. 37 (2010) 4692-4708
 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) << 
 33 //                                             << 
 34 // The Geant4-DNA web site is available at htt     30 // The Geant4-DNA web site is available at http://geant4-dna.org
 35 //                                                 31 //
                                                   >>  32 // $Id$
                                                   >>  33 //
 36 /// \file DetectorConstruction.cc                  34 /// \file DetectorConstruction.cc
 37 /// \brief Implementation of the DetectorConst     35 /// \brief Implementation of the DetectorConstruction class
 38                                                    36 
 39 #include "DetectorConstruction.hh"                 37 #include "DetectorConstruction.hh"
 40 #include "DetectorMessenger.hh"                    38 #include "DetectorMessenger.hh"
 41 #include "PhysicsList.hh"                      << 
 42                                                    39 
 43 #include "G4LogicalVolumeStore.hh"             << 
 44 #include "G4NistManager.hh"                    << 
 45 #include "G4RunManager.hh"                     << 
 46 #include "G4SystemOfUnits.hh"                      40 #include "G4SystemOfUnits.hh"
 47 #include "G4UserLimits.hh"                         41 #include "G4UserLimits.hh"
                                                   >>  42 #include "G4NistManager.hh"
                                                   >>  43 #include "G4RunManager.hh"
                                                   >>  44 #include "G4LogicalVolumeStore.hh"
 48                                                    45 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 50                                                    47 
 51 DetectorConstruction::DetectorConstruction(Phy <<  48 DetectorConstruction::DetectorConstruction() :
 52   : G4VUserDetectorConstruction(),             <<  49   G4VUserDetectorConstruction(), fpWaterMaterial(nullptr),
 53     fpWaterMaterial(nullptr),                  <<  50   fLogicWorld(nullptr),fPhysiWorld(nullptr)
 54     fLogicWorld(nullptr),                      << 
 55     fPhysiWorld(nullptr)                       << 
 56 {                                                  51 {
 57   // Create commands for interactive definitio <<  52   // create commands for interactive definition of the detector  
 58   fDetectorMessenger = new DetectorMessenger(t <<  53   fDetectorMessenger = new DetectorMessenger(this);
 59                                                << 
 60   // Default values                            << 
 61   //                                           << 
 62   // World size                                << 
 63   fWorldSize = 100 *um;                        << 
 64   // and material                              << 
 65   G4NistManager* man = G4NistManager::Instance << 
 66   G4Material* H2O = man->FindOrBuildMaterial(" << 
 67   fpWaterMaterial = H2O;                       << 
 68 }                                                  54 }
 69                                                    55 
 70 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 71                                                    57 
 72 DetectorConstruction::~DetectorConstruction()      58 DetectorConstruction::~DetectorConstruction()
 73 {                                                  59 {
 74   delete fDetectorMessenger;                       60   delete fDetectorMessenger;
 75 }                                                  61 }
 76                                                    62 
 77 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 78                                                    64 
                                                   >>  65 G4VPhysicalVolume* DetectorConstruction::Construct()
                                                   >>  66 
                                                   >>  67 {
                                                   >>  68   if(fPhysiWorld) { return fPhysiWorld; }
                                                   >>  69   DefineMaterials();
                                                   >>  70   return ConstructDetector();
                                                   >>  71 }
                                                   >>  72 
                                                   >>  73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  74 
 79 void DetectorConstruction::DefineMaterials()       75 void DetectorConstruction::DefineMaterials()
 80 {                                                  76 {
                                                   >>  77 
 81   // Water is defined from NIST material datab     78   // Water is defined from NIST material database
 82   G4NistManager* man = G4NistManager::Instance <<  79   G4NistManager * man = G4NistManager::Instance();
 83                                                    80 
 84   G4Material* H2O = man->FindOrBuildMaterial(" <<  81   G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
 85                                                    82 
 86   /*                                               83   /*
 87    If one wishes to test other density value f     84    If one wishes to test other density value for water material,
 88    one should use instead:                         85    one should use instead:
 89    G4Material * H2O = man->BuildMaterialWithNe     86    G4Material * H2O = man->BuildMaterialWithNewDensity("G4_WATER_MODIFIED",
 90    "G4_WATER",1.100*g/cm3);                        87    "G4_WATER",1.100*g/cm3);
 91                                                    88 
 92    Note: any string for "G4_WATER_MODIFIED" pa     89    Note: any string for "G4_WATER_MODIFIED" parameter is accepted
 93    and "G4_WATER" parameter should not be chan     90    and "G4_WATER" parameter should not be changed
 94    Both materials are created and can be selec     91    Both materials are created and can be selected from dna.mac
 95    */                                              92    */
 96   fpWaterMaterial = H2O;                           93   fpWaterMaterial = H2O;
 97                                                    94 
 98   // G4cout << "-> Density of water material ( <<  95   //G4cout << "-> Density of water material (g/cm3)="
 99   //  << fpWaterMaterial->GetDensity()/(g/cm/c <<  96   // << fpWaterMaterial->GetDensity()/(g/cm/cm/cm) << G4endl;
100                                                    97 
101   G4cout << *(G4Material::GetMaterialTable())      98   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
102 }                                                  99 }
103                                                   100 
104 //....oooOO0OOooo........oooOO0OOooo........oo << 
105                                                << 
106 G4Material*                                    << 
107 DetectorConstruction::MaterialWithDensity(G4St << 
108 {                                              << 
109   // Water is defined from NIST material datab << 
110   G4NistManager* man = G4NistManager::Instance << 
111                                                << 
112   G4Material * material = man->BuildMaterialWi << 
113    "G4_WATER", density);                       << 
114                                                << 
115    G4cout << "-> Density of water_modified mat << 
116     << material->GetDensity()/(g/cm/cm/cm) <<  << 
117                                                << 
118  return material;                              << 
119 }                                              << 
120                                                << 
121 //....oooOO0OOooo........oooOO0OOooo........oo    101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
122                                                << 102 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
123 G4VPhysicalVolume* DetectorConstruction::Const << 
124 {                                                 103 {
125   if (fPhysiWorld) {                           << 104   // WORLD VOLUME
126     return fPhysiWorld;                        << 105   G4double worldSizeX = 100 * micrometer;
127   }                                            << 
128                                                << 
129   // World volume                              << 
130   G4double worldSizeX = fWorldSize;            << 
131   G4double worldSizeY = worldSizeX;               106   G4double worldSizeY = worldSizeX;
132   G4double worldSizeZ = worldSizeX;               107   G4double worldSizeZ = worldSizeX;
133                                                   108 
134   G4Box* solidWorld = new G4Box("World",  // i << 109   G4Box* solidWorld = new G4Box("World", //its name
135                                 worldSizeX / 2 << 110       worldSizeX / 2, worldSizeY / 2, worldSizeZ / 2); //its size
136                                 // its size    << 111 
137                                                << 112   fLogicWorld = new G4LogicalVolume(solidWorld, //its solid
138   fLogicWorld = new G4LogicalVolume(solidWorld << 113       fpWaterMaterial, //its material
139                                     fpWaterMat << 114       "World"); //its name
140                                     "World");  << 115 
141                                                << 116   fPhysiWorld = new G4PVPlacement(0, //no rotation
142   fPhysiWorld = new G4PVPlacement(0,  // no ro << 117       G4ThreeVector(), //at (0,0,0)
143                                   G4ThreeVecto << 118       "World", //its name
144                                   "World",  // << 119       fLogicWorld, //its logical volume
145                                   fLogicWorld, << 120       0, //its mother  volume
146                                   0,  // its m << 121       false, //no boolean operation
147                                   false,  // n << 122       0); //copy number
148                                   0);  // copy << 
149                                                   123 
150   // Visualization attributes - white             124   // Visualization attributes - white
151   G4VisAttributes* worldVisAtt = new G4VisAttr    125   G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
152   worldVisAtt->SetVisibility(true);               126   worldVisAtt->SetVisibility(true);
153   fLogicWorld->SetVisAttributes(worldVisAtt);     127   fLogicWorld->SetVisAttributes(worldVisAtt);
154                                                   128 
155   G4VisAttributes* worldVisAtt1 = new G4VisAtt    129   G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
156   worldVisAtt1->SetVisibility(true);              130   worldVisAtt1->SetVisibility(true);
157                                                   131 
                                                   >> 132   // 
158   // Shows how to introduce a 20 eV tracking c    133   // Shows how to introduce a 20 eV tracking cut
159   // logicWorld->SetUserLimits(new G4UserLimit << 134   //
                                                   >> 135   //logicWorld->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,20*eV));
160                                                   136 
161   return fPhysiWorld;                             137   return fPhysiWorld;
162 }                                                 138 }
163                                                   139 
164 //....oooOO0OOooo........oooOO0OOooo........oo    140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165                                                   141 
166 void DetectorConstruction::SetMaterial(const G << 142 void DetectorConstruction::SetMaterial(G4String materialChoice)
167 {                                                 143 {
168   // Search the material by its name           << 144   // Search the material by its name   
169   G4Material* pttoMaterial =                   << 145   G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(
170     G4NistManager::Instance()->FindOrBuildMate << 146       materialChoice);
171                                                   147 
172   if (pttoMaterial) {                          << 148   if (pttoMaterial)
                                                   >> 149   {
173     fpWaterMaterial = pttoMaterial;               150     fpWaterMaterial = pttoMaterial;
174     if (fLogicWorld) {                         << 151     if(fLogicWorld) {
175       fLogicWorld->SetMaterial(fpWaterMaterial    152       fLogicWorld->SetMaterial(fpWaterMaterial);
176     }                                             153     }
177     G4RunManager::GetRunManager()->GeometryHas    154     G4RunManager::GetRunManager()->GeometryHasBeenModified();
178   }                                               155   }
179 }                                              << 
180                                                << 
181 //....oooOO0OOooo........oooOO0OOooo........oo << 
182                                                << 
183 void DetectorConstruction::SetSize(G4double va << 
184 {                                              << 
185   fWorldSize = value;                          << 
186   G4RunManager::GetRunManager()->ReinitializeG << 
187 }                                                 156 }
188                                                   157