From ab0d72a04e81c1fa31ba0ce5a77666e24f9a6b71 Mon Sep 17 00:00:00 2001 From: Samir Amar-Youcef Date: Fri, 19 Dec 2014 13:43:51 +0100 Subject: [PATCH] adding analysis and gui code --- s-curves/analysis_gui/ANA/Makefile | 16 + s-curves/analysis_gui/ANA/Mi26Ana.cpp | 1059 +++++++++++++++++++++++++ s-curves/analysis_gui/ANA/Mi26Ana.h | 82 ++ s-curves/analysis_gui/ANA/ana.C | 524 ++++++++++++ s-curves/analysis_gui/ANA/help.h | 92 +++ s-curves/analysis_gui/ANA/main.cpp | 51 ++ s-curves/analysis_gui/GUI/Makefile | 240 ++++++ s-curves/analysis_gui/GUI/main.cpp | 22 + s-curves/analysis_gui/GUI/scurves.cpp | 660 +++++++++++++++ s-curves/analysis_gui/GUI/scurves.h | 45 ++ s-curves/analysis_gui/GUI/scurves.pro | 14 + s-curves/analysis_gui/GUI/scurves.ui | 588 ++++++++++++++ s-curves/analysis_gui/run.sh | 11 + s-curves/analysis_gui/runana.sh | 15 + 14 files changed, 3419 insertions(+) create mode 100644 s-curves/analysis_gui/ANA/Makefile create mode 100644 s-curves/analysis_gui/ANA/Mi26Ana.cpp create mode 100644 s-curves/analysis_gui/ANA/Mi26Ana.h create mode 100644 s-curves/analysis_gui/ANA/ana.C create mode 100644 s-curves/analysis_gui/ANA/help.h create mode 100644 s-curves/analysis_gui/ANA/main.cpp create mode 100644 s-curves/analysis_gui/GUI/Makefile create mode 100644 s-curves/analysis_gui/GUI/main.cpp create mode 100644 s-curves/analysis_gui/GUI/scurves.cpp create mode 100644 s-curves/analysis_gui/GUI/scurves.h create mode 100644 s-curves/analysis_gui/GUI/scurves.pro create mode 100644 s-curves/analysis_gui/GUI/scurves.ui create mode 100755 s-curves/analysis_gui/run.sh create mode 100755 s-curves/analysis_gui/runana.sh diff --git a/s-curves/analysis_gui/ANA/Makefile b/s-curves/analysis_gui/ANA/Makefile new file mode 100644 index 0000000..0b7bb4f --- /dev/null +++ b/s-curves/analysis_gui/ANA/Makefile @@ -0,0 +1,16 @@ +CC=g++ +CFLAGS=-c -g -Wall -std=c++11 `root-config --cflags` +LDFLAGS=`root-config --glibs` +CLDFLAGS = -std=c++11 `root-config --cflags --glibs` -lboost_system -lboost_filesystem +SOURCES= main.cpp Mi26Ana.cpp Mi26Ana.h help.h +OBJECTS=$(subst .cc,.o,$(SOURCES)) +EXECUTABLE=Mi26Ana + +all: $(SOURCES) $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS) + $(CC) $(CLDFLAGS) $(OBJECTS) -o $@ + + +clean: + rm -f $(OBJS) diff --git a/s-curves/analysis_gui/ANA/Mi26Ana.cpp b/s-curves/analysis_gui/ANA/Mi26Ana.cpp new file mode 100644 index 0000000..8198408 --- /dev/null +++ b/s-curves/analysis_gui/ANA/Mi26Ana.cpp @@ -0,0 +1,1059 @@ +#include "Mi26Ana.h" +#include "help.h" + + +//#################################################################### + +Mi26Ana::Mi26Ana() { // ok + + + fInputRootFile = ""; + fInputPxFile = ""; + fNRndPx = 0; + fNPx = 0; + fCode = 0; + + fPixelprob = new Float_t [1152*576]; +// fFrames = new UShort_t [576]; +} + +//#################################################################### + +Mi26Ana::Mi26Ana( TString inFile, TString pxFile, int NRndPx, int NPx, int Code ) { // ok + + fInputRootFile = inFile; + fInputPxFile = pxFile; + fNRndPx = NRndPx; + fNPx = NPx; + fCode = Code; + + fPixelprob = new Float_t [1152*576]; +// fFrames = new UShort_t [576]; +} + +//#################################################################### + +Mi26Ana::~Mi26Ana() { // ok + + delete[] fPixelprob; +// delete[] fFrames; +// fFile->Close(); +} + +//#################################################################### + +void Mi26Ana::Exec(int Mode) { // ok +// Open Root-File + fFile = new TFile(fInputRootFile); + fTree = (TTree*)fFile->Get( "scurvesall" ); + fTree -> SetBranchAddress ("threshold" , &fThreshold ); + fTree -> SetBranchAddress ("pixelprob" , fPixelprob ); +// fTree -> SetBranchAddress ("frames" , fFrames ); + + fNthr = fTree->GetEntries(); + +// Decode 'Code' + fPixSel = ( (fCode/10000) & 1); + fMatrix[0] = ( (fCode/1000) & 1); + fMatrix[1] = ( (fCode/100) & 1); + fMatrix[2] = ( (fCode/10) & 1); + fMatrix[3] = ( (fCode/1) & 1); + + fMatrixActive = 0; + for(int i=0;i<4;i++) { fMatrixActive+=fMatrix[i]; } + +// Read Pixel File + if( fPixSel ) { if( !readPxFile() ) { fPixSel=0; } } +// fFilename + char longFile[256] = ""; + char shortFile[256] = ""; + + strcpy (longFile, fInputRootFile); + + uint namelength = strlen(longFile); + uint pos = 0; + for(uint i=0; i Branch("threshold" , &fThreshold , "threshold/s" , 32000); + treeout -> Branch("pixelprob" , pixelprobout , "pixelprob[663552]/F" , 32000); + +// Loop + for(int i=0;iGetEntry(i+j*nthr); + + for(int pix=0;pix<1152*576;pix++) + { + if( pix%1152>=1152/4*(j) && pix%1152<1152/4*(j+1) ) + { + pixelprobout[pix] = fPixelprob[pix]; + } + } + } + + cout<<"\rThreshold: "<Fill(); + } + cout<<"\r ...done! "< Write("",TObject::kOverwrite); + fout->Save(); + fout->Close(); + cout<<"-------------"<GetEntry(i); +// fPixSel 0 + if(!fPixSel) + { + for(int pix=0;pix<1152*576;pix++) + { + column = pix%1152; + row = (int)(pix/1152); + matrix = int(column/288); + + if(fMatrix[matrix]) + { +// if( row!=0 && row!=573 ) +// { + ploti[matrix] ->Fill(fThreshold,fPixelprob[pix]); +// } + } + } + } +// fPixSel 1 + else + { + int pix; + for(int pi=0;piFill(fThreshold,fPixelprob[pix]); +// } + } + } + } + } + } + + TCanvas* cm2 = new TCanvas("SCURVES",Form("SCURVES: %s", fFilename), 50,100,250*fMatrixActive,300); + cm2->Divide(fMatrixActive,1); + + int cdi = 1; + for(int i=0;i<4;i++) + { + if( fMatrix[i] ) + { + cm2->cd(cdi); + ploti[i]->SetStats(false); + ploti[i]->SetMarkerColor(kRed); + ploti[i]->Draw(); + cdi++; + } + } +} + +//#################################################################### + +void Mi26Ana::plotscsingle() { // ok + + cout<<"-------------"<GetEntry(i); + + pix = fNPx; + column = pix%288; + row = (int)(pix/288); + + for(matrix=0;matrix<4;matrix++) + { + pix = 1152*row+column+288*matrix; + + if(fMatrix[matrix]) + { + ploti[matrix] ->Fill(fThreshold,fPixelprob[pix]); + } + } + } + + TCanvas* cm2 = new TCanvas("SCURVE",Form("SCURVE (%i): %s", fNPx, fFilename), 50,100,250*fMatrixActive,300); + cm2->Divide(fMatrixActive,1); + + int cdi = 1; + for(int i=0;i<4;i++) + { + if( fMatrix[i] ) + { + cm2->cd(cdi); + ploti[i]->SetStats(false); + ploti[i]->SetMarkerColor(kRed); + ploti[i]->Draw(); + cdi++; + } + } +} + +//#################################################################### + +void Mi26Ana::fitsc() { // ok + +// File OUT +// TString RootFileOut = "outputpara2.root"; +// TFile* fout = new TFile(RootFileOut,"RECREATE"); +// TTree* paraTree[4]; +// +// for(int ba=0;ba<4;ba++) +// { +// paraTree[ba] = new TTree( Form("para%i",ba), Form("para%i",ba)); +// paraTree[ba] -> Branch("pixel" , &pixel , "pixel/i" , 32000); +// paraTree[ba] -> Branch("row" , &row , "row/i" , 32000); +// paraTree[ba] -> Branch("column" , &column , "column/F" , 32000); +// paraTree[ba] -> Branch("mean" , &mean , "mean/F" , 32000); +// paraTree[ba] -> Branch("sigma" , &sigma , "sigma/F" , 32000); +// paraTree[ba] -> Branch("chi2" , &chi2 , "chi2/F" , 32000); +// } +// -------------- + float* pixelprob_arr = new float [fNthr*1152*576]; + int* threshold_arr = new int [fNthr]; + + TH1F *histos, *histo[12]; + histos = new TH1F( "test", "test" , 255,0.,255.); + histo[0] = new TH1F( "mean0" , "mean" , 510,0.,255.); + histo[1] = new TH1F( "mean1" , "mean1" , 510,0.,255.); + histo[2] = new TH1F( "mean2" , "mean2" , 510,0.,255.); + histo[3] = new TH1F( "mean3" , "mean3" , 510,0.,255.); + histo[4] = new TH1F( "sigma0", "sigma" , 500,0.,100.); + histo[5] = new TH1F( "sigma1", "sigma1" , 500,0.,100.); + histo[6] = new TH1F( "sigma2", "sigma2" , 500,0.,100.); + histo[7] = new TH1F( "sigma3", "sigma3" , 500,0.,100.); + histo[8] = new TH1F( "chi20" , "chi2" , 1000,0.,1.); + histo[9] = new TH1F( "chi21" , "chi21" , 1000,0.,1.); + histo[10] = new TH1F( "chi22" , "chi22" , 1000,0.,1.); + histo[11] = new TH1F( "chi23" , "chi23" , 1000,0.,1.); + + TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100); + + float mean = 0, sigma = 0, chi2 = 0; + int chicount=0; + int meanmin, meanmax; + float meanmean; + float vsigma; + float vtmp=1; + int column; + int row; + int matrix; + int pixel; + float MAXX[3] = {0, 0, 0}; + double MAXY[3] = {0, 0, 0}; + +// ULong_t progress_tmp=-1; +// Float_t progress; + + TCanvas* canv = new TCanvas("Error Function Fit","Error Function Fit", 50,100,750,300); + canv->Divide(3,1); + +// Read TTree + for(int thr=0;thrGetEntry(thr); + + for(int pix=0;pix<1152*576;pix++) + { + pixelprob_arr[pix*fNthr+thr] = fPixelprob[pix]; + } + + threshold_arr[thr] = (int)fThreshold; + } + +// Fitting of Scurves + int* RndPx; + int pix; + int nrpixels = 1152*576; + + if(fPixSel) + { + nrpixels = 4*fNRndPx; + RndPx = new int[nrpixels]; + + for(int i=0;iFill(threshold_arr[thr],pixelprob_arr[pix*fNthr+thr]); + + if( pixelprob_arr[pix*fNthr+thr]!=1 && meanmin==0 ) { meanmin=threshold_arr[thr]-1; } + if( pixelprob_arr[pix*fNthr+thr]==0 && vtmp!=0 ) { meanmax=threshold_arr[thr]; } + vtmp = pixelprob_arr[pix*fNthr+thr]; + } + + vsigma = (meanmax-meanmin)/2.; + meanmean = (meanmax+meanmin)/2.; + erf->SetParameters(meanmean,vsigma); + + pixel = pix; + column = pix%1152; + row = (int)(pix/1152); + matrix = int(column/288); + +// if( row!=0 && row!=1 && row!=573 && column<288) + if( fMatrix[matrix] ) + { +// Fit + histos->Fit(erf,"QN"); + + mean = erf->GetParameter(0); + sigma = erf->GetParameter(1)/TMath::Sqrt(2); + chi2 = erf->GetChisquare()/erf->GetNDF(); +// Check whether Fit Parameters are okay + chicount=0; + + if( meanmeanmax || sigma>75 || sigma<1 ) + { + chicount=0; + + while( (meanmeanmax || sigma>75 || sigma<0.0001) && chicount<10) + { + erf->SetParameters(meanmean,1.*(chicount+1)); + histos->Fit(erf,"QMN"); + pixel = pix; + mean = erf->GetParameter(0); + sigma = erf->GetParameter(1)/TMath::Sqrt(2); + chi2 = erf->GetChisquare()/erf->GetNDF(); + chicount++; + + } + } + + histo[0+matrix]->Fill(mean); + histo[4+matrix]->Fill(sigma); + histo[8+matrix]->Fill(chi2); + + if( mean > MAXX[0] ) { MAXX[0]=mean+1; } + if( sigma > MAXX[1] ) { MAXX[1]=sigma+1; } + if( chi2 > MAXX[2] ) { MAXX[2]=chi2+0.01; } + +// paraTree[matrix]->Fill(); + } + + if(i%100==0) + { + printf("\r Pixel: %6i - %3.1f %% - fit attempts:%2i - %6.2f %4.2f %6.5f", pix, 100.*i/(nrpixels), chicount, mean, sigma, chi2); fflush(stdout); + + if(i%5000==0) + { + + if( histo[0]->GetBinContent(histo[0]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[0]->GetBinContent(histo[0]->GetMaximumBin())+1; } + if( histo[1]->GetBinContent(histo[1]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[1]->GetBinContent(histo[1]->GetMaximumBin())+1; } + if( histo[2]->GetBinContent(histo[2]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[2]->GetBinContent(histo[2]->GetMaximumBin())+1; } + if( histo[3]->GetBinContent(histo[3]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[3]->GetBinContent(histo[3]->GetMaximumBin())+1; } + + if( histo[4]->GetBinContent(histo[4]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[4]->GetBinContent(histo[4]->GetMaximumBin())+1; } + if( histo[5]->GetBinContent(histo[5]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[5]->GetBinContent(histo[5]->GetMaximumBin())+1; } + if( histo[6]->GetBinContent(histo[6]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[6]->GetBinContent(histo[6]->GetMaximumBin())+1; } + if( histo[7]->GetBinContent(histo[7]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[7]->GetBinContent(histo[7]->GetMaximumBin())+1; } + + if( histo[8]->GetBinContent(histo[8]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[8]->GetBinContent(histo[8]->GetMaximumBin())+1; } + if( histo[9]->GetBinContent(histo[9]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[9]->GetBinContent(histo[9]->GetMaximumBin())+1; } + if( histo[10]->GetBinContent(histo[10]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[10]->GetBinContent(histo[10]->GetMaximumBin())+1; } + if( histo[11]->GetBinContent(histo[11]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[11]->GetBinContent(histo[11]->GetMaximumBin())+1; } + + canv->cd(1); + histo[0]->SetLineColor(1); + histo[0]->SetStats(false); + histo[0]->Draw(); + histo[0]->SetAxisRange(0,MAXX[0]); + histo[0]->SetMaximum(MAXY[0]); + histo[1]->SetLineColor(2); + histo[1]->SetStats(false); + histo[1]->Draw("same"); + histo[2]->SetLineColor(3); + histo[2]->SetStats(false); + histo[2]->Draw("same"); + histo[3]->SetLineColor(4); + histo[3]->SetStats(false); + histo[3]->Draw("same"); + + canv->cd(2); + histo[4]->SetLineColor(1); + histo[4]->SetStats(false); + histo[4]->Draw(); + histo[4]->SetAxisRange(0,MAXX[1]); + histo[4]->SetMaximum(MAXY[1]); + histo[5]->SetLineColor(2); + histo[5]->SetStats(false); + histo[5]->Draw("same"); + histo[6]->SetLineColor(3); + histo[6]->SetStats(false); + histo[6]->Draw("same"); + histo[7]->SetLineColor(4); + histo[7]->SetStats(false); + histo[7]->Draw("same"); + + canv->cd(3); + histo[8]->SetLineColor(1); + histo[8]->SetStats(false); + histo[8]->Draw(); + histo[8]->SetAxisRange(0,MAXX[2]); + histo[8]->SetMaximum(MAXY[2]); + histo[9]->SetLineColor(2); + histo[9]->SetStats(false); + histo[9]->Draw("same"); + histo[10]->SetLineColor(3); + histo[10]->SetStats(false); + histo[10]->Draw("same"); + histo[11]->SetLineColor(4); + histo[11]->SetStats(false); + histo[11]->Draw("same"); + + canv->Update(); + } + } + } + } + + +// for(int ba=0;ba<4;ba++) +// { +// paraTree[ba]->Write("",TObject::kOverwrite); +// } + +// fout->Save(); +// fout->Close(); +// f->Close(); + printf("\r Pixel: %6i - %3.1f %% - fit attempts:%2i - %6.2f %4.2f %6.5f", pix, 100., chicount, mean, sigma, chi2); fflush(stdout); + + if( histo[0]->GetBinContent(histo[0]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[0]->GetBinContent(histo[0]->GetMaximumBin())+1; } + if( histo[1]->GetBinContent(histo[1]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[1]->GetBinContent(histo[1]->GetMaximumBin())+1; } + if( histo[2]->GetBinContent(histo[2]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[2]->GetBinContent(histo[2]->GetMaximumBin())+1; } + if( histo[3]->GetBinContent(histo[3]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[3]->GetBinContent(histo[3]->GetMaximumBin())+1; } + + if( histo[4]->GetBinContent(histo[4]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[4]->GetBinContent(histo[4]->GetMaximumBin())+1; } + if( histo[5]->GetBinContent(histo[5]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[5]->GetBinContent(histo[5]->GetMaximumBin())+1; } + if( histo[6]->GetBinContent(histo[6]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[6]->GetBinContent(histo[6]->GetMaximumBin())+1; } + if( histo[7]->GetBinContent(histo[7]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[7]->GetBinContent(histo[7]->GetMaximumBin())+1; } + + if( histo[8]->GetBinContent(histo[8]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[8]->GetBinContent(histo[8]->GetMaximumBin())+1; } + if( histo[9]->GetBinContent(histo[9]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[9]->GetBinContent(histo[9]->GetMaximumBin())+1; } + if( histo[10]->GetBinContent(histo[10]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[10]->GetBinContent(histo[10]->GetMaximumBin())+1; } + if( histo[11]->GetBinContent(histo[11]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[11]->GetBinContent(histo[11]->GetMaximumBin())+1; } + + canv->cd(1); + histo[0]->SetLineColor(1); + histo[0]->SetStats(false); + histo[0]->Draw(); + histo[0]->SetAxisRange(0,MAXX[0]); + histo[0]->SetMaximum(MAXY[0]); + histo[1]->SetLineColor(2); + histo[1]->SetStats(false); + histo[1]->Draw("same"); + histo[2]->SetLineColor(3); + histo[2]->SetStats(false); + histo[2]->Draw("same"); + histo[3]->SetLineColor(4); + histo[3]->SetStats(false); + histo[3]->Draw("same"); + + canv->cd(2); + histo[4]->SetLineColor(1); + histo[4]->SetStats(false); + histo[4]->Draw(); + histo[4]->SetAxisRange(0,MAXX[1]); + histo[4]->SetMaximum(MAXY[1]); + histo[5]->SetLineColor(2); + histo[5]->SetStats(false); + histo[5]->Draw("same"); + histo[6]->SetLineColor(3); + histo[6]->SetStats(false); + histo[6]->Draw("same"); + histo[7]->SetLineColor(4); + histo[7]->SetStats(false); + histo[7]->Draw("same"); + + canv->cd(3); + histo[8]->SetLineColor(1); + histo[8]->SetStats(false); + histo[8]->Draw(); + histo[8]->SetAxisRange(0,MAXX[2]); + histo[8]->SetMaximum(MAXY[2]); + histo[9]->SetLineColor(2); + histo[9]->SetStats(false); + histo[9]->Draw("same"); + histo[10]->SetLineColor(3); + histo[10]->SetStats(false); + histo[10]->Draw("same"); + histo[11]->SetLineColor(4); + histo[11]->SetStats(false); + histo[11]->Draw("same"); + + canv->Update(); + cout<<"\n-------------"<GetEntry(thr); + + for(pix=0;pix<4;pix++) + { + pixelprob_arr[pix*fNthr+thr] = fPixelprob[pixel[pix]]; + } + + threshold_arr[thr] = (int)fThreshold; + } + +// for(int i=0;i<4;i++) { histos[i] = new TH1F( Form("Matrix:%2i", i), Form("Matrix:%2i", i) , 255,0.,255.); } + for(int i=0;i<4;i++) { histos[i] = new TH1F( Form("Matrix:%2i", i), Form("Matrix:%2i", i) , fNthr, threshold_arr[0], threshold_arr[fNthr-1] ); } + + TCanvas* canv = new TCanvas( "Error Function Fit", Form("Error Function Fit: %i x %i",col,row), 50,100,250*fMatrixActive,300); + for(int pix=0;pix<4;pix++) + { +// Estimate Fit Parameters + meanmin=0; + meanmax=255; + + for(int thr=0;thrFill(threshold_arr[thr],pixelprob_arr[pix*fNthr+thr]); + + if( pixelprob_arr[pix*fNthr+thr]!=1 && meanmin==0 ) { meanmin=threshold_arr[thr]-1; } + if( pixelprob_arr[pix*fNthr+thr]==0 && vtmp!=0 ) { meanmax=threshold_arr[thr]; } + vtmp = pixelprob_arr[pix*fNthr+thr]; + } + + vsigma = (meanmax-meanmin)/2.; + meanmean = (meanmax+meanmin)/2.; + erf->SetParameters(meanmean,vsigma); + + if( fMatrix[pix] ) + { +// Fit + histos[pix]->Fit(erf,"Q"); + + mean = erf->GetParameter(0); + sigma = erf->GetParameter(1)/TMath::Sqrt(2); + chi2 = erf->GetChisquare()/erf->GetNDF(); +// Check whether Fit Parameters are okay + chicount=0; + + if( meanmeanmax || sigma>75 || sigma<1 ) + { + chicount=0; + + while( (meanmeanmax || sigma>75 || sigma<0.0001) && chicount<10) + { + erf->SetParameters(meanmean,1.*(chicount+1)); + histos[pix]->Fit(erf,"QM"); + mean = erf->GetParameter(0); + sigma = erf->GetParameter(1)/TMath::Sqrt(2); + chi2 = erf->GetChisquare()/erf->GetNDF(); + chicount++; + + } + } + printf("\r Pixel: %6i - fit attempts:%2i - %6.2f %4.2f %6.5f\n", pix, chicount, mean, sigma, chi2); fflush(stdout); + } + } + canv->Clear(); + canv->Divide(fMatrixActive,1); + int cdi = 1; + for(int i=0;i<4;i++) + { + if( fMatrix[i] ) + { + canv->cd(cdi); + histos[i]->SetStats(false); + histos[i]->Draw(); + cdi++; + } + } +} + +//#################################################################### + +void Mi26Ana::sumup() { // ok + cout<<"-------------"<GetEntry(nt); + + for(int i=0;i MAXX ) { MAXX=sum[i]; } + + plot[matrix]->Fill(sum[i]); + plot2->Fill(column, row, sum[i]); + } + +// if(row==1)cout<GetBinContent(plot[0]->GetMaximumBin()) > MAXY ) { MAXY = plot[0]->GetBinContent(plot[0]->GetMaximumBin())+1; } + if( plot[1]->GetBinContent(plot[1]->GetMaximumBin()) > MAXY ) { MAXY = plot[1]->GetBinContent(plot[1]->GetMaximumBin())+1; } + if( plot[2]->GetBinContent(plot[2]->GetMaximumBin()) > MAXY ) { MAXY = plot[2]->GetBinContent(plot[2]->GetMaximumBin())+1; } + if( plot[3]->GetBinContent(plot[3]->GetMaximumBin()) > MAXY ) { MAXY = plot[3]->GetBinContent(plot[3]->GetMaximumBin())+1; } + + TCanvas* cm2 = new TCanvas("SUM",Form("SUM: %s", fFilename), 50,100,250*2,300); + cm2->Divide(2,1); + cm2->cd(1); + plot[0]->SetStats(false); + plot[0]->SetAxisRange(MINX-5,MAXX+5); + plot[0]->SetMaximum(MAXY+10); + plot[0]->Draw(); + cm2->cd(2); + plot2->SetStats(false); + plot2->Draw("colz"); + + for(int i=1;i<4;i++) + { + cm2->cd(1); + plot[i]->SetStats(false); + plot[i]->SetLineColor(i); + plot[i]->Draw("same"); + } + + + + + + cout<<"\r ...done for "<Close(); + cout<<"-------------"<GetEntry(thr); + + for(int pix=0;pix<1152*576;pix++) + { + pixelprob_arr[pix*fNthr+thr] = fPixelprob[pix]; + } + +// threshold_arr[thr] = (int)fThreshold; + } + +// Check whether RndPix + int column, row, matrix; + int* RndPx; + int pix; + int nrpixels = 1152*576; + + if(fPixSel) + { + nrpixels = 4*fNRndPx; + RndPx = new int[nrpixels]; + + for(int i=0;i MAXX ) { MAXX=mean[i]; } + + plot[matrix]->Fill( mean[i] ); + plot2 ->Fill( column, row, mean[i] ); + + if( mean[i]==0 && row!=573 && row!=0) + { + if(pixelprob_arr[pix*fNthr]==0) {pixelprob_arr[pix*fNthr]=0.01;} + plot2a ->Fill( column, row, pixelprob_arr[pix*fNthr] ); + cout<<"\r"<GetBinContent(plot[0]->GetMaximumBin()) > MAXY ) { MAXY = plot[0]->GetBinContent(plot[0]->GetMaximumBin())+1; } + if( plot[1]->GetBinContent(plot[1]->GetMaximumBin()) > MAXY ) { MAXY = plot[1]->GetBinContent(plot[1]->GetMaximumBin())+1; } + if( plot[2]->GetBinContent(plot[2]->GetMaximumBin()) > MAXY ) { MAXY = plot[2]->GetBinContent(plot[2]->GetMaximumBin())+1; } + if( plot[3]->GetBinContent(plot[3]->GetMaximumBin()) > MAXY ) { MAXY = plot[3]->GetBinContent(plot[3]->GetMaximumBin())+1; } + + TCanvas* cm2 = new TCanvas("RMS",Form("RMS: %s", fFilename), 50,100,250*2,300*2); + cm2->Divide(2,2); + cm2->cd(1); + plot[0]->SetStats(false); + plot[0]->SetAxisRange(MINX,MAXX+1); + plot[0]->SetMaximum(MAXY+10); + plot[0]->Draw(); + cm2->cd(2); + plot2->SetStats(false); + plot2->Draw("colz"); + + cm2->cd(4); + plot2a->SetStats(false); + plot2a->Draw("colz"); + + for(int i=1;i<4;i++) + { + cm2->cd(1); + plot[i]->SetStats(false); + plot[i]->SetLineColor(i); + plot[i]->Draw("same"); + } + + + + + + cout<<"\r ...done for "<Close(); + cout<<"-------------"<GetEntry(i); +// +// for(int pix=0;pix<1152*576;pix++) +// { +// sum[pix]+=pixelprob[pix]; +// } +// } +// +// float column, row; +// +// TH1F* plot = new TH1F( "sum","sum",2550,0,255); +// TH2F* plot2 = new TH2F( "sum2","sum2",1152,0,1152,576,0,576); +// +// for(int pix=0;pix<1152*576;pix++) +// { +// column = (int)(pix%1152); +// row = (int)(pix/1152.); +// +// plot->Fill(sum[pix]); +// plot2->Fill(column, row, sum[pix]); +// +// if(row==1)cout<Divide(2,1); +// cm2->cd(1); +// plot->Draw(); +// cm2->cd(2); +// plot2->Draw("colz"); +// +// cout<<"\r ...done for "<Close(); +// cout<<"-------------"<> fNRndPx; + fRndPx = new int[fNRndPx]; + + int count=0; + int pix; + + while( myfile.good() ) + { + myfile >> pix; + if( count +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TCanvas.h" +#include "TRootCanvas.h" +#include +#include +#include +#include "TH1.h" +#include "TF1.h" +#include "TSystem.h" +#include +#include "TROOT.h" +#include "TMath.h" +// #include "TSystem.h" + +using namespace std; + +class Mi26Ana { + +private: + void rewrite (); + void plotsc (); + void plotscsingle (); + void fitsc (); + void fitscsingle (); + void sumup (); + void fakes (); + void empty1 (); + void empty2 (); + + void sum (); +// void rewrite (); + + bool readPxFile (); + + TString fInputRootFile; + TString fInputPxFile; + int fNRndPx; + int* fRndPx; + int fNPx; + int fCode; + + TFile* fFile; + TTree* fTree; + UShort_t fThreshold; + Float_t* fPixelprob; +// UShort_t* fFrames; + int fNthr; + + bool fPixSel; + bool fMatrix[4]; + int fMatrixActive; + char fFilename[256]; + +public: + Mi26Ana(); + Mi26Ana( TString, TString, int, int, int ); + ~Mi26Ana(); + + void Exec (int); + + void setInFile (TString name) { fInputRootFile= name; } + void setPxFile (TString name) { fInputPxFile = name; } + void setNRndPx (int val) { fNRndPx = val; } + void setNPx (int val) { fNPx = val; } + void setCode (int val) { fCode = val; } +}; + +#endif // Mi26Ana_H + \ No newline at end of file diff --git a/s-curves/analysis_gui/ANA/ana.C b/s-curves/analysis_gui/ANA/ana.C new file mode 100644 index 0000000..2319bde --- /dev/null +++ b/s-curves/analysis_gui/ANA/ana.C @@ -0,0 +1,524 @@ +#include +#include +#include +#include +#include +#include +#include "TROOT.h" +#include "TObject.h" +#include "TBrowser.h" +#include "TH1F.h" +#include "TMath.h" +#include "TF1.h" +#include "TH2F.h" +#include "TCanvas.h" +#include "TGraph.h" + + +void plotsc(); +//#################################################################### + +void ana( ) { + + plotsc(); + + +// if(i==0) { plotsc(); } +} + +void sum() { + cout<<"-------------"<Get( "scurvesall" ); + + tree -> SetBranchAddress ("threshold" , &threshold ); + tree -> SetBranchAddress ("pixelprob" , pixelprob ); + tree -> SetBranchAddress ("frames" , frames ); + +// -------------- + Int_t nthr = tree->GetEntries(); +// if (nthr % 4 != 0){ +// printf("Error: %d not divisible by 4!", nthr); +// exit(1); +// } +// nthr = nthr/4; + + for(int i=0;iGetEntry(i); + + for(int pix=0;pix<1152*576;pix++) + { + sum[pix]+=pixelprob[pix]; + } + } + + float column, row; + + TH1F* plot = new TH1F( "sum","sum",2550,0,255); + TH2F* plot2 = new TH2F( "sum2","sum2",1152,0,1152,576,0,576); + + for(int pix=0;pix<1152*576;pix++) + { + column = (int)(pix%1152); + row = (int)(pix/1152.); + + plot->Fill(sum[pix]); + plot2->Fill(column, row, sum[pix]); + + if(row==1)cout<Divide(2,1); + cm2->cd(1); + plot->Draw(); + cm2->cd(2); + plot2->Draw("colz"); + + cout<<"\r ...done for "<Close(); + cout<<"-------------"<Get( "scurvesall" ); + + tree -> SetBranchAddress ("threshold" , &threshold ); + tree -> SetBranchAddress ("pixelprob" , pixelprob ); + tree -> SetBranchAddress ("frames" , frames ); + +// File OUT + TString RootFileOut = "outputsc.root"; + TFile* fout = new TFile(RootFileOut,"RECREATE"); + TTree* treeout = new TTree( "scurvesall" , "scurvesall" ); + + treeout -> Branch("threshold" , &threshold , "threshold/s" , 32000); +// treeout -> Branch("pixel" , pixel , "pixel[663552]/I" , 32000); + treeout -> Branch("pixelprob" , pixelprobout , "pixelprob[663552]/F" , 32000); +// -------------- + Int_t nthr = tree->GetEntries(); + if (nthr % 4 != 0){ + printf("Error: %d not divisible by 4!", nthr); + exit(1); + } + nthr = nthr/4; + + for(int i=0;iGetEntry(i+j*nthr); + + for(int pix=0;pix<1152*576;pix++) + { + if( pix%1152>=1152/4*(j) && pix%1152<1152/4*(j+1) ) + { + pixelprobout[pix] = pixelprob[pix]; + } + } + } + + cout<<"\rThreshold: "<Fill(); + } + cout<<"\r ...done! "< Write("",TObject::kOverwrite); + fout->Save(); + fout->Close(); + f->Close(); + cout<<"-------------"<Get( "scurvesall" ); + + tree -> SetBranchAddress ("threshold" , &threshold ); +// tree -> SetBranchAddress ("pixel" , pixel ); + tree -> SetBranchAddress ("pixelprob" , pixelprob ); +// -------------- + Int_t nthr = tree->GetEntries(); + + int row, column; + int matrix; + + TH1F* plot[1152*576]; + for(int i=0;i<1152*576;i++) + { + plot[i] = new TH1F( Form("plot%i",i), Form("plot%i",i), nthr,0,255); + } + + TH2F * ploti[4]; + for(int i=0;i<4;i++) + { + ploti[i] = new TH2F( Form("ploti%i",i), Form("ploti%i",i), nthr,0,255, 500,0,1.05); + } + + for(int i=0;iGetEntry(i); + + for(int pix=0;pix<1152*576;pix++) + { + column = pix%1152; + row = (int)(pix/1152); + + matrix = int(column/288); + + plot[pix] ->Fill(threshold,pixelprob[pix]); + + if( row!=0 && row!=573 ) + { + ploti[matrix] ->Fill(threshold,pixelprob[pix]); + } + + if(pix==1152) { cout<Divide(4,1); + + /* + bool FIRST[4]= {0,0,0,0}; + for(int pix=0;pix<1152*576;pix++) + { + + column = pix%1152; + row = (int)(pix/1152); + + matrix = int(column/288); + + if(1) // Choose your conditions for which pixel you want to plot the scurves + { + + if( row!=0 && row!=573 ) + { + cm2->cd(matrix+1); + + // if(row<288) + // { + plot[pix]->SetLineColor(2); + // } + // else + // { + // plot[pix]->SetLineColor(3); + // } + + if( FIRST[matrix] ) + { + plot[pix]->Draw("same"); + } + else + { + plot[pix]->Draw(); + FIRST[matrix] = 1; + } + } + } + } + cm2->SaveAs("file.pdf"); + */ + + + for(int i=0;i<4;i++) + { + cm2->cd(i+1); + ploti[i]->Draw(); + } + +// f->Close(); +} + +//#################################################################### + +void calcpara() { + + UShort_t threshold; + Int_t pixel, row, column; +// Int_t* pixel = new Int_t [1152*576]; + Float_t* pixelprob = new Float_t [1152*576]; + Float_t mean, sigma, chi2; + +// File IN +// TString RootFile = "outputsc.root"; + TString RootFile = "messung.root"; + TFile* f = new TFile(RootFile); + TTree* tree = (TTree*)f->Get( "scurvesall" ); + + tree -> SetBranchAddress ("threshold" , &threshold ); +// tree -> SetBranchAddress ("pixel" , pixel ); + tree -> SetBranchAddress ("pixelprob" , pixelprob ); + +// File OUT + TString RootFileOut = "outputpara2.root"; +// TFile* fout = new TFile(RootFileOut,"RECREATE"); + TTree* paraTree[4]; + + for(int ba=0;ba<4;ba++) + { + paraTree[ba] = new TTree( Form("para%i",ba), Form("para%i",ba)); + paraTree[ba] -> Branch("pixel" , &pixel , "pixel/i" , 32000); + paraTree[ba] -> Branch("row" , &row , "row/i" , 32000); + paraTree[ba] -> Branch("column" , &column , "column/F" , 32000); + paraTree[ba] -> Branch("mean" , &mean , "mean/F" , 32000); + paraTree[ba] -> Branch("sigma" , &sigma , "sigma/F" , 32000); + paraTree[ba] -> Branch("chi2" , &chi2 , "chi2/F" , 32000); + } +// -------------- + Int_t entries = tree->GetEntries(); + + printf("\n-------------\n"); + printf("Found thresholds: %i\n",entries); + printf("-------------\n"); + + Float_t* pixelprob_arr = new Float_t[entries*1152*576]; + Int_t* threshold_arr = new Int_t[entries]; + + TH1F *histos, *histo[12]; + histos = new TH1F( "test", "test" , entries,0.,255.); + histo[0] = new TH1F( "mean0" , "mean0" , 2550,0.,255.); + histo[1] = new TH1F( "mean1" , "mean1" , 2550,0.,255.); + histo[2] = new TH1F( "mean2" , "mean2" , 2550,0.,255.); + histo[3] = new TH1F( "mean3" , "mean3" , 2550,0.,255.); + histo[4] = new TH1F( "sigma0", "sigma0" , 1000,0.,100.); + histo[5] = new TH1F( "sigma1", "sigma1" , 1000,0.,100.); + histo[6] = new TH1F( "sigma2", "sigma2" , 1000,0.,100.); + histo[7] = new TH1F( "sigma3", "sigma3" , 1000,0.,100.); + histo[8] = new TH1F( "chi20" , "chi20" , 1000,0.,1.); + histo[9] = new TH1F( "chi21" , "chi21" , 1000,0.,1.); + histo[10] = new TH1F( "chi22" , "chi22" , 1000,0.,1.); + histo[11] = new TH1F( "chi23" , "chi23" , 1000,0.,1.); + + TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100); + + int chicount=0; + int meanmin, meanmax; + float meanmean; + float vsigma; + float vtmp=1; +// int column; +// int row; + int matrix; + float MAXX[3] = {0, 0, 0}; + double MAXY[3] = {0, 0, 0}; + + TCanvas* canv = new TCanvas("sc","sc", 50,100,900,600); + canv->Divide(3,1); + + printf("Perform fitting of S-Curces:\n"); + + for(int thr=0;thrGetEntry(thr); + + for(int pix=0;pix<1152*576;pix++) + { + pixelprob_arr[pix*entries+thr] = pixelprob[pix]; + } + + threshold_arr[thr] = (int)threshold; + + } + + for(int pix=0;pix<1152*576;pix++) + { +// if(pix%100==0) { +// printf("\r - %6.1f %% - %5i -", 100.*pix/(1152*576), pix); +// // canv->Update(); +// fflush(stdout); +// } + + if( TMath::RMS(entries,&pixelprob_arr[pix*entries])!=0 ) + { + delete histos; + histos = new TH1F( "test", "test" , entries,0.,255.); + + meanmin=0; + meanmax=255; + + for(int thr=0;thrFill(threshold_arr[thr],pixelprob_arr[pix*entries+thr]); + + if( pixelprob_arr[pix*entries+thr]!=1 && meanmin==0 ) { meanmin=threshold_arr[thr]-1; } + if( pixelprob_arr[pix*entries+thr]==0 && vtmp!=0 ) { meanmax=threshold_arr[thr]; } + vtmp = pixelprob_arr[pix*entries+thr]; + } + + vsigma = (meanmax-meanmin)/2.; + meanmean = (meanmax+meanmin)/2.; + erf->SetParameters(meanmean,vsigma); + + pixel = pix; + column = pix%1152; + row = (int)(pix/1152); + matrix = int(column/288); + + if( row!=0 && row!=1 && row!=573 && column<288) + { + histos->Fit(erf,"QN"); + + mean = erf->GetParameter(0); + sigma = erf->GetParameter(1)/TMath::Sqrt(2); + chi2 = erf->GetChisquare()/erf->GetNDF(); + + chicount=0; + + if( meanmeanmax || sigma>75 || sigma<1 ) + { + chicount=0; + //printf("\r----- \n"); + //printf("%7i (%10i) %10.2f (%10i) %10.2f (%10f) %10.3f\n", pixel, meanmin, mean,meanmax, sigma,vsigma, chi2); + + while( (meanmeanmax || sigma>75 || sigma<0.0001) && chicount<10) + { + erf->SetParameters(meanmean,1.*(chicount+1)); + histos->Fit(erf,"QMN"); + pixel = pix; + mean = erf->GetParameter(0); + sigma = erf->GetParameter(1)/TMath::Sqrt(2); + chi2 = erf->GetChisquare()/erf->GetNDF(); + chicount++; + + // printf("%7i (%10i) %10.2f (%10i) %10.2f (%10f) %10.3f\n", pixel, meanmin, mean,meanmax, sigma,vsigma, chi2); + } + } + + histo[0+matrix]->Fill(mean); + histo[4+matrix]->Fill(sigma); + histo[8+matrix]->Fill(chi2); + + if( mean > MAXX[0] ) { MAXX[0]=mean+1; } + if( sigma > MAXX[1] ) { MAXX[1]=sigma+1; } + if( chi2 > MAXX[2] ) { MAXX[2]=chi2+0.01; } + + if(pix%100==0) + { + printf("\r Pixel: %5i - %6.1f %% - fit attempts: %5i - %6.2f %6.2f %6.5f", pix, 100.*pix/(1152*576), chicount, mean, sigma, chi2); fflush(stdout); + + if(pix%5000==0) + { + + if( histo[0]->GetBinContent(histo[0]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[0]->GetBinContent(histo[0]->GetMaximumBin())+1; } + if( histo[1]->GetBinContent(histo[1]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[1]->GetBinContent(histo[1]->GetMaximumBin())+1; } + if( histo[2]->GetBinContent(histo[2]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[2]->GetBinContent(histo[2]->GetMaximumBin())+1; } + if( histo[3]->GetBinContent(histo[3]->GetMaximumBin()) > MAXY[0] ) { MAXY[0] = histo[3]->GetBinContent(histo[3]->GetMaximumBin())+1; } + + if( histo[4]->GetBinContent(histo[4]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[4]->GetBinContent(histo[4]->GetMaximumBin())+1; } + if( histo[5]->GetBinContent(histo[5]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[5]->GetBinContent(histo[5]->GetMaximumBin())+1; } + if( histo[6]->GetBinContent(histo[6]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[6]->GetBinContent(histo[6]->GetMaximumBin())+1; } + if( histo[7]->GetBinContent(histo[7]->GetMaximumBin()) > MAXY[1] ) { MAXY[1] = histo[7]->GetBinContent(histo[7]->GetMaximumBin())+1; } + + if( histo[8]->GetBinContent(histo[8]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[8]->GetBinContent(histo[8]->GetMaximumBin())+1; } + if( histo[9]->GetBinContent(histo[9]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[9]->GetBinContent(histo[9]->GetMaximumBin())+1; } + if( histo[10]->GetBinContent(histo[10]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[10]->GetBinContent(histo[10]->GetMaximumBin())+1; } + if( histo[11]->GetBinContent(histo[11]->GetMaximumBin()) > MAXY[2] ) { MAXY[2] = histo[11]->GetBinContent(histo[11]->GetMaximumBin())+1; } + + canv->cd(1); + histo[0]->SetLineColor(1); + histo[0]->Draw(); + histo[0]->SetAxisRange(0,MAXX[0]); + histo[0]->SetMaximum(MAXY[0]); + histo[1]->SetLineColor(2); + histo[1]->Draw("same"); + histo[2]->SetLineColor(3); + histo[2]->Draw("same"); + histo[3]->SetLineColor(4); + histo[3]->Draw("same"); + + canv->cd(2); + histo[4]->SetLineColor(1); + histo[4]->Draw(); + histo[4]->SetAxisRange(0,MAXX[1]); + histo[4]->SetMaximum(MAXY[1]); + histo[5]->SetLineColor(2); + histo[5]->Draw("same"); + histo[6]->SetLineColor(3); + histo[6]->Draw("same"); + histo[7]->SetLineColor(4); + histo[7]->Draw("same"); + + canv->cd(3); + histo[8]->SetLineColor(1); + histo[8]->Draw(); + histo[8]->SetAxisRange(0,MAXX[2]); + histo[8]->SetMaximum(MAXY[2]); + histo[9]->SetLineColor(2); + histo[9]->Draw("same"); + histo[10]->SetLineColor(3); + histo[10]->Draw("same"); + histo[11]->SetLineColor(4); + histo[11]->Draw("same"); + + canv->Update(); + } + } + + paraTree[matrix]->Fill(); + } + } + } + + + for(int ba=0;ba<4;ba++) + { + paraTree[ba]->Write("",TObject::kOverwrite); + } + +// fout->Save(); +// fout->Close(); +// f->Close(); + cout<<"\n-------------"< +#include +#include +#include +#include +#include +#include +#include "TStopwatch.h" + +//#################################################################### + +Int_t print_progress(Float_t ProgressInPercent) { + + Int_t nCharacter = printf("\r ["); + Int_t iBlock; + + for( iBlock=0; iBlockReset(); + + const char* InFile; + const char* PxFile; + int Mode; + int NPx; // Pixelnummer + int NRndPx; // Amount of random pixels + int Code; + + stringstream strValue; + + if (argc>1) InFile = argv[1]; + if (argc>2) PxFile = argv[2]; + if (argc>3) strValue<> Mode; strValue.clear(); + if (argc>4) strValue<> NPx; strValue.clear(); + if (argc>5) strValue<> NRndPx; strValue.clear(); + if (argc>6) strValue<> Code; strValue.clear(); + +// cout<<" -- main 1 -- "<setInFile (InFile); + ana->setPxFile (PxFile); + ana->setNRndPx (NRndPx); + ana->setNPx (NPx); + ana->setCode (Code); + ana->Exec (Mode); + delete ana; + theApp.Run(); +} \ No newline at end of file diff --git a/s-curves/analysis_gui/GUI/Makefile b/s-curves/analysis_gui/GUI/Makefile new file mode 100644 index 0000000..cff0ab3 --- /dev/null +++ b/s-curves/analysis_gui/GUI/Makefile @@ -0,0 +1,240 @@ +############################################################################# +# Makefile for building: scurves +# Generated by qmake (2.01a) (Qt 4.8.5) on: Wed Oct 8 16:06:56 2014 +# Project: scurves.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile scurves.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I$(ROOTSYS)/include -I. -I. +LINK = g++ +LFLAGS = -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib64 -L$(ROOTSYS)/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -lRGL -lQtGui -L/usr/lib64 -L/usr/X11R6/lib -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + scurves.cpp moc_scurves.cpp +OBJECTS = main.o \ + scurves.o \ + moc_scurves.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/shared.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + scurves.pro +QMAKE_TARGET = scurves +DESTDIR = +TARGET = scurves + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): ui_scurves.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: scurves.pro /usr/share/qt4/mkspecs/default/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/shared.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib64/libQtGui.prl \ + /usr/lib64/libQtCore.prl + $(QMAKE) -o Makefile scurves.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/shared.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib64/libQtGui.prl: +/usr/lib64/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile scurves.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/scurves1.0.0 || $(MKDIR) .tmp/scurves1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/scurves1.0.0/ && $(COPY_FILE) --parents scurves.h .tmp/scurves1.0.0/ && $(COPY_FILE) --parents main.cpp scurves.cpp .tmp/scurves1.0.0/ && $(COPY_FILE) --parents scurves.ui .tmp/scurves1.0.0/ && (cd `dirname .tmp/scurves1.0.0` && $(TAR) scurves1.0.0.tar scurves1.0.0 && $(COMPRESS) scurves1.0.0.tar) && $(MOVE) `dirname .tmp/scurves1.0.0`/scurves1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/scurves1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: moc_scurves.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_scurves.cpp +moc_scurves.cpp: ui_scurves.h \ + scurves.h + /usr/bin/moc $(DEFINES) $(INCPATH) scurves.h -o moc_scurves.cpp + +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_scurves.h +compiler_uic_clean: + -$(DEL_FILE) ui_scurves.h +ui_scurves.h: scurves.ui + /usr/bin/uic scurves.ui -o ui_scurves.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_uic_clean + +####### Compile + +main.o: main.cpp scurves.h \ + ui_scurves.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +scurves.o: scurves.cpp scurves.h \ + ui_scurves.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o scurves.o scurves.cpp + +moc_scurves.o: moc_scurves.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_scurves.o moc_scurves.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/s-curves/analysis_gui/GUI/main.cpp b/s-curves/analysis_gui/GUI/main.cpp new file mode 100644 index 0000000..59db195 --- /dev/null +++ b/s-curves/analysis_gui/GUI/main.cpp @@ -0,0 +1,22 @@ +// --- main.cpp - start --- + +#include "scurves.h" +#include +#include + +int main( int argc, char* argv[] ) +{ + TApplication* gMyRootApp = new TApplication("My ROOT Application", &argc, argv); + gMyRootApp->SetReturnFromRun(true); +// gMyRootApp->Run(kTRUE); + + QApplication a(argc, argv); + scurves w; + w.show(); + + w.setWindowTitle(QString::fromUtf8("S-Curves GUI")); +// QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) ); + return a.exec(); +} + +// --- main.cpp - end --- diff --git a/s-curves/analysis_gui/GUI/scurves.cpp b/s-curves/analysis_gui/GUI/scurves.cpp new file mode 100644 index 0000000..6f0f4b5 --- /dev/null +++ b/s-curves/analysis_gui/GUI/scurves.cpp @@ -0,0 +1,660 @@ +// --- scurves.cpp - start --- +#include "scurves.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "TCanvas.h" +#include "TRootCanvas.h" +#include +#include +#include +#include "TH1.h" +#include "TF1.h" +#include "TSystem.h" +#include +#include "TROOT.h" +// #include "TSystem.h" + + + +using namespace std; + +//#################################################################### + +scurves::scurves(QMainWindow *parent) : QMainWindow(parent) { + + setupUi(this); +// Init inputs + initGUI(); + childcount=0; +// TApplication* gMyRootApp = new TApplication("My ROOT Application", &argc, argv); +// gMyRootApp->SetReturnFromRun(true); + + connect(pushSave ,SIGNAL( clicked() ) ,this ,SLOT( Save() ) ); + connect(pushFindNew ,SIGNAL( clicked() ) ,this ,SLOT( Newest() ) ); + connect(pushUnpack ,SIGNAL( clicked() ) ,this ,SLOT( Unpack() ) ); + connect(pushIdentRandPix ,SIGNAL( clicked() ) ,this ,SLOT( RandPix() ) ); + connect(pushClose ,SIGNAL( clicked() ) ,this ,SLOT( Close() ) ); + connect(pushOpenBrowser ,SIGNAL( clicked() ) ,this ,SLOT( OpenBrowser() ) ); + connect(lineDir ,SIGNAL( textChanged(QString) ) ,this ,SLOT( clickDir() ) ); + connect(lineFile ,SIGNAL( textChanged(QString) ) ,this ,SLOT( clickFile() ) ); + connect(spinRow ,SIGNAL( valueChanged(int) ) ,this ,SLOT( calcPix(int) ) ); + connect(spinCol ,SIGNAL( valueChanged(int) ) ,this ,SLOT( calcPix(int) ) ); + connect(spinPix ,SIGNAL( valueChanged(int) ) ,this ,SLOT( calcRC(int) ) ); + + QSignalMapper *signalMapper = new QSignalMapper(this); + QSignalMapper *signalMapper2 = new QSignalMapper(this); + + signalMapper ->setMapping( pushRewrite , 0); + signalMapper ->setMapping( pushPlotSc , 1); + signalMapper ->setMapping( pushPlotScSingle , 2); + signalMapper ->setMapping( pushFitSc , 3); + signalMapper ->setMapping( pushFitScSingle , 4); + signalMapper ->setMapping( pushSum , 5); + signalMapper ->setMapping( pushFakes , 6); + signalMapper ->setMapping( pushEmpty1 , 7); + signalMapper ->setMapping( pushEmpty2 , 8); + signalMapper2 ->setMapping( pushFindBack , -1); + signalMapper2 ->setMapping( pushFindForth , 1); + + connect(pushRewrite ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushPlotSc ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushPlotScSingle ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushFitSc ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushFitScSingle ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushSum ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushFakes ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushEmpty1 ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushEmpty2 ,SIGNAL( clicked(bool) ) ,signalMapper, SLOT( map() ) ); + connect(pushFindBack ,SIGNAL( clicked(bool) ) ,signalMapper2, SLOT( map() ) ); + connect(pushFindForth ,SIGNAL( clicked(bool) ) ,signalMapper2, SLOT( map() ) ); + + connect(signalMapper ,SIGNAL( mapped(int) ) ,this ,SLOT( RunAna (int) ) ); + connect(signalMapper2 ,SIGNAL( mapped(int) ) ,this ,SLOT( NextFile (int) ) ); + +// checkRandPix +// checkBank1 +// checkBank2 +// checkBank3 +// checkBank4 +// spinRandPix + +} + +//#################################################################### + +scurves::~scurves() { + + Save(); + Close(); +} + +//#################################################################### + +void scurves::initGUI() { + + ifstream myfile ( "scurves.ini"); + string line; + int para; + + if (myfile.is_open()) + { + getline( myfile, line ); + lineDir -> insert( QString::fromStdString(line) ); + getline( myfile, line ); + lineFile -> insert( QString::fromStdString(line) ); + + myfile >> para; + if( para ) { checkBank1 -> setChecked(true); } + myfile >> para; + if( para ) { checkBank2 -> setChecked(true); } + myfile >> para; + if( para ) { checkBank3 -> setChecked(true); } + myfile >> para; + if( para ) { checkBank4 -> setChecked(true); } + myfile >> para; + if( para ) { checkRandPix -> setChecked(true); } + myfile >> para; + radioHld -> setChecked(true); + if( para ) { radioRoot -> setChecked(true); } + + + myfile >> para; + spinRandPix -> setValue( para ); + myfile >> para; + spinPix -> setValue( para ); calcRC(para); + + + } + +} + +//#################################################################### + +bool scurves:: checkDir() { + + QString text = lineDir ->text(); + QByteArray bytes = text.toAscii(); + char *Dir = bytes.data(); + +// Add '/' at the end of Dir + if( Dir[strlen(Dir)-1] != '/' ) + { + strcat(Dir, "/" ); + lineDir -> clear(); + lineDir -> insert( QString(Dir) ); + } + +// Check whether Dir exists + DIR* dpdf = opendir(Dir); + + if (dpdf != NULL) { lineDir->setStyleSheet("QLineEdit { color:black; }"); return true; } + else { lineDir->setStyleSheet("QLineEdit { color:red; }"); return false; } +} + +//#################################################################### + +bool scurves:: checkFile() { + + if(checkDir()) + { + QString text; + QByteArray bytes; + char *Dir; + char *File; + + text = lineDir ->text(); + bytes = text.toAscii(); + Dir = bytes.data(); + + text = lineFile ->text(); + bytes = text.toAscii(); + File = bytes.data(); + + char Filecurr [256]; + strcpy (Filecurr, Dir); + strcat (Filecurr, File); + + struct stat buffer; + + if( stat (Filecurr, &buffer) == 0) { lineFile->setStyleSheet("QLineEdit { color:black; }"); return true; } + else { lineFile->setStyleSheet("QLineEdit { color:red; }"); return false; } + } + + return 0; +} + +//#################################################################### + +void scurves::Save() { + + + checkDir(); + checkFile(); + + fstream myfile; + myfile.open( "scurves.ini" , ios::out ); + myfile << ( lineDir -> text()).toStdString() < text()).toStdString() < isChecked() <<" "; + myfile << checkBank2 -> isChecked() <<" "; + myfile << checkBank3 -> isChecked() <<" "; + myfile << checkBank4 -> isChecked() <<" "; + myfile << checkRandPix -> isChecked() <<" "; + myfile << radioRoot -> isChecked() <<" "; + myfile <value() <<" "; + myfile << spinPix ->value() <<" "; + myfile <text(); + bytes = text.toAscii(); + Dir = bytes.data(); + + text = lineFile ->text(); + bytes = text.toAscii(); + File = bytes.data(); + + time_t timeref = 0; + time_t timecurr = 0; + time_t timenew = 2000000000; + if(sign==-1) {timenew = -2000000000;} + + char Fileref [256]; + char Filecurr [256]; + char Filenew [256] = ""; + + strcpy (Fileref, Dir); + strcat (Fileref, File); + + struct stat buff; + if( stat (Fileref, &buff) == 0 ) { lineFile->setStyleSheet("QLineEdit { color:black; }"); timeref = buff.st_mtime; } + else { lineFile->setStyleSheet("QLineEdit { color:red; }"); timeref = timenew; sign=-1*sign; timenew= -1*timenew; } + + text = lineDir ->text(); + bytes = text.toAscii(); + Dir = bytes.data(); + + text = lineFile ->text(); + bytes = text.toAscii(); + File = bytes.data(); + + char Ending [4]; + if( radioRoot -> isChecked() ) { strcpy (Ending, "root"); } + else { strcpy (Ending, "hld"); } + + uint Endinglength = strlen(Ending); + + DIR* dpdf; + struct dirent* epdf; + struct stat s; + uint namelength; + bool Endingcorr; + + dpdf = opendir(Dir); +// init File_new +// strcpy (File_new, ""); + + if (dpdf != NULL) + { + while ( (epdf = readdir(dpdf)) != NULL ) + { + if( (string) epdf->d_name != "." && (string) epdf->d_name != ".." ) + { + strcpy (Filecurr, Dir); + strcat (Filecurr, epdf->d_name); + + stat (Filecurr, &s); + timecurr = s.st_mtime; + namelength = strlen(Filecurr); + Endingcorr = true; + + if(namelength>Endinglength) + { + for(uint i=0; isign*timeref ) + { +// cout<sign*timecurr) + { + strcpy (Filenew, epdf->d_name); + timenew = timecurr; + } + } + } + } + } + } + + if ( strlen(Filenew)!=0 ) + { + lineFile -> clear(); + lineFile -> insert( QString(Filenew) ); + } +// else +// { +// pushFindBack ->setStyleSheet("* { background-color: red }"); +// pushFindForth ->setStyleSheet("* { background-color: red }"); +// pushFindBack ->setStyleSheet("* { background-color: lightGray }"); +// pushFindForth ->setStyleSheet("* { background-color: lightGray }"); +// } + } +} + +//#################################################################### + +void scurves::Newest() { + + if(checkDir()) + { + QString text = lineDir-> text(); + QByteArray bytes = text.toAscii(); + char *Dir = bytes.data(); + + time_t timecurr = 0; + time_t timenew = 0; + char Filecurr [256]; + char Filenew [256] = ""; + + char Ending [4]; + if( radioRoot -> isChecked() ) { strcpy (Ending, "root"); } + else { strcpy (Ending, "hld"); } + + uint Endinglength = strlen(Ending); + + DIR* dpdf; + struct dirent* epdf; + struct stat s; + uint namelength; + bool Endingcorr; + + dpdf = opendir(Dir); +// init File_new +// strcpy (File_new, ""); + + if (dpdf != NULL) + { + while ( (epdf = readdir(dpdf)) != NULL ) + { + if( (string) epdf->d_name != "." && (string) epdf->d_name != ".." ) + { + strcpy (Filecurr, Dir); + strcat (Filecurr, epdf->d_name); + + stat (Filecurr, &s); + timecurr = s.st_mtime; + namelength = strlen(Filecurr); + + Endingcorr = true; + + if(namelength>Endinglength) + { + for(uint i=0; id_name); + timenew = timecurr; + } + } + } + } + } + + if( strlen(Filenew)!=0 ) + { + lineFile -> clear(); + lineFile -> insert( QString(Filenew) ); + } + else + { + lineFile->setStyleSheet("QLineEdit { color:red; }"); + } + + } +} + +//#################################################################### + +void scurves::Unpack() { + + QString text; + QByteArray bytes; + char *Dir; + char *File; + char Filein [256] = ""; + char Fileout[256] = ""; + + text = lineDir ->text(); + bytes = text.toAscii(); + Dir = bytes.data(); + + text = lineFile ->text(); + bytes = text.toAscii(); + File = bytes.data(); + + + strcpy (Filein, Dir); + strcat (Filein, File); + + uint namelength = strlen(Filein); + + for(uint i=0; istart(ptr); + childcount++; + +} + +//#################################################################### + +void scurves::OpenBrowser() { + + QString text; + QByteArray bytes; + char *Dir; + char *File; + char Filein [256] = ""; + + text = lineDir ->text(); + bytes = text.toAscii(); + Dir = bytes.data(); + + text = lineFile ->text(); + bytes = text.toAscii(); + File = bytes.data(); + + strcpy (Filein, Dir); + strcat (Filein, File); + + string command = ""; + command += "xterm -geometry 130x10+10+10 -e root -l "; + command += Filein; + + const char *ptr = command.c_str() ; + + child[childcount] = new QProcess(); +// connect(child[childcount], SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(isFinished( int, QProcess::ExitStatus ))); + child[childcount]->start(ptr); + childcount++; + +} + +//#################################################################### + +void scurves::RandPix() { + + int randPixel = spinRandPix->value(); + int arr[randPixel]; + + srand( (unsigned) time(NULL) ) ; + + int rndnum; + int count = 0; + int loop; + + fstream myfile; + myfile.open( "rndmpxl.ini" , ios::out ); + + myfile << randPixel <5*1152/4 && rndnum<(576-5)*1152/4 ) + { + for(loop=0;loopsetStyleSheet("QLineEdit { color:black; }"); +} + +//#################################################################### + +void scurves::clickFile() { + lineFile->setStyleSheet("QLineEdit { color:black; }"); +} + +//#################################################################### + +void scurves::calcPix(int) { + + spinPix -> setValue( (288*spinRow->value())+spinCol->value() ); +} + +//#################################################################### + +void scurves::calcRC(int pix) { + + int row = (int)(pix/288); + int col = pix%288; + + spinRow -> setValue( row ); + spinCol -> setValue( col ); +} + +//#################################################################### + +void scurves::Close() { + + + for(int i=0;iclose(); + } + + childcount=0; + +} + +//#################################################################### + +void scurves::Error() { + + QMessageBox* box = new QMessageBox(); + box->setWindowTitle(QString("Error")); +// box->setText(QString("Current Text:\""+text+"\"")); + box->setText(QString("Directory not found!")); + box->show(); +} + +//#################################################################### + +void scurves::RunAna(int method) { + + + string dirPath = ( lineDir -> text() ).toStdString(); + string filePath = ( lineFile-> text() ).toStdString(); + +// xterm -geometry 65x10+10+10 -e root -l "runreadgui.C+(\""3"\",\"/local/samir/test.root\","0","what","what","0")" + + std::stringstream strstr1; + strstr1.str(""); + strstr1 << method; + + std::stringstream strstr2; + strstr2.str(""); + strstr2 << spinPix->value(); + + std::stringstream strstr3; + strstr3.str(""); + strstr3 << spinRandPix->value(); + + std::stringstream strstr4; + strstr4.str(""); + strstr4 << checkRandPix->isChecked(); + strstr4 << checkBank1->isChecked(); + strstr4 << checkBank2->isChecked(); + strstr4 << checkBank3->isChecked(); + strstr4 << checkBank4->isChecked(); + + string command = "xterm -geometry 65x10+10+10 -e ./runana.sh "; + command += " "; + command += dirPath + filePath; + command += " "; + command += strstr1.str(); + command += " "; + command += strstr2.str(); + command += " "; + command += strstr3.str(); + command += " "; + command += strstr4.str(); + + const char *ptr = command.c_str() ; +// cout<start(ptr); + childcount++; + +} + +//#################################################################### +// --- scurves.cpp - end --- diff --git a/s-curves/analysis_gui/GUI/scurves.h b/s-curves/analysis_gui/GUI/scurves.h new file mode 100644 index 0000000..a03662f --- /dev/null +++ b/s-curves/analysis_gui/GUI/scurves.h @@ -0,0 +1,45 @@ +// --- Anaint.h - start --- + +#ifndef SCURVES_H +#define SCURVES_H + +#include "ui_scurves.h" +#include "TCanvas.h" +#include + +class scurves : public QMainWindow, public Ui::MainWindow { + + Q_OBJECT + +public: + scurves(QMainWindow *parent=0); + ~scurves(); + +public slots: + void Error (); + void Unpack (); + void OpenBrowser(); + void Save (); + void Newest (); + void RandPix (); + void Close (); + void clickDir (); + void clickFile (); + void calcPix (int); + void calcRC (int); + void RunAna (int); + void NextFile (int); + +private: + void initGUI(); + bool checkDir(); + bool checkFile(); + + QProcess* child[1000]; + int childcount; +}; + +#endif // SCURVES_H + +// --- scurves.h - end --- + diff --git a/s-curves/analysis_gui/GUI/scurves.pro b/s-curves/analysis_gui/GUI/scurves.pro new file mode 100644 index 0000000..b176ae1 --- /dev/null +++ b/s-curves/analysis_gui/GUI/scurves.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Oct 8 15:34:41 2014 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += $(ROOTSYS)/include +LIBS += -L$(ROOTSYS)/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -lRGL + +# Input +HEADERS += scurves.h +FORMS += scurves.ui +SOURCES += main.cpp scurves.cpp \ No newline at end of file diff --git a/s-curves/analysis_gui/GUI/scurves.ui b/s-curves/analysis_gui/GUI/scurves.ui new file mode 100644 index 0000000..781dbd9 --- /dev/null +++ b/s-curves/analysis_gui/GUI/scurves.ui @@ -0,0 +1,588 @@ + + + MainWindow + + + + 0 + 0 + 595 + 336 + + + + MainWindow + + + + + + 59 + 12 + 391 + 26 + + + + + + + 59 + 42 + 391 + 26 + + + + + + + 19 + 18 + 41 + 16 + + + + DIR + + + + + + 19 + 48 + 41 + 16 + + + + FILE + + + + + + 198 + 80 + 251 + 31 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 30 + 3 + 101 + 26 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 165888 + + + + + + 140 + 3 + 101 + 25 + + + + Rand. Pixels + + + + + + 5 + 5 + 21 + 23 + + + + CheckBox + + + + + + + 198 + 110 + 251 + 31 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 6 + 54 + 16 + + + + Bank(s) + + + + + + 65 + 5 + 41 + 23 + + + + 1 + + + + + + 113 + 5 + 41 + 23 + + + + 2 + + + + + + 161 + 5 + 41 + 23 + + + + 3 + + + + + + 209 + 5 + 41 + 23 + + + + 4 + + + + + + + 100 + 150 + 95 + 51 + + + + Plot + S-Curves + + + + + + 200 + 150 + 95 + 51 + + + + Fit + S-Curves + + + + + + 400 + 150 + 95 + 51 + + + + Open + Browser + + + + + + 470 + 15 + 95 + 51 + + + + Save + + + + + + 500 + 150 + 95 + 51 + + + + Empty 1 + + + + + + 97 + 201 + 201 + 111 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 114 + 80 + 81 + 26 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 165887 + + + 0 + + + + + + 103 + 3 + 95 + 51 + + + + Fit + S-Curve + + + + + + 3 + 3 + 95 + 51 + + + + Plot + S-Curve + + + + + + 34 + 56 + 61 + 26 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 575 + + + 0 + + + + + + 5 + 62 + 31 + 16 + + + + Row + + + + + + 34 + 80 + 61 + 26 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 287 + + + 0 + + + + + + 5 + 86 + 31 + 16 + + + + Col + + + + + + 119 + 67 + 31 + 16 + + + + Pix + + + + + + + 470 + 71 + 95 + 51 + + + + Close + windows + + + + + + 59 + 80 + 135 + 61 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 6 + 51 + 21 + + + + Qt::RightToLeft + + + hld + + + + + + 62 + 6 + 51 + 21 + + + + root + + + + + + 27 + 26 + 81 + 31 + + + + Find Newest + + + + + + 3 + 26 + 21 + 31 + + + + < + + + + + + 111 + 26 + 21 + 31 + + + + > + + + + + + + 0 + 150 + 95 + 51 + + + + Unpack + + + + + + 0 + 205 + 95 + 51 + + + + Rewrite + + + + + + 500 + 205 + 95 + 51 + + + + Empty 2 + + + + + + 300 + 150 + 95 + 51 + + + + Sum + + + + + + 300 + 205 + 95 + 51 + + + + RMS + + + + + + + 0 + 0 + 595 + 20 + + + + + + + + diff --git a/s-curves/analysis_gui/run.sh b/s-curves/analysis_gui/run.sh new file mode 100755 index 0000000..3173fa5 --- /dev/null +++ b/s-curves/analysis_gui/run.sh @@ -0,0 +1,11 @@ +# export LD_LIBRARY_PATH=/d/jspc22/dabc/lib/:$LD_LIBRARY_PATH +# echo "Input: $1" +# echo "Output: $4" +# ./unpacker $1 $2 $3 $4 +# echo "Finished!" + + +echo "Input: $1" +# echo "Output: $4" +./unpackerB $1 +echo "Finished!" diff --git a/s-curves/analysis_gui/runana.sh b/s-curves/analysis_gui/runana.sh new file mode 100755 index 0000000..feb8a1b --- /dev/null +++ b/s-curves/analysis_gui/runana.sh @@ -0,0 +1,15 @@ +echo "Input: $1" +# echo "Mode: $2" +rndmpxl=`pwd`/rndmpxl.ini +time ./Mi26Ana $1 $rndmpxl $2 $3 $4 $5 +# echo "Finished!" +# +# echo "./Mi26Ana $1 $rndmpxl $2 $3 $4 $5" +# echo "--- runana ---" +# echo $1 +# echo $rndmpxl +# echo $2 +# echo $3 +# echo $4 +# echo $5 +# echo "---------" \ No newline at end of file -- 2.43.0