From 9ce03bd88601e4931f61a1a4f3a92b758461d4a6 Mon Sep 17 00:00:00 2001
From: matta <matta@npt>
Date: Fri, 1 Feb 2013 16:25:24 +0000
Subject: [PATCH] * correcting additional bug in target reading

---
 Inputs/DetectorConfiguration/sharc.detector |  2 +-
 NPLib/VDetector/DetectorManager.cxx         |  2 +-
 NPSimulation/include/Sharc.hh               | 11 ++++++-----
 NPSimulation/src/Sharc.cc                   |  7 ++-----
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/Inputs/DetectorConfiguration/sharc.detector b/Inputs/DetectorConfiguration/sharc.detector
index 74afb1bee..f06e6ea82 100644
--- a/Inputs/DetectorConfiguration/sharc.detector
+++ b/Inputs/DetectorConfiguration/sharc.detector
@@ -37,7 +37,7 @@ Sharc
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %Upstream Box
   SharcBOX
-    Z= -40
+    Z= 0
     ThicknessDector1= 100
     ThicknessDector2= 100
     ThicknessDector3= 100
diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx
index aedf8cc7f..e96927f80 100644
--- a/NPLib/VDetector/DetectorManager.cxx
+++ b/NPLib/VDetector/DetectorManager.cxx
@@ -472,7 +472,7 @@ void DetectorManager::ReadConfigurationFile(string Path)
             ConfigFile >> DataBuffer;
 
             // Search for comment Symbol %
-            if (DataBuffer.compare(0, 1, "%") == 0) {ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );}
+            if (DataBuffer.compare(0, 1, "%") == 0) {ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );getline(ConfigFile, LineBuffer);}
 
             else if (DataBuffer.compare(0, 10, "THICKNESS=") == 0) {
                check_Thickness = true ;
diff --git a/NPSimulation/include/Sharc.hh b/NPSimulation/include/Sharc.hh
index 661de5ab5..17ce3a0bb 100644
--- a/NPSimulation/include/Sharc.hh
+++ b/NPSimulation/include/Sharc.hh
@@ -71,13 +71,14 @@ namespace SHARC
   const G4int    BOX_Wafer_Back_NumberOfStrip = 16 ;
   
   // Compute
+  const G4double BOX_Exposed_Length1 = BOX_Wafer_Length + BOX_PCB_Slot1_Border +0.5*BOX_PCB_Slot1_Width;
+  const G4double BOX_CenterOffset1 = 0.5* (BOX_PCB_Length-BOX_Exposed_Length1);
+  
   const G4double BOX_Wafer_Width_Offset =
-  BOX_PCB_Width/2. - BOX_PCB_Border_LongSide - BOX_Wafer_Width/2.;
-  const G4double BOX_Wafer_Length_Offset =
-  BOX_PCB_Length/2. - BOX_PCB_Border_ShortSide - BOX_Wafer_Length/2.;
+  BOX_PCB_Width*0.5 - BOX_PCB_Border_LongSide - BOX_Wafer_Width*0.5;
+  const G4double BOX_Wafer_Length_Offset = BOX_CenterOffset1;
   
-  const G4double BOX_PCB_Slot1_Position =-(BOX_Wafer_Length_Offset-BOX_Wafer_Length/2.-BOX_PCB_Slot1_Border - BOX_PCB_Slot1_Width/2.);
-  //const G4double BOX_PCB_Slot1_Position = BOX_PCB_Width*0.5-(BOX_PCB_Width - (BOX_Wafer_Length+BOX_PCB_Border_ShortSide+BOX_PCB_Slot1_Border+BOX_PCB_Slot1_Width*0.5))-BOX_PCB_Slot1_Width*0.5;
+  const G4double BOX_PCB_Slot1_Position = (BOX_PCB_Slot1_Border+0.5*BOX_PCB_Slot1_Width+0.5*BOX_Wafer_Length-BOX_CenterOffset1);
   
   // PAD //
   // PAD PCB
diff --git a/NPSimulation/src/Sharc.cc b/NPSimulation/src/Sharc.cc
index 2cb9396a5..a4851b4f9 100644
--- a/NPSimulation/src/Sharc.cc
+++ b/NPSimulation/src/Sharc.cc
@@ -464,15 +464,12 @@ void Sharc::ConstructBOXDetector(G4LogicalVolume* world){
       ///////////////////////////////////////////////////////////////////////////////////
       // Place the detector in the world
       // Position of the center of the PCB
-      //  G4double Exposed_Length= BOX_Wafer_Length + BOX_PCB_Slot_Border + BOX_PCB_Slot_Width;
-      //  G4double DetectorOffset= -0.5*(BOX_PCB_Length-Exposed_Length);
-      /*FIXME*///////////////////////////////////////////
       G4ThreeVector DetectorPosition =
-      G4ThreeVector(0,Box_Wafer_Offset.y(),0);
+      G4ThreeVector(-BOX_CenterOffset1,-Box_Wafer_Offset.y(),0);
 
       // Distance of the PCB to the target
       G4ThreeVector DetectorSpacing =
-      -G4ThreeVector(0, 0,Box_Wafer_Offset.y()+BOX_PCB_Slot_Position );
+        -G4ThreeVector(0, 0,BOX_Exposed_Length1*0.5);
 
       // If a PAD is present, DSSD is not in the center of the Slot:
       G4ThreeVector PAD_OFFSET=-G4ThreeVector(0.5*PAD_PCB_Thickness,0,0);
-- 
GitLab