|
|
|
@ -567,61 +567,61 @@ module MCFMPrint |
|
|
|
end block scalevarmax |
|
|
|
endif |
|
|
|
|
|
|
|
if (size(tcutarray) > 1) then |
|
|
|
taucutfit: block |
|
|
|
type(HistogramStorage) :: histFitted |
|
|
|
real(dp), allocatable :: ydat(:), weights(:) |
|
|
|
real(dp), allocatable :: relerrs(:) |
|
|
|
real(dp) :: fitcross, fiterr, reserr |
|
|
|
integer :: i, info |
|
|
|
|
|
|
|
histFitted = storage%histCentral |
|
|
|
allocate(ydat(size(tcutarray))) |
|
|
|
allocate(weights(size(tcutarray))) |
|
|
|
allocate(relerrs(size(tcutarray))) |
|
|
|
|
|
|
|
! fill histFitted with fits |
|
|
|
do l=1,size(histFitted%histos) |
|
|
|
if (histFitted%histos(l)%initialized()) then |
|
|
|
allocate(histFitted%histos(l)%extras(2, 0:histFitted%histos(l)%nbins+1)) |
|
|
|
|
|
|
|
do k=0,histFitted%histos(l)%nbins+1 |
|
|
|
do i=1,size(tcutarray) |
|
|
|
ydat(i) = storage%histTaucut(i)%histos(l)%xx(k) |
|
|
|
weights(i) = 1._dp / storage%histTaucut(i)%histos(l)%xxsq(k) |
|
|
|
relerrs(i) = abs( storage%histTaucut(i)%histos(l)%xxsq(k) / & |
|
|
|
storage%histTaucut(i)%histos(l)%xx(k)) |
|
|
|
enddo |
|
|
|
|
|
|
|
call autofit(ydat, weights, fitcross, fiterr, reserr, info) |
|
|
|
histFitted%histos(l)%xx(k) = fitcross |
|
|
|
histFitted%histos(l)%xxsq(k) = fiterr |
|
|
|
histFitted%histos(l)%extras(1,k) = maxval(relerrs) |
|
|
|
histFitted%histos(l)%extras(2,k) = reserr |
|
|
|
enddo |
|
|
|
endif |
|
|
|
enddo |
|
|
|
|
|
|
|
! and write out |
|
|
|
do k=1,size(histFitted%histos) |
|
|
|
associate (histo => histFitted%histos(k)) |
|
|
|
if (histo%initialized()) then |
|
|
|
write (filename,'(A)') trim(rundir)//"/"//trim(runname)//"_"// & |
|
|
|
spacereplace(trim(histo%title))//"_taucutfit"//"."//ext |
|
|
|
open(unit=11, file=filename, status='replace', form='formatted', iostat=ierr, iomsg=imsg) |
|
|
|
if (ierr == 0) then |
|
|
|
call writefun(histo,11) |
|
|
|
close(unit=11) |
|
|
|
else |
|
|
|
write (*,*) "Problem writing histogram file "//filename |
|
|
|
write (*,*) trim(imsg) |
|
|
|
write (*,*) "Error code = ", ierr |
|
|
|
endif |
|
|
|
endif |
|
|
|
end associate |
|
|
|
enddo |
|
|
|
end block taucutfit |
|
|
|
endif |
|
|
|
!if (size(tcutarray) > 1) then |
|
|
|
! taucutfit: block |
|
|
|
! type(HistogramStorage) :: histFitted |
|
|
|
! real(dp), allocatable :: ydat(:), weights(:) |
|
|
|
! real(dp), allocatable :: relerrs(:) |
|
|
|
! real(dp) :: fitcross, fiterr, reserr |
|
|
|
! integer :: i, info |
|
|
|
|
|
|
|
! histFitted = storage%histCentral |
|
|
|
! allocate(ydat(size(tcutarray))) |
|
|
|
! allocate(weights(size(tcutarray))) |
|
|
|
! allocate(relerrs(size(tcutarray))) |
|
|
|
|
|
|
|
! ! fill histFitted with fits |
|
|
|
! do l=1,size(histFitted%histos) |
|
|
|
! if (histFitted%histos(l)%initialized()) then |
|
|
|
! allocate(histFitted%histos(l)%extras(2, 0:histFitted%histos(l)%nbins+1)) |
|
|
|
|
|
|
|
! do k=0,histFitted%histos(l)%nbins+1 |
|
|
|
! do i=1,size(tcutarray) |
|
|
|
! ydat(i) = storage%histTaucut(i)%histos(l)%xx(k) |
|
|
|
! weights(i) = 1._dp / storage%histTaucut(i)%histos(l)%xxsq(k) |
|
|
|
! relerrs(i) = abs( storage%histTaucut(i)%histos(l)%xxsq(k) / & |
|
|
|
! storage%histTaucut(i)%histos(l)%xx(k)) |
|
|
|
! enddo |
|
|
|
|
|
|
|
! call autofit(ydat, weights, fitcross, fiterr, reserr, info) |
|
|
|
! histFitted%histos(l)%xx(k) = fitcross |
|
|
|
! histFitted%histos(l)%xxsq(k) = fiterr |
|
|
|
! histFitted%histos(l)%extras(1,k) = maxval(relerrs) |
|
|
|
! histFitted%histos(l)%extras(2,k) = reserr |
|
|
|
! enddo |
|
|
|
! endif |
|
|
|
! enddo |
|
|
|
|
|
|
|
! ! and write out |
|
|
|
! do k=1,size(histFitted%histos) |
|
|
|
! associate (histo => histFitted%histos(k)) |
|
|
|
! if (histo%initialized()) then |
|
|
|
! write (filename,'(A)') trim(rundir)//"/"//trim(runname)//"_"// & |
|
|
|
! spacereplace(trim(histo%title))//"_taucutfit"//"."//ext |
|
|
|
! open(unit=11, file=filename, status='replace', form='formatted', iostat=ierr, iomsg=imsg) |
|
|
|
! if (ierr == 0) then |
|
|
|
! call writefun(histo,11) |
|
|
|
! close(unit=11) |
|
|
|
! else |
|
|
|
! write (*,*) "Problem writing histogram file "//filename |
|
|
|
! write (*,*) trim(imsg) |
|
|
|
! write (*,*) "Error code = ", ierr |
|
|
|
! endif |
|
|
|
! endif |
|
|
|
! end associate |
|
|
|
! enddo |
|
|
|
! end block taucutfit |
|
|
|
!endif |
|
|
|
|
|
|
|
do k=1,size(tcutarray) |
|
|
|
do l=1,size(storage%histTaucut(k)%histos) |
|
|
|
@ -883,30 +883,30 @@ module MCFMPrint |
|
|
|
write (*,*) "" |
|
|
|
|
|
|
|
! tau cut fit |
|
|
|
taucutfit: block |
|
|
|
real(dp), allocatable :: ydat(:) |
|
|
|
real(dp), allocatable :: weights(:) |
|
|
|
real(dp) :: fitcross, fiterr, reserr |
|
|
|
integer :: i, info |
|
|
|
|
|
|
|
allocate(ydat(size(tcutarray))) |
|
|
|
allocate(weights(size(tcutarray))) |
|
|
|
|
|
|
|
do i=1,size(tcutarray) |
|
|
|
ydat(i) = finalSum%histTaucut(i)%histos(1)%xx(1) |
|
|
|
weights(i) = 1._dp / finalSum%histTaucut(i)%histos(1)%xxsq(1) |
|
|
|
enddo |
|
|
|
|
|
|
|
call autofit(ydat, weights, fitcross, fiterr, reserr, info) |
|
|
|
|
|
|
|
write (*,*) "Fitted correction: ", formatCross(fitcross, fiterr) |
|
|
|
write (*,*) "Reduced chisquare: ", reserr |
|
|
|
write (*,*) "The reduced chisquare should be small or close to one" |
|
|
|
write (*,*) "for a good fit. Results can be trusted if the taucut " |
|
|
|
write (*,*) "dependence uncertainties are reliable (small)." |
|
|
|
write (*,*) "" |
|
|
|
|
|
|
|
end block taucutfit |
|
|
|
!taucutfit: block |
|
|
|
! real(dp), allocatable :: ydat(:) |
|
|
|
! real(dp), allocatable :: weights(:) |
|
|
|
! real(dp) :: fitcross, fiterr, reserr |
|
|
|
! integer :: i, info |
|
|
|
|
|
|
|
! allocate(ydat(size(tcutarray))) |
|
|
|
! allocate(weights(size(tcutarray))) |
|
|
|
|
|
|
|
! do i=1,size(tcutarray) |
|
|
|
! ydat(i) = finalSum%histTaucut(i)%histos(1)%xx(1) |
|
|
|
! weights(i) = 1._dp / finalSum%histTaucut(i)%histos(1)%xxsq(1) |
|
|
|
! enddo |
|
|
|
! |
|
|
|
! call autofit(ydat, weights, fitcross, fiterr, reserr, info) |
|
|
|
|
|
|
|
! write (*,*) "Fitted correction: ", formatCross(fitcross, fiterr) |
|
|
|
! write (*,*) "Reduced chisquare: ", reserr |
|
|
|
! write (*,*) "The reduced chisquare should be small or close to one" |
|
|
|
! write (*,*) "for a good fit. Results can be trusted if the taucut " |
|
|
|
! write (*,*) "dependence uncertainties are reliable (small)." |
|
|
|
! write (*,*) "" |
|
|
|
|
|
|
|
!end block taucutfit |
|
|
|
end subroutine |
|
|
|
|
|
|
|
! to print central values of all sets |
|
|
|
|