00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "globals.hh"
00030 #include "G3DetTable.hh"
00031
00032 typedef std::map<G4String, G3DetTableEntry*, std::less<G4String> >
00033 ::iterator DTDiterator;
00034
00035 G4String
00036 G3DetTable::MakeHash(G4String& set, G4String& det){;
00037 return set+" "+det;
00038 }
00039
00040 G3DetTable::G3DetTable(){
00041 }
00042
00043 G3DetTable::~G3DetTable(){
00044 if (DTD.size() > 0) {
00045
00046 for (DTDiterator i=DTD.begin(); i != DTD.end(); i++) {
00047 delete (*i).second;
00048 }
00049 DTD.clear();
00050 }
00051 }
00052
00053 G4VSensitiveDetector*
00054 G3DetTable::GetSD(G4String& set, G4String& det){
00055
00056
00057 const G4String ShashID = MakeHash(set, det);
00058
00059
00060 DTDiterator i = DTD.find(ShashID);
00061 G3DetTableEntry* DTE = (*i).second;
00062 if (DTE != 0) {
00063 return DTE->GetSD();
00064 } else {
00065 return 0;
00066 }
00067 }
00068
00069 G4int
00070 G3DetTable::GetID(G4String& set, G4String& det){
00071
00072
00073 G4String ShashID = MakeHash(set, det);
00074
00075
00076 DTDiterator i = DTD.find(ShashID);
00077 G3DetTableEntry* DTE = (*i).second;
00078 if (DTE != 0) {
00079 return DTE->GetID();
00080 } else {
00081 return 0;
00082 }
00083 }
00084
00085 void
00086 G3DetTable::Put(G4String& set, G4String& det, G4int id,
00087 G4VSensitiveDetector* D){
00088
00089 G4String ShashID = MakeHash(set, det);
00090 G3DetTableEntry* DTE = new G3DetTableEntry(set, det, id, D);
00091 G4cout << "Inserted DTE with id " << ShashID << G4endl;
00092 DTD[ShashID] = DTE;
00093 }
00094
00095 void
00096 G3DetTable::PrintAll(){
00097 if (DTD.size()>0){
00098 G4int count=0;
00099 G4cout << "Dump of DTD - " << DTD.size() << " entries:" << G4endl;
00100 for (DTDiterator i=DTD.begin(); i != DTD.end(); i++) {
00101 count++;
00102 G3DetTableEntry* DTE = (*i).second;
00103 G4cout << "DTD entry " << std::setw(3) << count << " sensitive detector name: "
00104 << DTE->GetSD()->GetName() << G4endl;
00105 }
00106 }
00107 }
00108
00109
00110
00111
00112