Geant4 Cross Reference

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


  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 // G4tgbVolumeMgr implementation                   26 // G4tgbVolumeMgr implementation
 27 //                                                 27 //
 28 // Author: P.Arce, CIEMAT (November 2007)          28 // Author: P.Arce, CIEMAT (November 2007)
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4tgbVolumeMgr.hh"                       31 #include "G4tgbVolumeMgr.hh"
 32                                                    32 
 33 #include "G4SystemOfUnits.hh"                      33 #include "G4SystemOfUnits.hh"
 34 #include "G4tgbVolume.hh"                          34 #include "G4tgbVolume.hh"
 35 #include "G4tgbMaterialMgr.hh"                     35 #include "G4tgbMaterialMgr.hh"
 36 #include "G4tgbRotationMatrixMgr.hh"               36 #include "G4tgbRotationMatrixMgr.hh"
 37                                                    37 
 38 #include "G4tgrVolumeMgr.hh"                       38 #include "G4tgrVolumeMgr.hh"
 39 #include "G4tgrFileReader.hh"                      39 #include "G4tgrFileReader.hh"
 40 #include "G4tgrUtils.hh"                           40 #include "G4tgrUtils.hh"
 41                                                    41 
 42 #include "G4VSolid.hh"                             42 #include "G4VSolid.hh"
 43 #include "G4PhysicalVolumeStore.hh"                43 #include "G4PhysicalVolumeStore.hh"
 44 #include "G4ReflectionFactory.hh"                  44 #include "G4ReflectionFactory.hh"
 45 #include "G4tgrMessenger.hh"                       45 #include "G4tgrMessenger.hh"
 46 #include "G4tgbDetectorBuilder.hh"                 46 #include "G4tgbDetectorBuilder.hh"
 47                                                    47 
 48 G4ThreadLocal G4tgbVolumeMgr* G4tgbVolumeMgr::     48 G4ThreadLocal G4tgbVolumeMgr* G4tgbVolumeMgr::theInstance = nullptr;
 49                                                    49 
 50 // -------------------------------------------     50 // --------------------------------------------------------------------
 51 G4tgbVolumeMgr::G4tgbVolumeMgr()                   51 G4tgbVolumeMgr::G4tgbVolumeMgr()
 52 {                                                  52 {
 53   G4ReflectionFactory::Instance()->SetScalePre     53   G4ReflectionFactory::Instance()->SetScalePrecision(1.E-6 * mm);
 54   // NOTE: problems building matrices with not     54   // NOTE: problems building matrices with not enough figures,
 55   // like  :ROTM RR30 0.866025 0.5 0. -0.5 0.8     55   // like  :ROTM RR30 0.866025 0.5 0. -0.5 0.866025 0. 0. 0 -1
 56   theDetectorBuilder = new G4tgbDetectorBuilde     56   theDetectorBuilder = new G4tgbDetectorBuilder();
 57 }                                                  57 }
 58                                                    58 
 59 // -------------------------------------------     59 // --------------------------------------------------------------------
 60 G4tgbVolumeMgr::~G4tgbVolumeMgr()                  60 G4tgbVolumeMgr::~G4tgbVolumeMgr()
 61 {                                                  61 {
 62   delete theDetectorBuilder;                       62   delete theDetectorBuilder;
 63   delete theInstance;                              63   delete theInstance;
 64 }                                                  64 }
 65                                                    65 
 66 // -------------------------------------------     66 // --------------------------------------------------------------------
 67 G4tgbVolumeMgr* G4tgbVolumeMgr::GetInstance()      67 G4tgbVolumeMgr* G4tgbVolumeMgr::GetInstance()
 68 {                                                  68 {
 69   if(theInstance == nullptr)                       69   if(theInstance == nullptr)
 70   {                                                70   {
 71     theInstance = new G4tgbVolumeMgr();            71     theInstance = new G4tgbVolumeMgr();
 72   }                                                72   }
 73   return theInstance;                              73   return theInstance;
 74 }                                                  74 }
 75                                                    75 
 76 // -------------------------------------------     76 // --------------------------------------------------------------------
 77 void G4tgbVolumeMgr::AddTextFile(const G4Strin     77 void G4tgbVolumeMgr::AddTextFile(const G4String& fname)
 78 {                                                  78 {
 79   G4tgrFileReader::GetInstance()->AddTextFile(     79   G4tgrFileReader::GetInstance()->AddTextFile(fname);
 80 }                                                  80 }
 81                                                    81 
 82 // -------------------------------------------     82 // --------------------------------------------------------------------
 83 G4VPhysicalVolume* G4tgbVolumeMgr::ReadAndCons     83 G4VPhysicalVolume* G4tgbVolumeMgr::ReadAndConstructDetector()
 84 {                                                  84 {
 85   const G4tgrVolume* tgrVoltop = theDetectorBu     85   const G4tgrVolume* tgrVoltop = theDetectorBuilder->ReadDetector();
 86   return theDetectorBuilder->ConstructDetector     86   return theDetectorBuilder->ConstructDetector(tgrVoltop);
 87 }                                                  87 }
 88                                                    88 
 89 // -------------------------------------------     89 // --------------------------------------------------------------------
 90 void G4tgbVolumeMgr::RegisterMe(const G4tgbVol     90 void G4tgbVolumeMgr::RegisterMe(const G4tgbVolume* vol)
 91 {                                                  91 {
 92   theVolumeList.insert(                            92   theVolumeList.insert(
 93     G4mssvol::value_type(vol->GetName(), const     93     G4mssvol::value_type(vol->GetName(), const_cast<G4tgbVolume*>(vol)));
 94 }                                                  94 }
 95                                                    95 
 96 // -------------------------------------------     96 // --------------------------------------------------------------------
 97 void G4tgbVolumeMgr::RegisterMe(const G4VSolid     97 void G4tgbVolumeMgr::RegisterMe(const G4VSolid* solid)
 98 {                                                  98 {
 99   theSolids.insert(                                99   theSolids.insert(
100     G4mmssol::value_type(solid->GetName(), con    100     G4mmssol::value_type(solid->GetName(), const_cast<G4VSolid*>(solid)));
101 }                                                 101 }
102                                                   102 
103 // -------------------------------------------    103 // --------------------------------------------------------------------
104 void G4tgbVolumeMgr::RegisterMe(const G4Logica    104 void G4tgbVolumeMgr::RegisterMe(const G4LogicalVolume* lv)
105 {                                                 105 {
106   theLVs.insert(                                  106   theLVs.insert(
107     G4mmslv::value_type(lv->GetName(), const_c    107     G4mmslv::value_type(lv->GetName(), const_cast<G4LogicalVolume*>(lv)));
108                                                   108 
109 #ifdef G4VERBOSE                                  109 #ifdef G4VERBOSE
110   if(G4tgrMessenger::GetVerboseLevel() >= 2)      110   if(G4tgrMessenger::GetVerboseLevel() >= 2)
111   {                                               111   {
112     G4cout << " G4tgbVolumeMgr::RegisterMe() -    112     G4cout << " G4tgbVolumeMgr::RegisterMe() - Logical volume registered: "
113            << lv->GetName() << G4endl;            113            << lv->GetName() << G4endl;
114   }                                               114   }
115 #endif                                            115 #endif
116 }                                                 116 }
117                                                   117 
118 // -------------------------------------------    118 // --------------------------------------------------------------------
119 void G4tgbVolumeMgr::RegisterMe(const G4VPhysi    119 void G4tgbVolumeMgr::RegisterMe(const G4VPhysicalVolume* pv)
120 {                                                 120 {
121   thePVs.insert(                                  121   thePVs.insert(
122     G4mmspv::value_type(pv->GetName(), const_c    122     G4mmspv::value_type(pv->GetName(), const_cast<G4VPhysicalVolume*>(pv)));
123 }                                                 123 }
124                                                   124 
125 // -------------------------------------------    125 // --------------------------------------------------------------------
126 void G4tgbVolumeMgr::RegisterChildParentLVs(co    126 void G4tgbVolumeMgr::RegisterChildParentLVs(const G4LogicalVolume* logvol,
127                                             co    127                                             const G4LogicalVolume* parentLV)
128 {                                                 128 {
129   theLVInvTree[const_cast<G4LogicalVolume*>(lo    129   theLVInvTree[const_cast<G4LogicalVolume*>(logvol)] =
130     const_cast<G4LogicalVolume*>(parentLV);       130     const_cast<G4LogicalVolume*>(parentLV);
131   theLVTree[const_cast<G4LogicalVolume*>(paren    131   theLVTree[const_cast<G4LogicalVolume*>(parentLV)] =
132     const_cast<G4LogicalVolume*>(logvol);         132     const_cast<G4LogicalVolume*>(logvol);
133 }                                                 133 }
134                                                   134 
135 // -------------------------------------------    135 // --------------------------------------------------------------------
136 void G4tgbVolumeMgr::CopyVolumes()                136 void G4tgbVolumeMgr::CopyVolumes()
137 {                                                 137 {
138   //--------- Loop G4tgbVolume's and create a     138   //--------- Loop G4tgbVolume's and create a G4tgbVolume for each DetUnit
139   G4mapsvol vollist = G4tgrVolumeMgr::GetInsta    139   G4mapsvol vollist = G4tgrVolumeMgr::GetInstance()->GetVolumeMap();
140   for(auto cite = vollist.cbegin(); cite != vo    140   for(auto cite = vollist.cbegin(); cite != vollist.cend(); ++cite)
141   {                                               141   {
142     G4tgrVolume* tgrvol = const_cast<G4tgrVolu    142     G4tgrVolume* tgrvol = const_cast<G4tgrVolume*>((*cite).second);
143     G4tgbVolume* svol   = new G4tgbVolume(tgrv    143     G4tgbVolume* svol   = new G4tgbVolume(tgrvol);
144     RegisterMe(svol);                             144     RegisterMe(svol);
145   }                                               145   }
146 }                                                 146 }
147                                                   147 
148 // -------------------------------------------    148 // --------------------------------------------------------------------
149 G4tgbVolume* G4tgbVolumeMgr::FindVolume(const     149 G4tgbVolume* G4tgbVolumeMgr::FindVolume(const G4String& volname)
150 {                                                 150 {
151   G4mssvol::const_iterator cite = theVolumeLis    151   G4mssvol::const_iterator cite = theVolumeList.find(volname);
152   if(cite == theVolumeList.cend())                152   if(cite == theVolumeList.cend())
153   {                                               153   {
154     G4String ErrMessage = "G4tgbVolume not fou    154     G4String ErrMessage = "G4tgbVolume not found: " + volname + " !";
155     G4Exception("G4tgbVolumeMgr::FindVolume()"    155     G4Exception("G4tgbVolumeMgr::FindVolume()", "InvalidSetup", FatalException,
156                 ErrMessage);                      156                 ErrMessage);
157     return nullptr;                               157     return nullptr;
158   }                                               158   }
159   else                                            159   else
160   {                                               160   {
161     return (*cite).second;                        161     return (*cite).second;
162   }                                               162   }
163 }                                                 163 }
164                                                   164 
165 // -------------------------------------------    165 // --------------------------------------------------------------------
166 G4VSolid* G4tgbVolumeMgr::FindG4Solid(const G4    166 G4VSolid* G4tgbVolumeMgr::FindG4Solid(const G4String& name)
167 {                                                 167 {
168 #ifdef G4VERBOSE                                  168 #ifdef G4VERBOSE
169   if(G4tgrMessenger::GetVerboseLevel() >= 2)      169   if(G4tgrMessenger::GetVerboseLevel() >= 2)
170   {                                               170   {
171     G4cout << " G4tgbVolumeMgr::FindG4Solid()     171     G4cout << " G4tgbVolumeMgr::FindG4Solid() - " << name << G4endl;
172   }                                               172   }
173 #endif                                            173 #endif
174                                                   174 
175   G4VSolid* oldSolid = nullptr;                   175   G4VSolid* oldSolid = nullptr;
176   std::pair<G4mmssol::iterator, G4mmssol::iter    176   std::pair<G4mmssol::iterator, G4mmssol::iterator> mmssdi;
177   mmssdi = theSolids.equal_range(name);           177   mmssdi = theSolids.equal_range(name);
178                                                   178 
179   if(mmssdi.first != mmssdi.second)               179   if(mmssdi.first != mmssdi.second)
180   {  // check there is a solid found              180   {  // check there is a solid found
181     G4mmssol::const_iterator mmsscite = mmssdi    181     G4mmssol::const_iterator mmsscite = mmssdi.first;
182                                                   182 
183 #ifdef G4VERBOSE                                  183 #ifdef G4VERBOSE
184     if(G4tgrMessenger::GetVerboseLevel() >= 2)    184     if(G4tgrMessenger::GetVerboseLevel() >= 2)
185     {                                             185     {
186       G4cout << " G4tgbVolumeMgr::FindG4Solid(    186       G4cout << " G4tgbVolumeMgr::FindG4Solid() - Solid finding " << name
187              << G4endl;                           187              << G4endl;
188     }                                             188     }
189 #endif                                            189 #endif
190     /*                                            190     /*
191        G4VSolid overwrites the operator== comp    191        G4VSolid overwrites the operator== comparing the addresses
192        => this cannot be used !!                  192        => this cannot be used !!
193        Then just compare solids by name =>> PO    193        Then just compare solids by name =>> POSP tag cannot be used
194        for the moment ...                         194        for the moment ...
195          if( solid == *( (*mmsscite).second )     195          if( solid == *( (*mmsscite).second ) )
196          {                                        196          {
197            oldSolid = (*mmsscite).second;         197            oldSolid = (*mmsscite).second;
198            break;                                 198            break;
199          }                                        199          }
200        until we write operator== for each soli    200        until we write operator== for each solid type, we take a solid
201        with the same name (therefore we will n    201        with the same name (therefore we will not allow two solids with
202        equal name and different parameters (PO    202        equal name and different parameters (POSP) )
203     */                                            203     */
204     oldSolid = (*mmsscite).second;                204     oldSolid = (*mmsscite).second;
205 #ifdef G4VERBOSE                                  205 #ifdef G4VERBOSE
206     if(G4tgrMessenger::GetVerboseLevel() >= 1)    206     if(G4tgrMessenger::GetVerboseLevel() >= 1)
207     {                                             207     {
208       G4cout << " G4tgbVolumeMgr::FindG4Solid(    208       G4cout << " G4tgbVolumeMgr::FindG4Solid() - Solid already found " << name
209              << G4endl;                           209              << G4endl;
210     }                                             210     }
211 #endif                                            211 #endif
212   }                                               212   }
213                                                   213 
214 #ifdef G4VERBOSE                                  214 #ifdef G4VERBOSE
215   if(G4tgrMessenger::GetVerboseLevel() >= 2)      215   if(G4tgrMessenger::GetVerboseLevel() >= 2)
216   {                                               216   {
217     G4cout << " G4tgbVolumeMgr::FindG4Solid()     217     G4cout << " G4tgbVolumeMgr::FindG4Solid() - Old solid: " << oldSolid
218            << G4endl;                             218            << G4endl;
219   }                                               219   }
220 #endif                                            220 #endif
221                                                   221 
222   return oldSolid;                                222   return oldSolid;
223 }                                                 223 }
224                                                   224 
225 // -------------------------------------------    225 // --------------------------------------------------------------------
226 G4LogicalVolume* G4tgbVolumeMgr::FindG4LogVol(    226 G4LogicalVolume* G4tgbVolumeMgr::FindG4LogVol(const G4String& name,
227                                                   227                                               const G4bool exists)
228 {                                                 228 {
229   G4mmslv::const_iterator mscite = theLVs.find    229   G4mmslv::const_iterator mscite = theLVs.find(name);
230   if(mscite == theLVs.cend())                     230   if(mscite == theLVs.cend())
231   {                                               231   {
232     if(exists)                                    232     if(exists)
233     {                                             233     {
234       G4String ErrMessage = "Logical volume na    234       G4String ErrMessage = "Logical volume name " + name + " not found !";
235       G4Exception("G4tgbVolumeMgr::FindG4LogVo    235       G4Exception("G4tgbVolumeMgr::FindG4LogVol()", "InvalidSetup",
236                   FatalException, ErrMessage);    236                   FatalException, ErrMessage);
237     }                                             237     }
238     return nullptr;                               238     return nullptr;
239   }                                               239   }
240   else                                            240   else
241   {                                               241   {
242     return (*mscite).second;                      242     return (*mscite).second;
243   }                                               243   }
244 }                                                 244 }
245                                                   245 
246 // -------------------------------------------    246 // --------------------------------------------------------------------
247 G4VPhysicalVolume* G4tgbVolumeMgr::FindG4PhysV    247 G4VPhysicalVolume* G4tgbVolumeMgr::FindG4PhysVol(const G4String& name,
248                                                   248                                                  const G4bool exists)
249 {                                                 249 {
250   G4mmspv::const_iterator mscite = thePVs.find    250   G4mmspv::const_iterator mscite = thePVs.find(name);
251   if(mscite == thePVs.cend())                     251   if(mscite == thePVs.cend())
252   {                                               252   {
253     if(exists)                                    253     if(exists)
254     {                                             254     {
255       G4String ErrMessage = "Physical volume n    255       G4String ErrMessage = "Physical volume name " + name + " not found !";
256       G4Exception("G4tgbVolumeMgr::FindG4PhysV    256       G4Exception("G4tgbVolumeMgr::FindG4PhysVol()", "InvalidSetup",
257                   FatalException, ErrMessage);    257                   FatalException, ErrMessage);
258     }                                             258     }
259     return nullptr;                               259     return nullptr;
260   }                                               260   }
261   else                                            261   else
262   {                                               262   {
263     return (*mscite).second;                      263     return (*mscite).second;
264   }                                               264   }
265 }                                                 265 }
266                                                   266 
267 // -------------------------------------------    267 // --------------------------------------------------------------------
268 G4VPhysicalVolume* G4tgbVolumeMgr::GetTopPhysV    268 G4VPhysicalVolume* G4tgbVolumeMgr::GetTopPhysVol()
269 {                                                 269 {
270   G4LogicalVolume* lv   = GetTopLogVol();         270   G4LogicalVolume* lv   = GetTopLogVol();
271   G4VPhysicalVolume* pv = (*(thePVs.find(lv->G    271   G4VPhysicalVolume* pv = (*(thePVs.find(lv->GetName()))).second;
272                                                   272 
273 #ifdef G4VERBOSE                                  273 #ifdef G4VERBOSE
274   if(G4tgrMessenger::GetVerboseLevel() >= 2)      274   if(G4tgrMessenger::GetVerboseLevel() >= 2)
275   {                                               275   {
276     G4cout << " G4tgbVolumeMgr::GetTopPhysVol(    276     G4cout << " G4tgbVolumeMgr::GetTopPhysVol() - pv: " << pv->GetName()
277            << G4endl;                             277            << G4endl;
278   }                                               278   }
279 #endif                                            279 #endif
280                                                   280 
281   return pv;                                      281   return pv;
282 }                                                 282 }
283                                                   283 
284 // -------------------------------------------    284 // --------------------------------------------------------------------
285 G4LogicalVolume* G4tgbVolumeMgr::GetTopLogVol(    285 G4LogicalVolume* G4tgbVolumeMgr::GetTopLogVol()
286 {                                                 286 {
287   //----------- Start from any G4LogicalVolume    287   //----------- Start from any G4LogicalVolume, because if you go upwards
288   //            you will always end at the top    288   //            you will always end at the top
289 #ifdef G4VERBOSE                                  289 #ifdef G4VERBOSE
290   if(G4tgrMessenger::GetVerboseLevel() >= 2)      290   if(G4tgrMessenger::GetVerboseLevel() >= 2)
291   {                                               291   {
292     G4cout << " G4tgbVolumeMgr::GetTopLogVol t    292     G4cout << " G4tgbVolumeMgr::GetTopLogVol theLVInvTresize "
293            << theLVInvTree.size() << G4endl;      293            << theLVInvTree.size() << G4endl;
294   }                                               294   }
295 #endif                                            295 #endif
296   if(theLVInvTree.size() == 0)                    296   if(theLVInvTree.size() == 0)
297   {                                               297   {
298     G4Exception("G4tgbVolumeMgr::GetTopLogVol(    298     G4Exception("G4tgbVolumeMgr::GetTopLogVol()", "InvalidSetup",
299                 FatalException, "theLVInvTree     299                 FatalException, "theLVInvTree has no elements.");
300   }                                               300   }
301   G4LogicalVolume* lv = (*(theLVInvTree.begin(    301   G4LogicalVolume* lv = (*(theLVInvTree.begin())).second;
302                                                   302 
303   //------- if first element is the top LV, it    303   //------- if first element is the top LV, its parent is 0
304   if(lv == nullptr)                               304   if(lv == nullptr)
305   {                                               305   {
306     lv = (*(theLVInvTree.begin())).first;         306     lv = (*(theLVInvTree.begin())).first;
307   }                                               307   }
308   else                                            308   else
309   {                                               309   {
310     while((*(theLVInvTree.find(lv))).second !=    310     while((*(theLVInvTree.find(lv))).second != nullptr)
311     {                                             311     {
312       //---------- get parent of first positio    312       //---------- get parent of first position
313       lv = (*(theLVInvTree.find(lv))).second;     313       lv = (*(theLVInvTree.find(lv))).second;
314 #ifdef G4VERBOSE                                  314 #ifdef G4VERBOSE
315       if(G4tgrMessenger::GetVerboseLevel() >=     315       if(G4tgrMessenger::GetVerboseLevel() >= 2)
316       {                                           316       {
317         G4cout << " G4tgbVolumeMgr::GetTopPhys    317         G4cout << " G4tgbVolumeMgr::GetTopPhysVol: lv " << lv->GetName()
318                << G4endl;                         318                << G4endl;
319       }                                           319       }
320 #endif                                            320 #endif
321     }                                             321     }
322   }                                               322   }
323                                                   323 
324   return lv;                                      324   return lv;
325 }                                                 325 }
326                                                   326 
327 // -------------------------------------------    327 // --------------------------------------------------------------------
328 void G4tgbVolumeMgr::BuildPhysVolTree()           328 void G4tgbVolumeMgr::BuildPhysVolTree()
329 {                                                 329 {
330   /*                                              330   /*
331     G4PhysicalVolumeStore* pvs = G4PhysicalVol    331     G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance();
332     for( auto cite = pvs->cbegin(); cite != pv    332     for( auto cite = pvs->cbegin(); cite != pvs->cend(); ++cite )
333     {                                             333     {
334       thePVTree[ *cite ] = (*cite)->GetMother(    334       thePVTree[ *cite ] = (*cite)->GetMother();
335       thePVInvTree[ (*cite)->GetMother() ] = *    335       thePVInvTree[ (*cite)->GetMother() ] = *cite;
336     }                                             336     }
337   */                                              337   */
338 }                                                 338 }
339                                                   339 
340 // -------------------------------------------    340 // --------------------------------------------------------------------
341 void G4tgbVolumeMgr::DumpSummary()                341 void G4tgbVolumeMgr::DumpSummary()
342 {                                                 342 {
343   //---------- Dump number of objects of each     343   //---------- Dump number of objects of each class
344   G4cout << " @@@@@@@@@@@@@ Dumping Geant4 geo    344   G4cout << " @@@@@@@@@@@@@ Dumping Geant4 geometry objects Summary " << G4endl;
345   G4cout << " @@@ Geometry built inside world     345   G4cout << " @@@ Geometry built inside world volume: "
346          << GetTopPhysVol()->GetName() << G4en    346          << GetTopPhysVol()->GetName() << G4endl;
347   G4cout << " Number of G4VSolid's: " << theSo    347   G4cout << " Number of G4VSolid's: " << theSolids.size() << G4endl;
348   G4cout << " Number of G4LogicalVolume's: " <    348   G4cout << " Number of G4LogicalVolume's: " << theLVs.size() << G4endl;
349   G4cout << " Number of G4VPhysicalVolume's: "    349   G4cout << " Number of G4VPhysicalVolume's: " << thePVs.size() << G4endl;
350                                                   350 
351   G4tgbMaterialMgr* mateMgr = G4tgbMaterialMgr    351   G4tgbMaterialMgr* mateMgr = G4tgbMaterialMgr::GetInstance();
352   G4cout << " Number of G4Isotope's: " << mate    352   G4cout << " Number of G4Isotope's: " << mateMgr->GetG4IsotopeList().size()
353          << G4endl;                               353          << G4endl;
354   G4cout << " Number of G4Element's: " << mate    354   G4cout << " Number of G4Element's: " << mateMgr->GetG4ElementList().size()
355          << G4endl;                               355          << G4endl;
356   G4cout << " Number of G4Material's: " << mat    356   G4cout << " Number of G4Material's: " << mateMgr->GetG4MaterialList().size()
357          << G4endl;                               357          << G4endl;
358                                                   358 
359   G4tgbRotationMatrixMgr* rotmMgr = G4tgbRotat    359   G4tgbRotationMatrixMgr* rotmMgr = G4tgbRotationMatrixMgr::GetInstance();
360   G4cout << " Number of G4RotationMatrix's: "     360   G4cout << " Number of G4RotationMatrix's: "
361          << rotmMgr->GetG4RotMatList().size()     361          << rotmMgr->GetG4RotMatList().size() << G4endl;
362                                                   362 
363   //---------- Dump list of objects of each cl    363   //---------- Dump list of objects of each class
364   DumpG4SolidList();                              364   DumpG4SolidList();
365   DumpG4LogVolTree();                             365   DumpG4LogVolTree();
366   DumpG4PhysVolTree();                            366   DumpG4PhysVolTree();
367 }                                                 367 }
368                                                   368 
369 // -------------------------------------------    369 // --------------------------------------------------------------------
370 void G4tgbVolumeMgr::DumpG4SolidList()            370 void G4tgbVolumeMgr::DumpG4SolidList()
371 {                                                 371 {
372   for(auto cite = theSolids.cbegin(); cite !=     372   for(auto cite = theSolids.cbegin(); cite != theSolids.cend(); ++cite)
373   {                                               373   {
374     G4cout << "G4SOLID: " << (*cite).second->G    374     G4cout << "G4SOLID: " << (*cite).second->GetName() << " of type "
375            << (*cite).second->GetEntityType()     375            << (*cite).second->GetEntityType() << G4endl;
376   }                                               376   }
377 }                                                 377 }
378                                                   378 
379 //--------------------------------------------    379 //---------------------------------------------------------------------
380 void G4tgbVolumeMgr::DumpG4LogVolTree()           380 void G4tgbVolumeMgr::DumpG4LogVolTree()
381 {                                                 381 {
382   G4cout << " @@@@@@@@@@@@@ DUMPING G4LogicalV    382   G4cout << " @@@@@@@@@@@@@ DUMPING G4LogicalVolume's Tree  " << G4endl;
383                                                   383 
384   G4LogicalVolume* lv = GetTopLogVol();           384   G4LogicalVolume* lv = GetTopLogVol();
385                                                   385 
386   DumpG4LogVolLeaf(lv, 0);                        386   DumpG4LogVolLeaf(lv, 0);
387 }                                                 387 }
388                                                   388 
389 //--------------------------------------------    389 //---------------------------------------------------------------------
390 void G4tgbVolumeMgr::DumpG4LogVolLeaf(const G4    390 void G4tgbVolumeMgr::DumpG4LogVolLeaf(const G4LogicalVolume* lv,
391                                       unsigned    391                                       unsigned int leafDepth)
392 {                                                 392 {
393   for(std::size_t ii = 0; ii < leafDepth; ++ii    393   for(std::size_t ii = 0; ii < leafDepth; ++ii)
394   {                                               394   {
395     G4cout << "  ";                               395     G4cout << "  ";
396   }                                               396   }
397   G4cout << " LV:(" << leafDepth << ")" << lv-    397   G4cout << " LV:(" << leafDepth << ")" << lv->GetName() << G4endl;
398                                                   398 
399   //---------- construct the children of this     399   //---------- construct the children of this volume
400   // G4LogicalVolume* lvnc = const_cast<G4Logi    400   // G4LogicalVolume* lvnc = const_cast<G4LogicalVolume*>(lv);
401   // std::pair<G4mlvlv::iterator, G4mlvlv::ite    401   // std::pair<G4mlvlv::iterator, G4mlvlv::iterator> children
402   //   = theLVTree.equal_range( lvnc );           402   //   = theLVTree.equal_range( lvnc );
403   //                                              403   //
404   // G4mlvlv::iterator cite;                      404   // G4mlvlv::iterator cite;
405                                                   405 
406   ++leafDepth;                                    406   ++leafDepth;
407   // for( cite = children.first; cite != child    407   // for( cite = children.first; cite != children.second; ++cite )
408   // {                                            408   // {
409   //  DumpG4LVLeaf( (*cite)->second, leafDepth    409   //  DumpG4LVLeaf( (*cite)->second, leafDepth );
410   // }                                            410   // }
411 }                                                 411 }
412                                                   412 
413 // -------------------------------------------    413 // --------------------------------------------------------------------
414 void G4tgbVolumeMgr::DumpG4PhysVolTree()          414 void G4tgbVolumeMgr::DumpG4PhysVolTree()
415 {                                                 415 {
416   G4cout << " @@@@@@@@@@@@@ DUMPING G4Physical    416   G4cout << " @@@@@@@@@@@@@ DUMPING G4PhysicalVolume's Tree  " << G4endl;
417                                                   417 
418   G4VPhysicalVolume* pv = GetTopPhysVol();        418   G4VPhysicalVolume* pv = GetTopPhysVol();
419                                                   419 
420   DumpG4PhysVolLeaf(pv, 0);                       420   DumpG4PhysVolLeaf(pv, 0);
421 }                                                 421 }
422                                                   422 
423 // -------------------------------------------    423 // --------------------------------------------------------------------
424 void G4tgbVolumeMgr::DumpG4PhysVolLeaf(const G    424 void G4tgbVolumeMgr::DumpG4PhysVolLeaf(const G4VPhysicalVolume* pv,
425                                        unsigne    425                                        unsigned int leafDepth)
426 {                                                 426 {
427   for(std::size_t ii = 0; ii < leafDepth; ++ii    427   for(std::size_t ii = 0; ii < leafDepth; ++ii)
428   {                                               428   {
429     G4cout << "  ";                               429     G4cout << "  ";
430   }                                               430   }
431   G4cout << " PV:(" << leafDepth << ")" << pv-    431   G4cout << " PV:(" << leafDepth << ")" << pv->GetName() << G4endl;
432                                                   432 
433   //---------- construct the children of this     433   //---------- construct the children of this PV
434   // G4VPhysicalVolume* pvnc = const_cast<G4VP    434   // G4VPhysicalVolume* pvnc = const_cast<G4VPhysicalVolume*>(pv);
435   // std::pair<G4mpvpv::iterator, G4mpvpv::ite    435   // std::pair<G4mpvpv::iterator, G4mpvpv::iterator> children
436   //  = thePVTree.equal_range( pvnc );            436   //  = thePVTree.equal_range( pvnc );
437   //                                              437   //
438   // G4mpvpv::iterator cite;                      438   // G4mpvpv::iterator cite;
439                                                   439 
440   ++leafDepth;                                    440   ++leafDepth;
441   // for( cite = children.first; cite != child    441   // for( cite = children.first; cite != children.second; ++cite )
442   // {                                            442   // {
443   //  DumpG4PVLeaf( (*cite)->second, leafDepth    443   //  DumpG4PVLeaf( (*cite)->second, leafDepth );
444   // }                                            444   // }
445 }                                                 445 }
446                                                   446