2
c*****************************************************************************
3
c Program to combine results from all of the different sub amplitudes
4
c and given total cross section and error.
5
c*****************************************************************************
11
parameter (rfile='results.dat')
13
parameter (symfile='symfact.dat')
15
include 'run_config.inc'
16
include 'maxparticles.inc'
17
include 'maxconfigs.inc'
21
integer max_np,min_iter
22
common/max_np/max_np,min_iter
27
double precision xsec(lmaxconfigs), xerr(lmaxconfigs)
28
double precision xerru(lmaxconfigs),xerrc(lmaxconfigs)
29
double precision xmax(lmaxconfigs), eff(lmaxconfigs)
30
double precision xlum(lmaxconfigs)
31
double precision ysec, yerr, yeff, ymax
32
double precision tsec, terr, teff, tmax, xi
33
integer nw(lmaxconfigs), nevents(lmaxconfigs), maxit
34
integer nunwgt(lmaxconfigs)
35
character*80 fname, gname(lmaxconfigs)
37
double precision xtot,errtot,err_goal
38
double precision errtotu,errtotc
39
integer mfact(lmaxconfigs)
40
logical parallel, gen_events
41
character*20 param(maxpara),value(maxpara)
42
integer npara, nreq, ngran, nhel_refine
43
integer ij, kl, ioffset
44
integer*8 iseed !tjs 20/6/2012 to avoid integer overflow
45
logical Gridpack,gridrun
46
logical split_channels
47
common /to_split/split_channels
56
call load_para(npara,param,value)
57
call get_logical(npara,param,value," gridpack ",gridpack,.false.)
58
call get_integer(npara,param,value," nhel ",nhel_refine,0)
59
c If different card options set for nhel_refine and nhel_survey:
60
call get_integer(npara,param,value," nhel_refine ",nhel_refine,
62
if (.not. Gridpack) then
63
write(*,'(a,a)')'Enter fractional accuracy (<1)',
64
& ', or number events (>1), max processes per job',
65
& ', and whether to split channels (T/F)'
66
read(5,*) err_goal, max_np, split_channels
69
if (err_goal .lt. 1) then
70
write(*,'(a,f8.2,a)') 'Running for accuracy of ',
73
elseif (err_goal .gt. 1) then
74
write(*,'(a,f9.0,a)') 'Generating ',err_goal,
75
& ' unweighted events.'
77
err_goal = err_goal * 1.2 !Extra factor to ensure works
79
write(*,*) 'Error, need non_zero goal'
84
split_channels=.false.
85
c Allow all the way down to a single iteration for gridruns
87
call get_integer(npara,param,value," gevents " ,nreq ,2000 )
88
err_goal = 1.2*nreq ! extra factor to ensure works
89
call get_int8(npara,param,value," gseed " ,iseed ,4321 )
90
call get_integer(npara,param,value," ngran " ,ngran , -1)
91
if (ngran.eq.-1) ngran = 1
92
write(*,*) "Running on Grid to generate ",nreq," events"
93
write(*,*) " with granularity equal to ",ngran
96
c Modified to allow for more sequences
97
c iseed can be between 0 and 30081*30081
98
c before patern repeats
99
c JA 11/2/2011: Check for ioffset, as in ntuple (ranmar.f)
100
c TJS 20/6/2012 changed mod value to 30081 to avoid duplicate sequences
102
call get_offset(ioffset)
103
iseed = iseed * 31300
104
ij=1802 + mod(iseed,30081)
105
kl=9373 + (iseed/30081) + ioffset
106
write(*,'($a,i6,a3,i6)') 'Using random seed offset: ',ioffset
107
write(*,*) ' with seed', iseed
108
do while (ij .gt. 31328)
111
do while (kl .gt. 30081)
114
write(*,*) "Using random seeds",ij,kl
117
open(unit=15,file=symfile,status='old',err=999)
123
c ncode is number of digits needed for the bw coding
124
ncode=int(dlog10(3d0)*(max_particles-3))+1
126
read(15,*,err=99,end=99) xi,j
129
k = int(xi*(1+10**(-ncode)))
130
npos=int(dlog10(dble(k)))+1
131
if ( (xi-k) .eq. 0) then
132
c Write with correct number of digits
133
write(formstr,'(a,i1,a)') '(a,i',npos,',a,a)'
134
write(fname, formstr) 'G',k,'/',rfile
136
c Write with correct number of digits
137
write(formstr,'(a,i1,a,i1,a)') '(a,f',npos+ncode+1,
139
write(fname, formstr) 'G',xi,'/',rfile
141
c write(*,*) 'log name ',fname
152
c Read in integration data from run
154
open(unit=25,file=fname,status='old',err=95)
155
read(25,*,err=94,end=94) xsec(i),xerru(i),xerrc(i),nevents(i),nw(i),maxit,
157
if (xsec(i) .eq. 0d0) xlum(i)=1d99 !zero cross section
158
xlum(i) = xlum(i)/1000 !convert to fb^-1
159
xerr(i)=sqrt(xerru(i)**2+xerrc(i)**2)
167
read(25,*,err=92) l,ysec,yerr,yeff,ymax
168
if (k .gt. 1) tmax = max(tmax,ymax)
173
92 maxit = k-1 !In case of error reading file
175
xerr(i)=sqrt(terr)/maxit
180
xsec(i) = xsec(i)*mfact(i)
181
xerr(i) = xerr(i)*mfact(i)
182
xerru(i) = xerru(i)*mfact(i)
183
xerrc(i) = xerrc(i)*mfact(i)
184
xlum(i) = xlum(i)/mfact(i)
186
eff(i)= xerr(i)*sqrt(real(nevents(i)))/(xsec(i)+1d-99)
187
errtotu = errtotu+(xerru(i))**2
188
errtotc = errtotc+(xerrc(i))
189
c xtot = xtot+ xsec(i)*mfact(i)
190
c eff(i)= xerr(i)*sqrt(real(nevents(i)))/xsec(i)
191
c errtot = errtot+(mfact(i)*xerr(i))**2
194
c There was an error reading an existing results.dat file
195
c Stop generation with error message
196
filename='../../error'
197
INQUIRE(FILE="../../RunWeb", EXIST=file_exists)
198
if(.not.file_exists) filename = '../' // filename
199
open(unit=26,file=filename,status='unknown')
200
write(26,*) 'Bad results.dat file for channel ',xi
202
c write(*,*) i,maxit,xsec(i), eff(i)
204
c i=i-1 !This is for case w/ B.W. and optimization
208
errtot=sqrt(errtotc**2+errtotu)
209
if ( .not. gen_events) then
210
call write_bash(xsec,xerru,xerrc,xtot,mfact,err_goal,
211
$ i,nevents,gname,nhel_refine)
213
open(unit=25,file='../results.dat',status='old',err=199)
215
write(*,'(a,e12.3)') 'Reading total xsection ',xtot
218
call write_gen_grid(err_goal,dble(ngran),i,nevents,gname,
219
$ xlum,xtot,mfact,xsec,nhel_refine)
221
call write_gen(err_goal,i,nevents,gname,xlum,xtot,mfact,
222
$ xsec,xerr,nhel_refine)
226
999 write(*,*) 'error'
230
subroutine write_bash(xsec,xerru,xerrc,xtot,
231
$ mfact,err_goal,ng,jpoints,gn,nhel_refine)
232
c*****************************************************************************
233
c Writes out bash commands for running each channel as needed.
234
c*****************************************************************************
239
include 'run_config.inc'
240
include 'maxconfigs.inc'
243
c parameter (max_np = 30)
247
integer max_np,min_iter
248
common/max_np/max_np,min_iter
252
double precision xsec(lmaxconfigs), xerru(lmaxconfigs),xerrc(lmaxconfigs)
253
double precision err_goal,xtot
254
integer mfact(lmaxconfigs),jpoints(lmaxconfigs),nhel_refine
256
character*(80) gn(lmaxconfigs)
260
integer i,j,k, io(lmaxconfigs), npoints, ip, np
261
double precision xt(lmaxconfigs),elimit
262
double precision yerr,ysec,rerr
270
if (mfact(j) .gt. 0) k=k+1
272
xt(j)= sqrt((xerru(j)+xerrc(j)**2)*mfact(j)) !sort by error
275
c Let's redetermine err_goal based on luminosity
277
write(*,*) 'Cross section pb',xtot
278
write(*,*) 'Desired Goal',err_goal
279
write(*,*) 'Total Error',err_goal
280
c elimit = err_goal*xtot/sqrt(real(k)) !Equal contributions from each
281
elimit = err_goal*xtot/real(k) !Equal contributions from each
286
do while( xt(k) .gt. abs(elimit)) !abs is just in case elimit<0 by mistake
292
c rerr = rerr+xt(j)**2
296
c write(*,*) 'Number of diagrams to fix',k
298
c Now readjust because most don't contribute
300
elimit = sqrt((err_goal*xtot)**2 - rerr)/sqrt(real(k))
306
c yerr = xerr(io(i))*mfact(io(i))
308
c write(*,*) i,xt(i),elimit
309
if (yerr .gt. elimit) then
311
ysec = xsec(io(i)) + yerr
312
npoints=(0.2d0)*jpoints(io(i))*(yerr/elimit)**2
313
npoints = max(npoints,min_events)
314
npoints = min(npoints,max_events)
315
c np = np + 3*npoints
317
if (np .gt. max_np) then
319
call close_bash_file(26)
322
call open_bash_file(26)
327
ip = index(gn(io(i)),'/')
328
write(*,*) 'Channel ',gn(io(i))(2:ip-1),
329
$ yerr, jpoints(io(i)),npoints
331
ip = index(gn(io(i)),'/')
332
write(26,'(2a)') 'j=',gn(io(i))(1:ip-1)
334
c Determine estimates for getting the desired accuracy
338
c Now write the commands
340
write(26,20) 'if [[ ! -e $j ]]; then'
341
write(26,25) 'mkdir $j'
344
write(26,20) 'rm -f $k'
345
c write(26,20) 'rm -f moffset.dat'
347
write(26,'(5x,a,3i8,a)') 'echo "',npoints,max_iter,min_iter,
348
$ '" >& input_sg.txt'
349
write(26,'(5x,a,f8.3,a)') 'echo "',max(elimit/ysec,0.001d0),
350
$ '" >> input_sg.txt'
351
write(26,'(5x,a)') 'echo "2" >> input_sg.txt' !Grid
352
write(26,'(5x,a)') 'echo "1" >> input_sg.txt' !Suppress
353
write(26,'(5x,a,i4,a)') 'echo "',nhel_refine,
354
& '" >> input_sg.txt' !Helicity
355
write(26,'(5x,3a)')'echo "',gn(io(i))(2:ip-1),
357
write(26,20) '../madevent >> $k <input_sg.txt'
358
write(26,20) 'rm ftn25 ftn26'
359
write(26,20) 'cat $k >> log.txt'
360
write(26,20) 'cd ../'
362
enddo !Loop over diagrams
364
call close_bash_file(26)
374
subroutine open_bash_file(lun)
375
c***********************************************************************
376
c Opens bash file for looping including standard header info
377
c which can be used with pbs, or stand alone
378
c***********************************************************************
383
include 'run_config.inc'
401
c Write ic with correct number of digits
402
npos=int(dlog10(dble(ic)))+1
403
write(formstr,'(a,i1,a)') '(I',npos,')'
404
write(fname(5:(5+npos-1)),formstr) ic
406
write(*,*) 'Opening file ',fname
407
open (unit=26, file = fname, status='unknown')
408
write(26,15) '#!/bin/bash'
409
c write(26,15) '#PBS -q ' // PBS_QUE
410
c write(26,15) '#PBS -o /dev/null'
411
c write(26,15) '#PBS -e /dev/null'
412
c write(26,15) 'if [[ "$PBS_O_WORKDIR" != "" ]]; then'
413
c write(26,15) ' cd $PBS_O_WORKDIR'
415
write(26,15) 'k=run1_app.log'
416
write(lun,15) 'script=' // fname
417
c write(lun,15) 'rm -f wait.$script >& /dev/null'
418
c write(lun,15) 'touch run.$script'
422
subroutine close_bash_file(lun)
423
c***********************************************************************
425
c***********************************************************************
445
c write(lun,'(a)') ')'
447
c Now write the commands
449
c write(lun,20) 'j=G$i'
450
c write(lun,20) 'if (! -e $j) then'
451
c write(lun,25) 'mkdir $j'
452
c write(lun,20) 'endif'
453
c write(lun,20) 'cd $j'
454
c write(lun,20) 'rm -f ftn25 ftn99'
455
c write(lun,20) 'rm -f $k'
456
c write(lun,20) 'cat ../input_app.txt >& input_app.txt'
457
c write(lun,20) 'echo $i >> input_app.txt'
459
c write(lun,20) 'cp ../../public.sh .'
460
c write(lun,20) 'qsub -N $1$i public.sh >> ../../running_jobs'
462
c write(lun,20) '../madevent > $k <input_app.txt'
463
c write(lun,20) 'rm -f ftn25 ftn99'
464
c write(lun,20) 'cp $k log.txt'
466
c write(lun,20) 'cd ../'
467
c write(lun,15) 'end'
468
c write(lun,15) 'rm -f run.$script >&/dev/null'
469
c write(lun,15) 'touch done.$script >&/dev/null'
478
subroutine write_gen(goal_lum,ng,jpoints,gn,xlum,xtot,mfact,xsec,
480
c*****************************************************************************
481
c Writes out scripts for achieving unweighted event goals
482
c*****************************************************************************
487
include 'run_config.inc'
488
include 'maxconfigs.inc'
492
integer max_np,min_iter
493
common/max_np/max_np,min_iter
494
c integer max_np !now set in run_config.inc
495
c parameter (max_np = 5) !number of channels/job
500
double precision goal_lum, xlum(lmaxconfigs), xsec(lmaxconfigs),xtot
501
double precision xerr(lmaxconfigs)
502
integer jpoints(lmaxconfigs), mfact(lmaxconfigs)
503
integer ng, np, nhel_refine
504
character*(80) gn(lmaxconfigs)
508
integer i,j,k,kk, io(lmaxconfigs), npoints, ip, nfiles,ifile,npfile
509
double precision xt(lmaxconfigs+1),elimit
510
double precision yerr,ysec,rerr
513
integer mjobs,ijob,jc
516
logical split_channels
517
common /to_split/split_channels
519
data cjobs/"abcdefghijklmnopqrstuvwxyz"/
525
write(*,*) 'Working on creating ', goal_lum, ' events.'
526
goal_lum = goal_lum/(xtot*1000) !Goal luminosity in fb^-1
527
write(*,*) 'Effective Luminosity', goal_lum, ' fb^-1.'
531
xt(j)= goal_lum/(xlum(j)+1d-99) !sort by events_needed/have.
532
write(*,*) j,xlum(j),xt(j)
534
c write(*,*) 'Number of channels',ng,k
536
c Reset multijob.dat for all channels
538
jc = index(gn(j),"/")
539
fname = gn(j)(1:jc)// "multijob.dat"
540
write(*,*) 'Resetting ' // fname
541
open(unit=15,file=fname,status="unknown",err=10)
546
c Let's redetermine err_goal based on luminosity
552
do while( xt(k) .gt. abs(elimit)) !elimit should be >0
553
write(*,*) 'Improving ',k,gn(io(k)),xt(k)
557
c Check error for the rest of the channels - rerun if
558
c bigger than channel xsec and bigger than 1% of largest channel
559
do while( kk .le. ng)
560
if (xerr(io(kk)).gt.max(xsec(io(kk)),0.01*xsec(io(1)))) then
561
write(*,*) 'Improving for error ',kk,gn(io(kk)),xt(kk),xsec(io(kk)),xerr(io(kk))
569
write(*,*) 'Number of diagrams to fix',k
571
c Now readjust because most don't contribute
577
c Want to write channels so that heaviest one (with largest error)
578
c gets grouped with least heavy channels. Complicated ordering for this
579
c follows. np is the present process number.
582
if(mod(k,max_np).gt.0) nfiles=nfiles+1
590
npoints=0.2*jpoints(io(np))*(yerr/elimit)
591
npoints = max(npoints,min_events)
592
npoints = min(npoints,max_events)
595
c np = nfiles*npfile+1-ifile !Fancy order for combining channels removed 12/6/2010 by tjs
599
c Add loop to allow for multiple jobs on a single channel
601
mjobs = (goal_lum*xsec(io(np))*1000 / MaxEventsPerJob + 0.9)
602
c write(*,*) "Working on Channel ",i,io(np),xt(np), goal_lum*xsec(io(np))*1000 /maxeventsperjob
603
if (mjobs .gt. 26) then
604
write(*,*) 'Error in gen_ximprove.f, too many events requested ',mjobs*maxeventsperjob
607
if (mjobs .lt. 1 .or. .not. split_channels) mjobs=1
609
c write multijob.dat file for combine_runs.f
611
jc = index(gn(io(np)),"/")
612
fname = gn(io(np))(1:jc)// "multijob.dat"
613
c write(*,*) "Writing file ", fname
614
open(unit=15,file=fname,status="unknown",err=11)
615
if (mjobs .gt. 1) then
625
if (npfile .gt. max_np .or. ifile.eq.0 .or. mjobs .gt. 1) then
627
call close_bash_file(26)
630
call open_bash_file(26)
633
c if (ijob .eq. 1) np = ifile !Only increment once / source channel
635
ip = index(gn(io(np)),'/')
636
write(*,*) 'Channel ',gn(io(np))(2:ip-1),
637
$ yerr, jpoints(io(np)),npoints
639
ip = index(gn(io(np)),'/')
640
if (mjobs .gt. 1) then
641
write(26,'(3a)') 'j=',gn(io(np))(1:ip-1),cjobs(ijob:ijob)
643
write(26,'(3a)') 'j=',gn(io(np))(1:ip-1)
646
c Now write the commands
648
write(26,20) 'if [[ ! -e $j ]]; then'
649
write(26,25) 'mkdir $j'
652
write(26,20) 'rm -f $k'
653
write(26,20) 'rm -f moffset.dat >& /dev/null'
654
write(26,*) ' echo ',ijob, ' > moffset.dat'
660
c Now I'll add a check to make sure the grid has been
661
c adjusted (ftn99 or ftn25 exist)
663
write(26,20) 'if [[ -e ftn26 ]]; then'
664
write(26,25) 'cp ftn26 ftn25'
667
write(26,20) 'if [[ ! -e ftn25 ]]; then'
670
write(26,'(9x,a,3i8,a)') 'echo "',npoints,max_iter,min_iter,
671
$ '" >& input_sg.txt'
673
c tjs 8/7/2007-JA 8/17/11 Allow stop when have enough luminocity
675
write(*,*) "Cross section",i,io(np),xsec(io(np)),mfact(io(np))
676
write(26,'(9x,a,e13.5,a)') 'echo "',-goal_lum*1000/mjobs,
677
$ '" >> input_sg.txt' !Luminocity
678
write(26,'(9x,a)') 'echo "2" >> input_sg.txt' !Grid Adjustment
679
write(26,'(9x,a)') 'echo "1" >> input_sg.txt' !Suppression
680
write(26,'(9x,a,i4,a)') 'echo "',nhel_refine,
681
& ' " >> input_sg.txt' !Helicity 0=exact
682
write(26,'(9x,3a)')'echo "',gn(io(np))(2:ip-1),
684
write(26,25) '../madevent >> $k <input_sg.txt'
685
write(26,25) 'cat $k >> log.txt'
686
write(26,25) 'if [[ -e ftn26 ]]; then'
687
write(26,25) ' cp ftn26 ftn25'
691
write(26,25) 'rm -f $k'
693
write(26,'(9x,a,3i8,a)') 'echo "',npoints,max_iter,min_iter,
694
$ '" >& input_sg.txt'
696
c tjs 8/7/2007-JA 8/17/11 Change to request luminocity not accuracy
698
write(26,'(9x,a,e13.5,a)') 'echo "',-goal_lum*1000/mjobs,
699
$ '" >> input_sg.txt' !Luminocity
700
c write(26,'(9x,a,e12.3,a)') 'echo "',-goal_lum*mfact(io(np)),
701
c $ '" >> input_sg.txt'
702
write(26,'(9x,a)') 'echo "0" >> input_sg.txt'
703
write(26,'(9x,a)') 'echo "1" >> input_sg.txt'
705
write(26,'(9x,a,i4,a)') 'echo "',nhel_refine,
706
& ' " >> input_sg.txt' !Helicity 0=exact
708
write(26,'(9x,3a)')'echo "',gn(io(np))(2:ip-1),
712
c write(26,'(9x,a)') 'echo "1" >> input_sg.txt' !Helicity 0=exact
714
c write(26,'(5x,3a)')'echo "',gn(io(np))(2:ip-1),
715
c $ '" >>input_sg.txt'
716
c write(26,20) 'cp ../../public_sg.sh .'
717
c write(26,20) 'qsub -N $1$j public_sg.sh >> ../../running_jobs'
718
write(26,25) 'if [[ -e ftn26 ]]; then'
719
write(26,25) ' cp ftn26 ftn25'
721
write(26,25) '../madevent >> $k <input_sg.txt'
722
write(26,25) 'cat $k >> log.txt'
724
write(26,20) 'cd ../'
726
c tjs end loop over split process
728
enddo !(ijob, split channel)
730
enddo !(k each channel)
732
call close_bash_file(26)
742
subroutine write_gen_grid(goal_lum,ngran,ng,jpoints,gn,xlum,xtot,mfact,xsec,nhel_refine)
743
c*****************************************************************************
744
c Writes out scripts for achieving unweighted event goals
745
c*****************************************************************************
750
include 'run_config.inc'
751
include 'maxconfigs.inc'
755
integer max_np,min_iter
756
common/max_np/max_np,min_iter
760
double precision goal_lum, xlum(lmaxconfigs), xsec(lmaxconfigs),xtot
761
double precision ngran !Granularity.... min # points from channel
762
integer jpoints(lmaxconfigs), mfact(lmaxconfigs)
763
integer ng, np, nhel_refine
764
character*(80) gn(lmaxconfigs)
768
integer i,j,k, npoints, ip
769
double precision xt(lmaxconfigs),elimit
770
double precision yerr,ysec,rerr
773
double precision rvec
781
c These random #'s should be changed w/ run
786
write(*,*) 'Working on creating ', goal_lum, ' events.'
788
np = max_np !Flag to open csh file
791
ip = index(gn(i),'/')
792
fname = gn(i)(1:ip) // 'gscalefact.dat'
793
open(unit=27,file=fname,status='unknown',err=91)
794
if (goal_lum * xsec(i)/xtot .ge. rvec*ngran ) then !need events
795
write(*,*) 'Requesting events from ',gn(i)(1:ip-1),xsec(i),xtot/goal_lum
796
if (xsec(i) .gt. xtot*ngran/goal_lum) then
799
write(27,*) xtot*ngran/xsec(i)/goal_lum
801
npoints = goal_lum * xsec(i) / xtot
802
if (npoints .lt. ngran) npoints = ngran
804
if (np .gt. max_np) then
806
call close_bash_file(26)
809
call open_bash_file(26)
812
ip = index(gn(i),'/')
813
write(*,*) 'Channel ',gn(i)(2:ip-1), goal_lum * xsec(i) / xtot,
816
ip = index(gn(i),'/')
817
write(26,'(2a)') 'j=',gn(i)(1:ip-1)
819
c Now write the commands
821
write(26,20) 'if [[ ! -e $j ]]; then'
822
write(26,25) 'mkdir $j'
825
write(26,20) 'rm -f $k'
827
c Now I'll add a check to make sure the grid has been
828
c adjusted (ftn99 or ftn25 exist)
830
write(26,20) 'if [[ -e ftn26 ]]; then'
831
write(26,25) 'cp ftn26 ftn25'
834
write(26,20) 'if [[ ! -e ftn25 ]]; then'
837
write(26,'(9x,a,3i8,a)') 'echo "',max(npoints,min_events),
838
$ max_iter,min_iter,'" >& input_sg.txt'
840
c tjs 8/7/2007 Allow stop when have enough events
842
write(*,*) "Cross section",i,xsec(i),mfact(i)
843
write(26,'(9x,a,e13.5,a)') 'echo "',-npoints/xsec(i),
844
$ '" >> input_sg.txt' !Luminocity
845
write(26,'(9x,a)') 'echo "2" >> input_sg.txt' !Grid Adjustment
846
write(26,'(9x,a)') 'echo "1" >> input_sg.txt' !Suppression
847
write(26,'(9x,a,i4,a)') 'echo "',nhel_refine,
848
& ' " >> input_sg.txt' !Helicity 0=exact
849
write(26,'(9x,3a)')'echo "',gn(i)(2:ip-1),
851
write(26,25) '../madevent >> $k <input_sg.txt'
852
write(26,25) 'cat $k >> log.txt'
853
write(26,25) 'if [[ -e ftn26 ]]; then'
854
write(26,25) ' cp ftn26 ftn25'
858
write(26,25) 'rm -f $k'
860
write(26,'(9x,a,3i8,a)') 'echo "',max(npoints,min_events),
861
$ max_iter,min_iter,'" >& input_sg.txt'
863
c tjs 8/7/2007 Change to request events not accuracy
865
write(26,'(9x,a,e13.5,a)') 'echo "',-npoints / xsec(i),
866
$ '" >> input_sg.txt' ! Luminocity
867
write(26,'(9x,a)') 'echo "0" >> input_sg.txt'
868
write(26,'(9x,a)') 'echo "1" >> input_sg.txt'
870
write(26,'(9x,a,i4,a)') 'echo "',nhel_refine,
871
& ' " >> input_sg.txt' !Helicity 0=exact
873
write(26,'(9x,3a)')'echo "',gn(i)(2:ip-1),
876
write(26,25) 'if [[ -e ftn26 ]]; then'
877
write(26,25) ' cp ftn26 ftn25'
879
write(26,25) '../madevent >> $k <input_sg.txt'
880
write(26,25) 'cat $k >> log.txt'
882
write(26,20) 'cd ../'
883
else !No events from this channel
884
write(*,*) 'Skipping channel:',gn(i)(1:ip-1),xsec(i)*goal_lum/xtot,rvec
890
call close_bash_file(26)
899
subroutine sort2(array,aux1,n)
904
double precision array(n)
907
double precision temp
916
if (array(k) .lt. array(k+1)) then
918
array(k) = array(k+1)
931
subroutine get_xsec_log(xsec,xerr,eff,xmax)
932
c*********************************************************************
933
c Reads from output file, gets cross section and maxwgt from
934
c first two iterations
935
c*********************************************************************
940
double precision xsec(2),xerr(2),eff(2),xmax(2)
953
read(25,'(a80)',err=99) buff
954
if (buff(1:4) .eq. 'Iter') then
955
read(buff(11:16),'(i5)') i
956
if (i .eq. 1 .or. i .eq. 2) then
957
read(buff(61:70),*) xmax(i)
958
read(buff(21:33),*) xsec(i)
959
xmax(i)=xmax(i)/xsec(i)
960
c read(buff(48:59),*) xerr(i)
961
c read(buff(48:59),*) xmax(i)
963
read(25,'(a80)',err=99) buff
964
read(buff(1:6),'(i5)') i
965
if (i .eq. 1 .or. i .eq. 2) then
966
read(buff(6:17),*) xsec(i)
967
read(buff(20:31),*) xerr(i)
968
read(buff(34:40),*) eff(i)
970
write(*,'(i4,4f12.3)') i,xsec(i),xerr(i),eff(i),xmax(i)