From 24067776533addcfefa95edc9bb2e02e9da58473 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 14:57:51 +0100
Subject: [PATCH 01/67] Update PID performance scripts for U2 studies

---
 Rec/GlobalReco/root/GlobalPID.C              |  41 +--
 Rec/GlobalReco/root/RichKaonIDCompareFiles.C | 329 +++++++++++--------
 2 files changed, 222 insertions(+), 148 deletions(-)

diff --git a/Rec/GlobalReco/root/GlobalPID.C b/Rec/GlobalReco/root/GlobalPID.C
index 0eeb84da23f..e65a2215d17 100755
--- a/Rec/GlobalReco/root/GlobalPID.C
+++ b/Rec/GlobalReco/root/GlobalPID.C
@@ -169,7 +169,7 @@ void GlobalPID::makeCurve( const Long64_t nTracks ) {
 
     //------------------------------------------------------------------------------
   }
-  std::cout << " Done." << std::endl << "Creating " << config.title << std::endl;
+  std::cout << " Done." << std::endl << "Creating '" << config.title << "'" << std::endl;
 
   // figure file name
   std::string figName = imageName();
@@ -215,23 +215,25 @@ void GlobalPID::makeCurve( const Long64_t nTracks ) {
     const double partMisIDEff    = 100 * ( totPartMisID > 0 ? selPartMisID / totPartMisID : 0 );
     const double partMisIDEffErr = 100 * poisError( selPartMisID, totPartMisID );
 
-    if ( partEff >= config.minIDeff && partEff <= config.maxIDeff && partMisIDEff >= config.minMisIDeff &&
+    if ( partEff >= config.minIDeff &&         //
+         partEff <= config.maxIDeff &&         //
+         partMisIDEff >= config.minMisIDeff && //
          partMisIDEff <= config.maxMisIDeff ) {
       ideff.push_back( partEff );
       idefferr.push_back( partEffErr );
       misideff.push_back( partMisIDEff );
       misidefferr.push_back( partMisIDEffErr );
-    }
+      // add label ?
+      if ( config.writeCutValues && iLabel >= labelRate ) {
+        iLabel = labelOffset;
+        std::ostringstream label;
+        // label << "cut=";
+        label << iStep->first;
+        labels.push_back( Label( partEff, partMisIDEff, label.str() ) );
+      }
+    } // in plot range
+  }   // step loop
 
-    // label ?
-    if ( config.writeCutValues && iLabel >= labelRate ) {
-      iLabel = labelOffset;
-      std::ostringstream label;
-      // label << "cut=";
-      label << iStep->first;
-      labels.push_back( Label( partEff, partMisIDEff, label.str() ) );
-    }
-  }
   labelOffset += 1;
 
   if ( config.useFixedGraphRange && !config.superImpose ) {
@@ -538,11 +540,12 @@ void GlobalPID::fillLabelBox() const {
   static double yOffset( 0 );
   if ( !config.superImpose ) yOffset = 0.88;
   if ( !config.subtitle.empty() ) { text->DrawText( xOffset, yOffset -= yInc, line0.str().c_str() ); }
-  text->DrawText( xOffset, yOffset -= yInc, line1.str().c_str() );
-  if ( config.secvar1 != NoVar ) { text->DrawText( xOffset, yOffset -= yInc, line2.str().c_str() ); }
-  text->DrawText( xOffset, yOffset -= yInc, line3.str().c_str() );
-  text->DrawText( xOffset, yOffset -= yInc, line5.str().c_str() );
-  text->DrawText( xOffset, yOffset -= yInc, line6.str().c_str() );
+  // text->DrawText( xOffset, yOffset -= yInc, line1.str().c_str() );
+  // if ( config.secvar1 != NoVar ) { text->DrawText( xOffset, yOffset -= yInc, line2.str().c_str() ); }
+  // text->DrawText( xOffset, yOffset -= yInc, line3.str().c_str() );
+  // text->DrawText( xOffset, yOffset -= yInc, line5.str().c_str() );
+  // text->DrawText( xOffset, yOffset -= yInc, line6.str().c_str() );
+  std::cout << line6.str() << std::endl;
 
   yOffset -= yInc / 2;
 }
@@ -681,8 +684,8 @@ void GlobalPID::Init( TTree* tree ) {
   fChain->SetBranchAddress( "CaloChargedSpd", &CaloChargedSpd, &b_CaloChargedSpd );
   fChain->SetBranchAddress( "CaloChargedPrs", &CaloChargedPrs, &b_CaloChargedPrs );
   fChain->SetBranchAddress( "CaloChargedEcal", &CaloChargedEcal, &b_CaloChargedEcal );
-  fChain->SetBranchAddress( "CaloSpdE", &CaloSpdE, &b_CaloSpdE );
-  fChain->SetBranchAddress( "CaloPrsE", &CaloPrsE, &b_CaloPrsE );
+  // fChain->SetBranchAddress( "CaloSpdE", &CaloSpdE, &b_CaloSpdE );
+  // fChain->SetBranchAddress( "CaloPrsE", &CaloPrsE, &b_CaloPrsE );
   fChain->SetBranchAddress( "CaloEcalChi2", &CaloEcalChi2, &b_CaloEcalChi2 );
   fChain->SetBranchAddress( "CaloClusChi2", &CaloClusChi2, &b_CaloClusChi2 );
   fChain->SetBranchAddress( "CaloBremChi2", &CaloBremChi2, &b_CaloBremChi2 );
diff --git a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
index faf5d6b35f3..a79fda95fa6 100755
--- a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
+++ b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
@@ -10,6 +10,7 @@
 \*****************************************************************************/
 
 #include <array>
+#include <map>
 #include <memory>
 #include <tuple>
 #include <vector>
@@ -18,133 +19,203 @@
 
 void RichKaonIDCompareFiles() {
 
-  // make a pid object
-  auto pid = std::make_unique<GlobalPID>();
-
-  const double GeV = 1000;
-
-  const std::string R = "R1";
-  // const std::string R = "R2";
-
-  // for ( const auto tktype : {GlobalPID::Long, GlobalPID::Upstream, GlobalPID::Downstream, GlobalPID::Ttrack} ) {
-  for ( const auto tktype : {GlobalPID::Long} ) {
-
-    if ( tktype == GlobalPID::Upstream && R == "R2" ) { continue; }
-    if ( tktype == GlobalPID::Ttrack && R == "R1" ) { continue; }
-
-    // Default Config Object
-    GlobalPID::Configuration gConf;
-
-    // track selection
-    gConf.trackType = tktype;
-
-    // Histo range
-    if ( GlobalPID::Long == tktype ) {
-      gConf.useFixedGraphRange = true;
-      gConf.minGraphX          = 80;
-      gConf.maxGraphX          = 100;
-      gConf.minGraphY          = 0.5;
-      gConf.maxGraphY          = 20;
-    } else if ( GlobalPID::Upstream == tktype ) {
-      gConf.useFixedGraphRange = true;
-      gConf.minGraphX          = 40;
-      gConf.maxGraphX          = 100;
-      gConf.minGraphY          = 5;
-      gConf.maxGraphY          = 50;
-    } else if ( GlobalPID::Downstream == tktype ) {
-      gConf.useFixedGraphRange = true;
-      gConf.minGraphX          = 60;
-      gConf.maxGraphX          = 100;
-      gConf.minGraphY          = 1.0;
-      gConf.maxGraphY          = 20;
-    } else if ( GlobalPID::Ttrack == tktype ) {
-      gConf.useFixedGraphRange = true;
-      gConf.minGraphX          = 10;
-      gConf.maxGraphX          = 100;
-      gConf.minGraphY          = 1;
-      gConf.maxGraphY          = 50;
-    }
-
-    // Stepping options
-    gConf.maxCut      = 35;
-    gConf.nSteps      = 100;
-    gConf.minMisIDeff = 0.3;
-
-    // Momentum range
-    if ( GlobalPID::Long == tktype ) {
-      gConf.minP  = 3 * GeV;
-      gConf.maxP  = 100 * GeV;
-      gConf.minPt = 0.5 * GeV;
-      gConf.maxPt = 100 * GeV;
-    } else if ( GlobalPID::Upstream == tktype ) {
-      gConf.minP  = 3 * GeV;
-      gConf.maxP  = 30 * GeV;
-      gConf.minPt = 0.5 * GeV;
-      gConf.maxPt = 30 * GeV;
-    } else if ( GlobalPID::Downstream == tktype ) {
-      gConf.minP  = 3 * GeV;
-      gConf.maxP  = 100 * GeV;
-      gConf.minPt = 0.5 * GeV;
-      gConf.maxPt = 100 * GeV;
-    } else if ( GlobalPID::Ttrack == tktype ) {
-      gConf.minP  = 3 * GeV;
-      gConf.maxP  = 30 * GeV;
-      gConf.minPt = 0.5 * GeV;
-      gConf.maxPt = 30 * GeV;
-    }
-
-    // detector selection
-    gConf.mustHaveAnyRICH = true;
-    // Plot Type
-    gConf.title     = "RICH Kaon ID";
-    gConf.idType    = GlobalPID::Kaon;
-    gConf.misidType = GlobalPID::Pion;
-    gConf.var1      = GlobalPID::richDLLk;
-    gConf.var2      = GlobalPID::richDLLpi;
-
-    const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Brunel/output/Upgrade/CKResolution";
-    // const std::string dir =
-    // "/Users/chris/cernbox/LHCb/RICH/ParameterisedCKRes"; const std::string
-    // dir = "/usera/jonesc/cernbox/LHCb/RICH/ParameterisedCKRes";
-
-    const std::string fName = "RichFuture-Feature-x86_64-centos7-gcc9-opt-Expert-ProtoTuple.root";
-
-    using PlotData = std::vector<std::tuple<std::string, std::string, Color_t>>;
-
-    // colours ... https://root.cern.ch/doc/master/classTColor.html
-    const std::array<Color_t, 11> colors{kBlack,       kRed - 6,    kBlue + 1, kGreen + 2, kRed + 1, kBlue - 1,
-                                         kMagenta + 2, kYellow + 3, kCyan + 2, kGreen - 5, kGray + 2};
-
-    auto lastColor = colors.end();
-
-    auto genTuple = [&]( const auto& tag ) {
-      if ( colors.end() == lastColor ) { lastColor = colors.begin(); }
-      return std::make_tuple( dir + "/NSigmaOpt/FunctCKRes-" + R + "-nS-" + tag + "/" + fName,
-                              "Funct " + R + " | nS " + tag, *( lastColor++ ) );
-    };
-
-    const auto tags = std::array{"1.0", "1.2", "1.4", "1.6", "1.8", "2.0", "3.0", "4.0"};
-    // const auto tags = std::array{"4.0", "4.2", "4.4", "4.6", "4.8", "5.0"};
-
-    PlotData plotdata;
-    plotdata.reserve( tags.size() );
-    for ( const auto& tag : tags ) { plotdata.push_back( genTuple( tag ) ); }
-
-    const Long64_t nTracks = 1e5;
-
-    unsigned int iPlot = 0;
-    for ( const auto& [fname, title, color] : plotdata ) {
-      pid->loadTTree( fname );
-      pid->config             = gConf;
-      pid->config.subtitle    = title;
-      pid->config.superImpose = ( iPlot++ != 0 );
-      pid->config.color       = color;
-      // create the plot
-      pid->makeCurve( nTracks );
-    }
-
-  } // track type loop
-
-  // save the figures
-  pid->saveFigures();
+  const Long64_t nTracks = 1e6;
+
+  const std::string dir = "/usera/jonesc/LHCb/output/U2";
+
+  const std::string fName = "RichFuture-Feature-x86_64_v3-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
+
+  std::map<std::string, std::vector<std::string>> dataSets;
+
+  // Compare lumis for 3D only
+  // const auto tags = std::array{"3D/lumi-2.0e32", "3D/lumi-2.0e33", "3D/lumi-3.0e33",
+  //                             "3D/lumi-1.0e34", "3D/lumi-1.2e34", "3D/lumi-1.5e34"};
+  // Compare at 2.0e33 different pixel windows
+  // const auto tags = std::array{"4D/lumi-2.0e33/PixWin-1.000/PhotWin-1.000",
+  //                              "4D/lumi-2.0e33/PixWin-2.000/PhotWin-1.000",
+  //                              "4D/lumi-2.0e33/PixWin-3.000/PhotWin-1.000",
+  //                              "4D/lumi-3.0e33/PixWin-1.000/PhotWin-1.000",
+  //                              "4D/lumi-3.0e33/PixWin-2.000/PhotWin-1.000",
+  //                              "4D/lumi-3.0e33/PixWin-3.000/PhotWin-1.000"};
+  // Photon window cuts
+  // const auto tags = std::array{
+  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-1.000",
+  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.500",
+  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.250",
+  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.100",
+  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.050"
+  //};
+  std::string bName = "-V12";
+  // Tune Rich1 Background weight
+  dataSets["3D-Rich1Only" + bName + "-BckWeightTune"] = //
+      std::vector{"Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.900/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.800/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.700/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.600/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.500/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.400/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.300/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.200/R2PixBckW-1.000",
+                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.100/R2PixBckW-1.000"};
+  dataSets["4D-Rich1Only" + bName + "-BckWeightTune"] = //
+      std::vector{"Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.900/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.800/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.700/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.600/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.500/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.400/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.300/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.200/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.100/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.050/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100"};
+  // Tune Rich2 Background weight
+  dataSets["3D-Rich2Only" + bName + "-BckWeightTune"] = //
+      std::vector{"Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.900",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.800",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.700",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.600",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.500",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.400",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.300",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.200",
+                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.100"};
+  dataSets["4D-Rich2Only" + bName + "-BckWeightTune"] = //
+      std::vector{"Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.900/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.800/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.700/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.600/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.500/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.400/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.300/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.200/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.100/PixWin-3.000/PhotWin-0.100",
+                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.050/PixWin-3.000/PhotWin-0.100"};
+
+  for ( const auto& [dname, tags] : dataSets ) {
+
+    // make a pid object
+    auto pid = std::make_unique<GlobalPID>();
+
+    const double GeV = 1000;
+
+    const std::string R = "R1";
+    // const std::string R = "R2";
+
+    // for ( const auto tktype : {GlobalPID::Long, GlobalPID::Upstream, GlobalPID::Downstream, GlobalPID::Ttrack} ) {
+    for ( const auto tktype : {GlobalPID::Long} ) {
+
+      if ( tktype == GlobalPID::Upstream && R == "R2" ) { continue; }
+      if ( tktype == GlobalPID::Ttrack && R == "R1" ) { continue; }
+
+      // Default Config Object
+      GlobalPID::Configuration gConf;
+
+      // track selection
+      gConf.trackType = tktype;
+
+      // Histo range
+      if ( GlobalPID::Long == tktype ) {
+        gConf.useFixedGraphRange = true;
+        gConf.minGraphX          = 80;
+        gConf.maxGraphX          = 100;
+        gConf.minGraphY          = 0.2;
+        gConf.maxGraphY          = 20;
+      } else if ( GlobalPID::Upstream == tktype ) {
+        gConf.useFixedGraphRange = true;
+        gConf.minGraphX          = 40;
+        gConf.maxGraphX          = 100;
+        gConf.minGraphY          = 5;
+        gConf.maxGraphY          = 50;
+      } else if ( GlobalPID::Downstream == tktype ) {
+        gConf.useFixedGraphRange = true;
+        gConf.minGraphX          = 60;
+        gConf.maxGraphX          = 100;
+        gConf.minGraphY          = 1.0;
+        gConf.maxGraphY          = 20;
+      } else if ( GlobalPID::Ttrack == tktype ) {
+        gConf.useFixedGraphRange = true;
+        gConf.minGraphX          = 10;
+        gConf.maxGraphX          = 100;
+        gConf.minGraphY          = 1;
+        gConf.maxGraphY          = 50;
+      }
+
+      // Stepping options
+      gConf.maxCut      = 35;
+      gConf.nSteps      = 50;
+      gConf.minMisIDeff = 0.2;
+
+      // Momentum range
+      if ( GlobalPID::Long == tktype ) {
+        gConf.minP  = 3 * GeV;
+        gConf.maxP  = 100 * GeV;
+        gConf.minPt = 0.5 * GeV;
+        gConf.maxPt = 100 * GeV;
+      } else if ( GlobalPID::Upstream == tktype ) {
+        gConf.minP  = 3 * GeV;
+        gConf.maxP  = 30 * GeV;
+        gConf.minPt = 0.5 * GeV;
+        gConf.maxPt = 30 * GeV;
+      } else if ( GlobalPID::Downstream == tktype ) {
+        gConf.minP  = 3 * GeV;
+        gConf.maxP  = 100 * GeV;
+        gConf.minPt = 0.5 * GeV;
+        gConf.maxPt = 100 * GeV;
+      } else if ( GlobalPID::Ttrack == tktype ) {
+        gConf.minP  = 3 * GeV;
+        gConf.maxP  = 30 * GeV;
+        gConf.minPt = 0.5 * GeV;
+        gConf.maxPt = 30 * GeV;
+      }
+
+      // detector selection
+      gConf.mustHaveAnyRICH = true;
+      // Plot Type
+      gConf.title     = "RICH Kaon ID";
+      gConf.idType    = GlobalPID::Kaon;
+      gConf.misidType = GlobalPID::Pion;
+      gConf.var1      = GlobalPID::richDLLk;
+      gConf.var2      = GlobalPID::richDLLpi;
+
+      gConf.writeCutValues = false;
+
+      using PlotData = std::vector<std::tuple<std::string, std::string, Color_t>>;
+
+      // colours ... https://root.cern.ch/doc/master/classTColor.html
+      const std::array<Color_t, 11> colors{kBlack,       kRed - 6,    kBlue + 1, kGreen + 2, kRed + 1, kBlue - 1,
+                                           kMagenta + 2, kYellow + 3, kCyan + 2, kGreen - 5, kGray + 2};
+
+      auto lastColor = colors.end();
+
+      auto genTuple = [&]( const auto& tag ) {
+        if ( colors.end() == lastColor ) { lastColor = colors.begin(); }
+        return std::make_tuple( dir + "/" + tag + "/" + fName, tag, *( lastColor++ ) );
+      };
+
+      PlotData plotdata;
+      plotdata.reserve( tags.size() );
+      for ( const auto& tag : tags ) { plotdata.push_back( genTuple( tag ) ); }
+
+      unsigned int iPlot = 0;
+      for ( const auto& [fname, title, color] : plotdata ) {
+        pid->loadTTree( fname );
+        pid->config           = gConf;
+        pid->config.imageFile = dname;
+        pid->config.title += " | " + dname;
+        pid->config.subtitle    = title;
+        pid->config.superImpose = ( iPlot++ != 0 );
+        pid->config.color       = color;
+        // create the plot
+        pid->makeCurve( nTracks );
+      }
+
+    } // track type loop
+
+    // save the figures
+    pid->saveFigures();
+  }
 }
-- 
GitLab


From 9c2b605ac10d9d1091b9f1c3be7a7661566939e9 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 14:59:39 +0100
Subject: [PATCH 02/67] Add ignore() to untested StatusCode return

---
 .../src/RichSIMDGlobalPIDLikelihoodMinimiser.cpp                | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureGlobalPID/src/RichSIMDGlobalPIDLikelihoodMinimiser.cpp b/Rich/RichFutureGlobalPID/src/RichSIMDGlobalPIDLikelihoodMinimiser.cpp
index d39a04b4313..006f27c03c7 100644
--- a/Rich/RichFutureGlobalPID/src/RichSIMDGlobalPIDLikelihoodMinimiser.cpp
+++ b/Rich/RichFutureGlobalPID/src/RichSIMDGlobalPIDLikelihoodMinimiser.cpp
@@ -95,7 +95,7 @@ namespace Rich::Future::Rec::GlobalPID {
       } );
       m_minSig.useUpdateHandler();
 
-      // setProperty( "OutputLevel", MSG::VERBOSE );
+      // setProperty( "OutputLevel", MSG::DEBUG ).ignore();
     }
 
   public:
-- 
GitLab


From 01d2b85392e170996832b245f0a5b53f682c7708 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:19:46 +0100
Subject: [PATCH 03/67] RichMCOpticalPhotons: Add new photon yield plots

---
 .../src/RichMCOpticalPhotons.cpp              | 82 ++++++++++++++++++-
 .../ConfiguredRecoMonitors.py                 |  2 +
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecCheckers/src/RichMCOpticalPhotons.cpp b/Rich/RichFutureRecCheckers/src/RichMCOpticalPhotons.cpp
index 23d0ea94011..5fe08f92e6a 100644
--- a/Rich/RichFutureRecCheckers/src/RichMCOpticalPhotons.cpp
+++ b/Rich/RichFutureRecCheckers/src/RichMCOpticalPhotons.cpp
@@ -32,6 +32,7 @@
 #include "Event/MCRichOpticalPhoton.h"
 #include "RichFutureRecEvent/RichRecCherenkovPhotons.h"
 #include "RichFutureRecEvent/RichRecPhotonPredictedPixelSignals.h"
+#include "RichFutureRecEvent/RichRecPhotonYields.h"
 #include "RichFutureRecEvent/RichRecRelations.h"
 #include "RichFutureRecEvent/RichRecSIMDPixels.h"
 #include "RichFutureRecEvent/RichSummaryEventData.h"
@@ -69,8 +70,10 @@ namespace Rich::Future::Rec::MC::Moni {
                                          const Rich::PDPixelCluster::Vector&,             //
                                          const Relations::PhotonToParents::Vector&,       //
                                          const LHCb::RichTrackSegment::Vector&,           //
+                                         const Relations::SegmentToTrackVector&,          //
                                          const SIMDCherenkovPhoton::Vector&,              //
                                          const Rich::Future::MC::Relations::TkToMCPRels&, //
+                                         const PhotonYields::Vector&,                     //
                                          const LHCb::MCRichDigitSummarys&,                //
                                          const LHCb::MCRichHits&,                         //
                                          const LHCb::MCRichOpticalPhotons&,               //
@@ -88,8 +91,10 @@ namespace Rich::Future::Rec::MC::Moni {
                      KeyValue{"RichPixelClustersLocation", Rich::PDPixelClusterLocation::Default},
                      KeyValue{"PhotonToParentsLocation", Relations::PhotonToParentsLocation::Default},
                      KeyValue{"TrackSegmentsLocation", LHCb::RichTrackSegmentLocation::Default},
+                     KeyValue{"SegmentToTrackLocation", Relations::SegmentToTrackLocation::Default},
                      KeyValue{"CherenkovPhotonLocation", SIMDCherenkovPhotonLocation::Default},
                      KeyValue{"TrackToMCParticlesRelations", Rich::Future::MC::Relations::TrackToMCParticles},
+                     KeyValue{"PhotonYieldLocation", PhotonYieldsLocation::Detectable},
                      KeyValue{"RichDigitSummariesLocation", LHCb::MCRichDigitSummaryLocation::Default},
                      KeyValue{"MCRichHitsLocation", LHCb::MCRichHitLocation::Default},
                      KeyValue{"MCRichOpticalPhotonsLocation", LHCb::MCRichOpticalPhotonLocation::Default},
@@ -113,13 +118,15 @@ namespace Rich::Future::Rec::MC::Moni {
 
       bool ok = true;
 
+      using namespace Gaudi::Units;
+
       const DetectorArray<double> panelXsizes{{650, 800}};
       const DetectorArray<double> panelYsizes{{680, 750}};
       const DetectorArray<double> shiftXrange{{10, 100}};
       const DetectorArray<double> shiftYrange{{10, 25}};
 
       // loop over RICHes
-      for ( const auto det : Rich::detectors() ) {
+      for ( const auto det : activeDetectors() ) {
         // Global X,Y Shifts
         ok &= saveAndCheck( h_pixXGloShift[det],                                         //
                             richHisto1D( HID( "pixXGloShift", det ),                     //
@@ -200,6 +207,30 @@ namespace Rich::Future::Rec::MC::Moni {
                                            "Y Projection of angle between Reco and MC Track Direction", //
                                            m_minP[rad], m_maxP[rad], nBins1D(),                         //
                                            "Track Momentum (MeV/c)", "<Rec-MC Track Angle-Y> / mrad" ) );
+        // loop over active mass hypos
+        for ( const auto pid : activeParticlesNoBT() ) {
+          // book yield histos
+          ok &= saveAndCheck( h_yield[rad][pid],                          //
+                              richHisto1D( HID( "yield", rad, pid ),      //
+                                           "Photon Yield (>0)",           //
+                                           0, m_maxYield[rad], nBins1D(), //
+                                           "Photon Yield (>0)" ) );
+          ok &= saveAndCheck( h_yieldVp[rad][pid],                              //
+                              richProfile1D( HID( "yieldVp", rad, pid ),        //
+                                             "Photon Yield (>0) V P (MeV/c)",   //
+                                             1.0 * GeV, 100.0 * GeV, nBins1D(), //
+                                             "Track Momentum (MeV/c)", "Photon Yield (>0)" ) );
+          ok &= saveAndCheck( h_yieldDiff[rad][pid],                        //
+                              richHisto1D( HID( "yieldDiff", rad, pid ),    //
+                                           "Expected-MC Photon Yield (>0)", //
+                                           -50.0, 50.0, nBins1D(),          //
+                                           "Exp-MC Photon Yield" ) );
+          ok &= saveAndCheck( h_yieldDiffVp[rad][pid],                                    //
+                              richProfile1D( HID( "yieldDiffVp", rad, pid ),              //
+                                             "Expected-MC Photon Yield (>0) V P (MeV/c)", //
+                                             1.0 * GeV, 100.0 * GeV, nBins1D(),           //
+                                             "Track Momentum (MeV/c)", "Exp-MC Photon Yield" ) );
+        }
       }
 
       return StatusCode{ok};
@@ -213,8 +244,10 @@ namespace Rich::Future::Rec::MC::Moni {
                      const Rich::PDPixelCluster::Vector&             clusters,     //
                      const Relations::PhotonToParents::Vector&       photToSegPix, //
                      const LHCb::RichTrackSegment::Vector&           segments,     //
+                     const Relations::SegmentToTrackVector&          segToTkRel,   //
                      const SIMDCherenkovPhoton::Vector&              photons,      //
                      const Rich::Future::MC::Relations::TkToMCPRels& tkrels,       //
+                     const PhotonYields::Vector&                     yields,       //
                      const LHCb::MCRichDigitSummarys&                digitSums,    //
                      const LHCb::MCRichHits&                         mchits,       //
                      const LHCb::MCRichOpticalPhotons&               mcphotons,    //
@@ -230,11 +263,50 @@ namespace Rich::Future::Rec::MC::Moni {
       // the lock
       std::lock_guard lock( m_updateLock );
 
+      // loop over segments
+      for ( const auto&& [seg, tkIndex, yield] : Ranges::ConstZip( segments, segToTkRel, yields ) ) {
+
+        // radiator
+        const auto rad = seg.radiator();
+        if ( !radiatorIsActive( rad ) ) { continue; }
+
+        // Track pointer
+        const auto tk = tracks.at( tkIndex );
+
+        // MCP Pointers
+        const auto mcPs = mcHelper.mcParticles( *tk );
+
+        // Loop over MCPs
+        for ( const auto mcP : mcPs ) {
+          // The True MCParticle type
+          const auto pid = mcHelper.mcParticleType( mcP );
+          if ( mcP && pid != Rich::Unknown ) {
+            if ( yield[pid] > 0 ) {
+              // MC Optical Photons
+              const auto mcPhots = photHelper.mcOpticalPhotons( mcP );
+              // Count signal photons in this radiator
+              const auto nPhots = std::count_if( mcPhots.begin(), mcPhots.end(), //
+                                                 [&rad]( const auto mcPhot ) {
+                                                   const auto mcH = ( mcPhot ? mcPhot->mcRichHit() : nullptr );
+                                                   return ( mcH && mcH->radiator() == rad && mcH->isSignal() );
+                                                 } );
+              fillHisto( h_yield[rad][pid], nPhots );
+              fillHisto( h_yieldVp[rad][pid], seg.bestMomentumMag(), nPhots );
+              const auto yield_diff = yield[pid] - (double)nPhots;
+              fillHisto( h_yieldDiff[rad][pid], yield_diff );
+              fillHisto( h_yieldDiffVp[rad][pid], seg.bestMomentumMag(), yield_diff );
+            }
+          }
+        } // MCPs
+
+      } // segment data
+
       // loop over the photon info
       for ( const auto&& [sumTk, tk] : Ranges::ConstZip( sumTracks, tracks ) ) {
 
         // Get the MCParticles for this track
         const auto mcPs = mcHelper.mcParticles( *tk, false, 0.75 );
+
         // Need MC info so skip tracks without any
         if ( mcPs.empty() ) { continue; }
 
@@ -349,6 +421,11 @@ namespace Rich::Future::Rec::MC::Moni {
     DetectorArray<AIDA::IProfile2D*>   h_pixXLocShift2D = {{}};
     DetectorArray<AIDA::IProfile2D*>   h_pixYLocShift2D = {{}};
 
+    RadiatorArray<ParticleArray<AIDA::IHistogram1D*>> h_yield       = {{}};
+    RadiatorArray<ParticleArray<AIDA::IProfile1D*>>   h_yieldVp     = {{}};
+    RadiatorArray<ParticleArray<AIDA::IHistogram1D*>> h_yieldDiff   = {{}};
+    RadiatorArray<ParticleArray<AIDA::IProfile1D*>>   h_yieldDiffVp = {{}};
+
   private:
     // JOs
 
@@ -360,6 +437,9 @@ namespace Rich::Future::Rec::MC::Moni {
     Gaudi::Property<RadiatorArray<double>> m_maxP{
         this, "MaxP", {20.0 * Gaudi::Units::GeV, 70.0 * Gaudi::Units::GeV, 120.0 * Gaudi::Units::GeV}};
 
+    /// Maximum photon yield
+    Gaudi::Property<RadiatorArray<float>> m_maxYield{this, "MaximumYields", {80, 80, 80}};
+
     /// Max track angle
     Gaudi::Property<RadiatorArray<double>> m_maxTkAng{this, "MaxTkAngle", {5.0, 5.0, 4.0}};
   };
diff --git a/Rich/RichFutureRecMonitors/python/RichFutureRecMonitors/ConfiguredRecoMonitors.py b/Rich/RichFutureRecMonitors/python/RichFutureRecMonitors/ConfiguredRecoMonitors.py
index 9995f39997e..5ec67d801af 100644
--- a/Rich/RichFutureRecMonitors/python/RichFutureRecMonitors/ConfiguredRecoMonitors.py
+++ b/Rich/RichFutureRecMonitors/python/RichFutureRecMonitors/ConfiguredRecoMonitors.py
@@ -679,6 +679,7 @@ def RichRecCheckers(
             tkSeq.Members += [mcOptPhots]
             # Inputs
             mcOptPhots.TrackSegmentsLocation = locs["TrackSegmentsLocation"]
+            mcOptPhots.SegmentToTrackLocation = locs["SegmentToTrackLocation"]
             mcOptPhots.CherenkovPhotonLocation = locs[
                 "CherenkovPhotonLocation"]
             mcOptPhots.SummaryTracksLocation = locs["SummaryTracksLocation"]
@@ -690,6 +691,7 @@ def RichRecCheckers(
             mcOptPhots.RichSIMDPixelSummariesLocation = cLocs[
                 "RichSIMDPixelSummariesLocation"]
             mcOptPhots.TracksLocation = trackLocation
+            mcOptPhots.PhotonYieldLocation = locs["SignalPhotonYieldLocation"]
             # Options
             #mcOptPhots.MinP = pCuts["MinP"]
             #mcOptPhots.MaxP = pCuts["MaxP"]
-- 
GitLab


From 04b29f46297c202f089cb54460da8a492b1d2e7f Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:22:19 +0100
Subject: [PATCH 04/67] RichPIDQC: Add new counters to monitor PID reassignment
 to BT rates

---
 Rich/RichFutureRecCheckers/src/RichPIDQC.cpp | 29 +++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/Rich/RichFutureRecCheckers/src/RichPIDQC.cpp b/Rich/RichFutureRecCheckers/src/RichPIDQC.cpp
index 02213395c38..2ecb8dbfaf6 100644
--- a/Rich/RichFutureRecCheckers/src/RichPIDQC.cpp
+++ b/Rich/RichFutureRecCheckers/src/RichPIDQC.cpp
@@ -127,8 +127,13 @@ namespace Rich::Future::Rec::MC::Moni {
   private:
     // properties
 
+    /// Enable detailed histograms
     Gaudi::Property<bool> m_fillPIDplots{this, "FillPIDPlots", false, "Enable the filling of detailed PID plots"};
 
+    /// Allow reassign PID to below threshold
+    Gaudi::Property<bool> m_allowBTreassign{this, "AllowBTReassign", true,
+                                            "Allow PIDs to be reassigned as Below Threshold"};
+
   private:
     // Gaudi counters and histos
 
@@ -167,6 +172,12 @@ namespace Rich::Future::Rec::MC::Moni {
 
     /// Using both RICH1 and RICH2
     mutable Gaudi::Accumulators::BinomialCounter<> m_withR1R2{this, "Used RICH1 and RICH2"};
+
+    /// Reco PID reassigned as BT
+    mutable Gaudi::Accumulators::BinomialCounter<> m_recoPIDBT{this, "Reassigned Reco PID BT"};
+
+    /// MC PID reassigned as BT
+    mutable Gaudi::Accumulators::BinomialCounter<> m_mcPIDBT{this, "Reassigned MC PID BT"};
   };
 
 } // namespace Rich::Future::Rec::MC::Moni
@@ -217,10 +228,10 @@ void PIDQC::operator()( const LHCb::Track::Range&                       tracks,
     _ri_debug << *pid << endmsg;
 
     // is track selected
-    if ( !tkSel->accept( *tk ) ) continue;
+    if ( !tkSel->accept( *tk ) ) { continue; }
     // Is the track in the input list
     // (if not skip, means we are running on a reduced track list with selection cuts)
-    if ( std::none_of( tracks.begin(), tracks.end(), [&tk]( const auto* t ) { return t == tk; } ) ) continue;
+    if ( std::none_of( tracks.begin(), tracks.end(), [&tk]( const auto* t ) { return t == tk; } ) ) { continue; }
 
     // Count PIDs and tracks
     ++pidCount;
@@ -231,7 +242,12 @@ void PIDQC::operator()( const LHCb::Track::Range&                       tracks,
     // Get best reco PID
     auto bpid = pid->bestParticleID();
     // if below threshold, set as such
-    if ( !pid->isAboveThreshold( bpid ) ) { bpid = Rich::BelowThreshold; }
+    const bool reassignRecoBT = ( m_allowBTreassign && !pid->isAboveThreshold( bpid ) );
+    if ( reassignRecoBT ) {
+      _ri_verbo << " -> Reassigned RecoPID to BT" << endmsg;
+      bpid = Rich::BelowThreshold;
+    }
+    m_recoPIDBT += reassignRecoBT;
     _ri_verbo << " -> Best Reco PID = " << bpid << endmsg;
 
     // Get the MCParticle range for this track
@@ -257,7 +273,12 @@ void PIDQC::operator()( const LHCb::Track::Range&                       tracks,
         // If unknown, set to below threshold (i.e. ghost).
         if ( Rich::Unknown == mcpid ) { mcpid = Rich::BelowThreshold; }
         // If a real type, but below threshold, set below threshold
-        if ( !pid->isAboveThreshold( mcpid ) ) { mcpid = Rich::BelowThreshold; }
+        const bool reassignMCBT = ( m_allowBTreassign && !pid->isAboveThreshold( mcpid ) );
+        if ( reassignMCBT ) {
+          _ri_verbo << " -> Reassigned MCPID to BT" << endmsg;
+          mcpid = Rich::BelowThreshold;
+        }
+        m_mcPIDBT += reassignMCBT;
         _ri_verbo << " -> MC PID = " << mcpid << endmsg;
         // fill table
         fillTable( bpid, mcpid, mcPW );
-- 
GitLab


From 3ef312c7ae023abf8279a9b51a5f0dd8763fa5ac Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:23:07 +0100
Subject: [PATCH 05/67] RichPhotonYield: Add histogram axis labels

---
 .../src/RichPhotonYield.cpp                   | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichPhotonYield.cpp b/Rich/RichFutureRecMonitors/src/RichPhotonYield.cpp
index b4a1a1465a6..2d3586eb2c9 100644
--- a/Rich/RichFutureRecMonitors/src/RichPhotonYield.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichPhotonYield.cpp
@@ -56,7 +56,7 @@ namespace Rich::Future::Rec::Moni {
       // print some stats on the final plots
       setProperty( "HistoPrint", true ).ignore();
       // debug
-      // setProperty( "OutputLevel", MSG::VERBOSE );
+      // setProperty( "OutputLevel", MSG::VERBOSE ).ignore();
     }
 
   public:
@@ -96,14 +96,16 @@ namespace Rich::Future::Rec::Moni {
         // loop over active mass hypos
         for ( const auto pid : activeParticlesNoBT() ) {
           // book yield histos
-          ok &= saveAndCheck( h_yields[rad][pid],                    //
-                              richHisto1D( HID( "yield", rad, pid ), //
-                                           "Photon Yield (>0)",      //
-                                           0, m_maxYield[rad], nBins1D() ) );
-          ok &= saveAndCheck( h_yieldVp[rad][pid],                          //
-                              richProfile1D( HID( "yieldVp", rad, pid ),    //
-                                             "Photon Yield (>0) V P (MeV)", //
-                                             1.0 * GeV, 100.0 * GeV, nBins1D() ) );
+          ok &= saveAndCheck( h_yields[rad][pid],                         //
+                              richHisto1D( HID( "yield", rad, pid ),      //
+                                           "Photon Yield (>0)",           //
+                                           0, m_maxYield[rad], nBins1D(), //
+                                           "Photon Yield (>0)" ) );
+          ok &= saveAndCheck( h_yieldVp[rad][pid],                              //
+                              richProfile1D( HID( "yieldVp", rad, pid ),        //
+                                             "Photon Yield (>0) V P (MeV/c)",   //
+                                             1.0 * GeV, 100.0 * GeV, nBins1D(), //
+                                             "Track Momentum (MeV/c)", "Photon Yield (>0)" ) );
         }
       }
       return StatusCode{ok};
-- 
GitLab


From 4069a861c3f7e35c32c2fbbc90f106dbb1beedb2 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:23:39 +0100
Subject: [PATCH 06/67] RichSIMDQuarticPhotonReco: Only print 4D info message
 when detector is enabled

---
 .../src/RichSIMDQuarticPhotonReco.cpp                           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
index 41f8fc4350d..7f21f7697d2 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
@@ -107,7 +107,7 @@ namespace Rich::Future::Rec {
       if ( !sc ) return sc;
 
       // loop over RICHes
-      for ( const auto rich : Rich::detectors() ) {
+      for ( const auto rich : activeDetectors() ) {
         m_timeWindowSIMD[rich] = SIMDFP( m_timeWindow[rich] );
         if ( m_enable4D[rich] ) {
           info() << "4D photons enabled for " << rich << " | Window = " << ( 2.0 * m_timeWindow[rich] ) << " ns"
-- 
GitLab


From c39c67a63b247efc1613a9e47db87e64327fcaf7 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:24:17 +0100
Subject: [PATCH 07/67] RichSIMDPixelBackgroundsEstiAvHPD: Larger PMT grouping
 based on PMT modules

---
 .../src/RichSIMDPixelBackgroundsEstiAvHPD.cpp | 738 +++++++++---------
 1 file changed, 365 insertions(+), 373 deletions(-)

diff --git a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
index f6a621cbccf..03e5509ce50 100644
--- a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
+++ b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
@@ -54,11 +54,13 @@ namespace Rich::Future::Rec {
 
     /// Data values for a single PD
     struct PDData {
+      using Vector = std::vector<PDData>; ///< Vector type
+      using Index  = std::size_t;         ///< Index type
+      Index         groupID{0};           ///< Group ID
       std::uint32_t obsSignal{0};         ///< Number of observed hits in this PD
       FP            expSignal{0};         ///< Expected signal in this PD
       FP            expBackgrd{0};        ///< Expected background in this PD
       FP            effNumPixs{0};        ///< Effective number of pixels
-      using Vector = std::vector<PDData>; ///< Vector type
     };
 
     /// Per Rich Data Structure
@@ -66,51 +68,34 @@ namespace Rich::Future::Rec {
 
     /// data cache object
     class PixBkgdsDataCache {
-    private:
-      // PDInfo
-      const Detector::PDInfo* m_pdInfo = nullptr;
-
-    private:
-      /// Builds the cached PD initalisation data
-      void getPDData();
 
     public:
       /// Constructor from detector info
-      PixBkgdsDataCache( const Detector::PDInfo&            pdInfo, //
-                         const DetectorArray<unsigned int>& pdGS )
-          : m_pdInfo( &pdInfo ), pdGroupSize( pdGS ) {
-
-        // Compute the min module ID
-        DetectorArray<PanelArray<std::size_t>> minModN{{{999999, 999999}, {999999, 999999}}};
-        for ( const auto pd : pdInfo.allPDRichSmartIDs() ) {
-          // get module number
-          const auto mod = pd.pdCol();
-          if ( mod < minModN[pd.rich()][pd.panel()] ) { minModN[pd.rich()][pd.panel()] = mod; }
-          // PD num in module. Add one so indicates total number not index in panel.
-          const auto n = pd.pdNumInCol() + 1;
-          if ( n > maxPDPerMod[pd.rich()] ) { maxPDPerMod[pd.rich()] = n; }
-        }
-        minPanelIndex = minModN;
-        for ( const auto rich : Rich::detectors() ) { maxPDGPerMod[rich] = maxPDPerMod[rich] / pdGS[rich]; }
-
-        // create the PD init data
+      PixBkgdsDataCache( const Detector::PDInfo& pdInfo, //
+                         const Gaudi::Algorithm* parent )
+          : m_pdInfo( &pdInfo ), m_parent( parent ) {
         getPDData();
-
-        // to do - add back some debug output
-        //_ri_debug << "Min Module IDs        " << m_minPanelIndex << endmsg;
-        //_ri_debug << "Max PD # In Col       " << m_maxPDPerMod << endmsg;
-        //_ri_debug << "PD Group size         " << m_pdGroupSize.value() << endmsg;
-        //_ri_debug << "Max PD Groups per Col " << m_maxPDGPerMod << endmsg;
       }
 
+    public:
+      /// PD data
+      RichPDData pdData;
+      /// Min group index per panel
+      DetectorArray<PanelArray<PDData::Index>> minPanelIndex{{{0, 0}, {0, 0}}};
+
     public:
       /// Gets the working data index for the given PD ID
       inline decltype( auto ) pdIndex( const LHCb::RichSmartID  pdID, //
                                        const Rich::DetectorType rich, //
                                        const Rich::Side         panel ) const noexcept {
-        // Use module numbers, sub-divided into groups of requested max size
-        return ( maxPDGPerMod[rich] * ( pdID.pdCol() - minPanelIndex[rich][panel] ) ) +
-               ( pdID.pdNumInCol() / pdGroupSize[rich] );
+        // Just use module number
+        // const auto idx = pdID.pdMod();
+        // Group modules in neighboring columns, doubling group size
+        const auto colGSize = 2u;
+        const auto colG     = pdID.panelLocalModuleColumn() / colGSize;
+        const auto idx      = ( colG * LHCb::RichSmartID::MaPMT::ModulesPerColumn ) + pdID.columnLocalModuleNum();
+        // return with min scale
+        return ( idx - minPanelIndex[rich][panel] );
       }
 
       /// Gets the working data index for the given PD ID
@@ -127,89 +112,97 @@ namespace Rich::Future::Rec {
       /// Get the DePD object
       inline decltype( auto ) dePD( const LHCb::RichSmartID pdID ) const { return m_pdInfo->dePD( pdID ); }
 
-    public:
-      /// PD data
-      RichPDData pdData;
-      /// Min group index per panel
-      DetectorArray<PanelArray<std::size_t>> minPanelIndex{{}};
-      /// Max number of PD per module, in each RICH
-      DetectorArray<std::size_t> maxPDPerMod{{}};
-      /// Number of PD groups per module
-      DetectorArray<std::size_t> maxPDGPerMod{{}};
-      /// PD group sizes
-      DetectorArray<unsigned int> pdGroupSize{{}};
-    };
-
-    //-----------------------------------------------------------------------------
+    private:
+      /// PDInfo
+      const Detector::PDInfo* m_pdInfo = nullptr;
+      /// Parent algorithm
+      const Gaudi::Algorithm* m_parent = nullptr;
 
-    void PixBkgdsDataCache::getPDData() {
+    private:
+      /// Builds the cached PD initalisation data
+      void getPDData() {
 
-      // loop over all PD smartIDs and extract min/max index for each
-      DetectorArray<PanelArray<std::size_t>> maxIndex{{}};
-      for ( const auto pd : m_pdInfo->allPDRichSmartIDs() ) {
-        // get the max (group) index for this PD
-        const auto index = pdIndex( pd );
-        // save the largest
-        if ( index > maxIndex[pd.rich()][pd.panel()] ) { maxIndex[pd.rich()][pd.panel()] = index; }
-      }
+        // Compute the min module ID
+        DetectorArray<PanelArray<PDData::Index>> tempMinPanIndx{{{999999, 999999}, {999999, 999999}}};
+        for ( const auto pd : m_pdInfo->allPDRichSmartIDs() ) {
+          // get module number
+          const auto mod = pdIndex( pd );
+          // Save minimum for each panel
+          if ( mod < tempMinPanIndx[pd.rich()][pd.panel()] ) { tempMinPanIndx[pd.rich()][pd.panel()] = mod; }
+        }
+        minPanelIndex = tempMinPanIndx;
+
+        // loop over all PD smartIDs and extract min index for each
+        DetectorArray<PanelArray<std::size_t>> maxIndex{{}};
+        for ( const auto pd : m_pdInfo->allPDRichSmartIDs() ) {
+          // get the max (group) index for this PD
+          const auto index = pdIndex( pd );
+          // save the largest
+          if ( index > maxIndex[pd.rich()][pd.panel()] ) { maxIndex[pd.rich()][pd.panel()] = index; }
+        }
 
-      // resize the static data accordling
-      for ( const auto rich : Rich::detectors() ) {
-        for ( const auto side : Rich::sides() ) {
-          auto& richD  = pdData[rich];
-          auto& panelD = richD[side];
-          // Max PD group index for this panel
-          const auto nPDGs = maxIndex[rich][side];
-          // _ri_debug << rich << " " << Rich::text( rich, side ) << " max PD index = " << nPDGs << endmsg;
-          // clear and resize
-          assert( nPDGs < 99999 );
-          panelD.clear();
-          panelD.resize( nPDGs + 1 );
+        // resize the static data accordingly
+        for ( const auto rich : Rich::detectors() ) {
+          for ( const auto side : Rich::sides() ) {
+            auto& richD  = pdData[rich];
+            auto& panelD = richD[side];
+            // Max PD group index for this panel
+            const auto nPDGs = maxIndex[rich][side];
+            m_parent->debug() << rich << " " << Rich::text( rich, side ) << " max PD index = " << nPDGs << endmsg;
+            // clear and resize
+            assert( nPDGs < 99999 );
+            panelD.clear();
+            panelD.resize( nPDGs + 1 );
+          }
         }
-      }
 
-      // Finally, loop again over all smartIDs and fill info
-      for ( const auto pd : m_pdInfo->allPDRichSmartIDs() ) {
+        // Finally, loop again over all smartIDs and fill info
+        m_parent->debug() << "Initialising PD Info" << endmsg;
+        for ( const auto pd : m_pdInfo->allPDRichSmartIDs() ) {
 
-        //    _ri_debug << "Filling info for " << pd << endmsg;
+          const auto rich = pd.rich();
+          const auto side = pd.panel();
 
-        const auto rich = pd.rich();
-        const auto side = pd.panel();
+          auto& richD  = pdData[rich];
+          auto& panelD = richD[side];
+
+          // The group ID
+          const auto groupID = pdIndex( pd, rich, side );
 
-        auto& richD  = pdData[rich];
-        auto& panelD = richD[side];
+          // get the entry in the group vector
+          auto& pdData   = panelD[groupID];
+          pdData.groupID = groupID;
 
-        // The group ID
-        const auto groupID = pdIndex( pd, rich, side );
+          // Get the DePD
+          const auto PD = dePD( pd );
+          if ( PD ) {
 
-        // get the entry in the group vector
-        auto& pdData = panelD[groupID];
+            // sanity checks
+            if ( pd.pdID() != PD->pdSmartID().pdID() ) {
+              std::ostringstream mess;
+              mess << "PD SmartID mis-match :- " << pd << " != " << PD->pdSmartID();
+              throw Rich::Exception( mess.str() );
+            }
 
-        // Get the DePD
-        const auto PD = dePD( pd );
-        if ( PD ) {
+            // add to pixel group size
+            pdData.effNumPixs += PD->effectiveNumActivePixels();
 
-          // sanity checks
-          if ( pd.pdID() != PD->pdSmartID().pdID() ) {
+            m_parent->debug() << " -> " << pd << " GroupID=" << groupID << " NPixs=" << PD->effectiveNumActivePixels()
+                              << endmsg;
+          } else {
             std::ostringstream mess;
-            mess << "PD SmartID mis-match :- " << pd << " != " << PD->pdSmartID();
+            mess << "  -> FAILED to load " << rich << " " << Rich::text( rich, side ) << " dePD for " << pd;
             throw Rich::Exception( mess.str() );
           }
 
-          // add to pixel group size
-          pdData.effNumPixs += PD->effectiveNumActivePixels();
-
-          // _ri_debug << "  -> index " << index << " Group ID " << groupID << " Eff NumPixs "
-          //          << PD->effectiveNumActivePixels() << endmsg;
-        } else {
-          std::ostringstream mess;
-          mess << "  -> FAILED to load " << rich << " " << Rich::text( rich, side ) << " dePD for " << pd;
-          throw Rich::Exception( mess.str() );
+          // end PD loop
         }
 
-        // end PD loop
+        m_parent->debug() << "Min Module IDs  " << minPanelIndex << endmsg;
       }
-    }
+    };
+
+    //-----------------------------------------------------------------------------
 
   } // namespace
 
@@ -252,8 +245,8 @@ namespace Rich::Future::Rec {
                         KeyValue{"DataCache", DeRichLocations::derivedCondition( name + "-DataCache" )}},
                        // outputs
                        {KeyValue{"PixelBackgroundsLocation", SIMDPixelBackgroundsLocation::Default}} ) {
-      // debug
-      // setProperty( "OutputLevel", MSG::VERBOSE );
+      // force debug
+      // setProperty( "OutputLevel", MSG::DEBUG ).ignore();
     }
 
     /// Initialization after creation
@@ -264,11 +257,12 @@ namespace Rich::Future::Rec {
         // Derived cached data
         addConditionDerivation( {Detector::PDInfo::DefaultConditionKey}, // inputs
                                 inputLocation<PixBkgdsDataCache>(),      // output
-                                [pdGroupSize = m_pdGroupSize.value()]( const Detector::PDInfo& pdInfo ) {
-                                  return PixBkgdsDataCache{pdInfo, pdGroupSize};
+                                [parent = this]( const Detector::PDInfo& pdInfo ) {
+                                  return PixBkgdsDataCache{pdInfo, parent};
                                 } );
         // debug info
         if ( m_ignoreExpSignal ) { _ri_debug << "Will ignore expected signals when computing backgrounds" << endmsg; }
+        if ( m_ignoreHitData ) { _ri_debug << "Will ignore hit data when computing backgrounds" << endmsg; }
       } );
     }
 
@@ -281,7 +275,260 @@ namespace Rich::Future::Rec {
                                      const PhotonYields::Vector&               detYieldsV,    //
                                      const SIMDPixelSummaries&                 pixels,        //
                                      const PixBkgdsDataCache&                  dataCache      //
-                                     ) const override;
+                                     ) const override {
+
+      // the backgrounds to return. Initialize to 0
+      SIMDPixelBackgrounds backgrounds( pixels.size(), SIMDFP::Zero() );
+
+      // Are we using the hit data ?
+      if ( !m_ignoreHitData ) {
+
+        // local cache of cluster indices
+        SIMD::STDVector<SIMDPDCopyNumber> indices( pixels.size(), SIMDPDCopyNumber::Zero() );
+
+        // The working data, copied from the default instance
+        auto pdData = dataCache.pdData;
+
+        // Zip the segment data together
+        const auto segRange = Ranges::ConstZip( segments, geomEffsPerPD, detYieldsV );
+
+        // -----------------------------------------------------------
+        // Fill the observed data
+        // -----------------------------------------------------------
+        _ri_debug << "Filling observed hit data" << endmsg;
+        for ( auto&& [pixel, index] : Ranges::Zip( pixels, indices ) ) {
+
+          // RICH and panel
+          const auto rich = pixel.rich();
+          const auto side = pixel.side();
+
+          // Get the data vector for this panel
+          auto& dataV = pdData[rich][side];
+
+          // Loop over the scalar entries for this SIMD pixel
+          for ( std::size_t i = 0; i < SIMDPixel::SIMDFP::Size; ++i ) {
+
+            // only use valid scalar info
+            if ( pixel.validMask()[i] ) {
+
+              // PD ID
+              const auto pd = pixel.smartID()[i].pdID();
+
+              // Get the PD copy number index
+              index[i] = dataCache.pdIndex( pd, rich, side );
+
+              _ri_verbo << "Hit PD " << pd << " " << index[i] << endmsg;
+
+              // Sanity check
+              if ( index[i] < dataV.size() ) {
+                // the working data object for this PD group
+                auto& data = dataV[index[i]];
+                // sanity check. Should correspond to an entry with size > 0
+                assert( data.effNumPixs > 0 );
+                // count the number of hits in each PD, in each RICH
+                ++( data.obsSignal );
+              } else {
+                ++m_pixIndexRangeErr;
+              }
+
+            } // valid check
+
+          } // pixel scalar loop
+
+        } // SIMD pixels
+
+        // -----------------------------------------------------------
+        // Now the expected signals, based on the track information
+        // loop over tracks (via the hypo values)
+        // -----------------------------------------------------------
+        if ( !m_ignoreExpSignal.value() ) {
+
+          // loop over track data
+          _ri_debug << "Filling track expectations" << endmsg;
+          for ( const auto&& [tkRels, tkHypo] : Ranges::ConstZip( tkToSegs, tkHypos ) ) {
+            _ri_debug << " -> Track " << tkRels.tkKey << " " << tkHypo << endmsg;
+
+            // Loop over the segments for this track
+            for ( const auto& iSeg : tkRels.segmentIndices ) {
+              // extract from the segment data tuple
+              const auto& [segment, geomEffs, detYield] = segRange[iSeg];
+
+              // which RICH
+              const auto rich = segment.rich();
+
+              _ri_debug << "  -> Segment " << iSeg << " " << rich << " " << segment.radiator()
+                        << " DetPhots=" << detYield[tkHypo] << endmsg;
+
+              // Loop over the per PD geom. effs. for this track hypo
+              for ( const auto& PD : geomEffs[tkHypo] ) {
+                // expected signal for this PD
+                const auto sig = detYield[tkHypo] * PD.eff;
+                // index
+                const auto index = dataCache.pdIndex( PD.pdID, rich );
+                _ri_verbo << "   -> PD " << PD.pdID << " index=" << index << " DetPhots=" << sig << endmsg;
+                // panel data vector
+                auto& dataV = ( pdData[rich] )[PD.pdID.panel()];
+                // Update the PD data map with this value
+                if ( index < dataV.size() ) {
+                  auto& data = dataV[index];
+                  // sanity check. Should correspond to an entry with size > 0
+                  assert( data.effNumPixs > 0 );
+                  // fill expected signal
+                  data.expSignal += sig;
+                } else {
+                  ++m_tkIndexRangeErr;
+                }
+              }
+            }
+          }
+        }
+
+        // -----------------------------------------------------------
+        // Now compute the background terms
+        // -----------------------------------------------------------
+
+        // Obtain background term PD by PD
+        for ( const auto rich : activeDetectors() ) {
+          _ri_debug << "Computing PD backgrounds in " << rich << endmsg;
+
+          // iteration loop
+          FP           rnorm = 0.0f; // normalisation value between iterations
+          bool         cont  = true; // loop abort
+          unsigned int iter  = 0;    // iteration count
+          while ( cont && ++iter <= m_maxBkgIterations ) {
+
+            _ri_debug << " -> Iteration " << iter << endmsg;
+
+            unsigned int nBelow( 0 ), nAbove( 0 );
+            FP           tBelow( 0.0f );
+
+            // loop over panels
+            for ( auto& panelData : pdData[rich] ) {
+              // Loop over PD in this panel
+              for ( auto& iPD : panelData ) {
+                // Only process PDs with observed hits
+                if ( iPD.obsSignal > 0 ) {
+
+                  // The background for this PD
+                  auto& bkg = iPD.expBackgrd;
+
+                  if ( 1 == iter ) {
+                    // First iteration, just set background for this PD to the difference
+                    // between the observed and expected number of hits in the PD
+                    bkg = static_cast<FP>( iPD.obsSignal ) - iPD.expSignal;
+                  } else {
+                    // For additional interations apply the normalisation factor
+                    bkg = ( bkg > 0 ? bkg - rnorm : 0 );
+                  }
+                  _ri_debug << "  -> PD Group " << iPD.groupID << " : obs= " << iPD.obsSignal
+                            << " exp= " << iPD.expSignal << " bkg=" << bkg << endmsg;
+
+                  if ( bkg < 0.0 ) {
+                    // Count the number of PDs below expectation for this iteration
+                    ++nBelow;
+                    // save the total amount below expectation
+                    tBelow += fabs( bkg );
+                  } else if ( bkg > 0.0 ) {
+                    // count the number of PDs above expectation
+                    ++nAbove;
+                  }
+
+                } // with observed hits
+              }   // end loop over signal PDs
+            }     // end loop over panels
+
+            _ri_debug << "  -> Above = " << nAbove << " Below = " << nBelow << endmsg;
+
+            if ( nBelow > 0 && nAbove > 0 ) {
+              // we have some PDs above and below expectation
+              // calculate the amount of signal below per above PD
+              rnorm = tBelow / ( static_cast<FP>( nAbove ) );
+              _ri_debug << "   -> Correction factor per PD above = " << rnorm << endmsg;
+            } else {
+              _ri_debug << "  -> Aborting iterations" << endmsg;
+              cont = false;
+            }
+
+          } // while loop
+
+        } // end rich loop
+
+        // -----------------------------------------------------------
+        // Normalise the PD backgrounds
+        // -----------------------------------------------------------
+
+        // Loop over the RICH data maps
+        _ri_verbo << "Normalising the backgrounds" << endmsg;
+        for ( const auto rich : activeDetectors() ) {
+          // loop over panels
+          for ( auto& panel : pdData[rich] ) {
+            // Loop over the PD data objects
+            for ( auto& pd : panel ) {
+              // PDs with signal
+              _ri_verbo << " -> PD info " << pd.obsSignal << " " << pd.expBackgrd << " " << pd.effNumPixs << endmsg;
+              if ( pd.obsSignal > 0 ) {
+                // normalise background for this PD
+                pd.expBackgrd = ( pd.expBackgrd > 0.0 ? pd.expBackgrd / pd.effNumPixs : 0.0 );
+                // rescale by the overall weight factor for the RICH this PD is in
+                pd.expBackgrd *= m_bkgWeight[rich];
+                // Apply threshold
+                if ( pd.expBackgrd < m_thresPixBkg[rich] ) { pd.expBackgrd = 0.0; }
+                // apply min and max pixel background limits
+                pd.expBackgrd = std::clamp( pd.expBackgrd, m_minPixBkg[rich], m_maxPixBkg[rich] );
+              }
+            }
+          }
+        }
+
+        // -----------------------------------------------------------
+        // Fill the background values into the output data structure
+        // -----------------------------------------------------------
+
+        _ri_debug << "Filling the final pixel backgrounds" << endmsg;
+        for ( auto&& [pixel, bkg, index] : Ranges::Zip( pixels, backgrounds, std::as_const( indices ) ) ) {
+
+          // RICH flags
+          const auto rich = pixel.rich();
+          const auto side = pixel.side();
+
+          // get the panel data vector
+          auto& dataV = ( pdData[rich] )[side];
+
+          // Loop over the scalar entries for this SIMD pixel
+          for ( std::size_t i = 0; i < SIMDPixel::SIMDFP::Size; ++i ) {
+
+            // only process valid scalar info
+            if ( pixel.validMask()[i] ) {
+
+              // index for this PD
+              const auto indx = index[i];
+
+              // get the data object for this PD
+              if ( indx < dataV.size() ) {
+                // data for this PD
+                auto& data = dataV[indx];
+                // update the pixel background
+                bkg[i] = data.expBackgrd;
+                _ri_debug << " -> " << pixel.smartID()[i].pdID() << " Bkg " << bkg[i] << endmsg;
+              } else {
+                ++m_bkgIndexRangeErr;
+                bkg[i] = 0;
+              }
+
+            } // valid entries
+
+          } // scalar loop
+
+        } // pixel loop
+
+      } // Using hit data
+
+      // -----------------------------------------------------------
+      // All done, so return
+      // -----------------------------------------------------------
+
+      return backgrounds;
+    }
 
   private:
     // properties
@@ -296,21 +543,24 @@ namespace Rich::Future::Rec {
 
     /// Maximum pixel background value, for each RICH
     Gaudi::Property<DetectorArray<FP>> m_maxPixBkg{
-        this, "MaxPixelBackground", {9e9f, 9e9f}, "Maximum pixel background for each RICH"};
+        this, "MaxPixelBackground", {99.9f, 99.9f}, "Maximum pixel background for each RICH"};
+
+    /// Threshold pixel background. Values below this will be reset to 0.
+    Gaudi::Property<DetectorArray<FP>> m_thresPixBkg{
+        this, "ThresholdBackground", {0.001f, 0.001f}, "Threshold background values"};
 
     /** Ignore the expected signal when computing the background terms.
         Effectively, will assume all observed hits are background */
     Gaudi::Property<bool> m_ignoreExpSignal{this, "IgnoreExpectedSignals", false,
-                                            "Ignore expectations when calculating backgrounds"};
+                                            "Ignore track expectations when calculating backgrounds"};
+
+    /// Ignore the hit data. Effectively results in zero background values.
+    Gaudi::Property<bool> m_ignoreHitData{this, "IgnoreHitData", false, "Ignore hit data when forming backgrounds"};
 
     /// Background 'weight' for each RICH
     Gaudi::Property<DetectorArray<float>> m_bkgWeight{
         this, "PDBckWeights", {1.0f, 1.0f}, "Weights to apply to the background terms for each RICH"};
 
-    /// PD Group Size for each RICH
-    Gaudi::Property<DetectorArray<unsigned int>> m_pdGroupSize{
-        this, "PDGroupSize", {4u, 4u}, "The number of PDs to group together for the background calculation"};
-
   private:
     // messaging
 
@@ -322,269 +572,11 @@ namespace Rich::Future::Rec {
     mutable ErrorCounter m_bkgIndexRangeErr{this, "Bkg PD index out of range !!"};
   };
 
-} // namespace Rich::Future::Rec
-
-using namespace Rich::Future::Rec;
-
-//-----------------------------------------------------------------------------
-
-SIMDPixelBackgrounds                                                                                //
-SIMDPixelBackgroundsEstiAvHPD::operator()( const Relations::TrackToSegments::Vector& tkToSegs,      //
-                                           const TrackPIDHypos&                      tkHypos,       //
-                                           const LHCb::RichTrackSegment::Vector&     segments,      //
-                                           const GeomEffsPerPDVector&                geomEffsPerPD, //
-                                           const PhotonYields::Vector&               detYieldsV,    //
-                                           const SIMDPixelSummaries&                 pixels,        //
-                                           const PixBkgdsDataCache&                  dataCache      //
-                                           ) const {
-
-  // the backgrounds to return. Initialize to 0
-  SIMDPixelBackgrounds backgrounds( pixels.size(), SIMDFP::Zero() );
-
-  // local cache of cluster indices
-  SIMD::STDVector<SIMDPDCopyNumber> indices( pixels.size(), SIMDPDCopyNumber::Zero() );
-
-  // The working data, copied from the default instance
-  auto pdData = dataCache.pdData;
-
-  // Zip the segment data together
-  const auto segRange = Ranges::ConstZip( segments, geomEffsPerPD, detYieldsV );
-
-  // -----------------------------------------------------------
-  // Fill the observed data
-  // -----------------------------------------------------------
-  for ( auto&& [pixel, index] : Ranges::Zip( pixels, indices ) ) {
-
-    // RICH and panel
-    const auto rich = pixel.rich();
-    const auto side = pixel.side();
-
-    // Get the data vector for this panel
-    auto& dataV = pdData[rich][side];
-
-    // Loop over the scalar entries for this SIMD pixel
-    for ( std::size_t i = 0; i < SIMDPixel::SIMDFP::Size; ++i ) {
-
-      // only use valid scalar info
-      if ( pixel.validMask()[i] ) {
-
-        // PD ID
-        const auto pd = ( pixel.smartID()[i] ).pdID();
-
-        // Get the PD copy number index
-        index[i] = dataCache.pdIndex( pd, rich, side );
-
-        //_ri_verbo << "Hit PD " << pd << " " << index[i] << endmsg;
-
-        // Sanity check
-        if ( index[i] < dataV.size() ) {
-          // the working data object for this PD group
-          auto& data = dataV[index[i]];
-          // sanity check. Should correspond to an entry with size > 0
-          assert( data.effNumPixs > 0 );
-          // count the number of hits in each PD, in each RICH
-          ++( data.obsSignal );
-        } else {
-          ++m_pixIndexRangeErr;
-        }
-
-      } // valid check
-
-    } // pixel scalar loop
-
-  } // SIMD pixels
-
-  // -----------------------------------------------------------
-  // Now the expected signals, based on the track information
-  // loop over tracks (via the hypo values)
-  // -----------------------------------------------------------
-  if ( !m_ignoreExpSignal.value() ) {
-
-    // loop over track data
-    for ( const auto&& [tkRels, tkHypo] : Ranges::ConstZip( tkToSegs, tkHypos ) ) {
-      //_ri_debug << " -> Track " << tkRels.tkKey << " " << tkHypo << endmsg;
-
-      // Loop over the segments for this track
-      for ( const auto& iSeg : tkRels.segmentIndices ) {
-        // extract from the segment data tuple
-        const auto& [segment, geomEffs, detYield] = segRange[iSeg];
-
-        // which RICH
-        const auto rich = segment.rich();
-
-        //_ri_debug << "  -> Segment " << iSeg << " " << rich
-        //          << " " << segment.radiator()
-        //          << " DetPhots=" << detYield[tkHypo] << endmsg;
-
-        // Loop over the per PD geom. effs. for this track hypo
-        for ( const auto& PD : geomEffs[tkHypo] ) {
-          // expected signal for this PD
-          const auto sig = detYield[tkHypo] * PD.eff;
-          // index
-          const auto index = dataCache.pdIndex( PD.pdID, rich );
-          //_ri_verbo << "Tk  PD " << PD.pdID << index << endmsg;
-          // panel data vector
-          auto& dataV = ( pdData[rich] )[PD.pdID.panel()];
-          // Update the PD data map with this value
-          if ( index < dataV.size() ) {
-            auto& data = dataV[index];
-            // sanity check. Should correspond to an entry with size > 0
-            assert( data.effNumPixs > 0 );
-            // fill expected signal
-            data.expSignal += sig;
-            //_ri_debug << "   -> " << LHCb::RichSmartID(PD.first) << " DetPhots=" << sig << endmsg;
-          } else {
-            ++m_tkIndexRangeErr;
-          }
-        }
-      }
-    }
-  }
-
-  // -----------------------------------------------------------
-  // Now compute the background terms
-  // -----------------------------------------------------------
-
-  // Obtain background term PD by PD
-  for ( const auto rich : activeDetectors() ) {
-    //_ri_debug << "Computing PD backgrounds in " << rich << endmsg;
+  //=============================================================================
 
-    FP rnorm = 0.0f; // normalisation value between iterations
+  // Declaration of the Algorithm Factory
+  DECLARE_COMPONENT( SIMDPixelBackgroundsEstiAvHPD )
 
-    // iteration loop
-    bool         cont = true; // loop abort
-    unsigned int iter = 0;    // iteration count
-    while ( cont && ++iter <= m_maxBkgIterations ) {
+  //=============================================================================
 
-      //_ri_debug << " -> Iteration " << iter << endmsg;
-
-      unsigned int nBelow( 0 ), nAbove( 0 );
-      FP           tBelow( 0.0f );
-
-      // loop over panels
-      for ( auto& panelData : pdData[rich] ) {
-        // Loop over PD in this panel
-        for ( auto& iPD : panelData ) {
-          // Only process PDs with observed hits
-          if ( iPD.obsSignal > 0 ) {
-
-            // The background for this PD
-            auto& bkg = iPD.expBackgrd;
-
-            if ( 1 == iter ) {
-              // First iteration, just set background for this PD to the difference
-              // between the observed and and expected number of hits in the PD
-              //_ri_debug << "  -> PD " << pd << " obs. = " << obs << " exp. = " << exp << endmsg;
-              bkg = static_cast<FP>( iPD.obsSignal ) - iPD.expSignal;
-            } else {
-              // For additional interations apply the normalisation factor
-              bkg = ( bkg > 0 ? bkg - rnorm : 0 );
-            }
-
-            if ( bkg < 0.0 ) {
-              // Count the number of PDs below expectation for this iteration
-              ++nBelow;
-              // save the total amount below expectation
-              tBelow += fabs( bkg );
-            } else if ( bkg > 0.0 ) {
-              // count the number of PDs above expectation
-              ++nAbove;
-            }
-
-          } // with observed hits
-        }   // end loop over signal PDs
-      }     // end loop over panels
-
-      //_ri_debug << "  -> Above = " << nAbove << " Below = " << nBelow << endmsg;
-
-      if ( nBelow > 0 && nAbove > 0 ) {
-        // we have some PDs above and below expectation
-        // calculate the amount of signal below per above PD
-        rnorm = tBelow / ( static_cast<FP>( nAbove ) );
-        //_ri_debug << "   -> Correction factor per PD above = " << rnorm << endmsg;
-      } else {
-        //_ri_debug << "  -> Aborting iterations" << endmsg;
-        cont = false;
-      }
-
-    } // while loop
-
-  } // end rich loop
-
-  // -----------------------------------------------------------
-  // Normalise the PD backgrounds
-  // -----------------------------------------------------------
-
-  // Loop over the RICH data maps
-  for ( const auto rich : activeDetectors() ) {
-    // loop over panels
-    for ( auto& panel : pdData[rich] ) {
-      // Loop over the PD data objects
-      for ( auto& pd : panel ) {
-        // PDs with signal
-        //_ri_verbo << "PD info " << pd.obsSignal << " " << pd.expBackgrd << " " << pd.effNumPixs << endmsg;
-        if ( pd.obsSignal > 0 ) {
-          // normalise background for this PD
-          pd.expBackgrd = ( pd.expBackgrd > 0 ? pd.expBackgrd / pd.effNumPixs : 0 );
-          // rescale by the overall weight factor for the RICH this PD is in
-          pd.expBackgrd *= m_bkgWeight[rich];
-          // apply min and max pixel background limits
-          pd.expBackgrd = std::clamp( pd.expBackgrd, m_minPixBkg[rich], m_maxPixBkg[rich] );
-        }
-      }
-    }
-  }
-
-  // -----------------------------------------------------------
-  // Fill the background values into the output data structure
-  // -----------------------------------------------------------
-
-  for ( auto&& [pixel, bkg, index] : Ranges::Zip( pixels, backgrounds, std::as_const( indices ) ) ) {
-
-    // RICH flags
-    const auto rich = pixel.rich();
-    const auto side = pixel.side();
-
-    // get the panel data vector
-    auto& dataV = ( pdData[rich] )[side];
-
-    // Loop over the scalar entries for this SIMD pixel
-    for ( std::size_t i = 0; i < SIMDPixel::SIMDFP::Size; ++i ) {
-
-      // only process valid scalar info
-      if ( pixel.validMask()[i] ) {
-
-        // index for this PD
-        const auto indx = index[i];
-
-        // get the data object for this PD
-        if ( indx < dataV.size() ) {
-          // data for this PD
-          auto& data = dataV[indx];
-          // update the pixel background
-          bkg[i] = data.expBackgrd;
-          //_ri_verbo << rich << " Pix Bkg " << bkg[i] << endmsg;
-        } else {
-          ++m_bkgIndexRangeErr;
-          bkg[i] = 0;
-        }
-
-      } // valid entries
-
-    } // scalar loop
-
-  } // pixel loop
-
-  // -----------------------------------------------------------
-  // All done, so return
-  // -----------------------------------------------------------
-
-  return backgrounds;
-}
-
-//=============================================================================
-
-// Declaration of the Algorithm Factory
-DECLARE_COMPONENT( SIMDPixelBackgroundsEstiAvHPD )
-
-//=============================================================================
+} // namespace Rich::Future::Rec
-- 
GitLab


From b979493879bd5d6f7a8a023df9ddcea844dae4f2 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:25:01 +0100
Subject: [PATCH 08/67] RichSIMDSummaryPixels: Only print 4D info message when
 detector is enabled

---
 Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp
index b73887d91d0..49dcfb15473 100644
--- a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp
+++ b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp
@@ -59,7 +59,7 @@ namespace Rich::Future::Rec {
         // create the RICH smartID helper instance
         Rich::Utils::RichSmartIDs::addConditionDerivation( this );
         // loop over RICHes
-        for ( const auto rich : Rich::detectors() ) {
+        for ( const auto rich : activeDetectors() ) {
           if ( m_enable4D[rich] ) {
             info() << "4D pixels enabled for " << rich << " | Window = "   //
                    << ( m_avHitTime[rich] - m_timeWindow[rich] ) << " to " //
-- 
GitLab


From 64e2e9d083ecc1abc6436db285961bd751eb7abe Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:25:41 +0100
Subject: [PATCH 09/67] ConfiguredRichReco.py: Update for new background
 algorithm options

---
 .../RichFutureRecSys/ConfiguredRichReco.py     | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
index bb2c8cb04b2..e4ff88d22c5 100644
--- a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
+++ b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
@@ -418,15 +418,21 @@ def RichRecoSequence(
         # Ignore the expected signals based on the track information
         PDBackIgnoreExpSignals=[True, False, False, False],
 
+        # Ignore the hit data when computing backgrounds
+        PDBackIgnoreHitData=[False, False, False, False],
+
         # Minimum allowed pixel background value (RICH1,RICH2)
         PDBackMinPixBackground=[(0, 0), (0, 0), (0, 0), (0, 0)],
 
         # Maximum allowed pixel background value (RICH1,RICH2)
-        PDBackMaxPixBackground=[(999, 999), (999, 999), (999, 999), (999,
-                                                                     999)],
+        PDBackMaxPixBackground=[(99, 99), (99, 99), (99, 99), (99, 99)],
+
+        # Threshold values for background values
+        PDBackThresholds=[(0.005, 0.005), (0.005, 0.005), (0.005, 0.005),
+                          (0.005, 0.005)],
 
-        # Group Size for PDs  RICH1 RICH2
-        PDGroupSize=(4, 4),
+        # Background weights for each RICH
+        PDBckWeights=[(1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0)],
 
         # Likelihood minimizer options
 
@@ -1020,9 +1026,11 @@ def RichRecoSequence(
             pixBkgs.PixelBackgroundsLocation = "Rec/Rich/PixelBackgrounds/" + itN + "/" + name
             # Settings
             pixBkgs.IgnoreExpectedSignals = PDBackIgnoreExpSignals[it]
+            pixBkgs.IgnoreHitData = PDBackIgnoreHitData[it]
             pixBkgs.MinPixelBackground = PDBackMinPixBackground[it]
             pixBkgs.MaxPixelBackground = PDBackMaxPixBackground[it]
-            pixBkgs.PDGroupSize = PDGroupSize
+            pixBkgs.PDBckWeights = PDBckWeights[it]
+            pixBkgs.ThresholdBackground = PDBackThresholds[it]
 
             # Likelihood minimiser
             like = makeRichAlg(LikelihoodMinimiser,
-- 
GitLab


From c5b5890380c215edb92f596ad275ff3fb4afadd9 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:26:25 +0100
Subject: [PATCH 10/67] RichFutureRecSys/examples/RichFuture.py: Update for new
 background algorithm options

---
 Rich/RichFutureRecSys/examples/RichFuture.py | 34 +++++++++++++-------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index 835a8b1eb49..a51e6388757 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -55,9 +55,9 @@ rootFileBaseName = "RichFuture-" + myBuild + "-" + myConf + "-" + histos
 HistogramPersistencySvc().OutputFile = rootFileBaseName + "-Histos.root"
 
 # Event numbers
-nEvents = (100 if not batchMode else 99999999)
-EventSelector().PrintFreq = (10 if not batchMode else 250)
-#LHCbApp().SkipEvents      = 1184
+nEvents = (1000 if not batchMode else 99999999)
+EventSelector().PrintFreq = (100 if not batchMode else 250)
+#LHCbApp().SkipEvents      = 2
 
 # Just to initialise
 DDDBConf()
@@ -107,13 +107,12 @@ useMCHits = False
 
 # Get time windows from environment vars if set
 # otherwise use default values as passed.
-PixWin = float(os.getenv("PIXWIN", "3.0"))
-PhotWin = float(os.getenv("PHOTWIN", "0.25"))
+PixWin = float(os.getenv("PIXWIN", "1.0"))
+PhotWin = float(os.getenv("PHOTWIN", "0.1"))
 
 # Enable 4D reco in each RICH
-is4D = bool(os.getenv("ENABLE4D", "1"))
+is4D = "ENABLE4D" in os.environ
 enable4D = (is4D, is4D)
-#enable4D = (False, False)
 # Average expected time for signal
 avSignalTime = (13.03, 52.94)
 # Pixel time window size in each RICH (in ns)
@@ -315,6 +314,19 @@ detYieldPrecision = "Average"
 #tkCKResTreatment = "Functional"
 tkCKResTreatment = "Parameterised"
 
+# Pixel background weights
+WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ( "0.3" if enable4D[0] else "0.6" )))
+WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ( "0.3" if enable4D[0] else "0.6" )))
+pdBckWeights = [( WR1, WR2 ), ( WR1, WR2 ), ( WR1, WR2 ), ( WR1, WR2 )]
+
+# Hit treatment in background alg
+# Need to try and understand the difference here between best 3D and 4D tunings
+PDBackIgnoreHitData = [is4D, False, False, False]
+
+# background thresholds
+bT = 0.005
+bkgThres = [(bT, bT), (bT, bT), (bT, bT), (bT, bT)]
+
 # CK resolutions
 from RichFutureRecSys.ConfiguredRichReco import defaultNSigmaCuts
 
@@ -335,16 +347,12 @@ tkCKResScaleF = None  # Use nominal values
 finalPIDLoc = "Rec/Rich/PIDs"
 
 # DataType
-#dType = "2016"
 dType = "Upgrade"
 
 # Online Brunel mode.
 #online = True
 online = False
 
-# PD Grouping for backgrounds
-pdGroupSize = (4, 4)
-
 # Create missing track states
 createStates = False
 
@@ -387,7 +395,6 @@ RichRec = RichRecoSequence(
     radiators=rads,
     particles=parts,
     createMissingStates=createStates,
-    PDGroupSize=pdGroupSize,
     MinP=minP,
     MinPt=minPt,
     NRingPointsMax=ringPointsMax,
@@ -401,6 +408,9 @@ RichRec = RichRecoSequence(
     applyPixelClustering=pixelClustering,
     truncateCKAngles=truncateAngles,
     trackExtrapolator=tkExtrap,
+    PDBckWeights=pdBckWeights,
+    PDBackIgnoreHitData=PDBackIgnoreHitData,
+    PDBackThresholds=bkgThres,
     nIterations=nIts,
     LikelihoodThreshold=likeThres,
     inputTrackLocations=tkLocs,
-- 
GitLab


From 9d0081c482adfb1659a8d0b90fda3c8956f13be7 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 15:26:54 +0100
Subject: [PATCH 11/67] Improvements to RichFutureRecSys example job submission
 scripts

---
 .../RichFutureRecSys/examples/jobs/RunJobs.py | 93 ++++++++++++++-----
 Rich/RichFutureRecSys/examples/jobs/merge.py  | 38 ++++----
 Rich/RichFutureRecSys/examples/jobs/submit.sh |  2 +-
 3 files changed, 92 insertions(+), 41 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
index 18830d4eaef..d322e108947 100755
--- a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
+++ b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
@@ -25,46 +25,100 @@ parser.add_argument("-4d", "--enable4D", help="Enable 4D", action='store_true')
 parser.add_argument(
     "--pixwins",
     help="Pixel time window(s) (only for 4D)",
-    default="3.0,2.0,1.0",
+    default="1.0,3.0",
     type=str)
 parser.add_argument(
     "--photwins",
     help="Photon time window(s) (only for 4D)",
-    default="1.0,0.5,0.25,0.1,0.05",
+    default="1.0,0.5,0.25,0.1,0.05,0.01",
     type=str)
+parser.add_argument(
+    "--pixbckwR1",
+    help="Pixel background weights for RICH1",
+    default="",
+    type=str)
+parser.add_argument(
+    "--pixbckwR2",
+    help="Pixel background weights for RICH2",
+    default="",
+    type=str)
+parser.add_argument("-N", "--name", help="Job Name", default="Test", type=str)
 args = parser.parse_args()
 config = vars(args)
 print(config)
 
 enable4D = config["enable4D"]
-os.environ["ENABLE4D"] = str(enable4D)
-
-optsroot = "/usera/jonesc/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
+if enable4D:
+    os.environ["ENABLE4D"] = str(enable4D)
 
 # To Do. Pass these as parameters below.
+optsroot = "/usera/jonesc/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
 #taskOpts = optsroot+"/RichFuture.py"
 #dataOpts = optsroot+"/data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py"
 
 rootDir = os.getcwd()
 
+
+def unsetenv(var):
+    if var in os.environ:
+        del os.environ[var]
+
+
 for Lumi in config["lumis"].split(","):
 
     os.environ["LUMI"] = Lumi
 
     # Known number of input files for each lumi data set
     nFiles = (40 if float(Lumi) < 1.0e34 else 100)
-    # files per subjob. Less for the higher lumi (10^34) samples
+    # files per subjob. Less for the higher lumi (10^34) samples1
     filesPerJob = (4 if float(Lumi) < 1.0e34 else 2)
 
-    if enable4D:
+    for r1PixW in config["pixbckwR1"].split(","):
+        for r2PixW in config["pixbckwR2"].split(","):
+            if enable4D:
+                for PixWin in config["pixwins"].split(","):
+                    for PhotWin in config["photwins"].split(","):
+
+                        jobName = config["name"] + "/4D/lumi-" + Lumi
+                        if len(r1PixW) != 0:
+                            jobName += "/R1PixBckW-" + "{:.3f}".format(
+                                float(r1PixW))
+                            os.environ["PIXBCKWEIGHTRICH1"] = r1PixW
+                        if len(r2PixW) != 0:
+                            jobName += "/R2PixBckW-" + "{:.3f}".format(
+                                float(r2PixW))
+                            os.environ["PIXBCKWEIGHTRICH2"] = r2PixW
+                        if len(PixWin) != 0:
+                            jobName += "/PixWin-" + "{:.3f}".format(
+                                float(PixWin))
+                            os.environ["PIXWIN"] = PixWin
+                        if len(PhotWin) != 0:
+                            jobName += "/PhotWin-" + "{:.3f}".format(
+                                float(PhotWin))
+                            os.environ["PHOTWIN"] = PhotWin
+
+                        print("Submitting jobs for", jobName)
+                        subprocess.run([
+                            optsroot + "jobs/submit.sh", jobName,
+                            str(nFiles),
+                            str(filesPerJob)
+                        ])
+
+                        unsetenv("PIXBCKWEIGHTRICH1")
+                        unsetenv("PIXBCKWEIGHTRICH2")
+                        unsetenv("PIXWIN")
+                        unsetenv("PHOTWIN")
+
+            else:
+
+                jobName = config["name"] + "/3D/lumi-" + Lumi
+                if len(r1PixW) != 0:
+                    jobName += "/R1PixBckW-" + "{:.3f}".format(float(r1PixW))
+                    os.environ["PIXBCKWEIGHTRICH1"] = r1PixW
+                if len(r2PixW) != 0:
+                    jobName += "/R2PixBckW-" + "{:.3f}".format(float(r2PixW))
+                    os.environ["PIXBCKWEIGHTRICH2"] = r2PixW
 
-        for PixWin in config["pixwins"].split(","):
-            for PhotWin in config["photwins"].split(","):
-                os.environ["PIXWIN"] = PixWin
-                os.environ["PHOTWIN"] = PhotWin
-                jobName = "4D/lumi-" + Lumi + "/PixWin-" + "{:.3f}".format(
-                    float(PixWin)) + "/PhotWin-" + "{:.3f}".format(
-                        float(PhotWin))
                 print("Submitting jobs for", jobName)
                 subprocess.run([
                     optsroot + "jobs/submit.sh", jobName,
@@ -72,12 +126,5 @@ for Lumi in config["lumis"].split(","):
                     str(filesPerJob)
                 ])
 
-    else:
-
-        jobName = "3D/lumi-" + Lumi
-        print("Submitting jobs for", jobName)
-        subprocess.run([
-            optsroot + "jobs/submit.sh", jobName,
-            str(nFiles),
-            str(filesPerJob)
-        ])
+                unsetenv("PIXBCKWEIGHTRICH1")
+                unsetenv("PIXBCKWEIGHTRICH2")
diff --git a/Rich/RichFutureRecSys/examples/jobs/merge.py b/Rich/RichFutureRecSys/examples/jobs/merge.py
index 8a5dc124156..208e8103d7a 100755
--- a/Rich/RichFutureRecSys/examples/jobs/merge.py
+++ b/Rich/RichFutureRecSys/examples/jobs/merge.py
@@ -16,7 +16,7 @@ import glob, os
 import subprocess
 import multiprocessing
 from contextlib import closing
-
+from shutil import which
 
 def merge(dir):
 
@@ -68,19 +68,23 @@ def directory_find(atom, root='.'):
 
 if __name__ == '__main__':
 
-    # Find jobs to merge
-    #dirs = sorted(glob.glob("CondorJobs/*"))
-    dirs = directory_find("jobs", "CondorJobs")
-    print("Found", len(dirs), "directories to merge")
-    #print(dirs)
-
-    # Get the number of processors available
-    num_cpu = min(8, multiprocessing.cpu_count())
-    print("Using", num_cpu, "processing pools")
-    # threads
-    threads = []
-
-    # Run jobs in parrallel using process pool
-    with closing(multiprocessing.Pool(num_cpu)) as pool:
-        pool.map(merge, dirs)
-        pool.terminate()
+    # Check hadd exists before proceeding
+    merger="hadd"
+    if which(merger) is None :
+        print(merger, "not found")
+    else:
+
+        # Find jobs to merge
+        dirs = directory_find("jobs", "CondorJobs")
+        print("Found", len(dirs), "directories to merge")
+
+        # Get the number of processors available
+        num_cpu = min(16, multiprocessing.cpu_count())
+        print("Using", num_cpu, "processing pools")
+        # threads
+        threads = []
+
+        # Run jobs in parrallel using process pool
+        with closing(multiprocessing.Pool(num_cpu)) as pool:
+            pool.map(merge, dirs)
+            pool.terminate()
diff --git a/Rich/RichFutureRecSys/examples/jobs/submit.sh b/Rich/RichFutureRecSys/examples/jobs/submit.sh
index 8935da74b72..1cfd2228b1c 100755
--- a/Rich/RichFutureRecSys/examples/jobs/submit.sh
+++ b/Rich/RichFutureRecSys/examples/jobs/submit.sh
@@ -99,7 +99,7 @@ copy_to_spool           = true
 should_transfer_files   = YES
 when_to_transfer_output = ON_EXIT_OR_EVICT
 environment = CONDOR_ID=\$(Cluster).\$(Process)
-JobBatchName            = ${JobName/\//_}
+JobBatchName            = ${JobName}
 
 # Requirements
 Requirements = (POOL != "GENERAL" && HAS_r02 && OpSysAndVer == "CentOS7" && TARGET.has_avx2)
-- 
GitLab


From 2bec138103079e9f9ab9169f2b8fc012f410178c Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Mon, 23 Oct 2023 14:31:00 +0000
Subject: [PATCH 12/67] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/33376290
---
 Rich/RichFutureRecSys/examples/RichFuture.py | 6 +++---
 Rich/RichFutureRecSys/examples/jobs/merge.py | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index a51e6388757..437af61ef87 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -315,9 +315,9 @@ detYieldPrecision = "Average"
 tkCKResTreatment = "Parameterised"
 
 # Pixel background weights
-WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ( "0.3" if enable4D[0] else "0.6" )))
-WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ( "0.3" if enable4D[0] else "0.6" )))
-pdBckWeights = [( WR1, WR2 ), ( WR1, WR2 ), ( WR1, WR2 ), ( WR1, WR2 )]
+WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ("0.3" if enable4D[0] else "0.6")))
+WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ("0.3" if enable4D[0] else "0.6")))
+pdBckWeights = [(WR1, WR2), (WR1, WR2), (WR1, WR2), (WR1, WR2)]
 
 # Hit treatment in background alg
 # Need to try and understand the difference here between best 3D and 4D tunings
diff --git a/Rich/RichFutureRecSys/examples/jobs/merge.py b/Rich/RichFutureRecSys/examples/jobs/merge.py
index 208e8103d7a..de27e088b8b 100755
--- a/Rich/RichFutureRecSys/examples/jobs/merge.py
+++ b/Rich/RichFutureRecSys/examples/jobs/merge.py
@@ -18,6 +18,7 @@ import multiprocessing
 from contextlib import closing
 from shutil import which
 
+
 def merge(dir):
 
     # Find files in sub-jobs
@@ -69,8 +70,8 @@ def directory_find(atom, root='.'):
 if __name__ == '__main__':
 
     # Check hadd exists before proceeding
-    merger="hadd"
-    if which(merger) is None :
+    merger = "hadd"
+    if which(merger) is None:
         print(merger, "not found")
     else:
 
-- 
GitLab


From f59864d3edded324f170790bce5a07b683dc9b6a Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 23 Oct 2023 16:18:58 +0100
Subject: [PATCH 13/67] Decrease RICH pixel background likelihood weight to 0.6

---
 .../python/RichFutureRecSys/ConfiguredRichReco.py               | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
index e4ff88d22c5..4bfdc106aad 100644
--- a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
+++ b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
@@ -432,7 +432,7 @@ def RichRecoSequence(
                           (0.005, 0.005)],
 
         # Background weights for each RICH
-        PDBckWeights=[(1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0)],
+        PDBckWeights=[(0.6, 0.6), (0.6, 0.6), (0.6, 0.6), (0.6, 0.6)],
 
         # Likelihood minimizer options
 
-- 
GitLab


From f8cb195828a705caa0b9c60614289e1a666cab3b Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 25 Oct 2023 13:20:42 +0100
Subject: [PATCH 14/67] RichSIMDQuarticPhotonReco: Fine tune application of
 time window to photons

---
 .../src/RichCommonQuarticPhotonReco.h         |  2 +-
 .../src/RichSIMDQuarticPhotonReco.cpp         | 27 ++++++++++++-------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichCommonQuarticPhotonReco.h b/Rich/RichFutureRecPhotonAlgorithms/src/RichCommonQuarticPhotonReco.h
index d4a2bc7f3eb..32d19319fdb 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichCommonQuarticPhotonReco.h
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichCommonQuarticPhotonReco.h
@@ -179,7 +179,7 @@ namespace Rich::Future::Rec {
     Gaudi::Property<RadiatorArray<bool>> m_ckValueTruncate{this, "TruncateCKAngles", {true, true, true}};
 
     /// Enabled 4D reconstruction
-    Gaudi::Property<DetectorArray<bool>> m_enable4D{this, "Enable4D", {false, false}};
+    Gaudi::Property<DetectorArray<bool>> m_enable4D{this, "Enable4D", {false, false}, "Enable 4D reconstruction"};
   };
 
 } // namespace Rich::Future::Rec
diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
index 7f21f7697d2..82918a6b03f 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
@@ -199,7 +199,7 @@ namespace Rich::Future::Rec {
 
     /// time window size for each RICH
     Gaudi::Property<DetectorArray<float>> m_timeWindow{
-        this, "TimeWindowSize", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}};
+        this, "TimeWindowSize", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}, "Time window to apply in each RICH"};
 
     Gaudi::Property<DetectorArray<float>> m_pdTransitTime{
         this, "PDTransitTime", {0.04605 * Gaudi::Units::ns, 0.04605 * Gaudi::Units::ns}};
@@ -368,7 +368,7 @@ SIMDQuarticPhotonReco::operator()( const LHCb::RichTrackSegment::Vector&     seg
           auto hypoMask = !pixmask;
           for ( const auto hypo : activeParticlesNoBT() ) {
             hypoMask |= ( abs( simd_tkCkAngles[hypo] - ckThetaEsti ) < simd_presel_scaled_tkCkRes[hypo] );
-            if ( all_of( hypoMask ) ) break;
+            if ( all_of( hypoMask ) ) { break; }
           }
           pixmask &= hypoMask;
 
@@ -694,18 +694,25 @@ SIMDQuarticPhotonReco::operator()( const LHCb::RichTrackSegment::Vector&     seg
           //  = origin time + transit time to radiator entry + track transit time in radiator to
           //    emission point + photon propagation time to photon detector + photoelectron
           //    transit time
-          const auto richTime = ( segPath / segVelocity ) + ( photPath / photonVelocity ) + pdTransitTime;
-          photDetTime         = richTime; // Save the RICH-only time to the photon object
+          // Save the RICH-only time to the photon object
+          photDetTime = ( segPath / segVelocity ) + ( photPath / photonVelocity ) + pdTransitTime;
 
           //_ri_verbo << "  -> reco.phot time " << photDetTime << endmsg;
           //_ri_verbo << "  ->  pix time " << pix.hitTime() << endmsg;
 
-          // Apply time window to select photons. Try slowest and fastest mass hypos.
-          // using the fact the PID container is sorted in mass (lightest to heaviest).
-          const auto slowestT = richTime + SIMDFP( segment.timeToRadEntry( activeParticlesNoBT().back() ) );
-          const auto fastestT = richTime + SIMDFP( segment.timeToRadEntry( activeParticlesNoBT().front() ) );
-          pixmask &= ( ( pix.hitTime() > ( fastestT - m_timeWindowSIMD[rich] ) ) &&
-                       ( pix.hitTime() < ( slowestT + m_timeWindowSIMD[rich] ) ) );
+          // Apply time window to select photons.
+          // Loop over mass hypos and apply OR of time window around each.
+          // Photon is kept if it is in any one of the windows.
+          // Only need confirmation for those not yet rejected already so start with !pixmask
+          auto hypoMask = !pixmask;
+          for ( const auto hypo : activeParticlesNoBT() ) {
+            const auto predT = photDetTime + SIMDFP( segment.timeToRadEntry( hypo ) );
+            hypoMask |= ( abs( pix.hitTime() - predT ) < m_timeWindowSIMD[rich] );
+            if ( all_of( hypoMask ) ) { break; }
+          }
+          pixmask &= hypoMask;
+
+          // Finally check if any photons survive.
           if ( none_of( pixmask ) ) {
             //_ri_verbo << "    -> photon FAILED time window test" << endmsg;
             continue;
-- 
GitLab


From 6c372643e0894d9aaeaeb452c0f6d019c6b86aef Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 25 Oct 2023 13:21:45 +0100
Subject: [PATCH 15/67] RichSIMDPhotonPredictedPixelSignal: When 4D enabled
 apply time window for each photon and mass hypothesis

---
 .../RichSIMDPhotonPredictedPixelSignal.cpp    | 26 +++++++++++++++++++
 .../RichFutureRecSys/ConfiguredRichReco.py    |  3 +++
 2 files changed, 29 insertions(+)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp
index 33eab628133..14971934b35 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp
@@ -145,6 +145,9 @@ namespace Rich::Future::Rec {
     /// cached min exp(arg) factor
     alignas( LHCb::SIMD::VectorAlignment ) RadiatorArray<SIMDFP> m_minExpArgF = {{}};
 
+    /// SIMD time windows
+    alignas( LHCb::SIMD::VectorAlignment ) DetectorArray<SIMDFP> m_timeWindowSIMD = {{}};
+
   private:
     /// The minimum expected track Cherenkov angle to be considered 'Above Threshold'
     Gaudi::Property<RadiatorArray<float>> m_minExpCKT{
@@ -165,6 +168,13 @@ namespace Rich::Future::Rec {
 
     /// The minimum argument value for the probability value
     Gaudi::Property<float> m_minArg{this, "MinExpArg", -80.0f};
+
+    /// Enable 4D time window
+    Gaudi::Property<DetectorArray<bool>> m_enable4D{this, "Enable4D", {false, false}, "Enable 4D reconstruction"};
+
+    /// time window size for each RICH
+    Gaudi::Property<DetectorArray<float>> m_timeWindow{
+        this, "TimeWindowSize", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}, "Time window to apply in each RICH"};
   };
 
 } // namespace Rich::Future::Rec
@@ -198,6 +208,14 @@ StatusCode SIMDPhotonPredictedPixelSignal::initialize() {
         return cache;
       } );
 
+  // loop over RICHes
+  for ( const auto rich : activeDetectors() ) {
+    m_timeWindowSIMD[rich] = SIMDFP( m_timeWindow[rich] );
+    if ( m_enable4D[rich] ) {
+      info() << "4D signals enabled for " << rich << " | Window = " << ( 2.0 * m_timeWindow[rich] ) << " ns" << endmsg;
+    }
+  }
+
   // loop over radiators
   for ( const auto rad : activeRadiators() ) {
     // cache SIMD versions of min prob values
@@ -291,6 +309,14 @@ OutData SIMDPhotonPredictedPixelSignal::operator()( const SIMDPixelSummaries&
       // selection mask
       auto mask = phot.validityMask() && ( arg > m_minExpArgF[rad] );
 
+      // Apply 4D time window if enabled
+      if ( m_enable4D[det] ) {
+        // Get time prediction for this mass hypo
+        const auto timePred = SIMDFP( segment.timeToRadEntry( id ) ) + phot.radTransitTime();
+        // Apply time window to mask
+        mask &= ( abs( pix.hitTime() - timePred ) < m_timeWindowSIMD[det] );
+      }
+
       // If any are OK continue
       if ( any_of( mask ) ) {
 
diff --git a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
index 4bfdc106aad..7dc1fd2bf57 100644
--- a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
+++ b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
@@ -941,6 +941,9 @@ def RichRecoSequence(
         # Options
         if minPhotonProbability:
             photPredSig.MinPhotonProbability = minPhotonProbability
+        # 4D reco
+        photPredSig.Enable4D = enable4DReco
+        photPredSig.TimeWindowSize = photonTimeWindow
 
         # The photon reco sequence
         phots = GaudiSequencer(
-- 
GitLab


From cba17cb263cc76c3a547d67a0b6e08f5a3ead5e1 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 25 Oct 2023 13:39:33 +0100
Subject: [PATCH 16/67] RichKaonIDCompareFiles.C: Clean up forming data sets

---
 Rec/GlobalReco/root/RichKaonIDCompareFiles.C | 103 +++++--------------
 1 file changed, 23 insertions(+), 80 deletions(-)

diff --git a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
index a79fda95fa6..b7dc9c470cd 100755
--- a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
+++ b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
@@ -19,98 +19,40 @@
 
 void RichKaonIDCompareFiles() {
 
-  const Long64_t nTracks = 1e6;
+  const std::string dir = "/usera/jonesc/LHCb/output/U2/MinBias";
 
-  const std::string dir = "/usera/jonesc/LHCb/output/U2";
+  // const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Rec/output/test";
 
   const std::string fName = "RichFuture-Feature-x86_64_v3-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
 
+  std::string bName = "NewTune-V2";
+
   std::map<std::string, std::vector<std::string>> dataSets;
+  for ( const std::string lumi : {"2.0e32", "2.0e33", "3.0e33", "1.0e34", "1.2e34", "1.5e34"} ) {
+    // 3D
+    dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi );
+    // 4D
+    for ( const std::string pixWin : {"3.000"} ) {
+      for ( const std::string photWin : {"1.000", "0.500", "0.250", "0.100", "0.050", "0.010"} ) {
+        const auto n = bName + "/4D/lumi-" + lumi + "/PixWin-" + pixWin + "/PhotWin-" + photWin;
+        dataSets[bName + "-4D-PhotWin_" + photWin].push_back( n );
+        dataSets[bName + "-4D-Lumi_" + lumi].push_back( n );
+      }
+    }
+  }
+
+  const Long64_t nTracks = 1e6;
 
-  // Compare lumis for 3D only
-  // const auto tags = std::array{"3D/lumi-2.0e32", "3D/lumi-2.0e33", "3D/lumi-3.0e33",
-  //                             "3D/lumi-1.0e34", "3D/lumi-1.2e34", "3D/lumi-1.5e34"};
-  // Compare at 2.0e33 different pixel windows
-  // const auto tags = std::array{"4D/lumi-2.0e33/PixWin-1.000/PhotWin-1.000",
-  //                              "4D/lumi-2.0e33/PixWin-2.000/PhotWin-1.000",
-  //                              "4D/lumi-2.0e33/PixWin-3.000/PhotWin-1.000",
-  //                              "4D/lumi-3.0e33/PixWin-1.000/PhotWin-1.000",
-  //                              "4D/lumi-3.0e33/PixWin-2.000/PhotWin-1.000",
-  //                              "4D/lumi-3.0e33/PixWin-3.000/PhotWin-1.000"};
-  // Photon window cuts
-  // const auto tags = std::array{
-  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-1.000",
-  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.500",
-  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.250",
-  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.100",
-  //  "4D/lumi-2.0e33/PixWin-1.000/PhotWin-0.050"
-  //};
-  std::string bName = "-V12";
-  // Tune Rich1 Background weight
-  dataSets["3D-Rich1Only" + bName + "-BckWeightTune"] = //
-      std::vector{"Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.900/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.800/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.700/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.600/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.500/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.400/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.300/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.200/R2PixBckW-1.000",
-                  "Rich1Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-0.100/R2PixBckW-1.000"};
-  dataSets["4D-Rich1Only" + bName + "-BckWeightTune"] = //
-      std::vector{"Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.900/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.800/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.700/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.600/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.500/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.400/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.300/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.200/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.100/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich1Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-0.050/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100"};
-  // Tune Rich2 Background weight
-  dataSets["3D-Rich2Only" + bName + "-BckWeightTune"] = //
-      std::vector{"Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.900",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.800",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.700",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.600",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.500",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.400",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.300",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.200",
-                  "Rich2Only" + bName + "/3D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.100"};
-  dataSets["4D-Rich2Only" + bName + "-BckWeightTune"] = //
-      std::vector{"Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-1.000/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.900/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.800/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.700/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.600/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.500/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.400/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.300/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.200/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.100/PixWin-3.000/PhotWin-0.100",
-                  "Rich2Only" + bName + "/4D/lumi-2.0e33/R1PixBckW-1.000/R2PixBckW-0.050/PixWin-3.000/PhotWin-0.100"};
+  const double GeV = 1000;
 
   for ( const auto& [dname, tags] : dataSets ) {
 
     // make a pid object
     auto pid = std::make_unique<GlobalPID>();
 
-    const double GeV = 1000;
-
-    const std::string R = "R1";
-    // const std::string R = "R2";
-
     // for ( const auto tktype : {GlobalPID::Long, GlobalPID::Upstream, GlobalPID::Downstream, GlobalPID::Ttrack} ) {
     for ( const auto tktype : {GlobalPID::Long} ) {
 
-      if ( tktype == GlobalPID::Upstream && R == "R2" ) { continue; }
-      if ( tktype == GlobalPID::Ttrack && R == "R1" ) { continue; }
-
       // Default Config Object
       GlobalPID::Configuration gConf;
 
@@ -123,7 +65,7 @@ void RichKaonIDCompareFiles() {
         gConf.minGraphX          = 80;
         gConf.maxGraphX          = 100;
         gConf.minGraphY          = 0.2;
-        gConf.maxGraphY          = 20;
+        gConf.maxGraphY          = 100;
       } else if ( GlobalPID::Upstream == tktype ) {
         gConf.useFixedGraphRange = true;
         gConf.minGraphX          = 40;
@@ -145,8 +87,9 @@ void RichKaonIDCompareFiles() {
       }
 
       // Stepping options
-      gConf.maxCut      = 35;
-      gConf.nSteps      = 50;
+      gConf.minCut      = -40;
+      gConf.maxCut      = 30;
+      gConf.nSteps      = 70;
       gConf.minMisIDeff = 0.2;
 
       // Momentum range
-- 
GitLab


From 26e78afb3aa586b309f5619767be6341531b9847 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:31:03 +0100
Subject: [PATCH 17/67] Add explicit braces for scope

---
 Rich/RichFutureRecCheckers/src/RichMCCherenkovResolution.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecCheckers/src/RichMCCherenkovResolution.cpp b/Rich/RichFutureRecCheckers/src/RichMCCherenkovResolution.cpp
index 79aa6a1ffff..52bacdc0368 100644
--- a/Rich/RichFutureRecCheckers/src/RichMCCherenkovResolution.cpp
+++ b/Rich/RichFutureRecCheckers/src/RichMCCherenkovResolution.cpp
@@ -327,7 +327,7 @@ void CherenkovResolution::operator()( const Summary::Track::Vector&
 
       // Radiator info
       const auto rad = seg.radiator();
-      if ( !radiatorIsActive( rad ) ) continue;
+      if ( !radiatorIsActive( rad ) ) { continue; }
 
       // get the expected CK theta values for this segment
       const auto& expCKangles = expTkCKThetas[rels.segmentIndex()];
-- 
GitLab


From 3209e6ad7f7cb93f7261858a2bcd58624c67244b Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:31:39 +0100
Subject: [PATCH 18/67] RichTrSegMakerFromMCRichTracks: Add better MCParticle
 selection, to more emulate 'Long' tracks

---
 Rich/RichFutureRecMCAlgorithms/CMakeLists.txt |  1 +
 .../src/RichTrSegMakerFromMCRichTracks.cpp    | 59 ++++++++++++++++---
 2 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt b/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
index 6fa47fbc277..bdd68935a60 100644
--- a/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
+++ b/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
@@ -33,6 +33,7 @@ gaudi_add_module(RichFutureRecMCAlgorithms
         LHCb::MCEvent
         Rec::RichFutureRecBase
         Rec::RichFutureRecEvent
+        Rec::PrKernel
 )
 
 # Fixes for GCC7.
diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
index 64028a50403..86b92cb3d9a 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
@@ -31,6 +31,7 @@
 #include "Event/LinksByKey.h"
 #include "Event/MCRichSegment.h"
 #include "Event/MCRichTrack.h"
+#include "Event/MCTrackInfo.h"
 #include "Event/State.h"
 #include "Event/Track.h"
 
@@ -49,6 +50,9 @@
 // Rec event model
 #include "RichFutureRecEvent/RichRecRelations.h"
 
+// Track tools
+#include "PrKernel/PrChecker.h"
+
 // GSL
 #include "gsl/gsl_math.h"
 
@@ -114,7 +118,9 @@ namespace Rich::Future::Rec::MC {
    *  @date   2023-06-29
    */
   class TrSegMakerFromMCRichTracks final
-      : public LHCb::Algorithm::MultiTransformer<OutData( LHCb::MCRichTracks const&, SegMakerDetInfo const& ),
+      : public LHCb::Algorithm::MultiTransformer<OutData( LHCb::MCRichTracks const&, //
+                                                          LHCb::MCProperty const&,   //
+                                                          SegMakerDetInfo const& ),
                                                  LHCb::DetDesc::usesBaseAndConditions<AlgBase<>, SegMakerDetInfo>> {
 
   public:
@@ -123,6 +129,7 @@ namespace Rich::Future::Rec::MC {
         : MultiTransformer( name, pSvcLocator,
                             // data inputs
                             {KeyValue{"MCRichTracksLocation", LHCb::MCRichTrackLocation::Default},
+                             KeyValue{"MCPropertyLocation", LHCb::MCPropertyLocation::TrackInfo},
                              // conditions input
                              KeyValue{"DetectorCache", DeRichLocations::derivedCondition( name + "-DetectorCache" )}},
                             // data outputs
@@ -138,7 +145,7 @@ namespace Rich::Future::Rec::MC {
       if ( !sc ) { return sc; }
 
       // Force debug messages
-      // sc = setProperty( "OutputLevel", MSG::VERBOSE );
+      //sc = setProperty( "OutputLevel", MSG::VERBOSE );
 
       if ( radiatorIsActive( Rich::Aerogel ) ) {
         error() << "Aerogel not supported in the 'RichFuture' framework" << endmsg;
@@ -166,6 +173,7 @@ namespace Rich::Future::Rec::MC {
   public:
     /// Algorithm execution via transform
     OutData operator()( LHCb::MCRichTracks const& mcRichtracks, //
+                        LHCb::MCProperty const&   mcProps,      //
                         SegMakerDetInfo const&    detInfo ) const override {
 
       _ri_debug << "Found " << mcRichtracks.size() << " MCRichTracks" << endmsg;
@@ -185,6 +193,9 @@ namespace Rich::Future::Rec::MC {
       using TkToMCPs = std::unordered_map<const LHCb::MCParticle*, std::vector<const LHCb::Track*>>;
       TkToMCPs tkToMCPs;
 
+      // For reconstructibility check
+      MCTrackInfo trackInfo( mcProps );
+
       // Loop over MC Rich Tracks
       for ( const auto mcRichTk : mcRichtracks ) {
         // sanity check
@@ -195,17 +206,45 @@ namespace Rich::Future::Rec::MC {
         const auto mcp = mcRichTk->mcParticle();
         if ( !mcp ) { continue; }
 
+        // get charge
         const auto charge = mcp->particleID().threeCharge() / 3;
         if ( 1 != abs( charge ) ) { continue; } // for some reason sometimes happens ...
 
         // Check we have an origin vertex
-        const auto mc_orig_v = mcp->primaryVertex();
-        if ( !mc_orig_v ) { continue; }
+        const auto mcp_orig_pv = mcp->primaryVertex();
+        if ( !mcp_orig_pv ) { continue; }
+        _ri_verbo << "Origin Primary Vertex " << mcp_orig_pv->position() << endmsg;
+
+        // Check origin vertex position
+        const auto mcp_orig_v = mcp->originVertex();
+        if ( !mcp_orig_v ) { continue; }
+        _ri_verbo << "Origin Vertex " << mcp_orig_v->position() << endmsg;
+        if ( m_tkOriginTol[0] < fabs( mcp_orig_v->position().X() ) || //
+             m_tkOriginTol[1] < fabs( mcp_orig_v->position().Y() ) || //
+             m_tkOriginTol[2] < fabs( mcp_orig_v->position().Z() ) ) {
+          _ri_verbo << " -> Out of range -> rejected" << endmsg;
+          continue;
+        }
 
         // Check MCParticle momentum vector
         const auto mcp_vect = mcp->momentum().Vect();
         if ( mcp->momentum().Pt() < m_minPt ) { continue; }
 
+        // Check required RICH segments
+        for ( const auto radiator : detInfo.radiators ) {
+          const auto rad = radiator->radiatorID();
+          if ( m_reqSegs[rad] && !mcRichTk->segmentInRad( rad ) ) {
+            _ri_verbo << " -> Has no " << rad << " segment -> rejected" << endmsg;
+            continue;
+          }
+        }
+
+        // Check MCParticle is reconstructible as a Long track
+        if ( LHCb::Pr::Checker::reconstructibleType( mcp, LHCb::Pr::Checker::RecAs::isNotLong, trackInfo ).value() ) {
+          _ri_verbo << " -> MCParticle is not reconstructible as Long -> rejected" << endmsg;
+          continue;
+        }
+
         // Create a fake 'reco' track for this MC track
         auto tk = std::make_unique<LHCb::Track>();
 
@@ -220,10 +259,10 @@ namespace Rich::Future::Rec::MC {
           const auto        qOvP = ( p2 > 0 ? charge / std::sqrt( p2 ) : 999 );
           const LHCb::State state( Gaudi::TrackVector{x, y, tx, ty, qOvP}, z, loc );
           _ri_verbo << "Created State : " << state << endmsg;
-          tk->addToStates( state );
+          tk->addToStates( std::move( state ) );
         };
 
-        // Create 'first' state
+        // Create 'first' state from origin vertex
         makeState( mc_orig_v->position(), mcp_vect, LHCb::State::Location::FirstMeasurement );
 
         // Fake some parameters
@@ -306,7 +345,7 @@ namespace Rich::Future::Rec::MC {
           segments.emplace_back( std::move( intersects ), midPoint, midStateMomentum, //
                                  rad, radiator->rich(),                               //
                                  stateErrs, stateErrs, stateErrs,                     //
-                                 mc_orig_v->position4vector() );
+                                 mcp_orig_pv->position4vector() );
 
           // Set mean photon energy
           segments.back().setAvPhotonEnergy( richPartProps()->meanPhotonEnergy( rad ) );
@@ -382,6 +421,12 @@ namespace Rich::Future::Rec::MC {
     /// Minimum z position for states in each radiator (mm)
     Gaudi::Property<RadiatorArray<double>> m_minZ{this, "MinStateZ", {800, 800, 9000}};
 
+    /// Tolerance on track origin w.r.t. (0,0,0)
+    Gaudi::Property<std::array<double, 3>> m_tkOriginTol{this, "TrackOriginTol", {1.0, 1.0, 100.0}};
+
+    /// Require segments in given radiator
+    Gaudi::Property<RadiatorArray<bool>> m_reqSegs{this, "RequireSegment", {false, false, true}};
+
   }; // namespace Rich::Future::Rec::MC
 
   //=============================================================================
-- 
GitLab


From 984ac65944d385ce637606eea3782b0dfc531f98 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:32:50 +0100
Subject: [PATCH 19/67] RichDetectorHits: Expand #hit range to 20k

---
 Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
index 87eee65fc90..e15224d7ff7 100644
--- a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
@@ -161,10 +161,10 @@ namespace Rich::Future::Rec::Moni {
       for ( const auto rich : activeDetectors() ) {
         ok &= saveAndCheck( h_nTotalPixsPerPD[rich],                                   //
                             richHisto1D( Rich::HistogramID( "nTotalPixsPerPD", rich ), //
-                                         "Average overall PD occupancy (nHits>0)", 0.5, 64.5, 65 ) );
+                                         "Average overall PD occupancy (nHits>0)", 0.5, 64.5, 64 ) );
         ok &= saveAndCheck( h_nTotalPixs[rich],                                   //
                             richHisto1D( Rich::HistogramID( "nTotalPixs", rich ), //
-                                         "Overall occupancy (nHits>0)", 0, m_maxPixels, nBins1D() ) );
+                                         "Overall occupancy (nHits>0)", 0.5, m_maxPixels + 0.5, m_maxPixels / 100 ) );
         ok &= saveAndCheck( h_nActivePDs[rich],                                   //
                             richHisto1D( Rich::HistogramID( "nActivePDs", rich ), //
                                          "# Active PDs (nHits>0)", -0.5, 2000.5, 2001 ) );
@@ -230,7 +230,7 @@ namespace Rich::Future::Rec::Moni {
 
   private:
     /// Maximum pixels
-    Gaudi::Property<unsigned int> m_maxPixels{this, "MaxPixels", 10000u};
+    Gaudi::Property<unsigned int> m_maxPixels{this, "MaxPixels", 20000u};
 
   private:
     // data
-- 
GitLab


From 6537ebee8d468d460fbcfaef4ddc55d4c285120e Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:33:28 +0100
Subject: [PATCH 20/67] ConfiguredRichReco: Add configuration to allow maximum
 PD occupancy to be set

---
 .../python/RichFutureRecSys/ConfiguredRichReco.py             | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
index 7dc1fd2bf57..4fd8105c541 100644
--- a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
+++ b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
@@ -303,6 +303,9 @@ def RichRecoSequence(
         # Maximum number of clusters GEC cut
         maxClusters=200000,
 
+        # Maximum PD occupancy
+        maxPDOccupancy=(64, 64),
+
         # Should pixel clustering be run, for either ( RICH1, RICH2 )
         applyPixelClustering=(False, False),
 
@@ -536,6 +539,7 @@ def RichRecoSequence(
     # Options
     richCluster.ApplyPixelClustering = applyPixelClustering
     richCluster.MaxClusters = maxClusters
+    richCluster.AbsoluteMaxPDOcc = maxPDOccupancy
     # 4D reco
     richCluster.Enable4D = enable4DReco
     richCluster.AvHitTime = averageHitTime
-- 
GitLab


From cf37350011a4bd8eacc931171cb3ae278ed01c6b Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:34:35 +0100
Subject: [PATCH 21/67] RichFutureRecSys: Rework example data files for
 Upgrade2

---
 .../PMTs/UpgradeII/NoSpill/DIGI/10000000.py   | 13 +++
 .../PMTs/UpgradeII/NoSpill/DIGI/30000000.py   | 78 +---------------
 .../data/PMTs/UpgradeII/NoSpill/DIGI/files.py | 90 +++++++++++++++++++
 .../PMTs/UpgradeII/WithSpill/DIGI/10000000.py | 13 +++
 .../PMTs/UpgradeII/WithSpill/DIGI/30000000.py | 78 +---------------
 .../PMTs/UpgradeII/WithSpill/DIGI/files.py    | 90 +++++++++++++++++++
 6 files changed, 210 insertions(+), 152 deletions(-)
 create mode 100644 Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/10000000.py
 create mode 100644 Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
 create mode 100644 Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py
 create mode 100644 Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py

diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/10000000.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/10000000.py
new file mode 100644
index 00000000000..505dbcbd9ad
--- /dev/null
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/10000000.py
@@ -0,0 +1,13 @@
+###############################################################################
+# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration      #
+#                                                                             #
+# This software is distributed under the terms of the GNU General Public      #
+# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
+#                                                                             #
+# In applying this licence, CERN does not waive the privileges and immunities #
+# granted to it by virtue of its status as an Intergovernmental Organization  #
+# or submit itself to any jurisdiction.                                       #
+###############################################################################
+
+import os
+os.environ["LHCB_EVENT_TYPE"] = "10000000"
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/30000000.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/30000000.py
index edb6ea62f6a..bf44b7b2603 100644
--- a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/30000000.py
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/30000000.py
@@ -9,79 +9,5 @@
 # or submit itself to any jurisdiction.                                       #
 ###############################################################################
 
-from __future__ import print_function
-from Gaudi.Configuration import *
-import glob, os
-from GaudiConf import IOHelper
-
-# name tag
-tag = "U2-NoSpill"
-
-# Choose sample luminosity
-lumi = os.getenv("LUMI", "2.0e33")
-
-# DetDesc DB tags
-dbTag = "dddb-20221004"
-cdTag = "sim-20221220-vc-md100"
-
-# Event type
-evType = "30000000"
-
-relPath = "data/MC/UpgradeII/" + evType + "/" + dbTag + "/" + cdTag + "/" + tag + "-lumi_" + lumi + "/DIGI/"
-
-# Check what is available
-searchPaths = [
-    # Cambridge
-    "/usera/jonesc/NFS/" + relPath,
-    # CERN EOS
-    "/eos/lhcb/user/j/jonrob/" + relPath,
-]
-
-print("Data Files :-")
-data = []
-for path in searchPaths:
-    files = sorted(glob.glob(path + "*.digi"))
-    data += ["'PFN:" + file for file in files]
-    for f in files:
-        print(f)
-
-# Batch options ?
-if "CONDOR_FILE_BATCH" in os.environ:
-    # Use env vars to define reduced file range for this job
-    batch = int(os.environ["CONDOR_FILE_BATCH"])
-    nfiles = int(os.environ["CONDOR_FILES_PER_BATCH"])
-    print("CONDOR_FILE_BATCH", batch)
-    print("CONDOR_FILES_PER_BATCH", nfiles)
-    firstFile = batch * nfiles
-    lastFile = (batch + 1) * nfiles
-    if firstFile <= len(data):
-        if lastFile > len(data): lastFile = len(data)
-        print("Using restricted file range", firstFile, lastFile)
-        data = data[firstFile:lastFile]
-        for f in data:
-            print(" ", f)
-    else:
-        print("WARNING: File range outside input data list")
-        data = []
-
-IOHelper('ROOT').inputFiles(data, clear=True)
-FileCatalog().Catalogs = ['xmlcatalog_file:out.xml']
-
-from Configurables import LHCbApp, DDDBConf
-LHCbApp().Simulation = True
-LHCbApp().DataType = "Upgrade"
-LHCbApp().DDDBtag = dbTag
-from DDDB.CheckDD4Hep import UseDD4Hep
-if UseDD4Hep:
-    # To Be Seen what is correct here...
-    # https://gitlab.cern.ch/lhcb-conddb/lhcb-conditions-database/-/merge_requests/26
-    LHCbApp().CondDBtag = "jonrob/all-pmts-active"
-    # Use a geometry from before changes to RICH1
-    # https://gitlab.cern.ch/lhcb/Detector/-/merge_requests/205
-    DDDBConf().GeometryVersion = 'run3/before-rich1-geom-update-26052022'
-else:
-    LHCbApp().CondDBtag = cdTag
-
-from Configurables import LHCb__UnpackRawEvent as UnpackRawEvent
-UnpackRawEvent('UnpackODIN').RawEventLocation = 'DAQ/RawEvent'
-UnpackRawEvent('UnpackRich').RawEventLocation = 'DAQ/RawEvent'
+import os
+os.environ["LHCB_EVENT_TYPE"] = "30000000"
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
new file mode 100644
index 00000000000..73cecccd383
--- /dev/null
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
@@ -0,0 +1,90 @@
+###############################################################################
+# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration      #
+#                                                                             #
+# This software is distributed under the terms of the GNU General Public      #
+# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
+#                                                                             #
+# In applying this licence, CERN does not waive the privileges and immunities #
+# granted to it by virtue of its status as an Intergovernmental Organization  #
+# or submit itself to any jurisdiction.                                       #
+###############################################################################
+
+from __future__ import print_function
+from Gaudi.Configuration import *
+import glob, os
+from GaudiConf import IOHelper
+
+# name tag
+tag = "U2-NoSpill"
+
+# Choose sample luminosity
+lumi = os.getenv("LUMI", "2.0e33")
+
+# DetDesc DB tags
+dbTag = "dddb-20221004"
+cdTag = "sim-20221220-vc-md100"
+
+# Event type
+evType = os.getenv("LHCB_EVENT_TYPE","30000000")
+
+relPath = "data/MC/UpgradeII/" + evType + "/" + dbTag + "/" + cdTag + "/" + tag + "-lumi_" + lumi + "/DIGI/"
+
+# Check what is available
+searchPaths = [
+    # Cambridge
+    "/usera/jonesc/NFS/" + relPath,
+    # CERN EOS
+    "/eos/lhcb/user/j/jonrob/" + relPath,
+]
+
+print("Data Files :-")
+data = []
+for path in searchPaths:
+    files = sorted(glob.glob(path + "*.digi"))
+    if len(files) > 0:
+        data += ["'PFN:" + file for file in files]
+        for f in files:
+            print(f)
+    else:
+        print("No data at",path)
+
+# Batch options ?
+if "CONDOR_FILE_BATCH" in os.environ:
+    # Use env vars to define reduced file range for this job
+    batch = int(os.environ["CONDOR_FILE_BATCH"])
+    nfiles = int(os.environ["CONDOR_FILES_PER_BATCH"])
+    print("CONDOR_FILE_BATCH", batch)
+    print("CONDOR_FILES_PER_BATCH", nfiles)
+    firstFile = batch * nfiles
+    lastFile = (batch + 1) * nfiles
+    if firstFile <= len(data):
+        if lastFile > len(data): lastFile = len(data)
+        print("Using restricted file range", firstFile, lastFile)
+        data = data[firstFile:lastFile]
+        for f in data:
+            print(" ", f)
+    else:
+        print("WARNING: File range outside input data list")
+        data = []
+
+IOHelper('ROOT').inputFiles(data, clear=True)
+FileCatalog().Catalogs = ['xmlcatalog_file:out.xml']
+
+from Configurables import LHCbApp, DDDBConf
+LHCbApp().Simulation = True
+LHCbApp().DataType = "Upgrade"
+LHCbApp().DDDBtag = dbTag
+from DDDB.CheckDD4Hep import UseDD4Hep
+if UseDD4Hep:
+    # To Be Seen what is correct here...
+    # https://gitlab.cern.ch/lhcb-conddb/lhcb-conditions-database/-/merge_requests/26
+    LHCbApp().CondDBtag = "jonrob/all-pmts-active"
+    # Use a geometry from before changes to RICH1
+    # https://gitlab.cern.ch/lhcb/Detector/-/merge_requests/205
+    DDDBConf().GeometryVersion = 'run3/before-rich1-geom-update-26052022'
+else:
+    LHCbApp().CondDBtag = cdTag
+
+from Configurables import LHCb__UnpackRawEvent as UnpackRawEvent
+UnpackRawEvent('UnpackODIN').RawEventLocation = 'DAQ/RawEvent'
+UnpackRawEvent('UnpackRich').RawEventLocation = 'DAQ/RawEvent'
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py
new file mode 100644
index 00000000000..505dbcbd9ad
--- /dev/null
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py
@@ -0,0 +1,13 @@
+###############################################################################
+# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration      #
+#                                                                             #
+# This software is distributed under the terms of the GNU General Public      #
+# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
+#                                                                             #
+# In applying this licence, CERN does not waive the privileges and immunities #
+# granted to it by virtue of its status as an Intergovernmental Organization  #
+# or submit itself to any jurisdiction.                                       #
+###############################################################################
+
+import os
+os.environ["LHCB_EVENT_TYPE"] = "10000000"
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py
index 96979f3d091..bf44b7b2603 100644
--- a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py
@@ -9,79 +9,5 @@
 # or submit itself to any jurisdiction.                                       #
 ###############################################################################
 
-from __future__ import print_function
-from Gaudi.Configuration import *
-import glob, os
-from GaudiConf import IOHelper
-
-# name tag
-tag = "U2-WithSpill"
-
-# Choose sample luminosity
-lumi = os.getenv("LUMI", "2.0e33")
-
-# DetDesc DB tags
-dbTag = "dddb-20221004"
-cdTag = "sim-20221220-vc-md100"
-
-# Event type
-evType = "30000000"
-
-relPath = "data/MC/UpgradeII/" + evType + "/" + dbTag + "/" + cdTag + "/" + tag + "-lumi_" + lumi + "/DIGI/"
-
-# Check what is available
-searchPaths = [
-    # Cambridge
-    "/usera/jonesc/NFS/" + relPath,
-    # CERN EOS
-    "/eos/lhcb/user/j/jonrob/" + relPath,
-]
-
-print("Data Files :-")
-data = []
-for path in searchPaths:
-    files = sorted(glob.glob(path + "*.digi"))
-    data += ["'PFN:" + file for file in files]
-    for f in files:
-        print(f)
-
-# Batch options ?
-if "CONDOR_FILE_BATCH" in os.environ:
-    # Use env vars to define reduced file range for this job
-    batch = int(os.environ["CONDOR_FILE_BATCH"])
-    nfiles = int(os.environ["CONDOR_FILES_PER_BATCH"])
-    print("CONDOR_FILE_BATCH", batch)
-    print("CONDOR_FILES_PER_BATCH", nfiles)
-    firstFile = batch * nfiles
-    lastFile = (batch + 1) * nfiles
-    if firstFile <= len(data):
-        if lastFile > len(data): lastFile = len(data)
-        print("Using restricted file range", firstFile, lastFile)
-        data = data[firstFile:lastFile]
-        for f in data:
-            print(" ", f)
-    else:
-        print("WARNING: File range outside input data list")
-        data = []
-
-IOHelper('ROOT').inputFiles(data, clear=True)
-FileCatalog().Catalogs = ['xmlcatalog_file:out.xml']
-
-from Configurables import LHCbApp, DDDBConf
-LHCbApp().Simulation = True
-LHCbApp().DataType = "Upgrade"
-LHCbApp().DDDBtag = dbTag
-from DDDB.CheckDD4Hep import UseDD4Hep
-if UseDD4Hep:
-    # To Be Seen what is correct here...
-    # https://gitlab.cern.ch/lhcb-conddb/lhcb-conditions-database/-/merge_requests/26
-    LHCbApp().CondDBtag = "jonrob/all-pmts-active"
-    # Use a geometry from before changes to RICH1
-    # https://gitlab.cern.ch/lhcb/Detector/-/merge_requests/205
-    DDDBConf().GeometryVersion = 'run3/before-rich1-geom-update-26052022'
-else:
-    LHCbApp().CondDBtag = cdTag
-
-from Configurables import LHCb__UnpackRawEvent as UnpackRawEvent
-UnpackRawEvent('UnpackODIN').RawEventLocation = 'DAQ/RawEvent'
-UnpackRawEvent('UnpackRich').RawEventLocation = 'DAQ/RawEvent'
+import os
+os.environ["LHCB_EVENT_TYPE"] = "30000000"
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py
new file mode 100644
index 00000000000..dad23165951
--- /dev/null
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py
@@ -0,0 +1,90 @@
+###############################################################################
+# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration      #
+#                                                                             #
+# This software is distributed under the terms of the GNU General Public      #
+# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
+#                                                                             #
+# In applying this licence, CERN does not waive the privileges and immunities #
+# granted to it by virtue of its status as an Intergovernmental Organization  #
+# or submit itself to any jurisdiction.                                       #
+###############################################################################
+
+from __future__ import print_function
+from Gaudi.Configuration import *
+import glob, os
+from GaudiConf import IOHelper
+
+# name tag
+tag = "U2-WithSpill"
+
+# Choose sample luminosity
+lumi = os.getenv("LUMI", "2.0e33")
+
+# DetDesc DB tags
+dbTag = "dddb-20221004"
+cdTag = "sim-20221220-vc-md100"
+
+# Event type
+evType = os.getenv("LHCB_EVENT_TYPE", "30000000")
+
+relPath = "data/MC/UpgradeII/" + evType + "/" + dbTag + "/" + cdTag + "/" + tag + "-lumi_" + lumi + "/DIGI/"
+
+# Check what is available
+searchPaths = [
+    # Cambridge
+    "/usera/jonesc/NFS/" + relPath,
+    # CERN EOS
+    "/eos/lhcb/user/j/jonrob/" + relPath,
+]
+
+print("Data Files :-")
+data = []
+for path in searchPaths:
+    files = sorted(glob.glob(path + "*.digi"))
+    if len(files) > 0:
+        data += ["'PFN:" + file for file in files]
+        for f in files:
+            print(f)
+    else:
+        print("No data at", path)
+
+# Batch options ?
+if "CONDOR_FILE_BATCH" in os.environ:
+    # Use env vars to define reduced file range for this job
+    batch = int(os.environ["CONDOR_FILE_BATCH"])
+    nfiles = int(os.environ["CONDOR_FILES_PER_BATCH"])
+    print("CONDOR_FILE_BATCH", batch)
+    print("CONDOR_FILES_PER_BATCH", nfiles)
+    firstFile = batch * nfiles
+    lastFile = (batch + 1) * nfiles
+    if firstFile <= len(data):
+        if lastFile > len(data): lastFile = len(data)
+        print("Using restricted file range", firstFile, lastFile)
+        data = data[firstFile:lastFile]
+        for f in data:
+            print(" ", f)
+    else:
+        print("WARNING: File range outside input data list")
+        data = []
+
+IOHelper('ROOT').inputFiles(data, clear=True)
+FileCatalog().Catalogs = ['xmlcatalog_file:out.xml']
+
+from Configurables import LHCbApp, DDDBConf
+LHCbApp().Simulation = True
+LHCbApp().DataType = "Upgrade"
+LHCbApp().DDDBtag = dbTag
+from DDDB.CheckDD4Hep import UseDD4Hep
+if UseDD4Hep:
+    # To Be Seen what is correct here...
+    # https://gitlab.cern.ch/lhcb-conddb/lhcb-conditions-database/-/merge_requests/26
+    LHCbApp().CondDBtag = "jonrob/all-pmts-active"
+    # Use a geometry from before changes to RICH1
+    # https://gitlab.cern.ch/lhcb/Detector/-/merge_requests/205
+    DDDBConf().GeometryVersion = 'run3/before-rich1-geom-update-26052022'
+else:
+    LHCbApp().CondDBtag = cdTag
+
+from Configurables import LHCb__UnpackRawEvent as UnpackRawEvent
+UnpackRawEvent('UnpackODIN').RawEventLocation = 'DAQ/RawEvent'
+UnpackRawEvent('UnpackRich').RawEventLocation = 'DAQ/RawEvent'
-- 
GitLab


From 0725209900dd8968c3e5e2be9cffa0bf5d5b4d90 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:36:00 +0100
Subject: [PATCH 22/67] RichFutureRecSys: Improve job submission scripts

---
 Rich/RichFutureRecSys/examples/jobs/RunJobs.py |  2 --
 Rich/RichFutureRecSys/examples/jobs/submit.sh  | 13 +++++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
index d322e108947..48ac481a8ad 100755
--- a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
+++ b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
@@ -53,8 +53,6 @@ if enable4D:
 
 # To Do. Pass these as parameters below.
 optsroot = "/usera/jonesc/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
-#taskOpts = optsroot+"/RichFuture.py"
-#dataOpts = optsroot+"/data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py"
 
 rootDir = os.getcwd()
 
diff --git a/Rich/RichFutureRecSys/examples/jobs/submit.sh b/Rich/RichFutureRecSys/examples/jobs/submit.sh
index 1cfd2228b1c..4ab3ac48334 100755
--- a/Rich/RichFutureRecSys/examples/jobs/submit.sh
+++ b/Rich/RichFutureRecSys/examples/jobs/submit.sh
@@ -51,8 +51,9 @@ mkdir -p ${JobDir}
 mkdir -p ${JobDir}"/jobs"
 OptsRoot="${HOME}/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
 cp ${OptsRoot}"RichFuture.py" ${JobDir}/"jobs/opts.py"
-cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py" ${JobDir}"/jobs/data.py"
-export RunOptions="${JobDir}/jobs/opts.py ${JobDir}/jobs/data.py"
+cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py" ${JobDir}"/jobs/EvtType.py"
+cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/files.py" ${JobDir}"/jobs/files.py"
+export RunOptions="${JobDir}/jobs/opts.py ${JobDir}/jobs/EvtType.py ${JobDir}/jobs/files.py"
 
 # Create run script
 JobScript=${JobDir}"/jobs/run.sh"
@@ -99,7 +100,7 @@ copy_to_spool           = true
 should_transfer_files   = YES
 when_to_transfer_output = ON_EXIT_OR_EVICT
 environment = CONDOR_ID=\$(Cluster).\$(Process)
-JobBatchName            = ${JobName}
+JobBatchName            = ${JobName//}
 
 # Requirements
 Requirements = (POOL != "GENERAL" && HAS_r02 && OpSysAndVer == "CentOS7" && TARGET.has_avx2)
@@ -114,9 +115,9 @@ request_memory = 1500
 # +IsSuspendableJob = True
 
 # Condor Output
-output = ${HOME}/CondorLogs/out.\$(Process)
-error  = ${HOME}/CondorLogs/err.\$(Process)
-Log    = ${HOME}/CondorLogs/log.\$(Process)
+output = ${HOME}/CondorLogs/${JobName//\//_}.out.\$(Process)
+error  = ${HOME}/CondorLogs/${JobName//\//_}.err.\$(Process)
+Log    = ${HOME}/CondorLogs/${JobName//\//_}.log.\$(Process)
 
 # =============================================================================
 # Submit the job script
-- 
GitLab


From df9adc4358f22843935fad04b8974079b5a533ac Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 27 Oct 2023 16:36:26 +0100
Subject: [PATCH 23/67] RichFuture.py: Adapt to options changes

---
 Rich/RichFutureRecSys/examples/RichFuture.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index 437af61ef87..30f9c6e9cd7 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -103,7 +103,7 @@ if UseDD4Hep:
 
 # Reco options
 useMCTracks = True
-useMCHits = False
+useMCHits = True
 
 # Get time windows from environment vars if set
 # otherwise use default values as passed.
@@ -364,6 +364,10 @@ pixelClustering = (False, False)
 #truncateAngles = (False, False, False)
 truncateAngles = (True, True, True)
 
+# Max PD occupancy
+maxPDOcc = (int(os.getenv("MAXPDOCCR1", "64")),
+            int(os.getenv("MAXPDOCCR2", "64")))
+
 # Minimum photon probability
 minPhotonProb = None  # Nominal
 
@@ -406,6 +410,7 @@ RichRec = RichRecoSequence(
     tkCKResScaleFactors=tkCKResScaleF,
     nSigmaCuts=ckResSigma,
     applyPixelClustering=pixelClustering,
+    maxPDOccupancy=maxPDOcc,
     truncateCKAngles=truncateAngles,
     trackExtrapolator=tkExtrap,
     PDBckWeights=pdBckWeights,
@@ -539,7 +544,7 @@ if enablePIDTuples:
 # GITCONDDBPATH='/usera/jonesc/NFS/GitDB' gaudirun.py ....
 
 # Upgrade II Studies
-# gaudirun.py ~/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/{RichFuture.py,data/PMTs/UpgradeII/NoSpill/DIGI/30000000.py} 2>&1 | tee RichFuture-${User_release_area##/*/}-${CMTCONFIG}.log
-# gaudirun.py ~/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/{RichFuture.py,data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py} 2>&1 | tee RichFuture-${User_release_area##/*/}-${CMTCONFIG}.log
+# gaudirun.py ~/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/{RichFuture.py,data/PMTs/UpgradeII/NoSpill/DIGI/{30000000.py,files.py}} 2>&1 | tee RichFuture-${User_release_area##/*/}-${CMTCONFIG}.log
+# gaudirun.py ~/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/{RichFuture.py,data/PMTs/UpgradeII/WithSpill/DIGI/{30000000.py,files.py}} 2>&1 | tee RichFuture-${User_release_area##/*/}-${CMTCONFIG}.log
 
 # --------------------------------------------------------------------------------------
-- 
GitLab


From 6bb52c6962ab5eb0fc6ac1953038e9f8dabf0ad3 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Fri, 27 Oct 2023 15:37:40 +0000
Subject: [PATCH 24/67] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/33491192
---
 .../src/RichTrSegMakerFromMCRichTracks.cpp                    | 2 +-
 .../examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py        | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
index 86b92cb3d9a..ddf2514944c 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
@@ -145,7 +145,7 @@ namespace Rich::Future::Rec::MC {
       if ( !sc ) { return sc; }
 
       // Force debug messages
-      //sc = setProperty( "OutputLevel", MSG::VERBOSE );
+      // sc = setProperty( "OutputLevel", MSG::VERBOSE );
 
       if ( radiatorIsActive( Rich::Aerogel ) ) {
         error() << "Aerogel not supported in the 'RichFuture' framework" << endmsg;
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
index 73cecccd383..c8e30a3cced 100644
--- a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
@@ -25,7 +25,7 @@ dbTag = "dddb-20221004"
 cdTag = "sim-20221220-vc-md100"
 
 # Event type
-evType = os.getenv("LHCB_EVENT_TYPE","30000000")
+evType = os.getenv("LHCB_EVENT_TYPE", "30000000")
 
 relPath = "data/MC/UpgradeII/" + evType + "/" + dbTag + "/" + cdTag + "/" + tag + "-lumi_" + lumi + "/DIGI/"
 
@@ -46,7 +46,7 @@ for path in searchPaths:
         for f in files:
             print(f)
     else:
-        print("No data at",path)
+        print("No data at", path)
 
 # Batch options ?
 if "CONDOR_FILE_BATCH" in os.environ:
-- 
GitLab


From 294cc4fd7a049ea3c69b06a2effd0e1aa5714660 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 31 Oct 2023 12:00:58 +0000
Subject: [PATCH 25/67] RichDetectorHits: Add PD occupancy plots for RICH2 R
 and H type PMTs

---
 .../src/RichDetectorHits.cpp                  | 25 ++++++++++++++++---
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
index e15224d7ff7..adee92978ad 100644
--- a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
@@ -102,6 +102,9 @@ namespace Rich::Future::Rec::Moni {
 
                   // Fill average HPD occ plot
                   fillHisto( h_nTotalPixsPerPD[rich], rawIDs.size() );
+                  if ( Rich::Rich2 == rich ) {
+                    fillHisto( ( pdID.isHTypePMT() ? h_nTotalPixsPerPDR2H : h_nTotalPixsPerPDR2R ), rawIDs.size() );
+                  }
 
                   // count active PDs
                   ++activePDs[rich];
@@ -161,10 +164,22 @@ namespace Rich::Future::Rec::Moni {
       for ( const auto rich : activeDetectors() ) {
         ok &= saveAndCheck( h_nTotalPixsPerPD[rich],                                   //
                             richHisto1D( Rich::HistogramID( "nTotalPixsPerPD", rich ), //
-                                         "Average overall PD occupancy (nHits>0)", 0.5, 64.5, 64 ) );
+                                         "Average overall PD occupancy (nHits>0)",     //
+                                         0.5, 64.5, 64 ) );
+        if ( Rich::Rich2 == rich ) {
+          ok &= saveAndCheck( h_nTotalPixsPerPDR2H,                                           //
+                              richHisto1D( Rich::HistogramID( "nTotalPixsPerHTypePD", rich ), //
+                                           "Average overall H-Type PD occupancy (nHits>0)",   //
+                                           0.5, 64.5, 64 ) );
+          ok &= saveAndCheck( h_nTotalPixsPerPDR2R,                                           //
+                              richHisto1D( Rich::HistogramID( "nTotalPixsPerRTypePD", rich ), //
+                                           "Average overall R-Type PD occupancy (nHits>0)",   //
+                                           0.5, 64.5, 64 ) );
+        }
         ok &= saveAndCheck( h_nTotalPixs[rich],                                   //
                             richHisto1D( Rich::HistogramID( "nTotalPixs", rich ), //
-                                         "Overall occupancy (nHits>0)", 0.5, m_maxPixels + 0.5, m_maxPixels / 100 ) );
+                                         "Overall occupancy (nHits>0)",           //
+                                         0.5, m_maxPixels[rich] + 0.5, m_maxPixels[rich] / 100 ) );
         ok &= saveAndCheck( h_nActivePDs[rich],                                   //
                             richHisto1D( Rich::HistogramID( "nActivePDs", rich ), //
                                          "# Active PDs (nHits>0)", -0.5, 2000.5, 2001 ) );
@@ -230,7 +245,7 @@ namespace Rich::Future::Rec::Moni {
 
   private:
     /// Maximum pixels
-    Gaudi::Property<unsigned int> m_maxPixels{this, "MaxPixels", 20000u};
+    Gaudi::Property<DetectorArray<unsigned int>> m_maxPixels{this, "MaxPixels", {30000u, 20000u}};
 
   private:
     // data
@@ -242,7 +257,9 @@ namespace Rich::Future::Rec::Moni {
     // cached histograms
 
     /// Pixels per PD histograms
-    DetectorArray<AIDA::IHistogram1D*> h_nTotalPixsPerPD = {{}};
+    DetectorArray<AIDA::IHistogram1D*> h_nTotalPixsPerPD    = {{}};
+    AIDA::IHistogram1D*                h_nTotalPixsPerPDR2H = nullptr;
+    AIDA::IHistogram1D*                h_nTotalPixsPerPDR2R = nullptr;
     /// Pixels per detector histograms
     DetectorArray<AIDA::IHistogram1D*> h_nTotalPixs = {{}};
     /// Number active PDs histograms
-- 
GitLab


From b79e8027ae8cc50853d49140cb1b8e123af79355 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 31 Oct 2023 12:02:13 +0000
Subject: [PATCH 26/67] Update U2 samples to tose with No SIN and no random
 RICh2 backgrounds

---
 .../examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py          | 2 +-
 .../examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
index c8e30a3cced..2c2548cb4ff 100644
--- a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/NoSpill/DIGI/files.py
@@ -15,7 +15,7 @@ import glob, os
 from GaudiConf import IOHelper
 
 # name tag
-tag = "U2-NoSpill"
+tag = "U2-NoSpill-NoSIN-NoRichRandHits"
 
 # Choose sample luminosity
 lumi = os.getenv("LUMI", "2.0e33")
diff --git a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py
index dad23165951..8e79b236835 100644
--- a/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py
+++ b/Rich/RichFutureRecSys/examples/data/PMTs/UpgradeII/WithSpill/DIGI/files.py
@@ -15,7 +15,7 @@ import glob, os
 from GaudiConf import IOHelper
 
 # name tag
-tag = "U2-WithSpill"
+tag = "U2-WithSpill-NoSIN-NoRichRandHits"
 
 # Choose sample luminosity
 lumi = os.getenv("LUMI", "2.0e33")
-- 
GitLab


From 47544ec1b87ef7b12c3ec354f2cf4af1292dc8a3 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 31 Oct 2023 12:02:47 +0000
Subject: [PATCH 27/67] RichFutureRecSys: update job submission scripts

---
 .../RichFutureRecSys/examples/jobs/RunJobs.py | 24 +++++++++++--------
 Rich/RichFutureRecSys/examples/jobs/submit.sh |  6 ++++-
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
index 48ac481a8ad..3cfeb3fc3d0 100755
--- a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
+++ b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
@@ -25,7 +25,7 @@ parser.add_argument("-4d", "--enable4D", help="Enable 4D", action='store_true')
 parser.add_argument(
     "--pixwins",
     help="Pixel time window(s) (only for 4D)",
-    default="1.0,3.0",
+    default="3.0",
     type=str)
 parser.add_argument(
     "--photwins",
@@ -56,6 +56,13 @@ optsroot = "/usera/jonesc/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
 
 rootDir = os.getcwd()
 
+def nFiles(lumi):
+    if lumi < 1.0e33 : return "80"
+    if lumi < 1.0e34 : return "60"
+    return "100"
+
+def nFilesPerJob(lumi):
+    return ("4" if lumi < 1.0e34 else "2")
 
 def unsetenv(var):
     if var in os.environ:
@@ -66,11 +73,6 @@ for Lumi in config["lumis"].split(","):
 
     os.environ["LUMI"] = Lumi
 
-    # Known number of input files for each lumi data set
-    nFiles = (40 if float(Lumi) < 1.0e34 else 100)
-    # files per subjob. Less for the higher lumi (10^34) samples1
-    filesPerJob = (4 if float(Lumi) < 1.0e34 else 2)
-
     for r1PixW in config["pixbckwR1"].split(","):
         for r2PixW in config["pixbckwR2"].split(","):
             if enable4D:
@@ -98,8 +100,8 @@ for Lumi in config["lumis"].split(","):
                         print("Submitting jobs for", jobName)
                         subprocess.run([
                             optsroot + "jobs/submit.sh", jobName,
-                            str(nFiles),
-                            str(filesPerJob)
+                            nFiles(float(Lumi)),
+                            nFilesPerJob(float(Lumi))
                         ])
 
                         unsetenv("PIXBCKWEIGHTRICH1")
@@ -120,9 +122,11 @@ for Lumi in config["lumis"].split(","):
                 print("Submitting jobs for", jobName)
                 subprocess.run([
                     optsroot + "jobs/submit.sh", jobName,
-                    str(nFiles),
-                    str(filesPerJob)
+                    nFiles(float(Lumi)),
+                    nFilesPerJob(float(Lumi))
                 ])
 
                 unsetenv("PIXBCKWEIGHTRICH1")
                 unsetenv("PIXBCKWEIGHTRICH2")
+
+    unsetenv("LUMI")
diff --git a/Rich/RichFutureRecSys/examples/jobs/submit.sh b/Rich/RichFutureRecSys/examples/jobs/submit.sh
index 4ab3ac48334..3831a02ac99 100755
--- a/Rich/RichFutureRecSys/examples/jobs/submit.sh
+++ b/Rich/RichFutureRecSys/examples/jobs/submit.sh
@@ -47,6 +47,9 @@ echo "Job Directory "${JobDir}
 rm -rf ${JobDir}
 mkdir -p ${JobDir}
 
+# 30000000 MinBias
+# 10000000 InclB
+
 # Jobs options
 mkdir -p ${JobDir}"/jobs"
 OptsRoot="${HOME}/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
@@ -103,7 +106,8 @@ environment = CONDOR_ID=\$(Cluster).\$(Process)
 JobBatchName            = ${JobName//}
 
 # Requirements
-Requirements = (POOL != "GENERAL" && HAS_r02 && OpSysAndVer == "CentOS7" && TARGET.has_avx2)
+#Requirements = (POOL != "GENERAL" && HAS_r02 && OpSysAndVer == "CentOS7" && TARGET.has_avx2)
+Requirements = (POOL != "GENERAL" && HAS_r02 && OpSysAndVer == "CentOS7")
 
 # Rank hosts according to floating point speed
 Rank = kflops
-- 
GitLab


From dbc6ac60e20e9f4dc318a5ee432d7962ff21d7fc Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 31 Oct 2023 12:03:35 +0000
Subject: [PATCH 28/67] Clean up RichFuture.py

---
 Rich/RichFutureRecSys/examples/RichFuture.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index 30f9c6e9cd7..53a51b1aa16 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -207,7 +207,8 @@ else:
     from Configurables import Rich__Future__MC__DecodedDataFromMCRichHits as RichMCDecoder
     richMCDecode = RichMCDecoder("RichDecodeFromMC")
     richMCDecode.IsDetDescMC = True
-    richMCDecode.RejectBackground = False
+    richMCDecode.RejectAllBackgrounds = False
+    richMCDecode.RejectScintillation = False
     richMCDecode.IncludeTimeInfo = True
     all.Members += [richMCDecode]
 
@@ -301,7 +302,7 @@ photonSel = "Nominal"
 ringPointsMin = (16, 16, 16)
 ringPointsMax = (96, 96, 96)
 
-# Compute the ring share CK theta valuesRichFuture-Feature-x86_64_v3-centos7-gcc12-opt-Expert-Histos.root
+# Compute the ring share CK theta values
 #rSTol = 0.075  # as fraction of sat. CK theta
 #newCKRingTol = (rSTol, rSTol, rSTol)
 newCKRingTol = (0.0, 0.05, 0.1)
-- 
GitLab


From 7ddedce5157a29e71948e4ff59c039a7e6f61db9 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Tue, 31 Oct 2023 12:04:35 +0000
Subject: [PATCH 29/67] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/33564661
---
 Rich/RichFutureRecSys/examples/jobs/RunJobs.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
index 3cfeb3fc3d0..7117c73138b 100755
--- a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
+++ b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
@@ -56,14 +56,17 @@ optsroot = "/usera/jonesc/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
 
 rootDir = os.getcwd()
 
+
 def nFiles(lumi):
-    if lumi < 1.0e33 : return "80"
-    if lumi < 1.0e34 : return "60"
+    if lumi < 1.0e33: return "80"
+    if lumi < 1.0e34: return "60"
     return "100"
 
+
 def nFilesPerJob(lumi):
     return ("4" if lumi < 1.0e34 else "2")
 
+
 def unsetenv(var):
     if var in os.environ:
         del os.environ[var]
-- 
GitLab


From df9d72190bd0ddc57972fb5a855a3d6d4ca09b6f Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 1 Nov 2023 16:41:56 +0000
Subject: [PATCH 30/67] RichPixelUseMCInfo: Add support for spillover hits

---
 .../src/RichPixelUseMCInfo.cpp                | 156 ++++++++++++++----
 1 file changed, 125 insertions(+), 31 deletions(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichPixelUseMCInfo.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichPixelUseMCInfo.cpp
index 9bc07148519..d85c14b4630 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichPixelUseMCInfo.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichPixelUseMCInfo.cpp
@@ -28,7 +28,7 @@
 #include "RichFutureUtils/RichSmartIDs.h"
 
 // STD
-#include <map>
+#include <unordered_map>
 
 namespace Rich::Future::Rec::MC {
 
@@ -70,28 +70,72 @@ namespace Rich::Future::Rec::MC {
 
   public:
     /// Functional operator
-    SIMDPixelSummaries operator()( SIMDPixelSummaries const&        pixels, //
-                                   LHCb::MCRichHits const&          mchits, //
+    SIMDPixelSummaries operator()( SIMDPixelSummaries const&        pixels,      //
+                                   LHCb::MCRichHits const&          main_mchits, //
                                    Rich::Utils::RichSmartIDs const& smartIDsHelper ) const override {
 
-      // Collect all the (signal) hits in the same pixel
-      std::map<LHCb::RichSmartID, std::vector<LHCb::MCRichHit*>> hitsPerPix;
-      for ( const auto mchit : mchits ) {
-        auto id = mchit->sensDetID().channelDataOnly();
+      // map from Smart ID to associated MC hits
+      using HitData = std::pair<const LHCb::MCRichHit*, double>;
+      std::unordered_map<LHCb::RichSmartID, std::vector<HitData>> hitsPerPix;
+
+      // Get the location of the container of an MC hit in the TES
+      auto hitLocation = [&]( const auto* obj ) { return ( obj ? objectLocation( obj->parent() ) : "Not Contained" ); };
+
+      // Get hit time from MC hit, including offsets
+      auto getTime = [&]( const auto* mchit ) {
+        if ( !mchit ) { return 0.0; }
+        // Deduce if this is a spillover event and if it is apply offset
+        const auto   loc         = hitLocation( mchit );
+        const double spillOffset =                                             //
+            ( ( loc.find( "PrevPrev" ) != std::string::npos ) ? -50.0 :        //
+                  ( loc.find( "Prev" ) != std::string::npos ) ? -25.0 :        //
+                      ( loc.find( "NextNext" ) != std::string::npos ) ? 50.0 : //
+                          ( loc.find( "Next" ) != std::string::npos ) ? 25.0 : //
+                              0.0 );
+        const auto hitT = spillOffset + mchit->timeOfFlight();
+        // _ri_verbo << "TES Location '" << loc << "' SpillOffset=" << spillOffset << " HitTime=" << hitT << endmsg;
+        return hitT;
+      };
+
+      auto addMCHits = [&]( auto const& mchits ) {
+        for ( const auto mchit : mchits ) {
+          auto id = mchit->sensDetID().channelDataOnly();
+          if ( id.isValid() ) {
 #ifdef USE_DD4HEP
-        if ( m_detdescMCinput ) {
-          // If built for DD4HEP apply correction to PMT module numbers to account
-          // for different numbering scheme between DD4HEP and DetDesc.
-          // Option needs to be explicitly activated only when input is known to
-          // be DetDesc based MC.
-          // ***** To eventually be removed when DetDesc finally dies completely *****
-          const Rich::DetectorArray<Rich::PanelArray<LHCb::RichSmartID::DataType>> mod_corr{{{0, 0}, {6, 18}}};
-          const auto pdMod      = id.pdMod() + mod_corr[id.rich()][id.panel()];
-          const auto pdNumInMod = id.pdNumInMod();
-          id.setPD( pdMod, pdNumInMod );
-        }
+            if ( m_detdescMCinput ) {
+              // If built for DD4HEP apply correction to PMT module numbers to account
+              // for different numbering scheme between DD4HEP and DetDesc.
+              // Option needs to be explicitly activated only when input is known to
+              // be DetDesc based MC.
+              // ***** To eventually be removed when DetDesc finally dies completely *****
+              const Rich::DetectorArray<Rich::PanelArray<LHCb::RichSmartID::DataType>> mod_corr{{{0, 0}, {6, 18}}};
+              const auto pdMod      = id.pdMod() + mod_corr[id.rich()][id.panel()];
+              const auto pdNumInMod = id.pdNumInMod();
+              id.setPD( pdMod, pdNumInMod );
+            }
 #endif
-        if ( id.isValid() ) { hitsPerPix[id].push_back( mchit ); }
+            // Are we inside the 0-25 ns window ?
+            const auto hitT        = getTime( mchit );
+            const auto hitTShifted = hitT - m_timeShift[id.rich()];
+            // _ri_verbo << "Shifted time = " << hitTShifted << endmsg;
+            if ( hitTShifted >= 0.0 && hitTShifted <= 25.0 ) { hitsPerPix[id].emplace_back( mchit, hitT ); }
+          }
+        } // hit loop
+      };
+
+      // add the main event hits
+      addMCHits( main_mchits );
+
+      // ... and if requested spillover hits
+      if ( m_enableSpillover ) {
+        auto addSpilloverHits = [&]( auto const& mchits ) {
+          if ( mchits.exist() ) { addMCHits( *mchits.get() ); }
+        };
+        addSpilloverHits( m_prevHits );
+        addSpilloverHits( m_prevPrevHits );
+        addSpilloverHits( m_nextHits );
+        addSpilloverHits( m_nextNextHits );
+        addSpilloverHits( m_lhcBkgHits );
       }
 
       // Clone the pixels to update them
@@ -108,26 +152,56 @@ namespace Rich::Future::Rec::MC {
           if ( pix.validMask()[i] ) {
 
             // SmartID for this hit
-            const auto id = pix.smartID()[i].channelDataOnly();
+            const auto id = pix.smartID()[i];
             _ri_verbo << id << endmsg;
             if ( !id.isValid() ) { continue; }
 
             // Do we have any MChits for this ID
-            const auto& pix_mchits = hitsPerPix[id];
+            const auto& pix_mchits = hitsPerPix[id.channelDataOnly()];
             if ( !pix_mchits.empty() ) {
-              // Find best MCHit to use. Either first labelled as single, otherwise
-              // just the first in the container
-              const auto* mch = pix_mchits.front();
-              for ( const auto* h : pix_mchits ) {
-                if ( h->isSignal() ) {
-                  mch = h;
-                  break;
+
+              // Find best MCHit to use
+              const auto* mch = &pix_mchits.front();
+              if ( pix_mchits.size() > 1 ) {
+                // If ID has time set use that to select MC hit
+                if ( id.adcTimeIsSet() ) {
+                  double minTimeDiff = 999999.9;
+                  for ( const auto& h : pix_mchits ) {
+                    // Apply same ADC truncation as in RichSmartID to MC hit time
+                    auto tmpID = id;
+                    tmpID.setTime( h.second );
+                    const auto tDiff = std::abs( tmpID.adcTime() - id.adcTime() );
+                    _ri_verbo << " -> " << id.adcTime() << " " << tmpID.adcTime() << endmsg;
+                    if ( tDiff < minTimeDiff ) {
+                      _ri_verbo << "  -> SELECTED " << endmsg;
+                      minTimeDiff = tDiff;
+                      mch         = &h;
+                    }
+                  } // hit loop
+                } else {
+                  // Just use first signal hit
+                  for ( const auto& h : pix_mchits ) {
+                    if ( h.first->isSignal() ) {
+                      mch = &h;
+                      break;
+                    }
+                  }
                 }
               }
+
               if ( m_useMCPos ) {
                 // Update hit position using MC
-                const auto mc_gpos = mch->entry();
-                _ri_verbo << " -> original GPos  " << i << " " << pix.gloPos( i ) << endmsg;
+                auto mc_gpos = mch->first->entry();
+                // Shift to local coords
+                auto mc_lpos = smartIDsHelper.globalToPDPanel( mc_gpos );
+                // Apply Z correction
+                const DetectorArray<double> zCorr{-10.8, -10.8};
+                mc_lpos.SetZ( mc_lpos.Z() + zCorr[pix.rich()] );
+                // Shift back to global
+                mc_gpos = smartIDsHelper.globalPosition( mc_lpos, pix.rich(), pix.side() );
+                _ri_verbo << " -> original  LPos " << i << " " << pix.locPos( i ) << endmsg;
+                _ri_verbo << " -> MC update LPos " << i << " " << mc_lpos << endmsg;
+                _ri_verbo << " -> original  GPos " << i << " " << pix.gloPos( i ) << endmsg;
                 _ri_verbo << " -> MC update GPos " << i << " " << mc_gpos << endmsg;
                 // Update position for this scalar
                 pix.gloPos().X()[i] = mc_gpos.X();
@@ -135,12 +209,14 @@ namespace Rich::Future::Rec::MC {
                 pix.gloPos().Z()[i] = mc_gpos.Z();
                 hasPosUpdate        = true;
               }
+
               if ( m_useMCTime ) {
                 // Set the hit time using MC
                 _ri_verbo << " -> original time  " << i << " " << pix.hitTime()[i] << endmsg;
-                pix.hitTime()[i] = mch->timeOfFlight();
+                pix.hitTime()[i] = mch->second;
                 _ri_verbo << " -> MC update time " << i << " " << pix.hitTime()[i] << endmsg;
               }
+
             } else {
               _ri_verbo << " -> No MC signal info" << endmsg;
             }
@@ -169,6 +245,24 @@ namespace Rich::Future::Rec::MC {
 
     /// Enable use of MC time info
     Gaudi::Property<bool> m_useMCTime{this, "UseMCTime", false};
+
+    /// Include spillover events
+    Gaudi::Property<bool> m_enableSpillover{this, "EnableSpillover", true};
+
+    /// Time window shift for each RICH
+    Gaudi::Property<DetectorArray<double>> m_timeShift{
+        this, "TimeCalib", {0., 40.}, "Global time shift for each RICH, to get both to same calibrated point"};
+
+  private:
+    // Handles to access MCRichHits other than Signal, as they are not necessary there
+    DataObjectReadHandle<LHCb::MCRichHits> m_prevHits{this, "PrevLocation", "Prev/" + LHCb::MCRichHitLocation::Default};
+    DataObjectReadHandle<LHCb::MCRichHits> m_prevPrevHits{this, "PrevPrevLocation",
+                                                          "PrevPrev/" + LHCb::MCRichHitLocation::Default};
+    DataObjectReadHandle<LHCb::MCRichHits> m_nextHits{this, "NextLocation", "Next/" + LHCb::MCRichHitLocation::Default};
+    DataObjectReadHandle<LHCb::MCRichHits> m_nextNextHits{this, "NextNextLocation",
+                                                          "NextNext/" + LHCb::MCRichHitLocation::Default};
+    DataObjectReadHandle<LHCb::MCRichHits> m_lhcBkgHits{this, "LHCBackgroundLocation",
+                                                        "LHCBackground/" + LHCb::MCRichHitLocation::Default};
   };
 
   // Declaration of the Algorithm Factory
-- 
GitLab


From 594af493533f54d152639ee3d6def24cd92184cf Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 1 Nov 2023 16:43:07 +0000
Subject: [PATCH 31/67] RichDetectorHits: Add average PD occupancy plots

---
 .../src/RichDetectorHits.cpp                  | 50 ++++++++++++++++++-
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
index adee92978ad..41107cd191d 100644
--- a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
@@ -20,9 +20,13 @@
 #include "RichFutureUtils/RichSmartIDs.h"
 #include "RichUtils/RichDAQDefinitions.h"
 
+// AIDA
+#include "AIDA/IAxis.h"
+
 // STD
 #include <cstdint>
 #include <mutex>
+#include <vector>
 
 namespace Rich::Future::Rec::Moni {
 
@@ -74,6 +78,10 @@ namespace Rich::Future::Rec::Moni {
       // Loop over RICHes
       for ( const auto rich : activeDetectors() ) {
 
+        // count for occupancy in each PD
+        using VD = std::vector<double>;
+        std::vector<VD> pdOccXY{nBins2D(), VD( nBins2D(), 0.0 )};
+
         // data for this RICH
         const auto& rD = data[rich];
 
@@ -124,6 +132,10 @@ namespace Rich::Future::Rec::Moni {
                     fillHisto( h_pixXYLoc[rich], lPos.X(), lPos.Y() );
                     fillHisto( h_pixXLoc[rich], lPos.X() );
                     fillHisto( h_pixYLoc[rich], lPos.Y() );
+                    // cache occupancy data
+                    const auto iX             = h_pdXYLocOcc[rich]->xAxis().coordToIndex( lPos.X() );
+                    const auto iY             = h_pdXYLocOcc[rich]->yAxis().coordToIndex( lPos.Y() );
+                    pdOccXY.at( iX ).at( iY ) = rawIDs.size();
                   }
 
                 } // PD has hits
@@ -136,6 +148,20 @@ namespace Rich::Future::Rec::Moni {
 
         } // panels
 
+        // Fill occupancies
+        for ( auto iX = 0u; iX < nBins2D(); ++iX ) {
+          for ( auto iY = 0u; iY < nBins2D(); ++iY ) {
+            const auto X   = 0.5 * ( h_pdXYLocOcc[rich]->xAxis().binLowerEdge( iX ) +
+                                   h_pdXYLocOcc[rich]->xAxis().binUpperEdge( iX ) );
+            const auto Y   = 0.5 * ( h_pdXYLocOcc[rich]->yAxis().binLowerEdge( iY ) +
+                                   h_pdXYLocOcc[rich]->yAxis().binUpperEdge( iY ) );
+            const auto occ = pdOccXY.at( iX ).at( iY );
+            fillHisto( h_pdXYLocOcc[rich], X, Y, occ );
+            fillHisto( h_pdXLocOcc[rich], X, occ );
+            fillHisto( h_pdYLocOcc[rich], Y, occ );
+          }
+        }
+
       } // RICHes
 
       // Loop over RICHes
@@ -231,13 +257,29 @@ namespace Rich::Future::Rec::Moni {
         ok &= saveAndCheck( h_pixXLoc[rich],                                               //
                             richHisto1D( HID( "pixXLoc", rich ),                           //
                                          "Local X hits",                                   //
-                                         -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
+                                         -panelXsizes[rich], panelXsizes[rich], nBins1D(), //
                                          "Local X / mm" ) );
         ok &= saveAndCheck( h_pixYLoc[rich],                                               //
                             richHisto1D( HID( "pixYLoc", rich ),                           //
                                          "Local Y hits",                                   //
-                                         -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
+                                         -panelYsizes[rich], panelYsizes[rich], nBins1D(), //
                                          "Local Y / mm" ) );
+        ok &= saveAndCheck( h_pdXYLocOcc[rich],                                              //
+                            richProfile2D( HID( "pdOccXYLoc", rich ),                        //
+                                           "PD Average Occupancy (X,Y)",                     //
+                                           -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
+                                           -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
+                                           "Local X / mm", "Local Y / mm" ) );
+        ok &= saveAndCheck( h_pdXLocOcc[rich],                                               //
+                            richProfile1D( HID( "pdOccXLoc", rich ),                         //
+                                           "PD Average Occupancy (X)",                       //
+                                           -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
+                                           "Local X / mm" ) );
+        ok &= saveAndCheck( h_pdYLocOcc[rich],                                               //
+                            richProfile1D( HID( "pdOccYLoc", rich ),                         //
+                                           "PD Average Occupancy (Y)",                       //
+                                           -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
+                                           "Local Y / mm" ) );
       }
 
       return StatusCode{ok};
@@ -274,6 +316,10 @@ namespace Rich::Future::Rec::Moni {
     DetectorArray<AIDA::IHistogram2D*> h_pixXYLoc = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_pixXLoc  = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_pixYLoc  = {{}};
+
+    DetectorArray<AIDA::IProfile2D*> h_pdXYLocOcc = {{}};
+    DetectorArray<AIDA::IProfile1D*> h_pdXLocOcc  = {{}};
+    DetectorArray<AIDA::IProfile1D*> h_pdYLocOcc  = {{}};
   };
 
   // Declaration of the Algorithm Factory
-- 
GitLab


From b0c7e91ab80378a28f9e6330aefda92b94f5a9fe Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:20:15 +0000
Subject: [PATCH 32/67] RichMCTrackResolution: Reorder includes

---
 .../src/RichMCTrackResolution.cpp                    | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Rich/RichFutureRecCheckers/src/RichMCTrackResolution.cpp b/Rich/RichFutureRecCheckers/src/RichMCTrackResolution.cpp
index 3cb75e005ef..59973862670 100644
--- a/Rich/RichFutureRecCheckers/src/RichMCTrackResolution.cpp
+++ b/Rich/RichFutureRecCheckers/src/RichMCTrackResolution.cpp
@@ -9,12 +9,6 @@
 * or submit itself to any jurisdiction.                                       *
 \*****************************************************************************/
 
-// STD
-#include <algorithm>
-#include <cassert>
-#include <mutex>
-#include <utility>
-
 // Gaudi
 #include "GaudiKernel/ParsersFactory.h"
 #include "GaudiKernel/PhysicalConstants.h"
@@ -38,6 +32,12 @@
 // Relations
 #include "RichFutureMCUtils/TrackToMCParticle.h"
 
+// STD
+#include <algorithm>
+#include <cassert>
+#include <mutex>
+#include <utility>
+
 namespace Rich::Future::Rec::MC::Moni {
 
   /** @class TrackResolution RichMCTrackResolution.h
-- 
GitLab


From 3010ad974d7ba5a33c1eb411b19a869c7708615b Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:20:51 +0000
Subject: [PATCH 33/67] RichTrSegMakerFromMCRichTracks: Add random efficiency
 factor

---
 .../src/RichTrSegMakerFromMCRichTracks.cpp    | 40 +++++++++++--------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
index ddf2514944c..79f7c874a1e 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
@@ -16,10 +16,8 @@
 // Gaudi
 #include "GaudiKernel/Bootstrap.h"
 #include "GaudiKernel/IDataProviderSvc.h"
-#include "GaudiKernel/IMagneticFieldSvc.h"
-#include "GaudiKernel/IToolSvc.h"
+#include "GaudiKernel/RndmGenerators.h"
 #include "GaudiKernel/SystemOfUnits.h"
-#include "GaudiKernel/ToolHandle.h"
 
 // base class
 #include "RichFutureRecBase/RichRecAlgBase.h"
@@ -53,15 +51,9 @@
 // Track tools
 #include "PrKernel/PrChecker.h"
 
-// GSL
-#include "gsl/gsl_math.h"
-
 // STL
 #include <array>
-#include <iostream>
-#include <limits>
 #include <memory>
-#include <optional>
 #include <string>
 #include <unordered_map>
 #include <utility>
@@ -166,6 +158,8 @@ namespace Rich::Future::Rec::MC {
 
       _ri_verbo << m_minP << " " << m_minPt << endmsg;
 
+      m_randZeroOne = Rndm::Numbers( randSvc(), Rndm::Flat( 0.0, 1.0 ) );
+
       // return
       return sc;
     }
@@ -245,6 +239,9 @@ namespace Rich::Future::Rec::MC {
           continue;
         }
 
+        // emulate tracking inefficiency
+        if ( m_randZeroOne.shoot() > m_tkEff ) { continue; }
+
         // Create a fake 'reco' track for this MC track
         auto tk = std::make_unique<LHCb::Track>();
 
@@ -316,14 +313,14 @@ namespace Rich::Future::Rec::MC {
           if ( entryPoint.Z() < m_minZ[rad] || midPoint.Z() < m_minZ[rad] || exitPoint.Z() < m_minZ[rad] ) { continue; }
 
           // check min/max momentum on segment
-          if ( sqrt( entryStateMomentum.mag2() ) < m_minP[rad] || //
-               sqrt( midStateMomentum.mag2() ) < m_minP[rad] ||   //
-               sqrt( exitStateMomentum.mag2() ) < m_minP[rad] ) {
+          if ( std::sqrt( entryStateMomentum.mag2() ) < m_minP[rad] || //
+               std::sqrt( midStateMomentum.mag2() ) < m_minP[rad] ||   //
+               std::sqrt( exitStateMomentum.mag2() ) < m_minP[rad] ) {
             continue;
           }
-          if ( sqrt( entryStateMomentum.mag2() ) > m_maxP[rad] || //
-               sqrt( midStateMomentum.mag2() ) > m_maxP[rad] ||   //
-               sqrt( exitStateMomentum.mag2() ) > m_maxP[rad] ) {
+          if ( std::sqrt( entryStateMomentum.mag2() ) > m_maxP[rad] || //
+               std::sqrt( midStateMomentum.mag2() ) > m_maxP[rad] ||   //
+               std::sqrt( exitStateMomentum.mag2() ) > m_maxP[rad] ) {
             continue;
           }
 
@@ -391,6 +388,12 @@ namespace Rich::Future::Rec::MC {
       return data;
     }
 
+  private:
+    // data
+
+    /// random number between 0 and 1
+    Rndm::Numbers m_randZeroOne{};
+
   private:
     // properties
 
@@ -399,7 +402,7 @@ namespace Rich::Future::Rec::MC {
         this, "MinPathLengths", {10 * Gaudi::Units::mm, 500 * Gaudi::Units::mm, 1500 * Gaudi::Units::mm}};
 
     /// Min number of photons for each radiator
-    Gaudi::Property<RadiatorArray<double>> m_minPhots{this, "MinNumPhotons", {3, 5, 5}};
+    Gaudi::Property<RadiatorArray<double>> m_minPhots{this, "MinNumPhotons", {0, 0, 0}};
 
     /// Overall Min monentum cut
     Gaudi::Property<RadiatorArray<double>> m_minP{
@@ -425,7 +428,10 @@ namespace Rich::Future::Rec::MC {
     Gaudi::Property<std::array<double, 3>> m_tkOriginTol{this, "TrackOriginTol", {1.0, 1.0, 100.0}};
 
     /// Require segments in given radiator
-    Gaudi::Property<RadiatorArray<bool>> m_reqSegs{this, "RequireSegment", {false, false, true}};
+    Gaudi::Property<RadiatorArray<bool>> m_reqSegs{this, "RequireSegment", {false, false, false}};
+
+    /// Tracking efficiency
+    Gaudi::Property<double> m_tkEff{this, "TrackingEfficiency", 0.90, "Tracking efficiency to emulate"};
 
   }; // namespace Rich::Future::Rec::MC
 
-- 
GitLab


From 087f2f4fb71dae801e3d5aa5b534e80a571bdf3f Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:21:31 +0000
Subject: [PATCH 34/67] Add new track filter that selects based on RICH MC
 information

---
 Rich/RichFutureRecMCAlgorithms/CMakeLists.txt |   1 +
 .../src/RichMCTrackFilter.cpp                 | 222 ++++++++++++++++++
 2 files changed, 223 insertions(+)
 create mode 100644 Rich/RichFutureRecMCAlgorithms/src/RichMCTrackFilter.cpp

diff --git a/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt b/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
index bdd68935a60..1ce7a821578 100644
--- a/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
+++ b/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
@@ -18,6 +18,7 @@ gaudi_add_module(RichFutureRecMCAlgorithms
         src/RichTrSegMakerFromMCRichTracks.cpp
         src/RichSegmentAddTimeFromMC.cpp
         src/RichPixelUseMCInfo.cpp
+        src/RichMCTrackFilter.cpp
     LINK
         Gaudi::GaudiAlgLib
         Gaudi::GaudiKernel
diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichMCTrackFilter.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichMCTrackFilter.cpp
new file mode 100644
index 00000000000..d93e97f9ba5
--- /dev/null
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichMCTrackFilter.cpp
@@ -0,0 +1,222 @@
+/*****************************************************************************\
+* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration      *
+*                                                                             *
+* This software is distributed under the terms of the GNU General Public      *
+* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   *
+*                                                                             *
+* In applying this licence, CERN does not waive the privileges and immunities *
+* granted to it by virtue of its status as an Intergovernmental Organization  *
+* or submit itself to any jurisdiction.                                       *
+\*****************************************************************************/
+
+// Gaudi
+#include "GaudiKernel/ParsersFactory.h"
+#include "GaudiKernel/PhysicalConstants.h"
+#include "GaudiKernel/StdArrayAsProperty.h"
+
+// base class
+#include "RichFutureRecBase/RichRecAlgBase.h"
+
+// Gaudi Functional
+#include "LHCbAlgs/Transformer.h"
+
+// Event Model
+#include "Event/MCRichSegment.h"
+#include "Event/MCRichTrack.h"
+#include "Event/Track.h"
+
+// Relations
+#include "RichFutureMCUtils/TrackToMCParticle.h"
+#include "RichFutureRecEvent/RichRecRelations.h"
+
+// STD
+#include <array>
+#include <unordered_map>
+
+namespace Rich::Future::Rec::MC {
+
+  namespace {
+    using OutData = LHCb::Track::Selection;
+  }
+
+  /** @class TrackFilter TrackFilter.h
+   *
+   *  Filter a container of Tracks based on MC information.
+   *  Designed to help mimic the tracks created by TrSegMakerFromMCRichTracks
+   *
+   *  @author Chris Jones
+   *  @date   2020-10-29
+   */
+
+  class TrackFilter final
+      : public LHCb::Algorithm::Transformer<OutData( const LHCb::Track::Range&,                       //
+                                                     const Rich::Future::MC::Relations::TkToMCPRels&, //
+                                                     const LHCb::MCRichTracks& ),
+                                            Gaudi::Functional::Traits::BaseClass_t<AlgBase<>>> {
+
+  public:
+    /// Standard constructor
+    TrackFilter( const std::string& name, ISvcLocator* pSvcLocator )
+        : Transformer( name, pSvcLocator,
+                       // data inputs
+                       {KeyValue{"InTracksLocation", LHCb::TrackLocation::Default},
+                        KeyValue{"TrackToMCParticlesRelations", Rich::Future::MC::Relations::TrackToMCParticles},
+                        KeyValue{"MCRichTracksLocation", LHCb::MCRichTrackLocation::Default}},
+                       // data output
+                       {KeyValue{"OutTracksLocation", LHCb::TrackLocation::Default + "Out"}} ) {}
+
+  public:
+    /// Functional operator
+    OutData operator()( const LHCb::Track::Range&                       tracks, //
+                        const Rich::Future::MC::Relations::TkToMCPRels& tkrels, //
+                        const LHCb::MCRichTracks&                       mcRichtracks ) const override {
+
+      // Buld map MCP -> MCRichTrack
+      std::unordered_map<const LHCb::MCParticle*, const LHCb::MCRichTrack*> mcPToMCR;
+      for ( const auto mcR : mcRichtracks ) {
+        const auto mcP = ( mcR ? mcR->mcParticle() : nullptr );
+        if ( mcP ) { mcPToMCR[mcP] = mcR; }
+      }
+
+      OutData sel_tracks;
+
+      // Make a local MC helper object
+      Rich::Future::MC::Relations::TrackToMCParticle mcHelper( tkrels );
+
+      for ( const auto tk : tracks ) {
+
+        // flag for if this track gets selected or not
+        bool selected = false;
+
+        // Get MCParticles for this track
+        const auto mcPs = mcHelper.mcParticles( *tk );
+
+        // Loop over MCPs
+        for ( const auto mcp : mcPs ) {
+
+          // Just in case
+          if ( !mcp ) { continue; }
+
+          // get charge
+          const auto charge = mcp->particleID().threeCharge() / 3;
+          if ( 1 != abs( charge ) ) { continue; }
+
+          // Check MCParticle Pt
+          if ( mcp->momentum().Pt() < m_minPt ) { continue; }
+
+          // Check we have a PV
+          const auto mcp_orig_pv = mcp->primaryVertex();
+          if ( !mcp_orig_pv ) { continue; }
+
+          // Check origin vertex position
+          const auto mcp_orig_v = mcp->originVertex();
+          if ( !mcp_orig_v ) { continue; }
+          if ( m_tkOriginTol[0] < fabs( mcp_orig_v->position().X() ) || //
+               m_tkOriginTol[1] < fabs( mcp_orig_v->position().Y() ) || //
+               m_tkOriginTol[2] < fabs( mcp_orig_v->position().Z() ) ) {
+            continue;
+          }
+
+          // Do we have a MCRichTrack
+          const auto mcr = mcPToMCR.find( mcp );
+          if ( mcr != mcPToMCR.end() ) {
+            const auto mcRichTk = mcr->second;
+
+            // Check MC segments
+            for ( const auto rad : activeRadiators() ) {
+
+              // Get MC segment for this track and radiator
+              const auto mcSeg = mcRichTk->segmentInRad( rad );
+              if ( !mcSeg ) { continue; }
+
+              // Apply selection cuts
+              if ( mcSeg->pathLength() < m_minPathL[rad] ) { continue; }
+              if ( mcSeg->mcRichOpticalPhotons().size() < m_minPhots[rad] ) { continue; }
+
+              // Get entry information
+              const auto& entryPoint         = mcSeg->entryPoint();
+              const auto& entryStateMomentum = mcSeg->entryMomentum();
+              // Get exit information
+              const auto& exitPoint         = mcSeg->exitPoint();
+              const auto& exitStateMomentum = mcSeg->exitMomentum();
+              // Get middle point information
+              const auto midPoint         = mcSeg->bestPoint( 0.5 );
+              const auto midStateMomentum = mcSeg->bestMomentum( 0.5 );
+
+              // Sanity checks on entry/exit points
+              if ( entryPoint.Z() < m_minZ[rad] || //
+                   midPoint.Z() < m_minZ[rad] ||   //
+                   exitPoint.Z() < m_minZ[rad] ) {
+                continue;
+              }
+
+              // check min/max momentum on segment
+              if ( std::sqrt( entryStateMomentum.mag2() ) < m_minP[rad] || //
+                   std::sqrt( midStateMomentum.mag2() ) < m_minP[rad] ||   //
+                   std::sqrt( exitStateMomentum.mag2() ) < m_minP[rad] ) {
+                continue;
+              }
+              if ( std::sqrt( entryStateMomentum.mag2() ) > m_maxP[rad] || //
+                   std::sqrt( midStateMomentum.mag2() ) > m_maxP[rad] ||   //
+                   std::sqrt( exitStateMomentum.mag2() ) > m_maxP[rad] ) {
+                continue;
+              }
+
+              // if get here track is selected
+              selected = true;
+              break;
+            }
+          }
+
+          // If already selected no need to check this track any further
+          if ( selected ) { break; }
+
+        } // MCPs loop
+
+        if ( selected ) { sel_tracks.insert( tk ); }
+
+      } // input track loop
+
+      _ri_debug << "Selected " << sel_tracks.size() << " tracks from " << tracks.size() << endmsg;
+
+      return sel_tracks;
+    }
+
+  private:
+    // properties
+
+    /// Overall Min monentum cut
+    Gaudi::Property<RadiatorArray<double>> m_minP{
+        this,
+        "MinP",
+        {0.0 * Gaudi::Units::GeV, 0.0 * Gaudi::Units::GeV, 0.0 * Gaudi::Units::GeV},
+        "Minimum momentum (GeV/c)"};
+
+    /// Overall Max monentum cut
+    Gaudi::Property<RadiatorArray<double>> m_maxP{
+        this,
+        "MaxP",
+        {9e9 * Gaudi::Units::GeV, 9e9 * Gaudi::Units::GeV, 9e9 * Gaudi::Units::GeV},
+        "Maximum momentum (GeV/c)"};
+
+    /// Minimum track transerve momentum
+    Gaudi::Property<double> m_minPt{this, "MinPt", 0.0 * Gaudi::Units::GeV, "Minimum transerve momentum (GeV/c)"};
+
+    /// Min path length for each radiator
+    Gaudi::Property<RadiatorArray<double>> m_minPathL{
+        this, "MinPathLengths", {10 * Gaudi::Units::mm, 500 * Gaudi::Units::mm, 1500 * Gaudi::Units::mm}};
+
+    /// Min number of photons for each radiator
+    Gaudi::Property<RadiatorArray<double>> m_minPhots{this, "MinNumPhotons", {0, 0, 0}};
+
+    /// Tolerance on track origin w.r.t. (0,0,0)
+    Gaudi::Property<std::array<double, 3>> m_tkOriginTol{this, "TrackOriginTol", {1.0, 1.0, 100.0}};
+
+    /// Minimum z position for states in each radiator (mm)
+    Gaudi::Property<RadiatorArray<double>> m_minZ{this, "MinStateZ", {800, 800, 9000}};
+  };
+
+  // Declaration of the Algorithm Factory
+  DECLARE_COMPONENT( TrackFilter )
+
+} // namespace Rich::Future::Rec::MC
-- 
GitLab


From f796aaf05e5dd38e66b0a053960075f8ab1629fa Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:22:21 +0000
Subject: [PATCH 35/67] GlobalPID: By default reject BT tracks when forming PID
 curves

---
 Rec/GlobalReco/root/GlobalPID.C | 18 ++++++++++++++++--
 Rec/GlobalReco/root/GlobalPID.h | 13 +++++++------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/Rec/GlobalReco/root/GlobalPID.C b/Rec/GlobalReco/root/GlobalPID.C
index e65a2215d17..ad9441b33b4 100755
--- a/Rec/GlobalReco/root/GlobalPID.C
+++ b/Rec/GlobalReco/root/GlobalPID.C
@@ -139,13 +139,27 @@ void GlobalPID::makeCurve( const Long64_t nTracks ) {
     //------------------------------------------------------------------------------
 
     // pid det selection
-    if ( !passBasicPIDDet() ) continue;
+    if ( !passBasicPIDDet() ) { continue; }
 
     // run the track selection
-    if ( !passTrackSelection() ) continue;
+    if ( !passTrackSelection() ) { continue; }
+
+    // reject below threshold tracks
+    if ( config.rejectBThypos &&                           //
+         ( ( Pion == RichBestPID && !RichAbovePiThres ) || //
+           ( Kaon == RichBestPID && !RichAboveKaThres ) || //
+           ( Proton == RichBestPID && !RichAbovePrThres ) ) ) {
+      continue;
+    }
 
     // Get the MC type
     const PIDType mcType = getMcType();
+    if ( config.rejectBThypos &&                      //
+         ( ( Pion == mcType && !RichAbovePiThres ) || //
+           ( Kaon == mcType && !RichAboveKaThres ) || //
+           ( Proton == mcType && !RichAbovePrThres ) ) ) {
+      continue;
+    }
 
     // Get the physical cut variable
     const double thisVar = selectionVar();
diff --git a/Rec/GlobalReco/root/GlobalPID.h b/Rec/GlobalReco/root/GlobalPID.h
index 26da3295131..2931e16216f 100755
--- a/Rec/GlobalReco/root/GlobalPID.h
+++ b/Rec/GlobalReco/root/GlobalPID.h
@@ -17,6 +17,7 @@
 
 #pragma once
 
+#include <array>
 #include <cmath>
 #include <iostream>
 #include <map>
@@ -65,11 +66,10 @@ public: // definitions
     muonNShared
   };
 
-  typedef std::pair<unsigned int, unsigned int> SelData;
-  typedef std::map<PIDType, SelData>            PIDData;
-  typedef std::map<double, PIDData>             PIDStepData;
-
-  typedef std::map<PIDType, unsigned int> AcceptanceTracks;
+  using SelData          = std::pair<unsigned int, unsigned int>;
+  using PIDData          = std::map<PIDType, SelData>;
+  using PIDStepData      = std::map<double, PIDData>;
+  using AcceptanceTracks = std::map<PIDType, unsigned int>;
 
 public: // classes
   /// Utility class used to configure the job
@@ -100,11 +100,12 @@ public: // classes
     bool                superImpose{false};
     bool                writeCutValues{true};
     Color_t             color{kBlack};
-    double              textSize{0.012};
+    double              textSize{0.018};
     std::string         imageFile;
     std::string         cutType{">"}, secCutType{">"};
     bool                useFixedGraphRange{true};
     double              minGraphX{60}, maxGraphX{100}, minGraphY{1}, maxGraphY{40};
+    bool                rejectBThypos{true};
   };
 
 public:
-- 
GitLab


From 26e0c610c1ceaf32aa9d423e32655817b508ba7e Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:22:52 +0000
Subject: [PATCH 36/67] RichKaonIDCompareFiles.C: Update ROOT script

---
 Rec/GlobalReco/root/RichKaonIDCompareFiles.C | 69 +++++++++++++-------
 1 file changed, 45 insertions(+), 24 deletions(-)

diff --git a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
index b7dc9c470cd..ef797504169 100755
--- a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
+++ b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
@@ -19,27 +19,48 @@
 
 void RichKaonIDCompareFiles() {
 
-  const std::string dir = "/usera/jonesc/LHCb/output/U2/MinBias";
-
-  // const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Rec/output/test";
-
+  //const std::string dir = "/usera/jonesc/LHCb/output/U2/InclB/WithSpill";
+  const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Rec/output/test";
+  
+  //const std::string fName = "RichFuture-Feature-x86_64_v2-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
   const std::string fName = "RichFuture-Feature-x86_64_v3-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
-
-  std::string bName = "NewTune-V2";
-
+  
   std::map<std::string, std::vector<std::string>> dataSets;
-  for ( const std::string lumi : {"2.0e32", "2.0e33", "3.0e33", "1.0e34", "1.2e34", "1.5e34"} ) {
-    // 3D
-    dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi );
-    // 4D
-    for ( const std::string pixWin : {"3.000"} ) {
-      for ( const std::string photWin : {"1.000", "0.500", "0.250", "0.100", "0.050", "0.010"} ) {
-        const auto n = bName + "/4D/lumi-" + lumi + "/PixWin-" + pixWin + "/PhotWin-" + photWin;
-        dataSets[bName + "-4D-PhotWin_" + photWin].push_back( n );
-        dataSets[bName + "-4D-Lumi_" + lumi].push_back( n );
-      }
-    }
-  }
+
+  dataSets["Run3Tracking-3D"].push_back( "NominalDSTs" );
+  dataSets["Run3Tracking-3D"].push_back( "NominalDSTs-MCFilteredTks" );
+
+  // const std::string bName = "FromMCHits";
+  // for ( const std::string lumi : {"2.0e32", "2.0e33", "3.0e33", "1.0e34", "1.2e34", "1.5e34"} ) {
+  //   // 3D
+  //   dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi );
+  //   // 4D
+  //   for ( const std::string pixWin : {"3.000"} ) {
+  //     for ( const std::string photWin : {"1.000", "0.500", "0.250", "0.100", "0.050", "0.010"} ) {
+  //       const auto n = bName + "/4D/lumi-" + lumi + "/PixWin-" + pixWin + "/PhotWin-" + photWin;
+  //       dataSets[bName + "-4D-PhotWin_" + photWin].push_back( n );
+  //       dataSets[bName + "-4D-Lumi_" + lumi].push_back( n );
+  //     }
+  //   }
+  // }
+
+  // const std::string lumi = "1.2e34";
+  // {
+  //   const std::string bName = "Rich1BckTune";
+  //   for ( const std::string w : {"0.500", "0.400", "0.300", "0.200", "0.100", "0.050"} ) {
+  //     dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi + "/R1PixBckW-" + w );
+  //     dataSets[bName + "-4D"].push_back( bName + "/4D/lumi-" + lumi + "/R1PixBckW-" + w +
+  //                                        "/PixWin-3.000/PhotWin-0.100" );
+  //   }
+  // }
+  // {
+  //   const std::string bName = "Rich2BckTune";
+  //   for ( const std::string w : {"0.500", "0.400", "0.300", "0.200", "0.100", "0.050"} ) {
+  //     dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi + "/R2PixBckW-" + w );
+  //     dataSets[bName + "-4D"].push_back( bName + "/4D/lumi-" + lumi + "/R2PixBckW-" + w +
+  //                                        "/PixWin-3.000/PhotWin-0.100" );
+  //   }
+  // }
 
   const Long64_t nTracks = 1e6;
 
@@ -64,7 +85,7 @@ void RichKaonIDCompareFiles() {
         gConf.useFixedGraphRange = true;
         gConf.minGraphX          = 80;
         gConf.maxGraphX          = 100;
-        gConf.minGraphY          = 0.2;
+        gConf.minGraphY          = 0.05;
         gConf.maxGraphY          = 100;
       } else if ( GlobalPID::Upstream == tktype ) {
         gConf.useFixedGraphRange = true;
@@ -87,10 +108,10 @@ void RichKaonIDCompareFiles() {
       }
 
       // Stepping options
-      gConf.minCut      = -40;
+      gConf.minCut      = -50;
       gConf.maxCut      = 30;
       gConf.nSteps      = 70;
-      gConf.minMisIDeff = 0.2;
+      gConf.minMisIDeff = gConf.minGraphY;
 
       // Momentum range
       if ( GlobalPID::Long == tktype ) {
@@ -129,8 +150,8 @@ void RichKaonIDCompareFiles() {
       using PlotData = std::vector<std::tuple<std::string, std::string, Color_t>>;
 
       // colours ... https://root.cern.ch/doc/master/classTColor.html
-      const std::array<Color_t, 11> colors{kBlack,       kRed - 6,    kBlue + 1, kGreen + 2, kRed + 1, kBlue - 1,
-                                           kMagenta + 2, kYellow + 3, kCyan + 2, kGreen - 5, kGray + 2};
+      const std::array<Color_t, 11> colors{kYellow - 1, kRed + 1,  kGreen + 2, kBlue + 1,  kMagenta + 2, kBlack,
+                                           kRed - 6,    kBlue - 1, kCyan + 2,  kGreen - 5, kGray + 2};
 
       auto lastColor = colors.end();
 
-- 
GitLab


From 9fd0b0044848e0a658f906c6d905a772c84f70e2 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:23:26 +0000
Subject: [PATCH 37/67] RichFuture.py: Add option to use RICH MC track filter

---
 Rich/RichFutureRecSys/examples/RichFuture.py | 62 ++++++++++++++------
 1 file changed, 43 insertions(+), 19 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index 53a51b1aa16..c5f1e1f7640 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -16,6 +16,8 @@ from GaudiConfig.ControlFlow import seq
 from GaudiKernel.SystemOfUnits import GeV
 from Configurables import LHCbApp, GaudiSequencer, DDDBConf
 from Configurables import UnpackMCParticle, UnpackMCVertex
+from Configurables import MCRichSegmentUnpacker, MCRichTrackUnpacker, MCRichHitUnpacker
+from Configurables import MCRichDigitSummaryUnpacker, MCRichOpticalPhotonUnpacker
 from Configurables import FPEAuditor
 import os, socket
 
@@ -55,7 +57,7 @@ rootFileBaseName = "RichFuture-" + myBuild + "-" + myConf + "-" + histos
 HistogramPersistencySvc().OutputFile = rootFileBaseName + "-Histos.root"
 
 # Event numbers
-nEvents = (1000 if not batchMode else 99999999)
+nEvents = (10000 if not batchMode else 99999999)
 EventSelector().PrintFreq = (100 if not batchMode else 250)
 #LHCbApp().SkipEvents      = 2
 
@@ -133,7 +135,12 @@ tkSegAddTimeFromMC = ((enable4D[0] or enable4D[1]) and not useMCTracks)
 usePixelMCTime = ((enable4D[0] or enable4D[1]) and not useMCHits)
 
 # Cheat pixel positions using MC info
-usePixelMCPos = False
+usePixelMCPos = True
+
+# Filter 'real' tracks based on MC info.
+# Designed to help match those made from MCRichTracks, where certain
+# track types cannot be made (e.g. ghosts, or BT tracks).
+filterTksUsingMC = False
 
 # Unpacking sequence before reco is run
 preUnpackSeq = GaudiSequencer("PreUnpackSeq", MeasureTime=True)
@@ -165,12 +172,11 @@ if UseDD4Hep:
     from Configurables import LHCb__Det__LbDD4hep__IOVProducer as IOVProducer
     all.Members += [IOVProducer("ReserveIOVDD4hep", ODIN=decodeODIN.ODIN)]
 
-if tkSegAddTimeFromMC or useMCHits or useMCTracks:
+if tkSegAddTimeFromMC or useMCHits or useMCTracks or filterTksUsingMC:
     preUnpackSeq.Members += [UnpackMCVertex(), UnpackMCParticle()]
 
 if usePixelMCPos or usePixelMCTime or useMCHits:
     fetcher.DataKeys += ['pSim/Rich/Hits']
-    from Configurables import MCRichHitUnpacker
     preUnpackSeq.Members += [MCRichHitUnpacker()]
     for spill in ["PrevPrev", "Prev", "Next", "NextNext", "LHCBackground"]:
         preUnpackSeq.Members += [
@@ -210,10 +216,24 @@ else:
     richMCDecode.RejectAllBackgrounds = False
     richMCDecode.RejectScintillation = False
     richMCDecode.IncludeTimeInfo = True
+    richMCDecode.AllowMultipleHits = True
     all.Members += [richMCDecode]
 
 # Now get the RICH sequence
 
+if filterTksUsingMC or useMCTracks:
+    # Build track info from RICH extended MC info
+    fetcher.DataKeys += [
+        'pSim/Rich/Segments', 'pSim/Rich/Tracks', 'pSim/MCVertices',
+        'pSim/MCParticles'
+    ]
+    preUnpackSeq.Members += [
+        MCRichHitUnpacker(),
+        MCRichOpticalPhotonUnpacker(),
+        MCRichSegmentUnpacker(),
+        MCRichTrackUnpacker()
+    ]
+
 if not useMCTracks:
 
     # Explicitly unpack the Tracks
@@ -222,15 +242,31 @@ if not useMCTracks:
     tkUnpack = UnpackTrack("UnpackTracks")
     preUnpackSeq.Members += [tkUnpack]
 
+    # Input tracks
+    inTracks = 'Rec/Track/Best'
+
+    if filterTksUsingMC:
+        from Configurables import Rich__Future__MC__TrackToMCParticleRelations as TkToMCPRels
+        tkRels = TkToMCPRels("TkMCLongFilterRels")
+        tkRels.TrackToMCParticlesRelations = "Rec/Track/BestLongRichMCRels"
+        from Configurables import Rich__Future__Rec__MC__TrackFilter as TkMCFilter
+        tkMCFilter = TkMCFilter("TkMCLongFilter")
+        tkMCFilter.InTracksLocation = inTracks
+        inTracks = 'Rec/Track/BestRichMCFiltered'
+        tkMCFilter.OutTracksLocation = inTracks
+        tkMCFilter.TrackToMCParticlesRelations = tkRels.TrackToMCParticlesRelations
+        all.Members += [tkRels, tkMCFilter]
+
     # Filter the tracks by type
     from Configurables import TracksSharedSplitterPerType as TrackFilter
     tkFilt = TrackFilter("TrackTypeFilter")
-    tkFilt.InputTracks = 'Rec/Track/Best'
+    tkFilt.InputTracks = inTracks
     tkFilt.LongTracks = 'Rec/Track/BestLong'
     tkFilt.DownstreamTracks = 'Rec/Track/BestDownstream'
     tkFilt.UpstreamTracks = 'Rec/Track/BestUpstream'
     tkFilt.Ttracks = 'Rec/Track/BestTtrack'
     tkFilt.VeloTracks = 'Rec/Track/BestVelo'
+
     all.Members += [tkFilt]
 
     # Input tracks
@@ -257,18 +293,8 @@ if not useMCTracks:
     #pidLocs = { "Up" : "Rec/Rich/UpPIDs" }
     #pidLocs = { "Down" : "Rec/Rich/DownPIDs" }
 
-    # Input tracks
-    inTracks = tkFilt.InputTracks
-
 else:
 
-    # Build track info from RICH extended MC info
-    from Configurables import (MCRichSegmentUnpacker, MCRichTrackUnpacker)
-    fetcher.DataKeys += [
-        'pSim/Rich/Segments', 'pSim/Rich/Tracks', 'pSim/MCVertices',
-        'pSim/MCParticles'
-    ]
-    preUnpackSeq.Members += [MCRichSegmentUnpacker(), MCRichTrackUnpacker()]
     # Fake Input tracks
     inTracks = "Rec/Track/FromRichMCTracks"
     # Use RichMCTracks as input
@@ -316,8 +342,8 @@ detYieldPrecision = "Average"
 tkCKResTreatment = "Parameterised"
 
 # Pixel background weights
-WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ("0.3" if enable4D[0] else "0.6")))
-WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ("0.3" if enable4D[0] else "0.6")))
+WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ("0.15" if enable4D[0] else "0.6")))
+WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ("0.15" if enable4D[0] else "0.6")))
 pdBckWeights = [(WR1, WR2), (WR1, WR2), (WR1, WR2), (WR1, WR2)]
 
 # Hit treatment in background alg
@@ -463,8 +489,6 @@ enableMCChecks = True
 enablePIDTuples = True
 
 if enableMCChecks or enablePIDTuples:
-    from Configurables import MCRichDigitSummaryUnpacker
-    from Configurables import MCRichHitUnpacker, MCRichOpticalPhotonUnpacker
     fetcher.DataKeys += [
         'pSim/MCVertices', 'pSim/MCParticles', 'pSim/Rich/Hits',
         'pSim/Rich/OpticalPhotons'
-- 
GitLab


From 6871f83b17494645ffba0bcc0f789a5a2f0af67a Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Fri, 3 Nov 2023 13:24:10 +0000
Subject: [PATCH 38/67] RichFutureRecSys: Update log file dir used in condor
 submission script

---
 Rich/RichFutureRecSys/examples/jobs/submit.sh | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/jobs/submit.sh b/Rich/RichFutureRecSys/examples/jobs/submit.sh
index 3831a02ac99..9b691d7f686 100755
--- a/Rich/RichFutureRecSys/examples/jobs/submit.sh
+++ b/Rich/RichFutureRecSys/examples/jobs/submit.sh
@@ -91,6 +91,11 @@ exit 0
 EOFSCRIPT
 chmod +x ${JobScript}
 
+# Condor log directory
+export CondorLogDir=${HOME}/CondorLogs/${JobName//\//_}
+#rm -rf ${CondorLogDir}
+mkdir ${CondorLogDir}
+
 # Create condor file
 CondorScript=${JobDir}"/jobs/condor.job"
 rm -f ${CondorScript}
@@ -119,9 +124,9 @@ request_memory = 1500
 # +IsSuspendableJob = True
 
 # Condor Output
-output = ${HOME}/CondorLogs/${JobName//\//_}.out.\$(Process)
-error  = ${HOME}/CondorLogs/${JobName//\//_}.err.\$(Process)
-Log    = ${HOME}/CondorLogs/${JobName//\//_}.log.\$(Process)
+output = ${CondorLogDir}/out.\$(Process)
+error  = ${CondorLogDir}/err.\$(Process)
+Log    = ${CondorLogDir}/log.\$(Process)
 
 # =============================================================================
 # Submit the job script
-- 
GitLab


From a67ff1ef990298f8ab73f394db28d87ce5e222c7 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Fri, 3 Nov 2023 13:25:35 +0000
Subject: [PATCH 39/67] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/33665431
---
 Rec/GlobalReco/root/RichKaonIDCompareFiles.C | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
index ef797504169..5d023fca053 100755
--- a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
+++ b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
@@ -19,12 +19,12 @@
 
 void RichKaonIDCompareFiles() {
 
-  //const std::string dir = "/usera/jonesc/LHCb/output/U2/InclB/WithSpill";
+  // const std::string dir = "/usera/jonesc/LHCb/output/U2/InclB/WithSpill";
   const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Rec/output/test";
-  
-  //const std::string fName = "RichFuture-Feature-x86_64_v2-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
+
+  // const std::string fName = "RichFuture-Feature-x86_64_v2-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
   const std::string fName = "RichFuture-Feature-x86_64_v3-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
-  
+
   std::map<std::string, std::vector<std::string>> dataSets;
 
   dataSets["Run3Tracking-3D"].push_back( "NominalDSTs" );
-- 
GitLab


From d17ea040ecd16d6af6b175ba164dbdd52ae85377 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 6 Nov 2023 12:33:13 +0000
Subject: [PATCH 40/67] RichTrSegMakerFromMCRichTracks: Use IdealStateCreator
 for below threshold tracks

---
 Rich/RichFutureRecMCAlgorithms/CMakeLists.txt |   1 +
 .../src/RichTrSegMakerFromMCRichTracks.cpp    | 221 +++++++++++++-----
 2 files changed, 162 insertions(+), 60 deletions(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt b/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
index 1ce7a821578..10067b4cb6c 100644
--- a/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
+++ b/Rich/RichFutureRecMCAlgorithms/CMakeLists.txt
@@ -32,6 +32,7 @@ gaudi_add_module(RichFutureRecMCAlgorithms
         LHCb::TrackEvent
         LHCb::LinkerEvent
         LHCb::MCEvent
+        LHCb::MCInterfaces
         Rec::RichFutureRecBase
         Rec::RichFutureRecEvent
         Rec::PrKernel
diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
index 79f7c874a1e..8f1599eba09 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
@@ -31,6 +31,7 @@
 #include "Event/MCRichTrack.h"
 #include "Event/MCTrackInfo.h"
 #include "Event/State.h"
+#include "Event/StateVector.h"
 #include "Event/Track.h"
 
 // Rich Utils
@@ -49,6 +50,8 @@
 #include "RichFutureRecEvent/RichRecRelations.h"
 
 // Track tools
+#include "DetDesc/IGeometryInfo.h"
+#include "MCInterfaces/IIdealStateCreator.h"
 #include "PrKernel/PrChecker.h"
 
 // STL
@@ -109,21 +112,26 @@ namespace Rich::Future::Rec::MC {
    *  @author Chris Jones
    *  @date   2023-06-29
    */
-  class TrSegMakerFromMCRichTracks final
-      : public LHCb::Algorithm::MultiTransformer<OutData( LHCb::MCRichTracks const&, //
-                                                          LHCb::MCProperty const&,   //
-                                                          SegMakerDetInfo const& ),
-                                                 LHCb::DetDesc::usesBaseAndConditions<AlgBase<>, SegMakerDetInfo>> {
+  class TrSegMakerFromMCRichTracks final : public LHCb::Algorithm::MultiTransformer<
+                                               OutData( LHCb::MCParticles const&,  //
+                                                        LHCb::MCRichTracks const&, //
+                                                        LHCb::MCProperty const&,   //
+                                                        SegMakerDetInfo const&,    //
+                                                        DetectorElement const& ),
+                                               LHCb::DetDesc::usesBaseAndConditions<AlgBase<>, //
+                                                                                    SegMakerDetInfo, DetectorElement>> {
 
   public:
     /// Standard constructor
     TrSegMakerFromMCRichTracks( const std::string& name, ISvcLocator* pSvcLocator )
         : MultiTransformer( name, pSvcLocator,
                             // data inputs
-                            {KeyValue{"MCRichTracksLocation", LHCb::MCRichTrackLocation::Default},
+                            {KeyValue{"MCParticleLocation", LHCb::MCParticleLocation::Default},
+                             KeyValue{"MCRichTracksLocation", LHCb::MCRichTrackLocation::Default},
                              KeyValue{"MCPropertyLocation", LHCb::MCPropertyLocation::TrackInfo},
                              // conditions input
-                             KeyValue{"DetectorCache", DeRichLocations::derivedCondition( name + "-DetectorCache" )}},
+                             KeyValue{"DetectorCache", DeRichLocations::derivedCondition( name + "-DetectorCache" )},
+                             KeyValue{"StandardGeometryTop", LHCb::standard_geometry_top}},
                             // data outputs
                             {KeyValue{"TrackSegmentsLocation", LHCb::RichTrackSegmentLocation::Default},
                              KeyValue{"TrackToSegmentsLocation", Relations::TrackToSegmentsLocation::Initial},
@@ -166,9 +174,11 @@ namespace Rich::Future::Rec::MC {
 
   public:
     /// Algorithm execution via transform
-    OutData operator()( LHCb::MCRichTracks const& mcRichtracks, //
+    OutData operator()( LHCb::MCParticles const&  mcParts,      //
+                        LHCb::MCRichTracks const& mcRichtracks, //
                         LHCb::MCProperty const&   mcProps,      //
-                        SegMakerDetInfo const&    detInfo ) const override {
+                        SegMakerDetInfo const&    detInfo,      //
+                        DetectorElement const&    geometry ) const override {
 
       _ri_debug << "Found " << mcRichtracks.size() << " MCRichTracks" << endmsg;
 
@@ -190,14 +200,17 @@ namespace Rich::Future::Rec::MC {
       // For reconstructibility check
       MCTrackInfo trackInfo( mcProps );
 
-      // Loop over MC Rich Tracks
+      // create map from MCP -> MCRichTrack
+      std::unordered_map<const LHCb::MCParticle*, const LHCb::MCRichTrack*> mcpToMCRT;
       for ( const auto mcRichTk : mcRichtracks ) {
-        // sanity check
-        if ( !mcRichTk ) { continue; }
-        _ri_verbo << "Considering MCRichTrack " << mcRichTk->key() << endmsg;
+        const auto mcp = ( mcRichTk ? mcRichTk->mcParticle() : nullptr );
+        if ( mcp ) { mcpToMCRT[mcp] = mcRichTk; }
+      }
+
+      // Loop over MCParticles
+      for ( const auto mcp : mcParts ) {
 
-        // associated MCParticle
-        const auto mcp = mcRichTk->mcParticle();
+        // sanity check
         if ( !mcp ) { continue; }
 
         // get charge
@@ -224,15 +237,6 @@ namespace Rich::Future::Rec::MC {
         const auto mcp_vect = mcp->momentum().Vect();
         if ( mcp->momentum().Pt() < m_minPt ) { continue; }
 
-        // Check required RICH segments
-        for ( const auto radiator : detInfo.radiators ) {
-          const auto rad = radiator->radiatorID();
-          if ( m_reqSegs[rad] && !mcRichTk->segmentInRad( rad ) ) {
-            _ri_verbo << " -> Has no " << rad << " segment -> rejected" << endmsg;
-            continue;
-          }
-        }
-
         // Check MCParticle is reconstructible as a Long track
         if ( LHCb::Pr::Checker::reconstructibleType( mcp, LHCb::Pr::Checker::RecAs::isNotLong, trackInfo ).value() ) {
           _ri_verbo << " -> MCParticle is not reconstructible as Long -> rejected" << endmsg;
@@ -240,9 +244,9 @@ namespace Rich::Future::Rec::MC {
         }
 
         // emulate tracking inefficiency
-        if ( m_randZeroOne.shoot() > m_tkEff ) { continue; }
+        if ( m_tkEff < 1.0 && m_randZeroOne.shoot() > m_tkEff ) { continue; }
 
-        // Create a fake 'reco' track for this MC track
+        // Create an emulated 'reco' track
         auto tk = std::make_unique<LHCb::Track>();
 
         // lambda func to create track states
@@ -271,43 +275,106 @@ namespace Rich::Future::Rec::MC {
         tk->setType( LHCb::Track::Types::Long );
 
         // Track errors... ??
-        LHCb::RichTrackSegment::StateErrors stateErrs{};
+        const LHCb::RichTrackSegment::StateErrors stateErrs{};
 
         // temporary container for segment indices
         Relations::SegmentIndices segList;
 
+        // Get MC Rich Track if available
+        const auto               findMCR  = mcpToMCRT.find( mcp );
+        const LHCb::MCRichTrack* mcRichTk = ( findMCR != mcpToMCRT.end() ? findMCR->second : nullptr );
+
+        // Check required RICH segments
+        if ( mcRichTk ) {
+          for ( const auto radiator : detInfo.radiators ) {
+            const auto rad = radiator->radiatorID();
+            if ( m_reqSegs[rad] && !mcRichTk->segmentInRad( rad ) ) {
+              _ri_verbo << " -> Has no " << rad << " segment -> rejected" << endmsg;
+              continue;
+            }
+          }
+        }
+
         // Loop over all radiators
         for ( const auto radiator : detInfo.radiators ) {
+
           // which radiator
           const auto rad = radiator->radiatorID();
           _ri_verbo << " -> Considering radiator " << rad << endmsg;
 
-          // Get MC segment for this track and radiator
-          const auto mcSeg = mcRichTk->segmentInRad( rad );
-          if ( !mcSeg ) { continue; }
-          _ri_verbo << "  -> Found MCRichSegment " << mcSeg->key() << endmsg;
-          _ri_verbo << "  -> " << *mcSeg << endmsg;
-
-          // Apply selection cuts
-          if ( mcSeg->pathLength() < m_minPathL[rad] ) { continue; }
-          if ( mcSeg->mcRichOpticalPhotons().size() < m_minPhots[rad] ) { continue; }
-          _ri_verbo << "   -> Passed selection cuts " << endmsg;
-
-          // Have an MC segment so make a reco segment
-
-          // Get entry information
-          const auto& entryPoint         = mcSeg->entryPoint();
-          const auto& entryStateMomentum = mcSeg->entryMomentum();
-          // Get exit information
-          const auto& exitPoint         = mcSeg->exitPoint();
-          const auto& exitStateMomentum = mcSeg->exitMomentum();
-          // Get middle point information
-          const auto midPoint         = mcSeg->bestPoint( 0.5 );
-          const auto midStateMomentum = mcSeg->bestMomentum( 0.5 );
+          // State info to extract
+          Gaudi::XYZPoint  entryPoint, exitPoint, midPoint;
+          Gaudi::XYZVector entryStateMomentum, exitStateMomentum, midStateMomentum;
+
+          // If we have a RichMCSegment use this
+          if ( mcRichTk ) {
+            // Use extended RICH MC information to form segment data
+            _ri_verbo << "Building segments using RICH extended MC information" << endmsg;
+
+            // Get MC segment for this track and radiator
+            const auto mcSeg = mcRichTk->segmentInRad( rad );
+            if ( !mcSeg ) { continue; }
+
+            _ri_verbo << "  -> Found MCRichSegment " << mcSeg->key() << endmsg;
+            _ri_verbo << "  -> " << *mcSeg << endmsg;
+
+            // Apply selection cuts
+            if ( mcSeg->pathLength() < m_minPathL[rad] ) { continue; }
+            if ( mcSeg->mcRichOpticalPhotons().size() < m_minPhots[rad] ) { continue; }
+
+            // Have an MC segment so make a reco segment
+
+            // Get state information
+            entryPoint         = mcSeg->entryPoint();
+            entryStateMomentum = mcSeg->entryMomentum();
+            exitPoint          = mcSeg->exitPoint();
+            exitStateMomentum  = mcSeg->exitMomentum();
+            midPoint           = mcSeg->bestPoint( 0.5 );
+            midStateMomentum   = mcSeg->bestMomentum( 0.5 );
+
+          } else if ( m_useIdealStates[rad] ) {
+            //  Try and use ideal state creator tool ...
+            _ri_verbo << "Building segments using ideal state creator" << endmsg;
+
+            // radiator entry and exit z positions
+            const auto zStart = ( Rich::Rich2Gas == rad ? m_nomZstates[2] : m_nomZstates[0] );
+            const auto zEnd   = ( Rich::Rich2Gas == rad ? m_nomZstates[3] : m_nomZstates[1] );
+            const auto zMid   = ( zStart + zEnd ) * 0.5;
+            // form state vectors
+            LHCb::StateVector entrySV, exitSV, midSV;
+            const auto        sc = //
+                ( m_ideal_state_creator->createStateVector( mcp, zStart, entrySV, geometry ) &&
+                  m_ideal_state_creator->createStateVector( mcp, zEnd, exitSV, geometry ) &&
+                  m_ideal_state_creator->createStateVector( mcp, zMid, midSV, geometry ) );
+            if ( !sc ) { continue; }
+
+            // Get the state info
+            entryPoint         = entrySV.position();
+            entryStateMomentum = entrySV.momentum();
+            exitPoint          = exitSV.position();
+            exitStateMomentum  = exitSV.momentum();
+            midPoint           = midSV.position();
+            midStateMomentum   = midSV.momentum();
+
+            // Apply selection cuts
+            const auto plength = std::sqrt( ( entryPoint - exitPoint ).Mag2() );
+            if ( plength < m_minPathL[rad] ) { continue; }
+
+          } else {
+            // reject
+            continue;
+          }
 
-          _ri_verbo << "Rad Points  | entry=" << entryPoint << " mid=" << midPoint << " exit=" << exitPoint << endmsg;
-          _ri_verbo << "Rad Momenta | entry=" << entryStateMomentum << " mid=" << midStateMomentum
-                    << " exit=" << exitStateMomentum << endmsg;
+          // Check point (x,y) boundaries
+          auto checkBoundaries = [&]( const auto& point ) {
+            const auto R2 = ( point.x() * point.x() + point.y() * point.y() );
+            return ( fabs( point.x() ) < m_maxX[rad] && //
+                     fabs( point.y() ) < m_maxY[rad] && //
+                     ( m_minR2[rad] < 0.01 || R2 > m_minR2[rad] ) );
+          };
+          if ( !checkBoundaries( entryPoint ) || !checkBoundaries( midPoint ) || !checkBoundaries( exitPoint ) ) {
+            continue;
+          }
 
           // Sanity checks on entry/exit points
           if ( entryPoint.Z() < m_minZ[rad] || midPoint.Z() < m_minZ[rad] || exitPoint.Z() < m_minZ[rad] ) { continue; }
@@ -315,15 +382,19 @@ namespace Rich::Future::Rec::MC {
           // check min/max momentum on segment
           if ( std::sqrt( entryStateMomentum.mag2() ) < m_minP[rad] || //
                std::sqrt( midStateMomentum.mag2() ) < m_minP[rad] ||   //
-               std::sqrt( exitStateMomentum.mag2() ) < m_minP[rad] ) {
-            continue;
-          }
-          if ( std::sqrt( entryStateMomentum.mag2() ) > m_maxP[rad] || //
+               std::sqrt( exitStateMomentum.mag2() ) < m_minP[rad] ||  //
+               std::sqrt( entryStateMomentum.mag2() ) > m_maxP[rad] || //
                std::sqrt( midStateMomentum.mag2() ) > m_maxP[rad] ||   //
                std::sqrt( exitStateMomentum.mag2() ) > m_maxP[rad] ) {
             continue;
           }
 
+          _ri_verbo << "   -> Passed selection cuts " << endmsg;
+          _ri_verbo << "    -> Rad Points  | entry=" << entryPoint << " mid=" << midPoint << " exit=" << exitPoint
+                    << endmsg;
+          _ri_verbo << "    -> Rad Momenta | entry=" << entryStateMomentum << " mid=" << midStateMomentum
+                    << " exit=" << exitStateMomentum << endmsg;
+
           // if get here segment will be saved so save relations
           segList.push_back( segments.size() ); // this gives the index for the next entry ...
           segToTkRel.push_back( tkIndex );
@@ -350,8 +421,8 @@ namespace Rich::Future::Rec::MC {
           _ri_verbo << "Created RichTrackSegment : " << segments.back() << endmsg;
         }
 
-        // If we made at least one segment, save track
-        if ( !segList.empty() ) {
+        // Finally save the track
+        if ( m_saveAllTracks || !segList.empty() ) {
           // Just use index as key ...
           const auto tkKey = tkIndex;
           // relations stuff...
@@ -367,7 +438,7 @@ namespace Rich::Future::Rec::MC {
           ++tkIndex;
         }
 
-      } // MC track loop
+      } // MCParticle loop
 
       // initialise the linker
       tkLinks = LHCb::LinksByKey{std::in_place_type<LHCb::Track>, std::in_place_type<LHCb::MCParticle>,
@@ -394,6 +465,9 @@ namespace Rich::Future::Rec::MC {
     /// random number between 0 and 1
     Rndm::Numbers m_randZeroOne{};
 
+    /// Ideal sate creator
+    ToolHandle<IIdealStateCreator> m_ideal_state_creator{this, "IdealStateCreator", "IdealStateCreator"};
+
   private:
     // properties
 
@@ -424,6 +498,15 @@ namespace Rich::Future::Rec::MC {
     /// Minimum z position for states in each radiator (mm)
     Gaudi::Property<RadiatorArray<double>> m_minZ{this, "MinStateZ", {800, 800, 9000}};
 
+    /// Maximum X for states in each radiator
+    Gaudi::Property<RadiatorArray<double>> m_maxX{this, "MaxX", {375, 500, 3000}};
+
+    /// Maximum Y for states in each radiator
+    Gaudi::Property<RadiatorArray<double>> m_maxY{this, "MaxY", {375, 500, 2500}};
+
+    /// Minimum R^2 for states in each radiator
+    Gaudi::Property<RadiatorArray<double>> m_minR2{this, "MinR2", {50 * 50, 50 * 50, 100 * 100}};
+
     /// Tolerance on track origin w.r.t. (0,0,0)
     Gaudi::Property<std::array<double, 3>> m_tkOriginTol{this, "TrackOriginTol", {1.0, 1.0, 100.0}};
 
@@ -431,7 +514,25 @@ namespace Rich::Future::Rec::MC {
     Gaudi::Property<RadiatorArray<bool>> m_reqSegs{this, "RequireSegment", {false, false, false}};
 
     /// Tracking efficiency
-    Gaudi::Property<double> m_tkEff{this, "TrackingEfficiency", 0.90, "Tracking efficiency to emulate"};
+    Gaudi::Property<double> m_tkEff{this, "TrackingEfficiency", 1.1, "Tracking efficiency to emulate"};
+
+    /// Allow use of ideal state creator when RICH data is missing
+    Gaudi::Property<RadiatorArray<bool>> m_useIdealStates{this, "UseIdealStates", {true, true, true}};
+
+    /// Nominal z positions of states at RICHes
+    Gaudi::Property<std::array<double, 2 * Rich::NRiches>> m_nomZstates{
+        this,
+        "NominalStateZ",
+        {
+            990 * Gaudi::Units::mm,  ///< Place to look for Rich1 entry state
+            2165 * Gaudi::Units::mm, ///< Place to look for Rich1 exit state
+            9450 * Gaudi::Units::mm, ///< Place to look for Rich2 entry state
+            11900 * Gaudi::Units::mm ///< Place to look for Rich2 exit state
+        },
+        "The z positions to look for state at the entry/exit of RICH1/RICH2."};
+
+    /// Always save tracks even if no RICH segments
+    Gaudi::Property<bool> m_saveAllTracks{this, "SaveAllTracks", true, "Save all tracks"};
 
   }; // namespace Rich::Future::Rec::MC
 
-- 
GitLab


From 4a4cb6334813581760e69116f47296f7b0536f5e Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 6 Nov 2023 12:34:07 +0000
Subject: [PATCH 41/67] GlobalPID.h: Do not reject BT tracks by default

---
 Rec/GlobalReco/root/GlobalPID.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rec/GlobalReco/root/GlobalPID.h b/Rec/GlobalReco/root/GlobalPID.h
index 2931e16216f..1331e264671 100755
--- a/Rec/GlobalReco/root/GlobalPID.h
+++ b/Rec/GlobalReco/root/GlobalPID.h
@@ -105,7 +105,7 @@ public: // classes
     std::string         cutType{">"}, secCutType{">"};
     bool                useFixedGraphRange{true};
     double              minGraphX{60}, maxGraphX{100}, minGraphY{1}, maxGraphY{40};
-    bool                rejectBThypos{true};
+    bool                rejectBThypos{false};
   };
 
 public:
-- 
GitLab


From 732acdf1327b66a9847d36cf03fa1b5b83dc9b5b Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 6 Nov 2023 12:34:50 +0000
Subject: [PATCH 42/67] IdealStateCreator: Add missing locations for hit
 linkers

---
 Tr/TrackMCTools/src/IdealStateCreator.cpp | 58 ++++++++++++-----------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/Tr/TrackMCTools/src/IdealStateCreator.cpp b/Tr/TrackMCTools/src/IdealStateCreator.cpp
index 6c827f996ee..d7963624888 100644
--- a/Tr/TrackMCTools/src/IdealStateCreator.cpp
+++ b/Tr/TrackMCTools/src/IdealStateCreator.cpp
@@ -28,16 +28,16 @@
 #include <vector>
 
 namespace {
-  double qOverP( const LHCb::MCParticle* mcPart ) {
-    const double charge = ( mcPart->particleID().threeCharge() ) / 3.;
-    const double p      = mcPart->p();
+  auto qOverP( const LHCb::MCParticle& mcPart ) {
+    const auto charge = ( mcPart.particleID().threeCharge() ) / 3.;
+    const auto p      = mcPart.p();
     return ( p < TrackParameters::lowTolerance ? 0.0 : charge / p );
   }
 
-  double qOverP( const LHCb::MCHit* mcHit ) {
-    const double charge = ( mcHit->mcParticle()->particleID().threeCharge() ) / 3.;
-    const double p      = mcHit->p();
-    return ( p < TrackParameters::lowTolerance ? qOverP( mcHit->mcParticle() ) : charge / p );
+  auto qOverP( const LHCb::MCHit& mcHit ) {
+    const auto charge = ( mcHit.mcParticle()->particleID().threeCharge() ) / 3.;
+    const auto p      = mcHit.p();
+    return ( p < TrackParameters::lowTolerance ? qOverP( *mcHit.mcParticle() ) : charge / p );
   }
 
 } // namespace
@@ -92,11 +92,14 @@ private:
 
   DataObjectReadHandle<LHCb::MCVertices> m_mc_vertices{this, "MCVertices", LHCb::MCVertexLocation::Default};
   DataObjectReadHandle<LHCb::MCHits>     m_mc_vp_hits{this, "VPMCHits", LHCb::MCHitLocation::VP};
-  DataObjectReadHandle<LHCb::LinksByKey> m_mc_vp_hits_links{this, "VPMCHitLinks", ""};
+  DataObjectReadHandle<LHCb::LinksByKey> m_mc_vp_hits_links{this, "VPMCHitLinks",
+                                                            LHCb::LinksByKey::linkerName( LHCb::MCHitLocation::VP )};
   DataObjectReadHandle<LHCb::MCHits>     m_mc_ut_hits{this, "UTMCHits", LHCb::MCHitLocation::UT};
-  DataObjectReadHandle<LHCb::LinksByKey> m_mc_ut_hits_links{this, "UTMCHitLinks", ""};
+  DataObjectReadHandle<LHCb::LinksByKey> m_mc_ut_hits_links{this, "UTMCHitLinks",
+                                                            LHCb::LinksByKey::linkerName( LHCb::MCHitLocation::UT )};
   DataObjectReadHandle<LHCb::MCHits>     m_mc_ft_hits{this, "FTMCHits", LHCb::MCHitLocation::FT};
-  DataObjectReadHandle<LHCb::LinksByKey> m_mc_ft_hits_links{this, "FTMCHitLinks", ""};
+  DataObjectReadHandle<LHCb::LinksByKey> m_mc_ft_hits_links{this, "FTMCHitLinks",
+                                                            LHCb::LinksByKey::linkerName( LHCb::MCHitLocation::FT )};
 
   //=============================================================================
   // Correct slopes for magnetic field given an MCHit and a MCParticle
@@ -109,13 +112,13 @@ private:
 
     // Get magnetic field vector
     Gaudi::XYZVector B;
-    m_magSvc->fieldVector( mcHit->midPoint(), B ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
+    m_magSvc->fieldVector( mcHit->midPoint(), B ).ignore();
 
     // Calculate new displacement vector and tx,ty slopes
-    Gaudi::XYZVector d    = mcHit->displacement();
-    Gaudi::XYZVector dNew = d - ( 0.5 * d.R() * qOverP( mcHit ) * d.Cross( B ) * eplus * c_light );
-    tx                    = dNew.x() / dNew.z();
-    ty                    = dNew.y() / dNew.z();
+    const auto d    = mcHit->displacement();
+    const auto dNew = d - ( 0.5 * d.R() * qOverP( *mcHit ) * d.Cross( B ) * eplus * c_light );
+    tx              = dNew.x() / dNew.z();
+    ty              = dNew.y() / dNew.z();
   }
 
 public:
@@ -130,10 +133,10 @@ public:
                           IGeometryInfo const& geometry ) const override {
 
     // Check if MCParticle exists
-    if ( mcPart == nullptr ) return StatusCode::FAILURE;
+    if ( !mcPart ) { return StatusCode::FAILURE; }
 
     // Get the closest MCHit
-    LHCb::MCHit const* closestHit = findClosestHit( mcPart, zRec );
+    const auto closestHit = findClosestHit( mcPart, zRec );
     if ( !closestHit ) return Error( "No closest MCHit found!!" );
 
     return createState( closestHit, zRec, state, geometry );
@@ -150,7 +153,7 @@ public:
                                 IGeometryInfo const& geometry ) const override {
 
     // Check if MCParticle exists
-    if ( mcPart == 0 ) return StatusCode::FAILURE;
+    if ( !mcPart ) { return StatusCode::FAILURE; }
 
     // Get the closest MCHit
     LHCb::MCHit const* closestHit = findClosestHit( mcPart, zRec );
@@ -185,7 +188,7 @@ public:
     state.setCovariance( cov );
 
     // transport to the z we want
-    StatusCode sc = m_extrapolator->propagate( state, zRec, geometry );
+    const auto sc = m_extrapolator->propagate( state, zRec, geometry );
     if ( sc.isFailure() ) {
       warning() << "Extrapolation of True State from z = " << state.z() << " to z = " << zRec << " failed!" << endmsg;
     }
@@ -223,13 +226,13 @@ public:
 
   void createStateVector( LHCb::MCHit const* aHit, LHCb::StateVector& pVec ) const {
     // Correct tx and ty from the MCHit for the magnetic field
-    double tx = aHit->dxdz();
-    double ty = aHit->dydz();
-    if ( m_correctSlopes ) correctSlopes( aHit, tx, ty );
+    auto tx = aHit->dxdz();
+    auto ty = aHit->dydz();
+    if ( m_correctSlopes ) { correctSlopes( aHit, tx, ty ); }
     Gaudi::XYZVector direction( tx, ty, 1.0 );
 
     // determine Q/P
-    const double trueQOverP = qOverP( aHit );
+    const auto trueQOverP = qOverP( *aHit );
 
     // construct true State
     pVec = LHCb::StateVector( aHit->entry(), direction, trueQOverP );
@@ -244,10 +247,10 @@ public:
   StatusCode createStateVertex( LHCb::MCParticle const* mcParticle, LHCb::State& state ) const override {
 
     // Check if MCParticle exists
-    if ( mcParticle == 0 ) return StatusCode::FAILURE;
+    if ( !mcParticle ) { return StatusCode::FAILURE; }
 
     LHCb::StateVector pVec;
-    StatusCode        sc = createStateVectorVertex( mcParticle, pVec );
+    const auto        sc = createStateVectorVertex( mcParticle, pVec );
     if ( sc.isFailure() ) { return Warning( "Failed to create state vector", StatusCode::SUCCESS ); }
 
     state.setZ( pVec.z() );
@@ -274,7 +277,7 @@ public:
   StatusCode createStateVectorVertex( LHCb::MCParticle const* mcParticle, LHCb::StateVector& pVec ) const override {
 
     // Check if MCParticle exists
-    if ( mcParticle == 0 ) return StatusCode::FAILURE;
+    if ( !mcParticle ) { return StatusCode::FAILURE; }
 
     // retrieve true MC particle info
     auto const* mcVertex = mcParticle->originVertex();
@@ -282,7 +285,7 @@ public:
     auto const& mc4Mom   = mcParticle->momentum();
 
     // determine Q/P
-    const double trueQOverP = qOverP( mcParticle );
+    const auto trueQOverP = qOverP( *mcParticle );
 
     // construct true State
     pVec = LHCb::StateVector( mcPos, Gaudi::XYZVector( mc4Mom ), trueQOverP );
@@ -295,6 +298,7 @@ public:
   // looping over the hits in all the tracking detectors
   //=============================================================================
   LHCb::MCHit const* findClosestHit( LHCb::MCParticle const* mcPart, const double zRec ) const {
+
     LHCb::MCHit const* closestHit = nullptr;
     double             closestZ   = 1000000.0;
 
-- 
GitLab


From 99bba2cbf708dc11cab95a2ec286d4a7e38329e4 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 6 Nov 2023 12:36:26 +0000
Subject: [PATCH 43/67] richFuture.py: Add options needed for IdealStateCreator

---
 Rich/RichFutureRecSys/examples/RichFuture.py | 29 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index c5f1e1f7640..146b11477ea 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -18,7 +18,8 @@ from Configurables import LHCbApp, GaudiSequencer, DDDBConf
 from Configurables import UnpackMCParticle, UnpackMCVertex
 from Configurables import MCRichSegmentUnpacker, MCRichTrackUnpacker, MCRichHitUnpacker
 from Configurables import MCRichDigitSummaryUnpacker, MCRichOpticalPhotonUnpacker
-from Configurables import FPEAuditor
+from Configurables import MCFTHitUnpacker, MCUTHitUnpacker, MCVPHitUnpacker
+from Configurables import FPEAuditor, MCParticle2MCHitAlg
 import os, socket
 
 # --------------------------------------------------------------------------------------
@@ -135,7 +136,7 @@ tkSegAddTimeFromMC = ((enable4D[0] or enable4D[1]) and not useMCTracks)
 usePixelMCTime = ((enable4D[0] or enable4D[1]) and not useMCHits)
 
 # Cheat pixel positions using MC info
-usePixelMCPos = True
+usePixelMCPos = False
 
 # Filter 'real' tracks based on MC info.
 # Designed to help match those made from MCRichTracks, where certain
@@ -216,7 +217,7 @@ else:
     richMCDecode.RejectAllBackgrounds = False
     richMCDecode.RejectScintillation = False
     richMCDecode.IncludeTimeInfo = True
-    richMCDecode.AllowMultipleHits = True
+    richMCDecode.AllowMultipleHits = False
     all.Members += [richMCDecode]
 
 # Now get the RICH sequence
@@ -295,6 +296,26 @@ if not useMCTracks:
 
 else:
 
+    # Needed for ideal state creator
+    unpVPHits = MCVPHitUnpacker()
+    unpFTHits = MCFTHitUnpacker()
+    unpUTHits = MCUTHitUnpacker()
+    linkVP = MCParticle2MCHitAlg(
+        "LinkVPMCHits",
+        MCHitPath=unpVPHits.OutputName,
+        OutputData="Link/MC/VP/Hits")
+    linkFF = MCParticle2MCHitAlg(
+        "LinkFTMCHits",
+        MCHitPath=unpFTHits.OutputName,
+        OutputData="Link/MC/FT/Hits")
+    linkUT = MCParticle2MCHitAlg(
+        "LinkUTMCHits",
+        MCHitPath=unpUTHits.OutputName,
+        OutputData="Link/MC/UT/Hits")
+    preUnpackSeq.Members += [
+        unpVPHits, unpFTHits, unpUTHits, linkVP, linkFF, linkUT
+    ]
+
     # Fake Input tracks
     inTracks = "Rec/Track/FromRichMCTracks"
     # Use RichMCTracks as input
@@ -344,6 +365,8 @@ tkCKResTreatment = "Parameterised"
 # Pixel background weights
 WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ("0.15" if enable4D[0] else "0.6")))
 WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ("0.15" if enable4D[0] else "0.6")))
+#WR1 = 0.6
+#WR2 = 0.6
 pdBckWeights = [(WR1, WR2), (WR1, WR2), (WR1, WR2), (WR1, WR2)]
 
 # Hit treatment in background alg
-- 
GitLab


From 06a5d5f29bdf916e1f5dc27b59198255fe00d420 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 6 Nov 2023 12:37:06 +0000
Subject: [PATCH 44/67] Update job submission scripts

---
 Rich/RichFutureRecSys/examples/jobs/merge.py  | 2 +-
 Rich/RichFutureRecSys/examples/jobs/submit.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/jobs/merge.py b/Rich/RichFutureRecSys/examples/jobs/merge.py
index de27e088b8b..b22c693999b 100755
--- a/Rich/RichFutureRecSys/examples/jobs/merge.py
+++ b/Rich/RichFutureRecSys/examples/jobs/merge.py
@@ -76,7 +76,7 @@ if __name__ == '__main__':
     else:
 
         # Find jobs to merge
-        dirs = directory_find("jobs", "CondorJobs")
+        dirs = directory_find("jobs")
         print("Found", len(dirs), "directories to merge")
 
         # Get the number of processors available
diff --git a/Rich/RichFutureRecSys/examples/jobs/submit.sh b/Rich/RichFutureRecSys/examples/jobs/submit.sh
index 9b691d7f686..afbaaa9ddec 100755
--- a/Rich/RichFutureRecSys/examples/jobs/submit.sh
+++ b/Rich/RichFutureRecSys/examples/jobs/submit.sh
@@ -54,7 +54,7 @@ mkdir -p ${JobDir}
 mkdir -p ${JobDir}"/jobs"
 OptsRoot="${HOME}/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
 cp ${OptsRoot}"RichFuture.py" ${JobDir}/"jobs/opts.py"
-cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py" ${JobDir}"/jobs/EvtType.py"
+cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py" ${JobDir}"/jobs/EvtType.py"
 cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/files.py" ${JobDir}"/jobs/files.py"
 export RunOptions="${JobDir}/jobs/opts.py ${JobDir}/jobs/EvtType.py ${JobDir}/jobs/files.py"
 
@@ -94,7 +94,7 @@ chmod +x ${JobScript}
 # Condor log directory
 export CondorLogDir=${HOME}/CondorLogs/${JobName//\//_}
 #rm -rf ${CondorLogDir}
-mkdir ${CondorLogDir}
+mkdir -p ${CondorLogDir}
 
 # Create condor file
 CondorScript=${JobDir}"/jobs/condor.job"
-- 
GitLab


From 2073f0bbe2dfea1ab07cf494886cfc737e7d06c1 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 6 Nov 2023 17:36:32 +0000
Subject: [PATCH 45/67] RichTrSegMakerFromMCRichTracks: Add missing
 DetectorElement include

---
 .../src/RichTrSegMakerFromMCRichTracks.cpp      | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
index 8f1599eba09..81b99eeded7 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
@@ -49,8 +49,12 @@
 // Rec event model
 #include "RichFutureRecEvent/RichRecRelations.h"
 
-// Track tools
+// Detector elements
+#include "DetDesc/DetectorElement.h"
+#include "DetDesc/GenericConditionAccessorHolder.h"
 #include "DetDesc/IGeometryInfo.h"
+
+// Track Tools
 #include "MCInterfaces/IIdealStateCreator.h"
 #include "PrKernel/PrChecker.h"
 
@@ -380,12 +384,11 @@ namespace Rich::Future::Rec::MC {
           if ( entryPoint.Z() < m_minZ[rad] || midPoint.Z() < m_minZ[rad] || exitPoint.Z() < m_minZ[rad] ) { continue; }
 
           // check min/max momentum on segment
-          if ( std::sqrt( entryStateMomentum.mag2() ) < m_minP[rad] || //
-               std::sqrt( midStateMomentum.mag2() ) < m_minP[rad] ||   //
-               std::sqrt( exitStateMomentum.mag2() ) < m_minP[rad] ||  //
-               std::sqrt( entryStateMomentum.mag2() ) > m_maxP[rad] || //
-               std::sqrt( midStateMomentum.mag2() ) > m_maxP[rad] ||   //
-               std::sqrt( exitStateMomentum.mag2() ) > m_maxP[rad] ) {
+          const auto entP = std::sqrt( entryStateMomentum.mag2() );
+          const auto extP = std::sqrt( exitStateMomentum.mag2() );
+          const auto midP = std::sqrt( midStateMomentum.mag2() );
+          if ( entP < m_minP[rad] || midP < m_minP[rad] || extP < m_minP[rad] || //
+               entP > m_maxP[rad] || midP > m_maxP[rad] || extP > m_maxP[rad] ) {
             continue;
           }
 
-- 
GitLab


From b1aad0e510daefdd4aa8e03bc805b05e541ae58d Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 7 Nov 2023 10:31:15 +0000
Subject: [PATCH 46/67] RichDetectorHits: Protect against AIDA return nonsense
 indices

---
 .../src/RichDetectorHits.cpp                  | 35 ++++++++++---------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
index 41107cd191d..2d0693b49bd 100644
--- a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
@@ -24,6 +24,7 @@
 #include "AIDA/IAxis.h"
 
 // STD
+#include <algorithm>
 #include <cstdint>
 #include <mutex>
 #include <vector>
@@ -133,8 +134,10 @@ namespace Rich::Future::Rec::Moni {
                     fillHisto( h_pixXLoc[rich], lPos.X() );
                     fillHisto( h_pixYLoc[rich], lPos.Y() );
                     // cache occupancy data
-                    const auto iX             = h_pdXYLocOcc[rich]->xAxis().coordToIndex( lPos.X() );
-                    const auto iY             = h_pdXYLocOcc[rich]->yAxis().coordToIndex( lPos.Y() );
+                    const auto iX =
+                        std::clamp( h_pdXYOcc[rich]->xAxis().coordToIndex( lPos.X() ), 0, (int)nBins2D() - 1 );
+                    const auto iY =
+                        std::clamp( h_pdXYOcc[rich]->yAxis().coordToIndex( lPos.Y() ), 0, (int)nBins2D() - 1 );
                     pdOccXY.at( iX ).at( iY ) = rawIDs.size();
                   }
 
@@ -151,14 +154,14 @@ namespace Rich::Future::Rec::Moni {
         // Fill occupancies
         for ( auto iX = 0u; iX < nBins2D(); ++iX ) {
           for ( auto iY = 0u; iY < nBins2D(); ++iY ) {
-            const auto X   = 0.5 * ( h_pdXYLocOcc[rich]->xAxis().binLowerEdge( iX ) +
-                                   h_pdXYLocOcc[rich]->xAxis().binUpperEdge( iX ) );
-            const auto Y   = 0.5 * ( h_pdXYLocOcc[rich]->yAxis().binLowerEdge( iY ) +
-                                   h_pdXYLocOcc[rich]->yAxis().binUpperEdge( iY ) );
-            const auto occ = pdOccXY.at( iX ).at( iY );
-            fillHisto( h_pdXYLocOcc[rich], X, Y, occ );
-            fillHisto( h_pdXLocOcc[rich], X, occ );
-            fillHisto( h_pdYLocOcc[rich], Y, occ );
+            const auto X =
+                0.5 * ( h_pdXYOcc[rich]->xAxis().binLowerEdge( iX ) + h_pdXYOcc[rich]->xAxis().binUpperEdge( iX ) );
+            const auto Y =
+                0.5 * ( h_pdXYOcc[rich]->yAxis().binLowerEdge( iY ) + h_pdXYOcc[rich]->yAxis().binUpperEdge( iY ) );
+            const auto occ = pdOccXY[iX][iY];
+            fillHisto( h_pdXYOcc[rich], X, Y, occ );
+            fillHisto( h_pdXOcc[rich], X, occ );
+            fillHisto( h_pdYOcc[rich], Y, occ );
           }
         }
 
@@ -264,18 +267,18 @@ namespace Rich::Future::Rec::Moni {
                                          "Local Y hits",                                   //
                                          -panelYsizes[rich], panelYsizes[rich], nBins1D(), //
                                          "Local Y / mm" ) );
-        ok &= saveAndCheck( h_pdXYLocOcc[rich],                                              //
+        ok &= saveAndCheck( h_pdXYOcc[rich],                                                 //
                             richProfile2D( HID( "pdOccXYLoc", rich ),                        //
                                            "PD Average Occupancy (X,Y)",                     //
                                            -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
                                            -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
                                            "Local X / mm", "Local Y / mm" ) );
-        ok &= saveAndCheck( h_pdXLocOcc[rich],                                               //
+        ok &= saveAndCheck( h_pdXOcc[rich],                                                  //
                             richProfile1D( HID( "pdOccXLoc", rich ),                         //
                                            "PD Average Occupancy (X)",                       //
                                            -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
                                            "Local X / mm" ) );
-        ok &= saveAndCheck( h_pdYLocOcc[rich],                                               //
+        ok &= saveAndCheck( h_pdYOcc[rich],                                                  //
                             richProfile1D( HID( "pdOccYLoc", rich ),                         //
                                            "PD Average Occupancy (Y)",                       //
                                            -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
@@ -317,9 +320,9 @@ namespace Rich::Future::Rec::Moni {
     DetectorArray<AIDA::IHistogram1D*> h_pixXLoc  = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_pixYLoc  = {{}};
 
-    DetectorArray<AIDA::IProfile2D*> h_pdXYLocOcc = {{}};
-    DetectorArray<AIDA::IProfile1D*> h_pdXLocOcc  = {{}};
-    DetectorArray<AIDA::IProfile1D*> h_pdYLocOcc  = {{}};
+    DetectorArray<AIDA::IProfile2D*> h_pdXYOcc = {{}};
+    DetectorArray<AIDA::IProfile1D*> h_pdXOcc  = {{}};
+    DetectorArray<AIDA::IProfile1D*> h_pdYOcc  = {{}};
   };
 
   // Declaration of the Algorithm Factory
-- 
GitLab


From 9043522a2b1f36ff1b15026184a20b6c199479ae Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 7 Nov 2023 10:31:42 +0000
Subject: [PATCH 47/67] Fix RICH QMT test options for MC decoding

---
 Rich/RichFutureRecSys/tests/options/rich-dst-reco.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py b/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py
index 92950e02c69..b1eec35f0f5 100644
--- a/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py
+++ b/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py
@@ -136,10 +136,8 @@ if not useMCHits:
         ]
 else:
     from Configurables import Rich__Future__MC__DecodedDataFromMCRichHits as RichMCDecoder
-    richMCDecode = RichMCDecoder("RichDecodeFromMC")
-    richMCDecode.IsDetDescMC = isDetDescMC
-    richMCDecode.RejectBackground = False
-    richMCDecode.IncludeTimeInfo = is4D
+    richMCDecode = RichMCDecoder(
+        "RichDecodeFromMC", IsDetDescMC=isDetDescMC, IncludeTimeInfo=is4D)
     all.Members += [richMCDecode]
 
 # DataType
-- 
GitLab


From 437741a45bf654209451132032e7cbf174d9692a Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 7 Nov 2023 13:12:04 +0000
Subject: [PATCH 48/67] ConfiguredRichReco.py: Reset PDBackThresholds and
 PDBckWeights to nominal defaults

---
 .../python/RichFutureRecSys/ConfiguredRichReco.py            | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
index 4fd8105c541..3bde87f47f6 100644
--- a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
+++ b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
@@ -431,11 +431,10 @@ def RichRecoSequence(
         PDBackMaxPixBackground=[(99, 99), (99, 99), (99, 99), (99, 99)],
 
         # Threshold values for background values
-        PDBackThresholds=[(0.005, 0.005), (0.005, 0.005), (0.005, 0.005),
-                          (0.005, 0.005)],
+        PDBackThresholds=[(0, 0), (0, 0), (0, 0), (0, 0)],
 
         # Background weights for each RICH
-        PDBckWeights=[(0.6, 0.6), (0.6, 0.6), (0.6, 0.6), (0.6, 0.6)],
+        PDBckWeights=[(1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0)],
 
         # Likelihood minimizer options
 
-- 
GitLab


From 87fc1a69aed979333d744c917b2f5cdac253d30e Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 7 Nov 2023 13:12:46 +0000
Subject: [PATCH 49/67] RichSIMDPixelBackgroundsEstiAvHPD: Use PMT EC as
 background grouping

---
 .../src/RichSIMDPixelBackgroundsEstiAvHPD.cpp | 27 +++++++++++--------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
index 03e5509ce50..0de247c1ce1 100644
--- a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
+++ b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
@@ -85,32 +85,37 @@ namespace Rich::Future::Rec {
 
     public:
       /// Gets the working data index for the given PD ID
-      inline decltype( auto ) pdIndex( const LHCb::RichSmartID  pdID, //
-                                       const Rich::DetectorType rich, //
-                                       const Rich::Side         panel ) const noexcept {
+      inline auto pdIndex( const LHCb::RichSmartID  pdID, //
+                           const Rich::DetectorType rich, //
+                           const Rich::Side         panel ) const noexcept {
         // Just use module number
         // const auto idx = pdID.pdMod();
         // Group modules in neighboring columns, doubling group size
-        const auto colGSize = 2u;
-        const auto colG     = pdID.panelLocalModuleColumn() / colGSize;
-        const auto idx      = ( colG * LHCb::RichSmartID::MaPMT::ModulesPerColumn ) + pdID.columnLocalModuleNum();
+        // const auto colGSize = 2u;
+        // const auto colG     = pdID.panelLocalModuleColumn() / colGSize;
+        // const auto idx      = ( colG * LHCb::RichSmartID::MaPMT::ModulesPerColumn ) + pdID.columnLocalModuleNum();
+        // Use EC ( 4 groups per module )
+        const auto idx = ( LHCb::RichSmartID::MaPMT::ECsPerModule * pdID.pdMod() ) + pdID.elementaryCell();
+        // Group two ECs together ( 2 groups per module )
+        // const auto idx =
+        //    ( ( LHCb::RichSmartID::MaPMT::ECsPerModule / 2 ) * pdID.pdMod() ) + ( pdID.elementaryCell() / 2 );
         // return with min scale
         return ( idx - minPanelIndex[rich][panel] );
       }
 
       /// Gets the working data index for the given PD ID
-      inline decltype( auto ) pdIndex( const LHCb::RichSmartID  pdID, //
-                                       const Rich::DetectorType rich ) const noexcept {
+      inline auto pdIndex( const LHCb::RichSmartID  pdID, //
+                           const Rich::DetectorType rich ) const noexcept {
         return pdIndex( pdID, rich, pdID.panel() );
       }
 
       /// Gets the working data index for the given PD ID
-      inline decltype( auto ) pdIndex( const LHCb::RichSmartID pdID ) const noexcept {
+      inline auto pdIndex( const LHCb::RichSmartID pdID ) const noexcept {
         return pdIndex( pdID, pdID.rich(), pdID.panel() );
       }
 
       /// Get the DePD object
-      inline decltype( auto ) dePD( const LHCb::RichSmartID pdID ) const { return m_pdInfo->dePD( pdID ); }
+      inline auto dePD( const LHCb::RichSmartID pdID ) const { return m_pdInfo->dePD( pdID ); }
 
     private:
       /// PDInfo
@@ -547,7 +552,7 @@ namespace Rich::Future::Rec {
 
     /// Threshold pixel background. Values below this will be reset to 0.
     Gaudi::Property<DetectorArray<FP>> m_thresPixBkg{
-        this, "ThresholdBackground", {0.001f, 0.001f}, "Threshold background values"};
+        this, "ThresholdBackground", {0.0f, 0.0f}, "Threshold background values"};
 
     /** Ignore the expected signal when computing the background terms.
         Effectively, will assume all observed hits are background */
-- 
GitLab


From e6a9993fa239fb5ce49ac0b2947884deef4695dc Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 7 Nov 2023 13:53:12 +0000
Subject: [PATCH 50/67] RichDetectorHits: Prefer [i] to at(i) when range
 checking is not required

---
 Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
index 2d0693b49bd..140a6223b7b 100644
--- a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
@@ -138,7 +138,7 @@ namespace Rich::Future::Rec::Moni {
                         std::clamp( h_pdXYOcc[rich]->xAxis().coordToIndex( lPos.X() ), 0, (int)nBins2D() - 1 );
                     const auto iY =
                         std::clamp( h_pdXYOcc[rich]->yAxis().coordToIndex( lPos.Y() ), 0, (int)nBins2D() - 1 );
-                    pdOccXY.at( iX ).at( iY ) = rawIDs.size();
+                    pdOccXY[iX][iY] = rawIDs.size();
                   }
 
                 } // PD has hits
-- 
GitLab


From 3d74787afa98404e035528b42da39288c3a879ba Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 7 Nov 2023 14:13:45 +0000
Subject: [PATCH 51/67] Add options for ideal state creator to QMT test

---
 .../tests/options/rich-dst-reco.py            | 33 ++++++++++++++++---
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py b/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py
index b1eec35f0f5..517706d5422 100644
--- a/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py
+++ b/Rich/RichFutureRecSys/tests/options/rich-dst-reco.py
@@ -15,9 +15,12 @@ from Gaudi.Configuration import *
 from GaudiConfig.ControlFlow import seq
 from GaudiKernel.SystemOfUnits import GeV
 from Configurables import LHCbApp, GaudiSequencer, DDDBConf
-from Configurables import FPEAuditor
+from Configurables import FPEAuditor, MCParticle2MCHitAlg
 from Configurables import UnpackMCParticle, UnpackMCVertex
 from Configurables import MCRichSegmentUnpacker, MCRichTrackUnpacker
+from Configurables import MCFTHitUnpacker, MCUTHitUnpacker, MCVPHitUnpacker
+from Configurables import MCRichDigitSummaryUnpacker, MCRichOpticalPhotonUnpacker
+from Configurables import MCRichHitUnpacker
 import os
 
 # --------------------------------------------------------------------------------------
@@ -186,7 +189,31 @@ else:
         'pSim/Rich/Segments', 'pSim/Rich/Tracks', 'pSim/MCVertices',
         'pSim/MCParticles'
     ]
-    preUnpackSeq.Members += [MCRichSegmentUnpacker(), MCRichTrackUnpacker()]
+    preUnpackSeq.Members += [
+        MCRichHitUnpacker(),
+        MCRichOpticalPhotonUnpacker(),
+        MCRichSegmentUnpacker(),
+        MCRichTrackUnpacker()
+    ]
+    # Needed for ideal state creator
+    unpVPHits = MCVPHitUnpacker()
+    unpFTHits = MCFTHitUnpacker()
+    unpUTHits = MCUTHitUnpacker()
+    linkVP = MCParticle2MCHitAlg(
+        "LinkVPMCHits",
+        MCHitPath=unpVPHits.OutputName,
+        OutputData="Link/MC/VP/Hits")
+    linkFF = MCParticle2MCHitAlg(
+        "LinkFTMCHits",
+        MCHitPath=unpFTHits.OutputName,
+        OutputData="Link/MC/FT/Hits")
+    linkUT = MCParticle2MCHitAlg(
+        "LinkUTMCHits",
+        MCHitPath=unpUTHits.OutputName,
+        OutputData="Link/MC/UT/Hits")
+    preUnpackSeq.Members += [
+        unpVPHits, unpFTHits, unpUTHits, linkVP, linkFF, linkUT
+    ]
     # Input tracks
     tkLocs = {"MC": "Rec/Track/FromRichMCTracks"}
     # Output PIDs
@@ -229,8 +256,6 @@ all.Members += [RichMoni]
 
 # --------------------------------------------------------------------------------------
 # Post reco Unpack sequence
-from Configurables import MCRichDigitSummaryUnpacker
-
 postUnpackSeq = GaudiSequencer("PostUnpackSeq", MeasureTime=True)
 all.Members += [postUnpackSeq]
 fetcher.DataKeys += ['pMC/Vertices', 'pMC/Particles']
-- 
GitLab


From e7a3e72827ee2220af28b480d5ebbfe5147fddcf Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 8 Nov 2023 11:59:51 +0000
Subject: [PATCH 52/67] RichDetectorHits: Present occupancies as percentage

---
 Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
index 140a6223b7b..6b3f230bbee 100644
--- a/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
+++ b/Rich/RichFutureRecMonitors/src/RichDetectorHits.cpp
@@ -138,7 +138,7 @@ namespace Rich::Future::Rec::Moni {
                         std::clamp( h_pdXYOcc[rich]->xAxis().coordToIndex( lPos.X() ), 0, (int)nBins2D() - 1 );
                     const auto iY =
                         std::clamp( h_pdXYOcc[rich]->yAxis().coordToIndex( lPos.Y() ), 0, (int)nBins2D() - 1 );
-                    pdOccXY[iX][iY] = rawIDs.size();
+                    pdOccXY[iX][iY] = ( 100.0 * rawIDs.size() ) / (double)LHCb::RichSmartID::MaPMT::TotalPixels;
                   }
 
                 } // PD has hits
@@ -272,17 +272,17 @@ namespace Rich::Future::Rec::Moni {
                                            "PD Average Occupancy (X,Y)",                     //
                                            -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
                                            -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
-                                           "Local X / mm", "Local Y / mm" ) );
+                                           "Local X / mm", "Local Y / mm", "Occupancy / %" ) );
         ok &= saveAndCheck( h_pdXOcc[rich],                                                  //
                             richProfile1D( HID( "pdOccXLoc", rich ),                         //
                                            "PD Average Occupancy (X)",                       //
                                            -panelXsizes[rich], panelXsizes[rich], nBins2D(), //
-                                           "Local X / mm" ) );
+                                           "Local X / mm", "Occupancy / %" ) );
         ok &= saveAndCheck( h_pdYOcc[rich],                                                  //
                             richProfile1D( HID( "pdOccYLoc", rich ),                         //
                                            "PD Average Occupancy (Y)",                       //
                                            -panelYsizes[rich], panelYsizes[rich], nBins2D(), //
-                                           "Local Y / mm" ) );
+                                           "Local Y / mm", "Occupancy / %" ) );
       }
 
       return StatusCode{ok};
-- 
GitLab


From 655ac8d860b77f7d663cb336033d6d1a7290a538 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Wed, 8 Nov 2023 13:33:13 +0000
Subject: [PATCH 53/67] Update RICH QMT test refs again following changes to
 clustering counters

---
 .../tests/refs/decode-2022-data.ref           | 33 +++++++++++++++++++
 .../tests/refs/decode-2023-data.ref           |  4 +++
 ...eco-from-detdesc-mc-dst-fake-mchits-4D.ref |  4 +++
 ...-detdesc-mc-dst-fake-mchits-4D.ref.detdesc |  4 +++
 ...t-fake-mchits-4D.ref.x86_64_v3-detdesc-opt |  4 +++
 ...sc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt |  4 +++
 .../reco-from-detdesc-mc-dst-fake-mchits.ref  |  4 +++
 ...rom-detdesc-mc-dst-fake-mchits.ref.detdesc |  4 +++
 ...-dst-fake-mchits.ref.x86_64_v3-detdesc-opt |  4 +++
 ...tdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt |  4 +++
 ...detdesc-mc-dst-fake-mctracks-mchits-4D.ref | 33 +++++++++++++++++++
 ...mc-dst-fake-mctracks-mchits-4D.ref.detdesc | 33 +++++++++++++++++++
 ...tracks-mchits-4D.ref.x86_64_v3-detdesc-opt | 33 +++++++++++++++++++
 ...-fake-mctracks-mchits-4D.ref.x86_64_v3-opt | 33 +++++++++++++++++++
 ...om-detdesc-mc-dst-fake-mctracks-mchits.ref | 33 +++++++++++++++++++
 ...sc-mc-dst-fake-mctracks-mchits.ref.detdesc | 33 +++++++++++++++++++
 ...-mctracks-mchits.ref.x86_64_v3-detdesc-opt | 33 +++++++++++++++++++
 ...dst-fake-mctracks-mchits.ref.x86_64_v3-opt | 33 +++++++++++++++++++
 ...reco-from-detdesc-mc-dst-fake-mctracks.ref | 33 +++++++++++++++++++
 ...m-detdesc-mc-dst-fake-mctracks.ref.detdesc | 33 +++++++++++++++++++
 ...st-fake-mctracks.ref.x86_64_v3-detdesc-opt | 33 +++++++++++++++++++
 ...esc-mc-dst-fake-mctracks.ref.x86_64_v3-opt | 33 +++++++++++++++++++
 .../reco-from-detdesc-mc-dst-pixmcpos.ref     |  4 +++
 ...o-from-detdesc-mc-dst-pixmcpos.ref.detdesc |  4 +++
 ...-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt |  4 +++
 ...-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt |  4 +++
 .../reco-from-detdesc-mc-dst-pixmctime-4D.ref |  4 +++
 ...om-detdesc-mc-dst-pixmctime-4D.ref.detdesc |  4 +++
 ...dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt |  4 +++
 ...desc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt |  4 +++
 .../tests/refs/reco-from-detdesc-mc-dst.ref   |  4 +++
 .../refs/reco-from-detdesc-mc-dst.ref.detdesc |  4 +++
 ...m-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt |  4 +++
 ...reco-from-detdesc-mc-dst.ref.x86_64_v3-opt |  4 +++
 34 files changed, 513 insertions(+)

diff --git a/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
index bf0caa58df5..9e43013f4d6 100644
--- a/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
+++ b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
@@ -34,6 +34,7 @@ ApplicationMgr       INFO Application Manager Terminated successfully
 RichClustering       INFO Number of counters : 1
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "No DePD object found for decoded channel ID"   |         4 |
+<<<<<<< HEAD
 RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
  | ID                        |   Title                                       |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
  | Rich1/bottom/pixXGlo      | "Rich1 bottom Global X hits"                  |  48590  |    -7.1318 | 237.48     |   0.070755 |     0.1685 |
@@ -56,3 +57,35 @@ RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
  | Rich2/nTotalPixsPerPD     | "Rich2 Average overall PD occupancy (nHits>0) |  48651  |     2.2419 | 1.8495     |     2.5593 |     10.805 |
  | Rich2/pixXLoc             | "Rich2 Local X hits"                          |  109070 |     1.5009 | 454.94     | -0.0062755 |    -1.4906 |
  | Rich2/pixYLoc             | "Rich2 Local Y hits"                          |  109070 |     11.101 | 309.99     |   0.020188 |   -0.47631 |
+=======
+RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 22
+ | ID                                            |   Title                                                                     |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
+ | Rich1/bottom/pixXGlo                          | "Rich1 bottom Global X hits"                                                |  48590  |    -7.1318 | 237.48     |   0.070755 |     0.1685 |
+ | Rich1/bottom/pixYGlo                          | "Rich1 bottom Global Y hits"                                                |  48590  |    -1361.6 | 67.406     |   -0.90512 |    0.40719 |
+ | Rich1/nActiveModules                          | "Rich1 # Active PD Modules (nHits>0)"                                       |   100   |      84.13 | 29.264     |   -0.58639 |    -0.6091 |
+ | Rich1/nActivePDs                              | "Rich1 # Active PDs (nHits>0)"                                              |   100   |     365.71 | 270.07     |    0.74883 |   -0.20499 |
+ | Rich1/nTotalPixs                              | "Rich1 Overall occupancy (nHits>0)"                                         |   100   |     971.85 | 998.75     |     1.4934 |       2.03 |
+ | Rich1/nTotalPixsPerPD                         | "Rich1 Average overall PD occupancy (nHits>0)"                              |  36571  |     2.6574 | 2.8133     |     2.9643 |     12.435 |
+ | Rich1/pixXLoc                                 | "Rich1 Local X hits"                                                        |  97185  | -0.0027776 | 236.43     |  -0.020509 |    0.14508 |
+ | Rich1/pixYLoc                                 | "Rich1 Local Y hits"                                                        |  97185  |    0.10756 | 258.98     |  0.0053737 |   -0.76547 |
+ | Rich1/top/pixXGlo                             | "Rich1 top Global X hits"                                                   |  48595  |     7.1255 | 235.16     |   -0.11368 |    0.20068 |
+ | Rich1/top/pixYGlo                             | "Rich1 top Global Y hits"                                                   |  48595  |     1361.7 | 68.186     |     0.8437 |    0.35607 |
+ | Rich2/ASide-left/pixXGlo                      | "Rich2 ASide-left Global X hits"                                            |  54761  |     3900.5 | 85.513     |   -0.10252 |   -0.97041 |
+ | Rich2/ASide-left/pixYGlo                      | "Rich2 ASide-left Global Y hits"                                            |  54761  |      10.02 | 306.8      |   0.021311 |   -0.41272 |
+ | Rich2/CSide-right/pixXGlo                     | "Rich2 CSide-right Global X hits"                                           |  54309  |    -3902.2 | 85.525     |    0.10848 |   -0.94471 |
+ | Rich2/CSide-right/pixYGlo                     | "Rich2 CSide-right Global Y hits"                                           |  54309  |     12.315 | 313.16     |   0.002616 |   -0.52723 |
+ | Rich2/nActiveModules                          | "Rich2 # Active PD Modules (nHits>0)"                                       |   100   |     118.55 | 34.643     |    -1.3935 |    0.85603 |
+ | Rich2/nActivePDs                              | "Rich2 # Active PDs (nHits>0)"                                              |   100   |     486.51 | 301.65     |   0.062544 |    -1.2409 |
+ | Rich2/nTotalPixs                              | "Rich2 Overall occupancy (nHits>0)"                                         |   100   |     1090.7 | 1016.8     |     1.5566 |     3.4929 |
+ | Rich2/nTotalPixsPerHTypePD                    | "Rich2 Average overall H-Type PD occupancy (nHits>0)"                       |  20333  |     2.4521 | 2.0899     |     2.6999 |     11.299 |
+ | Rich2/nTotalPixsPerPD                         | "Rich2 Average overall PD occupancy (nHits>0)"                              |  48651  |     2.2419 | 1.8495     |     2.7253 |     11.848 |
+ | Rich2/nTotalPixsPerRTypePD                    | "Rich2 Average overall R-Type PD occupancy (nHits>0)"                       |  28318  |      2.091 | 1.6389     |     2.5353 |     9.9284 |
+ | Rich2/pixXLoc                                 | "Rich2 Local X hits"                                                        |  109070 |     1.5009 | 454.94     | -0.0061976 |     -1.488 |
+ | Rich2/pixYLoc                                 | "Rich2 Local Y hits"                                                        |  109070 |     11.101 | 309.99     |   0.016165 |   -0.47687 |
+RichRecPixelQC    SUCCESS 1D profile histograms in directory "RICH/RichRecPixelQC" : 4
+ | ID                                            |   Title                                                                     |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
+ | Rich1/pdOccXLoc                               | "Rich1 PD Average Occupancy (X)"                                            |  250000 |          0 | 375.2      | -0.0041567 |    -2.5111 |
+ | Rich1/pdOccYLoc                               | "Rich1 PD Average Occupancy (Y)"                                            |  250000 |          0 | 392.52     |-0.00096035 |    -2.5819 |
+ | Rich2/pdOccXLoc                               | "Rich2 PD Average Occupancy (X)"                                            |  250000 |          0 | 461.79     |  -0.011424 |     -1.554 |
+ | Rich2/pdOccYLoc                               | "Rich2 PD Average Occupancy (Y)"                                            |  250000 |          0 | 432.93     |    0.06795 |    -2.1159 |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
diff --git a/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref b/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref
index bb891db59d7..56406062460 100644
--- a/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref
+++ b/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref
@@ -34,7 +34,11 @@ ApplicationMgr       INFO Application Manager Terminated successfully
 RichClustering       INFO Number of counters : 1
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "No DePD object found for decoded channel ID"   |         4 |
+<<<<<<< HEAD
 RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
+=======
+RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 22
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  | ID                                            |   Title                                                                     |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
  | Rich1/bottom/pixXGlo                          | "Rich1 bottom Global X hits"                                                |  97787  |    -14.261 | 231.76     |    -0.0133 |    0.19768 |
  | Rich1/bottom/pixYGlo                          | "Rich1 bottom Global Y hits"                                                |  97787  |    -1353.4 | 63.039     |   -0.91736 |    0.59504 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref
index 109398c3346..71e3c30914d 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref
@@ -182,7 +182,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc
index e946bef83c5..d50e117f1b9 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc
@@ -185,7 +185,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt
index 98b354d9a6e..0d989eedbe3 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt
@@ -185,7 +185,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        29 |         29 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt
index bd7f93372c3..eae15a7b5ac 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt
@@ -182,7 +182,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        28 |         28 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref
index 866ca8bdf53..3e742b8cc14 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref
@@ -172,7 +172,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc
index 4f8edb8206c..a672cf51570 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc
@@ -175,7 +175,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt
index 4b958be953b..46475baf825 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt
@@ -175,7 +175,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt
index aa240deb21b..dc1b6312f1f 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt
@@ -172,7 +172,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref
index c1571b843dd..2a3413a3cf5 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref
@@ -154,6 +154,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -169,6 +170,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4527 |( 10.88902 +- 0.1527739)% |
+ |*"Used RICH1 only"                               |     41574 |      18579 |( 44.68899 +- 0.2438345)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         5 |          5 |( 100.0000 +- 0.000000)% |
@@ -189,6 +197,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        71 |         70 |( 98.59155 +- 1.398497)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       227 |        206 |( 90.74890 +- 1.923112)% |
@@ -197,6 +206,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1268 |       1260 |( 99.36909 +- 0.2223573)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     21418 |      21353 |( 99.69652 +- 0.03758528)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       362 |        362 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |      17182 |( 42.42364 +- 0.2455801)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4524 |( 11.17009 +- 0.1565219)% |
+ |*"Used RICH1 only"                               |     40501 |      17659 |( 43.60139 +- 0.2464061)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       134 |        118 |( 88.05970 +- 2.801198)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        43 |         43 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |        118 |( 34.10405 +- 2.548557)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9627633 |     9627.6 |     9249.3 |      0.0000 |     65497.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc
index 1d0c5e20264..618f87a9786 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc
@@ -157,6 +157,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -172,6 +173,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
+ |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         7 |          7 |( 100.0000 +- 0.000000)% |
@@ -192,6 +200,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        77 |         73 |( 94.80519 +- 2.529038)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       238 |        222 |( 93.27731 +- 1.623196)% |
@@ -200,6 +209,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1349 |       1338 |( 99.18458 +- 0.2448536)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     22708 |      22659 |( 99.78422 +- 0.03079286)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       385 |        385 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |      15768 |( 38.93237 +- 0.2422859)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
+ |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        53 |         49 |( 92.45283 +- 3.628392)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       143 |        130 |( 90.90909 +- 2.404027)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        47 |         47 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |        103 |( 29.76879 +- 2.458146)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9639899 |     9639.9 |     9261.0 |      0.0000 |     65595.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt
index 89e1afa09fe..87ea66ff423 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt
@@ -157,6 +157,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -172,6 +173,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
+ |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         7 |          7 |( 100.0000 +- 0.000000)% |
@@ -192,6 +200,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        81 |         78 |( 96.29630 +- 2.098362)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       247 |        237 |( 95.95142 +- 1.254090)% |
@@ -200,6 +209,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1359 |       1348 |( 99.19058 +- 0.2430592)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     22678 |      22625 |( 99.76629 +- 0.03206455)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       384 |        382 |( 99.47917 +- 0.3673245)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |      15790 |( 38.98669 +- 0.2423470)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
+ |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        52 |         48 |( 92.30769 +- 3.695265)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       142 |        127 |( 89.43662 +- 2.579378)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        44 |         44 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |        108 |( 31.21387 +- 2.491072)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9639920 |     9639.9 |     9261.1 |      0.0000 |     65596.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt
index 33fca92c884..28c798f3e53 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt
@@ -154,6 +154,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -169,6 +170,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4529 |( 10.89383 +- 0.1528035)% |
+ |*"Used RICH1 only"                               |     41574 |      18577 |( 44.68418 +- 0.2438320)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         5 |          5 |( 100.0000 +- 0.000000)% |
@@ -189,6 +197,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        73 |         71 |( 97.26027 +- 1.910556)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       227 |        208 |( 91.62996 +- 1.838102)% |
@@ -197,6 +206,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1280 |       1268 |( 99.06250 +- 0.2693614)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     21479 |      21410 |( 99.67876 +- 0.03861107)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       356 |        354 |( 99.43820 +- 0.3961336)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |      17117 |( 42.26315 +- 0.2454565)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4526 |( 11.17503 +- 0.1565522)% |
+ |*"Used RICH1 only"                               |     40501 |      17657 |( 43.59645 +- 0.2464030)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        50 |         45 |( 90.00000 +- 4.242641)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       138 |        121 |( 87.68116 +- 2.797683)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        44 |         44 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |        114 |( 32.94798 +- 2.526866)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9627669 |     9627.7 |     9249.4 |      0.0000 |     65497.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref
index 470e424e9c8..4c3f2a2dfa3 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref
@@ -148,6 +148,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -163,6 +164,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4527 |( 10.88902 +- 0.1527739)% |
+ |*"Used RICH1 only"                               |     41574 |      18579 |( 44.68899 +- 0.2438345)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        16 |         13 |( 81.25000 +- 9.757809)% |
@@ -183,6 +191,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        96 |         86 |( 89.58333 +- 3.117758)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       318 |        265 |( 83.33333 +- 2.089874)% |
@@ -191,6 +200,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1928 |       1890 |( 98.02905 +- 0.3165645)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29067 |      28863 |( 99.29817 +- 0.04896497)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       567 |        558 |( 98.41270 +- 0.5248845)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       8184 |( 20.20691 +- 0.1995261)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4524 |( 11.17009 +- 0.1565219)% |
+ |*"Used RICH1 only"                               |     40501 |      17659 |( 43.60139 +- 0.2464061)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        65 |         59 |( 90.76923 +- 3.590307)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       182 |        152 |( 83.51648 +- 2.750270)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        59 |         58 |( 98.30508 +- 1.680490)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         39 |( 11.27168 +- 1.700150)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.281819e+07 |    12818.0 |    12698.0 |      0.0000 |     90894.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc
index 38f6371c7b2..642e773a9ca 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc
@@ -151,6 +151,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -166,6 +167,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
+ |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        21 |         19 |( 90.47619 +- 6.405645)% |
@@ -186,6 +194,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        98 |         87 |( 88.77551 +- 3.188723)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       333 |        286 |( 85.88589 +- 1.907944)% |
@@ -194,6 +203,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1976 |       1926 |( 97.46964 +- 0.3532911)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29552 |      29363 |( 99.36045 +- 0.04637146)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       588 |        578 |( 98.29932 +- 0.5332096)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       7575 |( 18.70324 +- 0.1937591)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
+ |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        66 |         56 |( 84.84848 +- 4.413449)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       185 |        157 |( 84.86486 +- 2.634943)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        62 |         61 |( 98.38710 +- 1.599843)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         32 |( 9.248555 +- 1.557491)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.283381e+07 |    12834.0 |    12713.0 |      0.0000 |     90999.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt
index ab805e4be6b..29a58ef0355 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt
@@ -151,6 +151,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -166,6 +167,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
+ |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        19 |         18 |( 94.73684 +- 5.122782)% |
@@ -186,6 +194,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        96 |         84 |( 87.50000 +- 3.375386)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       327 |        283 |( 86.54434 +- 1.887113)% |
@@ -194,6 +203,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1981 |       1934 |( 97.62746 +- 0.3419404)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29544 |      29361 |( 99.38058 +- 0.04564645)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       583 |        569 |( 97.59863 +- 0.6340410)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       7558 |( 18.66127 +- 0.1935916)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
+ |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        67 |         57 |( 85.07463 +- 4.353366)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       187 |        160 |( 85.56150 +- 2.570274)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        63 |         62 |( 98.41270 +- 1.574654)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         28 |( 8.092486 +- 1.466150)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.283386e+07 |    12834.0 |    12713.0 |      0.0000 |     90999.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt
index 4191c71d842..706c68815ff 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt
@@ -148,6 +148,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -163,6 +164,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4529 |( 10.89383 +- 0.1528035)% |
+ |*"Used RICH1 only"                               |     41574 |      18577 |( 44.68418 +- 0.2438320)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        14 |         13 |( 92.85714 +- 6.883029)% |
@@ -183,6 +191,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        93 |         83 |( 89.24731 +- 3.212289)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       317 |        269 |( 84.85804 +- 2.013297)% |
@@ -191,6 +200,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1945 |       1906 |( 97.99486 +- 0.3178442)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29053 |      28854 |( 99.31504 +- 0.04838860)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       565 |        555 |( 98.23009 +- 0.5547200)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       8159 |( 20.14518 +- 0.1992982)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4526 |( 11.17503 +- 0.1565522)% |
+ |*"Used RICH1 only"                               |     40501 |      17657 |( 43.59645 +- 0.2464030)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        66 |         58 |( 87.87879 +- 4.017382)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       183 |        155 |( 84.69945 +- 2.661143)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        59 |         59 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         37 |( 10.69364 +- 1.661368)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.281826e+07 |    12818.0 |    12698.0 |      0.0000 |     90894.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref
index ce5d005fec7..d2812892a9f 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref
@@ -145,6 +145,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -160,6 +161,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4527 |( 10.88902 +- 0.1527739)% |
+ |*"Used RICH1 only"                               |     41574 |      18579 |( 44.68899 +- 0.2438345)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        15 |         12 |( 80.00000 +- 10.32796)% |
@@ -180,6 +188,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        96 |         86 |( 89.58333 +- 3.117758)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       312 |        263 |( 84.29487 +- 2.059890)% |
@@ -188,6 +197,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1986 |       1935 |( 97.43202 +- 0.3549414)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29427 |      29196 |( 99.21501 +- 0.05144565)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       588 |        576 |( 97.95918 +- 0.5830904)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       7633 |( 18.84645 +- 0.1943281)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4524 |( 11.17009 +- 0.1565219)% |
+ |*"Used RICH1 only"                               |     40501 |      17659 |( 43.60139 +- 0.2464061)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        67 |         62 |( 92.53731 +- 3.210470)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       186 |        155 |( 83.33333 +- 2.732608)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        62 |         62 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         30 |( 8.670520 +- 1.512830)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.319374e+07 |    13194.0 |    12868.0 |      0.0000 |     91792.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc
index 6d8ace4f182..3d3555550da 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc
@@ -148,6 +148,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -163,6 +164,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
+ |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        18 |         16 |( 88.88889 +- 7.407407)% |
@@ -183,6 +191,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |       101 |         88 |( 87.12871 +- 3.332199)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       328 |        284 |( 86.58537 +- 1.881806)% |
@@ -191,6 +200,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      2029 |       1972 |( 97.19073 +- 0.3668325)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29806 |      29615 |( 99.35919 +- 0.04621862)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       608 |        592 |( 97.36842 +- 0.6491805)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       7110 |( 17.55512 +- 0.1890388)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
+ |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        67 |         62 |( 92.53731 +- 3.210470)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       191 |        166 |( 86.91099 +- 2.440473)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        63 |         63 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         24 |( 6.936416 +- 1.365902)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.321004e+07 |    13210.0 |    12883.0 |      0.0000 |     91892.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt
index 849cbbc3bbd..8251e1063b0 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt
@@ -148,6 +148,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -163,6 +164,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
+ |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        17 |         16 |( 94.11765 +- 5.706721)% |
@@ -183,6 +191,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        99 |         86 |( 86.86869 +- 3.394440)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       329 |        285 |( 86.62614 +- 1.876527)% |
@@ -191,6 +200,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      2032 |       1975 |( 97.19488 +- 0.3662987)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29797 |      29609 |( 99.36906 +- 0.04587034)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       600 |        586 |( 97.66667 +- 0.6162912)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       7134 |( 17.61438 +- 0.1892895)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
+ |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        68 |         63 |( 92.64706 +- 3.165133)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       187 |        161 |( 86.09626 +- 2.530097)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        64 |         64 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         26 |( 7.514451 +- 1.417253)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.321009e+07 |    13210.0 |    12883.0 |      0.0000 |     91892.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt
index 805c35f7bd9..95ac07419ec 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt
@@ -145,6 +145,7 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -160,6 +161,13 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
+=======
+ | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
+ |*"Used RICH1 and RICH2"                          |     41574 |       4529 |( 10.89383 +- 0.1528035)% |
+ |*"Used RICH1 only"                               |     41574 |      18577 |( 44.68418 +- 0.2438320)% |
+ |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
+RichPIDMonMC10to70               INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        15 |         13 |( 86.66667 +- 8.777075)% |
@@ -180,6 +188,7 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        95 |         83 |( 87.36842 +- 3.408351)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       325 |        276 |( 84.92308 +- 1.984849)% |
@@ -188,6 +197,30 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
+=======
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |      1989 |       1943 |( 97.68728 +- 0.3370258)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |     29422 |      29203 |( 99.25566 +- 0.05011036)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |       588 |        574 |( 97.61905 +- 0.6287152)% |
+ |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
+ |*"Reassigned Reco PID BT"                        |     40501 |       7634 |( 18.84892 +- 0.1943379)% |
+ |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
+ |*"Used RICH1 and RICH2"                          |     40501 |       4526 |( 11.17503 +- 0.1565522)% |
+ |*"Used RICH1 only"                               |     40501 |      17657 |( 43.59645 +- 0.2464030)% |
+ |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
+RichPIDMonMC70to100              INFO Number of counters : 10
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
+ |*"K->K,Pr,D ID Efficiency"                       |        68 |         62 |( 91.17647 +- 3.439601)% |
+ |*"Pi->El,Mu,Pi ID Efficiency"                    |       184 |        154 |( 83.69565 +- 2.723292)% |
+ |*"Pr DLL(Pr)>0 ID Efficiency"                    |        63 |         63 |( 100.0000 +- 0.000000)% |
+ |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
+ |*"Reassigned Reco PID BT"                        |       346 |         30 |( 8.670520 +- 1.512830)% |
+ |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
+ |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
+ |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
+ |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.319381e+07 |    13194.0 |    12868.0 |      0.0000 |     91792.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref
index f5481290093..7a57f23a5e6 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref
@@ -172,7 +172,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        52 |         50 |( 96.15385 +- 2.666828)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc
index 4cb28e72f70..c608663175b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc
@@ -175,7 +175,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        52 |         50 |( 96.15385 +- 2.666828)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt
index 5d5e497dd0b..f4a136c59db 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt
@@ -175,7 +175,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt
index 4aa9e5fea02..3296eee8b5b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt
@@ -172,7 +172,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        52 |         48 |( 92.30769 +- 3.695265)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref
index a49c96f5dc6..c4f6165addd 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref
@@ -182,7 +182,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc
index a72d60bb730..4daf7c5035b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc
@@ -185,7 +185,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt
index 30aabb7b7e0..0486ff2f6da 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt
@@ -185,7 +185,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        29 |         29 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt
index 261cfb27a0a..78296aa0d48 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt
@@ -182,7 +182,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        28 |         28 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref
index e8db4acf42d..8dcfaafd6a7 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref
@@ -169,7 +169,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc
index 64c57369060..b4e4fc07e1a 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc
@@ -172,7 +172,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt
index 3b1e063405d..3c7848e4fa2 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt
@@ -172,7 +172,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         47 |( 92.15686 +- 3.764642)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt
index 54b2ad578bc..241054bc9fa 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt
@@ -169,7 +169,11 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
+<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
+=======
+RichPIDMonDown10to70             INFO Number of counters : 10
+>>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
-- 
GitLab


From ec3b9285250b76eafa1f9ede14a0aa824bcb9916 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Thu, 9 Nov 2023 15:23:43 +0000
Subject: [PATCH 54/67] RichMCSIMDPhotonTime: Clean up time monitor, fix
 filling of some histos

---
 .../src/RichMCSIMDPhotonTime.cpp              | 181 ++++++++++--------
 1 file changed, 102 insertions(+), 79 deletions(-)

diff --git a/Rich/RichFutureRecCheckers/src/RichMCSIMDPhotonTime.cpp b/Rich/RichFutureRecCheckers/src/RichMCSIMDPhotonTime.cpp
index 9493e5b4b3a..e3a9230d8c1 100644
--- a/Rich/RichFutureRecCheckers/src/RichMCSIMDPhotonTime.cpp
+++ b/Rich/RichFutureRecCheckers/src/RichMCSIMDPhotonTime.cpp
@@ -111,19 +111,23 @@ namespace Rich::Future::Rec::MC::Moni {
     // histograms
     DetectorArray<AIDA::IHistogram1D*> h_hitTimeAll   = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_hitTimeTrue  = {{}};
+    DetectorArray<AIDA::IHistogram1D*> h_hitTimeFake  = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_timeResAll   = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_timeResTrue  = {{}};
+    DetectorArray<AIDA::IHistogram1D*> h_timeResFake  = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_tkOriginTime = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_tkOriginX    = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_tkOriginY    = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_tkOriginZ    = {{}};
     /////////////////////////////////////////////////////////////////////////////
-    DetectorArray<AIDA::IHistogram1D*> h_tkPVTime = {{}};
-    DetectorArray<AIDA::IHistogram1D*> h_tkPVZ    = {{}};
-    DetectorArray<AIDA::IHistogram1D*> h_tkPVt0   = {{}};
+    AIDA::IHistogram1D* h_tkPVTime       = nullptr;
+    AIDA::IHistogram1D* h_tkPVZ          = nullptr;
+    AIDA::IHistogram1D* h_tkPVt0         = nullptr;
+    AIDA::IHistogram2D* h_PVTime_PVZ_All = nullptr;
     /////////////////////////////////////////////////////////////////////////////
     DetectorArray<AIDA::IHistogram1D*> h_hitTime2All      = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_hitTime2True     = {{}};
+    DetectorArray<AIDA::IHistogram1D*> h_hitTime2Fake     = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_hitTime2_t0_All  = {{}};
     DetectorArray<AIDA::IHistogram1D*> h_hitTime2_t0_True = {{}};
     /////////////////////////////////////////////////////////////////////////////
@@ -132,8 +136,6 @@ namespace Rich::Future::Rec::MC::Moni {
     DetectorArray<AIDA::IHistogram2D*> h_hitTime2_timeRes_momentum_All  = {{}};
     DetectorArray<AIDA::IHistogram2D*> h_hitTime2_timeRes_momentum_True = {{}};
     /////////////////////////////////////////////////////////////////////////////
-    DetectorArray<AIDA::IHistogram2D*> h_PVTime_PVZ_All                = {{}};
-    DetectorArray<AIDA::IHistogram2D*> h_PVTime_PVZ_True               = {{}};
     DetectorArray<AIDA::IHistogram2D*> h_PVTime_CkAngle_All            = {{}};
     DetectorArray<AIDA::IHistogram2D*> h_PVTime_CkAngle_True           = {{}};
     DetectorArray<AIDA::IHistogram2D*> h_PVZ_CkAngle_All               = {{}};
@@ -155,22 +157,43 @@ StatusCode SIMDPhotonTime::prebookHistograms() {
   bool ok = true;
 
   // time limits
-  const DetectorArray<double> minTime{0.0, 40.0}, minTime_t0_corr{12.95, 52.5}, maxTime{25.0, 65.0},
-      maxTime_t0_corr{13.15, 53.5}, timeRes{50, 50};
+  const DetectorArray<double> minTime{0.0, 40.0}, minTime_t0_corr{12.95, 52.5}, maxTime{25.0, 65.0};
+  const DetectorArray<double> maxTime_t0_corr{13.15, 53.5}, timeRes{50, 50};
+
+  ok &= saveAndCheck( h_tkPVTime,                                       //
+                      richHisto1D( HID( "tkPVTime" ), "Track PV Times", //
+                                   -1.0, 1.0, nBins1D(), "Track PV Time / ns" ) );
+  ok &= saveAndCheck( h_tkPVZ,                                       //
+                      richHisto1D( HID( "tkPVZ" ), "Track PV Z pos", //
+                                   -200.0, 200.0, nBins1D(), "Track PV Z pos / mm" ) );
+  ok &= saveAndCheck( h_tkPVt0,                                    //
+                      richHisto1D( HID( "tkPVt0" ), "Track PV t0", //
+                                   -2.0, 2.0, nBins1D(), "Track PV t0 / ns" ) );
+  ok &= saveAndCheck( h_PVTime_PVZ_All,                                    //
+                      richHisto2D( HID( "PVTime_PVZ" ), "PV Time vs PV Z", //
+                                   -1.0, 1.0, nBins1D(), -200.0, 200.0, nBins1D(), "PV Time / ns", "PV Z / mm" ) );
 
   // Loop over RICHes
   for ( const auto rich : activeDetectors() ) {
-    ok &= saveAndCheck( h_hitTimeAll[rich],                                  //
-                        richHisto1D( HID( "hitTimeAll", rich ), "Hit Times", //
+    ok &= saveAndCheck( h_hitTimeAll[rich],                                           //
+                        richHisto1D( HID( "pixHitTimeAll", rich ), "Pixel Hit Times", //
                                      minTime[rich], maxTime[rich], nBins1D(), "Hit Time / ns" ) );
-    ok &= saveAndCheck( h_hitTimeTrue[rich],                                                //
-                        richHisto1D( HID( "hitTimeTrue", rich ), "Hit Times | True Signal", //
+    ok &= saveAndCheck( h_hitTimeTrue[rich],                                                         //
+                        richHisto1D( HID( "pixHitTimeTrue", rich ), "Pixel Hit Times | True Signal", //
                                      minTime[rich], maxTime[rich], nBins1D(), "Hit Time / ns" ) );
-    ok &= saveAndCheck( h_timeResAll[rich],                                                       //
-                        richHisto1D( HID( "timeResAll", rich ), "Hit-Prediction Time Resolution", //
+    ok &= saveAndCheck( h_hitTimeFake[rich],                                                         //
+                        richHisto1D( HID( "pixHitTimeFake", rich ), "Pixel Hit Times | Fake Signal", //
+                                     minTime[rich], maxTime[rich], nBins1D(), "Hit Time / ns" ) );
+    ok &= saveAndCheck( h_timeResAll[rich],                                                                  //
+                        richHisto1D( HID( "photTimeResAll", rich ), "Photon Hit-Prediction Time Resolution", //
+                                     -timeRes[rich], timeRes[rich], nBins1D(), "Hit time - prediction / ps" ) );
+    ok &= saveAndCheck( h_timeResTrue[rich],                                                //
+                        richHisto1D( HID( "photTimeResTrue", rich ),                        //
+                                     "Photon Hit-Prediction Time Resolution | True Signal", //
                                      -timeRes[rich], timeRes[rich], nBins1D(), "Hit time - prediction / ps" ) );
-    ok &= saveAndCheck( h_timeResTrue[rich],                                                                     //
-                        richHisto1D( HID( "timeResTrue", rich ), "Hit-Prediction Time Resolution | True Signal", //
+    ok &= saveAndCheck( h_timeResFake[rich],                                                //
+                        richHisto1D( HID( "photTimeResFake", rich ),                        //
+                                     "Photon Hit-Prediction Time Resolution | Fake Signal", //
                                      -timeRes[rich], timeRes[rich], nBins1D(), "Hit time - prediction / ps" ) );
     ok &= saveAndCheck( h_tkOriginTime[rich],                                           //
                         richHisto1D( HID( "tkOriginTime", rich ), "Track Origin Times", //
@@ -184,55 +207,44 @@ StatusCode SIMDPhotonTime::prebookHistograms() {
     ok &= saveAndCheck( h_tkOriginZ[rich],                                       //
                         richHisto1D( HID( "tkOriginZ", rich ), "Track Origin Z", //
                                      -200.0, 200.0, nBins1D(), "Track Origin Z / mm" ) );
-    ok &= saveAndCheck( h_tkPVTime[rich],                                       //
-                        richHisto1D( HID( "tkPVTime", rich ), "Track PV Times", //
-                                     -1.0, 1.0, nBins1D(), "Track PV Time / ns" ) );
-    ok &= saveAndCheck( h_tkPVZ[rich],                                       //
-                        richHisto1D( HID( "tkPVZ", rich ), "Track PV Z pos", //
-                                     -200.0, 200.0, nBins1D(), "Track PV Z pos / mm" ) );
-    ok &= saveAndCheck( h_tkPVt0[rich],                                    //
-                        richHisto1D( HID( "tkPVt0", rich ), "Track PV t0", //
-                                     -2.0, 2.0, nBins1D(), "Track PV t0 / ns" ) );
     //////////////////////////////////////////////////////////////////////////////////
-    ok &= saveAndCheck( h_hitTime2All[rich],                                  //
-                        richHisto1D( HID( "hitTime2All", rich ), "Hit Times", //
+    ok &= saveAndCheck( h_hitTime2All[rich],                                         //
+                        richHisto1D( HID( "photTimeAll", rich ), "Photon Hit Times", //
                                      minTime[rich], maxTime[rich], nBins1D(), "Hit Time / ns" ) );
-    ok &= saveAndCheck( h_hitTime2True[rich],                                                //
-                        richHisto1D( HID( "hitTime2True", rich ), "Hit Times | True Signal", //
+    ok &= saveAndCheck( h_hitTime2True[rich],                                                          //
+                        richHisto1D( HID( "photHitTimeTrue", rich ), "Photon Hit Times | True Signal", //
                                      minTime[rich], maxTime[rich], nBins1D(), "Hit Time / ns" ) );
-    ok &= saveAndCheck( h_hitTime2_t0_All[rich],                                       //
-                        richHisto1D( HID( "hitTime2_t0_All", rich ), "Hit Times - t0", //
+    ok &= saveAndCheck( h_hitTime2Fake[rich],                                                          //
+                        richHisto1D( HID( "photHitTimeFake", rich ), "Photon Hit Times | Fake Signal", //
+                                     minTime[rich], maxTime[rich], nBins1D(), "Hit Time / ns" ) );
+    ok &= saveAndCheck( h_hitTime2_t0_All[rich],                                                 //
+                        richHisto1D( HID( "photHitTime_t0_All", rich ), "Photon Hit Times - t0", //
                                      minTime_t0_corr[rich], maxTime_t0_corr[rich], nBins1D(), "Hit Time - t0 / ns" ) );
-    ok &= saveAndCheck( h_hitTime2_t0_True[rich],                                                     //
-                        richHisto1D( HID( "hitTime2_t0_True", rich ), "Hit Times - t0 | True Signal", //
+    ok &= saveAndCheck( h_hitTime2_t0_True[rich],                                                               //
+                        richHisto1D( HID( "photHitTime_t0_True", rich ), "Photon Hit Times - t0 | True Signal", //
                                      minTime_t0_corr[rich], maxTime_t0_corr[rich], nBins1D(), "Hit Time - t0 / ns" ) );
     //////////////////////////////////////////////////////////////////////////////////
-    ok &= saveAndCheck( h_hitTime2_PVt0_momentum_All[rich],                                                          //
-                        richHisto2D( HID( "hitTime2_PVt0_momentum_All", rich ), "Hit Times - t0 for PV vs momentum", //
+    ok &= saveAndCheck( h_hitTime2_PVt0_momentum_All[rich],                        //
+                        richHisto2D( HID( "photHitTime_PVt0_momentum_All", rich ), //
+                                     "Photon Hit Times - t0 for PV vs momentum",   //
                                      0, 120, nBins1D() * 2, minTime_t0_corr[rich], maxTime_t0_corr[rich], nBins1D() * 5,
-                                     "Momentum / GeV", "Hit Time - t0/ ns" ) );
-    ok &= saveAndCheck( h_hitTime2_PVt0_momentum_True[rich],                            //
-                        richHisto2D( HID( "hitTime2_PVt0_momentum_True", rich ),        //
-                                     "Hit Times - t0 for PV vs momentum | True Signal", //
+                                     "Momentum / GeV", "Hit Time - t0 / ns" ) );
+    ok &= saveAndCheck( h_hitTime2_PVt0_momentum_True[rich],                                   //
+                        richHisto2D( HID( "photHitTime_PVt0_momentum_True", rich ),            //
+                                     "Photon Hit Times - t0 for PV vs momentum | True Signal", //
                                      0, 120, nBins1D() * 2, minTime_t0_corr[rich], maxTime_t0_corr[rich], nBins1D() * 5,
-                                     "Momentum / GeV", "Hit Time - t0/ ns" ) );
+                                     "Momentum / GeV", "Hit Time - t0 / ns" ) );
     ok &= saveAndCheck( h_hitTime2_timeRes_momentum_All[rich], //
-                        richHisto2D( HID( "hitTime2_timeRes_momentum_All", rich ),
-                                     "Hit Times - prediction vs momentum", //
+                        richHisto2D( HID( "photHitTime_timeRes_momentum_All", rich ),
+                                     "Photon Hit Times - prediction vs momentum", //
                                      0, 100, nBins1D(), -500, 500, nBins1D() * 5, "Momentum / GeV",
                                      "Hit Time - prediction / ps" ) );
     ok &= saveAndCheck( h_hitTime2_timeRes_momentum_True[rich], //
-                        richHisto2D( HID( "hitTime2_timeRes_momentum_True", rich ),
-                                     "Hit Times - prediction vs momentum | True Signal", //
+                        richHisto2D( HID( "photHitTime_timeRes_momentum_True", rich ),
+                                     "Photon Hit Times - prediction vs momentum | True Signal", //
                                      0, 100, nBins1D(), -500, 500, nBins1D() * 5, "Momentum / GeV",
                                      "Hit Time - prediction / ps" ) );
     //////////////////////////////////////////////////////////////////////////////////
-    ok &= saveAndCheck( h_PVTime_PVZ_All[rich],                                    //
-                        richHisto2D( HID( "PVTime_PVZ", rich ), "PV Time vs PV Z", //
-                                     -1.0, 1.0, nBins1D(), -200.0, 200.0, nBins1D(), "PV Time / ns", "PV Z / mm" ) );
-    ok &= saveAndCheck( h_PVTime_PVZ_True[rich],                                                      //
-                        richHisto2D( HID( "PVTime_PVZ_True", rich ), "PV Time vs PV Z | True Signal", //
-                                     -1.0, 1.0, nBins1D(), -200.0, 200.0, nBins1D(), "PV Time / ns", "PV Z / mm" ) );
     ok &= saveAndCheck( h_PVTime_CkAngle_All[rich],                                        //
                         richHisto2D( HID( "PVTime_CkAngle", rich ), "PV Time vs Ck Angle", //
                                      -1.0, 1.0, nBins1D(), 0.0, 0.1, nBins1D(), "PV Time / ns", "Ck Angle / rad" ) );
@@ -253,14 +265,16 @@ StatusCode SIMDPhotonTime::prebookHistograms() {
                         richHisto2D( HID( "PVTime_Pred_noPV_True", rich ), "PV Time vs Pred Time | True Signal", //
                                      -1.0, 1.0, nBins1D(), minTime[rich], maxTime[rich], nBins1D(), "PV Time / ns",
                                      "Pred Time / ns" ) );
-    ok &= saveAndCheck( h_hitTime2_timeRes_CkAngle_All[rich],                                                     //
-                        richHisto2D( HID( "hitTime2_timeRes_CkAngle", rich ), "Hit Time - Pred Time vs Ck Angle", //
+    ok &= saveAndCheck( h_hitTime2_timeRes_CkAngle_All[rich],                    //
+                        richHisto2D( HID( "photHitTime_timeRes_CkAngle", rich ), //
+                                     "Photon Hit Time - Pred Time vs Ck Angle",  //
                                      0.0, 0.1, nBins1D(), -500, 500, nBins1D(), "Ck Angle / rad",
                                      "Hit Time - Pred Time / ps" ) );
-    ok &= saveAndCheck(
-        h_hitTime2_timeRes_CkAngle_True[rich],                                                                       //
-        richHisto2D( HID( "hitTime2_timeRes_CkAngle_True", rich ), "Hit Time - Pred Time vs Ck Angle | True Signal", //
-                     0.0, 0.1, nBins1D(), -500, 500, nBins1D(), "Ck Angle / rad", "Hit Time - Pred Time / ps" ) );
+    ok &= saveAndCheck( h_hitTime2_timeRes_CkAngle_True[rich],                                //
+                        richHisto2D( HID( "photHitTime_timeRes_CkAngle_True", rich ),         //
+                                     "Photon Hit Time - Pred Time vs Ck Angle | True Signal", //
+                                     0.0, 0.1, nBins1D(), -500, 500, nBins1D(),               //
+                                     "Ck Angle / rad", "Hit Time - Pred Time / ps" ) );
   }
 
   return StatusCode{ok};
@@ -293,17 +307,42 @@ void SIMDPhotonTime::operator()( const Summary::Track::Vector&
       for ( std::size_t i = 0; i < SIMDPixel::SIMDFP::Size; ++i ) {
         if ( !pix.validMask()[i] ) { continue; }
         fillHisto( h_hitTimeAll[rich], pix.hitTime()[i] );
-        if ( mcHelper.isCherenkovRadiation( pix.smartID()[i] ) ) { fillHisto( h_hitTimeTrue[rich], pix.hitTime()[i] ); }
+        const auto isTrue = mcHelper.isCherenkovRadiation( pix.smartID()[i] );
+        fillHisto( ( isTrue ? h_hitTimeTrue[rich] : h_hitTimeFake[rich] ), pix.hitTime()[i] );
       }
     }
   }
 
+  // Loop over all segments once
+  for ( const auto& seg : segments ) {
+    const auto rich = seg.rich();
+    if ( !richIsActive( rich ) ) { continue; }
+    // Track plots
+    fillHisto( h_tkOriginTime[rich], seg.originTime() );
+    fillHisto( h_tkOriginX[rich], seg.originVertex().X() );
+    fillHisto( h_tkOriginY[rich], seg.originVertex().Y() );
+    fillHisto( h_tkOriginZ[rich], seg.originVertex().Z() );
+  }
+
   // loop over the photon info
   for ( const auto&& [sumTk, tk] : Ranges::ConstZip( sumTracks, tracks ) ) {
 
     // Get the MCParticles for this track
     const auto mcPs = mcHelper.mcParticles( *tk, true, 0.5 );
 
+    // Fill plots per MCP
+    for ( const auto mcP : mcPs ) {
+      if ( mcP && !mcP->mother() && mcP->primaryVertex() ) {
+        const auto PVtime = mcP->primaryVertex()->time();
+        const auto PVZpos = mcP->primaryVertex()->position().z();
+        const auto PVt0   = PVtime - ( PVZpos / Gaudi::Units::c_light );
+        fillHisto( h_tkPVTime, PVtime );
+        fillHisto( h_tkPVZ, PVZpos );
+        fillHisto( h_tkPVt0, PVt0 );
+        fillHisto( h_PVTime_PVZ_All, PVtime, PVZpos );
+      }
+    }
+
     // loop over photons for this track
     for ( const auto photIn : sumTk.photonIndices() ) {
 
@@ -322,24 +361,6 @@ void SIMDPhotonTime::operator()( const Summary::Track::Vector&
       const auto rad  = seg.radiator();
       if ( !richIsActive( rich ) || !radiatorIsActive( rad ) ) { continue; }
 
-      // Track plots
-      fillHisto( h_tkOriginTime[rich], seg.originTime() );
-      fillHisto( h_tkOriginZ[rich], seg.originVertex().X() );
-      fillHisto( h_tkOriginZ[rich], seg.originVertex().Y() );
-      fillHisto( h_tkOriginZ[rich], seg.originVertex().Z() );
-
-      for ( const auto mcP : mcPs ) {
-        if ( mcP && !mcP->mother() && mcP->primaryVertex() ) {
-          const auto PVtime = mcP->primaryVertex()->time();
-          const auto PVZpos = mcP->primaryVertex()->position().z();
-          const auto PVt0   = PVtime - ( PVZpos / Gaudi::Units::c_light );
-          fillHisto( h_tkPVTime[rich], PVtime );
-          fillHisto( h_tkPVZ[rich], PVZpos );
-          fillHisto( h_tkPVt0[rich], PVt0 );
-          fillHisto( h_PVTime_PVZ_All[rich], PVtime, PVZpos );
-        }
-      }
-
       // Weight per MCP
       const auto mcPW = ( !mcPs.empty() ? 1.0 / (double)mcPs.size() : 1.0 );
 
@@ -369,8 +390,10 @@ void SIMDPhotonTime::operator()( const Summary::Track::Vector&
         // loop over MCPs
         for ( const auto mcP : mcPs ) {
 
-          const auto PVtime       = ( mcP && mcP->primaryVertex() ? mcP->primaryVertex()->time() : -999 );
-          const auto PVZpos       = ( mcP && mcP->primaryVertex() ? mcP->primaryVertex()->position().z() : -999 );
+          // get PV infor for this MCP
+          const auto mcPV         = ( mcP ? mcP->primaryVertex() : nullptr );
+          const auto PVtime       = ( mcPV ? mcPV->time() : -999 );
+          const auto PVZpos       = ( mcPV ? mcPV->position().z() : -999 );
           const auto PVt0         = PVtime - ( PVZpos / Gaudi::Units::c_light );
           const auto mcP_momentum = ( mcP ? mcP->momentum().E() / Gaudi::Units::GeV : -999 );
 
@@ -394,23 +417,23 @@ void SIMDPhotonTime::operator()( const Summary::Track::Vector&
           fillHisto( h_hitTime2_t0_All[rich], hitTime - PVt0, mcPW );
           fillHisto( h_hitTime2_PVt0_momentum_All[rich], mcP_momentum, ( hitTime - PVt0 ), mcPW );
           fillHisto( h_hitTime2_timeRes_momentum_All[rich], mcP_momentum, timeRes, mcPW );
-
           fillHisto( h_PVTime_CkAngle_All[rich], PVtime, thetaRec, mcPW );
           fillHisto( h_PVZ_CkAngle_All[rich], PVZpos, thetaRec, mcPW );
           fillHisto( h_PVTime_Pred_noPV_All[rich], PVtime, recoTime - PVtime, mcPW );
           fillHisto( h_hitTime2_timeRes_CkAngle_All[rich], thetaRec, timeRes, mcPW );
-
           if ( trueCKSig ) {
             fillHisto( h_timeResTrue[rich], timeRes, mcPW );
             fillHisto( h_hitTime2True[rich], hitTime, mcPW );
             fillHisto( h_hitTime2_t0_True[rich], hitTime - PVt0, mcPW );
             fillHisto( h_hitTime2_PVt0_momentum_True[rich], mcP_momentum, ( hitTime - PVt0 ), mcPW );
             fillHisto( h_hitTime2_timeRes_momentum_True[rich], mcP_momentum, timeRes, mcPW );
-
             fillHisto( h_PVTime_CkAngle_True[rich], PVtime, thetaRec, mcPW );
             fillHisto( h_PVZ_CkAngle_True[rich], PVZpos, thetaRec, mcPW );
             fillHisto( h_PVTime_Pred_noPV_True[rich], PVtime, recoTime - PVtime, mcPW );
             fillHisto( h_hitTime2_timeRes_CkAngle_True[rich], thetaRec, timeRes, mcPW );
+          } else {
+            fillHisto( h_timeResFake[rich], timeRes, mcPW );
+            fillHisto( h_hitTime2Fake[rich], hitTime, mcPW );
           }
 
         } // loop over associated MCPs
-- 
GitLab


From ffb13da244f12bd8c783131d33013855c5803cb5 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:26:49 +0000
Subject: [PATCH 55/67] RichSIMDPhotonPredictedPixelSignal: Clean up property
 name

---
 .../src/RichSIMDPhotonPredictedPixelSignal.cpp                  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp
index 14971934b35..2f32d8c00ee 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDPhotonPredictedPixelSignal.cpp
@@ -174,7 +174,7 @@ namespace Rich::Future::Rec {
 
     /// time window size for each RICH
     Gaudi::Property<DetectorArray<float>> m_timeWindow{
-        this, "TimeWindowSize", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}, "Time window to apply in each RICH"};
+        this, "TimeWindow", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}, "Time window to apply in each RICH"};
   };
 
 } // namespace Rich::Future::Rec
-- 
GitLab


From b4beee42d8b9b88ed651e348a8421606b3024cee Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:27:26 +0000
Subject: [PATCH 56/67] RichSIMDQuarticPhotonReco: Clean up property name

---
 .../src/RichSIMDQuarticPhotonReco.cpp          | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
index 82918a6b03f..060cad7f4be 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
@@ -108,10 +108,10 @@ namespace Rich::Future::Rec {
 
       // loop over RICHes
       for ( const auto rich : activeDetectors() ) {
-        m_timeWindowSIMD[rich] = SIMDFP( m_timeWindow[rich] );
+        m_photTimeWindowSIMD[rich] = SIMDFP( m_photTimeWindow[rich] );
         if ( m_enable4D[rich] ) {
-          info() << "4D photons enabled for " << rich << " | Window = " << ( 2.0 * m_timeWindow[rich] ) << " ns"
-                 << endmsg;
+          info() << "4D reconstruction enabled for " << rich << " | Window = " << ( 2.0 * m_photTimeWindow[rich] )
+                 << " ns" << endmsg;
         }
       }
       // loop over radiators
@@ -189,7 +189,7 @@ namespace Rich::Future::Rec {
     alignas( LHCb::SIMD::VectorAlignment ) RadiatorArray<SIMDFP> m_minSphMirrTolItSIMD = {{}};
 
     /// SIMD time windows
-    alignas( LHCb::SIMD::VectorAlignment ) DetectorArray<SIMDFP> m_timeWindowSIMD = {{}};
+    alignas( LHCb::SIMD::VectorAlignment ) DetectorArray<SIMDFP> m_photTimeWindowSIMD = {{}};
 
   private:
     // properties
@@ -197,9 +197,11 @@ namespace Rich::Future::Rec {
     /// Save optional mirror data
     Gaudi::Property<bool> m_saveMirrorData{this, "SaveMirrorData", false};
 
-    /// time window size for each RICH
-    Gaudi::Property<DetectorArray<float>> m_timeWindow{
-        this, "TimeWindowSize", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}, "Time window to apply in each RICH"};
+    /// photon time window size for each RICH
+    Gaudi::Property<DetectorArray<float>> m_photTimeWindow{this,
+                                                           "TimeWindow",
+                                                           {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns},
+                                                           "Photon Time window to apply in each RICH"};
 
     Gaudi::Property<DetectorArray<float>> m_pdTransitTime{
         this, "PDTransitTime", {0.04605 * Gaudi::Units::ns, 0.04605 * Gaudi::Units::ns}};
@@ -707,7 +709,7 @@ SIMDQuarticPhotonReco::operator()( const LHCb::RichTrackSegment::Vector&     seg
           auto hypoMask = !pixmask;
           for ( const auto hypo : activeParticlesNoBT() ) {
             const auto predT = photDetTime + SIMDFP( segment.timeToRadEntry( hypo ) );
-            hypoMask |= ( abs( pix.hitTime() - predT ) < m_timeWindowSIMD[rich] );
+            hypoMask |= ( abs( pix.hitTime() - predT ) < m_photTimeWindowSIMD[rich] );
             if ( all_of( hypoMask ) ) { break; }
           }
           pixmask &= hypoMask;
-- 
GitLab


From 70fdbe2a7b2f5997e8463738cb629ac706f57788 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:28:09 +0000
Subject: [PATCH 57/67] RichSIMDPixelBackgroundsEstiAvHPD: Add 4D time window
 size scale factor

---
 .../src/RichSIMDPixelBackgroundsEstiAvHPD.cpp | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
index 0de247c1ce1..1dec241fa5a 100644
--- a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
+++ b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
@@ -265,6 +265,15 @@ namespace Rich::Future::Rec {
                                 [parent = this]( const Detector::PDInfo& pdInfo ) {
                                   return PixBkgdsDataCache{pdInfo, parent};
                                 } );
+        for ( const auto rich : activeDetectors() ) {
+          if ( m_enable4D[rich] ) {
+            m_timeWindowFactor[rich] = std::clamp( 2.0f * m_photTimeWin[rich] / m_photTimeDenom[rich], 0.05f, 1.0f );
+            info() << "4D Photon Time Window Scale Factor for " << rich << " = " << m_timeWindowFactor[rich] << endmsg;
+          }
+          if ( m_bkgWeight[rich] != 1.0f ) {
+            info() << "Additional Scale Factor for " << rich << " = " << m_bkgWeight[rich] << endmsg;
+          }
+        }
         // debug info
         if ( m_ignoreExpSignal ) { _ri_debug << "Will ignore expected signals when computing backgrounds" << endmsg; }
         if ( m_ignoreHitData ) { _ri_debug << "Will ignore hit data when computing backgrounds" << endmsg; }
@@ -474,6 +483,8 @@ namespace Rich::Future::Rec {
               if ( pd.obsSignal > 0 ) {
                 // normalise background for this PD
                 pd.expBackgrd = ( pd.expBackgrd > 0.0 ? pd.expBackgrd / pd.effNumPixs : 0.0 );
+                // If 4D apply time window factor
+                if ( m_enable4D[rich] ) { pd.expBackgrd *= m_timeWindowFactor[rich]; }
                 // rescale by the overall weight factor for the RICH this PD is in
                 pd.expBackgrd *= m_bkgWeight[rich];
                 // Apply threshold
@@ -566,6 +577,25 @@ namespace Rich::Future::Rec {
     Gaudi::Property<DetectorArray<float>> m_bkgWeight{
         this, "PDBckWeights", {1.0f, 1.0f}, "Weights to apply to the background terms for each RICH"};
 
+    // 4D Reco options
+
+    /// Enabled 4D reconstruction
+    Gaudi::Property<DetectorArray<bool>> m_enable4D{this, "Enable4D", {false, false}};
+
+    /// Photon Time Window size (+-)
+    Gaudi::Property<DetectorArray<float>> m_photTimeWin{
+        this, "PhotonTimeWindow", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}};
+
+    /// Photon Time Window Denominator factor
+    Gaudi::Property<DetectorArray<float>> m_photTimeDenom{
+        this, "PhotonTimeWindowDenom", {1.0 * Gaudi::Units::ns, 1.0 * Gaudi::Units::ns}};
+
+  private:
+    // cached data
+
+    // 4D time window scale fctor
+    DetectorArray<float> m_timeWindowFactor{1.0f, 1.0f};
+
   private:
     // messaging
 
-- 
GitLab


From 0d4f24395c6213a73f01e1f0a766d2170ab7624e Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:28:39 +0000
Subject: [PATCH 58/67] RichSIMDSummaryPixels: Clean up property

---
 .../src/RichSIMDSummaryPixels.cpp                           | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp
index 49dcfb15473..367027b0206 100644
--- a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp
+++ b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDSummaryPixels.cpp
@@ -88,8 +88,10 @@ namespace Rich::Future::Rec {
         this, "AvHitTime", {13.03 * Gaudi::Units::ns, 52.94 * Gaudi::Units::ns}};
 
     /// Time window for each RICH
-    Gaudi::Property<DetectorArray<float>> m_timeWindow{
-        this, "TimeWindow", {3.0 * Gaudi::Units::ns, 3.0 * Gaudi::Units::ns}};
+    Gaudi::Property<DetectorArray<float>> m_timeWindow{this,
+                                                       "TimeWindow",
+                                                       {3.0 * Gaudi::Units::ns, 3.0 * Gaudi::Units::ns},
+                                                       "Pixel Time window to apply in each RICH"};
   };
 
 } // namespace Rich::Future::Rec
-- 
GitLab


From a2da58317023e8f0faf18812c0e416d4e572b441 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:29:58 +0000
Subject: [PATCH 59/67] ConfiguredRichReco.py: Clean up properties

---
 .../python/RichFutureRecSys/ConfiguredRichReco.py           | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
index 3bde87f47f6..e86a778efe8 100644
--- a/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
+++ b/Rich/RichFutureRecSys/python/RichFutureRecSys/ConfiguredRichReco.py
@@ -900,7 +900,7 @@ def RichRecoSequence(
         if photonReco == "Quartic" or photonReco == "FastQuartic":
             # enable 4D reco
             photReco.Enable4D = enable4DReco
-            photReco.TimeWindowSize = photonTimeWindow
+            photReco.TimeWindow = photonTimeWindow
         # Reconstruction algorithm tunings
         if photonReco == "Quartic":
             # Number of iterations for non-flat secondary mirrors
@@ -946,7 +946,7 @@ def RichRecoSequence(
             photPredSig.MinPhotonProbability = minPhotonProbability
         # 4D reco
         photPredSig.Enable4D = enable4DReco
-        photPredSig.TimeWindowSize = photonTimeWindow
+        photPredSig.TimeWindow = photonTimeWindow
 
         # The photon reco sequence
         phots = GaudiSequencer(
@@ -1037,6 +1037,8 @@ def RichRecoSequence(
             pixBkgs.MaxPixelBackground = PDBackMaxPixBackground[it]
             pixBkgs.PDBckWeights = PDBckWeights[it]
             pixBkgs.ThresholdBackground = PDBackThresholds[it]
+            pixBkgs.Enable4D = enable4DReco
+            pixBkgs.PhotonTimeWindow = photonTimeWindow
 
             # Likelihood minimiser
             like = makeRichAlg(LikelihoodMinimiser,
-- 
GitLab


From 4a853f9cc05f05995a451053cf4e8d619add06cf Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:32:15 +0000
Subject: [PATCH 60/67] RichFutureRecSys: Update examples

---
 Rich/RichFutureRecSys/examples/RichFuture.py   | 11 +++++------
 Rich/RichFutureRecSys/examples/jobs/RunJobs.py |  2 +-
 Rich/RichFutureRecSys/examples/jobs/submit.sh  |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index 146b11477ea..8a5d6030a17 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -58,7 +58,7 @@ rootFileBaseName = "RichFuture-" + myBuild + "-" + myConf + "-" + histos
 HistogramPersistencySvc().OutputFile = rootFileBaseName + "-Histos.root"
 
 # Event numbers
-nEvents = (10000 if not batchMode else 99999999)
+nEvents = (1000 if not batchMode else 99999999)
 EventSelector().PrintFreq = (100 if not batchMode else 250)
 #LHCbApp().SkipEvents      = 2
 
@@ -363,18 +363,17 @@ detYieldPrecision = "Average"
 tkCKResTreatment = "Parameterised"
 
 # Pixel background weights
-WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ("0.15" if enable4D[0] else "0.6")))
-WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ("0.15" if enable4D[0] else "0.6")))
-#WR1 = 0.6
-#WR2 = 0.6
+WR1 = float(os.getenv("PIXBCKWEIGHTRICH1", ("1.0" if enable4D[0] else "1.0")))
+WR2 = float(os.getenv("PIXBCKWEIGHTRICH2", ("1.0" if enable4D[0] else "1.0")))
 pdBckWeights = [(WR1, WR2), (WR1, WR2), (WR1, WR2), (WR1, WR2)]
 
 # Hit treatment in background alg
 # Need to try and understand the difference here between best 3D and 4D tunings
 PDBackIgnoreHitData = [is4D, False, False, False]
+#PDBackIgnoreHitData = [False, False, False, False]
 
 # background thresholds
-bT = 0.005
+bT = 0.0
 bkgThres = [(bT, bT), (bT, bT), (bT, bT), (bT, bT)]
 
 # CK resolutions
diff --git a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
index 7117c73138b..0d654bca92b 100755
--- a/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
+++ b/Rich/RichFutureRecSys/examples/jobs/RunJobs.py
@@ -25,7 +25,7 @@ parser.add_argument("-4d", "--enable4D", help="Enable 4D", action='store_true')
 parser.add_argument(
     "--pixwins",
     help="Pixel time window(s) (only for 4D)",
-    default="3.0",
+    default="1.0",
     type=str)
 parser.add_argument(
     "--photwins",
diff --git a/Rich/RichFutureRecSys/examples/jobs/submit.sh b/Rich/RichFutureRecSys/examples/jobs/submit.sh
index afbaaa9ddec..35f3225d554 100755
--- a/Rich/RichFutureRecSys/examples/jobs/submit.sh
+++ b/Rich/RichFutureRecSys/examples/jobs/submit.sh
@@ -54,7 +54,7 @@ mkdir -p ${JobDir}
 mkdir -p ${JobDir}"/jobs"
 OptsRoot="${HOME}/LHCbCMake/Feature/Rec/Rich/RichFutureRecSys/examples/"
 cp ${OptsRoot}"RichFuture.py" ${JobDir}/"jobs/opts.py"
-cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/30000000.py" ${JobDir}"/jobs/EvtType.py"
+cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/10000000.py" ${JobDir}"/jobs/EvtType.py"
 cp ${OptsRoot}"data/PMTs/UpgradeII/WithSpill/DIGI/files.py" ${JobDir}"/jobs/files.py"
 export RunOptions="${JobDir}/jobs/opts.py ${JobDir}/jobs/EvtType.py ${JobDir}/jobs/files.py"
 
-- 
GitLab


From 76230800d2e0c6bb6bb55f12af50b7d13441c7f5 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 11:32:47 +0000
Subject: [PATCH 61/67] GlobalReco: Update root scripts for PID plots

---
 Rec/GlobalReco/root/GlobalPID.C              |  7 ++
 Rec/GlobalReco/root/MakeRichPlots.C          | 17 +++--
 Rec/GlobalReco/root/RichKaonIDCompareFiles.C | 74 +++++++++++---------
 3 files changed, 58 insertions(+), 40 deletions(-)

diff --git a/Rec/GlobalReco/root/GlobalPID.C b/Rec/GlobalReco/root/GlobalPID.C
index ad9441b33b4..4cd8180de4c 100755
--- a/Rec/GlobalReco/root/GlobalPID.C
+++ b/Rec/GlobalReco/root/GlobalPID.C
@@ -22,6 +22,8 @@
 
 #include <sstream>
 
+#include <boost/filesystem.hpp>
+
 GlobalPID::PIDType GlobalPID::getMcType() const {
   if ( 0 == MCParticleType ) {
     return NoMCInfo;
@@ -765,6 +767,11 @@ void GlobalPID::saveImage( TCanvas* canvas, const std::string& filename ) {
     }
     fileMap[_name] = true;
     std::cout << "Printing image " << _name << std::endl;
+    // make parent path if needed
+    if ( _name.find( "/" ) != std::string::npos ) {
+      const auto dir = boost::filesystem::path( _name ).parent_path();
+      if ( !boost::filesystem::exists( dir ) ) { boost::filesystem::create_directories( dir ); }
+    }
     canvas->SaveAs( _name.c_str() );
   }
 }
diff --git a/Rec/GlobalReco/root/MakeRichPlots.C b/Rec/GlobalReco/root/MakeRichPlots.C
index edadb64cc1f..2c824906eca 100755
--- a/Rec/GlobalReco/root/MakeRichPlots.C
+++ b/Rec/GlobalReco/root/MakeRichPlots.C
@@ -14,6 +14,8 @@
 #include <sstream>
 #include <string>
 
+#include <boost/algorithm/string.hpp>
+
 #include "TCanvas.h"
 #include "TCut.h"
 #include "TFile.h"
@@ -25,16 +27,15 @@ void MakeRichPlots() {
 
   const std::string imageType = "pdf";
 
-  // const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Brunel/output/Upgrade/PhotonSelOpt";
-  const std::string dir = "/Users/chris/cernbox/LHCb/RICH/ParameterisedCKRes";
+  const std::string dir = "/usera/jonesc/LHCb/output/U2/InclB/WithSpill";
 
-  const std::string fName = "RichFuture-Feature-x86_64-centos7-gcc9-opt-Expert-ProtoTuple.root";
+  const std::string fName = "RichFuture-Feature-x86_64_v2-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
 
-  const std::vector<std::string> nametags = {
-      "FunctionalCKRes-PIDPerf-OnlinePhotonSel", "PtotParameterisedCKRes-PIDPerf-OnlinePhotonSel",
-      "FunctionalCKRes-PIDPerf-NominalPhotonSel", "PtotParameterisedCKRes-PIDPerf-NominalPhotonSel"};
+  const std::vector<std::string> nametags = {"FromMCHits/3D/lumi-2.0e33", "FromMCHits/3D/lumi-1.2e34",
+                                             "FromMCHits/4D/lumi-2.0e33/PixWin-3.000/PhotWin-0.100",
+                                             "FromMCHits/4D/lumi-1.2e34/PixWin-3.000/PhotWin-0.100"};
 
-  for ( const auto& nametag : nametags ) {
+  for ( auto nametag : nametags ) {
 
     // load the file and TTree
     auto f = TFile::Open( ( dir + "/" + nametag + "/" + fName ).c_str() );
@@ -58,6 +59,8 @@ void MakeRichPlots() {
     TCut kAboveThres  = "RichAboveKaThres";
     TCut piAboveThres = "RichAbovePiThres";
 
+    boost::replace_all( nametag, "/", "-" );
+
     auto c = std::make_unique<TCanvas>( nametag.c_str(), nametag.c_str(), 1400, 1000 );
 
     const std::vector<double> cuts = {-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10};
diff --git a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
index 5d023fca053..c13ba7cbb0d 100755
--- a/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
+++ b/Rec/GlobalReco/root/RichKaonIDCompareFiles.C
@@ -19,48 +19,56 @@
 
 void RichKaonIDCompareFiles() {
 
-  // const std::string dir = "/usera/jonesc/LHCb/output/U2/InclB/WithSpill";
-  const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Rec/output/test";
+  const std::string dir = "/usera/jonesc/LHCb/output/U2/InclB/WithSpill";
+  // const std::string dir = "/usera/jonesc/LHCbCMake/Feature/Rec/output/test";
 
-  // const std::string fName = "RichFuture-Feature-x86_64_v2-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
-  const std::string fName = "RichFuture-Feature-x86_64_v3-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
+  const std::string fName = "RichFuture-Feature-x86_64_v2-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
+  // const std::string fName = "RichFuture-Feature-x86_64_v3-centos7-gcc12+detdesc-opt-Expert-ProtoTuple.root";
 
   std::map<std::string, std::vector<std::string>> dataSets;
 
-  dataSets["Run3Tracking-3D"].push_back( "NominalDSTs" );
-  dataSets["Run3Tracking-3D"].push_back( "NominalDSTs-MCFilteredTks" );
+  // dataSets["Run3Tracking-3D"].push_back( "DSTs-MCTracks" );
+  // dataSets["Run3Tracking-3D"].push_back( "DSTs-RecoTracks" );
 
-  // const std::string bName = "FromMCHits";
-  // for ( const std::string lumi : {"2.0e32", "2.0e33", "3.0e33", "1.0e34", "1.2e34", "1.5e34"} ) {
-  //   // 3D
+  // const std::string bName = "FromMCHits-V2";
+  // for ( const std::string lumi : {"1.5e34", "1.2e34", "1.0e34", "3.0e33", "2.0e33", "2.0e32"} ) {
   //   dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi );
-  //   // 4D
   //   for ( const std::string pixWin : {"3.000"} ) {
   //     for ( const std::string photWin : {"1.000", "0.500", "0.250", "0.100", "0.050", "0.010"} ) {
   //       const auto n = bName + "/4D/lumi-" + lumi + "/PixWin-" + pixWin + "/PhotWin-" + photWin;
-  //       dataSets[bName + "-4D-PhotWin_" + photWin].push_back( n );
-  //       dataSets[bName + "-4D-Lumi_" + lumi].push_back( n );
+  //       dataSets[bName + "-4D-PixW_" + pixWin + "-PhoW_" + photWin].push_back( n );
+  //       dataSets[bName + "-4D-PixW_" + pixWin + "-Lumi_" + lumi].push_back( n );
   //     }
   //   }
   // }
 
-  // const std::string lumi = "1.2e34";
-  // {
-  //   const std::string bName = "Rich1BckTune";
-  //   for ( const std::string w : {"0.500", "0.400", "0.300", "0.200", "0.100", "0.050"} ) {
-  //     dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi + "/R1PixBckW-" + w );
-  //     dataSets[bName + "-4D"].push_back( bName + "/4D/lumi-" + lumi + "/R1PixBckW-" + w +
-  //                                        "/PixWin-3.000/PhotWin-0.100" );
-  //   }
-  // }
-  // {
-  //   const std::string bName = "Rich2BckTune";
-  //   for ( const std::string w : {"0.500", "0.400", "0.300", "0.200", "0.100", "0.050"} ) {
-  //     dataSets[bName + "-3D"].push_back( bName + "/3D/lumi-" + lumi + "/R2PixBckW-" + w );
-  //     dataSets[bName + "-4D"].push_back( bName + "/4D/lumi-" + lumi + "/R2PixBckW-" + w +
-  //                                        "/PixWin-3.000/PhotWin-0.100" );
-  //   }
-  // }
+  for ( const std::string lumi : {"1.2e34", "2.0e33", "2.0e32"} ) {
+    const std::string bName = "BkgTuneRich1";
+    for ( const std::string w : {"0.600", "0.800", "1.000", "1.200", "1.400"} ) {
+      dataSets["3D/lumi-" + lumi + "/" + bName].push_back( bName + "/3D/lumi-" + lumi + "/R1PixBckW-" + w );
+      for ( const std::string pixWin : {"1.000"} ) {
+        for ( const std::string photWin : {"0.250", "0.100", "0.050"} ) {
+          const auto name = "4D/lumi-" + lumi + "/PixWin-" + pixWin + "/" + bName + "_PhotWin-" + photWin;
+          dataSets[name].push_back( bName + "/4D/lumi-" + lumi + "/R1PixBckW-" + w + "/PixWin-" + pixWin + "/PhotWin-" +
+                                    photWin );
+        }
+      }
+    }
+  }
+
+  for ( const std::string lumi : {"1.2e34", "2.0e33", "2.0e32"} ) {
+    const std::string bName = "BkgTuneRich2";
+    for ( const std::string w : {"0.600", "0.800", "1.000", "1.200", "1.400"} ) {
+      dataSets["3D/lumi-" + lumi + "/" + bName].push_back( bName + "/3D/lumi-" + lumi + "/R2PixBckW-" + w );
+      for ( const std::string pixWin : {"1.000"} ) {
+        for ( const std::string photWin : {"0.250", "0.100", "0.050"} ) {
+          const auto name = "4D/lumi-" + lumi + "/PixWin-" + pixWin + "/" + bName + "_PhotWin-" + photWin;
+          dataSets[name].push_back( bName + "/4D/lumi-" + lumi + "/R2PixBckW-" + w + "/PixWin-" + pixWin + "/PhotWin-" +
+                                    photWin );
+        }
+      }
+    }
+  }
 
   const Long64_t nTracks = 1e6;
 
@@ -108,9 +116,9 @@ void RichKaonIDCompareFiles() {
       }
 
       // Stepping options
-      gConf.minCut      = -50;
-      gConf.maxCut      = 30;
-      gConf.nSteps      = 70;
+      gConf.minCut      = -100;
+      gConf.maxCut      = 40;
+      gConf.nSteps      = 100;
       gConf.minMisIDeff = gConf.minGraphY;
 
       // Momentum range
@@ -153,7 +161,7 @@ void RichKaonIDCompareFiles() {
       const std::array<Color_t, 11> colors{kYellow - 1, kRed + 1,  kGreen + 2, kBlue + 1,  kMagenta + 2, kBlack,
                                            kRed - 6,    kBlue - 1, kCyan + 2,  kGreen - 5, kGray + 2};
 
-      auto lastColor = colors.end();
+      auto lastColor = colors.begin();
 
       auto genTuple = [&]( const auto& tag ) {
         if ( colors.end() == lastColor ) { lastColor = colors.begin(); }
-- 
GitLab


From 468fb78bc012053a4ffa01809570426defa04924 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 13:05:48 +0000
Subject: [PATCH 62/67] revert message change to RichSIMDQuarticPhotonReco

---
 .../src/RichSIMDQuarticPhotonReco.cpp                           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
index 060cad7f4be..72694761e0a 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
@@ -110,7 +110,7 @@ namespace Rich::Future::Rec {
       for ( const auto rich : activeDetectors() ) {
         m_photTimeWindowSIMD[rich] = SIMDFP( m_photTimeWindow[rich] );
         if ( m_enable4D[rich] ) {
-          info() << "4D reconstruction enabled for " << rich << " | Window = " << ( 2.0 * m_photTimeWindow[rich] )
+          info() << "4D photons enabled for " << rich << " | Window = " << ( 2.0 * m_photTimeWindow[rich] )
                  << " ns" << endmsg;
         }
       }
-- 
GitLab


From a0cf9cbecd5f217023a4ee3bb67799b6ff4a43bf Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Mon, 13 Nov 2023 13:20:46 +0000
Subject: [PATCH 63/67] Update RICH QM refs for 4D

---
 .../tests/refs/decode-2022-data.ref           | 33 -------------------
 .../tests/refs/decode-2023-data.ref           |  4 ---
 ...eco-from-detdesc-mc-dst-fake-mchits-4D.ref |  4 ---
 ...-detdesc-mc-dst-fake-mchits-4D.ref.detdesc |  4 ---
 ...t-fake-mchits-4D.ref.x86_64_v3-detdesc-opt |  4 ---
 ...sc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt |  4 ---
 .../reco-from-detdesc-mc-dst-fake-mchits.ref  |  4 ---
 ...rom-detdesc-mc-dst-fake-mchits.ref.detdesc |  4 ---
 ...-dst-fake-mchits.ref.x86_64_v3-detdesc-opt |  4 ---
 ...tdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt |  4 ---
 ...detdesc-mc-dst-fake-mctracks-mchits-4D.ref | 33 -------------------
 ...mc-dst-fake-mctracks-mchits-4D.ref.detdesc | 33 -------------------
 ...tracks-mchits-4D.ref.x86_64_v3-detdesc-opt | 33 -------------------
 ...-fake-mctracks-mchits-4D.ref.x86_64_v3-opt | 33 -------------------
 ...om-detdesc-mc-dst-fake-mctracks-mchits.ref | 33 -------------------
 ...sc-mc-dst-fake-mctracks-mchits.ref.detdesc | 33 -------------------
 ...-mctracks-mchits.ref.x86_64_v3-detdesc-opt | 33 -------------------
 ...dst-fake-mctracks-mchits.ref.x86_64_v3-opt | 33 -------------------
 ...reco-from-detdesc-mc-dst-fake-mctracks.ref | 33 -------------------
 ...m-detdesc-mc-dst-fake-mctracks.ref.detdesc | 33 -------------------
 ...st-fake-mctracks.ref.x86_64_v3-detdesc-opt | 33 -------------------
 ...esc-mc-dst-fake-mctracks.ref.x86_64_v3-opt | 33 -------------------
 .../reco-from-detdesc-mc-dst-pixmcpos.ref     |  4 ---
 ...o-from-detdesc-mc-dst-pixmcpos.ref.detdesc |  4 ---
 ...-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt |  4 ---
 ...-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt |  4 ---
 .../reco-from-detdesc-mc-dst-pixmctime-4D.ref |  4 ---
 ...om-detdesc-mc-dst-pixmctime-4D.ref.detdesc |  4 ---
 ...dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt |  4 ---
 ...desc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt |  4 ---
 .../tests/refs/reco-from-detdesc-mc-dst.ref   |  4 ---
 .../refs/reco-from-detdesc-mc-dst.ref.detdesc |  4 ---
 ...m-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt |  4 ---
 ...reco-from-detdesc-mc-dst.ref.x86_64_v3-opt |  4 ---
 34 files changed, 513 deletions(-)

diff --git a/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
index 9e43013f4d6..bf0caa58df5 100644
--- a/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
+++ b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
@@ -34,7 +34,6 @@ ApplicationMgr       INFO Application Manager Terminated successfully
 RichClustering       INFO Number of counters : 1
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "No DePD object found for decoded channel ID"   |         4 |
-<<<<<<< HEAD
 RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
  | ID                        |   Title                                       |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
  | Rich1/bottom/pixXGlo      | "Rich1 bottom Global X hits"                  |  48590  |    -7.1318 | 237.48     |   0.070755 |     0.1685 |
@@ -57,35 +56,3 @@ RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
  | Rich2/nTotalPixsPerPD     | "Rich2 Average overall PD occupancy (nHits>0) |  48651  |     2.2419 | 1.8495     |     2.5593 |     10.805 |
  | Rich2/pixXLoc             | "Rich2 Local X hits"                          |  109070 |     1.5009 | 454.94     | -0.0062755 |    -1.4906 |
  | Rich2/pixYLoc             | "Rich2 Local Y hits"                          |  109070 |     11.101 | 309.99     |   0.020188 |   -0.47631 |
-=======
-RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 22
- | ID                                            |   Title                                                                     |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
- | Rich1/bottom/pixXGlo                          | "Rich1 bottom Global X hits"                                                |  48590  |    -7.1318 | 237.48     |   0.070755 |     0.1685 |
- | Rich1/bottom/pixYGlo                          | "Rich1 bottom Global Y hits"                                                |  48590  |    -1361.6 | 67.406     |   -0.90512 |    0.40719 |
- | Rich1/nActiveModules                          | "Rich1 # Active PD Modules (nHits>0)"                                       |   100   |      84.13 | 29.264     |   -0.58639 |    -0.6091 |
- | Rich1/nActivePDs                              | "Rich1 # Active PDs (nHits>0)"                                              |   100   |     365.71 | 270.07     |    0.74883 |   -0.20499 |
- | Rich1/nTotalPixs                              | "Rich1 Overall occupancy (nHits>0)"                                         |   100   |     971.85 | 998.75     |     1.4934 |       2.03 |
- | Rich1/nTotalPixsPerPD                         | "Rich1 Average overall PD occupancy (nHits>0)"                              |  36571  |     2.6574 | 2.8133     |     2.9643 |     12.435 |
- | Rich1/pixXLoc                                 | "Rich1 Local X hits"                                                        |  97185  | -0.0027776 | 236.43     |  -0.020509 |    0.14508 |
- | Rich1/pixYLoc                                 | "Rich1 Local Y hits"                                                        |  97185  |    0.10756 | 258.98     |  0.0053737 |   -0.76547 |
- | Rich1/top/pixXGlo                             | "Rich1 top Global X hits"                                                   |  48595  |     7.1255 | 235.16     |   -0.11368 |    0.20068 |
- | Rich1/top/pixYGlo                             | "Rich1 top Global Y hits"                                                   |  48595  |     1361.7 | 68.186     |     0.8437 |    0.35607 |
- | Rich2/ASide-left/pixXGlo                      | "Rich2 ASide-left Global X hits"                                            |  54761  |     3900.5 | 85.513     |   -0.10252 |   -0.97041 |
- | Rich2/ASide-left/pixYGlo                      | "Rich2 ASide-left Global Y hits"                                            |  54761  |      10.02 | 306.8      |   0.021311 |   -0.41272 |
- | Rich2/CSide-right/pixXGlo                     | "Rich2 CSide-right Global X hits"                                           |  54309  |    -3902.2 | 85.525     |    0.10848 |   -0.94471 |
- | Rich2/CSide-right/pixYGlo                     | "Rich2 CSide-right Global Y hits"                                           |  54309  |     12.315 | 313.16     |   0.002616 |   -0.52723 |
- | Rich2/nActiveModules                          | "Rich2 # Active PD Modules (nHits>0)"                                       |   100   |     118.55 | 34.643     |    -1.3935 |    0.85603 |
- | Rich2/nActivePDs                              | "Rich2 # Active PDs (nHits>0)"                                              |   100   |     486.51 | 301.65     |   0.062544 |    -1.2409 |
- | Rich2/nTotalPixs                              | "Rich2 Overall occupancy (nHits>0)"                                         |   100   |     1090.7 | 1016.8     |     1.5566 |     3.4929 |
- | Rich2/nTotalPixsPerHTypePD                    | "Rich2 Average overall H-Type PD occupancy (nHits>0)"                       |  20333  |     2.4521 | 2.0899     |     2.6999 |     11.299 |
- | Rich2/nTotalPixsPerPD                         | "Rich2 Average overall PD occupancy (nHits>0)"                              |  48651  |     2.2419 | 1.8495     |     2.7253 |     11.848 |
- | Rich2/nTotalPixsPerRTypePD                    | "Rich2 Average overall R-Type PD occupancy (nHits>0)"                       |  28318  |      2.091 | 1.6389     |     2.5353 |     9.9284 |
- | Rich2/pixXLoc                                 | "Rich2 Local X hits"                                                        |  109070 |     1.5009 | 454.94     | -0.0061976 |     -1.488 |
- | Rich2/pixYLoc                                 | "Rich2 Local Y hits"                                                        |  109070 |     11.101 | 309.99     |   0.016165 |   -0.47687 |
-RichRecPixelQC    SUCCESS 1D profile histograms in directory "RICH/RichRecPixelQC" : 4
- | ID                                            |   Title                                                                     |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
- | Rich1/pdOccXLoc                               | "Rich1 PD Average Occupancy (X)"                                            |  250000 |          0 | 375.2      | -0.0041567 |    -2.5111 |
- | Rich1/pdOccYLoc                               | "Rich1 PD Average Occupancy (Y)"                                            |  250000 |          0 | 392.52     |-0.00096035 |    -2.5819 |
- | Rich2/pdOccXLoc                               | "Rich2 PD Average Occupancy (X)"                                            |  250000 |          0 | 461.79     |  -0.011424 |     -1.554 |
- | Rich2/pdOccYLoc                               | "Rich2 PD Average Occupancy (Y)"                                            |  250000 |          0 | 432.93     |    0.06795 |    -2.1159 |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
diff --git a/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref b/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref
index 56406062460..bb891db59d7 100644
--- a/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref
+++ b/Rich/RichFutureRecSys/tests/refs/decode-2023-data.ref
@@ -34,11 +34,7 @@ ApplicationMgr       INFO Application Manager Terminated successfully
 RichClustering       INFO Number of counters : 1
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "No DePD object found for decoded channel ID"   |         4 |
-<<<<<<< HEAD
 RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
-=======
-RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 22
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  | ID                                            |   Title                                                                     |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
  | Rich1/bottom/pixXGlo                          | "Rich1 bottom Global X hits"                                                |  97787  |    -14.261 | 231.76     |    -0.0133 |    0.19768 |
  | Rich1/bottom/pixYGlo                          | "Rich1 bottom Global Y hits"                                                |  97787  |    -1353.4 | 63.039     |   -0.91736 |    0.59504 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref
index 71e3c30914d..109398c3346 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref
@@ -182,11 +182,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc
index d50e117f1b9..e946bef83c5 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.detdesc
@@ -185,11 +185,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt
index 0d989eedbe3..98b354d9a6e 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-detdesc-opt
@@ -185,11 +185,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        29 |         29 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt
index eae15a7b5ac..bd7f93372c3 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits-4D.ref.x86_64_v3-opt
@@ -182,11 +182,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        28 |         28 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref
index 3e742b8cc14..866ca8bdf53 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref
@@ -172,11 +172,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc
index a672cf51570..4f8edb8206c 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.detdesc
@@ -175,11 +175,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt
index 46475baf825..4b958be953b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-detdesc-opt
@@ -175,11 +175,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt
index dc1b6312f1f..aa240deb21b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mchits.ref.x86_64_v3-opt
@@ -172,11 +172,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         49 |( 96.07843 +- 2.718052)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref
index 2a3413a3cf5..c1571b843dd 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref
@@ -154,7 +154,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -170,13 +169,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4527 |( 10.88902 +- 0.1527739)% |
- |*"Used RICH1 only"                               |     41574 |      18579 |( 44.68899 +- 0.2438345)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         5 |          5 |( 100.0000 +- 0.000000)% |
@@ -197,7 +189,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        71 |         70 |( 98.59155 +- 1.398497)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       227 |        206 |( 90.74890 +- 1.923112)% |
@@ -206,30 +197,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1268 |       1260 |( 99.36909 +- 0.2223573)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     21418 |      21353 |( 99.69652 +- 0.03758528)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       362 |        362 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
- |*"Reassigned Reco PID BT"                        |     40501 |      17182 |( 42.42364 +- 0.2455801)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4524 |( 11.17009 +- 0.1565219)% |
- |*"Used RICH1 only"                               |     40501 |      17659 |( 43.60139 +- 0.2464061)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       134 |        118 |( 88.05970 +- 2.801198)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        43 |         43 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |        118 |( 34.10405 +- 2.548557)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9627633 |     9627.6 |     9249.3 |      0.0000 |     65497.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc
index 618f87a9786..1d0c5e20264 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.detdesc
@@ -157,7 +157,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -173,13 +172,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
- |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         7 |          7 |( 100.0000 +- 0.000000)% |
@@ -200,7 +192,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        77 |         73 |( 94.80519 +- 2.529038)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       238 |        222 |( 93.27731 +- 1.623196)% |
@@ -209,30 +200,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1349 |       1338 |( 99.18458 +- 0.2448536)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     22708 |      22659 |( 99.78422 +- 0.03079286)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       385 |        385 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
- |*"Reassigned Reco PID BT"                        |     40501 |      15768 |( 38.93237 +- 0.2422859)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
- |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        53 |         49 |( 92.45283 +- 3.628392)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       143 |        130 |( 90.90909 +- 2.404027)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        47 |         47 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |        103 |( 29.76879 +- 2.458146)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9639899 |     9639.9 |     9261.0 |      0.0000 |     65595.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt
index 87ea66ff423..89e1afa09fe 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-detdesc-opt
@@ -157,7 +157,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -173,13 +172,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
- |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         7 |          7 |( 100.0000 +- 0.000000)% |
@@ -200,7 +192,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        81 |         78 |( 96.29630 +- 2.098362)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       247 |        237 |( 95.95142 +- 1.254090)% |
@@ -209,30 +200,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1359 |       1348 |( 99.19058 +- 0.2430592)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     22678 |      22625 |( 99.76629 +- 0.03206455)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       384 |        382 |( 99.47917 +- 0.3673245)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
- |*"Reassigned Reco PID BT"                        |     40501 |      15790 |( 38.98669 +- 0.2423470)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
- |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        52 |         48 |( 92.30769 +- 3.695265)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       142 |        127 |( 89.43662 +- 2.579378)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        44 |         44 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |        108 |( 31.21387 +- 2.491072)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9639920 |     9639.9 |     9261.1 |      0.0000 |     65596.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt
index 28c798f3e53..33fca92c884 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits-4D.ref.x86_64_v3-opt
@@ -154,7 +154,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -170,13 +169,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4529 |( 10.89383 +- 0.1528035)% |
- |*"Used RICH1 only"                               |     41574 |      18577 |( 44.68418 +- 0.2438320)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |         5 |          5 |( 100.0000 +- 0.000000)% |
@@ -197,7 +189,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        73 |         71 |( 97.26027 +- 1.910556)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       227 |        208 |( 91.62996 +- 1.838102)% |
@@ -206,30 +197,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1280 |       1268 |( 99.06250 +- 0.2693614)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     21479 |      21410 |( 99.67876 +- 0.03861107)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       356 |        354 |( 99.43820 +- 0.3961336)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
- |*"Reassigned Reco PID BT"                        |     40501 |      17117 |( 42.26315 +- 0.2454565)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4526 |( 11.17503 +- 0.1565522)% |
- |*"Used RICH1 only"                               |     40501 |      17657 |( 43.59645 +- 0.2464030)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        50 |         45 |( 90.00000 +- 4.242641)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       138 |        121 |( 87.68116 +- 2.797683)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        44 |         44 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |        114 |( 32.94798 +- 2.526866)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |    9627669 |     9627.7 |     9249.4 |      0.0000 |     65497.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref
index 4c3f2a2dfa3..470e424e9c8 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref
@@ -148,7 +148,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -164,13 +163,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4527 |( 10.88902 +- 0.1527739)% |
- |*"Used RICH1 only"                               |     41574 |      18579 |( 44.68899 +- 0.2438345)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        16 |         13 |( 81.25000 +- 9.757809)% |
@@ -191,7 +183,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        96 |         86 |( 89.58333 +- 3.117758)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       318 |        265 |( 83.33333 +- 2.089874)% |
@@ -200,30 +191,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1928 |       1890 |( 98.02905 +- 0.3165645)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29067 |      28863 |( 99.29817 +- 0.04896497)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       567 |        558 |( 98.41270 +- 0.5248845)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       8184 |( 20.20691 +- 0.1995261)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4524 |( 11.17009 +- 0.1565219)% |
- |*"Used RICH1 only"                               |     40501 |      17659 |( 43.60139 +- 0.2464061)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        65 |         59 |( 90.76923 +- 3.590307)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       182 |        152 |( 83.51648 +- 2.750270)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        59 |         58 |( 98.30508 +- 1.680490)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         39 |( 11.27168 +- 1.700150)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.281819e+07 |    12818.0 |    12698.0 |      0.0000 |     90894.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc
index 642e773a9ca..38f6371c7b2 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.detdesc
@@ -151,7 +151,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -167,13 +166,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
- |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        21 |         19 |( 90.47619 +- 6.405645)% |
@@ -194,7 +186,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        98 |         87 |( 88.77551 +- 3.188723)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       333 |        286 |( 85.88589 +- 1.907944)% |
@@ -203,30 +194,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1976 |       1926 |( 97.46964 +- 0.3532911)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29552 |      29363 |( 99.36045 +- 0.04637146)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       588 |        578 |( 98.29932 +- 0.5332096)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       7575 |( 18.70324 +- 0.1937591)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
- |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        66 |         56 |( 84.84848 +- 4.413449)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       185 |        157 |( 84.86486 +- 2.634943)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        62 |         61 |( 98.38710 +- 1.599843)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         32 |( 9.248555 +- 1.557491)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.283381e+07 |    12834.0 |    12713.0 |      0.0000 |     90999.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt
index 29a58ef0355..ab805e4be6b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-detdesc-opt
@@ -151,7 +151,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -167,13 +166,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
- |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        19 |         18 |( 94.73684 +- 5.122782)% |
@@ -194,7 +186,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        96 |         84 |( 87.50000 +- 3.375386)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       327 |        283 |( 86.54434 +- 1.887113)% |
@@ -203,30 +194,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1981 |       1934 |( 97.62746 +- 0.3419404)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29544 |      29361 |( 99.38058 +- 0.04564645)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       583 |        569 |( 97.59863 +- 0.6340410)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       7558 |( 18.66127 +- 0.1935916)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
- |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        67 |         57 |( 85.07463 +- 4.353366)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       187 |        160 |( 85.56150 +- 2.570274)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        63 |         62 |( 98.41270 +- 1.574654)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         28 |( 8.092486 +- 1.466150)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.283386e+07 |    12834.0 |    12713.0 |      0.0000 |     90999.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt
index 706c68815ff..4191c71d842 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks-mchits.ref.x86_64_v3-opt
@@ -148,7 +148,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -164,13 +163,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4529 |( 10.89383 +- 0.1528035)% |
- |*"Used RICH1 only"                               |     41574 |      18577 |( 44.68418 +- 0.2438320)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        14 |         13 |( 92.85714 +- 6.883029)% |
@@ -191,7 +183,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        93 |         83 |( 89.24731 +- 3.212289)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       317 |        269 |( 84.85804 +- 2.013297)% |
@@ -200,30 +191,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1945 |       1906 |( 97.99486 +- 0.3178442)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29053 |      28854 |( 99.31504 +- 0.04838860)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       565 |        555 |( 98.23009 +- 0.5547200)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       8159 |( 20.14518 +- 0.1992982)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4526 |( 11.17503 +- 0.1565522)% |
- |*"Used RICH1 only"                               |     40501 |      17657 |( 43.59645 +- 0.2464030)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        66 |         58 |( 87.87879 +- 4.017382)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       183 |        155 |( 84.69945 +- 2.661143)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        59 |         59 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         37 |( 10.69364 +- 1.661368)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.281826e+07 |    12818.0 |    12698.0 |      0.0000 |     90894.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref
index d2812892a9f..ce5d005fec7 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref
@@ -145,7 +145,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -161,13 +160,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4527 |( 10.88902 +- 0.1527739)% |
- |*"Used RICH1 only"                               |     41574 |      18579 |( 44.68899 +- 0.2438345)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        15 |         12 |( 80.00000 +- 10.32796)% |
@@ -188,7 +180,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        96 |         86 |( 89.58333 +- 3.117758)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       312 |        263 |( 84.29487 +- 2.059890)% |
@@ -197,30 +188,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1986 |       1935 |( 97.43202 +- 0.3549414)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29427 |      29196 |( 99.21501 +- 0.05144565)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       588 |        576 |( 97.95918 +- 0.5830904)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       7633 |( 18.84645 +- 0.1943281)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4524 |( 11.17009 +- 0.1565219)% |
- |*"Used RICH1 only"                               |     40501 |      17659 |( 43.60139 +- 0.2464061)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        67 |         62 |( 92.53731 +- 3.210470)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       186 |        155 |( 83.33333 +- 2.732608)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        62 |         62 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         30 |( 8.670520 +- 1.512830)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.319374e+07 |    13194.0 |    12868.0 |      0.0000 |     91792.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc
index 3d3555550da..6d8ace4f182 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.detdesc
@@ -148,7 +148,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -164,13 +163,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
- |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        18 |         16 |( 88.88889 +- 7.407407)% |
@@ -191,7 +183,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |       101 |         88 |( 87.12871 +- 3.332199)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       328 |        284 |( 86.58537 +- 1.881806)% |
@@ -200,30 +191,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      2029 |       1972 |( 97.19073 +- 0.3668325)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29806 |      29615 |( 99.35919 +- 0.04621862)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       608 |        592 |( 97.36842 +- 0.6491805)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       7110 |( 17.55512 +- 0.1890388)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
- |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        67 |         62 |( 92.53731 +- 3.210470)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       191 |        166 |( 86.91099 +- 2.440473)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        63 |         63 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         24 |( 6.936416 +- 1.365902)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.321004e+07 |    13210.0 |    12883.0 |      0.0000 |     91892.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt
index 8251e1063b0..849cbbc3bbd 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-detdesc-opt
@@ -148,7 +148,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93906 |     93.906 |     54.299 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93906 |      14752 |( 15.70933 +- 0.1187468)% |
  |*"Used RICH1 only"                               |     93906 |      44912 |( 47.82655 +- 0.1630094)% |
@@ -164,13 +163,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4526 |( 10.88661 +- 0.1527590)% |
- |*"Used RICH1 only"                               |     41574 |      18580 |( 44.69139 +- 0.2438358)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        17 |         16 |( 94.11765 +- 5.706721)% |
@@ -191,7 +183,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        99 |         86 |( 86.86869 +- 3.394440)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       329 |        285 |( 86.62614 +- 1.876527)% |
@@ -200,30 +191,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      2032 |       1975 |( 97.19488 +- 0.3662987)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29797 |      29609 |( 99.36906 +- 0.04587034)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       600 |        586 |( 97.66667 +- 0.6162912)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5450 |( 13.45646 +- 0.1695703)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       7134 |( 17.61438 +- 0.1892895)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4523 |( 11.16763 +- 0.1565068)% |
- |*"Used RICH1 only"                               |     40501 |      17660 |( 43.60386 +- 0.2464077)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        68 |         63 |( 92.64706 +- 3.165133)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       187 |        161 |( 86.09626 +- 2.530097)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        64 |         64 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         26 |( 7.514451 +- 1.417253)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.321009e+07 |    13210.0 |    12883.0 |      0.0000 |     91892.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt
index 95ac07419ec..805c35f7bd9 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-fake-mctracks.ref.x86_64_v3-opt
@@ -145,7 +145,6 @@ MCRichTrackUnpacker              INFO Number of counters : 1
  | "# UnPackedData"                                |      1000 |     342734 |     342.73 |     195.41 |      0.0000 |      1237.0 |
 RichDLLsMC                       INFO Number of counters : 4
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  | "# PIDs"                                        |      1000 |      93907 |     93.907 |     54.300 |      0.0000 |      339.00 |
  |*"Used RICH1 and RICH2"                          |     93907 |      14752 |( 15.70916 +- 0.1187456)% |
  |*"Used RICH1 only"                               |     93907 |      44912 |( 47.82604 +- 0.1630085)% |
@@ -161,13 +160,6 @@ RichPIDMonMC10to70               INFO Number of counters : 8
  |*"Used RICH1 only"                               |     38121 |       5876 |( 15.41408 +- 0.1849378)% |
  |*"Used RICH2 only"                               |     38121 |      21657 |( 56.81121 +- 0.2537000)% |
 RichPIDMonMC2to10                INFO Number of counters : 7
-=======
- | "# PIDs"                                        |      1000 |      41574 |     41.574 |     25.146 |      0.0000 |      156.00 |
- |*"Used RICH1 and RICH2"                          |     41574 |       4529 |( 10.89383 +- 0.1528035)% |
- |*"Used RICH1 only"                               |     41574 |      18577 |( 44.68418 +- 0.2438320)% |
- |*"Used RICH2 only"                               |     41574 |      18468 |( 44.42199 +- 0.2436911)% |
-RichPIDMonMC10to70               INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        15 |         13 |( 86.66667 +- 8.777075)% |
@@ -188,7 +180,6 @@ RichPIDMonMC2to100               INFO Number of counters : 8
  |*"Used RICH2 only"                               |     86245 |      32040 |( 37.14998 +- 0.1645376)% |
 RichPIDMonMC70to100              INFO Number of counters : 8
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
-<<<<<<< HEAD
  |*"Event ID rate"                                 |      1000 |        992 |( 99.20000 +- 0.2817091)% |
  |*"K->K,Pr,D ID Efficiency"                       |        95 |         83 |( 87.36842 +- 3.408351)% |
  |*"Pi->El,Mu,Pi ID Efficiency"                    |       325 |        276 |( 84.92308 +- 1.984849)% |
@@ -197,30 +188,6 @@ RichPIDMonMC70to100              INFO Number of counters : 8
  |*"Used RICH1 and RICH2"                          |       681 |        137 |( 20.11747 +- 1.536169)% |
  |*"Used RICH1 only"                               |       681 |         26 |( 3.817915 +- 0.7343222)% |
  |*"Used RICH2 only"                               |       681 |        518 |( 76.06461 +- 1.635076)% |
-=======
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |      1989 |       1943 |( 97.68728 +- 0.3370258)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |     29422 |      29203 |( 99.25566 +- 0.05011036)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |       588 |        574 |( 97.61905 +- 0.6287152)% |
- |*"Reassigned MC PID BT"                          |     40501 |       5449 |( 13.45399 +- 0.1695572)% |
- |*"Reassigned Reco PID BT"                        |     40501 |       7634 |( 18.84892 +- 0.1943379)% |
- |*"Track ID rate"                                 |     53263 |      40501 |( 76.03965 +- 0.1849498)% |
- |*"Used RICH1 and RICH2"                          |     40501 |       4526 |( 11.17503 +- 0.1565522)% |
- |*"Used RICH1 only"                               |     40501 |      17657 |( 43.59645 +- 0.2464030)% |
- |*"Used RICH2 only"                               |     40501 |      18318 |( 45.22851 +- 0.2473151)% |
-RichPIDMonMC70to100              INFO Number of counters : 10
- |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
- |*"Event ID rate"                                 |      1000 |        990 |( 99.00000 +- 0.3146427)% |
- |*"K->K,Pr,D ID Efficiency"                       |        68 |         62 |( 91.17647 +- 3.439601)% |
- |*"Pi->El,Mu,Pi ID Efficiency"                    |       184 |        154 |( 83.69565 +- 2.723292)% |
- |*"Pr DLL(Pr)>0 ID Efficiency"                    |        63 |         63 |( 100.0000 +- 0.000000)% |
- |*"Reassigned MC PID BT"                          |       346 |          2 |(0.5780347 +- 0.4075492)% |
- |*"Reassigned Reco PID BT"                        |       346 |         30 |( 8.670520 +- 1.512830)% |
- |*"Track ID rate"                                 |       367 |        346 |( 94.27793 +- 1.212407)% |
- |*"Used RICH1 and RICH2"                          |       346 |         11 |( 3.179191 +- 0.9432018)% |
- |*"Used RICH1 only"                               |       346 |          1 |(0.2890173 +- 0.2885994)% |
- |*"Used RICH2 only"                               |       346 |        334 |( 96.53179 +- 0.9836706)% |
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
 RichRecoStatsMC                  INFO Number of counters : 6
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  | "# Rich1Gas Photons"                            |      1000 |1.319381e+07 |    13194.0 |    12868.0 |      0.0000 |     91792.0 |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref
index 7a57f23a5e6..f5481290093 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref
@@ -172,11 +172,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        52 |         50 |( 96.15385 +- 2.666828)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc
index c608663175b..4cb28e72f70 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.detdesc
@@ -175,11 +175,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        52 |         50 |( 96.15385 +- 2.666828)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt
index f4a136c59db..5d5e497dd0b 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-detdesc-opt
@@ -175,11 +175,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt
index 3296eee8b5b..4aa9e5fea02 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmcpos.ref.x86_64_v3-opt
@@ -172,11 +172,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        52 |         48 |( 92.30769 +- 3.695265)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref
index c4f6165addd..a49c96f5dc6 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref
@@ -182,11 +182,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc
index 4daf7c5035b..a72d60bb730 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.detdesc
@@ -185,11 +185,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        26 |         26 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt
index 0486ff2f6da..30aabb7b7e0 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-detdesc-opt
@@ -185,11 +185,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        29 |         29 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt
index 78296aa0d48..261cfb27a0a 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst-pixmctime-4D.ref.x86_64_v3-opt
@@ -182,11 +182,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        28 |         28 |( 100.0000 +- 0.000000)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref
index 8dcfaafd6a7..e8db4acf42d 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref
@@ -169,11 +169,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc
index b4e4fc07e1a..64c57369060 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.detdesc
@@ -172,11 +172,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt
index 3c7848e4fa2..3b1e063405d 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-detdesc-opt
@@ -172,11 +172,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6964 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6964 |       6964 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6964 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         47 |( 92.15686 +- 3.764642)% |
diff --git a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt
index 241054bc9fa..54b2ad578bc 100644
--- a/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt
+++ b/Rich/RichFutureRecSys/tests/refs/reco-from-detdesc-mc-dst.ref.x86_64_v3-opt
@@ -169,11 +169,7 @@ RichDLLsUp                       INFO Number of counters : 4
  |*"Used RICH1 and RICH2"                          |      6926 |          0 |( 0.000000 +- 0.000000)% |
  |*"Used RICH1 only"                               |      6926 |       6926 |( 100.0000 +- 0.000000)% |
  |*"Used RICH2 only"                               |      6926 |          0 |( 0.000000 +- 0.000000)% |
-<<<<<<< HEAD
 RichPIDMonDown10to70             INFO Number of counters : 8
-=======
-RichPIDMonDown10to70             INFO Number of counters : 10
->>>>>>> c5f206db5d (Update RICH QMT test refs again following changes to clustering counters)
  |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
  |*"Event ID rate"                                 |      1000 |        969 |( 96.90000 +- 0.5480785)% |
  |*"K->K,Pr,D ID Efficiency"                       |        51 |         48 |( 94.11765 +- 3.294777)% |
-- 
GitLab


From 8f7e66c6f4aba4727e1865e335681a616d786b14 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Mon, 13 Nov 2023 13:21:56 +0000
Subject: [PATCH 64/67] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/33897885
---
 .../src/RichSIMDQuarticPhotonReco.cpp                         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
index 72694761e0a..e7ff4a8f346 100644
--- a/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
+++ b/Rich/RichFutureRecPhotonAlgorithms/src/RichSIMDQuarticPhotonReco.cpp
@@ -110,8 +110,8 @@ namespace Rich::Future::Rec {
       for ( const auto rich : activeDetectors() ) {
         m_photTimeWindowSIMD[rich] = SIMDFP( m_photTimeWindow[rich] );
         if ( m_enable4D[rich] ) {
-          info() << "4D photons enabled for " << rich << " | Window = " << ( 2.0 * m_photTimeWindow[rich] )
-                 << " ns" << endmsg;
+          info() << "4D photons enabled for " << rich << " | Window = " << ( 2.0 * m_photTimeWindow[rich] ) << " ns"
+                 << endmsg;
         }
       }
       // loop over radiators
-- 
GitLab


From d9589c83abdff7a6858d5486a30cc86bf44dcbbf Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 12 Dec 2023 14:21:37 +0000
Subject: [PATCH 65/67] RichTrSegMakerFromMCRichTracks: fix origin vertex
 variable name

---
 .../src/RichTrSegMakerFromMCRichTracks.cpp                      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
index 81b99eeded7..7fc85fd97bb 100644
--- a/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
+++ b/Rich/RichFutureRecMCAlgorithms/src/RichTrSegMakerFromMCRichTracks.cpp
@@ -268,7 +268,7 @@ namespace Rich::Future::Rec::MC {
         };
 
         // Create 'first' state from origin vertex
-        makeState( mc_orig_v->position(), mcp_vect, LHCb::State::Location::FirstMeasurement );
+        makeState( mcp_orig_v->position(), mcp_vect, LHCb::State::Location::FirstMeasurement );
 
         // Fake some parameters
         tk->setNDoF( 10 ); // ??
-- 
GitLab


From 12df9fe6a16d8092988191c678d2664ab448fdb7 Mon Sep 17 00:00:00 2001
From: Sebastien Ponce <sebastien.ponce@cern.ch>
Date: Thu, 11 Jan 2024 12:36:17 +0100
Subject: [PATCH 66/67] Apply review suggestions

---
 Rec/GlobalReco/root/GlobalPID.C                          | 2 --
 .../src/RichSIMDPixelBackgroundsEstiAvHPD.cpp            | 9 ---------
 Rich/RichFutureRecSys/examples/RichFuture.py             | 1 -
 3 files changed, 12 deletions(-)

diff --git a/Rec/GlobalReco/root/GlobalPID.C b/Rec/GlobalReco/root/GlobalPID.C
index 4cd8180de4c..0cdcf3a66d9 100755
--- a/Rec/GlobalReco/root/GlobalPID.C
+++ b/Rec/GlobalReco/root/GlobalPID.C
@@ -700,8 +700,6 @@ void GlobalPID::Init( TTree* tree ) {
   fChain->SetBranchAddress( "CaloChargedSpd", &CaloChargedSpd, &b_CaloChargedSpd );
   fChain->SetBranchAddress( "CaloChargedPrs", &CaloChargedPrs, &b_CaloChargedPrs );
   fChain->SetBranchAddress( "CaloChargedEcal", &CaloChargedEcal, &b_CaloChargedEcal );
-  // fChain->SetBranchAddress( "CaloSpdE", &CaloSpdE, &b_CaloSpdE );
-  // fChain->SetBranchAddress( "CaloPrsE", &CaloPrsE, &b_CaloPrsE );
   fChain->SetBranchAddress( "CaloEcalChi2", &CaloEcalChi2, &b_CaloEcalChi2 );
   fChain->SetBranchAddress( "CaloClusChi2", &CaloClusChi2, &b_CaloClusChi2 );
   fChain->SetBranchAddress( "CaloBremChi2", &CaloBremChi2, &b_CaloBremChi2 );
diff --git a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
index 1dec241fa5a..efbd454c54e 100644
--- a/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
+++ b/Rich/RichFutureRecPixelAlgorithms/src/RichSIMDPixelBackgroundsEstiAvHPD.cpp
@@ -88,17 +88,8 @@ namespace Rich::Future::Rec {
       inline auto pdIndex( const LHCb::RichSmartID  pdID, //
                            const Rich::DetectorType rich, //
                            const Rich::Side         panel ) const noexcept {
-        // Just use module number
-        // const auto idx = pdID.pdMod();
-        // Group modules in neighboring columns, doubling group size
-        // const auto colGSize = 2u;
-        // const auto colG     = pdID.panelLocalModuleColumn() / colGSize;
-        // const auto idx      = ( colG * LHCb::RichSmartID::MaPMT::ModulesPerColumn ) + pdID.columnLocalModuleNum();
         // Use EC ( 4 groups per module )
         const auto idx = ( LHCb::RichSmartID::MaPMT::ECsPerModule * pdID.pdMod() ) + pdID.elementaryCell();
-        // Group two ECs together ( 2 groups per module )
-        // const auto idx =
-        //    ( ( LHCb::RichSmartID::MaPMT::ECsPerModule / 2 ) * pdID.pdMod() ) + ( pdID.elementaryCell() / 2 );
         // return with min scale
         return ( idx - minPanelIndex[rich][panel] );
       }
diff --git a/Rich/RichFutureRecSys/examples/RichFuture.py b/Rich/RichFutureRecSys/examples/RichFuture.py
index 8a5d6030a17..8711b0bb10b 100644
--- a/Rich/RichFutureRecSys/examples/RichFuture.py
+++ b/Rich/RichFutureRecSys/examples/RichFuture.py
@@ -370,7 +370,6 @@ pdBckWeights = [(WR1, WR2), (WR1, WR2), (WR1, WR2), (WR1, WR2)]
 # Hit treatment in background alg
 # Need to try and understand the difference here between best 3D and 4D tunings
 PDBackIgnoreHitData = [is4D, False, False, False]
-#PDBackIgnoreHitData = [False, False, False, False]
 
 # background thresholds
 bT = 0.0
-- 
GitLab


From 817171e67c76cab86d8eb3b18604e243f396adf3 Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Thu, 11 Jan 2024 14:34:07 +0000
Subject: [PATCH 67/67] TrackCheckerBase: Modernise, make tool instances
 private to allow for correct configuration of data dependencies.

---
 Tr/TrackCheckers/src/TrackCheckerBase.cpp | 37 ++++-----
 Tr/TrackCheckers/src/TrackCheckerBase.h   | 96 +++++++++--------------
 2 files changed, 54 insertions(+), 79 deletions(-)

diff --git a/Tr/TrackCheckers/src/TrackCheckerBase.cpp b/Tr/TrackCheckers/src/TrackCheckerBase.cpp
index b41cf72d1db..be07efc3080 100644
--- a/Tr/TrackCheckers/src/TrackCheckerBase.cpp
+++ b/Tr/TrackCheckers/src/TrackCheckerBase.cpp
@@ -16,14 +16,11 @@
 // Initialization. Check parameters
 //=============================================================================
 StatusCode TrackCheckerBase::initialize() {
-
-  static const std::string histoDir = "Track/";
-  if ( "" == histoTopDir() ) setHistoTopDir( histoDir );
-
+  if ( "" == histoTopDir() ) { setHistoTopDir( "Track/" ); }
   // Mandatory initialization of GaudiAlgorithm
   return GaudiHistoAlg::initialize().andThen( [&] {
-    const TrackMaps::RecMap& theMap = TrackMaps::recDescription();
-    m_recCat                        = theMap.find( m_selectionCriteria )->second;
+    const auto& theMap = TrackMaps::recDescription();
+    m_recCat           = theMap.find( m_selectionCriteria )->second;
   } );
 }
 
@@ -45,8 +42,8 @@ const LHCb::MCParticle* TrackCheckerBase::mcTruth( const LHCb::Track& track, con
 
 bool TrackCheckerBase::bAncestorWithReconstructibleDaughters( const LHCb::MCParticle* mcPart ) const {
   // loop back and see if there is a B in the history
-  bool                    fromB  = false;
-  const LHCb::MCParticle* mother = mcPart->mother();
+  bool        fromB  = false;
+  const auto* mother = mcPart->mother();
   while ( mother && !fromB ) {
     fromB = mother->particleID().hasBottom() && ( mother->particleID().isMeson() || mother->particleID().isBaryon() );
     if ( fromB && !allDaughtersReconstructible( mother ) ) return false;
@@ -57,8 +54,8 @@ bool TrackCheckerBase::bAncestorWithReconstructibleDaughters( const LHCb::MCPart
 
 bool TrackCheckerBase::bAncestor( const LHCb::MCParticle* mcPart ) const {
   // loop back and see if there is a B in the history
-  bool                    fromB  = false;
-  const LHCb::MCParticle* mother = mcPart->mother();
+  bool        fromB  = false;
+  const auto* mother = mcPart->mother();
   while ( mother && !fromB ) {
     fromB  = mother->particleID().hasBottom() && ( mother->particleID().isMeson() || mother->particleID().isBaryon() );
     mother = mother->mother();
@@ -68,22 +65,20 @@ bool TrackCheckerBase::bAncestor( const LHCb::MCParticle* mcPart ) const {
 
 bool TrackCheckerBase::ksLambdaAncestor( const LHCb::MCParticle* mcPart ) const {
   // loop back and see if there is a B in the history
-  bool                    fromKsL = false;
-  const LHCb::MCParticle* mother  = mcPart->mother();
+  bool        fromKsL = false;
+  const auto* mother  = mcPart->mother();
   while ( mother && !fromKsL ) {
-    if ( abs( mother->particleID().pid() ) == 310 || abs( mother->particleID().pid() ) == 3122 ) fromKsL = true;
+    if ( abs( mother->particleID().pid() ) == 310 || abs( mother->particleID().pid() ) == 3122 ) { fromKsL = true; }
     mother = mother->mother();
   } // loop
   return fromKsL;
 }
 
 bool TrackCheckerBase::allDaughtersReconstructible( const LHCb::MCParticle* mcPart ) const {
-  const SmartRefVector<LHCb::MCVertex>& vtx = mcPart->endVertices();
-
-  for ( SmartRefVector<LHCb::MCVertex>::const_iterator i = vtx.begin(); i != vtx.end(); ++i ) {
-    const SmartRefVector<LHCb::MCParticle>& ch = ( *i )->products();
-    for ( SmartRefVector<LHCb::MCParticle>::const_iterator j = ch.begin(); j != ch.end(); ++j ) {
-
+  const auto& vtx = mcPart->endVertices();
+  for ( auto i = vtx.begin(); i != vtx.end(); ++i ) {
+    const auto& ch = ( *i )->products();
+    for ( auto j = ch.begin(); j != ch.end(); ++j ) {
       if ( ( abs( ( *j )->particleID().pid() ) == 321 || abs( ( *j )->particleID().pid() ) == 211 ||
              abs( ( *j )->particleID().pid() ) == 13 || abs( ( *j )->particleID().pid() ) == 11 ||
              abs( ( *j )->particleID().pid() ) == 2212 ) ) {
@@ -92,10 +87,10 @@ bool TrackCheckerBase::allDaughtersReconstructible( const LHCb::MCParticle* mcPa
              ( *j )->mother()->particleID().pid() != 310 && ( *j )->mother()->particleID().pid() != 3122 ) {
           return false;
         }
-      } else if ( !allDaughtersReconstructible( *j ) )
+      } else if ( !allDaughtersReconstructible( *j ) ) {
         return false;
+      }
     }
   }
-
   return true;
 }
diff --git a/Tr/TrackCheckers/src/TrackCheckerBase.h b/Tr/TrackCheckers/src/TrackCheckerBase.h
index 981a0826d62..b85647dd92d 100644
--- a/Tr/TrackCheckers/src/TrackCheckerBase.h
+++ b/Tr/TrackCheckers/src/TrackCheckerBase.h
@@ -8,14 +8,12 @@
 * granted to it by virtue of its status as an Intergovernmental Organization  *
 * or submit itself to any jurisdiction.                                       *
 \*****************************************************************************/
-#ifndef TRACKCHECKERBASE_H
-#define TRACKCHECKERBASE_H 1
+
+#pragma once
 
 // from Gaudi
 #include "GaudiAlg/GaudiHistoAlg.h"
 
-#include <string>
-
 // interfaces
 #include "GaudiKernel/IMagneticFieldSvc.h"
 #include "MCInterfaces/IIdealStateCreator.h"
@@ -28,6 +26,8 @@
 #include "Event/MCParticle.h"
 #include "Event/Track.h"
 
+#include <string>
+
 /** @class TrackCheckerBase TrackCheckerBase.h "TrackCheckers/TrackCheckerBase"
  *
  *  Base class for track monitoring: essentially a 'box' of common tools
@@ -45,35 +45,36 @@ public:
   /** Algorithm initialization */
   StatusCode initialize() override;
 
+public:
+  /** small struct for link info */
+  struct LinkInfo {
+    LinkInfo( const LHCb::Track* t, unsigned int c, double p ) : track( t ), clone( c ), purity( p ) {}
+    LinkInfo() = default;
+    const LHCb::Track* track{nullptr};
+    unsigned int       clone{0};
+    double             purity{-1};
+  };
+
 public:
   /** Get a pointer to Magnetic field service
    *  @return field service
    */
-  const IMagneticFieldSvc* fieldSvc() const;
+  auto fieldSvc() const { return m_pIMF.get(); }
 
   /** Get a pointer to the track selection tool
    *  @return field service
    */
-  const IMCReconstructible* selector() const;
+  auto selector() const { return m_selector.get(); }
 
   /** Get a pointer to the idealStateCreator
    *  @return IdealStateCreator
    */
-  const IIdealStateCreator* idealStateCreator() const;
+  auto idealStateCreator() const { return m_stateCreator.get(); }
 
   /** Get a pointer to the track extrapolator
    *  @return extrapolator
    */
-  const ITrackExtrapolator* extrapolator() const;
-
-  /** small struct for link info */
-  struct LinkInfo {
-    LinkInfo( const LHCb::Track* t, unsigned int c, double p ) : track( t ), clone( c ), purity( p ) {}
-    LinkInfo() = default;
-    const LHCb::Track* track{nullptr};
-    unsigned int       clone{0};
-    double             purity{-1};
-  };
+  auto extrapolator() const { return m_extrapolator.get(); }
 
   /** link to truth
    * @param  aTrack track
@@ -85,12 +86,14 @@ public:
    *
    * @return bool
    */
-  bool selected( const LHCb::MCParticle* particle ) const;
+  bool selected( const LHCb::MCParticle* particle ) const {
+    return selector()->isReconstructibleAs( m_recCat, particle );
+  }
 
   /** Whether to split by algorithm
    *  @return splitByAlgorithm true or false
    */
-  bool splitByAlgorithm() const;
+  bool splitByAlgorithm() const { return m_splitByAlgorithm.value(); }
 
   /** Whether to split by algorithm
    *  @return splitByType true or false
@@ -100,12 +103,12 @@ public:
   /** Pointer to the visible primary vertex tool
    *  @return IVisPrimVertTool
    */
-  const IVisPrimVertTool* visPrimVertTool() const;
+  auto visPrimVertTool() const { return m_visPrimVertTool.get(); }
 
   /** Pointer to ghost classification tool
    *  @return ITrackGhostClassification
    */
-  const ITrackGhostClassification* ghostClassification() const;
+  auto ghostClassification() const { return m_ghostClassification.get(); }
 
   /** Is a b child ? ie has b quark somewhere in history
    * @param  mcPart MC particle
@@ -119,53 +122,30 @@ public:
    */
   bool ksLambdaAncestor( const LHCb::MCParticle* mcPart ) const;
 
-  /** are all stable daughters of this particle reconstructible?
+  /** Are all stable daughters of this particle reconstructible?
    * @param  mcPart MC particle
    * @return bool true/false
    */
-
   bool allDaughtersReconstructible( const LHCb::MCParticle* mcPart ) const;
 
+  /** Are all stable daughters of this particle reconstructible *and* is a b child ?
+   * @param  mcPart MC particle
+   * @return bool true/false
+   */
   bool bAncestorWithReconstructibleDaughters( const LHCb::MCParticle* mcPart ) const;
 
 private:
   Gaudi::Property<std::string>    m_selectionCriteria{this, "SelectionCriteria", "ChargedLong"};
-  IMCReconstructible::RecCategory m_recCat; ///<  Pointer to selector
-
-  ServiceHandle<IMagneticFieldSvc>      m_pIMF{this, "MagneticFieldService",
-                                          "MagneticFieldSvc"}; ///<  Pointer to the magn. field service
-  ToolHandle<ITrackGhostClassification> m_ghostClassification{
-      this, "GhostTool", "LongGhostClassification/GhostTool"};                               ///< Pointer to ghost tool
-  ToolHandle<IMCReconstructible> m_selector{this, "Selector", "MCReconstructible/Selector"}; ///<  Pointer to selector
-  PublicToolHandle<ITrackExtrapolator> m_extrapolator{this, "Extrapolator",
-                                                      "TrackMasterExtrapolator"}; ///<  Pointer to extrapolator
-  PublicToolHandle<IIdealStateCreator> m_stateCreator{this, "StateCreator",
-                                                      "IdealStateCreator"}; ///<  IdealStateCreator
-  PublicToolHandle<IVisPrimVertTool>   m_visPrimVertTool{this, "VisPrimVertTool",
-                                                       "VisPrimVertTool"}; ///< Visible primary vertices..
+  IMCReconstructible::RecCategory m_recCat;
+
+  ServiceHandle<const IMagneticFieldSvc>      m_pIMF{this, "MagneticFieldService", "MagneticFieldSvc"};
+  ToolHandle<const ITrackGhostClassification> m_ghostClassification{this, "GhostTool",
+                                                                    "LongGhostClassification/GhostTool"};
+  ToolHandle<const IMCReconstructible>        m_selector{this, "Selector", "MCReconstructible/Selector"};
+  ToolHandle<const ITrackExtrapolator>        m_extrapolator{this, "Extrapolator", "TrackMasterExtrapolator"};
+  ToolHandle<const IIdealStateCreator>        m_stateCreator{this, "StateCreator", "IdealStateCreator"};
+  ToolHandle<const IVisPrimVertTool>          m_visPrimVertTool{this, "VisPrimVertTool", "VisPrimVertTool"};
 
   Gaudi::Property<bool> m_splitByAlgorithm{this, "SplitByAlgorithm", false};
   Gaudi::Property<bool> m_splitByType{this, "SplitByType", false};
 };
-
-inline const IMagneticFieldSvc* TrackCheckerBase::fieldSvc() const { return m_pIMF.get(); }
-
-inline const IMCReconstructible* TrackCheckerBase::selector() const { return m_selector.get(); }
-
-inline bool TrackCheckerBase::selected( const LHCb::MCParticle* particle ) const {
-  return selector()->isReconstructibleAs( m_recCat, particle );
-}
-
-inline const ITrackExtrapolator* TrackCheckerBase::extrapolator() const { return m_extrapolator.get(); }
-
-inline const IIdealStateCreator* TrackCheckerBase::idealStateCreator() const { return m_stateCreator.get(); }
-
-inline const IVisPrimVertTool* TrackCheckerBase::visPrimVertTool() const { return m_visPrimVertTool.get(); }
-
-inline bool TrackCheckerBase::splitByAlgorithm() const { return m_splitByAlgorithm.value(); }
-
-inline const ITrackGhostClassification* TrackCheckerBase::ghostClassification() const {
-  return m_ghostClassification.get();
-}
-
-#endif // TRACKCHECKERBASE_H
-- 
GitLab