From cfcd19a920208b1048237617f484d30f8ccac6c3 Mon Sep 17 00:00:00 2001
From: Soshi Tsuno <soshi.tsuno@cern.ch>
Date: Fri, 9 Apr 2021 15:07:50 +0200
Subject: [PATCH] Update memory consumption (ATLASRECTS-6170)

---
 .../src/PixelConfigCondAlg.cxx                | 73 +++++++++-----
 .../src/PixelConfigCondAlg.h                  |  4 +
 .../PixelConditionsData/PixelModuleData.h     | 63 ------------
 .../PixelRadiationDamageFluenceMapData.h      | 99 +++++++++++++++++++
 .../src/PixelModuleData.cxx                   | 42 --------
 .../PixelRadiationDamageFluenceMapData.cxx    | 86 ++++++++++++++++
 .../src/PixelDigitizationTool.cxx             |  6 +-
 .../src/PixelDigitizationTool.h               |  4 -
 .../PixelDigitization/src/SensorSim3DTool.cxx | 24 ++---
 .../PixelDigitization/src/SensorSim3DTool.h   |  1 -
 .../src/SensorSimPlanarTool.cxx               | 15 +--
 .../src/SensorSimPlanarTool.h                 |  1 -
 .../PixelDigitization/src/SensorSimTool.h     | 14 ++-
 13 files changed, 269 insertions(+), 163 deletions(-)
 create mode 100644 InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelRadiationDamageFluenceMapData.h
 create mode 100644 InnerDetector/InDetConditions/PixelConditionsData/src/PixelRadiationDamageFluenceMapData.cxx

diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx
index 7d6faad1a2a..4b6d6a041cf 100644
--- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx
+++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx
@@ -39,6 +39,11 @@ StatusCode PixelConfigCondAlg::initialize() {
     ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc");
     return StatusCode::FAILURE;
   }
+  ATH_CHECK(m_writeFluenceMapKey.initialize());
+  if (m_condSvc->regHandle(this,m_writeFluenceMapKey).isFailure()) {
+    ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeFluenceMapKey.fullKey() << " with CondSvc");
+    return StatusCode::FAILURE;
+  }
 
   return StatusCode::SUCCESS;
 }
@@ -52,8 +57,15 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     return StatusCode::SUCCESS; 
   }
 
+  SG::WriteCondHandle<PixelRadiationDamageFluenceMapData> writeFluenceMapHandle(m_writeFluenceMapKey, ctx);
+  if (writeFluenceMapHandle.isValid()) {
+    ATH_MSG_DEBUG("CondHandle " << writeFluenceMapHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
+    return StatusCode::SUCCESS; 
+  }
+
   // Construct the output Cond Object and fill it in
   std::unique_ptr<PixelModuleData> writeCdo(std::make_unique<PixelModuleData>());
+  std::unique_ptr<PixelRadiationDamageFluenceMapData> writeFluenceCdo(std::make_unique<PixelRadiationDamageFluenceMapData>());
 
   const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT,                     0,                       
                                               0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
@@ -65,6 +77,8 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
   //==============
   EventIDRange rangeDeadMap{start, stop};
   if (!m_readDeadMapKey.empty()) {
+    ATH_MSG_INFO("Obsolate!! It shouldn't be called here..." << m_readDeadMapKey.key());
+
     SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readDeadMapKey, ctx);
     const CondAttrListCollection* readCdo = *readHandle; 
     if (readCdo==nullptr) {
@@ -210,7 +224,7 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     }
 
     // Radiation damage simulation
-    writeCdo -> setFluenceLayer(m_BarrelFluenceRUN1);
+    writeFluenceCdo -> setFluenceLayer(m_BarrelFluenceRUN1);
     for (size_t i=0; i<m_BarrelFluenceMapRUN1.size(); i++) {
       mapsPath_list.push_back(PathResolverFindCalibFile(m_BarrelFluenceMapRUN1[i]));
     }
@@ -270,13 +284,13 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     }
 
     // Radiation damage simulation
-    writeCdo -> setFluenceLayer(m_BarrelFluence2016);
+    writeFluenceCdo -> setFluenceLayer(m_BarrelFluence2016);
     for (size_t i=0; i<m_BarrelFluenceMap2016.size(); i++) {
       mapsPath_list.push_back(PathResolverFindCalibFile(m_BarrelFluenceMap2016[i]));
     }
 
     // Radiation damage simulation for 3D sensor
-    writeCdo -> setFluenceLayer3D(m_3DFluence2016);
+    writeFluenceCdo -> setFluenceLayer3D(m_3DFluence2016);
     for (size_t i=0; i<m_3DFluenceMap2016.size(); i++) {
       mapsPath_list3D.push_back(PathResolverFindCalibFile(m_3DFluenceMap2016[i]));
     }
@@ -309,13 +323,13 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     }
 
     // Radiation damage simulation
-    writeCdo -> setFluenceLayer(m_BarrelFluenceITK);
+    writeFluenceCdo -> setFluenceLayer(m_BarrelFluenceITK);
     for (size_t i=0; i<m_BarrelFluenceMapITK.size(); i++) {
       mapsPath_list.push_back(PathResolverFindCalibFile(m_BarrelFluenceMapITK[i]));
     }
 
     // Radiation damage simulation for 3D sensor
-    writeCdo -> setFluenceLayer3D(m_3DFluenceITK);
+    writeFluenceCdo -> setFluenceLayer3D(m_3DFluenceITK);
     for (size_t i=0; i<m_3DFluenceMapITK.size(); i++) {
       mapsPath_list3D.push_back(PathResolverFindCalibFile(m_3DFluenceMapITK[i]));
     }
@@ -366,13 +380,13 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     }
 
     // Radiation damage simulation
-    writeCdo -> setFluenceLayer(m_BarrelFluence2016);
+    writeFluenceCdo -> setFluenceLayer(m_BarrelFluence2016);
     for (size_t i=0; i<m_BarrelFluenceMap2016.size(); i++) {
       mapsPath_list.push_back(PathResolverFindCalibFile(m_BarrelFluenceMap2016[i]));
     }
 
     // Radiation damage simulation for 3D sensor
-    writeCdo -> setFluenceLayer3D(m_3DFluence2016);
+    writeFluenceCdo -> setFluenceLayer3D(m_3DFluence2016);
     for (size_t i=0; i<m_3DFluenceMap2016.size(); i++) {
       mapsPath_list3D.push_back(PathResolverFindCalibFile(m_3DFluenceMap2016[i]));
     }
@@ -423,13 +437,13 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     }
 
     // Radiation damage simulation
-    writeCdo -> setFluenceLayer(m_BarrelFluence2017);
+    writeFluenceCdo -> setFluenceLayer(m_BarrelFluence2017);
     for (size_t i=0; i<m_BarrelFluenceMap2017.size(); i++) {
       mapsPath_list.push_back(PathResolverFindCalibFile(m_BarrelFluenceMap2017[i]));
     }
 
     // Radiation damage simulation for 3D sensor
-    writeCdo -> setFluenceLayer3D(m_3DFluence2017);
+    writeFluenceCdo -> setFluenceLayer3D(m_3DFluence2017);
     for (size_t i=0; i<m_3DFluenceMap2017.size(); i++) {
       mapsPath_list3D.push_back(PathResolverFindCalibFile(m_3DFluenceMap2017[i]));
     }
@@ -480,13 +494,13 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
     }
 
     // Radiation damage simulation
-    writeCdo -> setFluenceLayer(m_BarrelFluence2018);
+    writeFluenceCdo -> setFluenceLayer(m_BarrelFluence2018);
     for (size_t i=0; i<m_BarrelFluenceMap2018.size(); i++) {
       mapsPath_list.push_back(PathResolverFindCalibFile(m_BarrelFluenceMap2018[i]));
     }
 
     // Radiation damage simulation for 3D sensor
-    writeCdo -> setFluenceLayer3D(m_3DFluence2018);
+    writeFluenceCdo -> setFluenceLayer3D(m_3DFluence2018);
     for (size_t i=0; i<m_3DFluenceMap2018.size(); i++) {
       mapsPath_list3D.push_back(PathResolverFindCalibFile(m_3DFluenceMap2018[i]));
     }
@@ -547,11 +561,11 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
 
     mapsFile->Close();
   }
-  writeCdo -> setLorentzMap_e(lorentzMap_e);
-  writeCdo -> setLorentzMap_h(lorentzMap_h);
-  writeCdo -> setDistanceMap_e(distanceMap_e);
-  writeCdo -> setDistanceMap_h(distanceMap_h);
-  writeCdo -> setRamoPotentialMap(ramoPotentialMap);
+  writeFluenceCdo -> setLorentzMap_e(lorentzMap_e);
+  writeFluenceCdo -> setLorentzMap_h(lorentzMap_h);
+  writeFluenceCdo -> setDistanceMap_e(distanceMap_e);
+  writeFluenceCdo -> setDistanceMap_h(distanceMap_h);
+  writeFluenceCdo -> setRamoPotentialMap(ramoPotentialMap);
 
   // Create mapping file for radiation damage simulation for 3D sensor
   std::vector<PixelHistoConverter> ramoPotentialMap3D;
@@ -639,17 +653,16 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
 
     mapsFile3D->Close();
   }
-
-  writeCdo -> setRamoPotentialMap3D(ramoPotentialMap3D);
-  writeCdo -> setEFieldMap3D(eFieldMap3D);
-  writeCdo -> setXPositionMap3D_e(xPositionMap3D_e);
-  writeCdo -> setXPositionMap3D_h(xPositionMap3D_h);
-  writeCdo -> setYPositionMap3D_e(yPositionMap3D_e);
-  writeCdo -> setYPositionMap3D_h(yPositionMap3D_h);
-  writeCdo -> setTimeMap3D_e(timeMap3D_e);
-  writeCdo -> setTimeMap3D_h(timeMap3D_h);
-  writeCdo -> setAvgChargeMap3D_e(avgChargeMap3D_e);
-  writeCdo -> setAvgChargeMap3D_h(avgChargeMap3D_h);
+  writeFluenceCdo -> setRamoPotentialMap3D(ramoPotentialMap3D);
+  writeFluenceCdo -> setEFieldMap3D(eFieldMap3D);
+  writeFluenceCdo -> setXPositionMap3D_e(xPositionMap3D_e);
+  writeFluenceCdo -> setXPositionMap3D_h(xPositionMap3D_h);
+  writeFluenceCdo -> setYPositionMap3D_e(yPositionMap3D_e);
+  writeFluenceCdo -> setYPositionMap3D_h(yPositionMap3D_h);
+  writeFluenceCdo -> setTimeMap3D_e(timeMap3D_e);
+  writeFluenceCdo -> setTimeMap3D_h(timeMap3D_h);
+  writeFluenceCdo -> setAvgChargeMap3D_e(avgChargeMap3D_e);
+  writeFluenceCdo -> setAvgChargeMap3D_h(avgChargeMap3D_h);
 
   //=======================
   // Combine time interval
@@ -668,6 +681,12 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
   }
   ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
 
+  if (writeFluenceMapHandle.record(rangeW, std::move(writeFluenceCdo)).isFailure()) {
+    ATH_MSG_FATAL("Could not record PixelRadiationDamageFluenceMapData " << writeFluenceMapHandle.key() << " with EventRange " << rangeW << " into Conditions Store");
+    return StatusCode::FAILURE;
+  }
+  ATH_MSG_INFO("recorded new CDO " << writeFluenceMapHandle.key() << " with range " << rangeW << " into Conditions Store");
+
   return StatusCode::SUCCESS;
 }
 
diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h
index c68e11312ba..cfeed6a7f23 100644
--- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h
+++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h
@@ -20,6 +20,7 @@
 
 #include "StoreGate/WriteCondHandleKey.h"
 #include "PixelConditionsData/PixelModuleData.h"
+#include "PixelConditionsData/PixelRadiationDamageFluenceMapData.h"
 
 #include "GaudiKernel/ICondSvc.h"
 #include "Gaudi/Property.h"
@@ -37,6 +38,9 @@ class PixelConfigCondAlg : public AthReentrantAlgorithm {
     SG::WriteCondHandleKey<PixelModuleData> m_writeKey
     {this, "WriteKey", "PixelModuleData", "Output key of pixel module data"};
 
+    SG::WriteCondHandleKey<PixelRadiationDamageFluenceMapData> m_writeFluenceMapKey
+    {this, "WriteRadiationFluenceMapKey", "PixelRadiationDamageFluenceMapData", "Output key for radiation damage fluence map"};
+
     // Digitization parameters
     Gaudi::Property<double> m_bunchSpace
     {this, "BunchSpace", 25.0, "Bunch space [ns]"};
diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h
index 80dd8c1827e..be9c5aa6222 100644
--- a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h
+++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h
@@ -164,50 +164,6 @@ class PixelModuleData {
     void setCablingMapFileName(std::string cablingMapFileName);
     std::string getCablingMapFileName() const;
 
-    // Map for radiation damage simulation
-    void setFluenceLayer(std::vector<double> fluenceLayer);
-    double getFluenceLayer(int layer) const;
-
-    void setLorentzMap_e(std::vector<PixelHistoConverter> lorentzMap_e);
-    void setLorentzMap_h(std::vector<PixelHistoConverter> lorentzMap_h);
-    void setDistanceMap_e(std::vector<PixelHistoConverter> distanceMap_e);
-    void setDistanceMap_h(std::vector<PixelHistoConverter> distanceMap_h);
-    void setRamoPotentialMap(std::vector<PixelHistoConverter> ramoPotentialMap);
-
-    const PixelHistoConverter& getLorentzMap_e(int layer) const;
-    const PixelHistoConverter& getLorentzMap_h(int layer) const;
-    const PixelHistoConverter& getDistanceMap_e(int layer) const;
-    const PixelHistoConverter& getDistanceMap_h(int layer) const;
-    const PixelHistoConverter& getRamoPotentialMap(int layer) const;
-
-    // Map for radiation damage simulation for 3D sensor
-    // The implementation for 3D radiation damage is different from the one for planar sensor.
-    // Thus, define separately. In future, coherent treatment is preferrable.
-    void setFluenceLayer3D(std::vector<double> fluenceLayer);
-    double getFluenceLayer3D(int layer) const;
-
-    void setRamoPotentialMap3D(std::vector<PixelHistoConverter> ramoPotentialMap3D);
-    void setEFieldMap3D(std::vector<PixelHistoConverter> eFieldMap3D);
-    void setXPositionMap3D_e(std::vector<PixelHistoConverter> xPositionMap3D_e);
-    void setXPositionMap3D_h(std::vector<PixelHistoConverter> xPositionMap3D_h);
-    void setYPositionMap3D_e(std::vector<PixelHistoConverter> yPositionMap3D_e);
-    void setYPositionMap3D_h(std::vector<PixelHistoConverter> yPositionMap3D_h);
-    void setTimeMap3D_e(std::vector<PixelHistoConverter> timeMap3D_e);
-    void setTimeMap3D_h(std::vector<PixelHistoConverter> timeMap3D_h);
-    void setAvgChargeMap3D_e(PixelHistoConverter avgChargeMap3D_e);
-    void setAvgChargeMap3D_h(PixelHistoConverter avgChargeMap3D_h);
-
-    const PixelHistoConverter& getRamoPotentialMap3D(int layer) const;
-    const PixelHistoConverter& getEFieldMap3D(int layer) const;
-    const PixelHistoConverter& getXPositionMap3D_e(int layer) const;
-    const PixelHistoConverter& getXPositionMap3D_h(int layer) const;
-    const PixelHistoConverter& getYPositionMap3D_e(int layer) const;
-    const PixelHistoConverter& getYPositionMap3D_h(int layer) const;
-    const PixelHistoConverter& getTimeMap3D_e(int layer) const;
-    const PixelHistoConverter& getTimeMap3D_h(int layer) const;
-    const PixelHistoConverter& getAvgChargeMap3D_e() const;
-    const PixelHistoConverter& getAvgChargeMap3D_h() const;
-
     // Distortion parameters
     void setDistortionInputSource(int distortionInputSource);
     int getDistortionInputSource() const;
@@ -329,25 +285,6 @@ class PixelModuleData {
     bool        m_cablingMapToFile;
     std::string m_cablingMapFileName;
 
-    std::vector<double> m_fluenceLayer;
-    std::vector<PixelHistoConverter> m_lorentzMap_e;
-    std::vector<PixelHistoConverter> m_lorentzMap_h;
-    std::vector<PixelHistoConverter> m_distanceMap_e;
-    std::vector<PixelHistoConverter> m_distanceMap_h;
-    std::vector<PixelHistoConverter> m_ramoPotentialMap;
-
-    std::vector<double> m_fluenceLayer3D;
-    std::vector<PixelHistoConverter> m_ramoPotentialMap3D;
-    std::vector<PixelHistoConverter> m_eFieldMap3D;
-    std::vector<PixelHistoConverter> m_xPositionMap3D_e;
-    std::vector<PixelHistoConverter> m_xPositionMap3D_h;
-    std::vector<PixelHistoConverter> m_yPositionMap3D_e;
-    std::vector<PixelHistoConverter> m_yPositionMap3D_h;
-    std::vector<PixelHistoConverter> m_timeMap3D_e;
-    std::vector<PixelHistoConverter> m_timeMap3D_h;
-    PixelHistoConverter m_avgChargeMap3D_e;
-    PixelHistoConverter m_avgChargeMap3D_h;
-
     int    m_distortionInputSource;
     int    m_distortionVersion;
     double m_distortionR1;
diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelRadiationDamageFluenceMapData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelRadiationDamageFluenceMapData.h
new file mode 100644
index 00000000000..b895ab5045e
--- /dev/null
+++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelRadiationDamageFluenceMapData.h
@@ -0,0 +1,99 @@
+/*
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+*/
+/**
+ * @file PixelConditionsData/PixelRadiationDamageFluenceMapData.h
+ * @author Soshi Tsuno <Soshi.Tsuno@cern.ch>
+ * @date November, 2019
+ * @brief Store pixel constant parameters in PixelRadiationDamageFluenceMapData.
+ */
+
+#ifndef PIXELRADIATIONDAMAGEFLUENCEMAPDATA_H
+#define PIXELRADIATIONDAMAGEFLUENCEMAPDATA_H
+
+#include "AthenaKernel/CLASS_DEF.h"
+#include <map>
+
+#include "AthenaKernel/CondCont.h"
+#include "PixelConditionsData/PixelHistoConverter.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "TH3.h"
+
+class PixelRadiationDamageFluenceMapData {
+  public:
+    PixelRadiationDamageFluenceMapData();
+    virtual ~PixelRadiationDamageFluenceMapData();
+
+    // Map for radiation damage simulation
+    void setFluenceLayer(std::vector<double> fluenceLayer);
+    double getFluenceLayer(int layer) const;
+
+    void setLorentzMap_e(std::vector<PixelHistoConverter> lorentzMap_e);
+    void setLorentzMap_h(std::vector<PixelHistoConverter> lorentzMap_h);
+    void setDistanceMap_e(std::vector<PixelHistoConverter> distanceMap_e);
+    void setDistanceMap_h(std::vector<PixelHistoConverter> distanceMap_h);
+    void setRamoPotentialMap(std::vector<PixelHistoConverter> ramoPotentialMap);
+
+    const PixelHistoConverter& getLorentzMap_e(int layer) const;
+    const PixelHistoConverter& getLorentzMap_h(int layer) const;
+    const PixelHistoConverter& getDistanceMap_e(int layer) const;
+    const PixelHistoConverter& getDistanceMap_h(int layer) const;
+    const PixelHistoConverter& getRamoPotentialMap(int layer) const;
+
+    // Map for radiation damage simulation for 3D sensor
+    // The implementation for 3D radiation damage is different from the one for planar sensor.
+    // Thus, define separately. In future, coherent treatment is preferrable.
+    void setFluenceLayer3D(std::vector<double> fluenceLayer);
+    double getFluenceLayer3D(int layer) const;
+
+    void setRamoPotentialMap3D(std::vector<PixelHistoConverter> ramoPotentialMap3D);
+    void setEFieldMap3D(std::vector<PixelHistoConverter> eFieldMap3D);
+    void setXPositionMap3D_e(std::vector<PixelHistoConverter> xPositionMap3D_e);
+    void setXPositionMap3D_h(std::vector<PixelHistoConverter> xPositionMap3D_h);
+    void setYPositionMap3D_e(std::vector<PixelHistoConverter> yPositionMap3D_e);
+    void setYPositionMap3D_h(std::vector<PixelHistoConverter> yPositionMap3D_h);
+    void setTimeMap3D_e(std::vector<PixelHistoConverter> timeMap3D_e);
+    void setTimeMap3D_h(std::vector<PixelHistoConverter> timeMap3D_h);
+    void setAvgChargeMap3D_e(PixelHistoConverter avgChargeMap3D_e);
+    void setAvgChargeMap3D_h(PixelHistoConverter avgChargeMap3D_h);
+
+    const PixelHistoConverter& getRamoPotentialMap3D(int layer) const;
+    const PixelHistoConverter& getEFieldMap3D(int layer) const;
+    const PixelHistoConverter& getXPositionMap3D_e(int layer) const;
+    const PixelHistoConverter& getXPositionMap3D_h(int layer) const;
+    const PixelHistoConverter& getYPositionMap3D_e(int layer) const;
+    const PixelHistoConverter& getYPositionMap3D_h(int layer) const;
+    const PixelHistoConverter& getTimeMap3D_e(int layer) const;
+    const PixelHistoConverter& getTimeMap3D_h(int layer) const;
+    const PixelHistoConverter& getAvgChargeMap3D_e() const;
+    const PixelHistoConverter& getAvgChargeMap3D_h() const;
+
+    void clear();
+
+  private:
+    std::vector<double> m_fluenceLayer;
+    std::vector<PixelHistoConverter> m_lorentzMap_e;
+    std::vector<PixelHistoConverter> m_lorentzMap_h;
+    std::vector<PixelHistoConverter> m_distanceMap_e;
+    std::vector<PixelHistoConverter> m_distanceMap_h;
+    std::vector<PixelHistoConverter> m_ramoPotentialMap;
+
+    std::vector<double> m_fluenceLayer3D;
+    std::vector<PixelHistoConverter> m_ramoPotentialMap3D;
+    std::vector<PixelHistoConverter> m_eFieldMap3D;
+    std::vector<PixelHistoConverter> m_xPositionMap3D_e;
+    std::vector<PixelHistoConverter> m_xPositionMap3D_h;
+    std::vector<PixelHistoConverter> m_yPositionMap3D_e;
+    std::vector<PixelHistoConverter> m_yPositionMap3D_h;
+    std::vector<PixelHistoConverter> m_timeMap3D_e;
+    std::vector<PixelHistoConverter> m_timeMap3D_h;
+    PixelHistoConverter m_avgChargeMap3D_e;
+    PixelHistoConverter m_avgChargeMap3D_h;
+};
+
+CLASS_DEF( PixelRadiationDamageFluenceMapData , 71942873 , 1 )
+
+CONDCONT_DEF( PixelRadiationDamageFluenceMapData, 71948393 );
+
+#endif
diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx
index d5fd5dc462e..e4ed7278f0d 100644
--- a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx
+++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx
@@ -315,48 +315,6 @@ bool PixelModuleData::getCablingMapToFile() const { return m_cablingMapToFile; }
 void PixelModuleData::setCablingMapFileName(std::string cablingMapFileName) { m_cablingMapFileName = cablingMapFileName; }
 std::string PixelModuleData::getCablingMapFileName() const { return m_cablingMapFileName; }
 
-// Map for radiation damage simulation
-void PixelModuleData::setFluenceLayer(std::vector<double> fluenceLayer) { m_fluenceLayer = fluenceLayer; }
-double PixelModuleData::getFluenceLayer(int layer) const { return m_fluenceLayer.at(layer); }
-
-void PixelModuleData::setLorentzMap_e(std::vector<PixelHistoConverter> lorentzMap_e) { m_lorentzMap_e = lorentzMap_e; }
-void PixelModuleData::setLorentzMap_h(std::vector<PixelHistoConverter> lorentzMap_h) { m_lorentzMap_h = lorentzMap_h; }
-void PixelModuleData::setDistanceMap_e(std::vector<PixelHistoConverter> distanceMap_e) { m_distanceMap_e = distanceMap_e; }
-void PixelModuleData::setDistanceMap_h(std::vector<PixelHistoConverter> distanceMap_h) { m_distanceMap_h = distanceMap_h; }
-void PixelModuleData::setRamoPotentialMap(std::vector<PixelHistoConverter> ramoPotentialMap) { m_ramoPotentialMap = ramoPotentialMap; }
-
-const PixelHistoConverter& PixelModuleData::getLorentzMap_e(int layer) const { return m_lorentzMap_e.at(layer); }
-const PixelHistoConverter& PixelModuleData::getLorentzMap_h(int layer) const { return m_lorentzMap_h.at(layer); }
-const PixelHistoConverter& PixelModuleData::getDistanceMap_e(int layer) const { return m_distanceMap_e.at(layer); }
-const PixelHistoConverter& PixelModuleData::getDistanceMap_h(int layer) const { return m_distanceMap_h.at(layer); }
-const PixelHistoConverter& PixelModuleData::getRamoPotentialMap(int layer) const { return m_ramoPotentialMap.at(layer); }
-
-// Map for radiation damage simulation for 3D sensor
-void PixelModuleData::setFluenceLayer3D(std::vector<double> fluenceLayer) { m_fluenceLayer3D = fluenceLayer; }
-double PixelModuleData::getFluenceLayer3D(int layer) const { return m_fluenceLayer3D.at(layer); }
-
-void PixelModuleData::setRamoPotentialMap3D(std::vector<PixelHistoConverter> ramoPotentialMap3D) { m_ramoPotentialMap3D = ramoPotentialMap3D; }
-void PixelModuleData::setEFieldMap3D(std::vector<PixelHistoConverter> eFieldMap3D) { m_eFieldMap3D = eFieldMap3D; }
-void PixelModuleData::setXPositionMap3D_e(std::vector<PixelHistoConverter> xPositionMap3D_e) { m_xPositionMap3D_e = xPositionMap3D_e; }
-void PixelModuleData::setXPositionMap3D_h(std::vector<PixelHistoConverter> xPositionMap3D_h) { m_xPositionMap3D_h = xPositionMap3D_h; }
-void PixelModuleData::setYPositionMap3D_e(std::vector<PixelHistoConverter> yPositionMap3D_e) { m_yPositionMap3D_e = yPositionMap3D_e; }
-void PixelModuleData::setYPositionMap3D_h(std::vector<PixelHistoConverter> yPositionMap3D_h) { m_yPositionMap3D_h = yPositionMap3D_h; }
-void PixelModuleData::setTimeMap3D_e(std::vector<PixelHistoConverter> timeMap3D_e) { m_timeMap3D_e = timeMap3D_e; }
-void PixelModuleData::setTimeMap3D_h(std::vector<PixelHistoConverter> timeMap3D_h) { m_timeMap3D_h = timeMap3D_h; }
-void PixelModuleData::setAvgChargeMap3D_e(PixelHistoConverter avgChargeMap3D_e) { m_avgChargeMap3D_e = avgChargeMap3D_e; }
-void PixelModuleData::setAvgChargeMap3D_h(PixelHistoConverter avgChargeMap3D_h) { m_avgChargeMap3D_h = avgChargeMap3D_h; }
-
-const PixelHistoConverter& PixelModuleData::getRamoPotentialMap3D(int layer) const { return m_ramoPotentialMap3D.at(layer); }
-const PixelHistoConverter& PixelModuleData::getEFieldMap3D(int layer) const { return m_eFieldMap3D.at(layer); }
-const PixelHistoConverter& PixelModuleData::getXPositionMap3D_e(int layer) const { return m_xPositionMap3D_e.at(layer); }
-const PixelHistoConverter& PixelModuleData::getXPositionMap3D_h(int layer) const { return m_xPositionMap3D_h.at(layer); }
-const PixelHistoConverter& PixelModuleData::getYPositionMap3D_e(int layer) const { return m_yPositionMap3D_e.at(layer); }
-const PixelHistoConverter& PixelModuleData::getYPositionMap3D_h(int layer) const { return m_yPositionMap3D_h.at(layer); }
-const PixelHistoConverter& PixelModuleData::getTimeMap3D_e(int layer) const { return m_timeMap3D_e.at(layer); }
-const PixelHistoConverter& PixelModuleData::getTimeMap3D_h(int layer) const { return m_timeMap3D_h.at(layer); }
-const PixelHistoConverter& PixelModuleData::getAvgChargeMap3D_e() const { return m_avgChargeMap3D_e; }
-const PixelHistoConverter& PixelModuleData::getAvgChargeMap3D_h() const { return m_avgChargeMap3D_h; }
-
 // Distortion parameters
 void PixelModuleData::setDistortionInputSource(int distortionInputSource) { m_distortionInputSource = distortionInputSource; }
 int PixelModuleData::getDistortionInputSource() const { return m_distortionInputSource; }
diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelRadiationDamageFluenceMapData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelRadiationDamageFluenceMapData.cxx
new file mode 100644
index 00000000000..cf3ab294da6
--- /dev/null
+++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelRadiationDamageFluenceMapData.cxx
@@ -0,0 +1,86 @@
+/*
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "PixelConditionsData/PixelRadiationDamageFluenceMapData.h"
+
+PixelRadiationDamageFluenceMapData::PixelRadiationDamageFluenceMapData():
+  m_fluenceLayer(),
+  m_lorentzMap_e(),
+  m_lorentzMap_h(),
+  m_distanceMap_e(),
+  m_distanceMap_h(),
+  m_ramoPotentialMap(),
+  m_fluenceLayer3D(),
+  m_ramoPotentialMap3D(),
+  m_eFieldMap3D(),
+  m_xPositionMap3D_e(),
+  m_xPositionMap3D_h(),
+  m_yPositionMap3D_e(),
+  m_yPositionMap3D_h(),
+  m_timeMap3D_e(),
+  m_timeMap3D_h()
+{ }
+
+PixelRadiationDamageFluenceMapData::~PixelRadiationDamageFluenceMapData() { }
+
+// Map for radiation damage simulation
+void PixelRadiationDamageFluenceMapData::setFluenceLayer(std::vector<double> fluenceLayer) { m_fluenceLayer = fluenceLayer; }
+double PixelRadiationDamageFluenceMapData::getFluenceLayer(int layer) const { return m_fluenceLayer.at(layer); }
+
+void PixelRadiationDamageFluenceMapData::setLorentzMap_e(std::vector<PixelHistoConverter> lorentzMap_e) { m_lorentzMap_e = lorentzMap_e; }
+void PixelRadiationDamageFluenceMapData::setLorentzMap_h(std::vector<PixelHistoConverter> lorentzMap_h) { m_lorentzMap_h = lorentzMap_h; }
+void PixelRadiationDamageFluenceMapData::setDistanceMap_e(std::vector<PixelHistoConverter> distanceMap_e) { m_distanceMap_e = distanceMap_e; }
+void PixelRadiationDamageFluenceMapData::setDistanceMap_h(std::vector<PixelHistoConverter> distanceMap_h) { m_distanceMap_h = distanceMap_h; }
+void PixelRadiationDamageFluenceMapData::setRamoPotentialMap(std::vector<PixelHistoConverter> ramoPotentialMap) { m_ramoPotentialMap = ramoPotentialMap; }
+
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getLorentzMap_e(int layer) const { return m_lorentzMap_e.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getLorentzMap_h(int layer) const { return m_lorentzMap_h.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getDistanceMap_e(int layer) const { return m_distanceMap_e.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getDistanceMap_h(int layer) const { return m_distanceMap_h.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getRamoPotentialMap(int layer) const { return m_ramoPotentialMap.at(layer); }
+
+// Map for radiation damage simulation for 3D sensor
+void PixelRadiationDamageFluenceMapData::setFluenceLayer3D(std::vector<double> fluenceLayer) { m_fluenceLayer3D = fluenceLayer; }
+double PixelRadiationDamageFluenceMapData::getFluenceLayer3D(int layer) const { return m_fluenceLayer3D.at(layer); }
+
+void PixelRadiationDamageFluenceMapData::setRamoPotentialMap3D(std::vector<PixelHistoConverter> ramoPotentialMap3D) { m_ramoPotentialMap3D = ramoPotentialMap3D; }
+void PixelRadiationDamageFluenceMapData::setEFieldMap3D(std::vector<PixelHistoConverter> eFieldMap3D) { m_eFieldMap3D = eFieldMap3D; }
+void PixelRadiationDamageFluenceMapData::setXPositionMap3D_e(std::vector<PixelHistoConverter> xPositionMap3D_e) { m_xPositionMap3D_e = xPositionMap3D_e; }
+void PixelRadiationDamageFluenceMapData::setXPositionMap3D_h(std::vector<PixelHistoConverter> xPositionMap3D_h) { m_xPositionMap3D_h = xPositionMap3D_h; }
+void PixelRadiationDamageFluenceMapData::setYPositionMap3D_e(std::vector<PixelHistoConverter> yPositionMap3D_e) { m_yPositionMap3D_e = yPositionMap3D_e; }
+void PixelRadiationDamageFluenceMapData::setYPositionMap3D_h(std::vector<PixelHistoConverter> yPositionMap3D_h) { m_yPositionMap3D_h = yPositionMap3D_h; }
+void PixelRadiationDamageFluenceMapData::setTimeMap3D_e(std::vector<PixelHistoConverter> timeMap3D_e) { m_timeMap3D_e = timeMap3D_e; }
+void PixelRadiationDamageFluenceMapData::setTimeMap3D_h(std::vector<PixelHistoConverter> timeMap3D_h) { m_timeMap3D_h = timeMap3D_h; }
+void PixelRadiationDamageFluenceMapData::setAvgChargeMap3D_e(PixelHistoConverter avgChargeMap3D_e) { m_avgChargeMap3D_e = avgChargeMap3D_e; }
+void PixelRadiationDamageFluenceMapData::setAvgChargeMap3D_h(PixelHistoConverter avgChargeMap3D_h) { m_avgChargeMap3D_h = avgChargeMap3D_h; }
+
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getRamoPotentialMap3D(int layer) const { return m_ramoPotentialMap3D.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getEFieldMap3D(int layer) const { return m_eFieldMap3D.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getXPositionMap3D_e(int layer) const { return m_xPositionMap3D_e.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getXPositionMap3D_h(int layer) const { return m_xPositionMap3D_h.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getYPositionMap3D_e(int layer) const { return m_yPositionMap3D_e.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getYPositionMap3D_h(int layer) const { return m_yPositionMap3D_h.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getTimeMap3D_e(int layer) const { return m_timeMap3D_e.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getTimeMap3D_h(int layer) const { return m_timeMap3D_h.at(layer); }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getAvgChargeMap3D_e() const { return m_avgChargeMap3D_e; }
+const PixelHistoConverter& PixelRadiationDamageFluenceMapData::getAvgChargeMap3D_h() const { return m_avgChargeMap3D_h; }
+
+void PixelRadiationDamageFluenceMapData::clear() {
+  m_fluenceLayer.clear();
+  m_lorentzMap_e.clear();
+  m_lorentzMap_h.clear();
+  m_distanceMap_e.clear();
+  m_distanceMap_h.clear();
+  m_ramoPotentialMap.clear();
+  m_fluenceLayer3D.clear();
+  m_ramoPotentialMap3D.clear();
+  m_eFieldMap3D.clear();
+  m_xPositionMap3D_e.clear();
+  m_xPositionMap3D_h.clear();
+  m_yPositionMap3D_e.clear();
+  m_yPositionMap3D_h.clear();
+  m_timeMap3D_e.clear();
+  m_timeMap3D_h.clear();
+}
+
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx
index cb42180275b..bff5e2d5f54 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx
@@ -44,7 +44,6 @@ StatusCode PixelDigitizationTool::initialize() {
 
   ATH_CHECK(m_hitsContainerKey.initialize(!m_onlyUseContainerName));
   ATH_CHECK(m_pixelDetEleCollKey.initialize());
-  ATH_CHECK(m_moduleDataKey.initialize());
   ATH_CHECK(m_rdoContainerKey.initialize());
   ATH_CHECK(m_simDataCollKey.initialize());
 
@@ -118,9 +117,6 @@ StatusCode PixelDigitizationTool::processAllSubEvents(const EventContext& ctx) {
 StatusCode PixelDigitizationTool::digitizeEvent(const EventContext& ctx) {
   ATH_MSG_VERBOSE("PixelDigitizationTool::digitizeEvent()");
 
-  // retrieve conditions data
-  SG::ReadCondHandle<PixelModuleData> moduleData(m_moduleDataKey, ctx);
-
   SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> pixelDetEleHandle(m_pixelDetEleCollKey, ctx);
   const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
   if (not pixelDetEleHandle.isValid() or elements == nullptr) {
@@ -190,7 +186,7 @@ StatusCode PixelDigitizationTool::digitizeEvent(const EventContext& ctx) {
         //Create signal in sensor, loop over collection of loaded sensorTools
         for (unsigned int itool = 0; itool < m_chargeTool.size(); itool++) {
           ATH_MSG_DEBUG("Executing tool " << m_chargeTool[itool]->name());
-          if (m_chargeTool[itool]->induceCharge(*phit, *chargedDiodes, *sielement, *p_design, moduleData.cptr(), trfHitRecord,
+          if (m_chargeTool[itool]->induceCharge(*phit, *chargedDiodes, *sielement, *p_design, trfHitRecord,
                                                 initialConditions, rndmEngine, ctx) == StatusCode::FAILURE) {
             break;
           }
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h
index 1df4bb7d325..aca221d9de5 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h
@@ -27,7 +27,6 @@
 #include "StoreGate/WriteHandleKey.h"
 #include "PileUpTools/PileUpMergeSvc.h"
 
-#include "PixelConditionsData/PixelModuleData.h"
 #include "InDetSimData/InDetSimDataCollection.h"
 #include "SensorSimTool.h"
 #include "FrontEndSimTool.h"
@@ -67,9 +66,6 @@ private:
   SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_pixelDetEleCollKey {
     this, "PixelDetEleCollKey", "PixelDetectorElementCollection", "Key of SiDetectorElementCollection for Pixel"
   };
-  SG::ReadCondHandleKey<PixelModuleData>     m_moduleDataKey{
-    this, "PixelModuleData", "PixelModuleData", "Pixel module data"
-  };
   std::string m_inputObjectName {
     ""
   };
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.cxx
index 5702d134ad9..c06300c550f 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.cxx
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.cxx
@@ -66,7 +66,6 @@ StatusCode SensorSim3DTool::induceCharge(const TimedHitPtr<SiHit>& phit,
                                          SiChargedDiodeCollection& chargedDiodes,
                                          const InDetDD::SiDetectorElement& Module,
                                          const InDetDD::PixelModuleDesign& p_design,
-                                         const PixelModuleData *moduleData,
                                          std::vector< std::pair<double, double> >& trfHitRecord,
                                          std::vector<double>& initialConditions,
                                          CLHEP::HepRandomEngine* rndmEngine,
@@ -88,21 +87,22 @@ StatusCode SensorSim3DTool::induceCharge(const TimedHitPtr<SiHit>& phit,
   }
 
   //Calculate trapping times based on fluence (already includes check for fluence=0)
+  SG::ReadCondHandle<PixelRadiationDamageFluenceMapData> fluenceData(m_fluenceDataKey,ctx);
   if (m_doRadDamage) {
-    std::pair < double, double > trappingTimes = m_radDamageUtil->getTrappingTimes(moduleData->getFluenceLayer3D(0));   //0 = IBL
+    std::pair < double, double > trappingTimes = m_radDamageUtil->getTrappingTimes(fluenceData->getFluenceLayer3D(0));   //0 = IBL
     m_trappingTimeElectrons = trappingTimes.first;
     m_trappingTimeHoles = trappingTimes.second;
   }
-  const PixelHistoConverter& ramoPotentialMap = moduleData->getRamoPotentialMap3D(0);
-  const PixelHistoConverter& eFieldMap        = moduleData->getEFieldMap3D(0);
-  const PixelHistoConverter& xPositionMap_e   = moduleData->getXPositionMap3D_e(0);
-  const PixelHistoConverter& xPositionMap_h   = moduleData->getXPositionMap3D_h(0);
-  const PixelHistoConverter& yPositionMap_e   = moduleData->getYPositionMap3D_e(0);
-  const PixelHistoConverter& yPositionMap_h   = moduleData->getYPositionMap3D_h(0);
-  const PixelHistoConverter& timeMap_e        = moduleData->getTimeMap3D_e(0);
-  const PixelHistoConverter& timeMap_h        = moduleData->getTimeMap3D_h(0);
-  const PixelHistoConverter& avgChargeMap_e   = moduleData->getAvgChargeMap3D_e();
-  const PixelHistoConverter& avgChargeMap_h   = moduleData->getAvgChargeMap3D_h();
+  const PixelHistoConverter& ramoPotentialMap = fluenceData->getRamoPotentialMap3D(0);
+  const PixelHistoConverter& eFieldMap        = fluenceData->getEFieldMap3D(0);
+  const PixelHistoConverter& xPositionMap_e   = fluenceData->getXPositionMap3D_e(0);
+  const PixelHistoConverter& xPositionMap_h   = fluenceData->getXPositionMap3D_h(0);
+  const PixelHistoConverter& yPositionMap_e   = fluenceData->getYPositionMap3D_e(0);
+  const PixelHistoConverter& yPositionMap_h   = fluenceData->getYPositionMap3D_h(0);
+  const PixelHistoConverter& timeMap_e        = fluenceData->getTimeMap3D_e(0);
+  const PixelHistoConverter& timeMap_h        = fluenceData->getTimeMap3D_h(0);
+  const PixelHistoConverter& avgChargeMap_e   = fluenceData->getAvgChargeMap3D_e();
+  const PixelHistoConverter& avgChargeMap_h   = fluenceData->getAvgChargeMap3D_h();
 
   double eta_0 = initialConditions[0];
   double phi_0 = initialConditions[1];
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.h
index 42ad264bd48..75c8adb7945 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.h
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSim3DTool.h
@@ -31,7 +31,6 @@ public:
                                   SiChargedDiodeCollection& chargedDiodes,
                                   const InDetDD::SiDetectorElement& Module,
                                   const InDetDD::PixelModuleDesign& p_design,
-                                  const PixelModuleData *moduleData,
                                   std::vector< std::pair<double, double> >& trfHitRecord,
                                   std::vector<double>& initialConditions,
                                   CLHEP::HepRandomEngine* rndmEngine,
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.cxx
index 82248a6e6bf..05b04a51c30 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.cxx
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.cxx
@@ -188,7 +188,6 @@ StatusCode SensorSimPlanarTool::induceCharge(const TimedHitPtr<SiHit>& phit,
                                              SiChargedDiodeCollection& chargedDiodes,
                                              const InDetDD::SiDetectorElement& Module,
                                              const InDetDD::PixelModuleDesign& p_design,
-                                             const PixelModuleData *moduleData,
                                              std::vector< std::pair<double, double> >& trfHitRecord,
                                              std::vector<double>& initialConditions,
                                              CLHEP::HepRandomEngine* rndmEngine,
@@ -203,12 +202,14 @@ StatusCode SensorSimPlanarTool::induceCharge(const TimedHitPtr<SiHit>& phit,
   const PixelID* p_pixelId = static_cast<const PixelID*>(Module.getIdHelper());
   int layer = p_pixelId->layer_disk(Module.identify());
 
+  SG::ReadCondHandle<PixelRadiationDamageFluenceMapData> fluenceData(m_fluenceDataKey,ctx);
+
   std::pair<double, double> trappingTimes;
   if (m_doRadDamage && Module.isBarrel()) {
     if (m_doInterpolateEfield) {
       trappingTimes = m_radDamageUtil->getTrappingTimes(m_fluenceLayer[layer]);
     } else {
-      trappingTimes = m_radDamageUtil->getTrappingTimes(moduleData->getFluenceLayer(layer));
+      trappingTimes = m_radDamageUtil->getTrappingTimes(fluenceData->getFluenceLayer(layer));
     }
   }
 
@@ -307,11 +308,11 @@ StatusCode SensorSimPlanarTool::induceCharge(const TimedHitPtr<SiHit>& phit,
 
     if (m_doRadDamage && !(Module.isDBM()) && Module.isBarrel()) {
 
-      const PixelHistoConverter& distanceMap_e    = m_doInterpolateEfield ? m_distanceMap_e[layer] : moduleData->getDistanceMap_e(layer);
-      const PixelHistoConverter& distanceMap_h    = m_doInterpolateEfield ? m_distanceMap_h[layer] : moduleData->getDistanceMap_h(layer);
-      const PixelHistoConverter& lorentzMap_e     = m_doInterpolateEfield ? m_lorentzMap_e[layer] : moduleData->getLorentzMap_e(layer);
-      const PixelHistoConverter& lorentzMap_h     = m_doInterpolateEfield ? m_lorentzMap_h[layer] : moduleData->getLorentzMap_h(layer);
-      const PixelHistoConverter& ramoPotentialMap = m_doInterpolateEfield ? m_ramoPotentialMap[layer] : moduleData->getRamoPotentialMap(layer);
+      const PixelHistoConverter& distanceMap_e    = m_doInterpolateEfield ? m_distanceMap_e[layer] : fluenceData->getDistanceMap_e(layer);
+      const PixelHistoConverter& distanceMap_h    = m_doInterpolateEfield ? m_distanceMap_h[layer] : fluenceData->getDistanceMap_h(layer);
+      const PixelHistoConverter& lorentzMap_e     = m_doInterpolateEfield ? m_lorentzMap_e[layer] : fluenceData->getLorentzMap_e(layer);
+      const PixelHistoConverter& lorentzMap_h     = m_doInterpolateEfield ? m_lorentzMap_h[layer] : fluenceData->getLorentzMap_h(layer);
+      const PixelHistoConverter& ramoPotentialMap = m_doInterpolateEfield ? m_ramoPotentialMap[layer] : fluenceData->getRamoPotentialMap(layer);
 
       const std::size_t distance_f_e_bin_x = distanceMap_e.getBinX(dist_electrode);
       const std::size_t distance_f_h_bin_x = distanceMap_h.getBinX(dist_electrode);
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.h
index 3c4b69e5271..b5137930979 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.h
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimPlanarTool.h
@@ -30,7 +30,6 @@ public:
                                   SiChargedDiodeCollection& chargedDiodes,
                                   const InDetDD::SiDetectorElement& Module,
                                   const InDetDD::PixelModuleDesign& p_design,
-                                  const PixelModuleData *moduleData, 
                                   std::vector< std::pair<double, double> >& trfHitRecord,
                                   std::vector<double>& initialConditions,
                                   CLHEP::HepRandomEngine* rndmEngine,
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimTool.h
index 7726f1ab7ad..1e70ae07946 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimTool.h
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SensorSimTool.h
@@ -20,6 +20,7 @@
 #include "HitManagement/TimedHitPtr.h"
 #include "InDetReadoutGeometry/SiDetectorElement.h"
 #include "PixelConditionsData/PixelModuleData.h"
+#include "PixelConditionsData/PixelRadiationDamageFluenceMapData.h"
 #include "PixelReadoutGeometry/PixelModuleDesign.h"
 #include "SiDigitization/SiChargedDiodeCollection.h"
 #include "SiPropertiesTool/ISiPropertiesTool.h"
@@ -39,6 +40,8 @@ public:
   virtual StatusCode initialize() {
     ATH_CHECK(AthAlgTool::initialize());
     ATH_CHECK(m_siPropertiesTool.retrieve());
+    ATH_CHECK(m_moduleDataKey.initialize());
+    ATH_CHECK(m_fluenceDataKey.initialize());
     return StatusCode::SUCCESS;
   }
 
@@ -48,7 +51,6 @@ public:
                                   SiChargedDiodeCollection& chargedDiodes,
                                   const InDetDD::SiDetectorElement& Module,
                                   const InDetDD::PixelModuleDesign& p_design,
-                                  const PixelModuleData *moduleData,
                                   std::vector< std::pair<double, double> >& trfHitRecord,
                                   std::vector<double>& initialConditions,
                                   CLHEP::HepRandomEngine* rndmEngine,
@@ -61,6 +63,16 @@ protected:
     this, "SiPropertiesTool", "SiPropertiesTool", "Tool to retrieve SiProperties"
   };
 
+  SG::ReadCondHandleKey<PixelModuleData> m_moduleDataKey
+  {
+    this, "PixelModuleData", "PixelModuleData", "Pixel module data"
+  };
+
+  SG::ReadCondHandleKey<PixelRadiationDamageFluenceMapData> m_fluenceDataKey
+  {
+    this, "PixelRadiationDamageFluenceMapData", "PixelRadiationDamageFluenceMapData", "Pixel fluence map data for radiation damage"
+  };
+
 };
 
 #endif // PIXELDIGITIZATION_SensorSimTool_H
-- 
GitLab