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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 11.2.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 // 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 //
 36 /// \file DetectorConstruction.cc                  33 /// \file DetectorConstruction.cc
 37 /// \brief Implementation of the DetectorConst     34 /// \brief Implementation of the DetectorConstruction class
 38                                                    35 
 39 #include "DetectorConstruction.hh"                 36 #include "DetectorConstruction.hh"
 40 #include "DetectorMessenger.hh"                    37 #include "DetectorMessenger.hh"
 41 #include "PhysicsList.hh"                      << 
 42                                                    38 
 43 #include "G4LogicalVolumeStore.hh"             << 
 44 #include "G4NistManager.hh"                    << 
 45 #include "G4RunManager.hh"                     << 
 46 #include "G4SystemOfUnits.hh"                      39 #include "G4SystemOfUnits.hh"
 47 #include "G4UserLimits.hh"                         40 #include "G4UserLimits.hh"
                                                   >>  41 #include "G4NistManager.hh"
                                                   >>  42 #include "G4RunManager.hh"
                                                   >>  43 #include "G4LogicalVolumeStore.hh"
                                                   >>  44 #include "PhysicsList.hh"
 48                                                    45 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 50                                                    47 
 51 DetectorConstruction::DetectorConstruction(Phy <<  48 DetectorConstruction::DetectorConstruction(PhysicsList* ptr) :
 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, ptr);
 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 
 79 void DetectorConstruction::DefineMaterials()       65 void DetectorConstruction::DefineMaterials()
 80 {                                                  66 {
                                                   >>  67 
 81   // Water is defined from NIST material datab     68   // Water is defined from NIST material database
 82   G4NistManager* man = G4NistManager::Instance <<  69   G4NistManager * man = G4NistManager::Instance();
 83                                                    70 
 84   G4Material* H2O = man->FindOrBuildMaterial(" <<  71   G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
 85                                                    72 
 86   /*                                               73   /*
 87    If one wishes to test other density value f     74    If one wishes to test other density value for water material,
 88    one should use instead:                         75    one should use instead:
 89    G4Material * H2O = man->BuildMaterialWithNe     76    G4Material * H2O = man->BuildMaterialWithNewDensity("G4_WATER_MODIFIED",
 90    "G4_WATER",1.100*g/cm3);                        77    "G4_WATER",1.100*g/cm3);
 91                                                    78 
 92    Note: any string for "G4_WATER_MODIFIED" pa     79    Note: any string for "G4_WATER_MODIFIED" parameter is accepted
 93    and "G4_WATER" parameter should not be chan     80    and "G4_WATER" parameter should not be changed
 94    Both materials are created and can be selec     81    Both materials are created and can be selected from dna.mac
 95    */                                              82    */
 96   fpWaterMaterial = H2O;                           83   fpWaterMaterial = H2O;
 97                                                    84 
 98   // G4cout << "-> Density of water material ( <<  85   //G4cout << "-> Density of water material (g/cm3)="
 99   //  << fpWaterMaterial->GetDensity()/(g/cm/c <<  86   // << fpWaterMaterial->GetDensity()/(g/cm/cm/cm) << G4endl;
100                                                    87 
101   G4cout << *(G4Material::GetMaterialTable())      88   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
102 }                                                  89 }
103                                                    90 
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     91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
122                                                    92 
123 G4VPhysicalVolume* DetectorConstruction::Const     93 G4VPhysicalVolume* DetectorConstruction::Construct()
124 {                                                  94 {
125   if (fPhysiWorld) {                           <<  95   if(fPhysiWorld) { return fPhysiWorld; }
126     return fPhysiWorld;                        <<  96   DefineMaterials();
127   }                                            << 
128                                                    97 
129   // World volume                              <<  98   // WORLD VOLUME
130   G4double worldSizeX = fWorldSize;            <<  99   G4double worldSizeX = 100 * micrometer;
131   G4double worldSizeY = worldSizeX;               100   G4double worldSizeY = worldSizeX;
132   G4double worldSizeZ = worldSizeX;               101   G4double worldSizeZ = worldSizeX;
133                                                   102 
134   G4Box* solidWorld = new G4Box("World",  // i << 103   G4Box* solidWorld = new G4Box("World", //its name
135                                 worldSizeX / 2 << 104       worldSizeX / 2, worldSizeY / 2, worldSizeZ / 2); //its size
136                                 // its size    << 105 
137                                                << 106   fLogicWorld = new G4LogicalVolume(solidWorld, //its solid
138   fLogicWorld = new G4LogicalVolume(solidWorld << 107       fpWaterMaterial, //its material
139                                     fpWaterMat << 108       "World"); //its name
140                                     "World");  << 109 
141                                                << 110   fPhysiWorld = new G4PVPlacement(0, //no rotation
142   fPhysiWorld = new G4PVPlacement(0,  // no ro << 111       G4ThreeVector(), //at (0,0,0)
143                                   G4ThreeVecto << 112       "World", //its name
144                                   "World",  // << 113       fLogicWorld, //its logical volume
145                                   fLogicWorld, << 114       0, //its mother  volume
146                                   0,  // its m << 115       false, //no boolean operation
147                                   false,  // n << 116       0); //copy number
148                                   0);  // copy << 
149                                                   117 
150   // Visualization attributes - white             118   // Visualization attributes - white
151   G4VisAttributes* worldVisAtt = new G4VisAttr    119   G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
152   worldVisAtt->SetVisibility(true);               120   worldVisAtt->SetVisibility(true);
153   fLogicWorld->SetVisAttributes(worldVisAtt);     121   fLogicWorld->SetVisAttributes(worldVisAtt);
154                                                   122 
155   G4VisAttributes* worldVisAtt1 = new G4VisAtt    123   G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
156   worldVisAtt1->SetVisibility(true);              124   worldVisAtt1->SetVisibility(true);
157                                                   125 
                                                   >> 126   // 
158   // Shows how to introduce a 20 eV tracking c    127   // Shows how to introduce a 20 eV tracking cut
159   // logicWorld->SetUserLimits(new G4UserLimit << 128   //
                                                   >> 129   //logicWorld->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,20*eV));
160                                                   130 
161   return fPhysiWorld;                             131   return fPhysiWorld;
162 }                                                 132 }
163                                                   133 
164 //....oooOO0OOooo........oooOO0OOooo........oo    134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165                                                   135 
166 void DetectorConstruction::SetMaterial(const G    136 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
167 {                                                 137 {
168   // Search the material by its name           << 138   // Search the material by its name   
169   G4Material* pttoMaterial =                   << 139   G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(
170     G4NistManager::Instance()->FindOrBuildMate << 140       materialChoice);
171                                                   141 
172   if (pttoMaterial) {                          << 142   if (pttoMaterial)
                                                   >> 143   {
173     fpWaterMaterial = pttoMaterial;               144     fpWaterMaterial = pttoMaterial;
174     if (fLogicWorld) {                         << 145     if(fLogicWorld) {
175       fLogicWorld->SetMaterial(fpWaterMaterial    146       fLogicWorld->SetMaterial(fpWaterMaterial);
176     }                                             147     }
177     G4RunManager::GetRunManager()->GeometryHas    148     G4RunManager::GetRunManager()->GeometryHasBeenModified();
178   }                                               149   }
179 }                                              << 
180                                                << 
181 //....oooOO0OOooo........oooOO0OOooo........oo << 
182                                                << 
183 void DetectorConstruction::SetSize(G4double va << 
184 {                                              << 
185   fWorldSize = value;                          << 
186   G4RunManager::GetRunManager()->ReinitializeG << 
187 }                                                 150 }
188                                                   151