G3VolTable.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // modified by I.Hrivnacova, 13.10.99
00030 
00031 #include <iomanip>
00032 #include "globals.hh"
00033 #include "G3VolTable.hh"
00034 #include "G3Pos.hh"
00035 
00036 typedef std::map<G4String, G3VolTableEntry*, std::less<G4String> >
00037 ::iterator VTDiterator;
00038 
00039 G3VolTable::G3VolTable() 
00040   : G3toG4TopVTE(0), _FirstKey("UnDefined"), _NG3Pos(0){
00041 }
00042 
00043 G3VolTable::~G3VolTable(){
00044   if (VTD.size()>0){
00045     //    G4cout << "Deleting VTD" << G4endl;
00046     for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
00047       delete (*i).second;
00048     }
00049     VTD.clear();
00050   }
00051 }
00052 
00053 G3VolTableEntry*
00054 G3VolTable::GetVTE(const G4String& Vname) {
00055   VTDiterator i = VTD.find(Vname);
00056   if (i == VTD.end()) return 0;
00057   else                return (*i).second;
00058 }
00059 
00060 void 
00061 G3VolTable::PrintAll(){
00062   if (VTD.size()){
00063     G4int i=0;
00064     G4cout << "Dump of VTD - " << VTD.size() << " entries:" << G4endl;
00065     VTEStat();
00066     for (VTDiterator v=VTD.begin(); v != VTD.end(); v++){
00067       G3VolTableEntry* VTE = (*v).second;
00068       G4cout << "G3VolTable element " << std::setw(3) << i++ << " name "
00069              << VTE->GetName() << " has " << VTE->GetNoDaughters() 
00070              << " daughters" << G4endl;
00071     }
00072   }
00073 }
00074 
00075 G3VolTableEntry*
00076 G3VolTable::PutVTE(G3VolTableEntry* aG3VolTableEntry){
00077   
00078   if (GetVTE(aG3VolTableEntry->GetName()) == 0 ){
00079     
00080     // create a hash key
00081     G4String HashID = aG3VolTableEntry->GetName();
00082     
00083     if (_FirstKey == "UnDefined") _FirstKey = HashID;
00084     
00085     // insert into dictionary
00086     VTD[HashID] = aG3VolTableEntry;
00087   }
00088   return GetVTE(aG3VolTableEntry->GetName());
00089 }
00090 
00091 void 
00092 G3VolTable::CountG3Pos(){
00093   _NG3Pos++;
00094 }
00095 
00096 void
00097 G3VolTable::SetFirstVTE(){
00098   G3toG4TopVTE = VTD[_FirstKey];
00099   
00100   if (G3toG4TopVTE->NPCopies() > 0) {
00101     _FirstKey = G3toG4TopVTE->GetMother()->GetName();
00102     SetFirstVTE();
00103   }
00104 }
00105 
00106 G3VolTableEntry*
00107 G3VolTable::GetFirstVTE() {
00108   return G3toG4TopVTE;
00109 }
00110 
00111 void
00112 G3VolTable::VTEStat() {
00113   G4cout << "Instantiated " << VTD.size() << 
00114     " volume table entries \n" 
00115          << "                      " << _NG3Pos << " positions." << G4endl;
00116 }
00117 
00118 void 
00119 G3VolTable::Clear() {
00120   if (VTD.size()>0){
00121     for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
00122       delete (*i).second;
00123     }
00124     VTD.clear();
00125   }
00126   G3toG4TopVTE = 0;
00127   _FirstKey = "UnDefined";
00128   _NG3Pos = 0;
00129 }  

Generated on Mon May 27 17:47:36 2013 for Geant4 by  doxygen 1.4.7