~maddevelopers/mg5amcnlo/3.0.2-alpha0

« back to all changes in this revision

Viewing changes to Template/SubProcesses/driver.f

Added Template and HELAS into bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      Program DRIVER
 
2
c**************************************************************************
 
3
c     This is the driver for the whole calulation
 
4
c**************************************************************************
 
5
      implicit none
 
6
C
 
7
C     CONSTANTS
 
8
C
 
9
      double precision zero
 
10
      parameter       (ZERO = 0d0)
 
11
      include 'genps.inc'
 
12
      include 'nexternal.inc'
 
13
      INTEGER    ITMAX,   NCALL
 
14
C
 
15
C     LOCAL
 
16
C
 
17
      integer i,ninvar,nconfigs,j,l,l1,l2,ndim
 
18
      double precision dsig,tot,mean,sigma
 
19
      integer npoints,lunsud
 
20
      double precision x,y,jac,s1,s2,xmin
 
21
      external dsig
 
22
      character*130 buf
 
23
      integer NextUnopen
 
24
      external NextUnopen
 
25
c
 
26
c     Global
 
27
c
 
28
      integer                                      nsteps
 
29
      character*40          result_file,where_file
 
30
      common /sample_status/result_file,where_file,nsteps
 
31
      integer           Minvar(maxdim,lmaxconfigs)
 
32
      common /to_invar/ Minvar
 
33
      real*8          dsigtot(10)
 
34
      common/to_dsig/ dsigtot
 
35
      integer ngroup
 
36
      common/to_group/ngroup
 
37
      data ngroup/0/
 
38
cc
 
39
      include 'run.inc'
 
40
      
 
41
      integer           mincfig, maxcfig
 
42
      common/to_configs/mincfig, maxcfig
 
43
 
 
44
 
 
45
      double precision twgt, maxwgt,swgt(maxevents)
 
46
      integer                             lun, nw
 
47
      common/to_unwgt/twgt, maxwgt, swgt, lun, nw
 
48
 
 
49
c--masses
 
50
      double precision pmass(nexternal)
 
51
      common/to_mass/  pmass
 
52
      double precision qmass(2)
 
53
      common/to_qmass/  qmass
 
54
 
 
55
c     $B$ new_def $E$  this is a tag for MadWeigth, Don't edit this line
 
56
 
 
57
c      double precision xsec,xerr
 
58
c      integer ncols,ncolflow(maxamps),ncolalt(maxamps),ic
 
59
c      common/to_colstats/ncols,ncolflow,ncolalt,ic
 
60
 
 
61
      include 'coupl.inc'
 
62
 
 
63
C-----
 
64
C  BEGIN CODE
 
65
C-----  
 
66
c
 
67
c     Read process number
 
68
c
 
69
      open (unit=lun+1,file='../dname.mg',status='unknown',err=11)
 
70
      read (lun+1,'(a130)',err=11,end=11) buf
 
71
      l1=index(buf,'P')
 
72
      l2=index(buf,'_')
 
73
      if(l1.ne.0.and.l2.ne.0.and.l1.lt.l2-1)
 
74
     $     read(buf(l1+1:l2-1),*,err=11) ngroup
 
75
 11   print *,'Process in group number ',ngroup
 
76
 
 
77
      lun = 27
 
78
      twgt = -2d0            !determine wgt after first iteration
 
79
      open(unit=lun,status='scratch')
 
80
      nsteps=2
 
81
      call setrun                !Sets up run parameters
 
82
c     $B$ setpara $B$ ! this is a tag for MadWeight. Don't edit this line
 
83
      call setpara('param_card.dat',.true.)   !Sets up couplings and masses
 
84
c     $E$ setpara $E$ ! this is a tag for MadWeight. Don't edit this line
 
85
      include 'pmass.inc'        !Sets up particle masses
 
86
      include 'qmass.inc'        !Sets up particle masses inside onium state
 
87
      call setcuts               !Sets up cuts 
 
88
      call printout              !Prints out a summary of paramaters
 
89
      call run_printout          !Prints out a summary of the run settings
 
90
      nconfigs = 1
 
91
 
 
92
c   If CKKW-type matching, read IS Sudakov grid
 
93
      if(ickkw.eq.2 .and. (lpp(1).ne.0.or.lpp(2).ne.0))then
 
94
        lunsud=NextUnopen()
 
95
        open(unit=lunsud,file=issgridfile,status='old',ERR=20)
 
96
        goto 40
 
97
 20     issgridfile='lib/'//issgridfile
 
98
        do i=1,5
 
99
          open(unit=lunsud,file=issgridfile,status='old',ERR=30)          
 
100
          exit
 
101
 30       issgridfile='../'//issgridfile
 
102
          if(i.eq.5)then
 
103
            print *,'ERROR: No Sudakov grid file found in lib with ickkw=2'
 
104
            stop
 
105
          endif
 
106
        enddo
 
107
        print *,'Reading Sudakov grid file ',issgridfile
 
108
 40     call readgrid(lunsud)
 
109
        print *,'Done reading IS Sudakovs'
 
110
      endif
 
111
        
 
112
      if(ickkw.eq.2)then
 
113
        hmult=.false.
 
114
        if(ngroup.ge.nhmult) hmult=.true.
 
115
        if(hmult)then
 
116
          print *,'Running CKKW as highest mult sample'
 
117
        else
 
118
          print *,'Running CKKW as lower mult sample'
 
119
        endif
 
120
      endif
 
121
 
 
122
c     
 
123
c     Get user input
 
124
c
 
125
      write(*,*) "getting user params"
 
126
      call get_user_params(ncall,itmax,mincfig)
 
127
      maxcfig=mincfig
 
128
      minvar(1,1) = 0              !This tells it to map things invarients
 
129
      write(*,*) 'Attempting mappinvarients',nconfigs,nexternal
 
130
      call map_invarients(minvar,nconfigs,ninvar,mincfig,maxcfig,nexternal,nincoming)
 
131
      write(*,*) "Completed mapping",nexternal
 
132
      ndim = 3*(nexternal-2)-4
 
133
      if (abs(lpp(1)) .ge. 1) ndim=ndim+1
 
134
      if (abs(lpp(2)) .ge. 1) ndim=ndim+1
 
135
      ninvar = ndim
 
136
      do j=mincfig,maxcfig
 
137
         if (abs(lpp(1)) .ge. 1 .and. abs(lpp(1)) .ge. 1) then
 
138
            minvar(ndim-1,j)=ninvar-1
 
139
            minvar(ndim,j) = ninvar
 
140
         elseif (abs(lpp(1)) .ge. 1 .or. abs(lpp(1)) .ge. 1) then
 
141
            minvar(ndim,j) = ninvar
 
142
         endif
 
143
      enddo
 
144
      write(*,*) "about to integrate ", ndim,ncall,itmax,ninvar,nconfigs
 
145
      call sample_full(ndim,ncall,itmax,dsig,ninvar,nconfigs)
 
146
c
 
147
c     Now write out events to permanent file
 
148
c
 
149
      if (twgt .gt. 0d0) maxwgt=maxwgt/twgt
 
150
      write(lun,'(a,f20.5)') 'Summary', maxwgt
 
151
      
 
152
      call store_events
 
153
 
 
154
c      write(*,'(a34,20I7)'),'Color flows originally chosen:   ',
 
155
c     &     (ncolflow(i),i=1,ncols)
 
156
c      write(*,'(a34,20I7)'),'Color flows according to diagram:',
 
157
c     &     (ncolalt(i),i=1,ncols)
 
158
c
 
159
c      call sample_result(xsec,xerr)
 
160
c      write(*,*) 'Final xsec: ',xsec
 
161
 
 
162
      rewind(lun)
 
163
 
 
164
      close(lun)
 
165
      end
 
166
 
 
167
c     $B$ get_user_params $B$ ! tag for MadWeight
 
168
c     change this routine to read the input in a file
 
169
c
 
170
      subroutine get_user_params(ncall,itmax,iconfig)
 
171
c**********************************************************************
 
172
c     Routine to get user specified parameters for run
 
173
c**********************************************************************
 
174
      implicit none
 
175
c
 
176
c     Constants
 
177
c
 
178
      include 'nexternal.inc'
 
179
c
 
180
c     Arguments
 
181
c
 
182
      integer ncall,itmax,iconfig, jconfig
 
183
c
 
184
c     Local
 
185
c
 
186
      integer i, j
 
187
      double precision dconfig
 
188
c
 
189
c     Global
 
190
c
 
191
      integer           isum_hel
 
192
      logical                   multi_channel
 
193
      common/to_matrix/isum_hel, multi_channel
 
194
      double precision    accur
 
195
      common /to_accuracy/accur
 
196
      integer           use_cut
 
197
      common /to_weight/use_cut
 
198
 
 
199
      integer        lbw(0:nexternal)  !Use of B.W.
 
200
      common /to_BW/ lbw
 
201
 
 
202
c-----
 
203
c  Begin Code
 
204
c-----
 
205
      write(*,'(a)') 'Enter number of events and iterations: '
 
206
      read(*,*) ncall,itmax
 
207
      write(*,*) 'Number of events and iterations ',ncall,itmax
 
208
      write(*,'(a)') 'Enter desired fractional accuracy: '
 
209
      read(*,*) accur
 
210
      write(*,*) 'Desired fractional accuracy: ',accur
 
211
 
 
212
      write(*,'(a)') 'Enter 0 for fixed, 2 for adjustable grid: '
 
213
      read(*,*) use_cut
 
214
      if (use_cut .lt. 0 .or. use_cut .gt. 2) then
 
215
         write(*,*) 'Bad choice, using 2',use_cut
 
216
         use_cut = 2
 
217
      endif
 
218
 
 
219
      write(*,10) 'Suppress amplitude (0 no, 1 yes)? '
 
220
      read(*,*) i
 
221
      if (i .eq. 1) then
 
222
         multi_channel = .true.
 
223
         write(*,*) 'Using suppressed amplitude.'
 
224
      else
 
225
         multi_channel = .false.
 
226
         write(*,*) 'Using full amplitude.'
 
227
      endif
 
228
 
 
229
      write(*,10) 'Exact helicity sum (0 yes, n = number/event)? '
 
230
      read(*,*) i
 
231
      if (i .eq. 0) then
 
232
         isum_hel = 0
 
233
         write(*,*) 'Explicitly summing over helicities'
 
234
      else
 
235
         isum_hel= i
 
236
         write(*,*) 'Summing over',i,' helicities/event'
 
237
      endif
 
238
 
 
239
      write(*,10) 'Enter Configuration Number: '
 
240
      read(*,*) dconfig
 
241
      iconfig = int(dconfig)
 
242
      write(*,12) 'Running Configuration Number: ',iconfig
 
243
c
 
244
c     Here I want to set up with B.W. we map and which we don't
 
245
c
 
246
      dconfig = dconfig-iconfig
 
247
      if (dconfig .eq. 0) then
 
248
         write(*,*) 'Not subdividing B.W.'
 
249
         lbw(0)=0
 
250
      else
 
251
         lbw(0)=1
 
252
         jconfig=dconfig*1000.1
 
253
         write(*,*) 'Using dconfig=',jconfig
 
254
         call DeCode(jconfig,lbw(1),3,nexternal)
 
255
         write(*,*) 'BW Setting ', (lbw(j),j=1,nexternal-2)
 
256
c         do i=nexternal-3,0,-1
 
257
c            if (jconfig .ge. 2**i) then
 
258
c               lbw(i+1)=1
 
259
c               jconfig=jconfig-2**i
 
260
c            else
 
261
c               lbw(i+1)=0
 
262
c            endif 
 
263
c            write(*,*) i+1, lbw(i+1)
 
264
c         enddo
 
265
      endif
 
266
 10   format( a)
 
267
 12   format( a,i4)
 
268
      end
 
269
c     $E$ get_user_params $E$ ! tag for MadWeight
 
270
c     change this routine to read the input in a file
 
271
c
 
272
 
 
273
 
 
274
 
 
275
 
 
276
 
 
277
 
 
278
 
 
279
 
 
280
 
 
281
 
 
282
 
 
283
 
 
284
 
 
285
 
 
286
 
 
287