Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/hadronic/Hadr05/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/hadronic/Hadr05/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/hadronic/Hadr05/src/DetectorConstruction.cc (Version 11.0)


  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 //                                                 29 //
 30 //....oooOO0OOooo........oooOO0OOooo........oo     30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32                                                    32 
 33 #include "DetectorConstruction.hh"                 33 #include "DetectorConstruction.hh"
 34                                                << 
 35 #include "DetectorMessenger.hh"                    34 #include "DetectorMessenger.hh"
 36                                                    35 
                                                   >>  36 #include "G4NistManager.hh"
                                                   >>  37 #include "G4Material.hh"
 37 #include "G4Box.hh"                                38 #include "G4Box.hh"
 38 #include "G4GeometryManager.hh"                << 
 39 #include "G4LogicalVolume.hh"                      39 #include "G4LogicalVolume.hh"
 40 #include "G4LogicalVolumeStore.hh"             << 
 41 #include "G4Material.hh"                       << 
 42 #include "G4NistManager.hh"                    << 
 43 #include "G4PVPlacement.hh"                        40 #include "G4PVPlacement.hh"
 44 #include "G4PVReplica.hh"                          41 #include "G4PVReplica.hh"
 45 #include "G4PhysicalConstants.hh"              <<  42 
                                                   >>  43 #include "G4GeometryManager.hh"
 46 #include "G4PhysicalVolumeStore.hh"                44 #include "G4PhysicalVolumeStore.hh"
 47 #include "G4RunManager.hh"                     <<  45 #include "G4LogicalVolumeStore.hh"
 48 #include "G4SolidStore.hh"                         46 #include "G4SolidStore.hh"
                                                   >>  47 
                                                   >>  48 #include "G4RunManager.hh"
 49 #include "G4SystemOfUnits.hh"                      49 #include "G4SystemOfUnits.hh"
 50 #include "G4UnitsTable.hh"                         50 #include "G4UnitsTable.hh"
                                                   >>  51 #include "G4PhysicalConstants.hh"
 51                                                    52 
 52 #include <iomanip>                                 53 #include <iomanip>
 53                                                    54 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    56 
 56 DetectorConstruction::DetectorConstruction()       57 DetectorConstruction::DetectorConstruction()
                                                   >>  58  :G4VUserDetectorConstruction(),
                                                   >>  59   fWorldMaterial(nullptr),fSolidWorld(nullptr),fLogicWorld(nullptr),
                                                   >>  60   fPhysiWorld(nullptr),fSolidCalor(nullptr),fLogicCalor(nullptr),
                                                   >>  61   fPhysiCalor(nullptr),fSolidLayer(nullptr),fLogicLayer(nullptr),
                                                   >>  62   fPhysiLayer(nullptr)
 57 {                                                  63 {
 58   for (G4int i = 0; i < kMaxAbsor; ++i) {      <<  64   for(G4int i=0; i<kMaxAbsor; ++i) { 
 59     fAbsorMaterial[i] = nullptr;               <<  65     fAbsorMaterial[i] = nullptr; 
 60     fAbsorThickness[i] = 0.0;                      66     fAbsorThickness[i] = 0.0;
 61     fSolidAbsor[i] = nullptr;                      67     fSolidAbsor[i] = nullptr;
 62     fLogicAbsor[i] = nullptr;                      68     fLogicAbsor[i] = nullptr;
 63     fPhysiAbsor[i] = nullptr;                      69     fPhysiAbsor[i] = nullptr;
 64   }                                            <<  70   } 
 65                                                    71 
 66   // default parameter values of the calorimet     72   // default parameter values of the calorimeter
 67   fNbOfAbsor = 2;                                  73   fNbOfAbsor = 2;
 68   fAbsorThickness[1] = 36 * mm;                <<  74   fAbsorThickness[1] = 36*mm;
 69   fAbsorThickness[2] = 4 * mm;                 <<  75   fAbsorThickness[2] = 4*mm;
 70   fNbOfLayers = 50;                            <<  76   fNbOfLayers        = 50;
 71   fCalorSizeYZ = 1.5 * m;                      <<  77   fCalorSizeYZ       = 1.5*m;
 72   ComputeCalorParameters();                        78   ComputeCalorParameters();
 73                                                    79 
 74   // materials                                     80   // materials
 75   DefineMaterials();                               81   DefineMaterials();
 76   SetWorldMaterial("Galactic");                    82   SetWorldMaterial("Galactic");
 77   SetAbsorMaterial(1, "Iron");                 <<  83   SetAbsorMaterial(1,"Iron");
 78   SetAbsorMaterial(2, "Scintillator");         <<  84   SetAbsorMaterial(2,"Scintillator");
 79                                                    85 
 80   // create commands for interactive definitio     86   // create commands for interactive definition of the calorimeter
 81   fDetectorMessenger = new DetectorMessenger(t     87   fDetectorMessenger = new DetectorMessenger(this);
 82 }                                                  88 }
 83                                                    89 
 84 //....oooOO0OOooo........oooOO0OOooo........oo     90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 85                                                    91 
 86 DetectorConstruction::~DetectorConstruction()      92 DetectorConstruction::~DetectorConstruction()
 87 {                                                  93 {
 88   delete fDetectorMessenger;                       94   delete fDetectorMessenger;
 89 }                                                  95 }
 90                                                    96 
 91 //....oooOO0OOooo........oooOO0OOooo........oo     97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 92                                                    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   G4Element* H = manager->FindOrBuildElement(1 << 108   G4Element* H  = manager->FindOrBuildElement(1);
103   G4Element* C = manager->FindOrBuildElement(6 << 109   G4Element* C  = manager->FindOrBuildElement(6);
104   G4Element* O = manager->FindOrBuildElement(8 << 110   G4Element* O  = manager->FindOrBuildElement(8);
105   //                                              111   //
106   // define an Element from isotopes, by relat    112   // define an Element from isotopes, by relative abundance
107   //                                              113   //
108   G4int iz, n;  // iz=number of protons  in an << 114   G4int iz, n;                       //iz=number of protons  in an isotope;
109                 //  n=number of nucleons in an << 115                                      // n=number of nucleons in an isotope;                            
110   G4int ncomponents;                           << 116   G4int   ncomponents;
111   G4double z, a;                               << 117   G4double z, a;                                     
112   G4double abundance;                          << 118   G4double abundance;                                     
113                                                << 119 
114   G4Isotope* U5 = new G4Isotope("U235", iz = 9 << 120   G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole);
115   G4Isotope* U8 = new G4Isotope("U238", iz = 9 << 121   G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole);
116                                                << 122 
117   G4Element* U = new G4Element("enriched Urani << 123   G4Element* U  = new G4Element("enriched Uranium", "U", ncomponents=2);
118   U->AddIsotope(U5, abundance = 90. * perCent) << 124   U->AddIsotope(U5, abundance= 90.*perCent);
119   U->AddIsotope(U8, abundance = 10. * perCent) << 125   U->AddIsotope(U8, abundance= 10.*perCent);
120                                                   126 
121   //                                              127   //
122   // define simple materials                      128   // define simple materials
123   //                                              129   //
124   G4double density;                               130   G4double density;
125                                                   131 
126   new G4Material("liquidH2", z = 1., a = 1.008 << 132   new G4Material("liquidH2",    z=1.,  a= 1.008*g/mole,  density= 70.8*mg/cm3);
127   new G4Material("Aluminium", z = 13., a = 26. << 133   new G4Material("Aluminium",   z=13., a= 26.98*g/mole,  density= 2.700*g/cm3);
128   new G4Material("liquidArgon", z = 18, a = 39 << 134   new G4Material("liquidArgon", z=18,  a= 39.948*g/mole, density= 1.396*g/cm3);
129   new G4Material("Titanium", z = 22., a = 47.8 << 135   new G4Material("Titanium",    z=22., a= 47.867*g/mole, density= 4.54*g/cm3);
130   new G4Material("Iron", z = 26., a = 55.85 *  << 136   new G4Material("Iron",        z=26., a= 55.85*g/mole,  density= 7.870*g/cm3);
131   new G4Material("Copper", z = 29., a = 63.55  << 137   new G4Material("Copper",      z=29., a= 63.55*g/mole,  density= 8.960*g/cm3);
132   new G4Material("Tungsten", z = 74., a = 183. << 138   new G4Material("Tungsten",    z=74., a= 183.85*g/mole, density= 19.30*g/cm3);
133   new G4Material("Gold", z = 79., a = 196.97 * << 139   new G4Material("Gold",        z=79., a= 196.97*g/mole, density= 19.32*g/cm3);
134   new G4Material("Lead", z = 82., a = 207.20 * << 140   new G4Material("Lead",        z=82., a= 207.20*g/mole, density= 11.35*g/cm3);  
135   new G4Material("Uranium", z = 92., a = 238.0 << 141   new G4Material("Uranium",     z=92., a= 238.03*g/mole, density= 18.95*g/cm3);
136                                                   142 
137   //                                              143   //
138   // define a material from elements.   case 1    144   // define a material from elements.   case 1: chemical molecule
139   //                                              145   //
140   G4int natoms;                                   146   G4int natoms;
141                                                   147 
142   G4Material* H2O = new G4Material("Water", de << 148   G4Material* H2O = 
143   H2O->AddElement(H, natoms = 2);              << 149   new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
144   H2O->AddElement(O, natoms = 1);              << 150   H2O->AddElement(H, natoms=2);
145   H2O->GetIonisation()->SetMeanExcitationEnerg << 151   H2O->AddElement(O, natoms=1);
                                                   >> 152   H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
146   H2O->SetChemicalFormula("H_2O");                153   H2O->SetChemicalFormula("H_2O");
147                                                << 154   
148   G4Material* CH = new G4Material("Polystyrene << 155   G4Material* CH = 
149   CH->AddElement(C, natoms = 1);               << 156   new G4Material("Polystyrene", density= 1.032*g/cm3, ncomponents=2);
150   CH->AddElement(H, natoms = 1);               << 157   CH->AddElement(C, natoms=1);
151                                                << 158   CH->AddElement(H, natoms=1);
152   G4Material* Sci = new G4Material("Scintillat << 159 
153   Sci->AddElement(C, natoms = 9);              << 160   G4Material* Sci = 
154   Sci->AddElement(H, natoms = 10);             << 161   new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
155                                                << 162   Sci->AddElement(C, natoms=9);
156   Sci->GetIonisation()->SetBirksConstant(0.126 << 163   Sci->AddElement(H, natoms=10);
                                                   >> 164   
                                                   >> 165   Sci->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
157                                                   166 
158   //                                              167   //
159   // examples of gas in non STP conditions        168   // examples of gas in non STP conditions
160   //                                              169   //
161   G4double temperature, pressure;                 170   G4double temperature, pressure;
162                                                << 171   
163   G4Material* CO2 =                            << 172   G4Material* CO2 = 
164     new G4Material("CarbonicGas", density = 27 << 173   new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
165                    temperature = 325. * kelvin << 174                  kStateGas, temperature= 325.*kelvin, pressure= 50.*atmosphere);
166   CO2->AddElement(C, natoms = 1);              << 175   CO2->AddElement(C, natoms=1);
167   CO2->AddElement(O, natoms = 2);              << 176   CO2->AddElement(O, natoms=2);
168                                                << 177   
169   new G4Material("ArgonGas", z = 18, a = 39.94 << 178   new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
170                  273.15 * kelvin, 1 * atmosphe << 179                  kStateGas, 273.15*kelvin, 1*atmosphere);
171   //                                              180   //
172   // example of vacuum                            181   // example of vacuum
173   //                                              182   //
174   density = universe_mean_density;  // from Ph << 183   density     = universe_mean_density;    //from PhysicalConstants.h
175   pressure = 3.e-18 * pascal;                  << 184   pressure    = 3.e-18*pascal;
176   temperature = 2.73 * kelvin;                 << 185   temperature = 2.73*kelvin;
177   new G4Material("Galactic", z = 1., a = 1.008 << 186   new G4Material("Galactic", z=1., a=1.008*g/mole, density,
178                  pressure);                    << 187                              kStateGas,temperature,pressure);
179                                                   188 
180   //  G4cout << *(G4Material::GetMaterialTable    189   //  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
181 }                                                 190 }
182                                                   191 
183 //....oooOO0OOooo........oooOO0OOooo........oo    192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184                                                   193 
185 G4Material* DetectorConstruction::MaterialWith << 194 G4Material* DetectorConstruction::MaterialWithSingleIsotope( G4String name,
186                                                << 195                            G4String symbol, G4double density, G4int Z, G4int A)
187 {                                                 196 {
188   // define a material from an isotope         << 197  // define a material from an isotope
189   //                                           << 198  //
190   G4int ncomponents;                           << 199  G4int ncomponents;
191   G4double abundance, massfraction;            << 200  G4double abundance, massfraction;
192                                                << 201 
193   G4Isotope* isotope = new G4Isotope(symbol, Z << 202  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
                                                   >> 203  
                                                   >> 204  G4Element* element  = new G4Element(name, symbol, ncomponents=1);
                                                   >> 205  element->AddIsotope(isotope, abundance= 100.*perCent);
                                                   >> 206  
                                                   >> 207  G4Material* material = new G4Material(name, density, ncomponents=1);
                                                   >> 208  material->AddElement(element, massfraction=100.*perCent);
194                                                   209 
195   G4Element* element = new G4Element(name, sym << 210  return material;
196   element->AddIsotope(isotope, abundance = 100 << 
197                                                << 
198   G4Material* material = new G4Material(name,  << 
199   material->AddElement(element, massfraction = << 
200                                                << 
201   return material;                             << 
202 }                                                 211 }
203                                                   212 
204 //....oooOO0OOooo........oooOO0OOooo........oo    213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205                                                   214 
206 void DetectorConstruction::ComputeCalorParamet    215 void DetectorConstruction::ComputeCalorParameters()
207 {                                                 216 {
208   // Compute derived parameters of the calorim    217   // Compute derived parameters of the calorimeter
209   fLayerThickness = 0.;                           218   fLayerThickness = 0.;
210   for (G4int iAbs = 1; iAbs <= fNbOfAbsor; iAb << 219   for (G4int iAbs=1; iAbs<=fNbOfAbsor; iAbs++) {
211     fLayerThickness += fAbsorThickness[iAbs];     220     fLayerThickness += fAbsorThickness[iAbs];
212   }                                               221   }
213   fCalorThickness = fNbOfLayers * fLayerThickn << 222   fCalorThickness = fNbOfLayers*fLayerThickness;     
214   fWorldSizeX = 1.2 * fCalorThickness;         << 223   fWorldSizeX = 1.2*fCalorThickness; 
215   fWorldSizeYZ = 1.2 * fCalorSizeYZ;           << 224   fWorldSizeYZ = 1.2*fCalorSizeYZ;
216 }                                                 225 }
217                                                   226 
218 //....oooOO0OOooo........oooOO0OOooo........oo    227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
219                                                   228 
220 G4VPhysicalVolume* DetectorConstruction::Const    229 G4VPhysicalVolume* DetectorConstruction::Construct()
221 {                                                 230 {
222   if (fPhysiWorld) {                           << 231   if(fPhysiWorld) { return fPhysiWorld; }
223     return fPhysiWorld;                        << 
224   }                                            << 
225   // complete the Calor parameters definition     232   // complete the Calor parameters definition
226   ComputeCalorParameters();                       233   ComputeCalorParameters();
227                                                   234 
228   //                                              235   //
229   // World                                        236   // World
230   //                                              237   //
231   fSolidWorld = new G4Box("World",  // its nam << 238   fSolidWorld = new G4Box("World",                                //its name
232                           fWorldSizeX / 2, fWo << 239                    fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2);  //its size
233                                                   240 
234   fLogicWorld = new G4LogicalVolume(fSolidWorl << 241   fLogicWorld = new G4LogicalVolume(fSolidWorld,        //its solid
235                                     fWorldMate << 242                                     fWorldMaterial,     //its material
236                                     "World");  << 243                                     "World");           //its name
237                                                << 244 
238   fPhysiWorld = new G4PVPlacement(0,  // no ro << 245   fPhysiWorld = new G4PVPlacement(0,                    //no rotation
239                                   G4ThreeVecto << 246                                   G4ThreeVector(),      //at (0,0,0)
240                                   fLogicWorld, << 247                                   fLogicWorld,          //its fLogical volume
241                                   "World",  // << 248                                   "World",              //its name
242                                   0,  // its m << 249                                   0,                    //its mother  volume
243                                   false,  // n << 250                                   false,                //no boolean operation
244                                   0);  // copy << 251                                   0);                   //copy number
245   //                                              252   //
246   // Calorimeter                                  253   // Calorimeter
247   //                                              254   //
248                                                   255 
249   fSolidCalor = new G4Box("Calorimeter", fCalo << 256   fSolidCalor = new G4Box("Calorimeter",                                  
                                                   >> 257                        fCalorThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
250                                                   258 
251   fLogicCalor = new G4LogicalVolume(fSolidCalo << 259   fLogicCalor = new G4LogicalVolume(fSolidCalor,               
252                                                << 260                                     fWorldMaterial,     
253   fPhysiCalor = new G4PVPlacement(0,  // no ro << 261                                     "Calorimeter");      
254                                   G4ThreeVecto << 262 
255                                   fLogicCalor, << 263   fPhysiCalor = new G4PVPlacement(0,                     //no rotation
256                                   "Calorimeter << 264                                  G4ThreeVector(),        //at (0,0,0)
257                                   fLogicWorld, << 265                                  fLogicCalor,            //its fLogical volume
258                                   false,  // n << 266                                  "Calorimeter",          //its name
259                                   0);  // copy << 267                                  fLogicWorld,            //its mother  volume
                                                   >> 268                                  false,                  //no boolean operation
                                                   >> 269                                  0);                     //copy number
260                                                   270 
261   //                                              271   //
262   // Layers                                       272   // Layers
263   //                                              273   //
264                                                   274 
265   fSolidLayer = new G4Box("Layer", fLayerThick << 275   fSolidLayer = new G4Box("Layer",                               
                                                   >> 276                           fLayerThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
266                                                   277 
267   fLogicLayer = new G4LogicalVolume(fSolidLaye << 278   fLogicLayer = new G4LogicalVolume(fSolidLayer,      
                                                   >> 279                                     fWorldMaterial,   
                                                   >> 280                                     "Layer");              
268   if (fNbOfLayers > 1) {                          281   if (fNbOfLayers > 1) {
269     fPhysiLayer =                              << 282     fPhysiLayer = new G4PVReplica("Layer",              
270       new G4PVReplica("Layer", fLogicLayer, fL << 283                                   fLogicLayer,     
271   }                                            << 284                                   fLogicCalor,      
272   else {                                       << 285                                   kXAxis,              
273     fPhysiLayer =                              << 286                                   fNbOfLayers,            
274       new G4PVPlacement(0, G4ThreeVector(), fL << 287                                   fLayerThickness);     
                                                   >> 288   } else {
                                                   >> 289     fPhysiLayer = new G4PVPlacement(0,                   
                                                   >> 290                                    G4ThreeVector(),     
                                                   >> 291                                    fLogicLayer,           
                                                   >> 292                                    "Layer",             
                                                   >> 293                                    fLogicCalor,         
                                                   >> 294                                    false,             
                                                   >> 295                                    0);                    
275   }                                               296   }
276   //                                              297   //
277   // Absorbers                                    298   // Absorbers
278   //                                              299   //
279                                                   300 
280   G4double xfront = -0.5 * fLayerThickness;    << 301   G4double xfront = -0.5*fLayerThickness;
281   for (G4int k = 1; k <= fNbOfAbsor; ++k) {    << 302   for (G4int k=1; k<=fNbOfAbsor; ++k) {
282     fSolidAbsor[k] = new G4Box("Absorber",  // << 303     fSolidAbsor[k] = new G4Box("Absorber",                //its name
283                                fAbsorThickness << 304                          fAbsorThickness[k]/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
284                                                   305 
285     fLogicAbsor[k] = new G4LogicalVolume(fSoli << 306     fLogicAbsor[k] = new G4LogicalVolume(fSolidAbsor[k],    //its solid
286                                          fAbso << 307                                          fAbsorMaterial[k], //its material
287                                          fAbso    308                                          fAbsorMaterial[k]->GetName());
288                                                   309 
289     G4double xcenter = xfront + 0.5 * fAbsorTh << 310     G4double xcenter = xfront+0.5*fAbsorThickness[k];
290     xfront += fAbsorThickness[k];                 311     xfront += fAbsorThickness[k];
291     fPhysiAbsor[k] = new G4PVPlacement(0, G4Th << 312     fPhysiAbsor[k] = new G4PVPlacement(0,              
292                                        fAbsorM << 313                          G4ThreeVector(xcenter,0.,0.),
293                                        k);  // << 314                          fLogicAbsor[k],               
                                                   >> 315                          fAbsorMaterial[k]->GetName(),
                                                   >> 316                          fLogicLayer,                  
                                                   >> 317                          false,                      
                                                   >> 318                          k);                                //copy number
                                                   >> 319 
294   }                                               320   }
295                                                   321 
296   PrintCalorParameters();                         322   PrintCalorParameters();
297                                                   323 
298   // always return the fPhysical World         << 324   //always return the fPhysical World
299   //                                              325   //
300   return fPhysiWorld;                             326   return fPhysiWorld;
301 }                                                 327 }
302                                                   328 
303 //....oooOO0OOooo........oooOO0OOooo........oo    329 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
304                                                   330 
305 void DetectorConstruction::PrintCalorParameter    331 void DetectorConstruction::PrintCalorParameters()
306 {                                                 332 {
307   G4int prec = 4, wid = prec + 2;              << 333   G4int prec = 4, wid = prec + 2;  
308   G4int dfprec = G4cout.precision(prec);          334   G4int dfprec = G4cout.precision(prec);
309                                                << 335   
310   G4double totLength(0.), totRadl(0.), totNucl    336   G4double totLength(0.), totRadl(0.), totNuclear(0.);
311                                                << 337   
312   G4cout << "\n-------------------------------    338   G4cout << "\n-------------------------------------------------------------"
313          << "\n ---> The calorimeter is " << f    339          << "\n ---> The calorimeter is " << fNbOfLayers << " layers of:";
314   for (G4int i = 1; i <= fNbOfAbsor; ++i) {    << 340   for (G4int i=1; i<=fNbOfAbsor; ++i) {
315     G4Material* material = fAbsorMaterial[i];     341     G4Material* material = fAbsorMaterial[i];
316     G4double radl = material->GetRadlen();        342     G4double radl = material->GetRadlen();
317     G4double nuclearl = material->GetNuclearIn    343     G4double nuclearl = material->GetNuclearInterLength();
318     G4double sumThickness = fNbOfLayers * fAbs << 344     G4double sumThickness = fNbOfLayers*fAbsorThickness[i];
319     G4double nbRadl = sumThickness / radl;     << 345     G4double nbRadl = sumThickness/radl;
320     G4double nbNuclearl = sumThickness / nucle << 346     G4double nbNuclearl = sumThickness/nuclearl;
321     totLength += sumThickness;                    347     totLength += sumThickness;
322     totRadl += nbRadl;                            348     totRadl += nbRadl;
323     totNuclear += nbNuclearl;                     349     totNuclear += nbNuclearl;
324     G4cout << "\n   " << std::setw(12) << fAbs << 350     G4cout << "\n   " << std::setw(12) << fAbsorMaterial[i]->GetName() <<": "
325            << G4BestUnit(fAbsorThickness[i], " << 351            << std::setw(wid) << G4BestUnit(fAbsorThickness[i],"Length")
326            << G4BestUnit(sumThickness, "Length << 352            << "  --->  sum = " << std::setw(wid) << G4BestUnit(sumThickness,"Length")
327            << " = " << std::setw(wid) << nbNuc << 353            << " = " << std::setw(wid) << nbRadl << " Radl "
328   }                                            << 354            << " = " << std::setw(wid) << nbNuclearl << " NuclearInteractionLength " ;
329   G4cout << "\n\n                       total  << 355   }
330          << G4BestUnit(totLength, "Length") << << 356   G4cout << "\n\n                       total thickness = " 
331          << " = " << std::setw(wid) << totNucl << 357                   << std::setw(wid) << G4BestUnit(totLength,"Length")
332                                                << 358          << " = " << std::setw(wid)<< totRadl << " Radl "
333   G4cout << "                     transverse s << 359          << " = " << std::setw(wid)<< totNuclear << " NuclearInteractionLength "
334          << G4BestUnit(fCalorSizeYZ, "Length") << 360          << G4endl;
                                                   >> 361          
                                                   >> 362   G4cout << "                     transverse sizeYZ = " 
                                                   >> 363                   << std::setw(wid) << G4BestUnit(fCalorSizeYZ,"Length")
                                                   >> 364          << G4endl;         
335   G4cout << "---------------------------------    365   G4cout << "-------------------------------------------------------------\n";
336                                                << 366   
337   G4cout << "\n" << fWorldMaterial << G4endl;  << 367   G4cout << "\n" << fWorldMaterial << G4endl;    
338   for (G4int j = 1; j <= fNbOfAbsor; ++j) {    << 368   for (G4int j=1; j<=fNbOfAbsor; ++j) {
339     G4cout << "\n" << fAbsorMaterial[j] << G4e    369     G4cout << "\n" << fAbsorMaterial[j] << G4endl;
340   }                                               370   }
341   G4cout << "\n-------------------------------    371   G4cout << "\n-------------------------------------------------------------\n";
342                                                << 372   
343   // restore default format                    << 373   //restore default format         
344   G4cout.precision(dfprec);                    << 374   G4cout.precision(dfprec);   
345 }                                                 375 }
346                                                   376 
347 //....oooOO0OOooo........oooOO0OOooo........oo    377 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
348                                                   378 
349 void DetectorConstruction::SetWorldMaterial(co    379 void DetectorConstruction::SetWorldMaterial(const G4String& material)
350 {                                                 380 {
351   // search the material by its name              381   // search the material by its name
352   G4Material* pttoMaterial = G4NistManager::In << 382   G4Material* pttoMaterial = 
353   if (pttoMaterial) {                          << 383     G4NistManager::Instance()->FindOrBuildMaterial(material);
                                                   >> 384   if(pttoMaterial) { 
354     fWorldMaterial = pttoMaterial;                385     fWorldMaterial = pttoMaterial;
355     if (fLogicWorld) {                         << 386     if(fLogicWorld) {
356       fLogicWorld->SetMaterial(fWorldMaterial)    387       fLogicWorld->SetMaterial(fWorldMaterial);
357       fLogicLayer->SetMaterial(fWorldMaterial)    388       fLogicLayer->SetMaterial(fWorldMaterial);
358       G4RunManager::GetRunManager()->PhysicsHa    389       G4RunManager::GetRunManager()->PhysicsHasBeenModified();
359     }                                             390     }
360   }                                               391   }
361 }                                                 392 }
362                                                   393 
363 //....oooOO0OOooo........oooOO0OOooo........oo    394 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
364                                                   395 
365 void DetectorConstruction::SetNbOfLayers(G4int    396 void DetectorConstruction::SetNbOfLayers(G4int ival)
366 {                                                 397 {
367   // set the number of Layers                     398   // set the number of Layers
368   //                                              399   //
369   if (ival < 1) {                              << 400   if (ival < 1)
370     G4cout << "\n --->warning from SetfNbOfLay << 401     { G4cout << "\n --->warning from SetfNbOfLayers: "
371            << " must be at least 1. Command re << 402              << ival << " must be at least 1. Command refused" << G4endl;
372     return;                                    << 403       return;
373   }                                            << 404     }
374   fNbOfLayers = ival;                             405   fNbOfLayers = ival;
375 }                                                 406 }
376                                                   407 
377 //....oooOO0OOooo........oooOO0OOooo........oo    408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
378                                                   409 
379 void DetectorConstruction::SetNbOfAbsor(G4int     410 void DetectorConstruction::SetNbOfAbsor(G4int ival)
380 {                                                 411 {
381   // set the number of Absorbers                  412   // set the number of Absorbers
382   //                                              413   //
383   if (ival < 1 || ival > (kMaxAbsor - 1)) {    << 414   if (ival < 1 || ival > (kMaxAbsor-1))
384     G4cout << "\n ---> warning from SetfNbOfAb << 415     { G4cout << "\n ---> warning from SetfNbOfAbsor: "
385            << kMaxAbsor - 1 << ". Command refu << 416              << ival << " must be at least 1 and and most " << kMaxAbsor-1
386     return;                                    << 417              << ". Command refused" << G4endl;
387   }                                            << 418       return;
                                                   >> 419     }
388   fNbOfAbsor = ival;                              420   fNbOfAbsor = ival;
389 }                                                 421 }
390                                                   422 
391 //....oooOO0OOooo........oooOO0OOooo........oo    423 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
392                                                   424 
393 void DetectorConstruction::SetAbsorMaterial(G4 << 425 void DetectorConstruction::SetAbsorMaterial(G4int ival,
                                                   >> 426                                             const G4String& material)
394 {                                                 427 {
395   // search the material by its name              428   // search the material by its name
396   //                                              429   //
397   if (ival > fNbOfAbsor || ival <= 0) {        << 430   if (ival > fNbOfAbsor || ival <= 0)
398     G4cout << "\n --->warning from SetAbsorMat << 431     { G4cout << "\n --->warning from SetAbsorMaterial: absor number "
399            << " out of range. Command refused" << 432              << ival << " out of range. Command refused" << G4endl;
400     return;                                    << 433       return;
401   }                                            << 434     }
402                                                   435 
403   G4Material* pttoMaterial = G4NistManager::In << 436   G4Material* pttoMaterial = 
                                                   >> 437     G4NistManager::Instance()->FindOrBuildMaterial(material);
404   if (pttoMaterial) {                             438   if (pttoMaterial) {
405     fAbsorMaterial[ival] = pttoMaterial;          439     fAbsorMaterial[ival] = pttoMaterial;
406     if (fLogicAbsor[ival]) {                   << 440     if(fLogicAbsor[ival]) {
407       fLogicAbsor[ival]->SetMaterial(pttoMater    441       fLogicAbsor[ival]->SetMaterial(pttoMaterial);
408       G4RunManager::GetRunManager()->PhysicsHa << 442       G4RunManager::GetRunManager()->PhysicsHasBeenModified();    
409     }                                             443     }
410   }                                               444   }
411 }                                                 445 }
412                                                   446 
413 //....oooOO0OOooo........oooOO0OOooo........oo    447 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
414                                                   448 
415 void DetectorConstruction::SetAbsorThickness(G    449 void DetectorConstruction::SetAbsorThickness(G4int ival, G4double val)
416 {                                                 450 {
417   // change Absorber thickness                    451   // change Absorber thickness
418   //                                              452   //
419   if (ival > fNbOfAbsor || ival <= 0) {        << 453   if (ival > fNbOfAbsor || ival <= 0)
420     G4cout << "\n --->warning from SetAbsorThi << 454     { G4cout << "\n --->warning from SetAbsorThickness: absor number "
421            << " out of range. Command refused" << 455              << ival << " out of range. Command refused" << G4endl;
422     return;                                    << 456       return;
423   }                                            << 457     }
424   if (val <= DBL_MIN) {                        << 458   if (val <= DBL_MIN)
425     G4cout << "\n --->warning from SetAbsorThi << 459     { G4cout << "\n --->warning from SetAbsorThickness: thickness "
426            << " out of range. Command refused" << 460              << val  << " out of range. Command refused" << G4endl;
427     return;                                    << 461       return;
428   }                                            << 462     }
429   fAbsorThickness[ival] = val;                    463   fAbsorThickness[ival] = val;
430 }                                                 464 }
431                                                   465 
432 //....oooOO0OOooo........oooOO0OOooo........oo    466 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
433                                                   467 
434 void DetectorConstruction::SetCalorSizeYZ(G4do    468 void DetectorConstruction::SetCalorSizeYZ(G4double val)
435 {                                                 469 {
436   // change the transverse size                   470   // change the transverse size
437   //                                              471   //
438   if (val <= DBL_MIN) {                        << 472   if (val <= DBL_MIN)
439     G4cout << "\n --->warning from SetfCalorSi << 473     { G4cout << "\n --->warning from SetfCalorSizeYZ: thickness "
440            << " out of range. Command refused" << 474              << val  << " out of range. Command refused" << G4endl;
441     return;                                    << 475       return;
442   }                                            << 476     }
443   fCalorSizeYZ = val;                             477   fCalorSizeYZ = val;
444 }                                                 478 }
445                                                   479 
446 //....oooOO0OOooo........oooOO0OOooo........oo    480 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
447                                                   481 
448 #include "G4AutoDelete.hh"                     << 
449 #include "G4GlobalMagFieldMessenger.hh"           482 #include "G4GlobalMagFieldMessenger.hh"
                                                   >> 483 #include "G4AutoDelete.hh"
450                                                   484 
451 void DetectorConstruction::ConstructSDandField    485 void DetectorConstruction::ConstructSDandField()
452 {                                                 486 {
453   if (fFieldMessenger.Get() == nullptr) {      << 487   if ( fFieldMessenger.Get() == nullptr ) {
454     // Create global magnetic field messenger.    488     // Create global magnetic field messenger.
455     // Uniform magnetic field is then created     489     // Uniform magnetic field is then created automatically if
456     // the field value is not zero.               490     // the field value is not zero.
457     G4ThreeVector fieldValue = G4ThreeVector()    491     G4ThreeVector fieldValue = G4ThreeVector();
458     G4GlobalMagFieldMessenger* msg = new G4Glo << 492     G4GlobalMagFieldMessenger* msg =
459     // msg->SetVerboseLevel(1);                << 493       new G4GlobalMagFieldMessenger(fieldValue);
                                                   >> 494     //msg->SetVerboseLevel(1);
460     G4AutoDelete::Register(msg);                  495     G4AutoDelete::Register(msg);
461     fFieldMessenger.Put(msg);                  << 496     fFieldMessenger.Put( msg );        
462   }                                               497   }
463 }                                                 498 }
464                                                   499 
465 //....oooOO0OOooo........oooOO0OOooo........oo    500 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
466                                                   501