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.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 7.0)


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