diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx index aefc7478944d949c84a20dcfc7d79bed38a17a21..9370663a1c6571f968fca5abcfc6517148f6df84 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx @@ -301,15 +301,15 @@ G4bool LArBarrelPresamplerCalculator::Process(const G4Step* a_step, std::vector< #ifdef DEBUGSTEP ATH_MSG_DEBUG(" set current map for module " << imodule); #endif - m_psmap->SetMap(imodule); - if (!(m_psmap->Map())) { + CurrMap* cm = m_psmap->GetMap(imodule); + if (!cm) { ATH_MSG_INFO(" LArBarrelPresamplerCalculator: cannot get map for module " << imodule); continue; } double current0,current1,current2,gap; // get information from current map - m_psmap->Map()->GetAll(x0,y0,&gap,¤t0,¤t1,¤t2); + cm->GetAll(x0,y0,&gap,¤t0,¤t1,¤t2); #ifdef DEBUGSTEP ATH_MSG_DEBUG(" module,x0,y0,current0 from map " << imodule << " " << x0 << " " << y0 << " " << current0); #endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx index e2dd318920697eced6684b4bf511c9098bd6aa8d..ed4ae3aac4ee369ee4ab4782abbdcf6d9d15c7a6 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx @@ -13,7 +13,6 @@ PsMap* PsMap::s_thePointer=nullptr; PsMap::PsMap() { - m_module=-1; m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; #ifndef LARG4_STAND_ALONE @@ -39,7 +38,6 @@ PsMap::PsMap() int code=imap; m_theMap[code]=cm; } - m_curr=0; } @@ -58,10 +56,8 @@ void PsMap::Reset() } } -void PsMap::SetMap(int module) +CurrMap* PsMap::GetMap(int module) const { - if (m_module==module) return; - m_module=module; // module 0 and 1 have their own maps (code = 0 and 1) // module 2 and 3 have the same map (same geometry) with code 2 // module 4 and 5 have the same map (same geometry) with code 3 @@ -69,11 +65,12 @@ void PsMap::SetMap(int module) int code = -1; if (module==0 || module==1) code=module; if (module > 1 && module < 8) code=(module-2)/2 + 2; - if (m_theMap.find(code) != m_theMap.end()) - m_curr = m_theMap[code]; + auto it = m_theMap.find(code); + if (it != m_theMap.end()) + return it->second; else { - std::cout << " Code " << code << " not found in map ..." << std::endl; - m_curr=0; + std::cout << " Code " << module << " not found in map ..." << std::endl; + return nullptr; } } diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h index f3bec25de942ce32f7cbc5cdb921196802330252..c5962bfc8bc6cf74ca2146adbf40dddcbbd6d5c4 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h @@ -19,15 +19,11 @@ class PsMap { static PsMap* GetPsMap(); void SetDirectory(std::string dir); void Reset(); - void SetMap(int module); - CurrMap* Map() const {return m_curr;} + CurrMap* GetMap (int module) const; private: PsMap(); static PsMap* s_thePointer; curr_map m_theMap; std::string m_directory; -// current map info - CurrMap* m_curr; - int m_module; }; #endif // LARG4BARREL_PsMap_h