Geant4  10.01.p02
G3DetTable.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G3DetTable.cc 67982 2013-03-13 10:36:03Z gcosmo $
28 //
29 #include "globals.hh"
30 #include "G3DetTable.hh"
31 
32 typedef std::map<G4String, G3DetTableEntry*, std::less<G4String> >
33 ::iterator DTDiterator;
34 
35 G4String
37  return set+" "+det;
38 }
39 
41 }
42 
44  if (DTD.size() > 0) {
45  // G4cout << "Deleting DTD" << G4endl;
46  for (DTDiterator i=DTD.begin(); i != DTD.end(); i++) {
47  delete (*i).second;
48  }
49  DTD.clear();
50  }
51 }
52 
55 
56  // make hash ID
57  const G4String ShashID = MakeHash(set, det);
58 
59  // search the map
60  DTDiterator i = DTD.find(ShashID);
61  G3DetTableEntry* DTE = (*i).second;
62  if (DTE != 0) {
63  return DTE->GetSD();
64  } else {
65  return 0;
66  }
67 }
68 
69 G4int
71 
72  // make hash ID
73  G4String ShashID = MakeHash(set, det);
74 
75  // search the Hash Dictionary
76  DTDiterator i = DTD.find(ShashID);
77  G3DetTableEntry* DTE = (*i).second;
78  if (DTE != 0) {
79  return DTE->GetID();
80  } else {
81  return 0;
82  }
83 }
84 
85 void
88  // make hash ID
89  G4String ShashID = MakeHash(set, det);
90  G3DetTableEntry* DTE = new G3DetTableEntry(set, det, id, D);
91  G4cout << "Inserted DTE with id " << ShashID << G4endl;
92  DTD[ShashID] = DTE;
93 }
94 
95 void
97  if (DTD.size()>0){
98  G4int count=0;
99  G4cout << "Dump of DTD - " << DTD.size() << " entries:" << G4endl;
100  for (DTDiterator i=DTD.begin(); i != DTD.end(); i++) {
101  count++;
102  G3DetTableEntry* DTE = (*i).second;
103  G4cout << "DTD entry " << std::setw(3) << count << " sensitive detector name: "
104  << DTE->GetSD()->GetName() << G4endl;
105  }
106  }
107 }
108 
109 
110 
111 
112 
G4VSensitiveDetector * GetSD(G4String &set, G4String &det)
Definition: G3DetTable.cc:54
void PrintAll()
Definition: G3DetTable.cc:96
G4String MakeHash(G4String &set, G4String &det)
Definition: G3DetTable.cc:36
G4VSensitiveDetector * GetSD()
void Put(G4String &set, G4String &det, G4int id, G4VSensitiveDetector *D)
Definition: G3DetTable.cc:86
std::map< G4String, G3DetTableEntry *, std::less< G4String > >::iterator DTDiterator
Definition: G3DetTable.cc:33
Definition: xmlparse.cc:260
G4int GetID(G4String &set, G4String &det)
Definition: G3DetTable.cc:70
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
virtual ~G3DetTable()
Definition: G3DetTable.cc:43
#define G4endl
Definition: G4ios.hh:61
G4int GetID()