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
00030
00031
00032
00033
00034
00035
00036 #include "G4IStore.hh"
00037 #include "G4VPhysicalVolume.hh"
00038 #include "G4GeometryCell.hh"
00039 #include "G4GeometryCellStepStream.hh"
00040 #include "G4LogicalVolume.hh"
00041
00042 G4IStore::G4IStore(const G4VPhysicalVolume &worldvolume) :
00043 fWorldVolume(worldvolume)
00044 {}
00045
00046 G4IStore::~G4IStore()
00047 {}
00048
00049 const G4VPhysicalVolume &G4IStore::GetWorldVolume() const
00050 {
00051 return fWorldVolume;
00052 }
00053
00054 void G4IStore::SetInternalIterator(const G4GeometryCell &gCell) const
00055 {
00056 fCurrentIterator = fGeometryCelli.find(gCell);
00057 }
00058
00059 void G4IStore::AddImportanceGeometryCell(G4double importance,
00060 const G4GeometryCell &gCell){
00061 if (importance < 0 ) {
00062 Error("AddImportanceGeometryCell() - Invalid importance value given.");
00063 }
00064 if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
00065 Error("AddImportanceGeometryCell() - Physical volume not found!");
00066 }
00067 SetInternalIterator(gCell);
00068 if (fCurrentIterator!=fGeometryCelli.end()) {
00069 Error("AddImportanceGeometryCell() - Region already existing!");
00070 }
00071 fGeometryCelli[gCell] = importance;
00072 }
00073
00074 void G4IStore::AddImportanceGeometryCell(G4double importance,
00075 const G4VPhysicalVolume &aVolume,
00076 G4int aRepNum)
00077 {
00078 AddImportanceGeometryCell(importance,
00079 G4GeometryCell(aVolume, aRepNum));
00080 }
00081
00082 void G4IStore::ChangeImportance(G4double importance,
00083 const G4GeometryCell &gCell){
00084 if (importance < 0 ) {
00085 Error("ChangeImportance() - Invalid importance value given.");
00086 }
00087 if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
00088 Error("ChangeImportance() - Physical volume not found!");
00089 }
00090 SetInternalIterator(gCell);
00091 if (fCurrentIterator==fGeometryCelli.end()) {
00092 Error("ChangeImportance() - Region does not exist!");
00093 }
00094 fGeometryCelli[gCell] = importance;
00095
00096 }
00097 void G4IStore::ChangeImportance(G4double importance,
00098 const G4VPhysicalVolume &aVolume,
00099 G4int aRepNum)
00100 {
00101 ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
00102 }
00103
00104 G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
00105 G4int aRepNum) const
00106 {
00107 SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
00108 G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
00109 if (gCellIterator==fGeometryCelli.end()) {
00110 Error("GetImportance() - Region does not exist!");
00111 return 0.;
00112 }
00113 return (*fCurrentIterator).second;
00114 }
00115
00116
00117 G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
00118 {
00119 SetInternalIterator(gCell);
00120 G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
00121 if (gCellIterator==fGeometryCelli.end()) {
00122 std::ostringstream err_mess;
00123 err_mess << "GetImportance() - Region does not exist!" << G4endl
00124 << "Geometry cell, " << gCell
00125 << ", not found in: " << fGeometryCelli << ".";
00126 Error(err_mess.str());
00127 return 0.;
00128 }
00129 return (*fCurrentIterator).second;
00130 }
00131
00132 G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
00133 G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
00134
00135 if ( inWorldKnown ) {
00136 SetInternalIterator(gCell);
00137 inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
00138 }
00139 return inWorldKnown;
00140 }
00141
00142 G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
00143 {
00144 G4bool isIn(true);
00145 if (!(aVolume == fWorldVolume)) {
00146 isIn = fWorldVolume.GetLogicalVolume()->IsAncestor(&aVolume);
00147 }
00148 return isIn;
00149 }
00150
00151
00152
00153 void G4IStore::Error(const G4String &msg) const
00154 {
00155 G4Exception("G4IStore::Error()", "GeomBias0002", FatalException, msg);
00156 }