subroutine fillfqzbsbank(fillstatus) implicit none #include "spliTChanOut.h" #include "fitqunout.h" integer ndata, fillstatus parameter(ndata=3000) integer idata(ndata) real rdata(ndata) INTEGER MSDATA(NDATA) equivalence(idata(1),rdata(1)) integer i, ipx, ix, itest, ise, ierr, index, imethod, ipeak integer idx1, idx2, idx3, idx4, itype, ntype integer ibase1, ibase2, ibase3, ibase4, icount integer nwmast, nsegm, lsegm, lsegm_per_px, nvars integer idum, LBANK INTEGER II character*20 bankformat c begin user code c zebra bank for Sub-Event Cluster information CALL KZBLOC('FITQUNCLST',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNCLST bank' CALL KZBDEL('FITQUNCLST') ENDIF idata(1) = cluster_ncand nwmast = 1 nsegm = cluster_ncand nvars = 5 lsegm = nvars + npeakfinds + 2*maxse*npeakfinds c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNCLST',nwmast,'1I',nsegm,lsegm,'2F 1I 1F 1I 4I 60I 60F',IERR) ! 60's should correspond to maxse*npeakfinds c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNCLST',0,nwmast,idata(1)) do ise=1,cluster_ncand rdata(1) = cluster_tstart(ise) rdata(2) = cluster_tend(ise) idata(3) = cluster_nhits(ise) rdata(4) = cluster_totq(ise) idata(nvars) = cluster_goodflag(ise) do imethod=1,npeakfinds idata(nvars+imethod) = cluster_npeaks(imethod,ise) do ipeak=1,maxse index = nvars + npeakfinds + (imethod-1)*maxse + ipeak if (ipeak.le.cluster_npeaks(imethod,ise)) then idata(index) = cluster_ipeak(ipeak,imethod,ise) rdata(index+maxse*npeakfinds) = cluster_timeofpeak(ipeak,imethod,ise) else idata(index) = 0 rdata(index+maxse*npeakfinds) = 0 endif enddo enddo CALL KZREP1('FITQUNCLST',ise,lsegm,idata) enddo c zebra bank for Sub-Event Muechk peak information CALL KZBLOC('FITQUNMUEC',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNMUEC bank' CALL KZBDEL('FITQUNMUEC') ENDIF idata(1) = npeakfinds nwmast = 1 nsegm = npeakfinds lsegm = 1+6*maxse c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNMUEC',nwmast,'1I',nsegm,lsegm,'1I 10F 10I 10F 10F 10F 10I',IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNMUEC',0,nwmast,idata(1)) do imethod=1,npeakfinds idata(1) = muechk_ncand(imethod) do ipeak=1,maxse index = 1 + ipeak if (ipeak.le.muechk_ncand(imethod)) then rdata(index+0*maxse) = muechk_tpeak(ipeak,imethod) idata(index+1*maxse) = muechk_bg(ipeak,imethod) rdata(index+2*maxse) = muechk_mean(ipeak,imethod) rdata(index+3*maxse) = muechk_excess(ipeak,imethod) rdata(index+4*maxse) = muechk_signif(ipeak,imethod) idata(index+5*maxse) = muechk_icluster(ipeak,imethod) else rdata(index+0*maxse) = 0 idata(index+1*maxse) = 0 rdata(index+2*maxse) = 0 rdata(index+3*maxse) = 0 rdata(index+4*maxse) = 0 idata(index+5*maxse) = 0 end if end do CALL KZREP1('FITQUNMUEC',imethod,lsegm,idata) enddo c zebra bank for time window information CALL KZBLOC('FITQUNTWND',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNTWND bank' CALL KZBDEL('FITQUNTWND') ENDIF idata(1) = maxnpeak idata(2) = fqntwnd rdata(3) = trgoff nwmast = 3 nsegm = fqntwnd lsegm = 8+2*maxnpeak write (bankformat,'(A2,I5,A1)') '2I', lsegm-2, 'F' c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNTWND',nwmast,'2I 1F',nsegm,lsegm,bankformat,IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNTWND',0,nwmast,idata(1)) do ise=1,fqntwnd idata(1) = fqtwnd_iclstr(ise) idata(2) = fqtwnd_npeak(ise) rdata(3) = fqtwnd_prftt0(ise) rdata(4) = fqtwnd_prftpos(1,ise) rdata(5) = fqtwnd_prftpos(2,ise) rdata(6) = fqtwnd_prftpos(3,ise) rdata(7) = fqtwnd(1,ise) rdata(8) = fqtwnd(2,ise) ibase1 = 8 ibase2 = ibase1+maxnpeak do ix=1,maxnpeak rdata(ibase1+ix) = fqtwnd_peakt0(ix,ise) rdata(ibase2+ix) = fqtwnd_peakiness(ix,ise) enddo CALL KZREP1('FITQUNTWND',ise,lsegm,idata) enddo c zebra bank for 1 ring fits CALL KZBLOC('FITQUN1R',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUN1R bank' CALL KZBDEL('FITQUN1R') ENDIF idata(1) = maxpx idata(2) = fqnse nwmast = 2 nsegm = fqnse lsegm_per_px = 12 lsegm = lsegm_per_px*maxpx write (bankformat,'(I1,A1,I3,A7)') maxpx, 'I', lsegm, 'F 1F 4I 3F' c write (*,*) '1R bank format=', bankformat lsegm = maxpx+lsegm+8 c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUN1R',nwmast,'2I',nsegm,lsegm,bankformat,IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUN1R',0,nwmast,idata(1)) do ise=1,fqnse do ipx=1,maxpx index = maxpx+(ipx - 1)*lsegm_per_px idata(ipx) = fq1rpcflg(ipx,ise) rdata(index+1) = fq1rmom(ipx,ise) rdata(index+2) = fq1rt0(ipx,ise) rdata(index+3) = fq1rtotmu(ipx,ise) rdata(index+4) = fq1rnll(ipx,ise) ibase1 = index+4 ibase2 = index+7 do ix=1,3 rdata(ibase1+ix) = fq1rpos(ix,ipx,ise) rdata(ibase2+ix) = fq1rdir(ix,ipx,ise) enddo rdata(index+11) = fq1rdconv(ipx,ise) rdata(index+12) = fq1reloss(ipx,ise) enddo rdata(lsegm-7) = fqq50(ise) idata(lsegm-6) = fqn50(ise) idata(lsegm-5) = fqitwnd(ise) idata(lsegm-4) = fqipeak(ise) idata(lsegm-3) = fqnhitpmt(ise) rdata(lsegm-2) = fqtotq(ise) rdata(lsegm-1) = fq0rtotmu(ise) rdata(lsegm) = fq0rnll(ise) CALL KZREP1('FITQUN1R',ise,lsegm,idata) enddo c pi0 fit zebra bank CALL KZBLOC('FITQUNPI0',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNPI0 bank' CALL KZBDEL('FITQUNPI0') ENDIF ntype = 2 nwmast = 1 nsegm = ntype lsegm = 23 idata(1) = ntype c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNPI0',nwmast,'1I',nsegm,lsegm,'1I 22F',IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNPI0',0,nwmast,idata(1)) do itype=1,2 idata(1) = fqpi0pcflg(itype) rdata(2) = fqpi0mom1(itype) rdata(3) = fqpi0mom2(itype) rdata(4) = fqpi0momtot(itype) rdata(5) = fqpi0dconv1(itype) rdata(6) = fqpi0dconv2(itype) rdata(7) = fqpi0t0(itype) rdata(8) = fqpi0totmu(itype) rdata(9) = fqpi0nll(itype) rdata(10) = fqpi0mass(itype) rdata(11) = fqpi0photangle(itype) ibase1 = 11 ibase2 = ibase1 + 3 ibase3 = ibase2 + 3 ibase4 = ibase3 + 3 do ix=1,3 rdata(ibase1+ix) = fqpi0pos(ix,itype) rdata(ibase2+ix) = fqpi0dir1(ix,itype) rdata(ibase3+ix) = fqpi0dir2(ix,itype) rdata(ibase4+ix) = fqpi0dirtot(ix,itype) enddo CALL KZREP1('FITQUNPI0',itype,lsegm,idata) enddo c zebra bank for multi-ring fits CALL KZBLOC('FITQUNMR',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNMR bank' CALL KZBDEL('FITQUNMR') ENDIF idata(1) = fqnmrfit nwmast = 1 nsegm = fqnmrfit lsegm = 5+11*fqmaxnring write (bankformat,'(A5,I2,A1,I3,A1)') '3I 2F', fqmaxnring, 'I', fqmaxnring*10,'F' c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNMR',nwmast,'1I',nsegm,lsegm,bankformat,IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNMR',0,nwmast,idata(1)) do idx1=1,fqnmrfit idata(1) = fqmrifit(idx1) idata(2) = fqmrnring(idx1) idata(3) = fqmrpcflg(idx1) rdata(4) = fqmrnll(idx1) rdata(5) = fqmrtotmu(idx1) do idx2=1,fqmaxnring idata(5+idx2) = fqmrpid(idx2,idx1) ibase1 = 5+fqmaxnring+(idx2-1)*10 rdata(ibase1+1) = fqmrmom(idx2,idx1) rdata(ibase1+2) = fqmrdconv(idx2,idx1) rdata(ibase1+3) = fqmreloss(idx2,idx1) rdata(ibase1+4) = fqmrt0(idx2,idx1) ibase2 = ibase1 + 4 do ix=1,3 rdata(ibase2+ix) = fqmrpos(ix,idx2,idx1) rdata(ibase2+3+ix) = fqmrdir(ix,idx2,idx1) enddo enddo CALL KZREP1('FITQUNMR',idx1,lsegm,idata) enddo c ZEBRA BANK FOR MULTIPLE SEGMENT FITS CALL KZBLOC('FITQUNMS',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNMS bank' CALL KZBDEL('FITQUNMS') ENDIF NWMAST = 1 NSEGM = FQMSNFIT LSEGM = 5+2+(9*FQMSMAXRING) c WRITE(*,*) 'FILLING MS FIT ZBS BANK FROM COMMON' WRITE(BANKFORMAT,'(A2,A2,I3,A1)') '5I','2F',(9*FQMSMAXRING),'F' C CREATE ZBS BANK CALL KZBCR1('FITQUNMS',NWMAST,'1I',NSEGM,LSEGM, & BANKFORMAT,IERR) C FILL MASTER SEGMENT IDATA(1) = FQMSNFIT CALL KZREP1('FITQUNMS',0,NWMAST,IDATA(1)) C FILL OTHER SEGMENTS C II=1 C LOOP OVER # OF MSFITS DO IDX1=1,FQMSNFIT II=1 IDATA(II)=FQMSNSEG(IDX1) II=II+1 IDATA(II)=FQMSPID(IDX1) II=II+1 IDATA(II)=FQMSIFIT(IDX1) II=II+1 IDATA(II)=FQMSIMER(IDX1) II=II+1 IDATA(II)=FQMSPCFLG(IDX1) II=II+1 RDATA(II)=FQMSTOTMU(IDX1) II=II+1 RDATA(II)=FQMSNLL(IDX1) II=II+1 C LOOP OVER SEGMENT TRACKS IN FIT DO IDX2=1,FQMSMAXRING RDATA(II)=FQMSMOM(IDX2,IDX1) II=II+1 RDATA(II)=FQMSeloss(IDX2,IDX1) II=II+1 RDATA(II)=FQMST0(IDX2,IDX1) II=II+1 C 3-VECTOR COMPONTENTS DO IDX3=1,3 RDATA(II)=FQMSpos(IDX3,IDX2,IDX1) II=II+1 RDATA(II)=FQMSDIR(IDX3,IDX2,IDX1) II=II+1 ENDDO ENDDO CALL KZREP1('FITQUNMS',IDX1,LSEGM,IDATA) ENDDO c zebra bank for test 1 ring fits CALL KZBLOC('FITQUNTEST1R',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNTEST1R bank' CALL KZBDEL('FITQUNTEST1R') ENDIF idata(1) = fqtestn1r nwmast = 1 nsegm = fqtestn1r lsegm = 16 c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNTEST1R',nwmast,'1I',nsegm,lsegm,'4I 11F',IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNTEST1R',0,nwmast,idata(1)) do itest=1,nsegm idata(1) = fqtest1rstage(itest) idata(2) = fqtest1rse(itest) idata(3) = fqtest1rpid(itest) idata(4) = fqtest1rpcflg(itest) rdata(5) = fqtest1rmom(itest) rdata(6) = fqtest1rt0(itest) rdata(7) = fqtest1rtotmu(itest) rdata(8) = fqtest1rnll(itest) ibase1 = 8 ibase2 = ibase1 + 3 do ix=1,3 rdata(ibase1+ix) = fqtest1rpos(ix,itest) rdata(ibase2+ix) = fqtest1rdir(ix,itest) enddo rdata(15) = fqtest1rdconv(itest) rdata(16) = fqtest1reloss(itest) CALL KZREP1('FITQUNTEST1R',itest,lsegm,idata) enddo c test pi0 fit zebra bank CALL KZBLOC('FITQUNTESTPI0',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNTESTPI0 bank' CALL KZBDEL('FITQUNTESTPI0') ENDIF idata(1) = fqtestnpi0 nwmast = 1 nsegm = fqtestnpi0 lsegm = 24 c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNTESTPI0',nwmast,'1I',nsegm,lsegm,'2I 22F',IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNTESTPI0',0,nwmast,idata(1)) do itest=1,nsegm idata(1) = fqtestpi0stage(itest) idata(2) = fqtestpi0pcflg(itest) rdata(3) = fqtestpi0mom1(itest) rdata(4) = fqtestpi0mom2(itest) rdata(5) = fqtestpi0momtot(itest) rdata(6) = fqtestpi0dconv1(itest) rdata(7) = fqtestpi0dconv2(itest) rdata(8) = fqtestpi0t0(itest) rdata(9) = fqtestpi0totmu(itest) rdata(10) = fqtestpi0nll(itest) rdata(11) = fqtestpi0mass(itest) rdata(12) = fqtestpi0photangle(itest) ibase1 = 12 ibase2 = ibase1 + 3 ibase3 = ibase2 + 3 ibase4 = ibase3 + 3 do ix=1,3 rdata(ibase1+ix) = fqtestpi0pos(ix,itest) rdata(ibase2+ix) = fqtestpi0dir1(ix,itest) rdata(ibase3+ix) = fqtestpi0dir2(ix,itest) rdata(ibase4+ix) = fqtestpi0dirtot(ix,itest) enddo CALL KZREP1('FITQUNTESTPI0',itest,lsegm,idata) enddo c proton decay to mu gamma fit zebra bank CALL KZBLOC('FITQUNPMG',LBANK) IF (LBANK.ne.0) THEN write(*,*) 'Replacing existing FITQUNPMG bank' CALL KZBDEL('FITQUNPMG') ENDIF ntype = 2 nwmast = 1 nsegm = ntype lsegm = 19 idata(1) = ntype c any name, # of non-array variables, string to describe first nwmast variables, number of elements in each array, number variables for each array element, string to describe variables in array elements, error flag CALL KZBCR1('FITQUNPMG',nwmast,'1I',nsegm,lsegm,'1I 18F',IERR) c same name, isegm (zero to fill nwmast variables), nwmast, first array element CALL KZREP1('FITQUNPMG',0,nwmast,idata(1)) do itype=1,2 idata(1) = fqpmgpcflg(itype) rdata(2) = fqpmgmom1(itype) rdata(3) = fqpmgmom2(itype) rdata(4) = fqpmgt01(itype) rdata(5) = fqpmgt02(itype) rdata(6) = fqpmgtotmu(itype) rdata(7) = fqpmgnll(itype) ibase1 = 7 ibase2 = ibase1 + 3 ibase3 = ibase2 + 3 ibase4 = ibase3 + 3 do ix=1,3 rdata(ibase1+ix) = fqpmgpos1(ix,itype) rdata(ibase2+ix) = fqpmgpos2(ix,itype) rdata(ibase3+ix) = fqpmgdir1(ix,itype) rdata(ibase4+ix) = fqpmgdir2(ix,itype) enddo CALL KZREP1('FITQUNPMG',itype,lsegm,idata) enddo if (fillstatus .ne. 0) then call kzwrit(20) endif return end