From fbeab2a6edbf797684466b980f1f86399885814c Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Tue, 30 Apr 2019 13:02:24 -0500
Subject: [PATCH] SIMC now correctly reads the z vertex position from the input
 file. Compiles but not yet tested

---
 CMakeLists.txt        |  4 ++--
 simc/event.f          |  2 +-
 simc/get_file_event.f | 16 +++++++++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc317fc..638af78 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,8 +6,8 @@
 cmake_minimum_required (VERSION 3.5)
 project (simc)
 set (SIMC_MAJOR_VERSION 0)
-set (SIMC_MINOR_VERSION 1)
-set (SIMC_PATCH_VERSION 1)
+set (SIMC_MINOR_VERSION 2)
+set (SIMC_PATCH_VERSION 0)
 set (SIMC_VERSION 
   ${SIMC_MAJOR_VERSION}.${SIMC_MINOR_VERSION}.${SIMC_PATCH_VERSION})
 set (SIMC_SOVERSION ${SIMC_MAJOR_VERSION})
diff --git a/simc/event.f b/simc/event.f
index 40f6c4c..db9293c 100644
--- a/simc/event.f
+++ b/simc/event.f
@@ -302,7 +302,7 @@ C modified 5/15/06 for poinct
 	   call get_file_event(electron_arm,spec%e%theta,spec%p%theta,
      >       vertex%e%xptar,vertex%e%yptar,vertex%e%p,vertex%e%E,
      >       vertex%p%xptar,vertex%p%yptar,vertex%p%p,vertex%p%E,
-     >       main%gen_weight)
+     >       main%target%z, targ%zoffset, main%gen_weight)
 	     if ( .not. ok_2pi) goto 100
 	     vertex%e%delta = 100.*(vertex%e%P-spec%e%P)/spec%e%P
 	     vertex%p%delta = 100.*(vertex%p%P-spec%p%P)/spec%p%P
diff --git a/simc/get_file_event.f b/simc/get_file_event.f
index 1eceead..fdca549 100644
--- a/simc/get_file_event.f
+++ b/simc/get_file_event.f
@@ -1,5 +1,6 @@
       subroutine get_file_event(e_arm,th_spec_e,th_spec_p,
-     >    dxdz,dydz,e_mom,e_E,dxdzp,dydzp,p_mom,p_E,weight)
+     >    dxdz,dydz,e_mom,e_E,dxdzp,dydzp,p_mom,
+     >    targ_z, targ_zoffset, weight)
 c
 c  input variables:
 c        electron_arm : 1 means HMS is electron arm
@@ -31,6 +32,7 @@ c
          real*8 sth_elec,cth_elec,sth_prot,cth_prot
          real*8 e_mom,e_E,dxdz,dydz,e_vz,SHMS_vz,HMS_vz
          real*8 p_mom,p_E,dxdzp,dydzp,p_vz
+         real*8 targ_z, targ_zoffset
          real*8 w, weight
          character*80 multpifile
          integer count,count_miss
@@ -90,12 +92,20 @@ c --> the HMS is at negative angles, and the SHMS at positive angles
              e_4v(4) = SHMS_4v(4)
             p_4v(4) = HMS_4v(4)
            endif
+cc SIMC only knows of a single vertex position, so even though we read
+cc two values, we only use a single one (they should match anyway in
+cc most cases)
+         targ_z = HMS_vz * 1.
+         if(e_vz * p_vz .gt. 0) then
+           targ_z = e_vz + targ_zoffset
+         endif
 	       if(debug(5)) then
              write(*,*) ' '
              write(*,*) ' NEW EVENT: ',count, weight
-             write(*,*) '       e: ',e_4v(1),e_4v(2),e_4v(3),e_4v(4)
-             write(*,*) '      p: ',p_4v(1),p_4v(2),p_4v(3),p_4v(4)
+             write(*,*) '         e: ',e_4v(1),e_4v(2),e_4v(3),e_4v(4)
+             write(*,*) '         p: ',p_4v(1),p_4v(2),p_4v(3),p_4v(4)
              write(*,*) '    vertex: ',e_vz,p_vz
+             write(*,*) 'SIMC vertex: ',targ_z
 	       endif !debug
 cc Rotatation about the x-axis --> only y, and z change
          e_4vr(1) = e_4v(1)
-- 
GitLab