From 1617d9faf8c2ae2a3e616c6abb5e5986a50425e6 Mon Sep 17 00:00:00 2001 From: morsch Date: Fri, 6 Dec 2002 12:19:01 +0000 Subject: [PATCH] Mapping between fluka regions and VirtualMC media improved. --- Flugg/FGeometryInit.cxx | 49 ++++++++++++++++++++++++++++++++++++----- Flugg/FGeometryInit.hh | 13 ++++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Flugg/FGeometryInit.cxx b/Flugg/FGeometryInit.cxx index 86961f5ac7f..6d44811bf3e 100644 --- a/Flugg/FGeometryInit.cxx +++ b/Flugg/FGeometryInit.cxx @@ -385,18 +385,55 @@ void FGeometryInit::PrintRegionsMap(G4std::ostream& os) { } //////////////////////////////////////////////////////////////////////// -// -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; } diff --git a/Flugg/FGeometryInit.hh b/Flugg/FGeometryInit.hh index bbd97591fcd..8c505748712 100644 --- a/Flugg/FGeometryInit.hh +++ b/Flugg/FGeometryInit.hh @@ -68,8 +68,11 @@ public: 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(); @@ -102,8 +105,12 @@ private: G4TouchableHistory * ptrTempNavHist; G4int * ptrJrLtGeant; G4int flagLttcGeant; - + G4int fNRegions; + int* fRegionMediumMap; + G4std::map > fRegionVolumeMap; + G4std::map > fMediumVolumeMap; + G4std::map > G4FlukaMaterialMap; G4std::map > G4FlukaCompoundMap; //G4int NOfMaterials; -- 2.43.0