From e01538603b1d92fd1afe48e1cbaebdf6ec29c5b8 Mon Sep 17 00:00:00 2001 From: Dave Gaskell Date: Tue, 7 May 2024 08:41:43 -0400 Subject: [PATCH] Add simulation of pions in HMS/SHMS collimators --- Makefile | 4 +- dbase.f | 11 ++- hms/mc_hms.f | 84 +++++++++++++++-------- hms/mc_hms_coll.f | 147 ++++++++++++++++++++++++++++++++++++++++ hms/pion_coll_absorb.f | 95 ++++++++++++++++++++++++++ hms/struct_hms.inc | 4 +- shms/mc_shms.f | 122 +++++++++++++++++++++------------ shms/mc_shms_coll.f | 149 +++++++++++++++++++++++++++++++++++++++++ shms/struct_shms.inc | 4 +- simc.f | 5 +- simulate.inc | 3 +- 11 files changed, 547 insertions(+), 81 deletions(-) create mode 100644 hms/mc_hms_coll.f create mode 100644 hms/pion_coll_absorb.f create mode 100644 shms/mc_shms_coll.f diff --git a/Makefile b/Makefile index 34e73c01..b02f62d6 100644 --- a/Makefile +++ b/Makefile @@ -30,11 +30,11 @@ OBJ3 = semi_physics.o rho_physics.o rho_decay.o generate_rho.o trg_track.o se OBJ4 = results_write.o event.o call_ranlux.o jacobians.o F1F2IN21_v1.0.o OBJ5 = $(A)musc.o $(A)musc_ext.o $(A)project.o $(A)transp.o OBJ6 = $(A)rotate_haxis.o $(A)rotate_vaxis.o $(A)locforunt.o -OBJ7 = $(H)mc_hms.o $(H)mc_hms_hut.o $(H)mc_hms_recon.o +OBJ7 = $(H)mc_hms.o $(H)mc_hms_hut.o $(H)mc_hms_recon.o $(H)pion_coll_absorb.o $(H)mc_hms_coll.o OBJ8 = $(S)mc_sos.o $(S)mc_sos_hut.o $(S)mc_sos_recon.o OBJ9 = $(R)mc_hrsr.o $(R)mc_hrsr_hut.o $(R)mc_hrsr_recon.o OBJA = $(L)mc_hrsl.o $(L)mc_hrsl_hut.o $(L)mc_hrsl_recon.o -OBJB = $(SH)mc_shms.o $(SH)mc_shms_hut.o $(SH)mc_shms_recon.o +OBJB = $(SH)mc_shms.o $(SH)mc_shms_hut.o $(SH)mc_shms_recon.o $(SH)mc_shms_coll.o OBJC = $(T)Ctq5Pdf.o OBJD = $(C)mc_calo.o $(C)mc_calo_recon.o OBJCH = $(CH)lfit.o $(CH)ranlux.o $(CH)fint.o $(CH)kerset.o $(CH)abend.o diff --git a/dbase.f b/dbase.f index af0e0c2e..30760407 100644 --- a/dbase.f +++ b/dbase.f @@ -825,12 +825,12 @@ subroutine dbase_read(H) if (hadron_arm.eq.electron_arm) then write(6,*) '**WARNING: SIMC works best with two DIFFERENT spectrometers!!!' else if ((hadron_arm+electron_arm).eq.3) then - write(6,*) 'Rolf welcomes you to Hall C at Jefferson Lab - Get to work!' + write(6,*) 'Welcome time traveler to Hall C at 6 GeV - Get to work!' else if (electron_arm.eq.5 .or. hadron_arm.eq.5 .or. > electron_arm.eq.6 .or. hadron_arm.eq.6) then - write(6,*) 'Grumpy Dutch Giant welcomes you to Hall C++ at JLab12 - Get to work!' + write(6,*) 'Welcome to Hall C++ at JLab12 - Get to work!' else if ((hadron_arm+electron_arm).eq.7) then - write(6,*) 'Kees welcomes you to Hall A at Jefferson Lab - Enjoy your stay!' + write(6,*) 'Welcome to Hall A at Jefferson Lab - Enjoy your stay!' else if ( electron_arm.eq.7 .and. hadron_arm .eq. 5) then write(6,*) ' Bigcal and SHMS' else if ( electron_arm.eq.8 .and. hadron_arm .eq. 1) then @@ -852,6 +852,9 @@ subroutine dbase_read(H) > Implmemented for beam and scattered electron only!' if (.not.correct_Eloss) write(6,*) 'NOTE: Will NOT correct reconstructed data for energy loss' if (.not.correct_raster) write(6,*) 'NOTE: Will NOT use raster terms in reconstruction' + if (using_HMScoll) write(6,*) 'NOTE: including pion scattering in HMS collimator' + if (using_SHMScoll) write(6,*) 'NOTE: including pion scattering in SHMS collimator' + return end @@ -970,6 +973,8 @@ subroutine regallvars() ierr = regparmint('using_Eloss',using_Eloss,0) ierr = regparmint('correct_Eloss',correct_eloss,0) ierr = regparmint('correct_raster',correct_raster,0) + ierr = regparmint('using_HMScoll',using_HMScoll,0) + ierr = regparmint('using_SHMScoll',using_SHMScoll,0) ierr = regparmint('deForest_flag',deForest_flag,0) ierr = regparmint('rad_flag',rad_flag,0) ierr = regparmint('extrad_flag',extrad_flag,0) diff --git a/hms/mc_hms.f b/hms/mc_hms.f index 586d7e4d..c2f5638c 100644 --- a/hms/mc_hms.f +++ b/hms/mc_hms.f @@ -1,6 +1,7 @@ subroutine mc_hms (p_spec, th_spec, dpp, x, y, z, dxdz, dydz, > x_fp, dx_fp, y_fp, dy_fp, m2, - > ms_flag, wcs_flag, decay_flag, resmult, fry, ok_spec, pathlen) + > ms_flag, wcs_flag, decay_flag, resmult, fry, ok_spec, pathlen, + > using_HMScoll) C+______________________________________________________________________________ ! @@ -130,6 +131,12 @@ subroutine mc_hms (p_spec, th_spec, dpp, x, y, z, dxdz, dydz, real*8 grnd +C DJG stuff for HMS collimator + real*8 save_Hcollsuccess, save_Scollsuccess + logical Hcollsuccess, Hcoll_flag + logical using_HMScoll + common /save_coll/ save_Hcollsuccess, save_Scollsuccess + ! Gaby's dipole shape stuff logical hit_dipole external hit_dipole @@ -193,35 +200,58 @@ subroutine mc_hms (p_spec, th_spec, dpp, x, y, z, dxdz, dydz, ! Check front of fixed slit. zdrift = z_entr call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project and decay - if (abs(ys-y_off).gt.h_entr) then - hSTOP_slit_hor = hSTOP_slit_hor + 1 - goto 500 - endif - if (abs(xs-x_off).gt.v_entr) then - hSTOP_slit_vert = hSTOP_slit_vert + 1 - goto 500 - endif - if (abs(xs-x_off).gt. (-v_entr/h_entr*abs(ys-y_off)+3*v_entr/2)) then - hSTOP_slit_oct = hSTOP_slit_oct + 1 - goto 500 - endif + +*------------------------------------------------------ +c SECTION ADDED FOR HMS COLLIMATOR + if (using_HMScoll .and. (m2.gt.100.0**2) .and.(m2.lt.200.0**2)) then ! check for pions/muons, if yes step through coll. + +c write(*,*)'m2=',m2 +c write(*,*)'mpi2 =',mpi2 +c write(*,*)'-----------------------' +c write(*,*) 'I found a pion',p + call mc_hms_coll(m2,p,p_spec,decay_flag,dflag,Hcollsuccess,Hcoll_flag,pathlen) +! save_Hcollsuccess=1.25 +c write(*,*) 'TH - SANITY CHECK',Hcollsuccess,p + + if(.not.Hcollsuccess) then + save_Hcollsuccess=1.5 + hSTOP_coll = hSTOP_coll + 1 + goto 500 + endif + + else !just apertures at front and back +*------------------------------------------------------ + + if (abs(ys-y_off).gt.h_entr) then + hSTOP_slit_hor = hSTOP_slit_hor + 1 + goto 500 + endif + if (abs(xs-x_off).gt.v_entr) then + hSTOP_slit_vert = hSTOP_slit_vert + 1 + goto 500 + endif + if (abs(xs-x_off).gt. (-v_entr/h_entr*abs(ys-y_off)+3*v_entr/2)) then + hSTOP_slit_oct = hSTOP_slit_oct + 1 + goto 500 + endif !Check back of fixed slit. - zdrift = z_exit-z_entr - call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project and decay - if (abs(ys-y_off).gt.h_exit) then - hSTOP_slit_hor = hSTOP_slit_hor + 1 - goto 500 - endif - if (abs(xs-x_off).gt.v_exit) then - hSTOP_slit_vert = hSTOP_slit_vert + 1 - goto 500 - endif - if (abs(xs-x_off).gt. (-v_exit/h_exit*abs(ys-y_off)+3*v_exit/2)) then - hSTOP_slit_oct = hSTOP_slit_oct + 1 - goto 500 - endif + zdrift = z_exit-z_entr + call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project and decay + if (abs(ys-y_off).gt.h_exit) then + hSTOP_slit_hor = hSTOP_slit_hor + 1 + goto 500 + endif + if (abs(xs-x_off).gt.v_exit) then + hSTOP_slit_vert = hSTOP_slit_vert + 1 + goto 500 + endif + if (abs(xs-x_off).gt. (-v_exit/h_exit*abs(ys-y_off)+3*v_exit/2)) then + hSTOP_slit_oct = hSTOP_slit_oct + 1 + goto 500 + endif + endif !check on collimator simulation ! Go to Q1 IN mag bound. Drift rather than using COSY matrices diff --git a/hms/mc_hms_coll.f b/hms/mc_hms_coll.f new file mode 100644 index 00000000..d6f6cb34 --- /dev/null +++ b/hms/mc_hms_coll.f @@ -0,0 +1,147 @@ + subroutine mc_hms_coll(m2,p,p_spec,decay_flag,dflag,success, + - coll_flag,pathlen) +CDJG Subroutine to step a particle "through" the collimator,checking for +CDJG energy loss, multiple scattering. If particle doesn't make it (too +CDJG much energy loss for example), returns .FALSE. + +! TH - collimator thickness ~6.3 cm. He uses 20 steps for some reason +! TH Why not..seems ok. Note that keep going even if the particle +! TH is outside entrance specs. + + implicit none + include 'apertures_hms.inc' + include 'struct_hms.inc' + include '../spectrometers.inc' + + real*8 m2,p,p_spec + logical decay_flag, dflag,success,coll_flag + real*8 grnd + real*8 h_entr,h_exit,v_entr,v_exit + real*8 x_off,y_off,z_off + + parameter (h_entr = 4.575) + parameter (v_entr = 11.646) + parameter (h_exit = 4.759) + parameter (v_exit = 12.114) + + parameter (x_off = 0.000) + parameter (y_off = +0.028) + parameter (z_off = +40.17) + + integer nstep + parameter(nstep=20) + + real*8 coll_thick,coll_dens,zcoll,acoll,coll_radl,coll_radw + real*8 pathlen + parameter(coll_thick = 6.30) + parameter(coll_dens = 17.0) + parameter(zcoll = 69.45) + parameter(acoll = 171.56797) + parameter(coll_radl = 0.41753) + + real*8 step_size,h_step,v_step + logical step_flag + logical slit_h_flag,slit_v_flag,slit_o_flag,rantemp_flag,epart_flag + + real*8 epart,trans,eloss_tot,eloss,rantemp + real*8 thick,thick_temp + integer n + + eloss_tot=0. + eloss=0. + + step_size = 6.30/nstep + + coll_flag = .FALSE. + success = .FALSE. + + slit_h_flag = .FALSE. + slit_v_flag = .FALSE. + slit_o_flag = .FALSE. + rantemp_flag = .FALSE. + epart_flag = .FALSE. + + h_step = h_entr + v_step = v_entr + + epart = sqrt(p**2+m2) + +C Now start stepping +C Check aperture, if part. hits collimator, do multiple scattering,eloss +C for next step and then project. + do n=1,nstep + step_flag = .FALSE. + if (abs(ys-y_off).gt.h_step) then + coll_flag = .TRUE. + step_flag = .TRUE. + hSTOP_slit_hor = hSTOP_slit_hor + 1 + slit_h_flag = .TRUE. + thick_temp = step_size + endif + if (abs(xs-x_off).gt.v_step) then + coll_flag = .TRUE. + step_flag = .TRUE. + hSTOP_slit_vert = hSTOP_slit_vert + 1 + slit_v_flag = .TRUE. + thick_temp=step_size + endif + if (abs(xs-x_off).gt.(-v_step/h_step*abs(ys-y_off)+3*v_step/2)) then + coll_flag = .TRUE. + step_flag = .TRUE. + hSTOP_slit_oct = hSTOP_slit_oct + 1 + slit_o_flag = .TRUE. + thick_temp = step_size + endif + + thick = thick_temp + +C If we hit the collimator, check for hadronic reaction, do eloss, mult. scat. for first step + if(step_flag) then + +c TH - un-comment the following line if want no collimator punch through! +c goto 500 + + if(m2.gt.12000. .and. m2.lt.20000.) then !check if pion - if muon, don't check for hadronic interaction + call pion_coll_absorb(p,thick,trans) + rantemp = grnd() + if(rantemp.gt.trans) then + rantemp_flag = .TRUE. + goto 500 + endif + endif + coll_radw = thick/coll_radl +! TH - some adjustment here for multiple scattering test +c call musc(m2,p,coll_radw,thick,dydzs,dxdzs) + call musc(m2,p,coll_radw,dydzs,dxdzs) + epart = sqrt(p**2+m2) + call enerloss_new(thick,coll_dens,zcoll,acoll,epart, + $ sqrt(m2),1,eloss) + epart = epart - eloss + eloss_tot = eloss_tot + eloss + if(epart.lt.sqrt(m2)) then + epart_flag = .TRUE. + goto 500 + endif + p = sqrt(epart**2-m2) + dpps = 100.*(p/p_spec - 1.) + endif + + call project(xs,ys,step_size,decay_flag,dflag,m2,p,pathlen) !drift and decay + + h_step = h_step + (h_exit-h_entr)/nstep + v_step = v_step + (v_exit-v_entr)/nstep +c write(6,*) 'step,eloss',n,eloss,step_flag,pathlen + enddo + + success = .TRUE. + + 500 continue +c write(6,*) 'step,eloss',n,eloss_tot,success,coll_flag,step_flag,xs,ys +c if (.not.success) then +c write(6,*) rantemp_flag,trans,epart_flag,eloss,slit_h_flag,slit_v_flag,slit_o_flag +c endif +c write(6,*) 'leaving collimator...',p,success,coll_flag,step_flag +c if (abs(xs).gt.0.5 .or. abs(ys).gt.0.5) write(6,*) 'xy ',xs,ys + + return + end diff --git a/hms/pion_coll_absorb.f b/hms/pion_coll_absorb.f new file mode 100644 index 00000000..9843bd70 --- /dev/null +++ b/hms/pion_coll_absorb.f @@ -0,0 +1,95 @@ + subroutine pion_coll_absorb(ppi,thick,transmission) +c Subroutine to calculate probability that pion will be absorbed in the SOS +c collimator - can be used for HMS assuming same geometry applies. TH - checked that. + +C DJG For now, I use the "reaction" cross sections. Also, only implemented for +C DJG pi+ - no pi-. + +! TH - cross section from Dave's parameterization of the energy and A dependence up to +! TH pion momenta of ~ 2 GeV, we extended that to > 2 GeV during Fpi analysis + + implicit none + + real*8 Ppi,Epi,Tpi,mpi !pion kinematics + real*8 Navagadro + parameter(Navagadro = 6.0221367d+23) + parameter(mpi = 139.56995) + + real*8 mate_dens + real*8 mate_t + real*8 mate_A + real*8 T(14),sigreac(14),qreac(14) + + real*8 sighi,siglo,qhi,qlo,transmission,lambdai,thick + real*8 Tlo,Thi,sigA,sigAlo,sigAhi,sum + + integer i + + +! TH - DG original + TH extension for > 2GeV + data T /85.0,125.0,165.0,205.0,245.0,315.0,584.02,711.95,870.12, + > 1227.57,1446.58,1865.29,2858.0,4159.0/ + +CCCCCCCCCC TOTAL CROSS SECTIONS CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC +! data sigreac /170.12,189.49,178.61,158.11,116.9,85.86,55.5,55.5, +! > 55.5,55.5,55.5,55.5,55.5,55.5/ +! data qreac /0.59980,0.5753,0.58046,0.59842,0.65218,0.69421,.779 +! > ,.779,.779,.779,.779,.779,0.779,0.779/ +CCCCCCCCCCCCC REACTION CROSS SECTIONS CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC +! TH - DG Original + TH extension for > 2GeV + data sigreac /26.03,84.47,117.3,117.4,101.9,69.58,42.5,44.7,47.9, + > 46.5,45.2,39.6,35.34,33.15/ + data qreac /0.948,0.659,0.56,0.5342,0.5452,0.60796,0.699,0.689, + > 0.679,0.683,0.688,0.704,0.7483,0.7705/ +CCCCCCCCCCCCC ABSORPTION(?) CROSS SECTIONS CCCCCCCCCCCCCCCCCCCCCCCCCCC +c data sigreac /8.81,25.57,29.57,30.245,15.63,8.302,4.98,4.98,4.98, +c > 4.98,4.98,4.98/ +c data qreac /0.986,0.763,0.744,0.679,0.762,0.6506,0.75,0.75, +c > 0.75,0.75,0.75,0.75/ + +c data sigreac_minus /25.0,100.0,120.,110.0,100.0,80.0/ +c data qreac_minus /0.97,0.60,0.52,0.50,0.53,0.60/ + + + mate_dens = 17.0 !Collimator density (g/cm^3) + mate_t = 6.35 !Total aluminum seen by pion(cm) + mate_A = 171.57 + + Epi = sqrt(Ppi**2+mpi**2) + Tpi = Epi - mpi + + sigA = 0.0 +c do i = 1,14 +c GH changed this to 13, there are only 14 elements, so the T(i+1) check should fail for i=14 + do i = 1,13 + if((Tpi.gt.T(i)).and.(Tpi.le.T(i+1))) then + Thi = T(i+1) + Tlo = T(i) + sighi = sigreac(i+1) + siglo = sigreac(i) + qhi = qreac(i+1) + qlo = qreac(i) + + sigAhi = sighi*mate_A**qhi + sigAlo = siglo*mate_A**qlo + sigA = (sigAlo*(Thi-Tpi) + sigAhi*(Tpi-Tlo))/(Thi-Tlo) + sigA = sigA*1.d-27 !convert to cm^2 + endif + enddo +c GH if pion kinetic energy is greater than T(14)=4159 MeV, then use T(14) parameters + if (Tpi.gt.T(14)) then + sigA = sigreac(14)*mate_A**qreac(14) + sigA = sigA*1.d-27 +c write(6,*)' coll: pion K.E. limit ',Tpi + endif + + sum = 0.0 + + lambdai = mate_dens*Navagadro*sigA/mate_A + sum = sum + thick*lambdai + transmission = exp(-sum) + + end + + + diff --git a/hms/struct_hms.inc b/hms/struct_hms.inc index 1df8fa14..ddc606c7 100644 --- a/hms/struct_hms.inc +++ b/hms/struct_hms.inc @@ -29,6 +29,7 @@ integer*4 hSTOP_D1_in,hSTOP_D1_out integer*4 hSTOP_hut,hSTOP_dc1,hSTOP_dc2 integer*4 hSTOP_scin,hSTOP_cal,hSTOP_successes + integer*4 hSTOP_coll ! HMS COLLIMATOR common/spectrometer1/ hSTOP_trials, > hSTOP_slit_hor,hSTOP_slit_vert,hSTOP_slit_oct, @@ -37,4 +38,5 @@ > hSTOP_Q3_in,hSTOP_Q3_mid,hSTOP_Q3_out, > hSTOP_D1_in,hSTOP_D1_out, > hSTOP_hut,hSTOP_dc1,hSTOP_dc2, - > hSTOP_scin,hSTOP_cal,hSTOP_successes + > hSTOP_scin,hSTOP_cal,hSTOP_successes, + > hSTOP_coll diff --git a/shms/mc_shms.f b/shms/mc_shms.f index abfbd7ff..3bd5d031 100755 --- a/shms/mc_shms.f +++ b/shms/mc_shms.f @@ -1,7 +1,7 @@ subroutine mc_shms(p_spec, th_spec, dpp, x, y, z, dxdz, dydz, > x_fp,dx_fp,y_fp,dy_fp,m2, > ms_flag, wcs_flag, decay_flag, resmult, fry, ok_spec, - > pathlen, spectr) + > pathlen, spectr, using_SHMScoll) C+______________________________________________________________________________ ! @@ -48,7 +48,6 @@ subroutine mc_shms(p_spec, th_spec, dpp, x, y, z, dxdz, dydz, parameter (r_d = 180./pi) parameter (root = 0.707106781) !square root of 1/2 - ! Option for mock sieve slit. Just take particles and forces trajectory ! to put the event in the nearest hole. Must choose the "No collimator" ! values for the h(v)_entr and h(v)_exit values. @@ -227,6 +226,16 @@ subroutine mc_shms(p_spec, th_spec, dpp, x, y, z, dxdz, dydz, logical ok_hut +C GH stuff for SHMS collimator + real*8 save_Hcollsuccess, save_Scollsuccess + logical Scollsuccess, Scoll_flag + logical using_SHMScoll + common /save_coll/ save_Hcollsuccess, save_Scollsuccess + +! Gaby's dipole shape stuff + logical hit_dipole + external hit_dipole + ! TH - start sieve logical check_sieve real*8 xlocal,ylocal @@ -322,7 +331,6 @@ subroutine mc_shms(p_spec, th_spec, dpp, x, y, z, dxdz, dydz, x_transp =xs y_transp =ys - C Read in transport coefficients. Choose tune-dependent parameters. if (first_time_here) then if (spectr.eq.5) then @@ -344,10 +352,8 @@ subroutine mc_shms(p_spec, th_spec, dpp, x, y, z, dxdz, dydz, C Begin transporting particle. - C Do transformations, checking against apertures. - !---------------------------------------------------------------------------- ! TH - START COLLIMATOR APERTURE TESTS ! --------------------------------------------------------------------------- @@ -490,50 +496,78 @@ subroutine mc_shms(p_spec, th_spec, dpp, x, y, z, dxdz, dydz, spec(7)=xt spec(8)=yt endif -! simulate collimator ------------------------------------------------- - if (use_coll) then -c tpathlen=pathlen + +*------------------------------------------------------ +c GH collimator routine including pion/muon scattering based on Fpi-2 code + + if (using_SHMScoll .and. (m2.gt.100.0**2).and.(m2.lt.200.0**2)) then ! check for pions/muons, if yes step through coll. + zdrift = z_entr - call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project -c xt=xs + zdrift*dxdzs -c yt=ys + zdrift*dydzs - xt=xs - yt=ys - if (abs(yt-y_off).gt.h_entr) then - shmsSTOP_slit_hor = shmsSTOP_slit_hor + 1 - goto 500 - endif - if (abs(xt-x_off).gt.v_entr) then - shmsSTOP_slit_vert = shmsSTOP_slit_vert + 1 + call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project and decay + +c write(*,*)'m2=',m2 +c write(*,*)'mpi2 =',mpi2 +c write(*,*)'-----------------------' +c write(*,*) 'I found a pion',p + call mc_shms_coll(m2,p,p_spec,decay_flag,dflag,Scollsuccess,Scoll_flag,pathlen) +! save_Scollsuccess=1.25 +c write(*,*) 'TH - SANITY CHECK',Scollsuccess,p + + if(.not.Scollsuccess) then + save_Scollsuccess=1.5 + sSTOP_coll = sSTOP_coll + 1 goto 500 endif - if (abs(xt-x_off).gt. (-v_entr/h_entr*abs(yt-y_off)+3*v_entr/2)) then - shmsSTOP_slit_oct = shmsSTOP_slit_oct + 1 - goto 500 - endif - zdrift = z_thick - call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project -c xt=xt + zdrift*dxdzs -c yt=yt + zdrift*dydzs - xt=xs - yt=ys - if (abs(yt-y_off).gt.(h_exit)) then - shmsSTOP_slit_hor = shmsSTOP_slit_hor + 1 - goto 500 - endif - if (abs(xt-x_off).gt.(v_exit)) then - shmsSTOP_slit_vert = shmsSTOP_slit_vert + 1 - goto 500 - endif - if (abs(xt-x_off).gt. ((-v_exit)/(h_exit)*abs(yt-y_off)+3*(v_exit)/2)) then - shmsSTOP_slit_oct = shmsSTOP_slit_oct + 1 - goto 500 + + else !just apertures at front and back + +! collimator aperture check ------------------------------------------------- + if (use_coll) then + zdrift = z_entr + call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project +c xt=xs + zdrift*dxdzs +c yt=ys + zdrift*dydzs + xt=xs + yt=ys + if (abs(yt-y_off).gt.h_entr) then + shmsSTOP_slit_hor = shmsSTOP_slit_hor + 1 + goto 500 + endif + if (abs(xt-x_off).gt.v_entr) then + shmsSTOP_slit_vert = shmsSTOP_slit_vert + 1 + goto 500 + endif + if (abs(xt-x_off).gt. (-v_entr/h_entr*abs(yt-y_off)+3*v_entr/2)) then + shmsSTOP_slit_oct = shmsSTOP_slit_oct + 1 + goto 500 + endif + zdrift = z_thick + call project(xs,ys,zdrift,decay_flag,dflag,m2,p,pathlen) !project +c xt=xt + zdrift*dxdzs +c yt=yt + zdrift*dydzs + xt=xs + yt=ys + if (abs(yt-y_off).gt.(h_exit)) then + shmsSTOP_slit_hor = shmsSTOP_slit_hor + 1 + goto 500 + endif + if (abs(xt-x_off).gt.(v_exit)) then + shmsSTOP_slit_vert = shmsSTOP_slit_vert + 1 + goto 500 + endif + if (abs(xt-x_off).gt. ((-v_exit)/(h_exit)*abs(yt-y_off)+3*(v_exit)/2)) then + shmsSTOP_slit_oct = shmsSTOP_slit_oct + 1 + goto 500 + endif + spec(56)=xt + spec(57)=yt +c pathlen=tpathlen endif - spec(56)=xt - spec(57)=yt -c pathlen=tpathlen - endif ! --------------------------------------------------------------------------- + + endif ! GH check on pions/muons in collimator + +*------------------------------------------------------ ! Go to Q1 IN Mech entrance if(use_coll) then diff --git a/shms/mc_shms_coll.f b/shms/mc_shms_coll.f new file mode 100644 index 00000000..5ec7127e --- /dev/null +++ b/shms/mc_shms_coll.f @@ -0,0 +1,149 @@ + subroutine mc_shms_coll(m2,p,p_spec,decay_flag,dflag,success, + - coll_flag,pathlen) +CDJG Subroutine to step a particle "through" the collimator,checking for +CDJG energy loss, multiple scattering. If particle doesn't make it (too +CDJG much energy loss for example), returns .FALSE. + +c GH 2024.04.05 +c GH code is based on mc_hms_coll.f used in Fpi-2 +c GH SHMS collimator dimensions taken from drawing 67238-00006 + + implicit none + include 'apertures_shms.inc' + include 'struct_shms.inc' + include '../spectrometers.inc' + + real*8 m2,p,p_spec + logical decay_flag, dflag,success,coll_flag + real*8 grnd + real*8 h_entr,h_exit,v_entr,v_exit + real*8 x_off,y_off,z_off + +! horiz. and vert. 1/2 gap of aperture + parameter (h_entr = 8.50) + parameter (v_entr = 12.50) + parameter (h_exit = 8.65) + parameter (v_exit = 12.85) + + parameter (x_off = 0.000) + parameter (y_off = +0.000) + parameter (z_off = +25.189) ! z_entr from mc_shms.f + + integer nstep + parameter(nstep=20) + + real*8 coll_thick,coll_dens,zcoll,acoll,coll_radl,coll_radw + real*8 pathlen + parameter(coll_thick = 6.35) + parameter(coll_dens = 17.0) + parameter(zcoll = 69.45) + parameter(acoll = 171.56797) + parameter(coll_radl = 0.42084) ! HMS radl scaled by 6.35/6.30 + + real*8 step_size,h_step,v_step + logical step_flag + logical slit_h_flag,slit_v_flag,slit_o_flag,rantemp_flag,epart_flag + + real*8 epart,trans,eloss_tot,eloss,rantemp + real*8 thick,thick_temp + integer n + + eloss_tot=0. + eloss=0. + + step_size = 6.35/nstep + + coll_flag = .FALSE. + success = .FALSE. + + slit_h_flag = .FALSE. + slit_v_flag = .FALSE. + slit_o_flag = .FALSE. + rantemp_flag = .FALSE. + epart_flag = .FALSE. + + h_step = h_entr + v_step = v_entr + + epart = sqrt(p**2+m2) + +C Now start stepping +C Check aperture, if particle hits collimator, do multiple scattering,eloss +C for next step and then project. + + do n=1,nstep + step_flag = .FALSE. + if (abs(ys-y_off).gt.h_step) then + coll_flag = .TRUE. + step_flag = .TRUE. + shmsSTOP_slit_hor = shmsSTOP_slit_hor + 1 + slit_h_flag = .TRUE. + thick_temp = step_size + endif + if (abs(xs-x_off).gt.v_step) then + coll_flag = .TRUE. + step_flag = .TRUE. + shmsSTOP_slit_vert = shmsSTOP_slit_vert + 1 + slit_v_flag = .TRUE. + thick_temp=step_size + endif + if (abs(xs-x_off).gt.(-v_step/h_step*abs(ys-y_off)+3*v_step/2)) then + coll_flag = .TRUE. + step_flag = .TRUE. + shmsSTOP_slit_oct = shmsSTOP_slit_oct + 1 + slit_o_flag = .TRUE. + thick_temp = step_size + endif + + thick = thick_temp + +C If we hit the collimator, check for hadronic reaction, do eloss, mult. scat. for first step + if(step_flag) then + +c TH - un-comment the following line if want no collimator punch through! +c goto 500 + + if(m2.gt.12000. .and. m2.lt.20000.) then !check if pion - if muon, don't check for hadronic interaction + call pion_coll_absorb(p,thick,trans) + rantemp = grnd() + if(rantemp.gt.trans) then + rantemp_flag = .TRUE. + goto 500 + endif + endif + coll_radw = thick/coll_radl +! TH - some adjustment here for multiple scattering test +c call musc(m2,p,coll_radw,thick,dydzs,dxdzs) + call musc(m2,p,coll_radw,dydzs,dxdzs) + epart = sqrt(p**2+m2) + call enerloss_new(thick,coll_dens,zcoll,acoll,epart, + $ sqrt(m2),1,eloss) + epart = epart - eloss + eloss_tot = eloss_tot + eloss + if(epart.lt.sqrt(m2)) then + epart_flag = .TRUE. + goto 500 + endif + p = sqrt(epart**2-m2) + dpps = 100.*(p/p_spec - 1.) + endif + + call project(xs,ys,step_size,decay_flag,dflag,m2,p,pathlen) !drift and decay + + h_step = h_step + (h_exit-h_entr)/nstep + v_step = v_step + (v_exit-v_entr)/nstep +c write(6,*) 'step,eloss',n,eloss,step_flag,pathlen + enddo + + success = .TRUE. + + 500 continue +c write(6,*) 'step,eloss',n,eloss_tot,success,coll_flag,step_flag,xs,ys +c if (.not.success) then +c write(6,*) rantemp_flag,trans,epart_flag,eloss,slit_h_flag,slit_v_flag,slit_o_flag +c endif +c write(6,*) 'leaving collimator...',p,success,coll_flag,step_flag +c if (abs(xs).gt.0.5 .or. abs(ys).gt.0.5) write(6,*) 'xy ',xs,ys + + return + end diff --git a/shms/struct_shms.inc b/shms/struct_shms.inc index 141639cb..38fae717 100755 --- a/shms/struct_shms.inc +++ b/shms/struct_shms.inc @@ -21,6 +21,7 @@ integer*4 shmsSTOP_s1,shmsSTOP_s2,shmsSTOP_s3,shmsSTOP_cal integer*4 shmsSTOP_cer1,shmsSTOP_cer2 integer*4 stop_id + integer*4 sSTOP_coll ! SHMS COLLIMATOR common/spectrometer_shms/ shmsSTOP_trials,shmsSTOP_successes, > shmsSTOP_targ_hor,shmsSTOP_targ_vert,shmsSTOP_targ_oct, @@ -39,4 +40,5 @@ > shmsSTOP_BP_in,shmsSTOP_BP_out, > shmsSTOP_hut,shmsSTOP_dc1,shmsSTOP_dc2, > shmsSTOP_cer1,shmsSTOP_cer2, - > shmsSTOP_s1,shmsSTOP_s2,shmsSTOP_s3,shmsSTOP_cal,stop_id + > shmsSTOP_s1,shmsSTOP_s2,shmsSTOP_s3,shmsSTOP_cal,stop_id, + > sSTOP_coll diff --git a/simc.f b/simc.f index 001f69d1..88a4e678 100644 --- a/simc.f +++ b/simc.f @@ -1449,7 +1449,7 @@ subroutine montecarlo(orig,main,recon,success) call mc_hms(spec%p%P, spec%p%theta, delta_P_arm, x_P_arm, > y_P_arm, z_P_arm, dx_P_arm, dy_P_arm, xfp, dxfp, yfp, dyfp, > m2, mc_smear, mc_smear, doing_decay, - > ntup%resfac, xtar_init_P, ok_P_arm, pathlen) + > ntup%resfac, xtar_init_P, ok_P_arm, pathlen, using_HMScoll) else if (hadron_arm.eq.2) then call mc_sos(spec%p%P, spec%p%theta, delta_P_arm, x_P_arm, > y_P_arm, z_P_arm, dx_P_arm, dy_P_arm, xfp, dxfp, yfp, dyfp, @@ -1469,7 +1469,8 @@ subroutine montecarlo(orig,main,recon,success) call mc_shms(spec%p%P, spec%p%theta, delta_P_arm, x_P_arm, > y_P_arm, z_P_arm, dx_P_arm, dy_P_arm, xfp, dxfp, yfp, dyfp, > m2, mc_smear, mc_smear, doing_decay, - > ntup%resfac, xtar_init_P, ok_P_arm, pathlen, hadron_arm) + > ntup%resfac, xtar_init_P, ok_P_arm, pathlen, hadron_arm, + > using_SHMScoll) endif diff --git a/simulate.inc b/simulate.inc index cae5946c..68f1b9be 100644 --- a/simulate.inc +++ b/simulate.inc @@ -73,6 +73,7 @@ logical correct_Eloss, correct_raster,do_fermi logical using_tgt_field integer*4 electron_arm, hadron_arm, use_first_cer + logical using_HMScoll, using_SHMScoll real*8 transparency logical use_benhar_sf character*80 random_state_file @@ -95,7 +96,7 @@ > doing_semipi, doing_semika, doing_hplus, which_kaon, > which_pion, using_cit_generation, using_Coulomb, using_Eloss, > correct_Eloss, correct_raster, do_fermi,using_tgt_field, - > electron_arm, hadron_arm, use_first_cer, + > electron_arm, hadron_arm, use_first_cer, using_HMScoll, using_SHMScoll, > transparency, use_benhar_sf,start_random_state_file, > random_state_file, random_seed