Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/electromagnetic/TestEm3/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/electromagnetic/TestEm3/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm3/src/DetectorConstruction.cc (Version 10.0.p2)


  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 electromagnetic/TestEm3/src/Detector     26 /// \file electromagnetic/TestEm3/src/DetectorConstruction.cc
 27 /// \brief Implementation of the DetectorConst     27 /// \brief Implementation of the DetectorConstruction class
 28 //                                                 28 //
                                                   >>  29 // $Id: DetectorConstruction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
 29 //                                                 30 //
 30 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32                                                    33 
 33 #include "DetectorConstruction.hh"                 34 #include "DetectorConstruction.hh"
 34                                                << 
 35 #include "DetectorMessenger.hh"                    35 #include "DetectorMessenger.hh"
 36                                                    36 
                                                   >>  37 #include "G4NistManager.hh"
                                                   >>  38 #include "G4Material.hh"
 37 #include "G4Box.hh"                                39 #include "G4Box.hh"
 38 #include "G4GeometryManager.hh"                << 
 39 #include "G4LogicalVolume.hh"                      40 #include "G4LogicalVolume.hh"
 40 #include "G4LogicalVolumeStore.hh"             << 
 41 #include "G4Material.hh"                       << 
 42 #include "G4NistManager.hh"                    << 
 43 #include "G4PVPlacement.hh"                        41 #include "G4PVPlacement.hh"
 44 #include "G4PVReplica.hh"                          42 #include "G4PVReplica.hh"
 45 #include "G4PhysicalConstants.hh"              <<  43 #include "G4UniformMagField.hh"
                                                   >>  44 
                                                   >>  45 #include "G4GeometryManager.hh"
 46 #include "G4PhysicalVolumeStore.hh"                46 #include "G4PhysicalVolumeStore.hh"
 47 #include "G4RunManager.hh"                     <<  47 #include "G4LogicalVolumeStore.hh"
 48 #include "G4SolidStore.hh"                         48 #include "G4SolidStore.hh"
 49 #include "G4SystemOfUnits.hh"                  << 
 50 #include "G4UnitsTable.hh"                     << 
 51                                                    49 
                                                   >>  50 #include "G4UImanager.hh"
                                                   >>  51 #include "G4UnitsTable.hh"
                                                   >>  52 #include "G4PhysicalConstants.hh"
                                                   >>  53 #include "G4SystemOfUnits.hh"
 52 #include <iomanip>                                 54 #include <iomanip>
 53                                                    55 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    57 
 56 DetectorConstruction::DetectorConstruction()       58 DetectorConstruction::DetectorConstruction()
                                                   >>  59 :G4VUserDetectorConstruction(),
                                                   >>  60  fDefaultMaterial(0),fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
                                                   >>  61  fSolidCalor(0),fLogicCalor(0),fPhysiCalor(0),
                                                   >>  62  fSolidLayer(0),fLogicLayer(0),fPhysiLayer(0),
                                                   >>  63  fMagField(0),fDetectorMessenger(0)
 57 {                                                  64 {
 58   for (G4int i = 0; i < kMaxAbsor; ++i) {      << 
 59     fAbsorMaterial[i] = nullptr;               << 
 60     fAbsorThickness[i] = 0.0;                  << 
 61     fSolidAbsor[i] = nullptr;                  << 
 62     fLogicAbsor[i] = nullptr;                  << 
 63     fPhysiAbsor[i] = nullptr;                  << 
 64   }                                            << 
 65                                                << 
 66   // default parameter values of the calorimet     65   // default parameter values of the calorimeter
 67   fNbOfAbsor = 2;                                  66   fNbOfAbsor = 2;
 68   fAbsorThickness[1] = 2.3 * mm;               <<  67   fAbsorThickness[1] = 2.3*mm;
 69   fAbsorThickness[2] = 5.7 * mm;               <<  68   fAbsorThickness[2] = 5.7*mm;
 70   fNbOfLayers = 50;                            <<  69   fNbOfLayers        = 50;
 71   fCalorSizeYZ = 40. * cm;                     <<  70   fCalorSizeYZ       = 40.*cm;
 72   ComputeCalorParameters();                        71   ComputeCalorParameters();
 73                                                    72 
 74   // materials                                     73   // materials
 75   DefineMaterials();                               74   DefineMaterials();
 76   SetWorldMaterial("Galactic");                    75   SetWorldMaterial("Galactic");
 77   SetAbsorMaterial(1, "G4_Pb");                <<  76   SetAbsorMaterial(1,"Lead");
 78   SetAbsorMaterial(2, "G4_lAr");               <<  77   SetAbsorMaterial(2,"liquidArgon");
 79                                                    78 
 80   // create commands for interactive definitio     79   // create commands for interactive definition of the calorimeter
 81   fDetectorMessenger = new DetectorMessenger(t     80   fDetectorMessenger = new DetectorMessenger(this);
 82 }                                                  81 }
 83                                                    82 
 84 //....oooOO0OOooo........oooOO0OOooo........oo     83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 85                                                    84 
 86 DetectorConstruction::~DetectorConstruction()      85 DetectorConstruction::~DetectorConstruction()
 87 {                                                  86 {
 88   delete fDetectorMessenger;                       87   delete fDetectorMessenger;
 89 }                                                  88 }
 90                                                    89 
 91 //....oooOO0OOooo........oooOO0OOooo........oo     90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 92                                                    91 
                                                   >>  92 G4VPhysicalVolume* DetectorConstruction::Construct()
                                                   >>  93 {
                                                   >>  94   return ConstructCalorimeter();
                                                   >>  95 }
                                                   >>  96 
                                                   >>  97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  98 
 93 void DetectorConstruction::DefineMaterials()       99 void DetectorConstruction::DefineMaterials()
 94 {                                                 100 {
 95   // This function illustrates the possible wa << 101   // This function illustrates the possible ways to define materials using 
 96   // G4 database on G4Elements                    102   // G4 database on G4Elements
 97   G4NistManager* manager = G4NistManager::Inst    103   G4NistManager* manager = G4NistManager::Instance();
 98   manager->SetVerbose(0);                         104   manager->SetVerbose(0);
 99   //                                              105   //
100   // define Elements                              106   // define Elements
101   //                                              107   //
102   G4double z, a;                               << 108   G4double z,a;
103                                                   109 
104   G4Element* H = manager->FindOrBuildElement(1 << 110   G4Element* H  = manager->FindOrBuildElement(1);
105   G4Element* C = manager->FindOrBuildElement(6 << 111   G4Element* C  = manager->FindOrBuildElement(6);
106   G4Element* N = manager->FindOrBuildElement(7 << 112   G4Element* N  = manager->FindOrBuildElement(7);
107   G4Element* O = manager->FindOrBuildElement(8 << 113   G4Element* O  = manager->FindOrBuildElement(8);
108   G4Element* Si = manager->FindOrBuildElement(    114   G4Element* Si = manager->FindOrBuildElement(14);
109   G4Element* Ge = manager->FindOrBuildElement(    115   G4Element* Ge = manager->FindOrBuildElement(32);
110   G4Element* Sb = manager->FindOrBuildElement(    116   G4Element* Sb = manager->FindOrBuildElement(51);
111   G4Element* I = manager->FindOrBuildElement(5 << 117   G4Element* I  = manager->FindOrBuildElement(53);
112   G4Element* Cs = manager->FindOrBuildElement(    118   G4Element* Cs = manager->FindOrBuildElement(55);
113   G4Element* Pb = manager->FindOrBuildElement(    119   G4Element* Pb = manager->FindOrBuildElement(82);
114   G4Element* Bi = manager->FindOrBuildElement(    120   G4Element* Bi = manager->FindOrBuildElement(83);
115                                                   121 
116   //                                              122   //
117   // define an Element from isotopes, by relat    123   // define an Element from isotopes, by relative abundance
118   //                                              124   //
119   G4int iz, n;  // iz=number of protons  in an << 125   G4int iz, n;                       //iz=number of protons  in an isotope;
120                 //  n=number of nucleons in an << 126                                      // n=number of nucleons in an isotope;
121   G4int ncomponents;                           << 127   G4int   ncomponents;                                     
122   G4double abundance;                          << 128   G4double abundance;                                     
123                                                << 129 
124   G4Isotope* U5 = new G4Isotope("U235", iz = 9 << 130   G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole);
125   G4Isotope* U8 = new G4Isotope("U238", iz = 9 << 131   G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole);
126                                                << 132 
127   G4Element* U = new G4Element("enriched Urani << 133   G4Element* U  = new G4Element("enriched Uranium", "U", ncomponents=2);
128   U->AddIsotope(U5, abundance = 90. * perCent) << 134   U->AddIsotope(U5, abundance= 90.*perCent);
129   U->AddIsotope(U8, abundance = 10. * perCent) << 135   U->AddIsotope(U8, abundance= 10.*perCent);
130                                                   136 
131   //                                              137   //
132   // define simple materials                      138   // define simple materials
133   //                                              139   //
134   G4double density;                               140   G4double density;
135                                                   141 
136   new G4Material("liquidH2", z = 1., a = 1.008 << 142   new G4Material("liquidH2",    z=1.,  a= 1.008*g/mole,  density= 70.8*mg/cm3);
137   new G4Material("Aluminium", z = 13., a = 26. << 143   new G4Material("Aluminium",   z=13., a= 26.98*g/mole,  density= 2.700*g/cm3);
138   new G4Material("Titanium", z = 22., a = 47.8 << 144   new G4Material("Titanium",    z=22., a= 47.867*g/mole, density= 4.54*g/cm3);
139   new G4Material("Iron", z = 26., a = 55.85 *  << 145   new G4Material("Iron",        z=26., a= 55.85*g/mole,  density= 7.870*g/cm3);
140   new G4Material("Copper", z = 29., a = 63.55  << 146   new G4Material("Copper",      z=29., a= 63.55*g/mole,  density= 8.960*g/cm3);
141   new G4Material("Tungsten", z = 74., a = 183. << 147   new G4Material("Tungsten",    z=74., a= 183.85*g/mole, density= 19.30*g/cm3);
142   new G4Material("Gold", z = 79., a = 196.97 * << 148   new G4Material("Gold",        z=79., a= 196.97*g/mole, density= 19.32*g/cm3);
143   new G4Material("Uranium", z = 92., a = 238.0 << 149   new G4Material("Uranium",     z=92., a= 238.03*g/mole, density= 18.95*g/cm3);
144                                                   150 
145   //                                              151   //
146   // define a material from elements.   case 1    152   // define a material from elements.   case 1: chemical molecule
147   //                                              153   //
148   G4int natoms;                                   154   G4int natoms;
149                                                   155 
150   G4Material* H2O = new G4Material("Water", de << 156   G4Material* H2O = 
151   H2O->AddElement(H, natoms = 2);              << 157   new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
152   H2O->AddElement(O, natoms = 1);              << 158   H2O->AddElement(H, natoms=2);
153   H2O->GetIonisation()->SetMeanExcitationEnerg << 159   H2O->AddElement(O, natoms=1);
                                                   >> 160   H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
154   H2O->SetChemicalFormula("H_2O");                161   H2O->SetChemicalFormula("H_2O");
155                                                << 162   
156   G4Material* CH = new G4Material("Polystyrene << 163   G4Material* CH = 
157   CH->AddElement(C, natoms = 1);               << 164   new G4Material("Polystyrene", density= 1.032*g/cm3, ncomponents=2);
158   CH->AddElement(H, natoms = 1);               << 165   CH->AddElement(C, natoms=1);
159                                                << 166   CH->AddElement(H, natoms=1);
160   G4Material* Sci = new G4Material("Scintillat << 167 
161   Sci->AddElement(C, natoms = 9);              << 168   G4Material* Sci = 
162   Sci->AddElement(H, natoms = 10);             << 169   new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
163                                                << 170   Sci->AddElement(C, natoms=9);
164   Sci->GetIonisation()->SetBirksConstant(0.126 << 171   Sci->AddElement(H, natoms=10);
165                                                << 172   
166   G4Material* Lct = new G4Material("Lucite", d << 173   Sci->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
167   Lct->AddElement(C, 59.97 * perCent);         << 174 
168   Lct->AddElement(H, 8.07 * perCent);          << 175   G4Material* Lct =
169   Lct->AddElement(O, 31.96 * perCent);         << 176   new G4Material("Lucite", density= 1.185*g/cm3, ncomponents=3);
170                                                << 177   Lct->AddElement(C, 59.97*perCent);
171   G4Material* Sili = new G4Material("Silicon", << 178   Lct->AddElement(H, 8.07*perCent);
172   Sili->AddElement(Si, natoms = 1);            << 179   Lct->AddElement(O, 31.96*perCent);
173                                                << 180 
174   G4Material* SiO2 = new G4Material("quartz",  << 181   G4Material* Sili = 
175   SiO2->AddElement(Si, natoms = 1);            << 182   new G4Material("Silicon", density= 2.330*g/cm3, ncomponents=1);
176   SiO2->AddElement(O, natoms = 2);             << 183   Sili->AddElement(Si, natoms=1);
177                                                << 184 
178   G4Material* G10 = new G4Material("NemaG10",  << 185   G4Material* SiO2 = 
179   G10->AddElement(Si, natoms = 1);             << 186   new G4Material("quartz", density= 2.200*g/cm3, ncomponents=2);
180   G10->AddElement(O, natoms = 2);              << 187   SiO2->AddElement(Si, natoms=1);
181   G10->AddElement(C, natoms = 3);              << 188   SiO2->AddElement(O , natoms=2);
182   G10->AddElement(H, natoms = 3);              << 189 
183                                                << 190   G4Material* G10 = 
184   G4Material* CsI = new G4Material("CsI", dens << 191   new G4Material("NemaG10", density= 1.700*g/cm3, ncomponents=4);
185   CsI->AddElement(Cs, natoms = 1);             << 192   G10->AddElement(Si, natoms=1);
186   CsI->AddElement(I, natoms = 1);              << 193   G10->AddElement(O , natoms=2);
187   CsI->GetIonisation()->SetMeanExcitationEnerg << 194   G10->AddElement(C , natoms=3);
188                                                << 195   G10->AddElement(H , natoms=3);
189   G4Material* BGO = new G4Material("BGO", dens << 196 
190   BGO->AddElement(O, natoms = 12);             << 197   G4Material* CsI = 
191   BGO->AddElement(Ge, natoms = 3);             << 198   new G4Material("CsI", density= 4.534*g/cm3, ncomponents=2);
192   BGO->AddElement(Bi, natoms = 4);             << 199   CsI->AddElement(Cs, natoms=1);
193                                                << 200   CsI->AddElement(I , natoms=1);
194   // SiNx                                      << 201   CsI->GetIonisation()->SetMeanExcitationEnergy(553.1*eV);
195   density = 3.1 * g / cm3;                     << 202 
196   G4Material* SiNx = new G4Material("SiNx", de << 203   G4Material* BGO = 
197   SiNx->AddElement(Si, 300);                   << 204   new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
198   SiNx->AddElement(N, 310);                    << 205   BGO->AddElement(O , natoms=12);
199   SiNx->AddElement(H, 6);                      << 206   BGO->AddElement(Ge, natoms= 3);
                                                   >> 207   BGO->AddElement(Bi, natoms= 4);
                                                   >> 208 
                                                   >> 209   //SiNx
                                                   >> 210   density= 3.1 *g/cm3;
                                                   >> 211   G4Material* SiNx= new G4Material("SiNx", density, ncomponents=3);
                                                   >> 212   SiNx-> AddElement(Si, 300);
                                                   >> 213   SiNx-> AddElement(N, 310);
                                                   >> 214   SiNx-> AddElement(H, 6);
200                                                   215 
201   //                                              216   //
202   // define gaseous materials using G4 NIST da << 217   // define gaseous materials using G4 NIST database 
203   //                                              218   //
204   G4double fractionmass;                          219   G4double fractionmass;
205                                                << 220   
206   G4Material* Air = manager->FindOrBuildMateri    221   G4Material* Air = manager->FindOrBuildMaterial("G4_AIR");
207   manager->ConstructNewGasMaterial("Air20", "G << 222   manager->ConstructNewGasMaterial("Air20","G4_AIR",293.*kelvin,1.*atmosphere);
208                                                   223 
209   G4Material* lAr = manager->FindOrBuildMateri    224   G4Material* lAr = manager->FindOrBuildMaterial("G4_lAr");
210   G4Material* lArEm3 = new G4Material("liquidA << 225   G4Material* lArEm3 = new G4Material("liquidArgon", density= 1.390*g/cm3, ncomponents=1);
211   lArEm3->AddMaterial(lAr, fractionmass = 1.0) << 226   lArEm3->AddMaterial(lAr, fractionmass=1.0);
212                                                   227 
213   //                                              228   //
214   // define a material from elements and other    229   // define a material from elements and others materials (mixture of mixtures)
215   //                                              230   //
216                                                   231 
217   G4Material* Lead = new G4Material("Lead", de << 232   G4Material* Lead = new G4Material("Lead", density= 11.35*g/cm3, ncomponents=1);
218   Lead->AddElement(Pb, fractionmass = 1.0);    << 233   Lead->AddElement(Pb, fractionmass=1.0);
219                                                   234 
220   G4Material* LeadSb = new G4Material("LeadSb" << 235   G4Material* LeadSb = new G4Material("LeadSb", density= 11.35*g/cm3, ncomponents=2);
221   LeadSb->AddElement(Sb, fractionmass = 4. * p << 236   LeadSb->AddElement(Sb, fractionmass=4.*perCent);
222   LeadSb->AddElement(Pb, fractionmass = 96. *  << 237   LeadSb->AddElement(Pb, fractionmass=96.*perCent);
223                                                << 238 
224   G4Material* Aerog = new G4Material("Aerogel" << 239   G4Material* Aerog = new G4Material("Aerogel", density= 0.200*g/cm3, ncomponents=3);
225   Aerog->AddMaterial(SiO2, fractionmass = 62.5 << 240   Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent);
226   Aerog->AddMaterial(H2O, fractionmass = 37.4  << 241   Aerog->AddMaterial(H2O , fractionmass=37.4*perCent);
227   Aerog->AddElement(C, fractionmass = 0.1 * pe << 242   Aerog->AddElement (C   , fractionmass= 0.1*perCent);
228                                                   243 
229   //                                              244   //
230   // examples of gas in non STP conditions        245   // examples of gas in non STP conditions
231   //                                              246   //
232   G4double temperature, pressure;                 247   G4double temperature, pressure;
233                                                << 248   
234   G4Material* CO2 =                            << 249   G4Material* CO2 = 
235     new G4Material("CarbonicGas", density = 27 << 250   new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
236                    temperature = 325. * kelvin << 251                  kStateGas, temperature= 325.*kelvin, pressure= 50.*atmosphere);
237   CO2->AddElement(C, natoms = 1);              << 252   CO2->AddElement(C, natoms=1);
238   CO2->AddElement(O, natoms = 2);              << 253   CO2->AddElement(O, natoms=2);
239                                                << 254 
240   G4Material* steam =                          << 255   G4Material* steam = 
241     new G4Material("WaterSteam", density = 1.0 << 256   new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1,
242                    temperature = 273 * kelvin, << 257                   kStateGas, temperature= 273*kelvin, pressure= 1*atmosphere);
243   steam->AddMaterial(H2O, fractionmass = 1.);  << 258   steam->AddMaterial(H2O, fractionmass=1.);
244                                                << 259   
245   new G4Material("ArgonGas", z = 18, a = 39.94 << 260   new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
246                  273.15 * kelvin, 1 * atmosphe << 261                  kStateGas, 273.15*kelvin, 1*atmosphere);
247   //                                              262   //
248   // examples of vacuum                           263   // examples of vacuum
249   //                                              264   //
250                                                   265 
251   density = universe_mean_density;  // from Ph << 266   density     = universe_mean_density;    //from PhysicalConstants.h
252   pressure = 3.e-18 * pascal;                  << 267   pressure    = 3.e-18*pascal;
253   temperature = 2.73 * kelvin;                 << 268   temperature = 2.73*kelvin;
254   new G4Material("Galactic", z = 1., a = 1.008 << 269   new G4Material("Galactic", z=1., a=1.008*g/mole, density,
255                  pressure);                    << 270                              kStateGas,temperature,pressure);
256                                                << 271 
257   density = 1.e-5 * g / cm3;                   << 272   density     = 1.e-5*g/cm3;
258   pressure = 2.e-2 * bar;                      << 273   pressure    = 2.e-2*bar;
259   temperature = STP_Temperature;  // from Phys << 274   temperature = STP_Temperature;         //from PhysicalConstants.h
260   G4Material* beam =                           << 275   G4Material* beam = 
261     new G4Material("Beam", density, ncomponent << 276   new G4Material("Beam", density, ncomponents=1,
262   beam->AddMaterial(Air, fractionmass = 1.);   << 277                          kStateGas,temperature,pressure);
                                                   >> 278   beam->AddMaterial(Air, fractionmass=1.);
263                                                   279 
264   //  G4cout << *(G4Material::GetMaterialTable    280   //  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
265 }                                                 281 }
266                                                   282 
267 //....oooOO0OOooo........oooOO0OOooo........oo    283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268                                                   284 
269 void DetectorConstruction::ComputeCalorParamet    285 void DetectorConstruction::ComputeCalorParameters()
270 {                                                 286 {
271   // Compute derived parameters of the calorim    287   // Compute derived parameters of the calorimeter
272   fLayerThickness = 0.;                           288   fLayerThickness = 0.;
273   for (G4int iAbs = 1; iAbs <= fNbOfAbsor; iAb << 289   for (G4int iAbs=1; iAbs<=fNbOfAbsor; iAbs++) {
274     fLayerThickness += fAbsorThickness[iAbs];     290     fLayerThickness += fAbsorThickness[iAbs];
275   }                                               291   }
276   fCalorThickness = fNbOfLayers * fLayerThickn << 292   fCalorThickness = fNbOfLayers*fLayerThickness;     
277   fWorldSizeX = 1.2 * fCalorThickness;         << 293   fWorldSizeX = 1.2*fCalorThickness; 
278   fWorldSizeYZ = 1.2 * fCalorSizeYZ;           << 294   fWorldSizeYZ = 1.2*fCalorSizeYZ;
279 }                                                 295 }
280                                                   296 
281 //....oooOO0OOooo........oooOO0OOooo........oo    297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
282                                                   298 
283 G4VPhysicalVolume* DetectorConstruction::Const << 299 G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
284 {                                                 300 {
285   if (fPhysiWorld) {                           << 
286     return fPhysiWorld;                        << 
287   }                                            << 
288   // complete the Calor parameters definition     301   // complete the Calor parameters definition
289   ComputeCalorParameters();                       302   ComputeCalorParameters();
290                                                   303 
                                                   >> 304   // Cleanup old geometry
                                                   >> 305   G4GeometryManager::GetInstance()->OpenGeometry();
                                                   >> 306   G4PhysicalVolumeStore::GetInstance()->Clean();
                                                   >> 307   G4LogicalVolumeStore::GetInstance()->Clean();
                                                   >> 308   G4SolidStore::GetInstance()->Clean();
                                                   >> 309 
291   //                                              310   //
292   // World                                        311   // World
293   //                                              312   //
294   fSolidWorld = new G4Box("World",  // its nam << 
295                           fWorldSizeX / 2, fWo << 
296                                                   313 
297   fLogicWorld = new G4LogicalVolume(fSolidWorl << 314   fSolidWorld = new G4Box("World",                                //its name
298                                     fWorldMate << 315                    fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2);        //its size
299                                     "World");  << 316 
300                                                << 317   fLogicWorld = new G4LogicalVolume(fSolidWorld,                //its solid
301   fPhysiWorld = new G4PVPlacement(0,  // no ro << 318                                    fDefaultMaterial,        //its material
302                                   G4ThreeVecto << 319                                    "World");                //its name
303                                   fLogicWorld, << 320 
304                                   "World",  // << 321   fPhysiWorld = new G4PVPlacement(0,                        //no rotation
305                                   0,  // its m << 322                                    G4ThreeVector(),        //at (0,0,0)
306                                   false,  // n << 323                                  fLogicWorld,                //its fLogical volume
307                                   0);  // copy << 324                                  "World",                //its name
                                                   >> 325                                  0,                        //its mother  volume
                                                   >> 326                                  false,                        //no boolean operation
                                                   >> 327                                  0);                        //copy number
308   //                                              328   //
309   // Calorimeter                                  329   // Calorimeter
310   //                                              330   //
311                                                   331 
312   fSolidCalor = new G4Box("Calorimeter", fCalo << 332   fSolidCalor = new G4Box("Calorimeter",                                     //its name
313                                                << 333                            fCalorThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);//size
314   fLogicCalor = new G4LogicalVolume(fSolidCalo << 
315                                                   334 
316   fPhysiCalor = new G4PVPlacement(0,  // no ro << 335   fLogicCalor = new G4LogicalVolume(fSolidCalor,                //its solid
317                                   G4ThreeVecto << 336                                          fDefaultMaterial,        //its material
318                                   fLogicCalor, << 337                                          "Calorimeter");        //its name
319                                   "Calorimeter << 338 
320                                   fLogicWorld, << 339   fPhysiCalor = new G4PVPlacement(0,                        //no rotation
321                                   false,  // n << 340                                  G4ThreeVector(),        //at (0,0,0)
322                                   0);  // copy << 341                                  fLogicCalor,                //its fLogical volume
                                                   >> 342                                  "Calorimeter",                //its name
                                                   >> 343                                  fLogicWorld,                //its mother  volume
                                                   >> 344                                  false,                        //no boolean operation
                                                   >> 345                                  0);                        //copy number
323                                                   346 
324   //                                              347   //
325   // Layers                                       348   // Layers
326   //                                              349   //
327                                                   350 
328   fSolidLayer = new G4Box("Layer", fLayerThick << 351   fSolidLayer = new G4Box("Layer",                                      //its name
                                                   >> 352                        fLayerThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); //size
                                                   >> 353 
                                                   >> 354   fLogicLayer = new G4LogicalVolume(fSolidLayer,                //its solid
                                                   >> 355                                    fDefaultMaterial,        //its material
                                                   >> 356                                    "Layer");                //its name
                                                   >> 357   if (fNbOfLayers > 1)
                                                   >> 358     fPhysiLayer = new G4PVReplica("Layer",                //its name
                                                   >> 359                                        fLogicLayer,                //its fLogical volume
                                                   >> 360                                        fLogicCalor,                //its mother
                                                   >> 361                                  kXAxis,                //axis of replication
                                                   >> 362                                  fNbOfLayers,                //number of replica
                                                   >> 363                                  fLayerThickness);        //witdth of replica
                                                   >> 364   else
                                                   >> 365     fPhysiLayer = new G4PVPlacement(0,                        //no rotation
                                                   >> 366                                    G4ThreeVector(),        //at (0,0,0)
                                                   >> 367                                    fLogicLayer,                //its fLogical volume
                                                   >> 368                                    "Layer",                //its name
                                                   >> 369                                    fLogicCalor,                //its mother  volume
                                                   >> 370                                    false,                //no boolean operation
                                                   >> 371                                    0);                        //copy number
329                                                   372 
330   fLogicLayer = new G4LogicalVolume(fSolidLaye << 
331   if (fNbOfLayers > 1) {                       << 
332     fPhysiLayer =                              << 
333       new G4PVReplica("Layer", fLogicLayer, fL << 
334   }                                            << 
335   else {                                       << 
336     fPhysiLayer =                              << 
337       new G4PVPlacement(0, G4ThreeVector(), fL << 
338   }                                            << 
339   //                                              373   //
340   // Absorbers                                    374   // Absorbers
341   //                                              375   //
342                                                   376 
343   G4double xfront = -0.5 * fLayerThickness;    << 377   G4double xfront = -0.5*fLayerThickness;
344   for (G4int k = 1; k <= fNbOfAbsor; ++k) {    << 378   for (G4int k=1; k<=fNbOfAbsor; k++) {
345     fSolidAbsor[k] = new G4Box("Absorber",  // << 379     fSolidAbsor[k] = new G4Box("Absorber",                //its name
346                                fAbsorThickness << 380                               fAbsorThickness[k]/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
347                                                << 381 
348     fLogicAbsor[k] = new G4LogicalVolume(fSoli << 382     fLogicAbsor[k] = new G4LogicalVolume(fSolidAbsor[k],    //its solid
349                                          fAbso << 383                                         fAbsorMaterial[k], //its material
350                                          fAbso << 384                                         fAbsorMaterial[k]->GetName());
351                                                   385 
352     G4double xcenter = xfront + 0.5 * fAbsorTh << 386     G4double xcenter = xfront+0.5*fAbsorThickness[k];
353     xfront += fAbsorThickness[k];                 387     xfront += fAbsorThickness[k];
354     fPhysiAbsor[k] = new G4PVPlacement(0, G4Th << 388     fPhysiAbsor[k] = new G4PVPlacement(0,                   //no rotation
355                                        fAbsorM << 389                          G4ThreeVector(xcenter,0.,0.),      //its position
356                                        k);  // << 390                          fLogicAbsor[k],                    //its logical volume        
                                                   >> 391                          fAbsorMaterial[k]->GetName(),      //its name
                                                   >> 392                          fLogicLayer,                       //its mother
                                                   >> 393                          false,                             //no boulean operat
                                                   >> 394                          k);                                //copy number
                                                   >> 395 
357   }                                               396   }
358                                                   397 
                                                   >> 398 
359   PrintCalorParameters();                         399   PrintCalorParameters();
360                                                   400 
361   // always return the fPhysical World         << 401   //always return the fPhysical World
362   //                                              402   //
363   return fPhysiWorld;                             403   return fPhysiWorld;
364 }                                                 404 }
365                                                   405 
366 //....oooOO0OOooo........oooOO0OOooo........oo    406 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
367                                                   407 
368 void DetectorConstruction::PrintCalorParameter    408 void DetectorConstruction::PrintCalorParameters()
369 {                                                 409 {
370   G4cout << "\n-------------------------------    410   G4cout << "\n-------------------------------------------------------------"
371          << "\n ---> The calorimeter is " << f    411          << "\n ---> The calorimeter is " << fNbOfLayers << " layers of:";
372   for (G4int i = 1; i <= fNbOfAbsor; ++i) {    << 412   for (G4int i=1; i<=fNbOfAbsor; i++)
373     G4cout << "\n \t" << std::setw(12) << fAbs << 413      {
374            << G4BestUnit(fAbsorThickness[i], " << 414       G4cout << "\n \t" << std::setw(12) << fAbsorMaterial[i]->GetName() <<": "
375   }                                            << 415               << std::setw(6) << G4BestUnit(fAbsorThickness[i],"Length");
                                                   >> 416      }
376   G4cout << "\n-------------------------------    417   G4cout << "\n-------------------------------------------------------------\n";
                                                   >> 418   
                                                   >> 419   G4cout << "\n" << fDefaultMaterial << G4endl;    
                                                   >> 420   for (G4int j=1; j<=fNbOfAbsor; j++)
                                                   >> 421      G4cout << "\n" << fAbsorMaterial[j] << G4endl;
377                                                   422 
378   G4cout << "\n" << fWorldMaterial << G4endl;  << 
379   for (G4int j = 1; j <= fNbOfAbsor; ++j) {    << 
380     G4cout << "\n" << fAbsorMaterial[j] << G4e << 
381   }                                            << 
382   G4cout << "\n-------------------------------    423   G4cout << "\n-------------------------------------------------------------\n";
383 }                                                 424 }
384                                                   425 
385 //....oooOO0OOooo........oooOO0OOooo........oo    426 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
386                                                   427 
387 void DetectorConstruction::SetWorldMaterial(co    428 void DetectorConstruction::SetWorldMaterial(const G4String& material)
388 {                                                 429 {
389   // search the material by its name              430   // search the material by its name
390   G4Material* pttoMaterial = G4NistManager::In << 431   G4Material* pttoMaterial = 
391   if (pttoMaterial) {                          << 432     G4NistManager::Instance()->FindOrBuildMaterial(material);
392     fWorldMaterial = pttoMaterial;             << 433   if (pttoMaterial) fDefaultMaterial = pttoMaterial;
393     if (fLogicWorld) {                         << 
394       fLogicWorld->SetMaterial(fWorldMaterial) << 
395       fLogicLayer->SetMaterial(fWorldMaterial) << 
396       G4RunManager::GetRunManager()->PhysicsHa << 
397     }                                          << 
398   }                                            << 
399 }                                                 434 }
400                                                   435 
401 //....oooOO0OOooo........oooOO0OOooo........oo    436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
402                                                   437 
403 void DetectorConstruction::SetNbOfLayers(G4int    438 void DetectorConstruction::SetNbOfLayers(G4int ival)
404 {                                                 439 {
405   // set the number of Layers                     440   // set the number of Layers
406   //                                              441   //
407   if (ival < 1) {                              << 442   if (ival < 1)
408     G4cout << "\n --->warning from SetfNbOfLay << 443     { G4cout << "\n --->warning from SetfNbOfLayers: "
409            << " must be at least 1. Command re << 444              << ival << " must be at least 1. Command refused" << G4endl;
410     return;                                    << 445       return;
411   }                                            << 446     }
412   fNbOfLayers = ival;                             447   fNbOfLayers = ival;
413 }                                                 448 }
414                                                   449 
415 //....oooOO0OOooo........oooOO0OOooo........oo    450 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
416                                                   451 
417 void DetectorConstruction::SetNbOfAbsor(G4int     452 void DetectorConstruction::SetNbOfAbsor(G4int ival)
418 {                                                 453 {
419   // set the number of Absorbers                  454   // set the number of Absorbers
420   //                                              455   //
421   if (ival < 1 || ival > (kMaxAbsor - 1)) {    << 456   if (ival < 1 || ival > (MaxAbsor-1))
422     G4cout << "\n ---> warning from SetfNbOfAb << 457     { G4cout << "\n ---> warning from SetfNbOfAbsor: "
423            << kMaxAbsor - 1 << ". Command refu << 458              << ival << " must be at least 1 and and most " << MaxAbsor-1
424     return;                                    << 459              << ". Command refused" << G4endl;
425   }                                            << 460       return;
                                                   >> 461     }
426   fNbOfAbsor = ival;                              462   fNbOfAbsor = ival;
427 }                                                 463 }
428                                                   464 
429 //....oooOO0OOooo........oooOO0OOooo........oo    465 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
430                                                   466 
431 void DetectorConstruction::SetAbsorMaterial(G4    467 void DetectorConstruction::SetAbsorMaterial(G4int ival, const G4String& material)
432 {                                                 468 {
433   // search the material by its name              469   // search the material by its name
434   //                                              470   //
435   if (ival > fNbOfAbsor || ival <= 0) {        << 471   if (ival > fNbOfAbsor || ival <= 0)
436     G4cout << "\n --->warning from SetAbsorMat << 472     { G4cout << "\n --->warning from SetAbsorMaterial: absor number "
437            << " out of range. Command refused" << 473              << ival << " out of range. Command refused" << G4endl;
438     return;                                    << 474       return;
439   }                                            << 
440                                                << 
441   G4Material* pttoMaterial = G4NistManager::In << 
442   if (pttoMaterial) {                          << 
443     fAbsorMaterial[ival] = pttoMaterial;       << 
444     if (fLogicAbsor[ival]) {                   << 
445       fLogicAbsor[ival]->SetMaterial(pttoMater << 
446       G4RunManager::GetRunManager()->PhysicsHa << 
447     }                                             475     }
448   }                                            << 476 
                                                   >> 477   G4Material* pttoMaterial = 
                                                   >> 478     G4NistManager::Instance()->FindOrBuildMaterial(material);
                                                   >> 479   if (pttoMaterial) fAbsorMaterial[ival] = pttoMaterial;
449 }                                                 480 }
450                                                   481 
451 //....oooOO0OOooo........oooOO0OOooo........oo    482 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
452                                                   483 
453 void DetectorConstruction::SetAbsorThickness(G << 484 void DetectorConstruction::SetAbsorThickness(G4int ival,G4double val)
454 {                                                 485 {
455   // change Absorber thickness                    486   // change Absorber thickness
456   //                                              487   //
457   if (ival > fNbOfAbsor || ival <= 0) {        << 488   if (ival > fNbOfAbsor || ival <= 0)
458     G4cout << "\n --->warning from SetAbsorThi << 489     { G4cout << "\n --->warning from SetAbsorThickness: absor number "
459            << " out of range. Command refused" << 490              << ival << " out of range. Command refused" << G4endl;
460     return;                                    << 491       return;
461   }                                            << 492     }
462   if (val <= DBL_MIN) {                        << 493   if (val <= DBL_MIN)
463     G4cout << "\n --->warning from SetAbsorThi << 494     { G4cout << "\n --->warning from SetAbsorThickness: thickness "
464            << " out of range. Command refused" << 495              << val  << " out of range. Command refused" << G4endl;
465     return;                                    << 496       return;
466   }                                            << 497     }
467   fAbsorThickness[ival] = val;                    498   fAbsorThickness[ival] = val;
468 }                                                 499 }
469                                                   500 
470 //....oooOO0OOooo........oooOO0OOooo........oo    501 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
471                                                   502 
472 void DetectorConstruction::SetCalorSizeYZ(G4do    503 void DetectorConstruction::SetCalorSizeYZ(G4double val)
473 {                                                 504 {
474   // change the transverse size                   505   // change the transverse size
475   //                                              506   //
476   if (val <= DBL_MIN) {                        << 507   if (val <= DBL_MIN)
477     G4cout << "\n --->warning from SetfCalorSi << 508     { G4cout << "\n --->warning from SetfCalorSizeYZ: thickness "
478            << " out of range. Command refused" << 509              << val  << " out of range. Command refused" << G4endl;
479     return;                                    << 510       return;
480   }                                            << 511     }
481   fCalorSizeYZ = val;                             512   fCalorSizeYZ = val;
482 }                                                 513 }
483                                                   514 
484 //....oooOO0OOooo........oooOO0OOooo........oo    515 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
485                                                   516 
486 #include "G4AutoDelete.hh"                     << 517 #include "G4FieldManager.hh"
487 #include "G4GlobalMagFieldMessenger.hh"        << 518 #include "G4TransportationManager.hh"
488                                                   519 
489 void DetectorConstruction::ConstructSDandField << 520 void DetectorConstruction::SetMagField(G4double fieldValue)
490 {                                                 521 {
491   if (fFieldMessenger.Get() == nullptr) {      << 522   //apply a global uniform magnetic field along Z axis
492     // Create global magnetic field messenger. << 523   //
493     // Uniform magnetic field is then created  << 524   G4FieldManager* fieldMgr
494     // the field value is not zero.            << 525    = G4TransportationManager::GetTransportationManager()->GetFieldManager();
495     G4ThreeVector fieldValue = G4ThreeVector() << 526 
496     G4GlobalMagFieldMessenger* msg = new G4Glo << 527   if(fMagField) delete fMagField;                //delete the existing magn field
497     // msg->SetVerboseLevel(1);                << 528 
498     G4AutoDelete::Register(msg);               << 529   if(fieldValue!=0.)                        // create a new one if non nul
499     fFieldMessenger.Put(msg);                  << 530   { fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
                                                   >> 531     fieldMgr->SetDetectorField(fMagField);
                                                   >> 532     fieldMgr->CreateChordFinder(fMagField);
                                                   >> 533   } else {
                                                   >> 534     fMagField = 0;
                                                   >> 535     fieldMgr->SetDetectorField(fMagField);
500   }                                               536   }
                                                   >> 537 }
                                                   >> 538 
                                                   >> 539 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 540 
                                                   >> 541 #include "G4RunManager.hh"
                                                   >> 542 
                                                   >> 543 void DetectorConstruction::UpdateGeometry()
                                                   >> 544 {
                                                   >> 545   G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
501 }                                                 546 }
502                                                   547 
503 //....oooOO0OOooo........oooOO0OOooo........oo    548 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
504                                                   549