}
////////////////////////////////////////////////////////////////////////
-//
-G4int FGeometryInit::GetRegionFromName(const char* volName) const {
+//
+void FGeometryInit::BuildMediaMap()
+{
+ fRegionMediumMap = new int[fNRegions+1];
+ for (RegionIterator i = fRegionVolumeMap.begin();
+ i != fRegionVolumeMap.end();
+ i++) {
+ //Get info in the map
+ G4VPhysicalVolume* ptrVol = (*i).first;
+ int region = (*i).second;
+ G4int imed = fMediumVolumeMap[ptrVol];
+ fRegionMediumMap[region] = imed;
+ printf("BuildMediaMap %s %d %d\n",(ptrVol->GetName()).data(), region, imed);
+
+ }
+}
+
+G4int FGeometryInit::GetMedium(int region) const
+{
+ return fRegionMediumMap[region];
+}
+
+
+void FGeometryInit::SetMediumFromName(const char* volName, int medium)
+ {
+ char name4[5];
+ char tmp[5];
+ strncpy(tmp, volName, 4);
+ tmp[4]='\0';
+ fNRegions = 0;
+
for (RegionIterator i = fRegionVolumeMap.begin();
i != fRegionVolumeMap.end();
i++) {
-
+ fNRegions++;
//Get info in the map
G4VPhysicalVolume* ptrVol = (*i).first;
- if (ptrVol->GetName() == volName)
- return ((*i).second);
+ strncpy(name4, (ptrVol->GetName()).data(), 4);
+ name4[4]='\0';
+ for (int j = 0; j < 4; j++) {
+ if (name4[j] == '\0') {
+ for (int k = j; k < 4; k++) {
+ name4[k] = ' ';
+ }
+ break;
+ }
+ }
+ if (! strncmp(name4, tmp, 4)) fMediumVolumeMap[ptrVol] = medium;
}
- return -1;
}
void PrintJrLtGeant();
//Map access methods
- G4int GetRegionFromName(const char* volName) const;
-
+ void BuildMediaMap();
+ void SetMediumFromName(const char* volName, int med);
+ //G4int GetRegionFromName(const char* volName) const;
+ G4int GetMedium(int) const;
+
protected:
void BuildRegionsMap();
G4TouchableHistory * ptrTempNavHist;
G4int * ptrJrLtGeant;
G4int flagLttcGeant;
-
+ G4int fNRegions;
+ int* fRegionMediumMap;
+
G4std::map<G4VPhysicalVolume*, int, G4std::less<G4VPhysicalVolume*> > fRegionVolumeMap;
+ G4std::map<G4VPhysicalVolume*, int, G4std::less<G4VPhysicalVolume*> > fMediumVolumeMap;
+
G4std::map<G4Material*, FlukaMaterial*, G4std::less<G4Material*> > G4FlukaMaterialMap;
G4std::map<G4Material*, FlukaCompound*, G4std::less<G4Material*> > G4FlukaCompoundMap;
//G4int NOfMaterials;