From 5f34a98e0391506c22bbf3009564d68256dda4d3 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Thu, 20 Oct 2022 20:21:45 +0000
Subject: [PATCH] feat: support pfrich/mrich alternatives in brycecanyon

---
 options/reconstruction.ecal.py |  5 +++++
 options/reconstruction.hcal.py |  5 +++++
 options/reconstruction.py      | 28 +++++++++++++++++++++++++---
 options/reconstruction.raw.py  | 14 +++++++++-----
 4 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/options/reconstruction.ecal.py b/options/reconstruction.ecal.py
index 93d1bd5f..ee98e66a 100644
--- a/options/reconstruction.ecal.py
+++ b/options/reconstruction.ecal.py
@@ -13,8 +13,13 @@ detector_version = str(os.environ.get("DETECTOR_VERSION", "main"))
 
 # Detector features that affect reconstruction
 has_ecal_barrel_scfi = False
+has_pid_backward_pfrich = False
 if "epic" in detector_name and "imaging" in detector_config:
     has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
+if "epic" in detector_name and "brycecanyon" in detector_config:
+    has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
 
 # CAL reconstruction
 # get sampling fractions from system environment variable
diff --git a/options/reconstruction.hcal.py b/options/reconstruction.hcal.py
index c8577aba..2d7d06c0 100644
--- a/options/reconstruction.hcal.py
+++ b/options/reconstruction.hcal.py
@@ -13,8 +13,13 @@ detector_version = str(os.environ.get("DETECTOR_VERSION", "main"))
 
 # Detector features that affect reconstruction
 has_ecal_barrel_scfi = False
+has_pid_backward_pfrich = False
 if "epic" in detector_name and "imaging" in detector_config:
     has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
+if "epic" in detector_name and "brycecanyon" in detector_config:
+    has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
 
 # CAL reconstruction
 # get sampling fractions from system environment variable
diff --git a/options/reconstruction.py b/options/reconstruction.py
index f859d2b6..785e7c65 100644
--- a/options/reconstruction.py
+++ b/options/reconstruction.py
@@ -15,8 +15,13 @@ detector_version = str(os.environ.get("DETECTOR_VERSION", "main"))
 
 # Detector features that affect reconstruction
 has_ecal_barrel_scfi = False
+has_pid_backward_pfrich = False
 if "epic" in detector_name and "imaging" in detector_config:
     has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
+if "epic" in detector_name and "brycecanyon" in detector_config:
+    has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
 
 if "PBEAM" in os.environ:
     ionBeamEnergy = str(os.environ["PBEAM"])
@@ -250,7 +255,10 @@ sim_coll += (
     + mpgd_barrel_collections
 )
 
-sim_coll.append("MRICHHits")
+if has_pid_backward_pfrich:
+    sim_coll.append("PFRICHHits")
+else:
+    sim_coll.append("MRICHHits")
 
 # list of algorithms
 algorithms = []
@@ -1119,8 +1127,22 @@ algorithms.append(drich_reco)
 #        #inputTrackCollection=parts_with_truth_pid.outputParticles,
 #        outputClusterCollection="ForwardRICHClusters")
 
-# MRICH
-if "acadia" in detector_version:
+# PFRICH/MRICH
+if has_pid_backward_pfrich:
+    pfrich_digi = PhotoMultiplierDigi(
+        "pfrich_digi",
+        inputHitCollection="PFRICHHits",
+        outputHitCollection="PFRICHRawHits",
+        quantumEfficiency=[(a * eV, b) for a, b in qe_data],
+    )
+    algorithms.append(pfrich_digi)
+    pfrich_reco = PhotoMultiplierReco(
+        "pfrich_reco",
+        inputHitCollection=pfrich_digi.outputHitCollection,
+        outputHitCollection="PFRICHRecHits",
+    )
+    algorithms.append(pfrich_reco)
+else:
     mrich_digi = PhotoMultiplierDigi(
         "mrich_digi",
         inputHitCollection="MRICHHits",
diff --git a/options/reconstruction.raw.py b/options/reconstruction.raw.py
index bd1759d5..99d88a2e 100644
--- a/options/reconstruction.raw.py
+++ b/options/reconstruction.raw.py
@@ -13,12 +13,13 @@ detector_version = str(os.environ.get("DETECTOR_VERSION", "main"))
 
 # Detector features that affect reconstruction
 has_ecal_barrel_scfi = False
-if "athena" in detector_name:
-    has_ecal_barrel_scfi = True
-if "ecce" in detector_name and "imaging" in detector_config:
-    has_ecal_barrel_scfi = True
+has_pid_backward_pfrich = False
 if "epic" in detector_name and "imaging" in detector_config:
     has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
+if "epic" in detector_name and "brycecanyon" in detector_config:
+    has_ecal_barrel_scfi = True
+    has_pid_backward_pfrich = True
 
 # RICH reconstruction
 qe_data = [
@@ -126,7 +127,10 @@ sim_coll += (
     + mpgd_barrel_collections
 )
 
-sim_coll.append("MRICHHits")
+if has_pid_backward_pfrich:
+    sim_coll.append("PFRICHHits")
+else:
+    sim_coll.append("MRICHHits")
 
 # list of algorithms
 algorithms = []
-- 
GitLab