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 9.6.p2)


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