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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/radioactivedecay/Activation/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/radioactivedecay/Activation/src/DetectorConstruction.cc (Version 10.4.p3)


  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 /// \file DetectorConstruction.cc                  26 /// \file DetectorConstruction.cc
 27 /// \brief Implementation of the DetectorConst     27 /// \brief Implementation of the DetectorConstruction class
 28 //                                                 28 //
                                                   >>  29 // $Id: DetectorConstruction.cc 70755 2013-06-05 12:17:48Z ihrivnac $
 29 //                                                 30 //
                                                   >>  31 
 30 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32                                                    34 
 33 #include "DetectorConstruction.hh"                 35 #include "DetectorConstruction.hh"
 34                                                << 
 35 #include "DetectorMessenger.hh"                    36 #include "DetectorMessenger.hh"
                                                   >>  37 #include "G4Material.hh"
                                                   >>  38 #include "G4NistManager.hh"
 36                                                    39 
 37 #include "G4Box.hh"                                40 #include "G4Box.hh"
 38 #include "G4GeometryManager.hh"                << 
 39 #include "G4LogicalVolume.hh"                      41 #include "G4LogicalVolume.hh"
 40 #include "G4LogicalVolumeStore.hh"             << 
 41 #include "G4Material.hh"                       << 
 42 #include "G4NistManager.hh"                    << 
 43 #include "G4PVPlacement.hh"                        42 #include "G4PVPlacement.hh"
 44 #include "G4PhysicalConstants.hh"              <<  43 
                                                   >>  44 #include "G4GeometryManager.hh"
 45 #include "G4PhysicalVolumeStore.hh"                45 #include "G4PhysicalVolumeStore.hh"
 46 #include "G4RunManager.hh"                     <<  46 #include "G4LogicalVolumeStore.hh"
 47 #include "G4SolidStore.hh"                         47 #include "G4SolidStore.hh"
                                                   >>  48 #include "G4RunManager.hh"
                                                   >>  49 
 48 #include "G4SystemOfUnits.hh"                      50 #include "G4SystemOfUnits.hh"
                                                   >>  51 #include "G4PhysicalConstants.hh"
 49 #include "G4UnitsTable.hh"                         52 #include "G4UnitsTable.hh"
 50                                                    53 
 51 //....oooOO0OOooo........oooOO0OOooo........oo     54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 52                                                    55 
 53 DetectorConstruction::DetectorConstruction()       56 DetectorConstruction::DetectorConstruction()
                                                   >>  57 :G4VUserDetectorConstruction(),
                                                   >>  58  fAbsorMaterial(nullptr), fLAbsor(nullptr), fWorldMaterial(nullptr),
                                                   >>  59  fWorldVolume(nullptr), fDetectorMessenger(nullptr)
 54 {                                                  60 {
 55   // default geometrical parameters                61   // default geometrical parameters
 56   fAbsorThickness = 1 * cm;                    <<  62   fAbsorThickness = 1*cm;
 57   fAbsorSizeYZ = 1 * cm;                       <<  63   fAbsorSizeYZ    = 1*cm;
 58   fWorldSizeX = 1.2 * fAbsorThickness;         <<  64   fWorldSizeX     = 1.2*fAbsorThickness;
 59   fWorldSizeYZ = 1.2 * fAbsorSizeYZ;           <<  65   fWorldSizeYZ    = 1.2*fAbsorSizeYZ;
 60                                                    66 
 61   // materials                                     67   // materials
 62   DefineMaterials();                               68   DefineMaterials();
 63   SetAbsorMaterial("G4_Co");                       69   SetAbsorMaterial("G4_Co");
 64                                                    70 
 65   // create commands for interactive definitio     71   // create commands for interactive definition of the geometry
 66   fDetectorMessenger = new DetectorMessenger(t     72   fDetectorMessenger = new DetectorMessenger(this);
 67 }                                                  73 }
 68                                                    74 
 69 //....oooOO0OOooo........oooOO0OOooo........oo     75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    76 
 71 DetectorConstruction::~DetectorConstruction()      77 DetectorConstruction::~DetectorConstruction()
 72 {                                              <<  78 { delete fDetectorMessenger;}
 73   delete fDetectorMessenger;                   << 
 74 }                                              << 
 75                                                    79 
 76 //....oooOO0OOooo........oooOO0OOooo........oo     80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 77                                                    81 
 78 G4VPhysicalVolume* DetectorConstruction::Const     82 G4VPhysicalVolume* DetectorConstruction::Construct()
 79 {                                                  83 {
 80   return ConstructVolumes();                       84   return ConstructVolumes();
 81 }                                                  85 }
 82                                                    86 
 83 //....oooOO0OOooo........oooOO0OOooo........oo     87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 84                                                    88 
 85 void DetectorConstruction::DefineMaterials()       89 void DetectorConstruction::DefineMaterials()
 86 {                                                  90 {
 87   // specific element name for thermal neutron     91   // specific element name for thermal neutronHP
 88   // (see G4ParticleHPThermalScatteringNames.c     92   // (see G4ParticleHPThermalScatteringNames.cc)
 89                                                    93 
 90   G4int ncomponents, natoms;                       94   G4int ncomponents, natoms;
 91                                                    95 
 92   // pressurized water                             96   // pressurized water
 93   G4Element* H = new G4Element("TS_H_of_Water" <<  97   G4Element* H  = new G4Element("TS_H_of_Water" ,"H" , 1., 1.0079*g/mole);
 94   G4Element* O = new G4Element("Oxygen", "O",  <<  98   G4Element* O  = new G4Element("Oxygen"        ,"O" , 8., 16.00*g/mole);
 95   G4Material* H2O = new G4Material("Water_ts", <<  99   G4Material* H2O = 
 96                                    593 * kelvi << 100   new G4Material("Water_ts", 1.000*g/cm3, ncomponents=2,
 97   H2O->AddElement(H, natoms = 2);              << 101                             kStateLiquid, 593*kelvin, 150*bar);
 98   H2O->AddElement(O, natoms = 1);              << 102   H2O->AddElement(H, natoms=2);
 99   H2O->GetIonisation()->SetMeanExcitationEnerg << 103   H2O->AddElement(O, natoms=1);
                                                   >> 104   H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
100                                                   105 
101   // heavy water                                  106   // heavy water
102   G4Isotope* H2 = new G4Isotope("H2", 1, 2);   << 107   G4Isotope* H2 = new G4Isotope("H2",1,2);
103   G4Element* D = new G4Element("TS_D_of_Heavy_ << 108   G4Element* D  = new G4Element("TS_D_of_Heavy_Water", "D", 1);
104   D->AddIsotope(H2, 100 * perCent);            << 109   D->AddIsotope(H2, 100*perCent);  
105   G4Material* D2O = new G4Material("HeavyWater << 110   G4Material* D2O = new G4Material("HeavyWater", 1.11*g/cm3, ncomponents=2,
106                                    293.15 * ke << 111                         kStateLiquid, 293.15*kelvin, 1*atmosphere);
107   D2O->AddElement(D, natoms = 2);              << 112   D2O->AddElement(D, natoms=2);
108   D2O->AddElement(O, natoms = 1);              << 113   D2O->AddElement(O, natoms=1);
109                                                   114 
110   // graphite                                     115   // graphite
111   G4Isotope* C12 = new G4Isotope("C12", 6, 12) << 116   G4Isotope* C12 = new G4Isotope("C12", 6, 12);  
112   G4Element* C = new G4Element("TS_C_of_Graphi << 117   G4Element* C   = new G4Element("TS_C_of_Graphite","C", ncomponents=1);
113   C->AddIsotope(C12, 100. * perCent);          << 118   C->AddIsotope(C12, 100.*perCent);
114   G4Material* graphite = new G4Material("graph << 119   G4Material* graphite = 
115                                         293 *  << 120   new G4Material("graphite", 2.27*g/cm3, ncomponents=1,
116   graphite->AddElement(C, natoms = 1);         << 121                          kStateSolid, 293*kelvin, 1*atmosphere);
                                                   >> 122   graphite->AddElement(C, natoms=1);
117                                                   123 
118   // example of vacuum                            124   // example of vacuum
119   fWorldMaterial = new G4Material("Galactic",  << 125   fWorldMaterial = new G4Material("Galactic", 1, 1.01*g/mole,
120                                   2.73 * kelvi << 126             universe_mean_density, kStateGas, 2.73*kelvin, 3.e-18*pascal);
121                                                   127 
122   /// G4cout << *(G4Material::GetMaterialTable << 128  ///G4cout << *(G4Material::GetMaterialTable()) << G4endl;
123 }                                                 129 }
124                                                   130 
125 //....oooOO0OOooo........oooOO0OOooo........oo    131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126                                                   132 
127 G4Material* DetectorConstruction::MaterialWith << 133 G4Material* DetectorConstruction::MaterialWithSingleIsotope( G4String name,
128                                                << 134                            G4String symbol, G4double density, G4int Z, G4int A)
129 {                                                 135 {
130   // define a material from an isotope         << 136  // define a material from an isotope
131   //                                           << 137  //
132   G4int ncomponents;                           << 138  G4int ncomponents;
133   G4double abundance, massfraction;            << 139  G4double abundance, massfraction;
134                                                << 
135   G4Isotope* isotope = new G4Isotope(symbol, Z << 
136                                                   140 
137   G4Element* element = new G4Element(name, sym << 141  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
138   element->AddIsotope(isotope, abundance = 100 << 142  
                                                   >> 143  G4Element* element  = new G4Element(name, symbol, ncomponents=1);
                                                   >> 144  element->AddIsotope(isotope, abundance= 100.*perCent);
                                                   >> 145  
                                                   >> 146  G4Material* material = new G4Material(name, density, ncomponents=1);
                                                   >> 147  material->AddElement(element, massfraction=100.*perCent);
139                                                   148 
140   G4Material* material = new G4Material(name,  << 149  return material;
141   material->AddElement(element, massfraction = << 
142                                                << 
143   return material;                             << 
144 }                                                 150 }
145                                                   151 
146 //....oooOO0OOooo........oooOO0OOooo........oo    152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147                                                   153 
148 G4VPhysicalVolume* DetectorConstruction::Const    154 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
149 {                                                 155 {
150   // Cleanup old geometry                         156   // Cleanup old geometry
151   G4GeometryManager::GetInstance()->OpenGeomet    157   G4GeometryManager::GetInstance()->OpenGeometry();
152   G4PhysicalVolumeStore::GetInstance()->Clean(    158   G4PhysicalVolumeStore::GetInstance()->Clean();
153   G4LogicalVolumeStore::GetInstance()->Clean()    159   G4LogicalVolumeStore::GetInstance()->Clean();
154   G4SolidStore::GetInstance()->Clean();           160   G4SolidStore::GetInstance()->Clean();
155                                                   161 
156   // World                                        162   // World
157   //                                              163   //
158   fWorldSizeX = 1.2 * fAbsorThickness;         << 164   fWorldSizeX     = 1.2*fAbsorThickness;
159   fWorldSizeYZ = 1.2 * fAbsorSizeYZ;           << 165   fWorldSizeYZ    = 1.2*fAbsorSizeYZ;
160                                                << 166   
161   G4Box* sWorld = new G4Box("World",  // name  << 167   G4Box*
162                             fWorldSizeX / 2, f << 168   sWorld = new G4Box("World",                                 //name
163                                                << 169               fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2);   //dimensions
164   G4LogicalVolume* lWorld = new G4LogicalVolum << 170 
165                                                << 171   G4LogicalVolume*
166                                                << 172   lWorld = new G4LogicalVolume(sWorld,                  //shape
167                                                << 173                              fWorldMaterial,            //material
168   fWorldVolume = new G4PVPlacement(0,  // no r << 174                              "World");                  //name
169                                    G4ThreeVect << 175 
170                                    lWorld,  // << 176   fWorldVolume = new G4PVPlacement(0,                   //no rotation
171                                    "World",  / << 177                             G4ThreeVector(),            //at (0,0,0)
172                                    0,  // moth << 178                             lWorld,                     //logical volume
173                                    false,  //  << 179                             "World",                    //name
174                                    0);  // cop << 180                             0,                          //mother volume
175                                                << 181                             false,                      //no boolean operation
                                                   >> 182                             0);                         //copy number
                                                   >> 183                             
176   // Absorber                                     184   // Absorber
177   //                                              185   //
178   G4Box* sAbsor = new G4Box("Absorber",  // na << 186   G4Box* sAbsor = new G4Box("Absorber",                       //name
179                             fAbsorThickness /  << 187         fAbsorThickness/2, fAbsorSizeYZ/2, fAbsorSizeYZ/2);   //dimensions
180                                                   188 
181   fLAbsor = new G4LogicalVolume(sAbsor,  // sh << 189  fLAbsor = new G4LogicalVolume(sAbsor,                        //shape
182                                 fAbsorMaterial << 190                                fAbsorMaterial,                //material
183                                 fAbsorMaterial << 191                                fAbsorMaterial->GetName());    //name
184                                                << 192                                
185   new G4PVPlacement(0,  // no rotation         << 193            new G4PVPlacement(0,                         //no rotation
186                     G4ThreeVector(),  // at (0 << 194                            G4ThreeVector(),             //at (0,0,0)
187                     fLAbsor,  // logical volum << 195                            fLAbsor,                     //logical volume
188                     fAbsorMaterial->GetName(), << 196                            fAbsorMaterial->GetName(),   //name
189                     lWorld,  // mother  volume << 197                            lWorld,                      //mother  volume
190                     false,  // no boolean oper << 198                            false,                       //no boolean operation
191                     0);  // copy number        << 199                            0);                          //copy number
192                                                   200 
193   PrintParameters();                              201   PrintParameters();
194                                                << 202   
195   // always return the root volume             << 203   //always return the root volume
196   //                                              204   //
197   return fWorldVolume;                            205   return fWorldVolume;
198 }                                                 206 }
199                                                   207 
200 //....oooOO0OOooo........oooOO0OOooo........oo    208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
201                                                   209 
202 void DetectorConstruction::PrintParameters()      210 void DetectorConstruction::PrintParameters()
203 {                                                 211 {
204   G4cout << "\n The Absorber is " << G4BestUni << 212   G4cout << "\n The Absorber is " << G4BestUnit(fAbsorThickness,"Length")
205          << fAbsorMaterial->GetName() << "\n \ << 213          << " of " << fAbsorMaterial->GetName() 
206          << fAbsorMaterial << G4endl;          << 214          << "\n \n" << fAbsorMaterial << G4endl;
207 }                                                 215 }
208                                                   216 
209 //....oooOO0OOooo........oooOO0OOooo........oo    217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210                                                   218 
211 void DetectorConstruction::SetAbsorMaterial(G4    219 void DetectorConstruction::SetAbsorMaterial(G4String materialChoice)
212 {                                                 220 {
213   // search the material by its name              221   // search the material by its name
214   G4Material* pttoMaterial = G4NistManager::In << 222   G4Material* pttoMaterial =
215                                                << 223      G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);   
216   if (pttoMaterial) {                          << 224   
                                                   >> 225   if (pttoMaterial) { 
217     fAbsorMaterial = pttoMaterial;                226     fAbsorMaterial = pttoMaterial;
218     if (fLAbsor) {                             << 227     if(fLAbsor) { fLAbsor->SetMaterial(fAbsorMaterial); }
219       fLAbsor->SetMaterial(fAbsorMaterial);    << 
220     }                                          << 
221     G4RunManager::GetRunManager()->PhysicsHasB    228     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
222   }                                            << 229   } else {
223   else {                                       << 230     G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
224     G4cout << "\n--> warning from DetectorCons << 231            << materialChoice << " not found" << G4endl;
225            << " not found" << G4endl;          << 232   }              
226   }                                            << 
227 }                                                 233 }
228                                                   234 
229 //....oooOO0OOooo........oooOO0OOooo........oo    235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
230                                                   236 
231 void DetectorConstruction::SetAbsorThickness(G    237 void DetectorConstruction::SetAbsorThickness(G4double value)
232 {                                                 238 {
233   fAbsorThickness = value;                        239   fAbsorThickness = value;
234   G4RunManager::GetRunManager()->ReinitializeG    240   G4RunManager::GetRunManager()->ReinitializeGeometry();
235 }                                                 241 }
236                                                   242 
237 //....oooOO0OOooo........oooOO0OOooo........oo    243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
238                                                   244 
239 void DetectorConstruction::SetAbsorSizeYZ(G4do    245 void DetectorConstruction::SetAbsorSizeYZ(G4double value)
240 {                                                 246 {
241   fAbsorSizeYZ = value;                           247   fAbsorSizeYZ = value;
242   G4RunManager::GetRunManager()->ReinitializeG    248   G4RunManager::GetRunManager()->ReinitializeGeometry();
243 }                                                 249 }
244                                                   250 
245 //....oooOO0OOooo........oooOO0OOooo........oo    251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246                                                   252