Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/gorad/src/GRDetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/gorad/src/GRDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/gorad/src/GRDetectorConstruction.cc (Version 11.0.p4)


  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 //  Gorad (Geant4 Open-source Radiation Analys     26 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
 27 //                                                 27 //
 28 //  Author : Makoto Asai (SLAC National Accele     28 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
 29 //                                                 29 //
 30 //  Development of Gorad is funded by NASA Joh     30 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
 31 //  under the contract NNJ15HK11B.                 31 //  under the contract NNJ15HK11B.
 32 //                                                 32 //
 33 // *******************************************     33 // ********************************************************************
 34 //                                                 34 //
 35 // GRDetectorConstruction.cc                       35 // GRDetectorConstruction.cc
 36 //   Read a GDML file to set up the geometry.      36 //   Read a GDML file to set up the geometry.
 37 //   This class also takes care of several uti     37 //   This class also takes care of several utility methods on geometry
 38 //   and creates a parallel world for geometry     38 //   and creates a parallel world for geometry importance biasing if
 39 //   requested.                                    39 //   requested.
 40 //                                                 40 //
 41 // History                                         41 // History
 42 //   September 8th, 2020 : first implementatio     42 //   September 8th, 2020 : first implementation
 43 //                                                 43 //
 44 // *******************************************     44 // ********************************************************************
 45                                                    45 
 46 #include "GRDetectorConstruction.hh"               46 #include "GRDetectorConstruction.hh"
 47                                                    47 
 48 #include "G4GDMLParser.hh"                         48 #include "G4GDMLParser.hh"
 49 #include "GRDetectorConstructionMessenger.hh"      49 #include "GRDetectorConstructionMessenger.hh"
 50 #include "GRGeomImpBiasWorld.hh"                   50 #include "GRGeomImpBiasWorld.hh"
 51                                                    51 
 52 #include "G4VPhysicalVolume.hh"                    52 #include "G4VPhysicalVolume.hh"
 53 #include "G4RunManager.hh"                         53 #include "G4RunManager.hh"
 54 #include "G4LogicalVolume.hh"                      54 #include "G4LogicalVolume.hh"
 55 #include "G4Box.hh"                                55 #include "G4Box.hh"
 56 #include <algorithm>                               56 #include <algorithm>
 57                                                    57 
 58 G4double GRDetectorConstruction::worldSize = -     58 G4double GRDetectorConstruction::worldSize = -1.;
 59                                                    59 
 60 GRDetectorConstruction::GRDetectorConstruction     60 GRDetectorConstruction::GRDetectorConstruction()
 61 : gdmlFile("noName"), fWorld(nullptr), initial     61 : gdmlFile("noName"), fWorld(nullptr), initialized(false)
 62 {                                                  62 {
 63   messenger = new GRDetectorConstructionMessen     63   messenger = new GRDetectorConstructionMessenger(this);
 64   parser = new G4GDMLParser();                     64   parser = new G4GDMLParser();
 65 }                                                  65 }
 66                                                    66 
 67 GRDetectorConstruction::~GRDetectorConstructio     67 GRDetectorConstruction::~GRDetectorConstruction()
 68 {                                                  68 {
 69   delete messenger;                                69   delete messenger;
 70   delete parser;                                   70   delete parser;
 71 }                                                  71 }
 72                                                    72 
 73 G4VPhysicalVolume* GRDetectorConstruction::Con     73 G4VPhysicalVolume* GRDetectorConstruction::Construct()
 74 {                                                  74 {
 75   if(!initialized)                                 75   if(!initialized)
 76   {                                                76   {
 77     Read();                                        77     Read();
 78     if(applyGeomImpBias)                           78     if(applyGeomImpBias)
 79     {                                              79     {
 80       G4String wName = "GeomBias";                 80       G4String wName = "GeomBias";
 81       geomImpBiasWorld = new GRGeomImpBiasWorl     81       geomImpBiasWorld = new GRGeomImpBiasWorld(wName,this);
 82       RegisterParallelWorld(geomImpBiasWorld);     82       RegisterParallelWorld(geomImpBiasWorld);
 83     }                                              83     }
 84   }                                                84   }
 85   return fWorld;                                   85   return fWorld;
 86 }                                                  86 }
 87                                                    87 
 88 void GRDetectorConstruction::ConstructSDAndFie     88 void GRDetectorConstruction::ConstructSDAndField()
 89 { ; }                                              89 { ; }
 90                                                    90 
 91 G4bool GRDetectorConstruction::SetGDMLFile(G4S     91 G4bool GRDetectorConstruction::SetGDMLFile(G4String& gdml)
 92 {                                                  92 {
 93   G4bool valid = true; // parser->IsValid(gdml     93   G4bool valid = true; // parser->IsValid(gdml); ## GDML parser fix needed
 94   if(valid)                                        94   if(valid)
 95   {                                                95   {
 96     if(initialized)                                96     if(initialized)
 97     {                                              97     {
 98       parser->Clear();                             98       parser->Clear();
 99       G4RunManager::GetRunManager()->Reinitial     99       G4RunManager::GetRunManager()->ReinitializeGeometry(true);
100     }                                             100     }
101     gdmlFile = gdml;                              101     gdmlFile = gdml;
102   }                                               102   }
103   return valid;                                   103   return valid;
104 }                                                 104 }
105                                                   105 
106 void GRDetectorConstruction::Read()               106 void GRDetectorConstruction::Read()
107 {                                                 107 {
108   parser->Read(gdmlFile);                         108   parser->Read(gdmlFile);
109   fWorld = parser->GetWorldVolume();              109   fWorld = parser->GetWorldVolume();
110   const G4Box* worldBox = dynamic_cast<const G    110   const G4Box* worldBox = dynamic_cast<const G4Box*>(fWorld->GetLogicalVolume()->GetSolid());
111   if(!worldBox)                                   111   if(!worldBox)
112   {                                               112   {
113     G4ExceptionDescription ed;                    113     G4ExceptionDescription ed;
114     ed << "PANIC!!! World volume defined in "<    114     ed << "PANIC!!! World volume defined in "<<gdmlFile<<" is not Box!!!";
115     G4Exception("GRDetectorConstruction::Read(    115     G4Exception("GRDetectorConstruction::Read()","GOoradGeom00012",FatalException,ed);
116   }                                               116   }
117   worldSize = std::min( {worldBox->GetXHalfLen    117   worldSize = std::min( {worldBox->GetXHalfLength(), worldBox->GetYHalfLength(), worldBox->GetZHalfLength()},
118                         [](G4double a,G4double    118                         [](G4double a,G4double b) {return a<b;} );
119   initialized = true;                             119   initialized = true;
120 }                                                 120 }
121                                                   121 
122 #include "G4UnitsTable.hh"                        122 #include "G4UnitsTable.hh"
123 #include "G4VSolid.hh"                            123 #include "G4VSolid.hh"
124 #include "G4SolidStore.hh"                        124 #include "G4SolidStore.hh"
125 void GRDetectorConstruction::ListSolids(G4int     125 void GRDetectorConstruction::ListSolids(G4int lvl)
126 {                                                 126 {
127   G4cout << "*********** List of registered so    127   G4cout << "*********** List of registered solids *************" << G4endl;
128   auto store = G4SolidStore::GetInstance();       128   auto store = G4SolidStore::GetInstance();
129   auto itr = store->begin();                      129   auto itr = store->begin();
130   for(;itr!=store->end();itr++)                   130   for(;itr!=store->end();itr++)
131   {                                               131   {
132     switch(lvl)                                   132     switch(lvl)
133     {                                             133     {
134       case 0:                                     134       case 0:
135         G4cout << (*itr)->GetName() << G4endl;    135         G4cout << (*itr)->GetName() << G4endl;
136         break;                                    136         break;
137       case 1:                                     137       case 1:
138         G4cout << (*itr)->GetName()               138         G4cout << (*itr)->GetName()
139                << "\t volume = " << G4BestUnit    139                << "\t volume = " << G4BestUnit((*itr)->GetCubicVolume(),"Volume")
140                << "\t surface = " << G4BestUni    140                << "\t surface = " << G4BestUnit((*itr)->GetSurfaceArea(),"Surface")
141                << G4endl;                         141                << G4endl;
142         break;                                    142         break;
143       default:                                    143       default:
144         (*itr)->DumpInfo();                       144         (*itr)->DumpInfo();
145         break;                                    145         break;
146     }                                             146     }
147   }                                               147   }
148 }                                                 148 }
149                                                   149 
150 #include "G4LogicalVolume.hh"                     150 #include "G4LogicalVolume.hh"
151 #include "G4LogicalVolumeStore.hh"                151 #include "G4LogicalVolumeStore.hh"
152 #include "G4Material.hh"                          152 #include "G4Material.hh"
153 #include "G4VSensitiveDetector.hh"                153 #include "G4VSensitiveDetector.hh"
154 void GRDetectorConstruction::ListLogVols(G4int    154 void GRDetectorConstruction::ListLogVols(G4int lvl)
155 {                                                 155 {
156   G4cout << "*********** List of registered lo    156   G4cout << "*********** List of registered logical volumes *************" << G4endl;
157   auto store = G4LogicalVolumeStore::GetInstan    157   auto store = G4LogicalVolumeStore::GetInstance();
158   auto itr = store->begin();                      158   auto itr = store->begin();
159   for(;itr!=store->end();itr++)                   159   for(;itr!=store->end();itr++)
160   {                                               160   {
161     G4cout << (*itr)->GetName() << "\t Solid =    161     G4cout << (*itr)->GetName() << "\t Solid = " << (*itr)->GetSolid()->GetName();
162     if((*itr)->GetMaterial())                     162     if((*itr)->GetMaterial())
163     { G4cout << "\t Material = " << (*itr)->Ge    163     { G4cout << "\t Material = " << (*itr)->GetMaterial()->GetName() << G4endl; }
164     else                                          164     else
165     { G4cout << "\t Material : not defined " <    165     { G4cout << "\t Material : not defined " << G4endl; }
166     if(lvl<1) continue;                           166     if(lvl<1) continue;
167     G4cout << "\t region = ";                     167     G4cout << "\t region = ";
168     if((*itr)->GetRegion())                       168     if((*itr)->GetRegion())
169     { G4cout << (*itr)->GetRegion()->GetName()    169     { G4cout << (*itr)->GetRegion()->GetName(); }
170     else                                          170     else
171     { G4cout << "not defined"; }                  171     { G4cout << "not defined"; }
172     G4cout << "\t sensitive detector = ";         172     G4cout << "\t sensitive detector = ";
173     if((*itr)->GetSensitiveDetector())            173     if((*itr)->GetSensitiveDetector())
174     { G4cout << (*itr)->GetSensitiveDetector()    174     { G4cout << (*itr)->GetSensitiveDetector()->GetName(); }
175     else                                          175     else
176     { G4cout << "not defined"; }                  176     { G4cout << "not defined"; }
177     G4cout << G4endl;                             177     G4cout << G4endl;
178     G4cout << "\t daughters = " << (*itr)->Get    178     G4cout << "\t daughters = " << (*itr)->GetNoDaughters();
179     if((*itr)->GetNoDaughters()>0)                179     if((*itr)->GetNoDaughters()>0)
180     {                                             180     {
181       switch((*itr)->CharacteriseDaughters())     181       switch((*itr)->CharacteriseDaughters())
182       {                                           182       {
183         case kNormal:                             183         case kNormal:
184           G4cout << " (placement)"; break;        184           G4cout << " (placement)"; break;
185         case kReplica:                            185         case kReplica:
186           G4cout << " (replica : " << (*itr)->    186           G4cout << " (replica : " << (*itr)->GetDaughter(0)->GetMultiplicity() << ")"; break;
187         case kParameterised:                      187         case kParameterised:
188           G4cout << " (parameterized : " << (*    188           G4cout << " (parameterized : " << (*itr)->GetDaughter(0)->GetMultiplicity() << ")"; break;
189         default:                                  189         default:
190           ;                                       190           ;
191       }                                           191       }
192     }                                             192     }
193     G4cout << G4endl;                             193     G4cout << G4endl;
194     if(lvl<2) continue;                           194     if(lvl<2) continue;
195     if((*itr)->GetMaterial())                     195     if((*itr)->GetMaterial())
196     { G4cout << "\t weight = " << G4BestUnit((    196     { G4cout << "\t weight = " << G4BestUnit((*itr)->GetMass(),"Mass") << G4endl; }
197     else                                          197     else
198     { G4cout << "\t weight : not available" <<    198     { G4cout << "\t weight : not available" << G4endl; }
199   }                                               199   }
200 }                                                 200 }
201                                                   201 
202 #include "G4VPhysicalVolume.hh"                   202 #include "G4VPhysicalVolume.hh"
203 #include "G4PhysicalVolumeStore.hh"               203 #include "G4PhysicalVolumeStore.hh"
204 void GRDetectorConstruction::ListPhysVols(G4in    204 void GRDetectorConstruction::ListPhysVols(G4int lvl)
205 {                                                 205 {
206   G4cout << "*********** List of registered ph    206   G4cout << "*********** List of registered physical volumes *************" << G4endl;
207   auto store = G4PhysicalVolumeStore::GetInsta    207   auto store = G4PhysicalVolumeStore::GetInstance();
208   auto itr = store->begin();                      208   auto itr = store->begin();
209   for(;itr!=store->end();itr++)                   209   for(;itr!=store->end();itr++)
210   {                                               210   {
211     switch(lvl)                                   211     switch(lvl)
212     {                                             212     {
213       case 0:                                     213       case 0:
214         G4cout << (*itr)->GetName() << G4endl;    214         G4cout << (*itr)->GetName() << G4endl;
215         break;                                    215         break;
216       case 1:                                     216       case 1:
217         G4cout << (*itr)->GetName()               217         G4cout << (*itr)->GetName()
218                << "\t logical volume = " << (*    218                << "\t logical volume = " << (*itr)->GetLogicalVolume()->GetName()
219                << "\t mother logical = ";         219                << "\t mother logical = ";
220         if((*itr)->GetMotherLogical())            220         if((*itr)->GetMotherLogical())
221         { G4cout << (*itr)->GetMotherLogical()    221         { G4cout << (*itr)->GetMotherLogical()->GetName(); }
222         else                                      222         else
223         { G4cout << "not defined"; }              223         { G4cout << "not defined"; }
224         G4cout << G4endl;                         224         G4cout << G4endl;
225         break;                                    225         break;
226       default:                                    226       default:
227         G4cout << (*itr)->GetName()               227         G4cout << (*itr)->GetName()
228                << "\t logical volume = " << (*    228                << "\t logical volume = " << (*itr)->GetLogicalVolume()->GetName()
229                << "\t mother logical = ";         229                << "\t mother logical = ";
230         if((*itr)->GetMotherLogical())            230         if((*itr)->GetMotherLogical())
231         { G4cout << (*itr)->GetMotherLogical()    231         { G4cout << (*itr)->GetMotherLogical()->GetName(); }
232         else                                      232         else
233         { G4cout << "not defined"; }              233         { G4cout << "not defined"; }
234         G4cout << "\t type = ";                   234         G4cout << "\t type = ";
235         switch((*itr)->VolumeType())              235         switch((*itr)->VolumeType())
236         {                                         236         {
237           case kNormal:                           237           case kNormal:
238             G4cout << "placement"; break;         238             G4cout << "placement"; break;
239           case kReplica:                          239           case kReplica:
240             G4cout << "replica"; break;           240             G4cout << "replica"; break;
241           case kParameterised:                    241           case kParameterised:
242             G4cout << "parameterized"; break;     242             G4cout << "parameterized"; break;
243           default:                                243           default:
244             ;                                     244             ;
245         }                                         245         }
246         G4cout << G4endl;                         246         G4cout << G4endl;
247     }                                             247     }
248   }                                               248   }
249 }                                                 249 }
250                                                   250 
251 G4bool GRDetectorConstruction::CheckOverlap(G4    251 G4bool GRDetectorConstruction::CheckOverlap(G4String& physVolName, G4int nSpots,
252                  G4int maxErr, G4double tol)      252                  G4int maxErr, G4double tol)
253 {                                                 253 {
254   G4cout << "*********** Checking overlap for     254   G4cout << "*********** Checking overlap for <" << physVolName << "> *************" << G4endl;
255   G4bool checkAll = (physVolName=="**ALL**");     255   G4bool checkAll = (physVolName=="**ALL**");
256   auto store = G4PhysicalVolumeStore::GetInsta    256   auto store = G4PhysicalVolumeStore::GetInstance();
257   auto itr = store->begin();                      257   auto itr = store->begin();
258   G4VPhysicalVolume* physVol = nullptr;           258   G4VPhysicalVolume* physVol = nullptr;
259   for(;itr!=store->end();itr++)                   259   for(;itr!=store->end();itr++)
260   {                                               260   {
261     if(checkAll || (*itr)->GetName()==physVolN    261     if(checkAll || (*itr)->GetName()==physVolName)
262     {                                             262     {
263       physVol = (*itr);                           263       physVol = (*itr);
264       physVol->CheckOverlaps(nSpots,tol,true,m    264       physVol->CheckOverlaps(nSpots,tol,true,maxErr);
265       if(!checkAll) break;                        265       if(!checkAll) break;
266     }                                             266     }
267   }                                               267   }
268   return (physVol!=nullptr);                      268   return (physVol!=nullptr);
269 }                                                 269 }
270                                                   270 
271 #include "G4Region.hh"                            271 #include "G4Region.hh"
272 #include "G4RegionStore.hh"                       272 #include "G4RegionStore.hh"
273 #include "G4RunManagerKernel.hh"                  273 #include "G4RunManagerKernel.hh"
274 void GRDetectorConstruction::ListRegions(G4int    274 void GRDetectorConstruction::ListRegions(G4int lvl)
275 {                                                 275 {
276   if(lvl==2)                                      276   if(lvl==2)
277   {                                               277   {
278     G4RunManagerKernel::GetRunManagerKernel()-    278     G4RunManagerKernel::GetRunManagerKernel()->DumpRegion();
279     return;                                       279     return;
280   }                                               280   }
281   G4cout << "*********** List of registered re    281   G4cout << "*********** List of registered regions *************" << G4endl;
282   auto store = G4RegionStore::GetInstance();      282   auto store = G4RegionStore::GetInstance();
283   auto itr = store->begin();                      283   auto itr = store->begin();
284   for(;itr!=store->end();itr++)                   284   for(;itr!=store->end();itr++)
285   {                                               285   {
286     G4cout << (*itr)->GetName();                  286     G4cout << (*itr)->GetName();
287     if((*itr)->GetWorldPhysical())                287     if((*itr)->GetWorldPhysical())
288     {                                             288     {
289       G4cout << "\t in the world volume <" <<     289       G4cout << "\t in the world volume <" << (*itr)->GetWorldPhysical()->GetName() << "> ";
290       if((*itr)->IsInMassGeometry()) G4cout <<    290       if((*itr)->IsInMassGeometry()) G4cout << "-- mass world";
291       if((*itr)->IsInParallelGeometry()) G4cou    291       if((*itr)->IsInParallelGeometry()) G4cout << "-- parallel world";
292     }                                             292     }
293     else                                          293     else
294     { G4cout << " -- is not associated to any     294     { G4cout << " -- is not associated to any world."; }
295     G4cout << G4endl;                             295     G4cout << G4endl;
296     if(lvl==0) continue;                          296     if(lvl==0) continue;
297     G4cout << "\t\t Root logical volume(s) : "    297     G4cout << "\t\t Root logical volume(s) : ";
298     size_t nRootLV = (*itr)->GetNumberOfRootVo    298     size_t nRootLV = (*itr)->GetNumberOfRootVolumes();
299     std::vector<G4LogicalVolume*>::iterator lv    299     std::vector<G4LogicalVolume*>::iterator lvItr = (*itr)->GetRootLogicalVolumeIterator();
300     for(size_t j=0;j<nRootLV;j++)                 300     for(size_t j=0;j<nRootLV;j++)
301     { G4cout << (*lvItr)->GetName() << " "; lv    301     { G4cout << (*lvItr)->GetName() << " "; lvItr++; }
302     G4cout << G4endl;                             302     G4cout << G4endl;
303     G4cout << "\t\t Pointers : G4VUserRegionIn    303     G4cout << "\t\t Pointers : G4VUserRegionInformation[" << (*itr)->GetUserInformation()
304            << "], G4UserLimits[" << (*itr)->Ge    304            << "], G4UserLimits[" << (*itr)->GetUserLimits()
305            << "], G4FastSimulationManager[" <<    305            << "], G4FastSimulationManager[" << (*itr)->GetFastSimulationManager()
306            << "], G4UserSteppingAction[" << (*    306            << "], G4UserSteppingAction[" << (*itr)->GetRegionalSteppingAction() << "]" << G4endl;
307   }                                               307   }
308 }                                                 308 }
309                                                   309 
310 G4bool GRDetectorConstruction::CreateRegion(G4    310 G4bool GRDetectorConstruction::CreateRegion(G4String& regionName,G4String& logVolName)
311 {                                                 311 {
312   auto logVolStore = G4LogicalVolumeStore::Get    312   auto logVolStore = G4LogicalVolumeStore::GetInstance();
313   auto itr = logVolStore->begin();                313   auto itr = logVolStore->begin();
314   G4LogicalVolume* logVol = nullptr;              314   G4LogicalVolume* logVol = nullptr;
315   for(;itr!=logVolStore->end();itr++)             315   for(;itr!=logVolStore->end();itr++)
316   {                                               316   {
317     if((*itr)->GetName() == logVolName)           317     if((*itr)->GetName() == logVolName)
318     { logVol = (*itr); break; }                   318     { logVol = (*itr); break; }
319   }                                               319   }
320   if(!logVol) return false;                       320   if(!logVol) return false;
321                                                   321 
322   auto regionStore = G4RegionStore::GetInstanc    322   auto regionStore = G4RegionStore::GetInstance();
323   auto region = regionStore->FindOrCreateRegio    323   auto region = regionStore->FindOrCreateRegion(regionName);
324   logVol->SetRegion(region);                      324   logVol->SetRegion(region);
325   region->AddRootLogicalVolume(logVol);           325   region->AddRootLogicalVolume(logVol);
326   return true;                                    326   return true;
327 }                                                 327 }
328                                                   328   
329 #include "G4MaterialTable.hh"                     329 #include "G4MaterialTable.hh"
330 void GRDetectorConstruction::ListAllMaterial()    330 void GRDetectorConstruction::ListAllMaterial()
331 {                                                 331 {
332   auto materialTable = G4Material::GetMaterial    332   auto materialTable = G4Material::GetMaterialTable();
333   auto matItr = materialTable->begin();           333   auto matItr = materialTable->begin();
334   G4cout << "*********** List of instantiated     334   G4cout << "*********** List of instantiated materials **************" << G4endl;
335   G4int i = 0;                                    335   G4int i = 0;
336   for(;matItr!=materialTable->end();matItr++)     336   for(;matItr!=materialTable->end();matItr++)
337   {                                               337   {
338     G4cout << (*matItr)->GetName() << "\t";       338     G4cout << (*matItr)->GetName() << "\t";
339     if(++i%5==0) G4cout << G4endl;                339     if(++i%5==0) G4cout << G4endl;
340   }                                               340   }
341   G4cout << G4endl;                               341   G4cout << G4endl;
342 }                                                 342 }
343                                                   343 
344 G4bool GRDetectorConstruction::ListMaterial(G4    344 G4bool GRDetectorConstruction::ListMaterial(G4String& matName)
345 {                                                 345 {
346   auto materialTable = G4Material::GetMaterial    346   auto materialTable = G4Material::GetMaterialTable();
347   auto matItr = materialTable->begin();           347   auto matItr = materialTable->begin();
348   for(;matItr!=materialTable->end();matItr++)     348   for(;matItr!=materialTable->end();matItr++)
349   {                                               349   {
350     if((*matItr)->GetName()==matName)             350     if((*matItr)->GetName()==matName) 
351     {                                             351     {
352       G4cout << *matItr << G4endl;                352       G4cout << *matItr << G4endl;
353       return true;                                353       return true;
354     }                                             354     }
355   }                                               355   }
356   return false;                                   356   return false;
357 }                                                 357 }
358                                                   358 
359 #include "G4NistManager.hh"                       359 #include "G4NistManager.hh"
360 void GRDetectorConstruction::DumpNistMaterials    360 void GRDetectorConstruction::DumpNistMaterials()
361 {                                                 361 {
362   auto nameVec = G4NistManager::Instance()->Ge    362   auto nameVec = G4NistManager::Instance()->GetNistMaterialNames();
363   auto itr = nameVec.begin();                     363   auto itr = nameVec.begin();
364   G4int i = 0;                                    364   G4int i = 0;
365   for(;itr!=nameVec.end();itr++)                  365   for(;itr!=nameVec.end();itr++)
366   {                                               366   {
367     G4cout << std::setw(26) << *itr;              367     G4cout << std::setw(26) << *itr;
368     if(++i%3==0) G4cout << G4endl;                368     if(++i%3==0) G4cout << G4endl;
369   }                                               369   }
370   G4cout << G4endl;                               370   G4cout << G4endl;
371 }                                                 371 }
372                                                   372 
373 G4bool GRDetectorConstruction::CreateMaterial(    373 G4bool GRDetectorConstruction::CreateMaterial(G4String& matName)
374 {                                                 374 {
375   auto mat = G4NistManager::Instance()->FindOr    375   auto mat = G4NistManager::Instance()->FindOrBuildMaterial(matName);
376   return (mat!=nullptr);                          376   return (mat!=nullptr);
377 }                                                 377 }
378                                                   378 
379 G4bool GRDetectorConstruction::GetMaterial(G4S    379 G4bool GRDetectorConstruction::GetMaterial(G4String& logVol)
380 {                                                 380 {
381   auto store = G4LogicalVolumeStore::GetInstan    381   auto store = G4LogicalVolumeStore::GetInstance();
382   std::vector<G4LogicalVolume*>::iterator itr     382   std::vector<G4LogicalVolume*>::iterator itr = store->begin();
383   for(;itr!=store->end();itr++)                   383   for(;itr!=store->end();itr++)
384   {                                               384   {
385     if((*itr)->GetName()==logVol)                 385     if((*itr)->GetName()==logVol)
386     {                                             386     {
387       G4cout << "Logical volume <" << (*itr)->    387       G4cout << "Logical volume <" << (*itr)->GetName() << "> is made of <"
388            << (*itr)->GetMaterial()->GetName()    388            << (*itr)->GetMaterial()->GetName() << ">" << G4endl;
389       return true;                                389       return true;
390     }                                             390     }
391   }                                               391   }
392   return false;                                   392   return false;
393 }                                                 393 }
394                                                   394 
395 G4int GRDetectorConstruction::SetMaterial(G4St    395 G4int GRDetectorConstruction::SetMaterial(G4String& logVolName,G4String& matName)
396 {                                                 396 {
397   G4LogicalVolume* logVol = nullptr;              397   G4LogicalVolume* logVol = nullptr;
398   G4Material* mat = nullptr;                      398   G4Material* mat = nullptr;
399                                                   399 
400   auto store = G4LogicalVolumeStore::GetInstan    400   auto store = G4LogicalVolumeStore::GetInstance();
401   auto itr = store->begin();                      401   auto itr = store->begin();
402   for(;itr!=store->end();itr++)                   402   for(;itr!=store->end();itr++)
403   {                                               403   {
404     if((*itr)->GetName()==logVolName)             404     if((*itr)->GetName()==logVolName)
405     {                                             405     {
406       logVol = *itr;                              406       logVol = *itr;
407       break;                                      407       break;
408     }                                             408     }
409   }                                               409   }
410                                                   410 
411   auto materialTable = G4Material::GetMaterial    411   auto materialTable = G4Material::GetMaterialTable();
412   auto matItr = materialTable->begin();           412   auto matItr = materialTable->begin();
413   for(;matItr!=materialTable->end();matItr++)     413   for(;matItr!=materialTable->end();matItr++)
414   {                                               414   {
415     if((*matItr)->GetName()==matName)             415     if((*matItr)->GetName()==matName) 
416     {                                             416     {
417       mat = *matItr;                              417       mat = *matItr;
418       break;                                      418       break;
419     }                                             419     }
420   }                                               420   }
421                                                   421 
422   G4int retVal = 0;                               422   G4int retVal = 0;
423   if(!logVol && !mat)                             423   if(!logVol && !mat) 
424   { retVal = 3; }                                 424   { retVal = 3; }
425   else if(!logVol)                                425   else if(!logVol)
426   { retVal = 1; }                                 426   { retVal = 1; }
427   else if(!mat)                                   427   else if(!mat)
428   { retVal = 2; }                                 428   { retVal = 2; }
429   else                                            429   else
430   { logVol->SetMaterial(mat); }                   430   { logVol->SetMaterial(mat); }
431                                                   431 
432   return retVal;                                  432   return retVal;
433 }                                                 433 }
434                                                   434 
435                                                   435 
436                                                   436