From cf13273d22a55a28a192dce3ce5242002d154e8b Mon Sep 17 00:00:00 2001
From: Shaun Roe <shaun.roe@cern.ch>
Date: Tue, 18 Mar 2025 10:38:25 +0100
Subject: [PATCH 1/2] alter limit for ToT generation

---
 .../src/PixelNoiseFunctions.cxx                | 14 ++++++++++++++
 .../src/PixelNoiseFunctions.h                  | 18 +++++++++++++-----
 .../PixelDigitization/src/RD53SimTool.cxx      | 16 ++++------------
 3 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.cxx
index 8b961c2688e7..382691f0d631 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.cxx
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.cxx
@@ -164,6 +164,20 @@ namespace PixelDigitization{
     }
     return;
   }
+  
+  int 
+  generateToT(CLHEP::HepRandomEngine* rndmEngine, double mean, double sd, const std::pair<int, int>& range){
+    int nToT = static_cast<int>(CLHEP::RandGaussZiggurat::shoot(rndmEngine, mean, sd));
+    const auto &[lo,hi] = range;
+    //
+    if (nToT < lo) {
+      nToT = lo;
+    }
+    if (nToT >= hi) {
+      nToT = hi;
+    }
+    return nToT;
+  }
 
   double 
   getG4Time(const SiTotalCharge& totalCharge) {
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.h
index 1cf9706b3ae4..dc273d940be4 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.h
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoiseFunctions.h
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+   Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
  */
 #ifndef PixelNoiseFunctions_h
 #define PixelNoiseFunctions_h
@@ -7,6 +7,7 @@
 
 #include "PixelReadoutGeometry/IPixelReadoutManager.h"
 #include <vector>
+#include <utility> //for std::pair
 
 class SiChargedDiodeCollection;
 class SiTotalCharge;
@@ -36,15 +37,22 @@ namespace PixelDigitization{
     InDetDD::IPixelReadoutManager * pixelReadout);
   
   //randomly disables certain elements, using moduleData to get probability
-  void randomDisable(SiChargedDiodeCollection& chargedDiodes,
+  void 
+  randomDisable(SiChargedDiodeCollection& chargedDiodes,
     const PixelModuleData *moduleData,
     CLHEP::HepRandomEngine* rndmEngine);
   
   //randomly disables certain elements, probability as a parameter          
-  void randomDisable(SiChargedDiodeCollection& chargedDiodes,
+  void 
+  randomDisable(SiChargedDiodeCollection& chargedDiodes,
     double disableProbability, CLHEP::HepRandomEngine* rndmEngine);
-                     
-  double getG4Time(const SiTotalCharge& totalCharge) ;
+    
+  //generate Time-Over-Threshold int values with mean, rms, and valid range
+  int 
+  generateToT(CLHEP::HepRandomEngine* rndmEngine, double mean, double sd, const std::pair<int, int>& range);
+  //
+  double 
+  getG4Time(const SiTotalCharge& totalCharge);
 }//namespace
   
   #endif
\ No newline at end of file
diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/RD53SimTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/RD53SimTool.cxx
index c45770a80115..d56cabeeb9d0 100644
--- a/InnerDetector/InDetDigitization/PixelDigitization/src/RD53SimTool.cxx
+++ b/InnerDetector/InDetDigitization/PixelDigitization/src/RD53SimTool.cxx
@@ -1,10 +1,10 @@
 /*
-   Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+   Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
  */
 
 #include "RD53SimTool.h"
 #include "PixelDigitizationUtilities.h"
-
+#include "PixelNoiseFunctions.h"
 #include "PixelReadoutGeometry/PixelModuleDesign.h"
 #include "PixelConditionsData/ChargeCalibParameters.h" //for Thresholds
 #include "SiDigitization/SiChargedDiodeCollection.h"
@@ -14,7 +14,6 @@
 #include "ReadoutGeometryBase/SiReadoutCellId.h"
 #include "InDetRawData/Pixel1RawData.h"
 #include "CLHEP/Random/RandFlat.h"
-#include "CLHEP/Random/RandGaussZiggurat.h"
 #include "PixelNoiseFunctions.h"
 #include <cmath>
 
@@ -64,7 +63,7 @@ void RD53SimTool::process(SiChargedDiodeCollection& chargedDiodes, PixelRDO_Coll
   SG::ReadCondHandle<PixelChargeCalibCondData> calibDataHandle(m_chargeDataKey, ctx);
   const PixelChargeCalibCondData *calibData = *calibDataHandle;
 
-  int overflowToT = calibData->getFEI4OverflowToT();
+  int overflowToT = 14; //for RD53 (aka ITkPixV2) chip, not FEI4
 
   std::vector<Pixel1RawData*> p_rdo_small_fei4;
   std::vector<int> row, col;
@@ -125,14 +124,7 @@ void RD53SimTool::process(SiChargedDiodeCollection& chargedDiodes, PixelRDO_Coll
     // charge to ToT conversion
     double tot = calibData->getToT(type, moduleHash, FE, charge);
     double totsig = calibData->getTotRes(moduleHash, FE, tot);
-    int nToT = static_cast<int>(CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot, totsig));
-    if (nToT < 1) {
-      nToT = 1;
-    }
-    // RD53 HitDiscConfig
-    if (nToT >= overflowToT) {
-      nToT = overflowToT;
-    }
+    int nToT = generateToT(rndmEngine, tot,totsig, std::make_pair(1,overflowToT));
 
     if (nToT <= moduleData->getToTThreshold(barrel_ec, layerIndex)) {
       SiHelper::belowThreshold(mapDiode, true, true);
-- 
GitLab


From e9737d0c8f346f7465fade5149d8d1280ec4e61f Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Thu, 20 Mar 2025 16:29:02 +0100
Subject: [PATCH 2/2] Update CI references

---
 Tools/WorkflowTestRunner/python/References.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Tools/WorkflowTestRunner/python/References.py b/Tools/WorkflowTestRunner/python/References.py
index 962a580cba5c..2242987c2aad 100644
--- a/Tools/WorkflowTestRunner/python/References.py
+++ b/Tools/WorkflowTestRunner/python/References.py
@@ -19,7 +19,7 @@ references_map = {
     "s4454": "v2",
     "a913": "v15",
     # Digi
-    "d1920": "v7",
+    "d1920": "v8",
     # Overlay
     "d1726": "v13",
     "d1759": "v20",
-- 
GitLab