#include "sopnamsp.h" #include "machdefs.h" #include #include #include #include #include #include #include "timing.h" #include "histerr.h" #include "hist2err.h" #include "fitshisterr.h" int ObjectType(string nameh,string nameppf); int ConcatHistoErr(string nameh,vector ppfname,int wrtyp=2,bool do_cov=false); int ConcatHisto2DErr(string nameh,vector ppfname,int wrtyp=2,int ibinkt=-1,int ibinkz=-1); void usage(void); void usage(void) { cout <<"cmvconcherr -w wtyp -n name_histoerr file1.ppf file2.ppf ..."< ppfname; int Write_Type = 2; bool Do_Cov = false; int ibinKt=-1, ibinKz=-1; // --- Decodage arguments char c; while((c = getopt(narg,arg,"hCn:w:Z:T:")) != -1) { switch (c) { case 'n' : nameh = optarg; break; case 'w' : sscanf(optarg,"%d",&Write_Type); break; case 'C' : Do_Cov = true; break; case 'Z' : sscanf(optarg,"%d",&ibinKt); break; case 'T' : sscanf(optarg,"%d",&ibinKz); break; case 'h' : default : usage(); return -1; } } if(nameh.size()<=0 || optind>=narg) {usage(); return -1;} for (int i=optind;iDataObj(); cout<<"Object type read from input PPF file : "<(obj); if(herr) return 1; Histo2DErr *herr2 = dynamic_cast(obj); if(herr2) return 2; return 0; } //--------------------------------------------------------------- int ConcatHistoErr(string nameh,vector ppfname,int wrtyp,bool do_cov) { if(ppfname.size()<=0) return 0; HistoErr *herrconc = NULL; TVector Tsum; TMatrix Tsum2; int nherr=0, nread=0, itest=0; double sum=0., sum2=0., nsum=0; for (unsigned int ifile=0;ifileWriteASCII(asname); } if(wrtyp&2 || do_cov) { // ecriture PPF string tagobs = "cmvconcherr.ppf"; POutPersist posobs(tagobs); tagobs = "herrconc"; posobs.PutObject(*herrconc,tagobs); if(do_cov) { tagobs = "mean"; posobs.PutObject(Tsum,tagobs); tagobs = "cov"; posobs.PutObject(Tsum2,tagobs); } } if(wrtyp&4) { // ecriture FITS FitsInOutFile fio("!cmvconcherr.fits",FitsInOutFile::Fits_Create); fio << *herrconc; } delete herrconc; return nread; } //--------------------------------------------------------------- int ConcatHisto2DErr(string nameh,vector ppfname,int wrtyp,int ibinkt,int ibinkz) { if(ppfname.size()<=0) return 0; Histo2DErr *herrconc = NULL; TVector Tsum_kz; TMatrix Tsum2_kz; TVector Tsum_kt; TMatrix Tsum2_kt; int nherrx=0, nherry=0, nread=0, itestx=0, itesty=0; double sum=0., sum2=0., nsum=0; for (unsigned int ifile=0;ifileNBinX()/5.+0.5); itesty = int(herrconc->NBinY()/5.+0.5); if(ibinkt>=0) { // matrix de covariance pour une ligne Kz if(ibinkt>=nherrx) ibinkt = nherrx-1; Tsum_kz.ReSize(nherry); Tsum_kz=0.; Tsum2_kz.ReSize(nherry,nherry); Tsum2_kz=0.; } if(ibinkz>=0) { // matrix de covariance pour une ligne Kt if(ibinkz>=nherry) ibinkz = nherry-1; Tsum_kt.ReSize(nherrx); Tsum_kt=0.; Tsum2_kt.ReSize(nherrx,nherrx); Tsum2_kt=0.; } } else if(nherrx!=herr.NBinX() || nherry!=herr.NBinY()) { cout<<"BAD NUMBER OF BINS"<WriteASCII(asname); } if(wrtyp&2) { // ecriture PPF string tagobs = "cmvconcherr2.ppf"; POutPersist posobs(tagobs); tagobs = "herrconc2"; posobs.PutObject(*herrconc,tagobs); if(ibinkt>=0) { char str[32]; sprintf(str,"kzm%d",ibinkt); posobs.PutObject(Tsum_kz,str); sprintf(str,"kzc%d",ibinkt); posobs.PutObject(Tsum2_kz,str); } if(ibinkz>=0) { char str[32]; sprintf(str,"ktm%d",ibinkz); posobs.PutObject(Tsum_kt,str); sprintf(str,"ktc%d",ibinkz); posobs.PutObject(Tsum2_kt,str); } } if(wrtyp&4) { // ecriture FITS FitsInOutFile fio("!cmvconcherr2.fits",FitsInOutFile::Fits_Create); fio << *herrconc; } delete herrconc; return nread; } /* #### #### HistoErr 1D #### openppf cmvconcherr.ppf c++exec int i = 700; \ cout<0 ! "connectpoints" n/plot herrconc.val-sqrt(err2)%log10(x) x>0&&err2>0 ! "connectpoints same red" n/plot herrconc.val+sqrt(err2)%log10(x) x>0&&err2>0 ! "connectpoints same red" n/plot herrconc.sqrt(err2)%log10(x) x>0&&err2>0 ! "connectpoints same red" n/plot herrconc.sqrt(err2)/val%log10(x) x>0&&err2>0&&val>0 ! "connectpoints" disp mean imag cov del cor c++exec \ TMatrix cor(cov,false); cor = 0.; \ for(int i=0;i $cor($cov,false); $cor = 0.; \ for(int i=0;i<$cor.NRows();i++) { \ for(int j=0;j<$cor.NCols();j++) { \ double v = $cov(i,i)*$cov(j,j); \ if(v<=0.) continue; \ $cor(i,j) = $cov(i,j)/sqrt(v); \ } } \ KeepObj($cor); \ cout<<"Matrice cor cree "<