From 64505206fb9e3c1fffea0f69404673c3d0124e73 Mon Sep 17 00:00:00 2001
From: "audrey.chatillon" <audrey.chatillon@gmail.com>
Date: Thu, 2 Jan 2025 13:48:59 +0100
Subject: [PATCH] include pairs of cathodes

---
 NPSimulation/Detectors/Epic/Epic.cc | 33 +++++++++++++++++------------
 NPSimulation/Detectors/Epic/Epic.hh |  6 +++---
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/NPSimulation/Detectors/Epic/Epic.cc b/NPSimulation/Detectors/Epic/Epic.cc
index be26e83ca..c551cf27f 100644
--- a/NPSimulation/Detectors/Epic/Epic.cc
+++ b/NPSimulation/Detectors/Epic/Epic.cc
@@ -130,14 +130,15 @@ void Epic::ReadConfiguration(NPL::InputParser parser){
       G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm"));
       string GasMaterial = blocks[i]->GetString("GasMaterial");
       double Pressure = blocks[i]->GetDouble("Pressure","bar");
-      double Distance_AK = blocks[i]->GetDouble("Distance_AnodeCathode","mm");
-      int    nA = blocks[i]->GetInt("nAnodes");
+      double Distance_AK = blocks[i]->GetDouble("Distance_AK","mm");
+      double InterDistance_KK = blocks[i]->GetDouble("InterDistance_KK","mm"); 
+      int    nA   = blocks[i]->GetInt("nAnodes");
       AddDetector(Pos);
       m_GasMaterial = GasMaterial;
       m_Pressure = Pressure;
       m_Distance_AK = Distance_AK;
+      m_InterDistance_KK = InterDistance_KK;
       m_nA = nA;
-      m_nK = m_nA + 1;
     }
     else{
       cout << "ERROR: check your input file formatting " << endl;
@@ -217,9 +218,9 @@ G4AssemblyVolume* Epic::BuildEpic(){
   double flange_full_height =   5.*mm;       double posY_flange = posY_PCB - 0.5*PCB_Cu_height - 0.5*flange_full_height ;
   double flange_open_width   = 150.0*mm; 
   double flange_open_height  =   5.1*mm; 
-  double flange_open1_length =  42.0*mm;     double posZ_open1 = -73.5*mm;
+  double flange_open1_length =  74.5*mm;     double posZ_open1 = -89.5*mm;
   double flange_open2_length =  85.0*mm;     double posZ_open2 =   0.0*mm;
-  double flange_open3_length =  74.5*mm;     double posZ_open3 =  89.5*mm;
+  double flange_open3_length =  42.0*mm;     double posZ_open3 =  73.5*mm;
 
   G4Box* flange_full  = new G4Box("flange_full" , 0.5*flange_full_width , 0.5*flange_full_height, 0.5*flange_full_length);
   G4Box* flange_open1 = new G4Box("flange_open1", 0.5*flange_open_width , 0.5*flange_open_height, 0.5*flange_open1_length);
@@ -287,15 +288,21 @@ G4AssemblyVolume* Epic::BuildEpic(){
   m_EpicVolume->AddPlacedVolume(frame_final_vol, Tv, Rv);
 
 
-  //--- Cathodes (simple: rajouter les depots)
-  double posY_first_cathode = -1.*(double)m_nA*m_Distance_AK*mm;
-  for(int i=0; i<1; i++){
-    BuildCathode(posY_first_cathode+i*2.*m_Distance_AK*mm);
+  //--- Cathodes (TO DO : rajouter les depots)
+  double posZ_first_cathode = -1.*(double)m_nA*m_Distance_AK*mm - (double)std::trunc(0.5*m_nA)*m_InterDistance_KK*mm;
+  // Build First Cathode
+  BuildCathode(posZ_first_cathode);
+  // Build the central pairs of cathodes back to back
+  for(int i=1; i<m_nA; i++){
+    double posZ_current_cathode = posZ_first_cathode + (double)i*2.*m_Distance_AK*mm + (double)(i-0.5)*m_InterDistance_KK*mm ;  
+    BuildCathode(posZ_current_cathode - 0.5*m_InterDistance_KK*mm);
+    BuildCathode(posZ_current_cathode + 0.5*m_InterDistance_KK*mm);
   }
-  //double origine_anode = origine_cathode + m_Distance_AK;
-  //for(int i=0; i<m_nA; i++){
-  //  BuildAnode(origine_anode+i*2.*m_Distance_AK*mm); 
-  //}
+  // Build Last Cathode
+  BuildCathode(posZ_first_cathode + (double)m_nA*2.*m_Distance_AK*mm + (double)(m_nA-1)*m_InterDistance_KK*mm);
+  
+
+  // --- Anodes 
 
 
 
diff --git a/NPSimulation/Detectors/Epic/Epic.hh b/NPSimulation/Detectors/Epic/Epic.hh
index 97713109d..07d7abd3d 100644
--- a/NPSimulation/Detectors/Epic/Epic.hh
+++ b/NPSimulation/Detectors/Epic/Epic.hh
@@ -104,9 +104,9 @@ class Epic : public NPS::VDetector{
     string m_GasMaterial;
     double m_Pressure;
     double m_Distance_AK;
-    int    m_nA;
-    int    m_nK;
-    
+    double m_InterDistance_KK;
+    int    m_nA;   // number of anodes
+
     // Visualisation Attribute
     G4VisAttributes* m_VisFCWall;
     G4VisAttributes* m_VisAl;
-- 
GitLab