Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 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 // 7 // >> 8 // $Id: G3VolTable.cc,v 1.19 2000/03/02 17:54:07 gcosmo Exp $ >> 9 // GEANT4 tag $Name: geant4-03-00 $ 27 // 10 // 28 // modified by I.Hrivnacova, 13.10.99 11 // modified by I.Hrivnacova, 13.10.99 29 12 30 #include <iomanip> << 13 #include "g4std/iomanip" 31 #include "globals.hh" 14 #include "globals.hh" 32 #include "G3VolTable.hh" 15 #include "G3VolTable.hh" 33 #include "G3Pos.hh" 16 #include "G3Pos.hh" 34 17 35 typedef std::map<G4String, G3VolTableEntry*, s << 18 typedef G4std::map<G4String, G3VolTableEntry*, G4std::less<G4String> > 36 ::iterator VTDiterator; 19 ::iterator VTDiterator; 37 20 38 G3VolTable::G3VolTable() 21 G3VolTable::G3VolTable() 39 : G3toG4TopVTE(0), _FirstKey("UnDefined"), _ 22 : G3toG4TopVTE(0), _FirstKey("UnDefined"), _NG3Pos(0){ 40 } 23 } 41 24 42 G3VolTable::~G3VolTable(){ 25 G3VolTable::~G3VolTable(){ 43 if (VTD.size()>0){ 26 if (VTD.size()>0){ 44 // G4cout << "Deleting VTD" << G4endl; 27 // G4cout << "Deleting VTD" << G4endl; 45 for (VTDiterator i=VTD.begin(); i != VTD.e 28 for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) { 46 delete (*i).second; 29 delete (*i).second; 47 } 30 } 48 VTD.clear(); 31 VTD.clear(); 49 } 32 } 50 } 33 } 51 34 52 G3VolTableEntry* 35 G3VolTableEntry* 53 G3VolTable::GetVTE(const G4String& Vname) { 36 G3VolTable::GetVTE(const G4String& Vname) { 54 VTDiterator i = VTD.find(Vname); 37 VTDiterator i = VTD.find(Vname); 55 if (i == VTD.end()) return 0; 38 if (i == VTD.end()) return 0; 56 else return (*i).second; 39 else return (*i).second; 57 } 40 } 58 41 59 void 42 void 60 G3VolTable::PrintAll(){ 43 G3VolTable::PrintAll(){ 61 if (VTD.size()){ 44 if (VTD.size()){ 62 G4int i=0; 45 G4int i=0; 63 G4cout << "Dump of VTD - " << VTD.size() < 46 G4cout << "Dump of VTD - " << VTD.size() << " entries:" << G4endl; 64 VTEStat(); 47 VTEStat(); 65 for (VTDiterator v=VTD.begin(); v != VTD.e 48 for (VTDiterator v=VTD.begin(); v != VTD.end(); v++){ 66 G3VolTableEntry* VTE = (*v).second; 49 G3VolTableEntry* VTE = (*v).second; 67 G4cout << "G3VolTable element " << std:: << 50 G4cout << "G3VolTable element " << G4std::setw(3) << i++ << " name " 68 << VTE->GetName() << " has " << VTE->Ge 51 << VTE->GetName() << " has " << VTE->GetNoDaughters() 69 << " daughters" << G4endl; 52 << " daughters" << G4endl; 70 } 53 } 71 } 54 } 72 } 55 } 73 56 74 G3VolTableEntry* 57 G3VolTableEntry* 75 G3VolTable::PutVTE(G3VolTableEntry* aG3VolTabl 58 G3VolTable::PutVTE(G3VolTableEntry* aG3VolTableEntry){ 76 59 77 if (GetVTE(aG3VolTableEntry->GetName()) == 0 60 if (GetVTE(aG3VolTableEntry->GetName()) == 0 ){ 78 61 79 // create a hash key 62 // create a hash key 80 G4String HashID = aG3VolTableEntry->GetNam 63 G4String HashID = aG3VolTableEntry->GetName(); 81 64 82 if (_FirstKey == "UnDefined") _FirstKey = 65 if (_FirstKey == "UnDefined") _FirstKey = HashID; 83 66 84 // insert into dictionary 67 // insert into dictionary 85 VTD[HashID] = aG3VolTableEntry; 68 VTD[HashID] = aG3VolTableEntry; 86 } 69 } 87 return GetVTE(aG3VolTableEntry->GetName()); 70 return GetVTE(aG3VolTableEntry->GetName()); 88 } 71 } 89 72 90 void 73 void 91 G3VolTable::CountG3Pos(){ 74 G3VolTable::CountG3Pos(){ 92 _NG3Pos++; 75 _NG3Pos++; 93 } 76 } 94 77 95 void 78 void 96 G3VolTable::SetFirstVTE(){ 79 G3VolTable::SetFirstVTE(){ 97 G3toG4TopVTE = VTD[_FirstKey]; 80 G3toG4TopVTE = VTD[_FirstKey]; 98 81 99 if (G3toG4TopVTE->NPCopies() > 0) { 82 if (G3toG4TopVTE->NPCopies() > 0) { 100 _FirstKey = G3toG4TopVTE->GetMother()->Get 83 _FirstKey = G3toG4TopVTE->GetMother()->GetName(); 101 SetFirstVTE(); 84 SetFirstVTE(); 102 } 85 } 103 } 86 } 104 87 105 G3VolTableEntry* 88 G3VolTableEntry* 106 G3VolTable::GetFirstVTE() { 89 G3VolTable::GetFirstVTE() { 107 return G3toG4TopVTE; 90 return G3toG4TopVTE; 108 } 91 } 109 92 110 void 93 void 111 G3VolTable::VTEStat() { 94 G3VolTable::VTEStat() { 112 G4cout << "Instantiated " << VTD.size() << 95 G4cout << "Instantiated " << VTD.size() << 113 " volume table entries \n" 96 " volume table entries \n" 114 << " " << _NG3Pos << " 97 << " " << _NG3Pos << " positions." << G4endl; 115 } 98 } 116 99 117 void 100 void 118 G3VolTable::Clear() { 101 G3VolTable::Clear() { 119 if (VTD.size()>0){ 102 if (VTD.size()>0){ 120 for (VTDiterator i=VTD.begin(); i != VTD.e 103 for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) { 121 delete (*i).second; 104 delete (*i).second; 122 } 105 } 123 VTD.clear(); 106 VTD.clear(); 124 } 107 } 125 G3toG4TopVTE = 0; 108 G3toG4TopVTE = 0; 126 _FirstKey = "UnDefined"; 109 _FirstKey = "UnDefined"; 127 _NG3Pos = 0; 110 _NG3Pos = 0; 128 } 111 } 129 112