Geant4 Cross Reference

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


  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/TestEm7/src/Detector     26 /// \file electromagnetic/TestEm7/src/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 "G4Material.hh"
 37 #include "G4Box.hh"                                37 #include "G4Box.hh"
 38 #include "G4FieldManager.hh"                   << 
 39 #include "G4GeometryManager.hh"                << 
 40 #include "G4LogicalVolume.hh"                      38 #include "G4LogicalVolume.hh"
 41 #include "G4LogicalVolumeStore.hh"             << 
 42 #include "G4Material.hh"                       << 
 43 #include "G4NistManager.hh"                    << 
 44 #include "G4PVPlacement.hh"                        39 #include "G4PVPlacement.hh"
 45 #include "G4PhysicalConstants.hh"              <<  40 #include "G4UniformMagField.hh"
                                                   >>  41 
                                                   >>  42 #include "G4GeometryManager.hh"
 46 #include "G4PhysicalVolumeStore.hh"                43 #include "G4PhysicalVolumeStore.hh"
 47 #include "G4RunManager.hh"                     <<  44 #include "G4LogicalVolumeStore.hh"
 48 #include "G4SolidStore.hh"                         45 #include "G4SolidStore.hh"
 49 #include "G4SystemOfUnits.hh"                  <<  46 
 50 #include "G4TransportationManager.hh"          <<  47 #include "G4NistManager.hh"
 51 #include "G4UniformMagField.hh"                << 
 52 #include "G4UnitsTable.hh"                         48 #include "G4UnitsTable.hh"
 53                                                    49 
                                                   >>  50 #include "G4FieldManager.hh"
                                                   >>  51 #include "G4TransportationManager.hh"
                                                   >>  52 #include "G4RunManager.hh" 
                                                   >>  53 
                                                   >>  54 #include "G4PhysicalConstants.hh"
                                                   >>  55 #include "G4SystemOfUnits.hh"
                                                   >>  56 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    58 
 56 DetectorConstruction::DetectorConstruction()       59 DetectorConstruction::DetectorConstruction()
 57   : G4VUserDetectorConstruction(), fMagField(n <<  60   : G4VUserDetectorConstruction(), 
                                                   >>  61     fMagField(nullptr), 
                                                   >>  62     fLAbsor(nullptr),
                                                   >>  63     fLWorld(nullptr)
 58 {                                                  64 {
 59   // default parameter values                      65   // default parameter values
 60   fAbsorSizeX = fAbsorSizeYZ = 20 * cm;        <<  66   fAbsorSizeX = fAbsorSizeYZ = 20*cm;
 61   fWorldSizeX = fWorldSizeYZ = 1.2 * fAbsorSiz <<  67   fWorldSizeX = fWorldSizeYZ = 1.2*fAbsorSizeX;
 62                                                <<  68   
 63   fTallyNumber = 0;                                69   fTallyNumber = 0;
 64   for (G4int j = 0; j < kMaxTally; j++) {      <<  70   for (G4int j=0; j<kMaxTally; j++) {
 65     fTallySize[j] = fTallyPosition[j] = G4Thre <<  71     fTallySize[j] = fTallyPosition[j] = G4ThreeVector(0.,0.,0.);
 66     fTallyMass[j] = 0.;                        <<  72     fTallyMass[j]     = 0.;
 67     fLTally[j] = nullptr;                      <<  73     fLTally[j]        = nullptr; 
 68   }                                                74   }
 69                                                <<  75     
 70   DefineMaterials();                               76   DefineMaterials();
 71                                                    77 
 72   // create commands for interactive definitio <<  78   // create commands for interactive definition of the detector  
 73   fDetectorMessenger = new DetectorMessenger(t     79   fDetectorMessenger = new DetectorMessenger(this);
 74 }                                                  80 }
 75                                                    81 
 76 //....oooOO0OOooo........oooOO0OOooo........oo     82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 77                                                    83 
 78 DetectorConstruction::~DetectorConstruction()      84 DetectorConstruction::~DetectorConstruction()
 79 {                                              <<  85 { 
 80   delete fDetectorMessenger;                       86   delete fDetectorMessenger;
 81 }                                                  87 }
 82                                                    88 
 83 //....oooOO0OOooo........oooOO0OOooo........oo     89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 84                                                    90 
 85 void DetectorConstruction::DefineMaterials()       91 void DetectorConstruction::DefineMaterials()
 86 {                                              <<  92 { 
 87   //                                               93   //
 88   // define Elements                               94   // define Elements
 89   //                                               95   //
 90   G4double z, a;                                   96   G4double z, a;
 91                                                    97 
 92   G4Element* H = new G4Element("Hydrogen", "H" <<  98   G4Element* H = new G4Element("Hydrogen", "H", z= 1, a= 1.008*g/mole);
 93   G4Element* N = new G4Element("Nitrogen", "N" <<  99   G4Element* N = new G4Element("Nitrogen", "N", z= 7, a= 14.01*g/mole);
 94   G4Element* O = new G4Element("Oxygen", "O",  << 100   G4Element* O = new G4Element("Oxygen"  , "O", z= 8, a= 16.00*g/mole);
 95                                                   101 
 96   //                                              102   //
 97   // define Materials.                            103   // define Materials.
 98   //                                              104   //
 99   G4double density, temperature, pressure;        105   G4double density, temperature, pressure;
100   G4int ncomponents, natoms;                   << 106   G4int    ncomponents, natoms;
101   G4double fractionmass;                          107   G4double fractionmass;
102                                                << 108  
103   G4Material* H2O = new G4Material("Water", de << 109   G4Material* H2O = 
104   H2O->AddElement(H, natoms = 2);              << 110     new G4Material("Water", density= 1.0*g/cm3, ncomponents=2);
105   H2O->AddElement(O, natoms = 1);              << 111   H2O->AddElement(H, natoms=2);
106   H2O->GetIonisation()->SetMeanExcitationEnerg << 112   H2O->AddElement(O, natoms=1);
                                                   >> 113   H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
107                                                   114 
108   // In this line both G4_WATER and Water_1.05    115   // In this line both G4_WATER and Water_1.05 will be constructed
109   G4NistManager::Instance()->BuildMaterialWith << 116   G4NistManager::Instance()->
                                                   >> 117     BuildMaterialWithNewDensity("Water_1.05","G4_WATER",1.05*g/cm3);
110                                                   118 
111   G4Material* Air = new G4Material("Air", dens << 119   G4Material* Air = 
112   Air->AddElement(N, fractionmass = 0.7);      << 120     new G4Material("Air"  , density= 1.290*mg/cm3, ncomponents=2);
113   Air->AddElement(O, fractionmass = 0.3);      << 121   Air->AddElement(N, fractionmass=0.7);
                                                   >> 122   Air->AddElement(O, fractionmass=0.3);
114                                                   123 
115   density = 1.e-5 * g / cm3;                   << 124   density     = 1.e-5*g/cm3;
116   pressure = 2.e-2 * bar;                      << 125   pressure    = 2.e-2*bar;
117   temperature = STP_Temperature;  // From Phys    126   temperature = STP_Temperature;  // From PhysicalConstants.h .
118   G4Material* vac = new G4Material("TechVacuum << 127   G4Material* vac = new G4Material( "TechVacuum", density, 1,
119   vac->AddMaterial(Air, 1.);                   << 128                            kStateGas, temperature, pressure );
                                                   >> 129   vac->AddMaterial( Air, 1. );
                                                   >> 130 
                                                   >> 131   density     = universe_mean_density;    //from PhysicalConstants.h
                                                   >> 132   pressure    = 3.e-18*pascal;
                                                   >> 133   temperature = 2.73*kelvin;
                                                   >> 134   G4Material* vacuum = 
                                                   >> 135     new G4Material("Galactic",z= 1,a= 1.008*g/mole,density,
                                                   >> 136                    kStateGas,temperature,pressure);
120                                                   137 
121   density = universe_mean_density;  // from Ph << 138   //default materials
122   pressure = 3.e-18 * pascal;                  << 
123   temperature = 2.73 * kelvin;                 << 
124   G4Material* vacuum = new G4Material("Galacti << 
125                                       temperat << 
126                                                << 
127   // default materials                         << 
128   fAbsorMaterial = H2O;                           139   fAbsorMaterial = H2O;
129   fWorldMaterial = vacuum;                        140   fWorldMaterial = vacuum;
130 }                                                 141 }
131                                                   142 
132 //....oooOO0OOooo........oooOO0OOooo........oo    143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133                                                << 144   
134 G4VPhysicalVolume* DetectorConstruction::Const    145 G4VPhysicalVolume* DetectorConstruction::Construct()
135 {                                                 146 {
136   // World                                        147   // World
137   //                                              148   //
138   G4Box* sWorld = new G4Box("World",  // name  << 149   G4Box*
139                             fWorldSizeX / 2, f << 150   sWorld = new G4Box("World",                                      //name
140                                                << 151                    fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2);   //dimensions
141   fLWorld = new G4LogicalVolume(sWorld,  // sh << 152 
142                                 fWorldMaterial << 153   fLWorld = new G4LogicalVolume(sWorld,                        //shape
143                                 "World");  //  << 154                                 fWorldMaterial,                //material
144                                                << 155                                 "World");                      //name
145   G4VPhysicalVolume* pWorld = new G4PVPlacemen << 156 
146                                                << 157   G4VPhysicalVolume*                                   
147                                                << 158   pWorld = new G4PVPlacement(0,                           //no rotation
148                                                << 159                              G4ThreeVector(0.,0.,0.),     //at (0,0,0)
149                                                << 160                              fLWorld,                     //logical volume
150                                                << 161                              "World",                     //name
151                                                << 162                              0,                           //mother  volume
152   //                                           << 163                              false,                       //no boolean operation
                                                   >> 164                              0);                          //copy number
                                                   >> 165   //                           
153   // Absorber                                     166   // Absorber
154   //                                           << 167   //                           
155   G4Box* sAbsor = new G4Box("Absorber",  // na << 168   G4Box*
156                             fAbsorSizeX / 2, f << 169   sAbsor = new G4Box("Absorber",                                 //name
157                                                << 170                    fAbsorSizeX/2,fAbsorSizeYZ/2,fAbsorSizeYZ/2); //dimensions
158   fLAbsor = new G4LogicalVolume(sAbsor,  // sh << 171                                                                  
159                                 fAbsorMaterial << 172   fLAbsor = new G4LogicalVolume(sAbsor,                   //shape
160                                 "Absorber");   << 173                                 fAbsorMaterial,           //material
161                                                << 174                                 "Absorber");              //name
162   new G4PVPlacement(0,  // no rotation         << 175   
163                     G4ThreeVector(0., 0., 0.), << 176                               
164                     fLAbsor,  // logical volum << 177   new G4PVPlacement(0,                           //no rotation
165                     "Absorber",  // name       << 178                     G4ThreeVector(0.,0.,0.),     //at (0,0,0)
166                     fLWorld,  // mother  volum << 179                     fLAbsor,                     //logical volume
167                     false,  // no boolean oper << 180                     "Absorber",                  //name
168                     0);  // copy number        << 181                     fLWorld,                     //mother  volume
                                                   >> 182                     false,                       //no boolean operation
                                                   >> 183                     0);                          //copy number
169   //                                              184   //
170   // Tallies (optional)                           185   // Tallies (optional)
171   //                                              186   //
172   if (fTallyNumber > 0) {                         187   if (fTallyNumber > 0) {
173     for (G4int j = 0; j < fTallyNumber; ++j) { << 188     for (G4int j=0; j<fTallyNumber; ++j) {
174       G4Box* sTally =                          << 189             
175         new G4Box("Tally", fTallySize[j].x() / << 190        G4Box* sTally = new G4Box("Tally",
176                                                << 191                    fTallySize[j].x()/2,fTallySize[j].y()/2,fTallySize[j].z()/2);
177       fLTally[j] = new G4LogicalVolume(sTally, << 192                       
178                                                << 193        fLTally[j] = new G4LogicalVolume(sTally,fAbsorMaterial,"Tally");
179       new G4PVPlacement(0,  // no rotation     << 194            
180                         fTallyPosition[j],  // << 195        new G4PVPlacement(0,                        //no rotation
181                         fLTally[j],  // logica << 196                          fTallyPosition[j],        //position
182                         "Tally",  // name      << 197                          fLTally[j],               //logical volume
183                         fLAbsor,  // mother  v << 198                          "Tally",                  //name
184                         false,  // no boolean  << 199                          fLAbsor,                  //mother  volume
185                         j + 1);  // copy numbe << 200                          false,                    //no boolean operation
186                                                << 201                          j+1);                     //copy number
187       fTallyMass[j] =                          << 202        
188         fTallySize[j].x() * fTallySize[j].y()  << 203       fTallyMass[j] = fTallySize[j].x()*fTallySize[j].y()*fTallySize[j].z()
189     }                                          << 204                *(fAbsorMaterial->GetDensity());
190   }                                            << 205     }               
                                                   >> 206   } 
191                                                   207 
192   PrintParameters();                              208   PrintParameters();
193                                                << 209     
194   //                                           << 
195   // always return the World volume            << 
196   //                                              210   //
                                                   >> 211   //always return the World volume
                                                   >> 212   //  
197   return pWorld;                                  213   return pWorld;
198 }                                                 214 }
199                                                   215 
200 //....oooOO0OOooo........oooOO0OOooo........oo    216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
201                                                   217 
202 void DetectorConstruction::PrintParameters() c    218 void DetectorConstruction::PrintParameters() const
203 {                                                 219 {
204   G4cout << *(G4Material::GetMaterialTable())     220   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
205   G4cout << "\n-------------------------------    221   G4cout << "\n---------------------------------------------------------\n";
206   G4cout << "---> The Absorber is " << G4BestU << 222   G4cout << "---> The Absorber is " << G4BestUnit(fAbsorSizeX,"Length")
207          << fAbsorMaterial->GetName() << G4end << 223          << " of " << fAbsorMaterial->GetName() << G4endl;
208   G4cout << "\n-------------------------------    224   G4cout << "\n---------------------------------------------------------\n";
209                                                << 225   
210   if (fTallyNumber > 0) {                         226   if (fTallyNumber > 0) {
211     G4cout << "---> There are " << fTallyNumbe << 227     G4cout << "---> There are " << fTallyNumber << " tallies : " << G4endl;    
212     for (G4int j = 0; j < fTallyNumber; ++j) { << 228     for (G4int j=0; j<fTallyNumber; ++j) {
213       G4cout << "fTally " << j << ": " << fAbs << 229       G4cout << "fTally " << j << ": "
214              << ",  mass = " << G4BestUnit(fTa << 230              << fAbsorMaterial->GetName()
215              << " size = " << G4BestUnit(fTall << 231              << ",  mass = " << G4BestUnit(fTallyMass[j],"Mass")
216              << " position = " << G4BestUnit(f << 232              << " size = "   << G4BestUnit(fTallySize[j],"Length")           
217     }                                          << 233              << " position = " << G4BestUnit(fTallyPosition[j],"Length")
                                                   >> 234              << G4endl;
                                                   >> 235     }                 
218     G4cout << "\n-----------------------------    236     G4cout << "\n---------------------------------------------------------\n";
219   }                                            << 237   }  
220 }                                                 238 }
221                                                   239 
222 //....oooOO0OOooo........oooOO0OOooo........oo    240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
223                                                   241 
224 void DetectorConstruction::SetSizeX(G4double v    242 void DetectorConstruction::SetSizeX(G4double value)
225 {                                                 243 {
226   fAbsorSizeX = value;                         << 244   fAbsorSizeX = value; 
227   fWorldSizeX = 1.2 * fAbsorSizeX;             << 245   fWorldSizeX = 1.2*fAbsorSizeX;
228 }                                                 246 }
229                                                << 247   
230 //....oooOO0OOooo........oooOO0OOooo........oo    248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
231                                                   249 
232 void DetectorConstruction::SetSizeYZ(G4double     250 void DetectorConstruction::SetSizeYZ(G4double value)
233 {                                                 251 {
234   fAbsorSizeYZ = value;                        << 252   fAbsorSizeYZ = value; 
235   fWorldSizeYZ = 1.2 * fAbsorSizeYZ;           << 253   fWorldSizeYZ = 1.2*fAbsorSizeYZ;
236 }                                              << 254 }  
237                                                   255 
238 //....oooOO0OOooo........oooOO0OOooo........oo    256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239                                                   257 
240 void DetectorConstruction::SetMaterial(const G    258 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
241 {                                                 259 {
242   // search the material by its name           << 260   // search the material by its name   
243   G4Material* pttoMaterial = G4NistManager::In << 261   G4Material* pttoMaterial =
                                                   >> 262     G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
244   if (pttoMaterial && pttoMaterial != fAbsorMa    263   if (pttoMaterial && pttoMaterial != fAbsorMaterial) {
245     // change target material everywhere          264     // change target material everywhere
246     fAbsorMaterial = pttoMaterial;                265     fAbsorMaterial = pttoMaterial;
247     for (G4int j = 0; j < fTallyNumber; ++j) { << 266     for (G4int j=0; j<fTallyNumber; ++j) {
248       if (fLTally[j]) {                        << 267       if(fLTally[j]) { 
249         fLTally[j]->SetMaterial(pttoMaterial); << 268         fLTally[j]->SetMaterial(pttoMaterial); 
250         fTallyMass[j] =                        << 269         fTallyMass[j] = fTallySize[j].x()*fTallySize[j].y()*fTallySize[j].z()
251           fTallySize[j].x() * fTallySize[j].y( << 270           *(pttoMaterial->GetDensity());
252       }                                           271       }
253     }                                          << 272     } 
254     if (fLAbsor) {                             << 273     if(fLAbsor) {
255       fLAbsor->SetMaterial(fAbsorMaterial);       274       fLAbsor->SetMaterial(fAbsorMaterial);
256       G4RunManager::GetRunManager()->PhysicsHa    275       G4RunManager::GetRunManager()->PhysicsHasBeenModified();
257     }                                             276     }
258   }                                               277   }
259 }                                                 278 }
260                                                   279 
261 //....oooOO0OOooo........oooOO0OOooo........oo    280 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
262                                                   281 
263 void DetectorConstruction::SetWorldMaterial(co    282 void DetectorConstruction::SetWorldMaterial(const G4String& materialChoice)
264 {                                                 283 {
265   // search the material by its name           << 284   // search the material by its name   
266   G4Material* pttoMaterial = G4NistManager::In << 285   G4Material* pttoMaterial =
                                                   >> 286     G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
267   if (pttoMaterial && pttoMaterial != fWorldMa    287   if (pttoMaterial && pttoMaterial != fWorldMaterial) {
268     fWorldMaterial = pttoMaterial;                288     fWorldMaterial = pttoMaterial;
269     if (fLWorld) {                             << 289     if(fLWorld) {
270       fLWorld->SetMaterial(fAbsorMaterial);       290       fLWorld->SetMaterial(fAbsorMaterial);
271       G4RunManager::GetRunManager()->PhysicsHa    291       G4RunManager::GetRunManager()->PhysicsHasBeenModified();
272     }                                             292     }
273   }                                               293   }
274 }                                                 294 }
275                                                   295 
276 //....oooOO0OOooo........oooOO0OOooo........oo    296 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
277                                                   297 
278 void DetectorConstruction::SetMagField(G4doubl    298 void DetectorConstruction::SetMagField(G4double fieldValue)
279 {                                                 299 {
280   // apply a global uniform magnetic field alo << 300   //apply a global uniform magnetic field along Z axis
281   G4FieldManager* fieldMgr = G4TransportationM << 301   G4FieldManager* fieldMgr 
282                                                << 302    = G4TransportationManager::GetTransportationManager()->GetFieldManager();
283   if (fMagField) delete fMagField;  // delete  << 303     
284                                                << 304   if (fMagField) delete fMagField;        //delete the existing magn field  
285   if (fieldValue != 0.)  // create a new one i << 305 
286   {                                            << 306   if (fieldValue!=0.)                        // create a new one if non nul
287     fMagField = new G4UniformMagField(G4ThreeV << 307     {
288     fieldMgr->SetDetectorField(fMagField);     << 308       fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
289     fieldMgr->CreateChordFinder(fMagField);    << 309       fieldMgr->SetDetectorField(fMagField);
290   }                                            << 310       fieldMgr->CreateChordFinder(fMagField);
291   else {                                       << 311     }
292     fMagField = nullptr;                       << 312    else
293     fieldMgr->SetDetectorField(fMagField);     << 313     {
294   }                                            << 314       fMagField = nullptr;
                                                   >> 315       fieldMgr->SetDetectorField(fMagField);
                                                   >> 316     }
295 }                                                 317 }
296 //....oooOO0OOooo........oooOO0OOooo........oo    318 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
297                                                   319 
298 void DetectorConstruction::SetTallyNumber(G4in    320 void DetectorConstruction::SetTallyNumber(G4int value)
299 {                                                 321 {
300   if (value >= 0 && value < kMaxTally) {       << 322   if(value >= 0 && value <kMaxTally) {
301     fTallyNumber = value;                         323     fTallyNumber = value;
302   }                                            << 324   } else {
303   else {                                       << 
304     G4cout << "### DetectorConstruction::SetTa    325     G4cout << "### DetectorConstruction::SetTallyNumber WARNING: wrong tally "
305            << "number " << value << " is ignor    326            << "number " << value << " is ignored" << G4endl;
306   }                                               327   }
307 }                                                 328 }
308                                                   329 
309 //....oooOO0OOooo........oooOO0OOooo........oo    330 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
310                                                   331 
311 void DetectorConstruction::SetTallySize(G4int     332 void DetectorConstruction::SetTallySize(G4int j, const G4ThreeVector& value)
312 {                                                 333 {
313   if (j >= 0 && j < kMaxTally) {               << 334   if(j >= 0 && j < kMaxTally) {
314     fTallySize[j] = value;                        335     fTallySize[j] = value;
315   }                                            << 336   } else {
316   else {                                       << 
317     G4cout << "### DetectorConstruction::SetTa    337     G4cout << "### DetectorConstruction::SetTallyNumber WARNING: wrong tally "
318            << "number " << j << " is ignored"     338            << "number " << j << " is ignored" << G4endl;
319   }                                            << 339   } 
320 }                                              << 340 }  
321                                                   341 
322 //....oooOO0OOooo........oooOO0OOooo........oo    342 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
323                                                   343 
324 void DetectorConstruction::SetTallyPosition(G4    344 void DetectorConstruction::SetTallyPosition(G4int j, const G4ThreeVector& value)
325 {                                                 345 {
326   if (j >= 0 && j < kMaxTally) {               << 346   if(j >= 0 && j < kMaxTally) {
327     fTallyPosition[j] = value;                 << 347     fTallyPosition[j] = value; 
328   }                                            << 348   } else {
329   else {                                       << 
330     G4cout << "### DetectorConstruction::SetTa    349     G4cout << "### DetectorConstruction::SetTallyPosition WARNING: wrong tally "
331            << "number " << j << " is ignored"     350            << "number " << j << " is ignored" << G4endl;
332   }                                            << 351   } 
333 }                                              << 352 }  
334                                                   353 
335 G4double DetectorConstruction::GetTallyMass(G4    354 G4double DetectorConstruction::GetTallyMass(G4int j) const
336 {                                                 355 {
337   if (j >= 0 && j < kMaxTally) {               << 356   if(j >= 0 && j < kMaxTally) {
338     return fTallyMass[j];                         357     return fTallyMass[j];
339   }                                            << 358   } else {
340   else {                                       << 
341     G4cout << "### DetectorConstruction::GetTa    359     G4cout << "### DetectorConstruction::GetTallyMass WARNING: wrong tally "
342            << "number " << j << " is ignored"     360            << "number " << j << " is ignored" << G4endl;
343     return 0.0;                                   361     return 0.0;
344   }                                            << 362   } 
345 }                                                 363 }
346                                                   364 
347 const G4LogicalVolume* DetectorConstruction::G << 365 const G4LogicalVolume* DetectorConstruction::GetLogicalTally(G4int j) const 
348 {                                                 366 {
349   if (j >= 0 && j < kMaxTally) {               << 367   if(j >= 0 && j < kMaxTally) {
350     return fLTally[j];                            368     return fLTally[j];
351   }                                            << 369   } else {
352   else {                                       << 
353     G4cout << "### DetectorConstruction::GetLO    370     G4cout << "### DetectorConstruction::GetLOgicalTally WARNING: wrong tally "
354            << "number " << j << " is ignored"     371            << "number " << j << " is ignored" << G4endl;
355     return nullptr;                               372     return nullptr;
356   }                                            << 373   } 
357 }                                                 374 }
358                                                   375 
359 //....oooOO0OOooo........oooOO0OOooo........oo    376 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
360                                                   377