subroutine readfqzbsbank(iret) IMPLICIT NONE #include "spliTChanOut.h" #include "fitqunout.h" INTEGER*4 iret INTEGER*4 IDATA(3000),NDATA, ndata_expected REAL*4 RDATA(3000) EQUIVALENCE (IDATA(1),RDATA(1)) INTEGER*4 lbank, i, j, lopc, lopc2, idummy, ise, ix, ipx, lsegm_per_px, ipeak, imethod integer*4 ibase1, ibase2, ibase3, ibase4, index, idx1, idx2, idx3, idx4, icount, II integer*4 itype, ntype, nvars iret = -1 idummy=0 call clrfqcmns(idummy) write(*,*) 'Filling fiTQun common block variables...' c Sub-event Cluster variables CALL KZBLOC('FITQUNCLST',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNCLST bank' RETURN ENDIF C-READ number of segments CALL KZGET1('FITQUNCLST',0,NDATA,IDATA) cluster_ncand = IDATA(1) nvars = 5 ndata_expected = nvars + npeakfinds + 2*maxse*npeakfinds do ise=1,cluster_ncand CALL KZGET1('FITQUNCLST',ise,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNCLST is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF cluster_tstart(ise) = rdata(1) cluster_tend(ise) = rdata(2) cluster_nhits(ise) = idata(3) cluster_totq(ise) = rdata(4) cluster_goodflag(ise)= idata(nvars) do imethod=1,npeakfinds cluster_npeaks(imethod,ise) = idata(nvars+imethod) do ipeak=1,maxse index = nvars + npeakfinds + (imethod-1)*maxse + ipeak if (ipeak.le.cluster_npeaks(imethod,ise)) then cluster_ipeak(ipeak,imethod,ise) = idata(index) cluster_timeofpeak(ipeak,imethod,ise) = rdata(index+maxse*npeakfinds) else cluster_ipeak(ipeak,imethod,ise) = 0 cluster_timeofpeak(ipeak,imethod,ise) = 0 endif enddo enddo enddo c Sub-event Muechk variables CALL KZBLOC('FITQUNMUEC',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNMUEC bank' RETURN ENDIF C -READ number of segments CALL KZGET1('FITQUNMUEC',0,NDATA,IDATA) idummy = IDATA(1) ! npeakfinds must already be hardcoded here anyway IF (idummy.ne.npeakfinds) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of IDATA(1) in FITQUNMUEC is wrong(expected=',npeakfinds,', actual=',idummy,')' RETURN ENDIF ndata_expected = 1+6*maxse do imethod=1,npeakfinds CALL KZGET1('FITQUNMUEC',imethod,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNMUEC is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF muechk_ncand(imethod) = IDATA(1) do ipeak=1,maxse index = 1 + ipeak if (ipeak.le.muechk_ncand(imethod)) then muechk_tpeak(ipeak,imethod) = rdata(index+0*maxse) muechk_bg(ipeak,imethod) = idata(index+1*maxse) muechk_mean(ipeak,imethod) = rdata(index+2*maxse) muechk_excess(ipeak,imethod) = rdata(index+3*maxse) muechk_signif(ipeak,imethod) = rdata(index+4*maxse) muechk_icluster(ipeak,imethod) = idata(index+5*maxse) else muechk_tpeak(ipeak,imethod) = 0 muechk_bg(ipeak,imethod) = 0 muechk_mean(ipeak,imethod) = 0 muechk_excess(ipeak,imethod) = 0 muechk_signif(ipeak,imethod) = 0 muechk_icluster(ipeak,imethod) = 0 endif enddo enddo c Time window variables CALL KZBLOC('FITQUNTWND',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNTWND bank' RETURN ENDIF C-READ number of segments CALL KZGET1('FITQUNTWND',0,NDATA,IDATA) idummy = IDATA(1) ! maxnpeak must already be hardcoded here anyway fqntwnd = idata(2) trgoff = rdata(3) ndata_expected = 8+2*maxnpeak do ise=1,fqntwnd CALL KZGET1('FITQUNTWND',ise,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNPRFT is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF fqtwnd_iclstr(ise) = idata(1) fqtwnd_npeak(ise) = idata(2) fqtwnd_prftt0(ise) = rdata(3) fqtwnd_prftpos(1,ise) = rdata(4) fqtwnd_prftpos(2,ise) = rdata(5) fqtwnd_prftpos(3,ise) = rdata(6) fqtwnd(1,ise) = rdata(7) fqtwnd(2,ise) = rdata(8) ibase1 = 8 ibase2 = ibase1+maxnpeak do ix=1,maxnpeak fqtwnd_peakt0(ix,ise) = rdata(ibase1+ix) fqtwnd_peakiness(ix,ise) = rdata(ibase2+ix) enddo enddo c 1 ring fit variables CALL KZBLOC('FITQUN1R',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUN1R bank' RETURN ENDIF C-READ number of segments CALL KZGET1('FITQUN1R',0,NDATA,IDATA) idummy = IDATA(1) ! maxpx must already be hardcoded here anyway fqnse = idata(2) lsegm_per_px = 12 ndata_expected = maxpx+lsegm_per_px*maxpx+8 do ise=1,fqnse CALL KZGET1('FITQUN1R',ise,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUN1R is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF do ipx=1,maxpx index = maxpx+(ipx - 1)*lsegm_per_px fq1rpcflg(ipx,ise) = idata(ipx) fq1rmom(ipx,ise) = rdata(index+1) fq1rt0(ipx,ise) = rdata(index+2) fq1rtotmu(ipx,ise) = rdata(index+3) fq1rnll(ipx,ise) = rdata(index+4) ibase1 = index+4 ibase2 = ibase1+3 do j=1,3 fq1rpos(j,ipx,ise) = rdata(ibase1+j) fq1rdir(j,ipx,ise) = rdata(ibase2+j) enddo fq1rdconv(ipx,ise) = rdata(index+11) fq1reloss(ipx,ise) = rdata(index+12) enddo fqq50(ise) = rdata(ndata_expected-7) fqn50(ise) = idata(ndata_expected-6) fqitwnd(ise) = idata(ndata_expected-5) fqipeak(ise) = idata(ndata_expected-4) fqnhitpmt(ise) = idata(ndata_expected-3) fqtotq(ise) = rdata(ndata_expected-2) fq0rtotmu(ise) = rdata(ndata_expected-1) fq0rnll(ise) = rdata(ndata_expected) enddo c pi0 fit variables CALL KZBLOC('FITQUNPI0',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNPI0 bank' RETURN ENDIF ndata_expected = 23 CALL KZGET1('FITQUNPI0',0,NDATA,IDATA) ntype = IDATA(1) do itype=1,ntype CALL KZGET1('FITQUNPI0',itype,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNPI0 is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF fqpi0pcflg(itype) = idata(1) fqpi0mom1(itype) = rdata(2) fqpi0mom2(itype) = rdata(3) fqpi0momtot(itype) = rdata(4) fqpi0dconv1(itype) = rdata(5) fqpi0dconv2(itype) = rdata(6) fqpi0t0(itype) = rdata(7) fqpi0totmu(itype) = rdata(8) fqpi0nll(itype) = rdata(9) fqpi0mass(itype) = rdata(10) fqpi0photangle(itype) = rdata(11) ibase1 = 11 ibase2 = ibase1 + 3 ibase3 = ibase2 + 3 ibase4 = ibase3 + 3 do i=1,3 fqpi0pos(i,itype) = rdata(ibase1+i) fqpi0dir1(i,itype) = rdata(ibase2+i) fqpi0dir2(i,itype) = rdata(ibase3+i) fqpi0dirtot(i,itype) = rdata(ibase4+i) enddo enddo c zebra bank for multi-ring fits (new) CALL KZBLOC('FITQUNMR',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNMR bank' RETURN ENDIF CALL KZGET1('FITQUNMR',0,NDATA,IDATA) fqnmrfit = idata(1) ndata_expected = 5+11*fqmaxnring do idx1=1,fqnmrfit CALL KZGET1('FITQUNMR',idx1,NDATA,idata) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNMR is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF fqmrifit(idx1) = idata(1) fqmrnring(idx1) = idata(2) fqmrpcflg(idx1) = idata(3) fqmrnll(idx1) = rdata(4) fqmrtotmu(idx1) = rdata(5) do idx2=1,fqmaxnring fqmrpid(idx2,idx1) = idata(5+idx2) ibase1 = 5+fqmaxnring+(idx2-1)*10 fqmrmom(idx2,idx1) = rdata(ibase1+1) fqmrdconv(idx2,idx1) = rdata(ibase1+2) fqmreloss(idx2,idx1) = rdata(ibase1+3) fqmrt0(idx2,idx1) = rdata(ibase1+4) ibase2 = ibase1 + 4 do ix=1,3 fqmrpos(ix,idx2,idx1) = rdata(ibase2+ix) fqmrdir(ix,idx2,idx1) = rdata(ibase2+3+ix) enddo enddo enddo c ZEBRA BANK FOR MULTIPLE SEGMENT FITS CALL KZBLOC('FITQUNMS',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNMS bank' RETURN ENDIF CALL KZGET1('FITQUNMS',0,NDATA,IDATA) FQMSNFIT = IDATA(1) ndata_expected = 5+2+(9*FQMSMAXRING) C LOOP OVER # OF MSFITS DO IDX1=1,FQMSNFIT CALL KZGET1('FITQUNMS',IDX1,NDATA,idata) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNMS is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF II=1 FQMSNSEG(IDX1) = IDATA(II) II=II+1 FQMSPID(IDX1) = IDATA(II) II=II+1 FQMSIFIT(IDX1) = IDATA(II) II=II+1 FQMSIMER(IDX1) = IDATA(II) II=II+1 FQMSPCFLG(IDX1) = IDATA(II) II=II+1 FQMSTOTMU(IDX1) = RDATA(II) II=II+1 FQMSNLL(IDX1) = RDATA(II) II=II+1 C LOOP OVER SEGMENT TRACKS IN FIT DO IDX2=1,FQMSMAXRING FQMSMOM(IDX2,IDX1) = RDATA(II) II=II+1 FQMSeloss(IDX2,IDX1) = RDATA(II) II=II+1 FQMST0(IDX2,IDX1) = RDATA(II) II=II+1 C 3-VECTOR COMPONTENTS DO IDX3=1,3 FQMSpos(IDX3,IDX2,IDX1) = RDATA(II) II=II+1 FQMSDIR(IDX3,IDX2,IDX1) = RDATA(II) II=II+1 ENDDO ENDDO ENDDO c test 1 ring fit variables CALL KZBLOC('FITQUNTEST1R',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNTEST1R bank' RETURN ENDIF ndata_expected = 16 CALL KZGET1('FITQUNTEST1R',0,NDATA,IDATA) fqtestn1r = IDATA(1) do i=1,fqtestn1r CALL KZGET1('FITQUNTEST1R',I,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNTEST1R is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF fqtest1rstage(i) = idata(1) fqtest1rse(i) = idata(2) fqtest1rpid(i) = idata(3) fqtest1rpcflg(i) = idata(4) fqtest1rmom(i) = rdata(5) fqtest1rt0(i) = rdata(6) fqtest1rtotmu(i) = rdata(7) fqtest1rnll(i) = rdata(8) ibase1 = 8 ibase2 = ibase1 + 3 do j=1,3 fqtest1rpos(j,i) = rdata(ibase1+j) fqtest1rdir(j,i) = rdata(ibase2+j) enddo fqtest1rdconv(i) = rdata(15) fqtest1reloss(i) = rdata(16) enddo c test pi0 fit variables CALL KZBLOC('FITQUNTESTPI0',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNTESTPI0 bank' RETURN ENDIF ndata_expected = 24 CALL KZGET1('FITQUNTESTPI0',0,NDATA,IDATA) fqtestnpi0 = IDATA(1) do i=1,fqtestnpi0 CALL KZGET1('FITQUNTESTPI0',i,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF fqtestpi0stage(i) = idata(1) fqtestpi0pcflg(i) = idata(2) fqtestpi0mom1(i) = rdata(3) fqtestpi0mom2(i) = rdata(4) fqtestpi0momtot(i) = rdata(5) fqtestpi0dconv1(i) = rdata(6) fqtestpi0dconv2(i) = rdata(7) fqtestpi0t0(i) = rdata(8) fqtestpi0totmu(i) = rdata(9) fqtestpi0nll(i) = rdata(10) fqtestpi0mass(i) = rdata(11) fqtestpi0photangle(i) = rdata(12) ibase1 = 12 ibase2 = ibase1+3 ibase3 = ibase2+3 ibase4 = ibase3+3 do j=1,3 fqtestpi0pos(j,i) = rdata(ibase1+j) fqtestpi0dir1(j,i) = rdata(ibase2+j) fqtestpi0dir2(j,i) = rdata(ibase3+j) fqtestpi0dirtot(j,i) = rdata(ibase4+j) enddo enddo c proton decay to mu gamma fit variables CALL KZBLOC('FITQUNPMG',LBANK) IF (LBANK.eq.0) THEN write(*,*) 'readfqzbsbank: Does not contain FITQUNPMG bank' RETURN ENDIF ndata_expected = 19 CALL KZGET1('FITQUNPMG',0,NDATA,IDATA) ntype = IDATA(1) do itype=1,ntype CALL KZGET1('FITQUNPMG',itype,NDATA,IDATA) IF (NDATA.ne.ndata_expected) THEN write(0,*) 'Error in readfqzbsbank:' write(0,*) 'Number of DATA in FITQUNPMG is wrong(expected=',ndata_expected,', actual=',NDATA,')' RETURN ENDIF fqpmgpcflg(itype) = idata(1) fqpmgmom1(itype) = rdata(2) fqpmgmom2(itype) = rdata(3) fqpmgt01(itype) = rdata(4) fqpmgt02(itype) = rdata(5) fqpmgtotmu(itype) = rdata(6) fqpmgnll(itype) = rdata(7) ibase1 = 7 ibase2 = ibase1 + 3 ibase3 = ibase2 + 3 ibase4 = ibase3 + 3 do i=1,3 fqpmgpos1(i,itype) = rdata(ibase1+i) fqpmgpos2(i,itype) = rdata(ibase2+i) fqpmgdir1(i,itype) = rdata(ibase3+i) fqpmgdir2(i,itype) = rdata(ibase4+i) enddo enddo iret = 0 ! common blocks are filled properly return end