diff --git a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h index 403138e1c1b59edeccd611b34bfdf076711c79c0..0ff97dd46335e2d28ce346aa758af71cb4249342 100644 --- a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h +++ b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h @@ -176,10 +176,10 @@ private: void storeBuiltAlignableTransform(GeoAlignableTransform* node); GeoAlignableTransform* getBuiltAlignableTransform(const unsigned int id); - //void storeVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyNumber, GeoGraphNode* node); - //GeoGraphNode* getVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyNumber); - void storeVPhysVol(const unsigned int id, const unsigned int tableId, GeoGraphNode* node); - GeoGraphNode* getVPhysVol(const unsigned int id, const unsigned int tableId); + void storeVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyNumber, GeoGraphNode* node); + GeoGraphNode* getVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyNumber); + //void storeVPhysVol(const unsigned int id, const unsigned int tableId, GeoGraphNode* node); + //GeoGraphNode* getVPhysVol(const unsigned int id, const unsigned int tableId); bool isBuiltLog(const unsigned int id); void storeBuiltLog(GeoLogVol* nodePtr); diff --git a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.tpp b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.tpp index 9e6d1ec7013528725f036c5377537a6faadd4dac..e82300dcd8d3ce63bbefe9b4225c94d72b008c6b 100644 --- a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.tpp +++ b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.tpp @@ -40,7 +40,7 @@ namespace GeoModelIO { ++ii; N volPtr = nullptr; if constexpr ( std::is_same_v<GeoFullPhysVol*, N> ) { - volPtr = dynamic_cast<GeoFullPhysVol*>( getVPhysVol(std::stoul(volID), 2) ); //always table=2, and we should have copyN=1 because FullPhysVols are not sharable + volPtr = dynamic_cast<GeoFullPhysVol*>( getVPhysVol(std::stoul(volID), 2,1) ); //always table=2, and we should have copyN=1 because FullPhysVols are not sharable } else if constexpr ( std::is_same_v<GeoAlignableTransform*, N> ) { volPtr = getBuiltAlignableTransform(std::stoul(volID)); } else { diff --git a/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp b/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp index 768e4706a1a734dbd04bf1e6eb6368799f23c2c1..b82aba4159e28b61f341d3b5543b106dfcf888a1 100644 --- a/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp +++ b/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp @@ -800,16 +800,16 @@ GeoVPhysVol* ReadGeoModel::buildVPhysVolInstance(const unsigned int id, const un } // A - if the instance has been previously built, return that - //if ( nullptr != getVPhysVol(id, tableId, copyN)) { - if ( nullptr != getVPhysVol(id, tableId)) { + if ( nullptr != getVPhysVol(id, tableId, copyN)) { + //if ( nullptr != getVPhysVol(id, tableId)) { if (m_deepDebug) { muxCout.lock(); - //std::cout << "getting the instance volume from memory... Returning: [" << getVPhysVol(id, tableId, copyN) << "] -- logvol: " << ((GeoVPhysVol*)getVPhysVol(id, tableId, copyN))->getLogVol()->getName() << std::endl; - std::cout << "getting the instance volume from memory... Returning: [" << getVPhysVol(id, tableId) << "] -- logvol: " << ((GeoVPhysVol*)getVPhysVol(id, tableId))->getLogVol()->getName() << std::endl; + std::cout << "getting the instance volume from memory... Returning: [" << getVPhysVol(id, tableId, copyN) << "] -- logvol: " << ((GeoVPhysVol*)getVPhysVol(id, tableId, copyN))->getLogVol()->getName() << std::endl; + //std::cout << "getting the instance volume from memory... Returning: [" << getVPhysVol(id, tableId) << "] -- logvol: " << ((GeoVPhysVol*)getVPhysVol(id, tableId))->getLogVol()->getName() << std::endl; muxCout.unlock(); } - //return dynamic_cast<GeoVPhysVol*>(getVPhysVol(id, tableId, copyN)); - return dynamic_cast<GeoVPhysVol*>(getVPhysVol(id, tableId)); + return dynamic_cast<GeoVPhysVol*>(getVPhysVol(id, tableId, copyN)); + //return dynamic_cast<GeoVPhysVol*>(getVPhysVol(id, tableId)); } // B - if not built already, then get the actual volume, @@ -841,8 +841,8 @@ GeoVPhysVol* ReadGeoModel::buildVPhysVolInstance(const unsigned int id, const un std::cout << "ERROR! VPhysVol not found! It should be already built, by now. Exiting...\n"; exit(EXIT_FAILURE); } - //storeVPhysVol(id, tableId, copyN, vol); - storeVPhysVol(id, tableId, vol); + storeVPhysVol(id, tableId, copyN, vol); + //storeVPhysVol(id, tableId, vol); return vol; } @@ -3019,30 +3019,30 @@ GeoSerialTransformer* ReadGeoModel::getBuiltSerialTransformer(const unsigned int */ // --- methods for caching GeoPhysVol/GeoFullPhysVol nodes --- -//std::string getVPhysVolKey(const unsigned int id, const unsigned int tableId, const unsigned int copyNumber) -//{ - //std::string key = std::to_string(id) + ":" + std::to_string(tableId) + ":" + std::to_string(copyNumber); - //return key; -//} -std::string getVPhysVolKey(const unsigned int id, const unsigned int tableId) +std::string getVPhysVolKey(const unsigned int id, const unsigned int tableId, const unsigned int copyNumber) { - std::string key = std::to_string(id) + ":" + std::to_string(tableId); + std::string key = std::to_string(id) + ":" + std::to_string(tableId) + ":" + std::to_string(copyNumber); return key; } -//void ReadGeoModel::storeVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyN, GeoGraphNode* nodePtr) -void ReadGeoModel::storeVPhysVol(const unsigned int id, const unsigned int tableId, GeoGraphNode* nodePtr) +//std::string getVPhysVolKey(const unsigned int id, const unsigned int tableId) +//{ +// std::string key = std::to_string(id) + ":" + std::to_string(tableId); +// return key; +//} +void ReadGeoModel::storeVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyN, GeoGraphNode* nodePtr) +//void ReadGeoModel::storeVPhysVol(const unsigned int id, const unsigned int tableId, GeoGraphNode* nodePtr) { std::lock_guard<std::mutex> lk(muxVPhysVol); - //std::string key = getVPhysVolKey(id, tableId, copyN); - std::string key = getVPhysVolKey(id, tableId); + std::string key = getVPhysVolKey(id, tableId, copyN); + //std::string key = getVPhysVolKey(id, tableId); m_memMap[key] = nodePtr; } -//GeoGraphNode* ReadGeoModel::getVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyN) -GeoGraphNode* ReadGeoModel::getVPhysVol(const unsigned int id, const unsigned int tableId) +GeoGraphNode* ReadGeoModel::getVPhysVol(const unsigned int id, const unsigned int tableId, const unsigned int copyN) +//GeoGraphNode* ReadGeoModel::getVPhysVol(const unsigned int id, const unsigned int tableId) { std::lock_guard<std::mutex> lk(muxVPhysVol); - //std::string key = getVPhysVolKey(id, tableId, copyN); - std::string key = getVPhysVolKey(id, tableId); + std::string key = getVPhysVolKey(id, tableId, copyN); + // std::string key = getVPhysVolKey(id, tableId); if (m_memMap.find(key) == m_memMap.end()) { return nullptr; // if volume is not found in cache }