% ppalldata_04_05_07

    clear all ; close all ;

    cent = [1024 1024] ;
%    cent = [1051 1045] ;
    pplim = 140 ;
    width = 45 ;
    zlen = 10 ;
    rotang = 0 ;
%    energy = 35e3 ;
    plt = [2 2 1 1 1 2 1 0 1 2] ;
%    plt = [0 0 1 0 0 2 1 0 1 2] ;
    bitdiv = 4 ;

    [ppdir,slash] = getppdir ;
    datdir = ('04_05_07') ;
    dir = ([ppdir slash datdir slash]) ;

    if 0

%    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_13kV_35kV_300mm_cal.tif'],[972 945],[1114 947],calplt) ;
    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_13kV_35kV_300mm_cal.tif'],[973 946],[1114 947],calplt) ;

%    [ppposdat_300mm_13kV,ppemitdat_300mm_13kV,ppim_300mm_13kV,pppixemit5d_300mm_13kV,pppixemit2d_300mm_13kV,ppemithist_300mm_13kV] = ...
    [ppposdat_300mm_13kV,ppemitdat_300mm_13kV,ppim_300mm_13kV] = ...
        ppanalyse41([dir 'pp_13kV_35kV_300mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_13kV_35kV_200mm_cal.tif'],[978 942],[1119 943],calplt) ;

%    [ppposdat_200mm_13kV,ppemitdat_200mm_13kV,ppim_200mm_13kV,pppixemit5d_200mm_13kV,pppixemit2d_200mm_13kV,ppemithist_200mm_13kV] = ...
    [ppposdat_200mm_13kV,ppemitdat_200mm_13kV,ppim_200mm_13kV] = ...
        ppanalyse41([dir 'pp_13kV_35kV_200mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_13kV_35kV_100mm_cal.tif'],[974 946],[1116 947],calplt) ;

%    [ppposdat_100mm_13kV,ppemitdat_100mm_13kV,ppim_100mm_13kV,pppixemit5d_100mm_13kV,pppixemit2d_100mm_13kV,ppemithist_100mm_13kV] = ...
    [ppposdat_100mm_13kV,ppemitdat_100mm_13kV,ppim_100mm_13kV] = ...
        ppanalyse41([dir 'pp_13kV_35kV_100mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_13kV_35kV_0mm_cal.tif'],[974 958],[1115 959],calplt) ;

%    [ppposdat_0mm_13kV,ppemitdat_0mm_13kV,ppim_0mm_13kV] = ...
    [ppposdat_0mm_13kV,ppemitdat_0mm_13kV,ppim_0mm_13kV,pppixemit5d_0mm_13kV,pppixemit2d_0mm_13kV,ppemithist_0mm_13kV] = ...
        ppanalyse41([dir 'pp_13kV_35kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_30kV,ppemitdat_0mm_13kV_30kV,pppixemit5d_0mm_13kV_30kV,pppixemit2d_0mm_13kV_30kV,ppemithist_0mm_13kV_30kV] = ...
    [ppposdat_0mm_13kV_30kV,ppemitdat_0mm_13kV_30kV,ppim_0mm_13kV_30kV] = ...
        ppanalyse41([dir 'pp_13kV_30kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,30e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_25kV,ppemitdat_0mm_13kV_25kV,pppixemit5d_0mm_13kV_25kV,pppixemit2d_0mm_13kV_25kV,ppemithist_0mm_13kV_25kV] = ...
    [ppposdat_0mm_13kV_25kV,ppemitdat_0mm_13kV_25kV,ppim_0mm_13kV_25kV] = ...
        ppanalyse41([dir 'pp_13kV_25kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,25e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_20kV,ppemitdat_0mm_13kV_20kV,pppixemit5d_0mm_13kV_20kV,pppixemit2d_0mm_13kV_20kV,ppemithist_0mm_13kV_20kV] = ...
    [ppposdat_0mm_13kV_20kV,ppemitdat_0mm_13kV_20kV,ppim_0mm_13kV_20kV] = ...
        ppanalyse41([dir 'pp_13kV_20kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,20e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_15kV,ppemitdat_0mm_13kV_15kV,pppixemit5d_0mm_13kV_15kV,pppixemit2d_0mm_13kV_15kV,ppemithist_0mm_13kV_15kV] = ...
    [ppposdat_0mm_13kV_15kV,ppemitdat_0mm_13kV_15kV,ppim_0mm_13kV_15kV] = ...
        ppanalyse41([dir 'pp_13kV_15kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,15e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_135kV,ppemitdat_0mm_13kV_135kV,pppixemit5d_0mm_13kV_135kV,pppixemit2d_0mm_13kV_135kV,ppemithist_0mm_13kV_135kV] = ...
    [ppposdat_0mm_13kV_135kV,ppemitdat_0mm_13kV_135kV,ppim_0mm_13kV_135kV] = ...
        ppanalyse41([dir 'pp_13kV_135kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,13.5e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_125kV,ppemitdat_0mm_13kV_125kV,pppixemit5d_0mm_13kV_125kV,pppixemit2d_0mm_13kV_125kV,ppemithist_0mm_13kV_125kV] = ...
    [ppposdat_0mm_13kV_125kV,ppemitdat_0mm_13kV_125kV,ppim_0mm_13kV_125kV] = ...
        ppanalyse41([dir 'pp_13kV_125kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,12.5e3,plt,bitdiv) ;

%    [ppposdat_0mm_13kV_10kV,ppemitdat_0mm_13kV_10kV,pppixemit5d_0mm_13kV_10kV,pppixemit2d_0mm_13kV_10kV,ppemithist_0mm_13kV_10kV] = ...
    [ppposdat_0mm_13kV_10kV,ppemitdat_0mm_13kV_10kV,ppim_0mm_13kV_10kV] = ...
        ppanalyse41([dir 'pp_13kV_10kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,10e3,plt,bitdiv) ;

        if 0 % images too faint for emittance data
%        [ppposdat_0mm_13kV_5kV,ppemitdat_0mm_13kV_5kV,pppixemit5d_0mm_13kV_5kV,pppixemit2d_0mm_13kV_5kV,ppemithist_0mm_13kV_5kV] = ...
        [ppposdat_0mm_13kV_5kV,ppemitdat_0mm_13kV_5kV,ppim_0mm_13kV_5kV] = ...
            ppanalyse41([dir 'pp_13kV_5kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
            pplim,width,zlen,rotang,5e3,plt,bitdiv) ;

%        [ppposdat_0mm_13kV_0kV,ppemitdat_0mm_13kV_0kV,pppixemit5d_0mm_13kV_0kV,pppixemit2d_0mm_13kV_0kV,ppemithist_0mm_13kV_0kV] = ...
        [ppposdat_0mm_13kV_0kV,ppemitdat_0mm_13kV_0kV,ppim_0mm_13kV_0kV] = ...
            ppanalyse41([dir 'pp_13kV_0kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
            pplim,width,zlen,rotang,0e3,plt,bitdiv) ;
        end

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_9kV_35kV_0mm_cal.tif'],[974 956],[1115 957],1) ;

%    [ppposdat_0mm_9kV,ppemitdat_0mm_9kV,ppim_0mm_9kV,pppixemit5d_0mm_9kV,pppixemit2d_0mm_9kV,ppemithist_0mm_9kV] = ...
    [ppposdat_0mm_9kV,ppemitdat_0mm_9kV,ppim_0mm_9kV] = ...
        ppanalyse41([dir 'pp_9kV_35kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_9kV_35kV_100mm_cal.tif'],[974 947],[1115 948],1) ;

%    [ppposdat_100mm_9kV,ppemitdat_100mm_9kV,ppim_100mm_9kV,pppixemit5d_100mm_9kV,pppixemit2d_100mm_9kV,ppemithist_100mm_9kV] = ...
    [ppposdat_100mm_9kV,ppemitdat_100mm_9kV,ppim_100mm_9kV] = ...
        ppanalyse41([dir 'pp_9kV_35kV_100mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_9kV_35kV_200mm_cal.tif'],[974 942],[1115 943],1) ;

%    [ppposdat_200mm_9kV,ppemitdat_200mm_9kV,ppim_200mm_9kV,pppixemit5d_200mm_9kV,pppixemit2d_200mm_9kV,ppemithist_200mm_9kV] = ...
    [ppposdat_200mm_9kV,ppemitdat_200mm_9kV,ppim_200mm_9kV] = ...
        ppanalyse41([dir 'pp_9kV_35kV_200mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        150,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_9kV_35kV_300mm_cal.tif'],[974 945],[1115 946],1) ;

%    [ppposdat_300mm_9kV,ppemitdat_300mm_9kV,ppim_300mm_9kV,pppixemit5d_300mm_9kV,pppixemit2d_300mm_9kV,ppemithist_300mm_9kV] = ...
    [ppposdat_300mm_9kV,ppemitdat_300mm_9kV,ppim_300mm_9kV] = ...
        ppanalyse41([dir 'pp_9kV_35kV_300mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_6kV_35kV_0mm_cal.tif'],[974 956],[1115 957],1) ;

%    [ppposdat_0mm_6kV,ppemitdat_0mm_6kV,ppim_0mm_6kV,pppixemit5d_0mm_6kV,pppixemit2d_0mm_6kV,ppemithist_0mm_6kV] = ...
    [ppposdat_0mm_6kV,ppemitdat_0mm_6kV,ppim_0mm_6kV] = ...
        ppanalyse41([dir 'pp_6kV_35kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_6kV_35kV_100mm_cal.tif'],[973 946],[1114 947],1) ;

%    [ppposdat_100mm_6kV,ppemitdat_100mm_6kV,ppim_100mm_6kV,pppixemit5d_100mm_6kV,pppixemit2d_100mm_6kV,ppemithist_100mm_6kV] = ...
    [ppposdat_100mm_6kV,ppemitdat_100mm_6kV,ppim_100mm_6kV] = ...
        ppanalyse41([dir 'pp_6kV_35kV_100mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_6kV_35kV_200mm_cal.tif'],[974 942],[1115 943],1) ;

%    [ppposdat_200mm_6kV,ppemitdat_200mm_6kV,ppim_200mm_6kV,pppixemit5d_200mm_6kV,pppixemit2d_200mm_6kV,ppemithist_200mm_6kV] = ...
    [ppposdat_200mm_6kV,ppemitdat_200mm_6kV,ppim_200mm_6kV] = ...
        ppanalyse41([dir 'pp_6kV_35kV_200mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        150,width,zlen,rotang,35e3,plt,bitdiv) ;

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_6kV_35kV_300mm_cal.tif'],[974 944],[1115 945],1) ;

%    [ppposdat_300mm_6kV,ppemitdat_300mm_6kV,ppim_300mm_6kV,pppixemit5d_300mm_6kV,pppixemit2d_300mm_6kV,ppemithist_300mm_6kV] = ...
    [ppposdat_300mm_6kV,ppemitdat_300mm_6kV,ppim_300mm_6kV] = ...
        ppanalyse41([dir 'pp_6kV_35kV_300mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    end

    [midpos,sp2sp,imtilt] = ppcalfind2p([dir 'pp_17kV_35kV_0mm_cal.tif'],[974 957],[1115 958],1) ;

%    [ppposdat_0mm_17kV,ppemitdat_0mm_17kV,ppim_0mm_17kV,pppixemit5d_0mm_17kV,pppixemit2d_0mm_17kV,ppemithist_0mm_17kV] = ...
    [ppposdat_0mm_17kV,ppemitdat_0mm_17kV,ppim_0mm_17kV] = ...
        ppanalyse41([dir 'pp_17kV_35kV_0mm_dat.tif'],[],midpos,imtilt,sp2sp, ...
        pplim,width,zlen,rotang,35e3,plt,bitdiv) ;

    return

