]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TGeant4/TG4GeometryManager.cxx
changed printout
[u/mrichter/AliRoot.git] / TGeant4 / TG4GeometryManager.cxx
index bc7993527b3e758f78b99a237165484e0ea6c879..4d44393ffa2f08c5d8954b1da4596f866bd24cd7 100644 (file)
 #include "TG4GeometryManager.h"
 #include "TG4GeometryOutputManager.h"
 #include "TG4GeometryServices.h"
-#include "TG4PhysicsManager.h"
-#include "TG4VSensitiveDetector.h"
-#include "TG4Limits.h"
+#include "TG4G3Units.h"
 #include "TG4Globals.h"
-#include "TG3Units.h"
 
 #include <G3toG4.hh> 
 #include <G3toG4BuildTree.hh>
@@ -26,7 +23,6 @@
 #include <G3MedTable.hh>
 #include <G3SensVolVector.hh>
 
-#include <G4VSensitiveDetector.hh>
 #include <G4LogicalVolumeStore.hh>
 #include <G4PVPlacement.hh>
 #include <G4Material.hh>
@@ -38,6 +34,7 @@ void G3CLRead(G4String &, char *);
 
 TG4GeometryManager* TG4GeometryManager::fgInstance = 0;
 
+//_____________________________________________________________________________
 TG4GeometryManager::TG4GeometryManager() 
   : fMediumCounter(0),
     fMaterialCounter(0),
@@ -61,6 +58,7 @@ TG4GeometryManager::TG4GeometryManager()
   //TG4ElementTable::Instance();
 }
 
+//_____________________________________________________________________________
 TG4GeometryManager::TG4GeometryManager(const TG4GeometryManager& right) {
 // 
   TG4Globals::Exception(
@@ -68,18 +66,21 @@ TG4GeometryManager::TG4GeometryManager(const TG4GeometryManager& right) {
 }
 
 
+//_____________________________________________________________________________
 TG4GeometryManager::~TG4GeometryManager() {
 //
   delete fOutputManager;
   delete fGeometryServices;
 }
 
-//==================================================================== =========
+//=============================================================================
 //
 // operators
 //
-//==================================================================== =========
+//=============================================================================
+
 
+//_____________________________________________________________________________
 TG4GeometryManager& 
 TG4GeometryManager::operator=(const TG4GeometryManager& right)
 {
@@ -98,84 +99,12 @@ TG4GeometryManager::operator=(const TG4GeometryManager& right)
 // private methods
 //
 //=============================================================================
-
-
-void TG4GeometryManager::GstparCut(G4int itmed, TG3Cut par, G4double parval)
-{
-// Sets special tracking medium parameter. 
-// It is applied to all logical volumes that use the specified 
-// tracking medium.
-// ---
-
-  // get medium from table
-  G3MedTableEntry* medium = G3Med.get(itmed);
-  if (!medium) {
-    G4String text = "TG4GeometryManager::GstparCut: \n";
-    text = text + "    Medium not found."; 
-    G4Exception(text);
-  }  
-
-  // get/create user limits
-  G4UserLimits* limits = medium->GetLimits();
-  TG4Limits* tg4Limits;
-  if (limits) {
-    tg4Limits = dynamic_cast<TG4Limits*> (limits);
-    if (!tg4Limits)
-      G4Exception("TG4GeometryManager::GstparCut: Wrong limits type.");
-  }    
-  else {
-    tg4Limits = new TG4Limits();
-    medium->SetLimits(tg4Limits);
-
-    // add verbose 
-    G4cout << "TG4GeometryManager::GstparCut: new TG4Limits() for medium " 
-           << itmed << " has been created." << G4endl;  
-  }       
-  // set parameter
-  tg4Limits->SetG3Cut(par, parval*GeV);
-}
-
-
-void TG4GeometryManager::GstparFlag(G4int itmed, TG3Flag par, G4double parval)
-{
-// Sets special tracking medium parameter. 
-// It is applied to all logical volumes that use the specified 
-// tracking medium.
-// ---
-
-  // get medium from table
-  G3MedTableEntry* medium = G3Med.get(itmed);
-  if (!medium) {
-    G4String text = "TG4GeometryManager::GstparFlag: \n";
-    text = text + "    Medium not found."; 
-    G4Exception(text);
-  }  
-
-  // get/create user limits
-  G4UserLimits* limits = medium->GetLimits();
-  TG4Limits* tg4Limits;
-  if (limits) {
-    tg4Limits = dynamic_cast<TG4Limits*> (limits);
-    if (!tg4Limits)
-      G4Exception("TG4GeometryManager::GstparFlag: Wrong limits type.");
-  }    
-  else {     
-    tg4Limits = new TG4Limits();
-    medium->SetLimits(tg4Limits);
-
-    // add verbose 
-    G4cout << "TG4GeometryManager::GstparFlag: new TG4Limits() for medium " 
-           << itmed << " has been created." << G4endl;  
-  }
-  // set parameter
-  tg4Limits->SetG3Flag(par, parval);
-}
-
  
+//_____________________________________________________________________________
 void TG4GeometryManager::FillMediumIdVector()
 {
 // The second index for materials (having its origin in
-// G4 tracking media concept) is stored in a vector of G4int
+// G3 tracking media concept) is stored in a vector of G4int
 // parallel to G4MaterialTable.
 // ---
 
@@ -203,6 +132,25 @@ void TG4GeometryManager::FillMediumIdVector()
   G4cout << "Total nof tracking medias: " << fMediumCounter << G4endl;  
 }    
 
+//_____________________________________________________________________________
+void TG4GeometryManager::SetUserLimits()
+{
+// Sets user limits defined in G3MedTable for all logical volumes.
+// ---
+
+  G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
+
+  for (G4int i=0; i<lvStore->size(); i++) {
+    G4LogicalVolume* lv = (*lvStore)[i];
+
+    // get limits from G3Med
+    G4int materialIndex = lv->GetMaterial()->GetIndex();
+    G4int mediumIndex = fMediumIdVector[materialIndex];   
+    G4UserLimits* limits = G3Med.get(mediumIndex)->GetLimits();
+
+    lv->SetUserLimits(limits);
+  } 
+}
 
 //=============================================================================
 //
@@ -211,6 +159,7 @@ void TG4GeometryManager::FillMediumIdVector()
 //=============================================================================
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::Material(Int_t& kmat, const char* name, Float_t a, 
           Float_t z, Float_t dens, Float_t radl, Float_t absl, Float_t* buf, 
           Int_t nwbuf)
@@ -243,6 +192,7 @@ void TG4GeometryManager::Material(Int_t& kmat, const char* name, Float_t a,
 }
   
  
+//_____________________________________________________________________________
 void TG4GeometryManager::Mixture(Int_t& kmat, const char *name, Float_t *a, 
           Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat)
 { 
@@ -279,6 +229,7 @@ void TG4GeometryManager::Mixture(Int_t& kmat, const char *name, Float_t *a,
    delete [] wmatin;
 } 
 
+//_____________________________________________________________________________
 void TG4GeometryManager::Medium(Int_t& kmed, const char *name, Int_t nmat, 
           Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, 
           Float_t stemax, Float_t deemax, Float_t epsil, 
@@ -287,7 +238,7 @@ void TG4GeometryManager::Medium(Int_t& kmed, const char *name, Int_t nmat,
 // Creates a temporary "medium" that is used for 
 // assigning corresponding parameters to G4 objects:
 // NTMED is stored as a second material index;
-// ISVOL is used for builing TG3SensVolVector;
+// ISVOL is used for builing G3SensVolVector;
 // STEMAX is passed in TG4Limits (if fUseG3TMLimits is set true);
 // !! The other parameters (IFIELD, FIELDM, TMAXFD, DEEMAX, EPSIL, STMIN)
 // are ignored by Geant4.
@@ -334,8 +285,9 @@ void TG4GeometryManager::Medium(Int_t& kmed, const char *name, Int_t nmat,
 } 
 
 
-void TG4GeometryManager::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX, 
-           Float_t thetaY, Float_t phiY, Float_t thetaZ, Float_t phiZ)
+//_____________________________________________________________________________
+void TG4GeometryManager::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, 
+           Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ)
 {
 // Creates G4RotationMatrix.
 // ---
@@ -350,8 +302,29 @@ void TG4GeometryManager::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX,
 }
   
 
+//_____________________________________________________________________________
+void TG4GeometryManager::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX, 
+           Float_t thetaY, Float_t phiY, Float_t thetaZ, Float_t phiZ)
+{
+// Single precision interface.
+// ---
+
+  //TG4Globals::Warning("TG4GeometryManager::Matrix in single precision.");
+  
+  Double_t dthetaX = thetaX;
+  Double_t dphiX   = phiX; 
+  Double_t dthetaY = thetaY; 
+  Double_t dphiY   = phiY;
+  Double_t dthetaZ = thetaZ;
+  Double_t dphiZ   = phiZ;
+
+  Matrix(krot, dthetaX, dphiX, dthetaY, dphiY, dthetaZ, dphiZ);
+}
+  
+
+//_____________________________________________________________________________
 void TG4GeometryManager::Ggclos() 
-{ 
+{
 // Sets the top VTE in temporary G3 volume table.
 // Close geometry output file (if fWriteGeometry is set true).
 //
@@ -366,6 +339,7 @@ void TG4GeometryManager::Ggclos()
 } 
  
 
+//_____________________________________________________________________________
 void TG4GeometryManager::Gfmate(Int_t imat, char *name, Float_t &a, 
           Float_t &z, Float_t &dens, Float_t &radl, Float_t &absl,
           Float_t* ubuf, Int_t& nbuf) 
@@ -386,10 +360,10 @@ void TG4GeometryManager::Gfmate(Int_t imat, char *name, Float_t &a,
     z = fGeometryServices->GetEffZ(material);
     
     dens = material->GetDensity();
-    dens /= TG3Units::MassDensity();
+    dens /= TG4G3Units::MassDensity();
 
     radl = material->GetRadlen();
-    radl /= TG3Units::Length();
+    radl /= TG4G3Units::Length();
 
     // the following parameters are not defined in Geant4
     absl = 0.; 
@@ -403,65 +377,20 @@ void TG4GeometryManager::Gfmate(Int_t imat, char *name, Float_t &a,
 } 
 
  
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gstpar(Int_t itmed, const char *param, 
            Float_t parval) 
 { 
-// Passes the tracking medium parameter to TG4Limits.
-// The tracking medium parameter is set only in case
-// its value is different from the "global" physics setup.
-// (If: CheckCut/FlagWithG3Defaults is used checking
-//  is performed with respect to G3 default values.)
-// When any cut/flag parameter is set in limits
-// the physics manager is locked and the physics setup
-// cannot be changed.
-// Applying this TG4Limits to particles and physical
-// processes is still in development.
-//
-//  Geant3 desription:
-//  ==================
-//  To change the value of cut  or mechanism "CHPAR"
-//  to a new value PARVAL  for tracking medium ITMED
-//  The  data   structure  JTMED   contains  the   standard  tracking
-//  parameters (CUTS and flags to control the physics processes)  which
-//  are used  by default  for all  tracking media.   It is  possible to
-//  redefine individually  with GSTPAR  any of  these parameters  for a
-//  given tracking medium. 
-//  ITMED     tracking medium number 
-//  CHPAR     is a character string (variable name) 
-//  PARVAL    must be given as a floating point.
+// Write token to the output file only,
+// the method is performed by TG4PhysicsManager.
 // ---
 
-  // write token to the output file
   if (fWriteGeometry) 
     fOutputManager->WriteGstpar(itmed, param, parval); 
-
-  // get physics setup
-  TG4PhysicsManager* physicsManager = TG4PhysicsManager::Instance();
-  //TG4CutVector* cutVector = physicsManager->GetCutVector();
-  //TG4FlagVector* flagVector = physicsManager->GetFlagVector();
-
-  G4String name = fGeometryServices->CutName(param); 
-  TG3Cut g3Cut;
-  if (physicsManager->CheckCutWithCutVector(name, parval, g3Cut)) {
-      GstparCut(itmed, g3Cut, parval);
-      physicsManager->Lock();
-  }  
-  else {
-    TG3Flag g3Flag;
-    if (physicsManager->CheckFlagWithFlagVector(name, parval, g3Flag)) {
-      GstparFlag(itmed, g3Flag, parval);
-      physicsManager->Lock();
-    } 
-    else if (g3Cut==kNoG3Cuts && g3Flag==kNoG3Flags) { 
-      G4String text = "TG4GeometryManager::Gstpar:";
-      text = text + name;
-      text = text + " parameter is not yet implemented.";
-      TG4Globals::Warning(text);
-    }  
-  } 
 } 
  
  
+//_____________________________________________________________________________
 void  TG4GeometryManager::SetCerenkov(Int_t itmed, Int_t npckov, 
                              Float_t* ppckov, Float_t* absco, Float_t* effic, 
                             Float_t* rindex)
@@ -493,8 +422,8 @@ void  TG4GeometryManager::SetCerenkov(Int_t itmed, Int_t npckov,
   // add units
   G4int i;
   for (i=0; i<npckov; i++) {
-    ppckovDbl[i] = ppckovDbl[i]*TG3Units::Energy();
-    abscoDbl[i]  = abscoDbl[i]*TG3Units::Length();
+    ppckovDbl[i] = ppckovDbl[i]*TG4G3Units::Energy();
+    abscoDbl[i]  = abscoDbl[i]*TG4G3Units::Length();
   }  
 
   // create material properties table
@@ -530,6 +459,7 @@ void  TG4GeometryManager::SetCerenkov(Int_t itmed, Int_t npckov,
 }                       
 
  
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gsdvn(const char *name, const char *mother, 
            Int_t ndiv, Int_t iaxis) 
 { 
@@ -556,8 +486,9 @@ void  TG4GeometryManager::Gsdvn(const char *name, const char *mother,
 } 
  
  
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gsdvn2(const char *name, const char *mother, 
-           Int_t ndiv, Int_t iaxis, Float_t c0i, Int_t numed) 
+           Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed) 
 { 
 //  Geant3 desription:
 //  ==================
@@ -578,8 +509,24 @@ void  TG4GeometryManager::Gsdvn2(const char *name, const char *mother,
 } 
  
  
+//_____________________________________________________________________________
+void  TG4GeometryManager::Gsdvn2(const char *name, const char *mother, 
+           Int_t ndiv, Int_t iaxis, Float_t c0i, Int_t numed) 
+{ 
+// Single precision interface.
+// ---
+
+    //TG4Globals::Warning("TG4GeometryManager::Gsdvn2 in single precision.");
+
+    G4double dc0i = c0i;
+    
+    Gsdvn2(name, mother, ndiv, iaxis, dc0i, numed);
+} 
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gsdvt(const char *name, const char *mother, 
-           Float_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
+           Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
 { 
 //  Geant3 desription:
 //  ==================
@@ -604,8 +551,24 @@ void  TG4GeometryManager::Gsdvt(const char *name, const char *mother,
 } 
  
  
+//_____________________________________________________________________________
+void  TG4GeometryManager::Gsdvt(const char *name, const char *mother, 
+           Float_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
+{ 
+// Single precision interface.
+// ---
+
+    //TG4Globals::Warning("TG4GeometryManager::Gsdvt in single precision.");
+
+    G4double dstep = step;
+
+    Gsdvt(name, mother, dstep, iaxis, numed, ndvmx);
+} 
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gsdvt2(const char *name, const char *mother, 
-           Float_t step, Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
+           Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx)
 { 
 //  Geant3 desription:
 //  ==================
@@ -632,6 +595,23 @@ void  TG4GeometryManager::Gsdvt2(const char *name, const char *mother,
 } 
  
  
+//_____________________________________________________________________________
+void  TG4GeometryManager::Gsdvt2(const char *name, const char *mother, 
+           Float_t step, Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
+{ 
+// Single precision interface.
+// ---
+
+    //TG4Globals::Warning("TG4GeometryManager::Gsdvt2 in single precision.");
+    
+    G4double dstep = step;
+    G4double dc0   = c0;
+
+    Gsdvt2(name, mother, dstep, iaxis, dc0, numed, ndvmx);
+} 
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gsord(const char *name, Int_t iax) 
 { 
 // No corresponding action in G4.
@@ -655,8 +635,9 @@ void  TG4GeometryManager::Gsord(const char *name, Int_t iax)
 } 
  
  
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gspos(const char *vname, Int_t num, 
-          const char *vmoth, Float_t x, Float_t y, Float_t z, Int_t irot, 
+          const char *vmoth, Double_t x, Double_t y, Double_t z, Int_t irot, 
           const char *vonly) 
 { 
 //  Geant3 desription:
@@ -687,9 +668,28 @@ void  TG4GeometryManager::Gspos(const char *vname, Int_t num,
 } 
  
  
+//_____________________________________________________________________________
+void  TG4GeometryManager::Gspos(const char *vname, Int_t num, 
+          const char *vmoth, Float_t x, Float_t y, Float_t z, Int_t irot, 
+          const char *vonly) 
+{ 
+// Single precision interface.
+// ---
+
+   //TG4Globals::Warning("TG4GeometryManager::Gspos in single precision.");
+
+   G4double dx = x; 
+   G4double dy = y;
+   G4double dz = z;
+   
+   Gspos(vname, num, vmoth, dx, dy, dz, irot, vonly);
+} 
+//_____________________________________________________________________________
 void  TG4GeometryManager::Gsposp(const char *name, Int_t nr, 
-           const char *mother, Float_t x, Float_t y, Float_t z, Int_t irot, 
-           const char *konly, Float_t *upar, Int_t np ) 
+           const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, 
+           const char *konly, Double_t *upar, Int_t np ) 
 { 
 //  Geant3 desription:
 //  ==================
@@ -697,25 +697,43 @@ void  TG4GeometryManager::Gsposp(const char *name, Int_t nr,
 //      NR inside MOTHER, with its parameters UPAR(1..NP)
 // ---
 
-   G4double* parin = fGeometryServices->CreateG4doubleArray(upar, np); 
-
    // write token to the output file
    if (fWriteGeometry) 
-     fOutputManager->WriteGsposp(name, nr, mother, x, y, z, irot, konly, parin, np);
+     fOutputManager->WriteGsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
 
    G4gsposp(fGeometryServices->CutName(name), nr, 
             fGeometryServices->CutName(mother), x, y, z, irot, konly, 
-             parin, np);
-
-   delete [] parin;
+             upar, np);
 
    // register name in name map
    fNameMap.AddName(fGeometryServices->CutName(name));
 } 
  
  
+//_____________________________________________________________________________
+void  TG4GeometryManager::Gsposp(const char *name, Int_t nr, 
+           const char *mother, Float_t x, Float_t y, Float_t z, Int_t irot, 
+           const char *konly, Float_t *upar, Int_t np ) 
+{ 
+// Single precision interface.
+// ---
+
+   //TG4Globals::Warning("TG4GeometryManager::Gsposp in single precision.");
+
+   G4double dx = x; 
+   G4double dy = y;
+   G4double dz = z;
+   G4double* parin = fGeometryServices->CreateG4doubleArray(upar, np); 
+
+   Gsposp(name, nr, mother, dx, dy, dz, irot, konly, parin, np);
+
+   delete [] parin;
+} 
+//_____________________________________________________________________________
 Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape, 
-          Int_t nmed, Float_t *upar, Int_t npar) 
+          Int_t nmed, Double_t *upar, Int_t npar) 
 { 
 //  Geant3 desription:
 //  ==================
@@ -728,16 +746,12 @@ Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape,
 //  It creates a new volume in the JVOLUM data structure.
 // ---  
 
-  G4double* parin = fGeometryServices->CreateG4doubleArray(upar, npar); 
-
   // write token to the output file
   if (fWriteGeometry) 
-    fOutputManager->WriteGsvolu(name, shape, nmed, parin, npar);    
+    fOutputManager->WriteGsvolu(name, shape, nmed, upar, npar);    
 
   G4gsvolu(fGeometryServices->CutName(name), 
-           fGeometryServices->CutName(shape), nmed, parin, npar);
-
-  delete [] parin;
+           fGeometryServices->CutName(shape), nmed, upar, npar);
   
   // register name in name map
   fNameMap.AddName(fGeometryServices->CutName(name));
@@ -746,6 +760,27 @@ Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape,
 } 
 
 
+//_____________________________________________________________________________
+Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape, 
+          Int_t nmed, Float_t *upar, Int_t npar) 
+{ 
+// Single precision interface.
+// ---
+
+  //TG4Globals::Warning("TG4GeometryManager::Gsvolu in single precision.");
+
+  G4double* parin = fGeometryServices->CreateG4doubleArray(upar, npar); 
+
+  G4int result
+   = Gsvolu(name, shape, nmed, parin, npar);
+
+  delete [] parin;
+
+  return result;
+} 
+
+
+//_____________________________________________________________________________
 void TG4GeometryManager::WriteEuclid(const char* fileName, 
           const char* topVolName, Int_t number, Int_t nlevel)
 {
@@ -781,42 +816,6 @@ void TG4GeometryManager::WriteEuclid(const char* fileName,
 }
 
  
-Int_t TG4GeometryManager::VolId(const Text_t* volName) const
-{ 
-// Returns the sensitive detector identifier.
-// ---
-
-  return fGeometryServices->GetVolumeID(volName);
-}
-
-
-const char* TG4GeometryManager::VolName(Int_t id) const
-{
-// Returns the name of the sensitive detector with the given identifier.
-// ---
-
-  return fGeometryServices->GetVolumeName(id);
-}
-
-
-Int_t TG4GeometryManager::NofVolumes() const
-{
-// Returns the total number of sensitive detectors.
-// ---
-
-  return fGeometryServices->NofSensitiveDetectors();
-}
-
-Int_t TG4GeometryManager::VolId2Mate(Int_t volumeId)  const
-{
-// Return the material number for a given volume id
-// ---
-
-  return fGeometryServices->GetMediumId(volumeId);                      
-}
-
 //=============================================================================
 //
 // public methods - Geant4 only
@@ -824,6 +823,7 @@ Int_t TG4GeometryManager::VolId2Mate(Int_t volumeId)  const
 //=============================================================================
 
  
+//_____________________________________________________________________________
 G4VPhysicalVolume* TG4GeometryManager::CreateG4Geometry()
 {
 // Creates G4 geometry objects according to the G3VolTable 
@@ -861,6 +861,7 @@ G4VPhysicalVolume* TG4GeometryManager::CreateG4Geometry()
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::ReadG3Geometry(G4String filePath)
 {
 // Processes g3calls.dat file and fills G3 tables.
@@ -873,6 +874,7 @@ void TG4GeometryManager::ReadG3Geometry(G4String filePath)
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::UseG3TrackingMediaLimits()
 {
 // Sets fUseG3TMLimits option.
@@ -892,6 +894,7 @@ void TG4GeometryManager::UseG3TrackingMediaLimits()
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::ClearG3Tables()
 { 
 // Clears G3 volumes, materials, rotations(?) tables
@@ -918,12 +921,15 @@ void TG4GeometryManager::ClearG3Tables()
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::ClearG3TablesFinal()
 {
 // Clears G3 medias and volumes tables
 // (the top volume is removed from the vol table)
 // ---
 
+  SetUserLimits();
+
   G3Med.Clear();
   G3Vol.Clear();  
 
@@ -933,6 +939,7 @@ void TG4GeometryManager::ClearG3TablesFinal()
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::OpenOutFile(G4String filePath)
 { 
 // Opens output file.
@@ -942,6 +949,7 @@ void TG4GeometryManager::OpenOutFile(G4String filePath)
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::CloseOutFile()
 { 
 // Closes output file.
@@ -951,6 +959,7 @@ void TG4GeometryManager::CloseOutFile()
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::PrintNameMap()
 {
 // Prints the map of volumes names to second names.
@@ -960,6 +969,7 @@ void TG4GeometryManager::PrintNameMap()
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::SetWriteGeometry(G4bool writeGeometry)
 { 
 // Controls geometry output.
@@ -969,6 +979,7 @@ void TG4GeometryManager::SetWriteGeometry(G4bool writeGeometry)
 }
 
  
+//_____________________________________________________________________________
 void TG4GeometryManager::SetMapSecond(const G4String& name)
 {
 // Sets the second name for the map of volumes names.