Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/ascii/src/G4tgbGeometryDumper.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 /persistency/ascii/src/G4tgbGeometryDumper.cc (Version 11.3.0) and /persistency/ascii/src/G4tgbGeometryDumper.cc (Version 10.7.p3)


  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 // G4tgbGeometryDumper implementation              26 // G4tgbGeometryDumper implementation
 27 //                                                 27 //
 28 // Author: P.Arce, CIEMAT (November 2007)          28 // Author: P.Arce, CIEMAT (November 2007)
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4tgbGeometryDumper.hh"                  31 #include "G4tgbGeometryDumper.hh"
 32                                                    32 
 33 #include "G4tgrMessenger.hh"                       33 #include "G4tgrMessenger.hh"
 34                                                    34 
 35 #include "G4UIcommand.hh"                          35 #include "G4UIcommand.hh"
 36 #include "G4Material.hh"                           36 #include "G4Material.hh"
 37 #include "G4Element.hh"                            37 #include "G4Element.hh"
 38 #include "G4VSolid.hh"                             38 #include "G4VSolid.hh"
 39 #include "G4Box.hh"                                39 #include "G4Box.hh"
 40 #include "G4Tubs.hh"                               40 #include "G4Tubs.hh"
 41 #include "G4Cons.hh"                               41 #include "G4Cons.hh"
 42 #include "G4Trap.hh"                               42 #include "G4Trap.hh"
 43 #include "G4Sphere.hh"                             43 #include "G4Sphere.hh"
 44 #include "G4Orb.hh"                                44 #include "G4Orb.hh"
 45 #include "G4Trd.hh"                                45 #include "G4Trd.hh"
 46 #include "G4Para.hh"                               46 #include "G4Para.hh"
 47 #include "G4Torus.hh"                              47 #include "G4Torus.hh"
 48 #include "G4Hype.hh"                               48 #include "G4Hype.hh"
 49 #include "G4Polycone.hh"                           49 #include "G4Polycone.hh"
 50 #include "G4GenericPolycone.hh"                    50 #include "G4GenericPolycone.hh"
 51 #include "G4Polyhedra.hh"                          51 #include "G4Polyhedra.hh"
 52 #include "G4EllipticalTube.hh"                     52 #include "G4EllipticalTube.hh"
 53 #include "G4Ellipsoid.hh"                          53 #include "G4Ellipsoid.hh"
 54 #include "G4EllipticalCone.hh"                     54 #include "G4EllipticalCone.hh"
 55 #include "G4Hype.hh"                               55 #include "G4Hype.hh"
 56 #include "G4Tet.hh"                                56 #include "G4Tet.hh"
 57 #include "G4TwistedBox.hh"                         57 #include "G4TwistedBox.hh"
 58 #include "G4TwistedTrap.hh"                        58 #include "G4TwistedTrap.hh"
 59 #include "G4TwistedTrd.hh"                         59 #include "G4TwistedTrd.hh"
 60 #include "G4TwistedTubs.hh"                        60 #include "G4TwistedTubs.hh"
 61 #include "G4MultiUnion.hh"                     << 
 62 #include "G4ScaledSolid.hh"                    << 
 63 #include "G4PVPlacement.hh"                        61 #include "G4PVPlacement.hh"
 64 #include "G4PVParameterised.hh"                    62 #include "G4PVParameterised.hh"
 65 #include "G4PVReplica.hh"                          63 #include "G4PVReplica.hh"
 66 #include "G4BooleanSolid.hh"                       64 #include "G4BooleanSolid.hh"
 67 #include "G4ReflectionFactory.hh"                  65 #include "G4ReflectionFactory.hh"
 68 #include "G4ReflectedSolid.hh"                     66 #include "G4ReflectedSolid.hh"
 69 #include "G4LogicalVolumeStore.hh"                 67 #include "G4LogicalVolumeStore.hh"
 70 #include "G4PhysicalVolumeStore.hh"                68 #include "G4PhysicalVolumeStore.hh"
 71 #include "G4GeometryTolerance.hh"                  69 #include "G4GeometryTolerance.hh"
 72 #include "G4VPVParameterisation.hh"                70 #include "G4VPVParameterisation.hh"
 73 #include "G4SystemOfUnits.hh"                      71 #include "G4SystemOfUnits.hh"
 74 #include <iomanip>                                 72 #include <iomanip>
 75                                                    73 
 76 // -------------------------------------------     74 // --------------------------------------------------------------------
 77 G4ThreadLocal G4tgbGeometryDumper* G4tgbGeomet     75 G4ThreadLocal G4tgbGeometryDumper* G4tgbGeometryDumper::theInstance = nullptr;
 78                                                    76 
 79 // -------------------------------------------     77 // --------------------------------------------------------------------
 80 G4tgbGeometryDumper::G4tgbGeometryDumper()         78 G4tgbGeometryDumper::G4tgbGeometryDumper()
 81 {                                                  79 {
 82 }                                                  80 }
 83                                                    81 
 84 // -------------------------------------------     82 // --------------------------------------------------------------------
 85 G4tgbGeometryDumper* G4tgbGeometryDumper::GetI     83 G4tgbGeometryDumper* G4tgbGeometryDumper::GetInstance()
 86 {                                                  84 {
 87   if(theInstance == nullptr)                       85   if(theInstance == nullptr)
 88   {                                                86   {
 89     theInstance = new G4tgbGeometryDumper;         87     theInstance = new G4tgbGeometryDumper;
 90   }                                                88   }
 91   return theInstance;                              89   return theInstance;
 92 }                                                  90 }
 93                                                    91 
 94 // -------------------------------------------     92 // --------------------------------------------------------------------
 95 void G4tgbGeometryDumper::DumpGeometry(const G     93 void G4tgbGeometryDumper::DumpGeometry(const G4String& fname)
 96 {                                                  94 {
 97   theFile = new std::ofstream(fname);              95   theFile = new std::ofstream(fname);
 98                                                    96 
 99   G4VPhysicalVolume* pv = GetTopPhysVol();         97   G4VPhysicalVolume* pv = GetTopPhysVol();
100   DumpPhysVol(pv);  // dump volume and recursi     98   DumpPhysVol(pv);  // dump volume and recursively it will dump all hierarchy
101 }                                                  99 }
102                                                   100 
103 // -------------------------------------------    101 // --------------------------------------------------------------------
104 G4VPhysicalVolume* G4tgbGeometryDumper::GetTop    102 G4VPhysicalVolume* G4tgbGeometryDumper::GetTopPhysVol()
105 {                                                 103 {
106   G4PhysicalVolumeStore* pvstore = G4PhysicalV    104   G4PhysicalVolumeStore* pvstore = G4PhysicalVolumeStore::GetInstance();
107   G4VPhysicalVolume* pv = *(pvstore->cbegin())    105   G4VPhysicalVolume* pv = *(pvstore->cbegin());
108   for(;;)                                         106   for(;;)
109   {                                               107   {
110     G4LogicalVolume* lv = pv->GetMotherLogical    108     G4LogicalVolume* lv = pv->GetMotherLogical();
111     if(lv == 0)                                   109     if(lv == 0)
112     {                                             110     {
113       break;                                      111       break;
114     }                                             112     }
115                                                   113 
116     //----- look for one PV of this LV            114     //----- look for one PV of this LV
117     for(auto ite = pvstore->cbegin(); ite != p    115     for(auto ite = pvstore->cbegin(); ite != pvstore->cend(); ++ite)
118     {                                             116     {
119       pv = (*ite);                                117       pv = (*ite);
120       if(pv->GetLogicalVolume() == lv)            118       if(pv->GetLogicalVolume() == lv)
121       {                                           119       {
122         break;                                    120         break;
123       }                                           121       }
124     }                                             122     }
125   }                                               123   }
126                                                   124 
127   return pv;                                      125   return pv;
128 }                                                 126 }
129                                                   127 
130 // -------------------------------------------    128 // --------------------------------------------------------------------
131 G4tgbGeometryDumper::~G4tgbGeometryDumper()       129 G4tgbGeometryDumper::~G4tgbGeometryDumper()
132 {                                                 130 {
133 }                                                 131 }
134                                                   132 
135 // -------------------------------------------    133 // --------------------------------------------------------------------
136 void G4tgbGeometryDumper::DumpPhysVol(G4VPhysi    134 void G4tgbGeometryDumper::DumpPhysVol(G4VPhysicalVolume* pv)
137 {                                                 135 {
138   //--- Dump logical volume first                 136   //--- Dump logical volume first
139   G4LogicalVolume* lv = pv->GetLogicalVolume()    137   G4LogicalVolume* lv = pv->GetLogicalVolume();
140                                                   138 
141   G4ReflectionFactory* reffact = G4ReflectionF    139   G4ReflectionFactory* reffact = G4ReflectionFactory::Instance();
142                                                   140 
143   //--- It is not needed to dump _refl volumes    141   //--- It is not needed to dump _refl volumes created when parent is reflected
144   // !!WARNING : it must be avoided to reflect    142   // !!WARNING : it must be avoided to reflect a volume hierarchy if children
145   //             has also been reflected, as b    143   //             has also been reflected, as both will have same name
146                                                   144 
147   if(reffact->IsReflected(lv) && reffact->IsRe    145   if(reffact->IsReflected(lv) && reffact->IsReflected(pv->GetMotherLogical()))
148   {                                               146   {
149     return;                                       147     return;
150   }                                               148   }
151                                                   149 
152   G4bool bVolExists = CheckIfLogVolExists(lv->    150   G4bool bVolExists = CheckIfLogVolExists(lv->GetName(), lv);
153                                                   151 
154   //---- Construct this PV                        152   //---- Construct this PV
155   if(pv->GetMotherLogical() != nullptr)  // no    153   if(pv->GetMotherLogical() != nullptr)  // not WORLD volume
156   {                                               154   {
157     if(!pv->IsReplicated())                       155     if(!pv->IsReplicated())
158     {                                             156     {
159       G4String lvName = lv->GetName();            157       G4String lvName = lv->GetName();
160       if(!bVolExists)                             158       if(!bVolExists)
161       {                                           159       {
162         lvName = DumpLogVol(lv);                  160         lvName = DumpLogVol(lv);
163       }                                           161       }
164       DumpPVPlacement(pv, lvName);                162       DumpPVPlacement(pv, lvName);
165     }                                             163     }
166     else if(pv->IsParameterised())                164     else if(pv->IsParameterised())
167     {                                             165     {
168       G4PVParameterised* pvparam = (G4PVParame    166       G4PVParameterised* pvparam = (G4PVParameterised*) (pv);
169       DumpPVParameterised(pvparam);               167       DumpPVParameterised(pvparam);
170     }                                             168     }
171     else                                          169     else
172     {                                             170     {
173       G4String lvName = lv->GetName();            171       G4String lvName = lv->GetName();
174       if(!bVolExists)                             172       if(!bVolExists)
175       {                                           173       {
176         lvName = DumpLogVol(lv);                  174         lvName = DumpLogVol(lv);
177       }                                           175       }
178       G4PVReplica* pvrepl = (G4PVReplica*) (pv    176       G4PVReplica* pvrepl = (G4PVReplica*) (pv);
179       DumpPVReplica(pvrepl, lvName);              177       DumpPVReplica(pvrepl, lvName);
180     }                                             178     }
181   }                                               179   }
182   else                                            180   else
183   {                                               181   {
184     DumpLogVol(lv);                               182     DumpLogVol(lv);
185   }                                               183   }
186                                                   184 
187   if(!bVolExists)                                 185   if(!bVolExists)
188   {                                               186   {
189     //---- Construct PV's who has this LV as m    187     //---- Construct PV's who has this LV as mother
190     std::vector<G4VPhysicalVolume*> pvChildren    188     std::vector<G4VPhysicalVolume*> pvChildren = GetPVChildren(lv);
191     for(auto ite = pvChildren.cbegin(); ite !=    189     for(auto ite = pvChildren.cbegin(); ite != pvChildren.cend(); ++ite)
192     {                                             190     {
193       DumpPhysVol(*ite);                          191       DumpPhysVol(*ite);
194     }                                             192     }
195   }                                               193   }
196 }                                                 194 }
197                                                   195 
198 // -------------------------------------------    196 // --------------------------------------------------------------------
199 void G4tgbGeometryDumper::DumpPVPlacement(G4VP    197 void G4tgbGeometryDumper::DumpPVPlacement(G4VPhysicalVolume* pv,
200                                           cons    198                                           const G4String& lvName, G4int copyNo)
201 {                                                 199 {
202   G4String pvName = pv->GetName();                200   G4String pvName = pv->GetName();
203                                                   201 
204   G4RotationMatrix* rotMat = pv->GetRotation()    202   G4RotationMatrix* rotMat = pv->GetRotation();
205   if(rotMat == nullptr)                           203   if(rotMat == nullptr)
206     rotMat = new G4RotationMatrix();              204     rotMat = new G4RotationMatrix();
207                                                   205 
208   //---- Check if it is reflected                 206   //---- Check if it is reflected
209   G4ReflectionFactory* reffact = G4ReflectionF    207   G4ReflectionFactory* reffact = G4ReflectionFactory::Instance();
210   G4LogicalVolume* lv          = pv->GetLogica    208   G4LogicalVolume* lv          = pv->GetLogicalVolume();
211   if(reffact->IsReflected(lv))                    209   if(reffact->IsReflected(lv))
212   {                                               210   {
213 #ifdef G4VERBOSE                                  211 #ifdef G4VERBOSE
214     if(G4tgrMessenger::GetVerboseLevel() >= 1)    212     if(G4tgrMessenger::GetVerboseLevel() >= 1)
215     {                                             213     {
216       G4cout << " G4tgbGeometryDumper::DumpPVP    214       G4cout << " G4tgbGeometryDumper::DumpPVPlacement() - Reflected volume: "
217              << pv->GetName() << G4endl;          215              << pv->GetName() << G4endl;
218     }                                             216     }
219 #endif                                            217 #endif
220     G4ThreeVector colx = rotMat->colX();          218     G4ThreeVector colx = rotMat->colX();
221     G4ThreeVector coly = rotMat->colY();          219     G4ThreeVector coly = rotMat->colY();
222     G4ThreeVector colz = rotMat->colZ();          220     G4ThreeVector colz = rotMat->colZ();
223     // apply a Z reflection (reflection matrix    221     // apply a Z reflection (reflection matrix is decomposed in new
224     // reflection-free rotation + z-reflection    222     // reflection-free rotation + z-reflection)
225     colz *= -1.;                                  223     colz *= -1.;
226     G4Rep3x3 rottemp(colx.x(), coly.x(), colz.    224     G4Rep3x3 rottemp(colx.x(), coly.x(), colz.x(), colx.y(), coly.y(), colz.y(),
227                      colx.z(), coly.z(), colz.    225                      colx.z(), coly.z(), colz.z());
228     // matrix representation (inverted)           226     // matrix representation (inverted)
229     *rotMat = G4RotationMatrix(rottemp);          227     *rotMat = G4RotationMatrix(rottemp);
230     *rotMat = (*rotMat).inverse();                228     *rotMat = (*rotMat).inverse();
231     pvName += "_refl";                            229     pvName += "_refl";
232   }                                               230   }
233   const G4String& rotName  = DumpRotationMatri << 231   G4String rotName  = DumpRotationMatrix(rotMat);
234   G4ThreeVector pos = pv->GetTranslation();       232   G4ThreeVector pos = pv->GetTranslation();
235                                                   233 
236   if(copyNo == -999)  // for parameterisations    234   if(copyNo == -999)  // for parameterisations copy number is provided
237   {                                               235   {
238     copyNo = pv->GetCopyNo();                     236     copyNo = pv->GetCopyNo();
239   }                                               237   }
240                                                   238 
241   const G4String& fullname = pvName + "#" + G4 << 239   G4String fullname = pvName + "#" + G4UIcommand::ConvertToString(copyNo) +
242                            + "/" + pv->GetMoth << 240                       "/" + pv->GetMotherLogical()->GetName();
243                                                   241 
244   if(!CheckIfPhysVolExists(fullname, pv))         242   if(!CheckIfPhysVolExists(fullname, pv))
245   {                                               243   {
246     (*theFile) << ":PLACE " << SubstituteRefl(    244     (*theFile) << ":PLACE " << SubstituteRefl(AddQuotes(lvName)) << " "
247                << copyNo << " "                   245                << copyNo << " "
248                << SubstituteRefl(AddQuotes(pv-    246                << SubstituteRefl(AddQuotes(pv->GetMotherLogical()->GetName()))
249                << " " << AddQuotes(rotName) <<    247                << " " << AddQuotes(rotName) << " " << pos.x() << " " << pos.y()
250                << " " << pos.z() << G4endl;       248                << " " << pos.z() << G4endl;
251                                                   249 
252     thePhysVols[fullname] = pv;                   250     thePhysVols[fullname] = pv;
253   }                                               251   }
254 }                                                 252 }
255                                                   253 
256 // -------------------------------------------    254 // --------------------------------------------------------------------
257 void G4tgbGeometryDumper::DumpPVParameterised(    255 void G4tgbGeometryDumper::DumpPVParameterised(G4PVParameterised* pv)
258 {                                                 256 {
259   G4String pvName = pv->GetName();                257   G4String pvName = pv->GetName();
260                                                   258 
261   EAxis axis;                                     259   EAxis axis;
262   G4int nReplicas;                                260   G4int nReplicas;
263   G4double width;                                 261   G4double width;
264   G4double offset;                                262   G4double offset;
265   G4bool consuming;                               263   G4bool consuming;
266   pv->GetReplicationData(axis, nReplicas, widt    264   pv->GetReplicationData(axis, nReplicas, width, offset, consuming);
267                                                   265 
268   G4VPVParameterisation* param = pv->GetParame    266   G4VPVParameterisation* param = pv->GetParameterisation();
269                                                   267 
270   G4LogicalVolume* lv             = pv->GetLog    268   G4LogicalVolume* lv             = pv->GetLogicalVolume();
271   G4VSolid* solid1st              = param->Com    269   G4VSolid* solid1st              = param->ComputeSolid(0, pv);
272   G4Material* mate1st             = param->Com    270   G4Material* mate1st             = param->ComputeMaterial(0, pv);
273   std::vector<G4double> params1st = GetSolidPa    271   std::vector<G4double> params1st = GetSolidParams(solid1st);
274   std::vector<G4double> newParams;                272   std::vector<G4double> newParams;
275   G4VSolid* newSolid = solid1st;                  273   G4VSolid* newSolid = solid1st;
276   G4String lvName;                                274   G4String lvName;
277                                                   275 
278   for(G4int ii = 0; ii < nReplicas; ++ii)         276   for(G4int ii = 0; ii < nReplicas; ++ii)
279   {                                               277   {
280     G4Material* newMate = param->ComputeMateri    278     G4Material* newMate = param->ComputeMaterial(ii, pv);
281     if(solid1st->GetEntityType() == "G4Box")      279     if(solid1st->GetEntityType() == "G4Box")
282     {                                             280     {
283       G4Box* box = (G4Box*) (solid1st);           281       G4Box* box = (G4Box*) (solid1st);
284       param->ComputeDimensions(*box, ii, pv);     282       param->ComputeDimensions(*box, ii, pv);
285       newParams = GetSolidParams(box);            283       newParams = GetSolidParams(box);
286       newSolid  = (G4VSolid*) box;                284       newSolid  = (G4VSolid*) box;
287     }                                             285     }
288     else if(solid1st->GetEntityType() == "G4Tu    286     else if(solid1st->GetEntityType() == "G4Tubs")
289     {                                             287     {
290       G4Tubs* tubs = (G4Tubs*) (solid1st);        288       G4Tubs* tubs = (G4Tubs*) (solid1st);
291       param->ComputeDimensions(*tubs, ii, pv);    289       param->ComputeDimensions(*tubs, ii, pv);
292       newParams = GetSolidParams(tubs);           290       newParams = GetSolidParams(tubs);
293       newSolid  = (G4VSolid*) tubs;               291       newSolid  = (G4VSolid*) tubs;
294     }                                             292     }
295     else if(solid1st->GetEntityType() == "G4Tr    293     else if(solid1st->GetEntityType() == "G4Trd")
296     {                                             294     {
297       G4Trd* trd = (G4Trd*) (solid1st);           295       G4Trd* trd = (G4Trd*) (solid1st);
298       param->ComputeDimensions(*trd, ii, pv);     296       param->ComputeDimensions(*trd, ii, pv);
299       newParams = GetSolidParams(trd);            297       newParams = GetSolidParams(trd);
300       newSolid  = (G4VSolid*) trd;                298       newSolid  = (G4VSolid*) trd;
301     }                                             299     }
302     else if(solid1st->GetEntityType() == "G4Tr    300     else if(solid1st->GetEntityType() == "G4Trap")
303     {                                             301     {
304       G4Trap* trap = (G4Trap*) (solid1st);        302       G4Trap* trap = (G4Trap*) (solid1st);
305       param->ComputeDimensions(*trap, ii, pv);    303       param->ComputeDimensions(*trap, ii, pv);
306       newParams = GetSolidParams(trap);           304       newParams = GetSolidParams(trap);
307       newSolid  = (G4VSolid*) trap;               305       newSolid  = (G4VSolid*) trap;
308     }                                             306     }
309     else if(solid1st->GetEntityType() == "G4Co    307     else if(solid1st->GetEntityType() == "G4Cons")
310     {                                             308     {
311       G4Cons* cons = (G4Cons*) (solid1st);        309       G4Cons* cons = (G4Cons*) (solid1st);
312       param->ComputeDimensions(*cons, ii, pv);    310       param->ComputeDimensions(*cons, ii, pv);
313       newParams = GetSolidParams(cons);           311       newParams = GetSolidParams(cons);
314       newSolid  = (G4VSolid*) cons;               312       newSolid  = (G4VSolid*) cons;
315     }                                             313     }
316     else if(solid1st->GetEntityType() == "G4Sp    314     else if(solid1st->GetEntityType() == "G4Sphere")
317     {                                             315     {
318       G4Sphere* sphere = (G4Sphere*) (solid1st    316       G4Sphere* sphere = (G4Sphere*) (solid1st);
319       param->ComputeDimensions(*sphere, ii, pv    317       param->ComputeDimensions(*sphere, ii, pv);
320       newParams = GetSolidParams(sphere);         318       newParams = GetSolidParams(sphere);
321       newSolid  = (G4VSolid*) sphere;             319       newSolid  = (G4VSolid*) sphere;
322     }                                             320     }
323     else if(solid1st->GetEntityType() == "G4Or    321     else if(solid1st->GetEntityType() == "G4Orb")
324     {                                             322     {
325       G4Orb* orb = (G4Orb*) (solid1st);           323       G4Orb* orb = (G4Orb*) (solid1st);
326       param->ComputeDimensions(*orb, ii, pv);     324       param->ComputeDimensions(*orb, ii, pv);
327       newParams = GetSolidParams(orb);            325       newParams = GetSolidParams(orb);
328       newSolid  = (G4VSolid*) orb;                326       newSolid  = (G4VSolid*) orb;
329     }                                             327     }
330     else if(solid1st->GetEntityType() == "G4To    328     else if(solid1st->GetEntityType() == "G4Torus")
331     {                                             329     {
332       G4Torus* torus = (G4Torus*) (solid1st);     330       G4Torus* torus = (G4Torus*) (solid1st);
333       param->ComputeDimensions(*torus, ii, pv)    331       param->ComputeDimensions(*torus, ii, pv);
334       newParams = GetSolidParams(torus);          332       newParams = GetSolidParams(torus);
335       newSolid  = (G4VSolid*) torus;              333       newSolid  = (G4VSolid*) torus;
336     }                                             334     }
337     else if(solid1st->GetEntityType() == "G4Pa    335     else if(solid1st->GetEntityType() == "G4Para")
338     {                                             336     {
339       G4Para* para = (G4Para*) (solid1st);        337       G4Para* para = (G4Para*) (solid1st);
340       param->ComputeDimensions(*para, ii, pv);    338       param->ComputeDimensions(*para, ii, pv);
341       newParams = GetSolidParams(para);           339       newParams = GetSolidParams(para);
342       newSolid  = (G4VSolid*) para;               340       newSolid  = (G4VSolid*) para;
343     }                                             341     }
344     else if(solid1st->GetEntityType() == "G4Po    342     else if(solid1st->GetEntityType() == "G4Polycone")
345     {                                             343     {
346       G4Polycone* polycone = (G4Polycone*) (so    344       G4Polycone* polycone = (G4Polycone*) (solid1st);
347       param->ComputeDimensions(*polycone, ii,     345       param->ComputeDimensions(*polycone, ii, pv);
348       newParams = GetSolidParams(polycone);       346       newParams = GetSolidParams(polycone);
349       newSolid  = (G4VSolid*) polycone;           347       newSolid  = (G4VSolid*) polycone;
350     }                                             348     }
351     else if(solid1st->GetEntityType() == "G4Po    349     else if(solid1st->GetEntityType() == "G4Polyhedra")
352     {                                             350     {
353       G4Polyhedra* polyhedra = (G4Polyhedra*)     351       G4Polyhedra* polyhedra = (G4Polyhedra*) (solid1st);
354       param->ComputeDimensions(*polyhedra, ii,    352       param->ComputeDimensions(*polyhedra, ii, pv);
355       newParams = GetSolidParams(polyhedra);      353       newParams = GetSolidParams(polyhedra);
356       newSolid  = (G4VSolid*) polyhedra;          354       newSolid  = (G4VSolid*) polyhedra;
357     }                                             355     }
358     else if(solid1st->GetEntityType() == "G4Hy    356     else if(solid1st->GetEntityType() == "G4Hype")
359     {                                             357     {
360       G4Hype* hype = (G4Hype*) (solid1st);        358       G4Hype* hype = (G4Hype*) (solid1st);
361       param->ComputeDimensions(*hype, ii, pv);    359       param->ComputeDimensions(*hype, ii, pv);
362       newParams = GetSolidParams(hype);           360       newParams = GetSolidParams(hype);
363       newSolid  = (G4VSolid*) hype;               361       newSolid  = (G4VSolid*) hype;
364     }                                             362     }
365     if(ii == 0 || mate1st != newMate || params    363     if(ii == 0 || mate1st != newMate || params1st[0] != newParams[0])
366     {                                             364     {
367       G4String extraName = "";                    365       G4String extraName = "";
368       if(ii != 0)                                 366       if(ii != 0)
369       {                                           367       {
370         extraName = "#" + G4UIcommand::Convert    368         extraName = "#" + G4UIcommand::ConvertToString(ii) + "/" +
371                     pv->GetMotherLogical()->Ge    369                     pv->GetMotherLogical()->GetName();
372       }                                           370       }
373       lvName = DumpLogVol(lv, extraName, newSo    371       lvName = DumpLogVol(lv, extraName, newSolid, newMate);
374     }                                             372     }
375                                                   373 
376     param->ComputeTransformation(ii, pv);         374     param->ComputeTransformation(ii, pv);
377     DumpPVPlacement(pv, lvName, ii);              375     DumpPVPlacement(pv, lvName, ii);
378   }                                               376   }
379 }                                                 377 }
380                                                   378 
381 // -------------------------------------------    379 // --------------------------------------------------------------------
382 void G4tgbGeometryDumper::DumpPVReplica(G4PVRe    380 void G4tgbGeometryDumper::DumpPVReplica(G4PVReplica* pv, const G4String& lvName)
383 {                                                 381 {
384   EAxis axis;                                     382   EAxis axis;
385   G4int nReplicas;                                383   G4int nReplicas;
386   G4double width;                                 384   G4double width;
387   G4double offset;                                385   G4double offset;
388   G4bool consuming;                               386   G4bool consuming;
389   pv->GetReplicationData(axis, nReplicas, widt    387   pv->GetReplicationData(axis, nReplicas, width, offset, consuming);
390   G4String axisName;                              388   G4String axisName;
391   switch(axis)                                    389   switch(axis)
392   {                                               390   {
393     case kXAxis:                                  391     case kXAxis:
394       axisName = "X";                             392       axisName = "X";
395       break;                                      393       break;
396     case kYAxis:                                  394     case kYAxis:
397       axisName = "Y";                             395       axisName = "Y";
398       break;                                      396       break;
399     case kZAxis:                                  397     case kZAxis:
400       axisName = "Z";                             398       axisName = "Z";
401       break;                                      399       break;
402     case kRho:                                    400     case kRho:
403       axisName = "R";                             401       axisName = "R";
404       break;                                      402       break;
405     case kPhi:                                    403     case kPhi:
406       axisName = "PHI";                           404       axisName = "PHI";
407       break;                                      405       break;
408     case kRadial3D:                               406     case kRadial3D:
409     case kUndefined:                              407     case kUndefined:
410       G4String ErrMessage =                       408       G4String ErrMessage =
411         "Unknown axis of replication for volum    409         "Unknown axis of replication for volume" + pv->GetName();
412       G4Exception("G4tgbGeometryDumper::DumpPV    410       G4Exception("G4tgbGeometryDumper::DumpPVReplica", "Wrong axis ",
413                   FatalException, ErrMessage);    411                   FatalException, ErrMessage);
414       break;                                      412       break;
415   }                                               413   }
416                                                   414 
417   const G4String& fullname = lvName + "/" + pv << 415   G4String fullname = lvName + "/" + pv->GetMotherLogical()->GetName();
418                                                   416 
419   if(!CheckIfPhysVolExists(fullname, pv))         417   if(!CheckIfPhysVolExists(fullname, pv))
420   {                                               418   {
421     (*theFile) << ":REPL " << SubstituteRefl(A    419     (*theFile) << ":REPL " << SubstituteRefl(AddQuotes(lvName)) << " "
422                << SubstituteRefl(AddQuotes(pv-    420                << SubstituteRefl(AddQuotes(pv->GetMotherLogical()->GetName()))
423                << " " << axisName << " " << nR    421                << " " << axisName << " " << nReplicas;
424     if(axis != kPhi)                              422     if(axis != kPhi)
425     {                                             423     {
426       (*theFile) << " " << width << " " << off    424       (*theFile) << " " << width << " " << offset << G4endl;
427     }                                             425     }
428     else                                          426     else
429     {                                             427     {
430       (*theFile) << " " << width / deg << "*de    428       (*theFile) << " " << width / deg << "*deg"
431                  << " " << offset / deg << "*d    429                  << " " << offset / deg << "*deg" << G4endl;
432     }                                             430     }
433                                                   431 
434     thePhysVols[fullname] = pv;                   432     thePhysVols[fullname] = pv;
435   }                                               433   }
436 }                                                 434 }
437                                                   435 
438 // -------------------------------------------    436 // --------------------------------------------------------------------
439 G4String G4tgbGeometryDumper::DumpLogVol(G4Log    437 G4String G4tgbGeometryDumper::DumpLogVol(G4LogicalVolume* lv,
440                                          const    438                                          const G4String& extraName,
441                                          G4VSo    439                                          G4VSolid* solid,
442                                          G4Mat    440                                          G4Material* mate)
443 {                                                 441 {
444   G4String lvName;                                442   G4String lvName;
445                                                   443 
446   if(extraName == "")  //--- take out the '_re    444   if(extraName == "")  //--- take out the '_refl' in the name
447   {                                               445   {
448     lvName = GetObjectName(lv, theLogVols);       446     lvName = GetObjectName(lv, theLogVols);
449   }                                               447   }
450   else                                            448   else
451   {                                               449   {
452     lvName = lv->GetName() + extraName;           450     lvName = lv->GetName() + extraName;
453   }                                               451   }
454                                                   452 
455   if(theLogVols.find(lvName) != theLogVols.cen    453   if(theLogVols.find(lvName) != theLogVols.cend())  // alredy dumped
456   {                                               454   {
457     return lvName;                                455     return lvName;
458   }                                               456   }
459                                                   457 
460   if(solid == nullptr)                            458   if(solid == nullptr)
461   {                                               459   {
462     solid = lv->GetSolid();                       460     solid = lv->GetSolid();
463   }                                               461   }
464                                                   462 
465   //---- Dump solid                               463   //---- Dump solid
466   const G4String& solidName = DumpSolid(solid, << 464   G4String solidName = DumpSolid(solid, extraName);
467                                                   465 
468   //---- Dump material                            466   //---- Dump material
469   if(mate == nullptr)                             467   if(mate == nullptr)
470   {                                               468   {
471     mate = lv->GetMaterial();                     469     mate = lv->GetMaterial();
472   }                                               470   }
473   const G4String& mateName = DumpMaterial(mate << 471   G4String mateName = DumpMaterial(mate);
474                                                   472 
475   //---- Dump logical volume (solid + material    473   //---- Dump logical volume (solid + material)
476   (*theFile) << ":VOLU " << SubstituteRefl(Add    474   (*theFile) << ":VOLU " << SubstituteRefl(AddQuotes(lvName)) << " "
477              << SupressRefl(AddQuotes(solidNam    475              << SupressRefl(AddQuotes(solidName)) << " " << AddQuotes(mateName)
478              << G4endl;                           476              << G4endl;
479                                                   477 
480   theLogVols[lvName] = lv;                        478   theLogVols[lvName] = lv;
481                                                   479 
482   return lvName;                                  480   return lvName;
483 }                                                 481 }
484                                                   482 
485 // -------------------------------------------    483 // --------------------------------------------------------------------
486 G4String G4tgbGeometryDumper::DumpMaterial(G4M    484 G4String G4tgbGeometryDumper::DumpMaterial(G4Material* mat)
487 {                                                 485 {
488   const G4String& mateName = GetObjectName(mat << 486   G4String mateName = GetObjectName(mat, theMaterials);
489   if(theMaterials.find(mateName) != theMateria    487   if(theMaterials.find(mateName) != theMaterials.cend())  // alredy dumped
490   {                                               488   {
491     return mateName;                              489     return mateName;
492   }                                               490   }
493                                                   491 
494   std::size_t numElements = mat->GetNumberOfEl    492   std::size_t numElements = mat->GetNumberOfElements();
495   G4double density   = mat->GetDensity() / g *    493   G4double density   = mat->GetDensity() / g * cm3;
496                                                   494 
497   // start tag                                    495   // start tag
498   //                                              496   //
499   if(numElements == 1)                            497   if(numElements == 1)
500   {                                               498   {
501     (*theFile) << ":MATE " << AddQuotes(mateNa    499     (*theFile) << ":MATE " << AddQuotes(mateName) << " " << mat->GetZ() << " "
502                << mat->GetA() / (g / mole) <<     500                << mat->GetA() / (g / mole) << " " << density << G4endl;
503   }                                               501   }
504   else                                            502   else
505   {                                               503   {
506     const G4ElementVector* elems = mat->GetEle    504     const G4ElementVector* elems = mat->GetElementVector();
507     const G4double* fractions    = mat->GetFra    505     const G4double* fractions    = mat->GetFractionVector();
508     for(std::size_t ii = 0; ii < numElements;     506     for(std::size_t ii = 0; ii < numElements; ++ii)
509     {                                             507     {
510       DumpElement(const_cast<G4Element*>((*ele << 508       DumpElement((*elems)[ii]);
511     }                                             509     }
512                                                   510 
513     (*theFile) << ":MIXT " << AddQuotes(mateNa    511     (*theFile) << ":MIXT " << AddQuotes(mateName) << " " << density << " "
514                << numElements << G4endl;          512                << numElements << G4endl;
515     // close start element tag and get ready t    513     // close start element tag and get ready to do composit "parts"
516     for(std::size_t ii = 0; ii < numElements;     514     for(std::size_t ii = 0; ii < numElements; ++ii)
517     {                                             515     {
518       (*theFile) << "   " << AddQuotes(GetObje << 516       (*theFile) << "   " << AddQuotes(GetObjectName((*elems)[ii], theElements))
519                  << " " << fractions[ii] << G4    517                  << " " << fractions[ii] << G4endl;
520     }                                             518     }
521   }                                               519   }
522                                                   520 
523   (*theFile) << ":MATE_MEE " << AddQuotes(mate    521   (*theFile) << ":MATE_MEE " << AddQuotes(mateName) << " "
524              << mat->GetIonisation()->GetMeanE    522              << mat->GetIonisation()->GetMeanExcitationEnergy() / eV << "*eV"
525              << G4endl;                           523              << G4endl;
526                                                   524 
527   (*theFile) << ":MATE_TEMPERATURE " << AddQuo    525   (*theFile) << ":MATE_TEMPERATURE " << AddQuotes(mateName) << " "
528              << mat->GetTemperature() / kelvin    526              << mat->GetTemperature() / kelvin << "*kelvin" << G4endl;
529                                                   527 
530   (*theFile) << ":MATE_PRESSURE " << AddQuotes    528   (*theFile) << ":MATE_PRESSURE " << AddQuotes(mateName) << " "
531              << mat->GetPressure() / atmospher    529              << mat->GetPressure() / atmosphere << "*atmosphere" << G4endl;
532                                                   530 
533   G4State state = mat->GetState();                531   G4State state = mat->GetState();
534   G4String stateStr;                              532   G4String stateStr;
535   switch(state)                                   533   switch(state)
536   {                                               534   {
537     case kStateUndefined:                         535     case kStateUndefined:
538       stateStr = "Undefined";                     536       stateStr = "Undefined";
539       break;                                      537       break;
540     case kStateSolid:                             538     case kStateSolid:
541       stateStr = "Solid";                         539       stateStr = "Solid";
542       break;                                      540       break;
543     case kStateLiquid:                            541     case kStateLiquid:
544       stateStr = "Liquid";                        542       stateStr = "Liquid";
545       break;                                      543       break;
546     case kStateGas:                               544     case kStateGas:
547       stateStr = "Gas";                           545       stateStr = "Gas";
548       break;                                      546       break;
549   }                                               547   }
550                                                   548 
551   (*theFile) << ":MATE_STATE " << AddQuotes(ma    549   (*theFile) << ":MATE_STATE " << AddQuotes(mateName) << " " << stateStr
552              << G4endl;                           550              << G4endl;
553                                                   551 
554   theMaterials[mateName] = mat;                   552   theMaterials[mateName] = mat;
555                                                   553 
556   return mateName;                                554   return mateName;
557 }                                                 555 }
558                                                   556 
559 // -------------------------------------------    557 // --------------------------------------------------------------------
560 void G4tgbGeometryDumper::DumpElement(G4Elemen    558 void G4tgbGeometryDumper::DumpElement(G4Element* ele)
561 {                                                 559 {
562   const G4String& elemName = GetObjectName(ele << 560   G4String elemName = GetObjectName(ele, theElements);
563                                                   561 
564   if(theElements.find(elemName) != theElements    562   if(theElements.find(elemName) != theElements.cend())  // alredy dumped
565   {                                               563   {
566     return;                                       564     return;
567   }                                               565   }
568                                                   566 
569   //--- Add symbol name: Material mixtures sto    567   //--- Add symbol name: Material mixtures store the components as elements
570   //    (even if the input are materials), but    568   //    (even if the input are materials), but without symbol
571   //                                              569   //
572   G4String symbol = ele->GetSymbol();             570   G4String symbol = ele->GetSymbol();
573   if(symbol == "" || symbol == " ")               571   if(symbol == "" || symbol == " ")
574   {                                               572   {
575     symbol = elemName;                            573     symbol = elemName;
576   }                                               574   }
577                                                   575 
578   if(ele->GetNumberOfIsotopes() == 0)             576   if(ele->GetNumberOfIsotopes() == 0)
579   {                                               577   {
580     (*theFile) << ":ELEM " << AddQuotes(elemNa    578     (*theFile) << ":ELEM " << AddQuotes(elemName) << " " << AddQuotes(symbol)
581                << " " << ele->GetZ() << " " <<    579                << " " << ele->GetZ() << " " << ele->GetA() / (g / mole) << " "
582                << G4endl;                         580                << G4endl;
583   }                                               581   }
584   else                                            582   else
585   {                                               583   {
586     const G4IsotopeVector* isots = ele->GetIso    584     const G4IsotopeVector* isots = ele->GetIsotopeVector();
587     for(std::size_t ii = 0; ii < ele->GetNumbe    585     for(std::size_t ii = 0; ii < ele->GetNumberOfIsotopes(); ++ii)
588     {                                             586     {
589       DumpIsotope((*isots)[ii]);                  587       DumpIsotope((*isots)[ii]);
590     }                                             588     }
591                                                   589 
592     (*theFile) << ":ELEM_FROM_ISOT " << AddQuo    590     (*theFile) << ":ELEM_FROM_ISOT " << AddQuotes(elemName) << " "
593                << AddQuotes(symbol) << " " <<     591                << AddQuotes(symbol) << " " << ele->GetNumberOfIsotopes()
594                << G4endl;                         592                << G4endl;
595     const G4double* fractions = ele->GetRelati    593     const G4double* fractions = ele->GetRelativeAbundanceVector();
596     for(std::size_t ii = 0; ii < ele->GetNumbe    594     for(std::size_t ii = 0; ii < ele->GetNumberOfIsotopes(); ++ii)
597     {                                             595     {
598       (*theFile) << "   " << AddQuotes(GetObje    596       (*theFile) << "   " << AddQuotes(GetObjectName((*isots)[ii], theIsotopes))
599                  << " " << fractions[ii] << G4    597                  << " " << fractions[ii] << G4endl;
600     }                                             598     }
601   }                                               599   }
602   theElements[elemName] = ele;                    600   theElements[elemName] = ele;
603 }                                                 601 }
604                                                   602 
605 // -------------------------------------------    603 // --------------------------------------------------------------------
606 void G4tgbGeometryDumper::DumpIsotope(G4Isotop    604 void G4tgbGeometryDumper::DumpIsotope(G4Isotope* isot)
607 {                                                 605 {
608   const G4String& isotName = GetObjectName(iso << 606   G4String isotName = GetObjectName(isot, theIsotopes);
609   if(theIsotopes.find(isotName) != theIsotopes    607   if(theIsotopes.find(isotName) != theIsotopes.cend())  // alredy dumped
610   {                                               608   {
611     return;                                       609     return;
612   }                                               610   }
613                                                   611 
614   (*theFile) << ":ISOT " << AddQuotes(isotName    612   (*theFile) << ":ISOT " << AddQuotes(isotName) << " " << isot->GetZ() << " "
615              << isot->GetN() << " " << isot->G    613              << isot->GetN() << " " << isot->GetA() / (g / mole) << " "
616              << G4endl;                           614              << G4endl;
617                                                   615 
618   theIsotopes[isotName] = isot;                   616   theIsotopes[isotName] = isot;
619 }                                                 617 }
620                                                   618 
621 // -------------------------------------------    619 // --------------------------------------------------------------------
622 G4String G4tgbGeometryDumper::DumpSolid(G4VSol    620 G4String G4tgbGeometryDumper::DumpSolid(G4VSolid* solid,
623                                         const     621                                         const G4String& extraName)
624 {                                                 622 {
625   G4String solidName;                             623   G4String solidName;
626   if(extraName == "")                             624   if(extraName == "")
627   {                                               625   {
628     solidName = GetObjectName(solid, theSolids    626     solidName = GetObjectName(solid, theSolids);
629   }                                               627   }
630   else                                            628   else
631   {                                               629   {
632     solidName = solid->GetName() + extraName;     630     solidName = solid->GetName() + extraName;
633   }                                               631   }
634                                                   632 
635   if(theSolids.find(solidName) != theSolids.ce    633   if(theSolids.find(solidName) != theSolids.cend())  // alredy dumped
636   {                                               634   {
637     return solidName;                             635     return solidName;
638   }                                               636   }
639                                                   637 
640   G4String solidType = solid->GetEntityType();    638   G4String solidType = solid->GetEntityType();
641   solidType          = GetTGSolidType(solidTyp    639   solidType          = GetTGSolidType(solidType);
642                                                << 640 
643   if(solidType == "UNIONSOLID")                   641   if(solidType == "UNIONSOLID")
644   {                                               642   {
645     DumpBooleanVolume("UNION", solid);            643     DumpBooleanVolume("UNION", solid);
646   }                                               644   }
647   else if(solidType == "SUBTRACTIONSOLID")        645   else if(solidType == "SUBTRACTIONSOLID")
648   {                                               646   {
649     DumpBooleanVolume("SUBTRACTION", solid);      647     DumpBooleanVolume("SUBTRACTION", solid);
650   }                                               648   }
651   else if(solidType == "INTERSECTIONSOLID")       649   else if(solidType == "INTERSECTIONSOLID")
652   {                                               650   {
653     DumpBooleanVolume("INTERSECTION", solid);     651     DumpBooleanVolume("INTERSECTION", solid);
654   }                                               652   }
655   else if(solidType == "REFLECTEDSOLID")          653   else if(solidType == "REFLECTEDSOLID")
656   {                                               654   {
657     G4ReflectedSolid* solidrefl = dynamic_cast    655     G4ReflectedSolid* solidrefl = dynamic_cast<G4ReflectedSolid*>(solid);
658     if(solidrefl == nullptr)                      656     if(solidrefl == nullptr)
659     {                                             657     {
660       G4Exception("G4tgbGeometryDumper::DumpSo    658       G4Exception("G4tgbGeometryDumper::DumpSolid()", "InvalidType",
661                   FatalException, "Invalid ref    659                   FatalException, "Invalid reflected solid!");
662       return solidName;                           660       return solidName;
663     }                                             661     }
664     G4VSolid* solidori = solidrefl->GetConstit    662     G4VSolid* solidori = solidrefl->GetConstituentMovedSolid();
665     DumpSolid(solidori);                          663     DumpSolid(solidori);
666   }                                               664   }
667   else if(solidType == "MULTIUNION")           << 
668   {                                            << 
669     DumpMultiUnionVolume(solid);               << 
670   }                                            << 
671   else if(solidType == "SCALEDSOLID")          << 
672   {                                            << 
673     DumpScaledVolume(solid);                   << 
674   }                                            << 
675   else                                            665   else
676   {                                               666   {
677     (*theFile) << ":SOLID " << AddQuotes(solid    667     (*theFile) << ":SOLID " << AddQuotes(solidName) << " ";
678     (*theFile) << AddQuotes(solidType) << " ";    668     (*theFile) << AddQuotes(solidType) << " ";
679     DumpSolidParams( solid );                  << 669     DumpSolidParams(solid);
680     theSolids[solidName] = solid;                 670     theSolids[solidName] = solid;
681   }                                               671   }
682                                                   672 
683   return solidName;                               673   return solidName;
684 }                                                 674 }
685                                                   675 
686 // -------------------------------------------    676 // --------------------------------------------------------------------
687 void G4tgbGeometryDumper::DumpBooleanVolume(co    677 void G4tgbGeometryDumper::DumpBooleanVolume(const G4String& solidType,
688                                             G4    678                                             G4VSolid* so)
689 {                                                 679 {
690   G4BooleanSolid* bso = dynamic_cast<G4Boolean    680   G4BooleanSolid* bso = dynamic_cast<G4BooleanSolid*>(so);
691   if(bso == nullptr)                              681   if(bso == nullptr)
692   {                                               682   {
693     return;                                       683     return;
694   }                                               684   }
695   G4VSolid* solid0             = bso->GetConst    685   G4VSolid* solid0             = bso->GetConstituentSolid(0);
696   G4VSolid* solid1             = bso->GetConst    686   G4VSolid* solid1             = bso->GetConstituentSolid(1);
697   G4DisplacedSolid* solid1Disp = nullptr;         687   G4DisplacedSolid* solid1Disp = nullptr;
698   G4bool displaced             = dynamic_cast<    688   G4bool displaced             = dynamic_cast<G4DisplacedSolid*>(solid1);
699   if(displaced)                                   689   if(displaced)
700   {                                               690   {
701     solid1Disp = dynamic_cast<G4DisplacedSolid    691     solid1Disp = dynamic_cast<G4DisplacedSolid*>(solid1);
702     if(solid1Disp != nullptr)                     692     if(solid1Disp != nullptr)
703     {                                             693     {
704       solid1 = solid1Disp->GetConstituentMoved    694       solid1 = solid1Disp->GetConstituentMovedSolid();
705     }                                             695     }
706     else                                          696     else
707     {                                             697     {
708       return;                                     698       return;
709     }                                             699     }
710   }                                               700   }
711   DumpSolid(solid0);                              701   DumpSolid(solid0);
712   DumpSolid(solid1);                              702   DumpSolid(solid1);
713                                                   703 
714   G4String rotName;                               704   G4String rotName;
715   G4ThreeVector pos;                              705   G4ThreeVector pos;
716   if(displaced)                                   706   if(displaced)
717   {                                               707   {
718     pos = solid1Disp->GetObjectTranslation();     708     pos = solid1Disp->GetObjectTranslation();  // translation is of mother frame
719     rotName = DumpRotationMatrix(new G4Rotatio    709     rotName = DumpRotationMatrix(new G4RotationMatrix(
720       (solid1Disp->GetTransform().NetRotation(    710       (solid1Disp->GetTransform().NetRotation()).inverse()));
721   }                                               711   }
722   else  // no displacement                        712   else  // no displacement
723   {                                               713   {
724     rotName = DumpRotationMatrix(new G4Rotatio    714     rotName = DumpRotationMatrix(new G4RotationMatrix);
725     pos     = G4ThreeVector();                    715     pos     = G4ThreeVector();
726   }                                               716   }
727                                                   717 
728   const G4String& bsoName = GetObjectName(so,  << 718   G4String bsoName = GetObjectName(so, theSolids);
729   if(theSolids.find(bsoName) != theSolids.cend << 719   if(theSolids.find(bsoName) != theSolids.cend())
730   const G4String& solid0Name = FindSolidName(s << 720     return;  // alredy dumped
731   const G4String& solid1Name = FindSolidName(s << 721   G4String solid0Name = FindSolidName(solid0);
                                                   >> 722   G4String solid1Name = FindSolidName(solid1);
732                                                   723 
733   (*theFile) << ":SOLID " << AddQuotes(bsoName    724   (*theFile) << ":SOLID " << AddQuotes(bsoName) << " " << AddQuotes(solidType)
734              << " " << AddQuotes(solid0Name) <    725              << " " << AddQuotes(solid0Name) << " " << AddQuotes(solid1Name)
735              << " " << AddQuotes(rotName) << "    726              << " " << AddQuotes(rotName) << " " << approxTo0(pos.x()) << " "
736              << approxTo0(pos.y()) << " " << a    727              << approxTo0(pos.y()) << " " << approxTo0(pos.z()) << " "
737              << G4endl;                           728              << G4endl;
738                                                   729 
739   theSolids[bsoName] = bso;                       730   theSolids[bsoName] = bso;
740 }                                                 731 }
741                                                   732 
742 // -------------------------------------------    733 // --------------------------------------------------------------------
743 void G4tgbGeometryDumper::DumpMultiUnionVolume << 
744 {                                              << 
745   const G4MultiUnion* muun = dynamic_cast<cons << 
746   if(muun != nullptr)                          << 
747     {                                          << 
748       G4int nSolids = muun->GetNumberOfSolids( << 
749       std::vector<G4String> rotList;           << 
750       for( G4int iso = 0; iso < nSolids; iso++ << 
751   G4Transform3D trans = muun->GetTransformatio << 
752   const G4String& rotName = DumpRotationMatrix << 
753   rotList.push_back(rotName);                  << 
754   G4VSolid* solN = muun->GetSolid(iso);        << 
755   DumpSolid(solN);                             << 
756       }                                        << 
757       const G4String& bsoName = GetObjectName( << 
758       (*theFile) << ":SOLID " << AddQuotes(bso << 
759      << nSolids;                               << 
760                                                << 
761       for( G4int iso = 0; iso < nSolids; ++iso << 
762   G4VSolid* solN = muun->GetSolid(iso);        << 
763   G4Transform3D trans = muun->GetTransformatio << 
764   G4ThreeVector pos = trans.getTranslation();  << 
765   (*theFile) << " " <<  solN->GetName()        << 
766        << " " << " " << rotList[iso]           << 
767        << " " << approxTo0(pos.x())            << 
768        << " " << approxTo0(pos.y())            << 
769        << " " << approxTo0(pos.z());           << 
770       }                                        << 
771       (*theFile) << G4endl;                    << 
772                                                << 
773     }                                          << 
774 }                                              << 
775                                                << 
776 // ------------------------------------------- << 
777 void G4tgbGeometryDumper::DumpScaledVolume( G4 << 
778 {                                              << 
779   const G4ScaledSolid* ssol = dynamic_cast<con << 
780   if(ssol != nullptr)                          << 
781     {                                          << 
782       G4VSolid* unscaledSolid = ssol->GetUnsca << 
783       G4Scale3D scaleTransf = ssol->GetScaleTr << 
784       G4String bsoName = GetObjectName(const_c << 
785       (*theFile) << ":SOLID " << AddQuotes(bso << 
786      << unscaledSolid->GetName() << " "        << 
787      << scaleTransf.xx() << " "                << 
788      << scaleTransf.yy() << " "                << 
789      << scaleTransf.zz() << G4endl;            << 
790     }                                          << 
791 }                                              << 
792                                                << 
793 // ------------------------------------------- << 
794 void G4tgbGeometryDumper::DumpSolidParams(G4VS    734 void G4tgbGeometryDumper::DumpSolidParams(G4VSolid* so)
795 {                                                 735 {
796   std::vector<G4double> params = GetSolidParam    736   std::vector<G4double> params = GetSolidParams(so);
797   for(std::size_t ii = 0; ii < params.size();     737   for(std::size_t ii = 0; ii < params.size(); ++ii)
798   {                                               738   {
799     (*theFile) << params[ii] << " ";              739     (*theFile) << params[ii] << " ";
800   }                                               740   }
801   (*theFile) << G4endl;                           741   (*theFile) << G4endl;
802 }                                                 742 }
803                                                   743 
804 // -------------------------------------------    744 // --------------------------------------------------------------------
805 std::vector<G4double> G4tgbGeometryDumper::Get    745 std::vector<G4double> G4tgbGeometryDumper::GetSolidParams(const G4VSolid* so)
806 {                                                 746 {
807   std::vector<G4double> params;                   747   std::vector<G4double> params;
808                                                   748 
809   G4String solidType = so->GetEntityType();       749   G4String solidType = so->GetEntityType();
810   solidType          = GetTGSolidType(solidTyp    750   solidType          = GetTGSolidType(solidType);
811                                                   751 
812   if(solidType == "BOX")                          752   if(solidType == "BOX")
813   {                                               753   {
814     const G4Box* sb = dynamic_cast<const G4Box    754     const G4Box* sb = dynamic_cast<const G4Box*>(so);
815     if(sb != nullptr)                             755     if(sb != nullptr)
816     {                                             756     {
817       params.push_back(sb->GetXHalfLength());     757       params.push_back(sb->GetXHalfLength());
818       params.push_back(sb->GetYHalfLength());     758       params.push_back(sb->GetYHalfLength());
819       params.push_back(sb->GetZHalfLength());     759       params.push_back(sb->GetZHalfLength());
820     }                                             760     }
821   }                                               761   }
822   else if(solidType == "TUBS")                    762   else if(solidType == "TUBS")
823   {                                               763   {
824     const G4Tubs* tu = dynamic_cast<const G4Tu    764     const G4Tubs* tu = dynamic_cast<const G4Tubs*>(so);
825     if(tu != nullptr)                             765     if(tu != nullptr)
826     {                                             766     {
827       params.push_back(tu->GetInnerRadius());     767       params.push_back(tu->GetInnerRadius());
828       params.push_back(tu->GetOuterRadius());     768       params.push_back(tu->GetOuterRadius());
829       params.push_back(tu->GetZHalfLength());     769       params.push_back(tu->GetZHalfLength());
830       params.push_back(tu->GetStartPhiAngle()     770       params.push_back(tu->GetStartPhiAngle() / deg);
831       params.push_back(tu->GetDeltaPhiAngle()     771       params.push_back(tu->GetDeltaPhiAngle() / deg);
832     }                                             772     }
833   }                                               773   }
834   else if(solidType == "TRAP")                    774   else if(solidType == "TRAP")
835   {                                               775   {
836     const G4Trap* trp = dynamic_cast<const G4T    776     const G4Trap* trp = dynamic_cast<const G4Trap*>(so);
837     if(trp != nullptr)                            777     if(trp != nullptr)
838     {                                             778     {
839       G4ThreeVector symAxis(trp->GetSymAxis())    779       G4ThreeVector symAxis(trp->GetSymAxis());
840       params.push_back(trp->GetZHalfLength());    780       params.push_back(trp->GetZHalfLength());
841       params.push_back(symAxis.theta() / deg);    781       params.push_back(symAxis.theta() / deg);
842       params.push_back(symAxis.phi() / deg);      782       params.push_back(symAxis.phi() / deg);
843       params.push_back(trp->GetYHalfLength1())    783       params.push_back(trp->GetYHalfLength1());
844       params.push_back(trp->GetXHalfLength1())    784       params.push_back(trp->GetXHalfLength1());
845       params.push_back(trp->GetXHalfLength2())    785       params.push_back(trp->GetXHalfLength2());
846       params.push_back(std::atan(trp->GetTanAl    786       params.push_back(std::atan(trp->GetTanAlpha1()) / deg);
847       params.push_back(trp->GetYHalfLength2())    787       params.push_back(trp->GetYHalfLength2());
848       params.push_back(trp->GetXHalfLength3())    788       params.push_back(trp->GetXHalfLength3());
849       params.push_back(trp->GetXHalfLength4())    789       params.push_back(trp->GetXHalfLength4());
850       params.push_back(std::atan(trp->GetTanAl    790       params.push_back(std::atan(trp->GetTanAlpha2()) / deg);
851     }                                             791     }
852   }                                               792   }
853   else if(solidType == "TRD")                     793   else if(solidType == "TRD")
854   {                                               794   {
855     const G4Trd* tr = dynamic_cast<const G4Trd    795     const G4Trd* tr = dynamic_cast<const G4Trd*>(so);
856     if(tr != nullptr)                             796     if(tr != nullptr)
857     {                                             797     {
858       params.push_back(tr->GetXHalfLength1());    798       params.push_back(tr->GetXHalfLength1());
859       params.push_back(tr->GetXHalfLength2());    799       params.push_back(tr->GetXHalfLength2());
860       params.push_back(tr->GetYHalfLength1());    800       params.push_back(tr->GetYHalfLength1());
861       params.push_back(tr->GetYHalfLength2());    801       params.push_back(tr->GetYHalfLength2());
862       params.push_back(tr->GetZHalfLength());     802       params.push_back(tr->GetZHalfLength());
863     }                                             803     }
864   }                                               804   }
865   else if(solidType == "PARA")                    805   else if(solidType == "PARA")
866   {                                               806   {
867     const G4Para* para = dynamic_cast<const G4    807     const G4Para* para = dynamic_cast<const G4Para*>(so);
868     if(para != nullptr)                           808     if(para != nullptr)
869     {                                             809     {
870       G4ThreeVector symAxis(para->GetSymAxis()    810       G4ThreeVector symAxis(para->GetSymAxis());
871       params.push_back(para->GetXHalfLength())    811       params.push_back(para->GetXHalfLength());
872       params.push_back(para->GetYHalfLength())    812       params.push_back(para->GetYHalfLength());
873       params.push_back(para->GetZHalfLength())    813       params.push_back(para->GetZHalfLength());
874       params.push_back(std::atan(para->GetTanA    814       params.push_back(std::atan(para->GetTanAlpha()) / deg);
875       params.push_back(symAxis.theta() / deg);    815       params.push_back(symAxis.theta() / deg);
876       params.push_back(symAxis.phi() / deg);      816       params.push_back(symAxis.phi() / deg);
877     }                                             817     }
878   }                                               818   }
879   else if(solidType == "CONS")                    819   else if(solidType == "CONS")
880   {                                               820   {
881     const G4Cons* cn = dynamic_cast<const G4Co    821     const G4Cons* cn = dynamic_cast<const G4Cons*>(so);
882     if(cn != nullptr)                             822     if(cn != nullptr)
883     {                                             823     {
884       params.push_back(cn->GetInnerRadiusMinus    824       params.push_back(cn->GetInnerRadiusMinusZ());
885       params.push_back(cn->GetOuterRadiusMinus    825       params.push_back(cn->GetOuterRadiusMinusZ());
886       params.push_back(cn->GetInnerRadiusPlusZ    826       params.push_back(cn->GetInnerRadiusPlusZ());
887       params.push_back(cn->GetOuterRadiusPlusZ    827       params.push_back(cn->GetOuterRadiusPlusZ());
888       params.push_back(cn->GetZHalfLength());     828       params.push_back(cn->GetZHalfLength());
889       params.push_back(cn->GetStartPhiAngle()     829       params.push_back(cn->GetStartPhiAngle() / deg);
890       params.push_back(cn->GetDeltaPhiAngle()     830       params.push_back(cn->GetDeltaPhiAngle() / deg);
891     }                                             831     }
892   }                                               832   }
893   else if(solidType == "SPHERE")                  833   else if(solidType == "SPHERE")
894   {                                               834   {
895     const G4Sphere* sphere = dynamic_cast<cons    835     const G4Sphere* sphere = dynamic_cast<const G4Sphere*>(so);
896     if(sphere != nullptr)                         836     if(sphere != nullptr)
897     {                                             837     {
898       params.push_back(sphere->GetInnerRadius(    838       params.push_back(sphere->GetInnerRadius());
899       params.push_back(sphere->GetOuterRadius(    839       params.push_back(sphere->GetOuterRadius());
900       params.push_back(sphere->GetStartPhiAngl    840       params.push_back(sphere->GetStartPhiAngle() / deg);
901       params.push_back(sphere->GetDeltaPhiAngl    841       params.push_back(sphere->GetDeltaPhiAngle() / deg);
902       params.push_back(sphere->GetStartThetaAn    842       params.push_back(sphere->GetStartThetaAngle() / deg);
903       params.push_back(sphere->GetDeltaThetaAn    843       params.push_back(sphere->GetDeltaThetaAngle() / deg);
904     }                                             844     }
905   }                                               845   }
906   else if(solidType == "ORB")                     846   else if(solidType == "ORB")
907   {                                               847   {
908     const G4Orb* orb = dynamic_cast<const G4Or    848     const G4Orb* orb = dynamic_cast<const G4Orb*>(so);
909     if(orb != nullptr)                            849     if(orb != nullptr)
910     {                                             850     {
911       params.push_back(orb->GetRadius());         851       params.push_back(orb->GetRadius());
912     }                                             852     }
913   }                                               853   }
914   else if(solidType == "TORUS")                   854   else if(solidType == "TORUS")
915   {                                               855   {
916     const G4Torus* torus = dynamic_cast<const     856     const G4Torus* torus = dynamic_cast<const G4Torus*>(so);
917     if(torus != nullptr)                          857     if(torus != nullptr)
918     {                                             858     {
919       params.push_back(torus->GetRmin());         859       params.push_back(torus->GetRmin());
920       params.push_back(torus->GetRmax());         860       params.push_back(torus->GetRmax());
921       params.push_back(torus->GetRtor());         861       params.push_back(torus->GetRtor());
922       params.push_back(torus->GetSPhi() / deg)    862       params.push_back(torus->GetSPhi() / deg);
923       params.push_back(torus->GetDPhi() / deg)    863       params.push_back(torus->GetDPhi() / deg);
924     }                                             864     }
925   }                                               865   }
926   else if(solidType == "POLYCONE")                866   else if(solidType == "POLYCONE")
927   {                                               867   {
928     //--- Dump RZ corners, as original paramet    868     //--- Dump RZ corners, as original parameters will not be present
929     //    if it was build from RZ corners         869     //    if it was build from RZ corners
930     const G4Polycone* plc = dynamic_cast<const    870     const G4Polycone* plc = dynamic_cast<const G4Polycone*>(so);
931     if(plc != nullptr)                            871     if(plc != nullptr)
932     {                                             872     {
933       G4double angphi = plc->GetStartPhi() / d    873       G4double angphi = plc->GetStartPhi() / deg;
934       if(angphi > 180 * deg)                      874       if(angphi > 180 * deg)
935       {                                           875       {
936         angphi -= 360 * deg;                      876         angphi -= 360 * deg;
937       }                                           877       }
938       G4double endphi = plc->GetEndPhi() / deg << 
939       if(endphi > 180 * deg)                   << 
940       {                                        << 
941         endphi -= 360 * deg;                   << 
942       }                                        << 
943       params.push_back(angphi);                << 
944       params.push_back(endphi - angphi);       << 
945       //      params.push_back(plc->GetOrigina << 
946       G4int ncor = plc->GetNumRZCorner();         878       G4int ncor = plc->GetNumRZCorner();
                                                   >> 879       params.push_back(angphi);
                                                   >> 880       params.push_back(plc->GetOriginalParameters()->Opening_angle / deg);
947       params.push_back(ncor);                     881       params.push_back(ncor);
948                                                   882 
949       for(G4int ii = 0; ii < ncor; ++ii)          883       for(G4int ii = 0; ii < ncor; ++ii)
950       {                                           884       {
951         params.push_back(plc->GetCorner(ii).r)    885         params.push_back(plc->GetCorner(ii).r);
952         params.push_back(plc->GetCorner(ii).z)    886         params.push_back(plc->GetCorner(ii).z);
953       }                                           887       }
954     }                                             888     }
955   }                                               889   }
956   else if(solidType == "GENERICPOLYCONE")         890   else if(solidType == "GENERICPOLYCONE")
957   {                                               891   {
958     //--- Dump RZ corners                         892     //--- Dump RZ corners
959     const G4GenericPolycone* plc = dynamic_cas    893     const G4GenericPolycone* plc = dynamic_cast<const G4GenericPolycone*>(so);
960     if(plc != nullptr)                            894     if(plc != nullptr)
961     {                                             895     {
962       G4double angphi = plc->GetStartPhi() / d    896       G4double angphi = plc->GetStartPhi() / deg;
963       if(angphi > 180 * deg)                      897       if(angphi > 180 * deg)
964       {                                           898       {
965         angphi -= 360 * deg;                      899         angphi -= 360 * deg;
966       }                                           900       }
967       G4double endphi = plc->GetEndPhi() / deg    901       G4double endphi = plc->GetEndPhi() / deg;
968       if(endphi > 180 * deg)                      902       if(endphi > 180 * deg)
969       {                                           903       {
970         endphi -= 360 * deg;                      904         endphi -= 360 * deg;
971       }                                           905       }
                                                   >> 906       G4int ncor = plc->GetNumRZCorner();
972       params.push_back(angphi);                   907       params.push_back(angphi);
973       params.push_back(endphi - angphi);          908       params.push_back(endphi - angphi);
974       G4int ncor = plc->GetNumRZCorner();      << 
975       params.push_back(ncor);                     909       params.push_back(ncor);
976                                                   910 
977       for(G4int ii = 0; ii < ncor; ++ii)          911       for(G4int ii = 0; ii < ncor; ++ii)
978       {                                           912       {
979         params.push_back(plc->GetCorner(ii).r)    913         params.push_back(plc->GetCorner(ii).r);
980         params.push_back(plc->GetCorner(ii).z)    914         params.push_back(plc->GetCorner(ii).z);
981       }                                           915       }
982     }                                             916     }
983   }                                               917   }
984   else if(solidType == "POLYHEDRA")               918   else if(solidType == "POLYHEDRA")
985   {                                               919   {
986     //--- Dump RZ corners, as original paramet    920     //--- Dump RZ corners, as original parameters will not be present
987     //    if it was build from RZ corners         921     //    if it was build from RZ corners
988     const G4Polyhedra* ph = (dynamic_cast<cons    922     const G4Polyhedra* ph = (dynamic_cast<const G4Polyhedra*>(so));
989     if(ph != nullptr)                             923     if(ph != nullptr)
990     {                                             924     {
991       G4double angphi = ph->GetStartPhi() / de    925       G4double angphi = ph->GetStartPhi() / deg;
992       if(angphi > 180 * deg)                      926       if(angphi > 180 * deg)
993         angphi -= 360 * deg;                      927         angphi -= 360 * deg;
994                                                   928 
995       G4int ncor = ph->GetNumRZCorner();          929       G4int ncor = ph->GetNumRZCorner();
996                                                   930 
997       params.push_back(angphi);                   931       params.push_back(angphi);
998       params.push_back(ph->GetOriginalParamete    932       params.push_back(ph->GetOriginalParameters()->Opening_angle / deg);
999       params.push_back(ph->GetNumSide());         933       params.push_back(ph->GetNumSide());
1000       params.push_back(ncor);                    934       params.push_back(ncor);
1001                                                  935 
1002       for(G4int ii = 0; ii < ncor; ++ii)         936       for(G4int ii = 0; ii < ncor; ++ii)
1003       {                                          937       {
1004         params.push_back(ph->GetCorner(ii).r)    938         params.push_back(ph->GetCorner(ii).r);
1005         params.push_back(ph->GetCorner(ii).z)    939         params.push_back(ph->GetCorner(ii).z);
1006       }                                          940       }
1007     }                                            941     }
1008   }                                              942   }
1009   else if(solidType == "ELLIPTICALTUBE")         943   else if(solidType == "ELLIPTICALTUBE")
1010   {                                              944   {
1011     const G4EllipticalTube* eltu = dynamic_ca    945     const G4EllipticalTube* eltu = dynamic_cast<const G4EllipticalTube*>(so);
1012     if(eltu != nullptr)                          946     if(eltu != nullptr)
1013     {                                            947     {
1014       params.push_back(eltu->GetDx());           948       params.push_back(eltu->GetDx());
1015       params.push_back(eltu->GetDy());           949       params.push_back(eltu->GetDy());
1016       params.push_back(eltu->GetDz());           950       params.push_back(eltu->GetDz());
1017     }                                            951     }
1018   }                                              952   }
1019   else if(solidType == "ELLIPSOID")              953   else if(solidType == "ELLIPSOID")
1020   {                                              954   {
1021     const G4Ellipsoid* dso = dynamic_cast<con    955     const G4Ellipsoid* dso = dynamic_cast<const G4Ellipsoid*>(so);
1022     if(dso != nullptr)                           956     if(dso != nullptr)
1023     {                                            957     {
1024       params.push_back(dso->GetSemiAxisMax(0)    958       params.push_back(dso->GetSemiAxisMax(0));
1025       params.push_back(dso->GetSemiAxisMax(1)    959       params.push_back(dso->GetSemiAxisMax(1));
1026       params.push_back(dso->GetSemiAxisMax(2)    960       params.push_back(dso->GetSemiAxisMax(2));
1027       params.push_back(dso->GetZBottomCut());    961       params.push_back(dso->GetZBottomCut());
1028       params.push_back(dso->GetZTopCut());       962       params.push_back(dso->GetZTopCut());
1029     }                                            963     }
1030   }                                              964   }
1031   else if(solidType == "ELLIPTICAL_CONE")        965   else if(solidType == "ELLIPTICAL_CONE")
1032   {                                              966   {
1033     const G4EllipticalCone* elco = dynamic_ca    967     const G4EllipticalCone* elco = dynamic_cast<const G4EllipticalCone*>(so);
1034     if(elco != nullptr)                          968     if(elco != nullptr)
1035     {                                            969     {
1036       params.push_back(elco->GetSemiAxisX());    970       params.push_back(elco->GetSemiAxisX());
1037       params.push_back(elco->GetSemiAxisY());    971       params.push_back(elco->GetSemiAxisY());
1038       params.push_back(elco->GetZMax());         972       params.push_back(elco->GetZMax());
1039       params.push_back(elco->GetZTopCut());      973       params.push_back(elco->GetZTopCut());
1040     }                                            974     }
1041   }                                              975   }
1042   else if(solidType == "HYPE")                   976   else if(solidType == "HYPE")
1043   {                                              977   {
1044     const G4Hype* hype = dynamic_cast<const G    978     const G4Hype* hype = dynamic_cast<const G4Hype*>(so);
1045     if(hype != nullptr)                          979     if(hype != nullptr)
1046     {                                            980     {
1047       params.push_back(hype->GetInnerRadius()    981       params.push_back(hype->GetInnerRadius());
1048       params.push_back(hype->GetOuterRadius()    982       params.push_back(hype->GetOuterRadius());
1049       params.push_back(hype->GetInnerStereo()    983       params.push_back(hype->GetInnerStereo() / deg);
1050       params.push_back(hype->GetOuterStereo()    984       params.push_back(hype->GetOuterStereo() / deg);
1051       params.push_back(2 * hype->GetZHalfLeng    985       params.push_back(2 * hype->GetZHalfLength());
1052     }                                            986     }
1053     //  } else if( solidType == "TET" ) {        987     //  } else if( solidType == "TET" ) {
1054   }                                              988   }
1055   else if(solidType == "TWISTEDBOX")             989   else if(solidType == "TWISTEDBOX")
1056   {                                              990   {
1057     const G4TwistedBox* tbox = dynamic_cast<c    991     const G4TwistedBox* tbox = dynamic_cast<const G4TwistedBox*>(so);
1058     if(tbox != nullptr)                          992     if(tbox != nullptr)
1059     {                                            993     {
1060       params.push_back(tbox->GetPhiTwist() /     994       params.push_back(tbox->GetPhiTwist() / deg);
1061       params.push_back(tbox->GetXHalfLength()    995       params.push_back(tbox->GetXHalfLength());
1062       params.push_back(tbox->GetYHalfLength()    996       params.push_back(tbox->GetYHalfLength());
1063       params.push_back(tbox->GetZHalfLength()    997       params.push_back(tbox->GetZHalfLength());
1064     }                                            998     }
1065   }                                              999   }
1066   else if(solidType == "TWISTEDTRAP")            1000   else if(solidType == "TWISTEDTRAP")
1067   {                                              1001   {
1068     const G4TwistedTrap* ttrap = dynamic_cast    1002     const G4TwistedTrap* ttrap = dynamic_cast<const G4TwistedTrap*>(so);
1069     if(ttrap != nullptr)                         1003     if(ttrap != nullptr)
1070     {                                            1004     {
1071       params.push_back(ttrap->GetPhiTwist() /    1005       params.push_back(ttrap->GetPhiTwist() / deg);
1072       params.push_back(ttrap->GetZHalfLength(    1006       params.push_back(ttrap->GetZHalfLength());
1073       params.push_back(ttrap->GetPolarAngleTh    1007       params.push_back(ttrap->GetPolarAngleTheta() / deg);
1074       params.push_back(ttrap->GetAzimuthalAng    1008       params.push_back(ttrap->GetAzimuthalAnglePhi() / deg);
1075       params.push_back(ttrap->GetY1HalfLength    1009       params.push_back(ttrap->GetY1HalfLength());
1076       params.push_back(ttrap->GetX1HalfLength    1010       params.push_back(ttrap->GetX1HalfLength());
1077       params.push_back(ttrap->GetX2HalfLength    1011       params.push_back(ttrap->GetX2HalfLength());
1078       params.push_back(ttrap->GetY2HalfLength    1012       params.push_back(ttrap->GetY2HalfLength());
1079       params.push_back(ttrap->GetX3HalfLength    1013       params.push_back(ttrap->GetX3HalfLength());
1080       params.push_back(ttrap->GetX4HalfLength    1014       params.push_back(ttrap->GetX4HalfLength());
1081       params.push_back(ttrap->GetTiltAngleAlp    1015       params.push_back(ttrap->GetTiltAngleAlpha() / deg);
1082     }                                            1016     }
1083   }                                              1017   }
1084   else if(solidType == "TWISTEDTRD")             1018   else if(solidType == "TWISTEDTRD")
1085   {                                              1019   {
1086     const G4TwistedTrd* ttrd = dynamic_cast<c    1020     const G4TwistedTrd* ttrd = dynamic_cast<const G4TwistedTrd*>(so);
1087     if(ttrd != nullptr)                          1021     if(ttrd != nullptr)
1088     {                                            1022     {
1089       params.push_back(ttrd->GetX1HalfLength(    1023       params.push_back(ttrd->GetX1HalfLength());
1090       params.push_back(ttrd->GetX2HalfLength(    1024       params.push_back(ttrd->GetX2HalfLength());
1091       params.push_back(ttrd->GetY1HalfLength(    1025       params.push_back(ttrd->GetY1HalfLength());
1092       params.push_back(ttrd->GetY2HalfLength(    1026       params.push_back(ttrd->GetY2HalfLength());
1093       params.push_back(ttrd->GetZHalfLength()    1027       params.push_back(ttrd->GetZHalfLength());
1094       params.push_back(ttrd->GetPhiTwist() /     1028       params.push_back(ttrd->GetPhiTwist() / deg);
1095     }                                            1029     }
1096   }                                              1030   }
1097   else if(solidType == "TWISTEDTUBS")            1031   else if(solidType == "TWISTEDTUBS")
1098   {                                              1032   {
1099     const G4TwistedTubs* ttub = dynamic_cast<    1033     const G4TwistedTubs* ttub = dynamic_cast<const G4TwistedTubs*>(so);
1100     if(ttub != nullptr)                          1034     if(ttub != nullptr)
1101     {                                            1035     {
1102       params.push_back(ttub->GetInnerRadius()    1036       params.push_back(ttub->GetInnerRadius());
1103       params.push_back(ttub->GetOuterRadius()    1037       params.push_back(ttub->GetOuterRadius());
1104       params.push_back(ttub->GetZHalfLength()    1038       params.push_back(ttub->GetZHalfLength());
1105       params.push_back(ttub->GetDPhi() / deg)    1039       params.push_back(ttub->GetDPhi() / deg);
1106       params.push_back(ttub->GetPhiTwist() /     1040       params.push_back(ttub->GetPhiTwist() / deg);
1107     }                                            1041     }
1108   }                                              1042   }
1109   else                                           1043   else
1110   {                                              1044   {
1111     const G4String& ErrMessage = "Solid type  << 1045     G4String ErrMessage = "Solid type not supported, sorry... " + solidType;
1112     G4Exception("G4tgbGeometryDumper::DumpSol << 1046     G4Exception("G4tgbGeometryDumpe::DumpSolidParams()", "NotImplemented",
1113                 FatalException, ErrMessage);     1047                 FatalException, ErrMessage);
1114   }                                              1048   }
1115                                                  1049 
1116   return params;                                 1050   return params;
1117 }                                                1051 }
1118                                                  1052 
1119 // ------------------------------------------    1053 // --------------------------------------------------------------------
1120 G4String G4tgbGeometryDumper::DumpRotationMat    1054 G4String G4tgbGeometryDumper::DumpRotationMatrix(G4RotationMatrix* rotm)
1121 {                                                1055 {
1122   if(rotm == nullptr)                            1056   if(rotm == nullptr)
1123   {                                              1057   {
1124     rotm = new G4RotationMatrix();               1058     rotm = new G4RotationMatrix();
1125   }                                              1059   }
1126                                                  1060 
1127   G4double de      = MatDeterminant(rotm);       1061   G4double de      = MatDeterminant(rotm);
1128   G4String rotName = LookForExistingRotation(    1062   G4String rotName = LookForExistingRotation(rotm);
1129   if(rotName != "")                              1063   if(rotName != "")
1130   {                                              1064   {
1131     return rotName;                              1065     return rotName;
1132   }                                              1066   }
1133                                                  1067 
1134   G4ThreeVector v(1., 1., 1.);                   1068   G4ThreeVector v(1., 1., 1.);
1135   if(de < -0.9)  // a reflection ....            1069   if(de < -0.9)  // a reflection ....
1136   {                                              1070   {
1137     (*theFile) << ":ROTM ";                      1071     (*theFile) << ":ROTM ";
1138     rotName = "RRM";                             1072     rotName = "RRM";
1139     rotName += G4UIcommand::ConvertToString(t    1073     rotName += G4UIcommand::ConvertToString(theRotationNumber++);
1140                                                  1074 
1141     (*theFile) << AddQuotes(rotName) << std::    1075     (*theFile) << AddQuotes(rotName) << std::setprecision(9) << " "
1142                << approxTo0(rotm->xx()) << "     1076                << approxTo0(rotm->xx()) << " " << approxTo0(rotm->yx()) << " "
1143                << approxTo0(rotm->zx()) << "     1077                << approxTo0(rotm->zx()) << " " << approxTo0(rotm->xy()) << " "
1144                << approxTo0(rotm->yy()) << "     1078                << approxTo0(rotm->yy()) << " " << approxTo0(rotm->zy()) << " "
1145                << approxTo0(rotm->xz()) << "     1079                << approxTo0(rotm->xz()) << " " << approxTo0(rotm->yz()) << " "
1146                << approxTo0(rotm->zz()) << G4    1080                << approxTo0(rotm->zz()) << G4endl;
1147   }                                              1081   }
1148   else if(de > 0.9)  // a rotation ....          1082   else if(de > 0.9)  // a rotation ....
1149   {                                              1083   {
1150     (*theFile) << ":ROTM ";                      1084     (*theFile) << ":ROTM ";
1151     rotName = "RM";                              1085     rotName = "RM";
1152     rotName += G4UIcommand::ConvertToString(t    1086     rotName += G4UIcommand::ConvertToString(theRotationNumber++);
1153                                                  1087 
1154     (*theFile) << AddQuotes(rotName) << " " <    1088     (*theFile) << AddQuotes(rotName) << " " << approxTo0(rotm->thetaX() / deg)
1155                << " " << approxTo0(rotm->phiX    1089                << " " << approxTo0(rotm->phiX() / deg) << " "
1156                << approxTo0(rotm->thetaY() /     1090                << approxTo0(rotm->thetaY() / deg) << " "
1157                << approxTo0(rotm->phiY() / de    1091                << approxTo0(rotm->phiY() / deg) << " "
1158                << approxTo0(rotm->thetaZ() /     1092                << approxTo0(rotm->thetaZ() / deg) << " "
1159                << approxTo0(rotm->phiZ() / de    1093                << approxTo0(rotm->phiZ() / deg) << G4endl;
1160   }                                              1094   }
1161                                                  1095 
1162   theRotMats[rotName] = rotm;                    1096   theRotMats[rotName] = rotm;
1163                                                  1097 
1164   return rotName;                                1098   return rotName;
1165 }                                                1099 }
1166                                                  1100 
1167 // ------------------------------------------    1101 // --------------------------------------------------------------------
1168 std::vector<G4VPhysicalVolume*>                  1102 std::vector<G4VPhysicalVolume*>
1169 G4tgbGeometryDumper::GetPVChildren(G4LogicalV    1103 G4tgbGeometryDumper::GetPVChildren(G4LogicalVolume* lv)
1170 {                                                1104 {
1171   G4PhysicalVolumeStore* pvstore = G4Physical    1105   G4PhysicalVolumeStore* pvstore = G4PhysicalVolumeStore::GetInstance();
1172   std::vector<G4VPhysicalVolume*> children;      1106   std::vector<G4VPhysicalVolume*> children;
1173   for(auto ite = pvstore->cbegin(); ite != pv    1107   for(auto ite = pvstore->cbegin(); ite != pvstore->cend(); ++ite)
1174   {                                              1108   {
1175     if((*ite)->GetMotherLogical() == lv)         1109     if((*ite)->GetMotherLogical() == lv)
1176     {                                            1110     {
1177       children.push_back(*ite);                  1111       children.push_back(*ite);
1178 #ifdef G4VERBOSE                                 1112 #ifdef G4VERBOSE
1179       if(G4tgrMessenger::GetVerboseLevel() >=    1113       if(G4tgrMessenger::GetVerboseLevel() >= 1)
1180       {                                          1114       {
1181         G4cout << " G4tgbGeometryDumper::GetP    1115         G4cout << " G4tgbGeometryDumper::GetPVChildren() - adding children: "
1182                << (*ite)->GetName() << " of "    1116                << (*ite)->GetName() << " of " << lv->GetName() << G4endl;
1183       }                                          1117       }
1184 #endif                                           1118 #endif
1185     }                                            1119     }
1186   }                                              1120   }
1187                                                  1121 
1188   return children;                               1122   return children;
1189 }                                                1123 }
1190                                                  1124 
1191 // ------------------------------------------    1125 // --------------------------------------------------------------------
1192 G4String G4tgbGeometryDumper::GetTGSolidType(    1126 G4String G4tgbGeometryDumper::GetTGSolidType(const G4String& solidType)
1193 {                                                1127 {
1194   G4String newsolidType = solidType.substr(2,    1128   G4String newsolidType = solidType.substr(2, solidType.length());
1195   for(G4int ii = 0; ii < (G4int)newsolidType. << 1129   for(std::size_t ii = 0; ii < newsolidType.length(); ++ii)
1196   {                                              1130   {
1197     newsolidType[ii] = (char)std::toupper(new << 1131     newsolidType[ii] = toupper(newsolidType[ii]);
1198   }                                              1132   }
1199   return newsolidType;                           1133   return newsolidType;
1200 }                                                1134 }
1201                                                  1135 
1202 // ------------------------------------------    1136 // --------------------------------------------------------------------
1203 G4double G4tgbGeometryDumper::MatDeterminant(    1137 G4double G4tgbGeometryDumper::MatDeterminant(G4RotationMatrix* ro)
1204 {                                                1138 {
1205   G4Rep3x3 r = ro->rep3x3();                     1139   G4Rep3x3 r = ro->rep3x3();
1206   return r.xx_ * (r.yy_ * r.zz_ - r.zy_ * r.y    1140   return r.xx_ * (r.yy_ * r.zz_ - r.zy_ * r.yz_) -
1207          r.yx_ * (r.xy_ * r.zz_ - r.zy_ * r.x    1141          r.yx_ * (r.xy_ * r.zz_ - r.zy_ * r.xz_) +
1208          r.zx_ * (r.xy_ * r.yz_ - r.yy_ * r.x    1142          r.zx_ * (r.xy_ * r.yz_ - r.yy_ * r.xz_);
1209 }                                                1143 }
1210                                                  1144 
1211 // ------------------------------------------    1145 // --------------------------------------------------------------------
1212 G4double G4tgbGeometryDumper::approxTo0(G4dou    1146 G4double G4tgbGeometryDumper::approxTo0(G4double val)
1213 {                                                1147 {
1214   G4double precision =                           1148   G4double precision =
1215     G4GeometryTolerance::GetInstance()->GetSu    1149     G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
1216                                                  1150 
1217   if(std::fabs(val) < precision)                 1151   if(std::fabs(val) < precision)
1218   {                                              1152   {
1219     val = 0.0;                                   1153     val = 0.0;
1220   }                                              1154   }
1221   return val;                                    1155   return val;
1222 }                                                1156 }
1223                                                  1157 
1224 // ------------------------------------------    1158 // --------------------------------------------------------------------
1225 G4String G4tgbGeometryDumper::AddQuotes(const    1159 G4String G4tgbGeometryDumper::AddQuotes(const G4String& str)
1226 {                                                1160 {
1227   //--- look if there is a separating blank      1161   //--- look if there is a separating blank
1228                                                  1162 
1229   G4bool bBlank = FALSE;                         1163   G4bool bBlank = FALSE;
1230   std::size_t siz = str.length();                1164   std::size_t siz = str.length();
1231   for(std::size_t ii = 0; ii < siz; ++ii)        1165   for(std::size_t ii = 0; ii < siz; ++ii)
1232   {                                              1166   {
1233     if(str.substr(ii, 1) == " ")                 1167     if(str.substr(ii, 1) == " ")
1234     {                                            1168     {
1235       bBlank = TRUE;                             1169       bBlank = TRUE;
1236       break;                                     1170       break;
1237     }                                            1171     }
1238   }                                              1172   }
1239   G4String str2 = str;                           1173   G4String str2 = str;
1240   if(bBlank)                                     1174   if(bBlank)
1241   {                                              1175   {
1242     str2 = G4String("\"") + str2 + G4String("    1176     str2 = G4String("\"") + str2 + G4String("\"");
1243   }                                              1177   }
1244   return str2;                                   1178   return str2;
1245 }                                                1179 }
1246                                                  1180 
1247 // ------------------------------------------    1181 // --------------------------------------------------------------------
1248 G4String G4tgbGeometryDumper::SupressRefl(G4S    1182 G4String G4tgbGeometryDumper::SupressRefl(G4String name)
1249 {                                                1183 {
1250   std::size_t irefl = name.rfind("_refl");    << 1184   G4int irefl = name.rfind("_refl");
1251   if(irefl != G4String::npos)                 << 1185   if(irefl != -1)
1252   {                                              1186   {
1253     name = name.substr(0, irefl);                1187     name = name.substr(0, irefl);
1254   }                                              1188   }
1255   return name;                                   1189   return name;
1256 }                                                1190 }
1257                                                  1191 
1258 // ------------------------------------------    1192 // --------------------------------------------------------------------
1259 G4String G4tgbGeometryDumper::SubstituteRefl(    1193 G4String G4tgbGeometryDumper::SubstituteRefl(G4String name)
1260 {                                                1194 {
1261   std::size_t irefl = name.rfind("_refl");    << 1195   G4int irefl = name.rfind("_refl");
1262   if(irefl != G4String::npos)                 << 1196   if(irefl != -1)
1263   {                                              1197   {
1264     name = name.substr(0, irefl) + "_REFL";      1198     name = name.substr(0, irefl) + "_REFL";
1265   }                                              1199   }
1266   return name;                                   1200   return name;
1267 }                                                1201 }
1268                                                  1202 
1269 // ------------------------------------------    1203 // --------------------------------------------------------------------
1270 G4String G4tgbGeometryDumper::GetIsotopeName(    1204 G4String G4tgbGeometryDumper::GetIsotopeName(G4Isotope* isot)
1271 {                                                1205 {
1272   G4String isotName = isot->GetName();           1206   G4String isotName = isot->GetName();
1273   // first look if this is isotope is already    1207   // first look if this is isotope is already dumped,
1274   // with original isotope name or new one       1208   // with original isotope name or new one
1275   //                                             1209   //
1276   std::map<G4String, G4Isotope*>::const_itera    1210   std::map<G4String, G4Isotope*>::const_iterator ite;
1277   for(ite = theIsotopes.cbegin(); ite != theI    1211   for(ite = theIsotopes.cbegin(); ite != theIsotopes.cend(); ++ite)
1278   {                                              1212   {
1279     if(isot == (*ite).second)                    1213     if(isot == (*ite).second)
1280     {                                            1214     {
1281       return (*ite).first;                       1215       return (*ite).first;
1282     }                                            1216     }
1283   }                                              1217   }
1284                                                  1218 
1285   // Now look if there is another isotope dum    1219   // Now look if there is another isotope dumped with same name,
1286   // and if found add _N to the name             1220   // and if found add _N to the name
1287   //                                             1221   //
1288   ite = theIsotopes.find(isotName);              1222   ite = theIsotopes.find(isotName);
1289   if(ite != theIsotopes.cend())  // Isotope f    1223   if(ite != theIsotopes.cend())  // Isotope found with same name
1290   {                                              1224   {
1291     G4Isotope* isotold = (*ite).second;          1225     G4Isotope* isotold = (*ite).second;
1292     if(isot != isotold)  // new isotope it is    1226     if(isot != isotold)  // new isotope it is not the really
1293     {                    // the same one as i    1227     {                    // the same one as isotope found
1294       if(!Same2G4Isotopes(isot, isotold))        1228       if(!Same2G4Isotopes(isot, isotold))
1295       {                // if the two have sam    1229       {                // if the two have same data, use the old one
1296         G4int ii = 2;  // G4Nist does names i    1230         G4int ii = 2;  // G4Nist does names isotopes of same element
1297                        // with same name         1231                        // with same name
1298         for(;; ++ii)                             1232         for(;; ++ii)
1299         {                                        1233         {
1300           const G4String& newIsotName =       << 1234           G4String newIsotName =
1301             isotName + "_" + G4UIcommand::Con    1235             isotName + "_" + G4UIcommand::ConvertToString(ii);
1302           std::map<G4String, G4Isotope*>::con    1236           std::map<G4String, G4Isotope*>::const_iterator ite2 =
1303             theIsotopes.find(newIsotName);       1237             theIsotopes.find(newIsotName);
1304           if(ite2 == theIsotopes.cend())         1238           if(ite2 == theIsotopes.cend())
1305           {                                      1239           {
1306             isotName = newIsotName;              1240             isotName = newIsotName;
1307             break;                               1241             break;
1308           }                                      1242           }
1309           else                                   1243           else
1310           {                                      1244           {
1311             if(Same2G4Isotopes(isot, (*ite2).    1245             if(Same2G4Isotopes(isot, (*ite2).second))
1312             {                                    1246             {
1313               isotName = newIsotName;            1247               isotName = newIsotName;
1314               break;                             1248               break;
1315             }                                    1249             }
1316           }                                      1250           }
1317         }                                        1251         }
1318       }                                          1252       }
1319     }                                            1253     }
1320   }                                              1254   }
1321   return isotName;                               1255   return isotName;
1322 }                                                1256 }
1323                                                  1257 
1324 // ------------------------------------------    1258 // --------------------------------------------------------------------
1325 template <class TYP>                             1259 template <class TYP>
1326 G4String G4tgbGeometryDumper::GetObjectName(     1260 G4String G4tgbGeometryDumper::GetObjectName(
1327   TYP* obj, std::map<G4String, TYP*> objectsD    1261   TYP* obj, std::map<G4String, TYP*> objectsDumped)
1328 {                                                1262 {
1329   G4String objName = obj->GetName();             1263   G4String objName = obj->GetName();
1330                                                  1264 
1331   // first look if this is objecy is already     1265   // first look if this is objecy is already dumped,
1332   // with original object name or new one        1266   // with original object name or new one
1333   //                                             1267   //
1334   typename std::map<G4String, TYP*>::const_it    1268   typename std::map<G4String, TYP*>::const_iterator ite;
1335   for(ite = objectsDumped.cbegin(); ite != ob    1269   for(ite = objectsDumped.cbegin(); ite != objectsDumped.cend(); ++ite)
1336   {                                              1270   {
1337     if(obj == (*ite).second)                     1271     if(obj == (*ite).second)
1338     {                                            1272     {
1339       return (*ite).first;                       1273       return (*ite).first;
1340     }                                            1274     }
1341   }                                              1275   }
1342                                                  1276 
1343   // Now look if there is another object dump    1277   // Now look if there is another object dumped with same name,
1344   // and if found add _N to the name             1278   // and if found add _N to the name
1345   //                                             1279   //
1346   ite = objectsDumped.find(objName);             1280   ite = objectsDumped.find(objName);
1347                                                  1281 
1348   if(ite != objectsDumped.cend())  // Object     1282   if(ite != objectsDumped.cend())  // Object found with same name
1349   {                                              1283   {
1350     TYP* objold = (*ite).second;                 1284     TYP* objold = (*ite).second;
1351     if(obj != objold)  // new object it is no    1285     if(obj != objold)  // new object it is not the really
1352     {                  // the same one as obj    1286     {                  // the same one as object found
1353       G4int ii = 2;                              1287       G4int ii = 2;
1354       for(;; ++ii)                               1288       for(;; ++ii)
1355       {                                          1289       {
1356         const G4String& newObjName = objName  << 1290         G4String newObjName = objName + "_" + G4UIcommand::ConvertToString(ii);
1357         typename std::map<G4String, TYP*>::co    1291         typename std::map<G4String, TYP*>::const_iterator ite2 =
1358           objectsDumped.find(newObjName);        1292           objectsDumped.find(newObjName);
1359         if(ite2 == objectsDumped.cend())         1293         if(ite2 == objectsDumped.cend())
1360         {                                        1294         {
1361           objName = newObjName;                  1295           objName = newObjName;
1362           break;                                 1296           break;
1363         }                                        1297         }
1364       }                                          1298       }
1365     }                                            1299     }
1366   }                                              1300   }
1367   return objName;                                1301   return objName;
1368 }                                                1302 }
1369                                                  1303 
1370 // ------------------------------------------    1304 // --------------------------------------------------------------------
1371 G4bool G4tgbGeometryDumper::CheckIfLogVolExis    1305 G4bool G4tgbGeometryDumper::CheckIfLogVolExists(const G4String& name,
1372                                                  1306                                                 G4LogicalVolume* pt)
1373 {                                                1307 {
1374   if(theLogVols.find(name) != theLogVols.cend    1308   if(theLogVols.find(name) != theLogVols.cend())
1375   {                                              1309   {
1376     G4LogicalVolume* lvnew = (*(theLogVols.fi    1310     G4LogicalVolume* lvnew = (*(theLogVols.find(name))).second;
1377     if(lvnew != pt)                              1311     if(lvnew != pt)
1378     {                                            1312     {
1379       /*                                         1313       /*
1380       //---- Reflected volumes are repeated      1314       //---- Reflected volumes are repeated
1381                                                  1315 
1382       G4ReflectionFactory* reffact = G4Reflec    1316       G4ReflectionFactory* reffact = G4ReflectionFactory::Instance();
1383       if( !reffact->IsReflected( pt ) && !ref    1317       if( !reffact->IsReflected( pt ) && !reffact->IsReflected( lvnew ) )
1384       {                                          1318       {
1385         G4String ErrMessage = "LogVol found b    1319         G4String ErrMessage = "LogVol found but not same as before: " + name;
1386         G4Exception("G4tgbGeometryDumper::Che    1320         G4Exception("G4tgbGeometryDumper::CheckIfLogVolExists()",
1387                     "InvalidSetup", FatalExce    1321                     "InvalidSetup", FatalException, ErrMessage);
1388       }                                          1322       }
1389       */                                         1323       */
1390     }                                            1324     }
1391     return true;                                 1325     return true;
1392   }                                              1326   }
1393   else                                           1327   else
1394   {                                              1328   {
1395     return false;                                1329     return false;
1396   }                                              1330   }
1397 }                                                1331 }
1398                                                  1332 
1399 // ------------------------------------------    1333 // --------------------------------------------------------------------
1400 G4bool G4tgbGeometryDumper::CheckIfPhysVolExi    1334 G4bool G4tgbGeometryDumper::CheckIfPhysVolExists(const G4String& name,
1401                                                  1335                                                  G4VPhysicalVolume* pt)
1402 {                                                1336 {
1403 #ifdef G4VERBOSE                                 1337 #ifdef G4VERBOSE
1404   if(G4tgrMessenger::GetVerboseLevel() >= 1)     1338   if(G4tgrMessenger::GetVerboseLevel() >= 1)
1405   {                                              1339   {
1406     G4cout << " G4tgbGeometryDumper::CheckIfP    1340     G4cout << " G4tgbGeometryDumper::CheckIfPhysVolExists() - " << name
1407            << G4endl;                            1341            << G4endl;
1408   }                                              1342   }
1409 #endif                                           1343 #endif
1410   if(thePhysVols.find(name) != thePhysVols.ce    1344   if(thePhysVols.find(name) != thePhysVols.cend())
1411   {                                              1345   {
1412     if((*(thePhysVols.find(name))).second !=     1346     if((*(thePhysVols.find(name))).second != pt)
1413     {                                            1347     {
1414       // G4String ErrMessage = "Placement fou    1348       // G4String ErrMessage = "Placement found but not same as before: "
1415       //                     + name;             1349       //                     + name;
1416       // G4Exception("G4tgbGeometryDumper::Ch    1350       // G4Exception("G4tgbGeometryDumper::CheckIfPhysVolExists()",
1417       //             "InvalidSetup", FatalExc    1351       //             "InvalidSetup", FatalException, ErrMessage);
1418       G4cerr << " G4tgbGeometryDumper::CheckI    1352       G4cerr << " G4tgbGeometryDumper::CheckIfPhysVolExists () -"
1419              << " Placement found but not sam    1353              << " Placement found but not same as before : " << name << G4endl;
1420     }                                            1354     }
1421     return true;                                 1355     return true;
1422   }                                              1356   }
1423   else                                           1357   else
1424   {                                              1358   {
1425     return false;                                1359     return false;
1426   }                                              1360   }
1427 }                                                1361 }
1428                                                  1362 
1429 // ------------------------------------------    1363 // --------------------------------------------------------------------
1430 G4String                                         1364 G4String
1431 G4tgbGeometryDumper::LookForExistingRotation(    1365 G4tgbGeometryDumper::LookForExistingRotation(const G4RotationMatrix* rotm)
1432 {                                                1366 {
1433   G4String rmName = "";                          1367   G4String rmName = "";
1434                                                  1368 
1435   for(auto ite = theRotMats.cbegin(); ite !=     1369   for(auto ite = theRotMats.cbegin(); ite != theRotMats.cend(); ++ite)
1436   {                                              1370   {
1437     if((*ite).second->isNear(*rotm))             1371     if((*ite).second->isNear(*rotm))
1438     {                                            1372     {
1439       rmName = (*ite).first;                     1373       rmName = (*ite).first;
1440       break;                                     1374       break;
1441     }                                            1375     }
1442   }                                              1376   }
1443   return rmName;                                 1377   return rmName;
1444 }                                                1378 }
1445                                                  1379 
1446 // ------------------------------------------    1380 // --------------------------------------------------------------------
1447 G4bool G4tgbGeometryDumper::Same2G4Isotopes(G    1381 G4bool G4tgbGeometryDumper::Same2G4Isotopes(G4Isotope* isot1, G4Isotope* isot2)
1448 {                                                1382 {
1449   if((isot1->GetZ() != isot2->GetZ()) || (iso    1383   if((isot1->GetZ() != isot2->GetZ()) || (isot1->GetN() != isot2->GetN()) ||
1450      (isot1->GetA() != isot2->GetA()))           1384      (isot1->GetA() != isot2->GetA()))
1451   {                                              1385   {
1452     return false;                                1386     return false;
1453   }                                              1387   }
1454   else                                           1388   else
1455   {                                              1389   {
1456     return true;                                 1390     return true;
1457   }                                              1391   }
1458 }                                                1392 }
1459                                                  1393 
1460 // ------------------------------------------    1394 // --------------------------------------------------------------------
1461 const G4String& G4tgbGeometryDumper::FindSoli    1395 const G4String& G4tgbGeometryDumper::FindSolidName(G4VSolid* solid)
1462 {                                                1396 {
1463   std::map<G4String, G4VSolid*>::const_iterat    1397   std::map<G4String, G4VSolid*>::const_iterator ite;
1464   for(ite = theSolids.cbegin(); ite != theSol    1398   for(ite = theSolids.cbegin(); ite != theSolids.cend(); ++ite)
1465   {                                              1399   {
1466     if(solid == (*ite).second)                   1400     if(solid == (*ite).second)
1467     {                                            1401     {
1468       return (*ite).first;                       1402       return (*ite).first;
1469     }                                            1403     }
1470   }                                              1404   }
1471                                                  1405 
1472   if(ite == theSolids.cend())                    1406   if(ite == theSolids.cend())
1473   {                                              1407   {
1474     G4Exception("G4tgbGeometryDumper::FindSol    1408     G4Exception("G4tgbGeometryDumper::FindSolidName()", "ReadError",
1475                 FatalException, "Programming     1409                 FatalException, "Programming error.");
1476   }                                              1410   }
1477   return (*ite).first;                           1411   return (*ite).first;
1478 }                                                1412 }
1479                                                  1413