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