From 1ef48719935f63fed4cefbbdf156c16e79402980 Mon Sep 17 00:00:00 2001
From: "audrey.chatillon" <audrey.chatillon@gmail.com>
Date: Thu, 19 Dec 2024 14:29:37 +0100
Subject: [PATCH] change back from double to vector<double> for m_R etc.. even
 if one detector only

---
 NPSimulation/Detectors/Epic/Epic.cc | 45 +++++++++++++++--------------
 NPSimulation/Detectors/Epic/Epic.hh |  8 ++---
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/NPSimulation/Detectors/Epic/Epic.cc b/NPSimulation/Detectors/Epic/Epic.cc
index 762bd392d..c8369a844 100644
--- a/NPSimulation/Detectors/Epic/Epic.cc
+++ b/NPSimulation/Detectors/Epic/Epic.cc
@@ -101,9 +101,9 @@ Epic::~Epic(){
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 void Epic::AddDetector(G4ThreeVector POS){
   // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 
-  m_R = POS.mag();
-  m_Theta = POS.theta();
-  m_Phi = POS.phi();
+  m_R.push_back(POS.mag());
+  m_Theta.push_back(POS.theta());
+  m_Phi.push_back(POS.phi());
 }
 
 
@@ -151,26 +151,27 @@ void Epic::ReadConfiguration(NPL::InputParser parser){
 // Construct detector and inialise sensitive part.
 // Called After DetecorConstruction::AddDetector Method
 void Epic::ConstructDetector(G4LogicalVolume* world){
+  for (unsigned short i = 0 ; i < m_R.size() ; i++) {
 
-  G4double wX = m_R * sin(m_Theta ) * cos(m_Phi ) ;
-  G4double wY = m_R * sin(m_Theta ) * sin(m_Phi ) ;
-  G4double wZ = m_R * cos(m_Theta ) ;
-  G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ;
-
-  // Building Detector reference frame
-  G4double ii = cos(m_Theta) * cos(m_Phi);
-  G4double jj = cos(m_Theta) * sin(m_Phi);
-  G4double kk = -sin(m_Theta);
-  G4ThreeVector Y(ii,jj,kk);
-  G4ThreeVector w = Det_pos.unit();
-  G4ThreeVector u = w.cross(Y);
-  G4ThreeVector v = w.cross(u);
-  v = v.unit();
-  u = u.unit();
-
-  G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w);
-  BuildEpic()->MakeImprint(world, Det_pos, Rot, 0);
-
+    G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ;
+    G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ;
+    G4double wZ = m_R[i] * cos(m_Theta[i] ) ;
+    G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ;
+    
+    // Building Detector reference frame
+    G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]);
+    G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]);
+    G4double kk = -sin(m_Theta[i]);
+    G4ThreeVector Y(ii,jj,kk);
+    G4ThreeVector w = Det_pos.unit();
+    G4ThreeVector u = w.cross(Y);
+    G4ThreeVector v = w.cross(u);
+    v = v.unit();
+    u = u.unit();
+
+    G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0);
+    BuildEpic()->MakeImprint(world, Det_pos, Rot, i);
+  }
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
diff --git a/NPSimulation/Detectors/Epic/Epic.hh b/NPSimulation/Detectors/Epic/Epic.hh
index 74938962f..97713109d 100644
--- a/NPSimulation/Detectors/Epic/Epic.hh
+++ b/NPSimulation/Detectors/Epic/Epic.hh
@@ -54,8 +54,8 @@ class Epic : public NPS::VDetector{
     void AddDetector(G4ThreeVector POS);
 
     G4AssemblyVolume* BuildEpic();
-    void BuildCathode(double PosZ);
     void BuildAnode(double PosZ);
+    void BuildCathode(double PosZ);
   
   private:
     G4AssemblyVolume* m_EpicVolume;
@@ -97,9 +97,9 @@ class Epic : public NPS::VDetector{
     ////////////////////////////////////////////////////
   private: // Geometry
     // Detector Coordinate 
-    double m_R; 
-    double m_Theta;
-    double m_Phi; 
+    vector<double> m_R; 
+    vector<double> m_Theta;
+    vector<double> m_Phi; 
 
     string m_GasMaterial;
     double m_Pressure;
-- 
GitLab