From ab0d72a04e81c1fa31ba0ce5a77666e24f9a6b71 Mon Sep 17 00:00:00 2001
From: Samir Amar-Youcef <samir@ikf>
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<namelength;i++)	{ if ( longFile[i]=='/' ) { pos=i+1;} }
+	for(uint i=pos; i<namelength;i++)	{ shortFile[i-pos]=longFile[i];		 }
+	strcpy(fFilename, shortFile);
+	
+// Exec
+	if		( Mode == 0 )	{ rewrite();		}
+	else if	( Mode == 1 )	{ plotsc();			}
+	else if	( Mode == 2 )	{ plotscsingle();	}
+	else if	( Mode == 3 )	{ fitsc();			}
+	else if	( Mode == 4 )	{ fitscsingle();	}
+	else if	( Mode == 5 )	{ sumup();			}
+	else if	( Mode == 6 )	{ fakes();			}
+	else if	( Mode == 7 )	{ empty1();			}
+	else if	( Mode == 8 )	{ empty2();			}
+	
+	
+
+}
+
+//####################################################################
+
+void Mi26Ana::rewrite() {																// ok evtl. check to which extend
+	
+	cout<<"-------------"<<endl;
+	cout<<"REWRITE FILE: "<<endl;
+//  --------------
+	if (fNthr % 4 != 0){
+		printf("Error: %d not divisible by 4!", fNthr);
+		exit(1);
+	}
+	
+// Variables
+	int 		nthr		= fNthr/4;
+	Float_t*	pixelprobout= new Float_t	[1152*576];
+	
+// Determine Ouput Path
+	char	inputFile[256]		= "";
+	char	outputFile[256]	= "";
+	
+	strcpy	(inputFile, fInputRootFile);
+	
+	uint namelength = strlen(inputFile);			
+	
+	for(uint i=0; i<namelength-5;i++)
+	{
+		outputFile[i] = inputFile[i];
+	}
+	
+	strcat	(outputFile, "_re.root");
+
+	TFile*	fout		= new TFile(outputFile,"RECREATE");
+	TTree*	treeout		= new TTree( "scurvesall" , "scurvesall" );
+	
+	treeout -> Branch("threshold"	, &fThreshold		, "threshold/s"			, 32000);
+	treeout -> Branch("pixelprob"	, pixelprobout		, "pixelprob[663552]/F"	, 32000);
+	
+// Loop
+	for(int i=0;i<nthr;i++)
+	{
+		for(int j=0;j<4;j++)
+		{
+			fTree->GetEntry(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: "<<fThreshold<<" ( " <<i+1<<" of "<<nthr<<" ) ";
+		cout.flush();
+		treeout->Fill();
+	}
+	cout<<"\r ...done!                                       "<<endl;
+	cout<<"-------------"<<endl;
+	cout<<"\r Save File: "<<outputFile<<endl;
+	treeout -> Write("",TObject::kOverwrite);
+	fout->Save();
+	fout->Close();
+	cout<<"-------------"<<endl;
+}
+
+//####################################################################
+
+void Mi26Ana::plotsc() {																// ok
+	
+	cout<<"-------------"<<endl;
+	cout<<"PLOT SCURVES: "<<endl;
+	
+	int row, column, matrix;
+	
+	TH2F * ploti[4];
+	for(int i=0;i<4;i++)		{ ploti[i] = new TH2F( Form("Matrix %i",i), Form("Matrix %i",i), fNthr,0,255, 500,-0.05,1.05); }
+	
+	ULong_t	progress_tmp=-1;
+	Float_t		progress;
+			
+	for(int i=0;i<fNthr;i++)
+	{
+		progress = (Int_t)((i*100)/(fNthr-1)*10);
+		if(progress!=progress_tmp)	{ print_progress( ((i*100.)/(fNthr-1)) ); progress_tmp=progress;}
+	
+		fTree->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;pi<fNRndPx;pi++)
+			{
+				pix		= fRndPx[pi];
+				column	= pix%288;
+				row		= (int)(pix/288);
+				
+				for(matrix=0;matrix<4;matrix++)
+				{
+					pix = 1152*row+column+288*matrix;
+					
+					if(fMatrix[matrix])
+					{
+// 						if( row!=0 && row!=573 )
+// 						{
+							ploti[matrix] ->Fill(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<<"-------------"<<endl;
+	cout<<"PLOT SINGLE SCURVE: "<<endl;
+	
+	int row, column, matrix, pix;
+	
+	TH2F * ploti[4];
+	for(int i=0;i<4;i++)		{ ploti[i] = new TH2F( Form("Matrix %i",i), Form("Matrix %i",i), fNthr,0,255, 500,-0.05,1.05); }
+	
+	ULong_t	progress_tmp=-1;
+	Float_t		progress;
+			
+	for(int i=0;i<fNthr;i++)
+	{
+		progress = (Int_t)((i*100)/(fNthr-1)*10);
+		if(progress!=progress_tmp)	{ print_progress( ((i*100.)/(fNthr-1)) ); progress_tmp=progress;}
+	
+		fTree->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;thr<fNthr;thr++)
+	{
+		fTree->GetEntry(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;i<fNRndPx;i++)
+		{
+			pix		= fRndPx[i];
+			row		= (int)(pix/288);
+			column	= pix%288;
+					
+			for(int j=0;j<4;j++)
+			{
+				RndPx[i*4+j] = 1152*row+column+288*j;
+			}
+		}
+	}
+		
+	for(int i=0;i<nrpixels;i++)
+	{
+		if(!fPixSel)	{ pix = i; 			}
+		else			{ pix = RndPx[i];	}
+// 		progress = (Int_t)((pix*100)/(1152*576-1)*10);
+// 		if(progress!=progress_tmp)	{ print_progress( ((pix*100.)/(1152*576-1)) ); progress_tmp=progress;}		
+		
+		if( TMath::RMS(fNthr,&pixelprob_arr[pix*fNthr])!=0 )
+		{
+			delete histos;
+			histos	= new TH1F( "test", "test" , fNthr, threshold_arr[0],threshold_arr[fNthr-1]);
+// Estimate Fit Parameters
+			meanmin=0;
+			meanmax=255;
+			
+			for(int thr=0;thr<fNthr;thr++)
+			{
+				histos->Fill(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( mean<meanmin || mean>meanmax || sigma>75 || sigma<1 )
+				{
+					chicount=0;
+					
+					while( (mean<meanmin || mean>meanmax || 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-------------"<<endl;
+}
+
+//####################################################################
+
+void Mi26Ana::fitscsingle() {															// ok
+	
+	float*	pixelprob_arr = new float	[4*fNthr];
+	int*	threshold_arr = new int		[fNthr];
+	int		pix, row, col;
+	int		pixel[4];
+	float	mean = 0, sigma = 0, chi2 = 0;
+	int		chicount=0;
+	int		meanmin, meanmax;
+	float	meanmean;
+	float	vsigma;
+	float	vtmp=1;
+	
+	TH1F *histos[4];
+	TF1* erf = new TF1("erf","0.5*(1+TMath::Erf((-x+[0])/[1]))",0,100);
+//  --------------
+	col	= fNPx%288;
+	row	= (int)(fNPx/288);
+	
+	for(int i=0;i<4;i++)	{ pixel[i]	= 1152*row+col+288*i; }
+	
+// Read TTree
+	for(int thr=0;thr<fNthr;thr++)
+	{
+		fTree->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;thr<fNthr;thr++)
+		{
+			histos[pix]->Fill(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( mean<meanmin || mean>meanmax || sigma>75 || sigma<1 )
+			{
+				chicount=0;
+				
+				while( (mean<meanmin || mean>meanmax || 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<<"-------------"<<endl;
+	cout<<"SUM UP:"<<endl;
+	
+	ULong_t	progress_tmp=-1;
+	Float_t		progress;
+	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<fNRndPx;i++)
+		{
+			pix		= fRndPx[i];
+			row		= (int)(pix/288);
+			column	= pix%288;
+					
+			for(int j=0;j<4;j++)
+			{
+				RndPx[i*4+j] = 1152*row+column+288*j;
+			}
+		}
+	}
+	
+	Float_t*	sum	= new Float_t	[nrpixels];
+	for(int i=0;i<nrpixels;i++) {sum[i]=0;}
+	
+	for(int nt=0;nt<fNthr;nt++)
+	{
+		progress = (Int_t)((nt*100)/(1152*576-1)*10);
+		if(progress!=progress_tmp)	{ print_progress( ((nt*100.)/(1152*576-1)) ); progress_tmp=progress;}	
+		
+		fTree->GetEntry(nt);
+				
+		for(int i=0;i<nrpixels;i++)
+		{
+			if( !fPixSel )	{ pix = i; }
+			else			{ pix = RndPx[i]; }
+			
+			sum[i]+=fPixelprob[pix];
+		}
+	}
+	
+	TH1F *plot[4];
+	plot[0] =  new TH1F( "sum0","sum",2550,0,255);
+	plot[1] =  new TH1F( "sum1","sum1",2550,0,255);
+	plot[2] =  new TH1F( "sum2","sum2",2550,0,255);
+	plot[3] =  new TH1F( "sum3","sum3",2550,0,255);
+	TH2F* plot2 =  new TH2F( "sum2D0","sum2D",1152,0,1152,576,0,576);
+	
+	int MINX=fNthr,MAXX=0;
+	for(int i=0;i<nrpixels;i++)
+	{
+		if( !fPixSel )	{ pix = i; }
+		else			{ pix = RndPx[i]; }
+			
+		column	= (int)(pix%1152);
+		row		= (int)(pix/1152.);
+		matrix	= int(column/288);
+		
+		if( fMatrix[matrix] )
+		{
+			if( sum[i] < MINX ) { MINX=sum[i]; }
+			if( sum[i] > MAXX ) { MAXX=sum[i]; }
+			
+			plot[matrix]->Fill(sum[i]);
+			plot2->Fill(column, row, sum[i]);
+		}
+		
+// 		if(row==1)cout<<column<<" "<<row<<" "<<sum[pix]<<endl;
+	}
+	int MAXY = 0;
+	if( plot[0]->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 "<<fNthr<<" thresholds!                                       "<<endl;
+	cout<<"-------------"<<endl;
+// 	f->Close();
+	cout<<"-------------"<<endl;
+}
+
+//####################################################################
+
+void Mi26Ana::fakes() {																	// ok
+	
+	ULong_t	progress_tmp=-1;
+	Float_t		progress;
+//  --------------
+	float*	pixelprob_arr = new float	[fNthr*1152*576];	
+// Read TTree
+	for(int thr=0;thr<fNthr;thr++)
+	{
+		progress = (Int_t)((thr*100)/(fNthr-1)*10);
+		if(progress!=progress_tmp)	{ print_progress( ((thr*100.)/(fNthr-1)) ); progress_tmp=progress;}
+		
+		fTree->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<fNRndPx;i++)
+		{
+			pix		= fRndPx[i];
+			row		= (int)(pix/288);
+			column	= pix%288;
+					
+			for(int j=0;j<4;j++)
+			{
+				RndPx[i*4+j] = 1152*row+column+288*j;
+			}
+		}
+	}
+	
+// Calc RMS
+	TH1F *plot[4];
+	plot[0] =  new TH1F( "RMS0","RMS",1000,-1,1);
+	plot[1] =  new TH1F( "RMS1","RMS1",1000,-1,1);
+	plot[2] =  new TH1F( "RMS2","RMS2",1000,-1,1);
+	plot[3] =  new TH1F( "RMS3","RMS3",1000,-1,1);
+	TH2F* plot2 =  new TH2F( "RMS2D0","RMS2D",1152,0,1152,576,0,576);
+	TH2F* plot2a =  new TH2F( "RMS","RMS==0",1152,0,1152,576,0,576);
+	
+	int MINX=fNthr,MAXX=0;
+	
+	progress_tmp=-1;
+	Float_t*	mean	= new Float_t	[nrpixels];
+	for(int i=0;i<nrpixels;i++) {mean[i]=0;}
+	
+	for(int i=0;i<nrpixels;i++)
+	{
+// 		progress = (Int_t)((i*100)/(nrpixels-1)*10);
+// 		if(progress!=progress_tmp)	{ print_progress( ((i*100.)/(nrpixels-1)) ); progress_tmp=progress;}
+		
+		if( !fPixSel )	{ pix = i; }
+		else			{ pix = RndPx[i]; }
+		
+		mean[i] = TMath::RMS(fNthr,&pixelprob_arr[pix*fNthr]);
+		
+		column	= (int)(pix%1152);
+		row		= (int)(pix/1152.);
+		matrix	= int(column/288);
+		
+		if( fMatrix[matrix] )
+		{
+			if( mean[i] < MINX ) { MINX=mean[i]; }
+			if( mean[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"<<column<<"\t"<<row<<"\t"<<pixelprob_arr[pix*fNthr]<<"\t"<<mean[i]  <<endl;
+			}
+		}
+		
+	}
+	
+	int MAXY = 0;
+	if( plot[0]->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 "<<fNthr<<" thresholds!                                       "<<endl;
+	cout<<"-------------"<<endl;
+// 	f->Close();
+	cout<<"-------------"<<endl;
+}
+
+//####################################################################
+
+void Mi26Ana::empty1() {
+
+}
+
+//####################################################################
+
+void Mi26Ana::empty2() {
+
+}
+
+//####################################################################
+
+void Mi26Ana::sum() {																	// ok
+// 	Float_t*	sum	= new Float_t	[1152*576];
+// 	for(int i=0;i<1152*576;i++) {sum[i]=0;}
+// // 	if (nthr % 4 != 0){
+// // 		printf("Error: %d not divisible by 4!", nthr);
+// // 		exit(1);
+// // 	}
+// // 	nthr = nthr/4;
+// 	
+// 	for(int i=0;i<nthr;i++)
+// 	{
+// 		tree->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<<column<<" "<<row<<" "<<sum[pix]<<endl;
+// 	}
+// 	
+// 	TCanvas* cm2 = new TCanvas("a","<", 50,100,900,600);
+// 	cm2->Divide(2,1);
+// 	cm2->cd(1);
+// 	plot->Draw();
+// 	cm2->cd(2);
+// 	plot2->Draw("colz");
+// 	
+// 	cout<<"\r ...done for "<<nthr<<" thresholds!                                       "<<endl;
+// 	cout<<"-------------"<<endl;
+// // 	f->Close();
+// 	cout<<"-------------"<<endl;
+	
+	
+}
+
+//####################################################################
+//####################################################################
+//####################################################################
+
+bool Mi26Ana::readPxFile() {
+	
+	ifstream myfile( fInputPxFile, std::ifstream::in );
+	
+	if(!myfile.good())	return 0;
+	
+	myfile >> fNRndPx;
+	fRndPx = new int[fNRndPx];
+	
+	int count=0;
+	int	pix;
+	
+	while( myfile.good() )
+	{
+		myfile >> pix;
+		if( count<fNRndPx )	{ fRndPx[count] = pix; }
+		count++;
+	}
+	
+	if( count==fNRndPx )	{ return 1; }
+	else					{ return 0; }
+}
+
+//####################################################################
\ No newline at end of file
diff --git a/s-curves/analysis_gui/ANA/Mi26Ana.h b/s-curves/analysis_gui/ANA/Mi26Ana.h
new file mode 100644
index 0000000..3c42044
--- /dev/null
+++ b/s-curves/analysis_gui/ANA/Mi26Ana.h
@@ -0,0 +1,82 @@
+#ifndef Mi26Ana_H
+#define Mi26Ana_H
+
+#include <iostream>
+#include <fstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <iomanip> 
+#include <sstream>
+
+#include "TCanvas.h"
+#include "TRootCanvas.h"
+#include <TFile.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include "TH1.h"
+#include "TF1.h"
+#include "TSystem.h"
+#include <TTree.h>
+#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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <TTree.h>
+#include <TFile.h>
+#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<<"-------------"<<endl;
+	cout<<"SUM UP:"<<endl;
+	UShort_t	threshold;
+	Float_t*	pixelprob	= new Float_t	[1152*576];
+	UShort_t*	frames		= new UShort_t	[576];
+	
+	Float_t*	sum	= new Float_t	[1152*576];
+	
+	for(int i=0;i<1152*576;i++) {sum[i]=0;}
+	
+//  File IN
+	TString RootFile = "messung.root";
+	TFile*	f		= new TFile(RootFile);
+	TTree* tree	= (TTree*)f->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;i<nthr;i++)
+	{
+		tree->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<<column<<" "<<row<<" "<<sum[pix]<<endl;
+	}
+	
+	TCanvas* cm2 = new TCanvas("a","<", 50,100,900,600);
+	cm2->Divide(2,1);
+	cm2->cd(1);
+	plot->Draw();
+	cm2->cd(2);
+	plot2->Draw("colz");
+	
+	cout<<"\r ...done for "<<nthr<<" thresholds!                                       "<<endl;
+	cout<<"-------------"<<endl;
+// 	f->Close();
+	cout<<"-------------"<<endl;
+}
+
+//####################################################################
+
+void rewrite() {
+	cout<<"-------------"<<endl;
+	cout<<"REWRITE FILE:"<<endl;
+	UShort_t	threshold;
+	Int_t*		pixel		= new Int_t		[1152*576];
+	Float_t*		pixelprob	= new Float_t	[1152*576];
+	Float_t*		pixelprobout	= new Float_t	[1152*576];
+	UShort_t*	frames		= new UShort_t	[576];
+	
+	for(int i=0;i<1152*576;i++)	{ pixel[i]=i; }
+	
+//  File IN
+	TString RootFile = "output.root";
+	TFile*	f		= new TFile(RootFile);
+	TTree* tree	= (TTree*)f->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;i<nthr;i++)
+	{
+		for(int j=0;j<4;j++)
+		{
+			tree->GetEntry(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: "<<threshold<<" ( " <<i+1<<" of "<<nthr<<" ) ";
+		cout.flush();
+		treeout->Fill();
+	}
+	cout<<"\r ...done!                                       "<<endl;
+	cout<<"-------------"<<endl;
+	printf("\r Save File!\n");
+	treeout -> Write("",TObject::kOverwrite);
+	fout->Save();
+	fout->Close();
+	f->Close();
+	cout<<"-------------"<<endl;
+}
+
+//####################################################################
+
+void plotsc() {
+	
+	UShort_t	threshold;
+// 	Int_t*		pixel		= new Int_t		[1152*576];
+	Float_t*		pixelprob	= new Float_t	[1152*576];
+	
+//  File IN
+	TString RootFile = "/local/samir/data/G03_testmessung_01.root";
+	TFile*	f		= new TFile(RootFile);
+	TTree* tree	= (TTree*)f->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;i<nthr;i++)
+	{
+		tree->GetEntry(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<<threshold<<"\t"<<pix<<"\t"<<pixelprob[1152]<<"\t"<<endl; }
+		}
+	}
+	
+	TCanvas* cm2 = new TCanvas("a","<", 50,100,900,600);
+	cm2->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;thr<entries;thr++)
+	{
+		tree->GetEntry(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;thr<entries;thr++)
+			{
+				histos->Fill(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( mean<meanmin || mean>meanmax || 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( (mean<meanmin || mean>meanmax || 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-------------"<<endl;
+}
+
+//####################################################################
+
+// void ana() {
+// 
+// // 	rewrite();
+// 		plotsc();
+// // 	calcpara();
+// }
+
+//####################################################################
\ No newline at end of file
diff --git a/s-curves/analysis_gui/ANA/help.h b/s-curves/analysis_gui/ANA/help.h
new file mode 100644
index 0000000..5ee6558
--- /dev/null
+++ b/s-curves/analysis_gui/ANA/help.h
@@ -0,0 +1,92 @@
+#ifndef HELP_H
+#define HELP_H
+
+#include <iostream>
+#include <cstdlib>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "TStopwatch.h"
+
+//####################################################################
+
+Int_t print_progress(Float_t ProgressInPercent) {
+	
+	Int_t nCharacter = printf("\r [");
+	Int_t iBlock;
+	
+	for( iBlock=0; iBlock<ProgressInPercent/2; ++iBlock )
+	{
+		putchar( '=' );
+		nCharacter++;
+	}
+	
+	for( ; iBlock<100/2; ++iBlock )
+	{
+		putchar( ' ' );
+		nCharacter++;
+	}
+	
+// 	Int_t sec	= TimeInSec%60;
+// 	Int_t min	= TimeInSec/60;
+// 	Int_t hours	= TimeInSec/3600;
+	
+	nCharacter += printf( "] %4.0f%%", ProgressInPercent);
+	fflush( stdout );
+	
+	if((Int_t)ProgressInPercent==100) 
+	{
+		printf("\r");
+		for(Int_t i=0; i<nCharacter; i++)
+		{
+			putchar( ' ' );
+		}
+		printf("\r ... done! \n");
+	}
+	
+	return nCharacter;
+}
+
+//####################################################################
+
+Int_t print_progress(Float_t ProgressInPercent, Int_t TimeInSec) {
+	
+	Int_t nCharacter = printf("\r [");
+	Int_t iBlock;
+	
+	for( iBlock=0; iBlock<ProgressInPercent/2; ++iBlock )
+	{
+		putchar( '=' );
+		nCharacter++;
+	}
+	
+	for( ; iBlock<100/2; ++iBlock )
+	{
+		putchar( ' ' );
+		nCharacter++;
+	}
+	
+	Int_t sec	= TimeInSec%60;
+	Int_t min	= TimeInSec/60;
+	Int_t hours	= TimeInSec/3600;
+	
+	nCharacter += printf( "] %6.2f%% \t %3i:%02i:%02i   ", ProgressInPercent, hours, min, sec );
+	fflush( stdout );
+	
+	if(ProgressInPercent==100) 
+	{
+		printf("\r");
+		for(Int_t i=0; i<nCharacter; i++)
+		{
+			putchar( ' ' );
+		}
+		printf("\r ...done! \t ( %i:%02i:%02i ) \n", hours, min, sec );
+	}
+	
+	return nCharacter;
+}
+
+//####################################################################
+#endif
\ No newline at end of file
diff --git a/s-curves/analysis_gui/ANA/main.cpp b/s-curves/analysis_gui/ANA/main.cpp
new file mode 100644
index 0000000..0ef5e10
--- /dev/null
+++ b/s-curves/analysis_gui/ANA/main.cpp
@@ -0,0 +1,51 @@
+#include "Mi26Ana.h"
+#include "TApplication.h"
+
+
+int main(int argc, char** argv) {
+	
+	gROOT->Reset();
+	
+	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<<argv[3]; strValue >> Mode;	strValue.clear();
+	if (argc>4) strValue<<argv[4]; strValue >> NPx;		strValue.clear();
+	if (argc>5) strValue<<argv[5]; strValue >> NRndPx;	strValue.clear();
+	if (argc>6) strValue<<argv[6]; strValue >> Code;	strValue.clear();
+	
+// 	cout<<" -- main 1 -- "<<endl;
+// 	for(int i=0;i<7;i++)
+// 	{
+// 		cout<<i<<"\t"<<argc<<"\t"<<argv[i]<<endl;
+// 	}
+// 	cout<<" -- main 2 --"<<endl;
+// 	cout<<InFile<<endl;
+// 	cout<<PxFile<<endl;
+// 	cout<<Mode<<endl;
+// 	cout<<NRndPx<<endl;
+// 	cout<<NPx<<endl;
+// 	cout<<Code<<endl;
+// 	
+// 	
+// 	cout<<"-------------"<<endl;
+	TApplication theApp("Analysis", &argc, argv);
+	
+	Mi26Ana* ana = new Mi26Ana();
+	ana->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 <QApplication>
+#include <TApplication.h>
+
+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 <QtGui>
+#include <QtCore>
+#include <iostream>
+#include <fstream>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <time.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <iomanip> 
+#include <sstream>
+
+#include "TCanvas.h"
+#include "TRootCanvas.h"
+#include <TFile.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include "TH1.h"
+#include "TF1.h"
+#include "TSystem.h"
+#include <TTree.h>
+#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()	<<endl;
+	myfile << ( lineFile	-> text()).toStdString()	<<endl;
+	myfile << checkBank1		->  isChecked() <<"  ";
+	myfile << checkBank2		->  isChecked() <<"  ";
+	myfile << checkBank3		->  isChecked() <<"  ";
+	myfile << checkBank4		->  isChecked() <<"  ";
+	myfile << checkRandPix		->  isChecked() <<"  ";
+	myfile << radioRoot			->  isChecked() <<"  ";
+	myfile <<endl;
+	
+	myfile <<  spinRandPix	->value()	<<" ";
+	myfile <<  spinPix			->value()	<<" ";
+	myfile <<endl;
+	
+	myfile.close();
+}
+
+//####################################################################
+
+void scurves::NextFile(int sign) {
+	
+	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();
+		
+		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; i<Endinglength;i++)
+						{
+							if( Filecurr[namelength-Endinglength+i] != Ending[i] )	{ Endingcorr=false; break; }
+						}
+							
+						if(Endingcorr && sign*timecurr>sign*timeref )
+						{
+// 							cout<<left<<setw(3)<< Endingcorr; 
+// 							cout<<left<<setw(50)<< Filecurr;
+// 							cout<<left<<setw(10)<< timecurr;
+// 							cout<<left<<setw(5)<< namelength;
+// 							cout<<left<<setw(15)<< ctime(&s.st_mtime);
+							
+							if( timenew!=0 && sign*timenew>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; i<Endinglength;i++)
+						{
+							if( Filecurr[namelength-Endinglength+i] != Ending[i] )	{ Endingcorr=false; break; }
+						}
+						
+						if(Endingcorr && timenew<timecurr)
+						{
+// 							cout<<left<<setw(3)<< Endingcorr; 
+// 							cout<<left<<setw(50)<< Filecurr;
+// 							cout<<left<<setw(10)<< timecurr;
+// 							cout<<left<<setw(5)<< namelength;
+// 							cout<<left<<setw(15)<< ctime(&s.st_mtime);
+						
+							strcpy	(Filenew, epdf->d_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; i<namelength-3;i++)
+	{
+		Fileout[i] = Filein[i];
+	}
+	
+	strcat	(Fileout, "root");
+
+	string command = "";
+	command += "xterm -hold -geometry 130x10+10+10 -e ./run.sh ";
+	command += Filein;
+	command += " ";
+	command += ".png";
+	command += " ";
+	command += "mystem";
+	command += " ";
+	command += Fileout;
+	
+	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::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 <<endl;
+	
+	while( count<randPixel )
+	{
+		rndnum = rand()%(1152*576/4);
+		
+		if( rndnum>5*1152/4 && rndnum<(576-5)*1152/4 )
+		{
+			for(loop=0;loop<count;loop++)
+			{
+				if( rndnum == arr[loop] ) break;
+			}
+			
+			if(loop==count)
+			{
+				myfile << " " << rndnum;
+// 				cout	<< count<<" \t "<< rndnum  <<endl;
+				
+				arr[count] = rndnum;
+				count++;
+			}
+		}
+	}
+	
+	myfile.close();
+	
+// 	cout<<"done "<< count <<endl;
+	
+}
+
+//####################################################################
+
+void scurves::clickDir() {
+	 lineDir->setStyleSheet("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;i<childcount;i++)
+	{
+		  	child[i]->close();
+	}
+	
+	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<<command<<endl;
+	
+	child[childcount] = new QProcess();
+// 	connect(child[childcount], SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(isFinished( int, QProcess::ExitStatus )));
+	child[childcount]->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 <QProcess>
+
+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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>595</width>
+    <height>336</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QLineEdit" name="lineDir">
+    <property name="geometry">
+     <rect>
+      <x>59</x>
+      <y>12</y>
+      <width>391</width>
+      <height>26</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineFile">
+    <property name="geometry">
+     <rect>
+      <x>59</x>
+      <y>42</y>
+      <width>391</width>
+      <height>26</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>19</x>
+      <y>18</y>
+      <width>41</width>
+      <height>16</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>DIR</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_2">
+    <property name="geometry">
+     <rect>
+      <x>19</x>
+      <y>48</y>
+      <width>41</width>
+      <height>16</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>FILE</string>
+    </property>
+   </widget>
+   <widget class="QFrame" name="frame">
+    <property name="geometry">
+     <rect>
+      <x>198</x>
+      <y>80</y>
+      <width>251</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="frameShape">
+     <enum>QFrame::StyledPanel</enum>
+    </property>
+    <property name="frameShadow">
+     <enum>QFrame::Raised</enum>
+    </property>
+    <widget class="QSpinBox" name="spinRandPix">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>3</y>
+       <width>101</width>
+       <height>26</height>
+      </rect>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="maximum">
+      <number>165888</number>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushIdentRandPix">
+     <property name="geometry">
+      <rect>
+       <x>140</x>
+       <y>3</y>
+       <width>101</width>
+       <height>25</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Rand. Pixels</string>
+     </property>
+    </widget>
+    <widget class="QCheckBox" name="checkRandPix">
+     <property name="geometry">
+      <rect>
+       <x>5</x>
+       <y>5</y>
+       <width>21</width>
+       <height>23</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>CheckBox</string>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QFrame" name="frame_2">
+    <property name="geometry">
+     <rect>
+      <x>198</x>
+      <y>110</y>
+      <width>251</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="frameShape">
+     <enum>QFrame::StyledPanel</enum>
+    </property>
+    <property name="frameShadow">
+     <enum>QFrame::Raised</enum>
+    </property>
+    <widget class="QLabel" name="label_3">
+     <property name="geometry">
+      <rect>
+       <x>10</x>
+       <y>6</y>
+       <width>54</width>
+       <height>16</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Bank(s)</string>
+     </property>
+    </widget>
+    <widget class="QCheckBox" name="checkBank1">
+     <property name="geometry">
+      <rect>
+       <x>65</x>
+       <y>5</y>
+       <width>41</width>
+       <height>23</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>1</string>
+     </property>
+    </widget>
+    <widget class="QCheckBox" name="checkBank2">
+     <property name="geometry">
+      <rect>
+       <x>113</x>
+       <y>5</y>
+       <width>41</width>
+       <height>23</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>2</string>
+     </property>
+    </widget>
+    <widget class="QCheckBox" name="checkBank3">
+     <property name="geometry">
+      <rect>
+       <x>161</x>
+       <y>5</y>
+       <width>41</width>
+       <height>23</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>3</string>
+     </property>
+    </widget>
+    <widget class="QCheckBox" name="checkBank4">
+     <property name="geometry">
+      <rect>
+       <x>209</x>
+       <y>5</y>
+       <width>41</width>
+       <height>23</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>4</string>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QPushButton" name="pushPlotSc">
+    <property name="geometry">
+     <rect>
+      <x>100</x>
+      <y>150</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Plot 
+ S-Curves</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushFitSc">
+    <property name="geometry">
+     <rect>
+      <x>200</x>
+      <y>150</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Fit 
+ S-Curves</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushOpenBrowser">
+    <property name="geometry">
+     <rect>
+      <x>400</x>
+      <y>150</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Open 
+ Browser</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushSave">
+    <property name="geometry">
+     <rect>
+      <x>470</x>
+      <y>15</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Save</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushEmpty1">
+    <property name="geometry">
+     <rect>
+      <x>500</x>
+      <y>150</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Empty 1</string>
+    </property>
+   </widget>
+   <widget class="QFrame" name="frame_3">
+    <property name="geometry">
+     <rect>
+      <x>97</x>
+      <y>201</y>
+      <width>201</width>
+      <height>111</height>
+     </rect>
+    </property>
+    <property name="frameShape">
+     <enum>QFrame::StyledPanel</enum>
+    </property>
+    <property name="frameShadow">
+     <enum>QFrame::Raised</enum>
+    </property>
+    <widget class="QSpinBox" name="spinPix">
+     <property name="geometry">
+      <rect>
+       <x>114</x>
+       <y>80</y>
+       <width>81</width>
+       <height>26</height>
+      </rect>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="maximum">
+      <number>165887</number>
+     </property>
+     <property name="value">
+      <number>0</number>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushFitScSingle">
+     <property name="geometry">
+      <rect>
+       <x>103</x>
+       <y>3</y>
+       <width>95</width>
+       <height>51</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Fit 
+ S-Curve</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushPlotScSingle">
+     <property name="geometry">
+      <rect>
+       <x>3</x>
+       <y>3</y>
+       <width>95</width>
+       <height>51</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Plot 
+ S-Curve</string>
+     </property>
+    </widget>
+    <widget class="QSpinBox" name="spinRow">
+     <property name="geometry">
+      <rect>
+       <x>34</x>
+       <y>56</y>
+       <width>61</width>
+       <height>26</height>
+      </rect>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="maximum">
+      <number>575</number>
+     </property>
+     <property name="value">
+      <number>0</number>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_4">
+     <property name="geometry">
+      <rect>
+       <x>5</x>
+       <y>62</y>
+       <width>31</width>
+       <height>16</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Row</string>
+     </property>
+    </widget>
+    <widget class="QSpinBox" name="spinCol">
+     <property name="geometry">
+      <rect>
+       <x>34</x>
+       <y>80</y>
+       <width>61</width>
+       <height>26</height>
+      </rect>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="maximum">
+      <number>287</number>
+     </property>
+     <property name="value">
+      <number>0</number>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_5">
+     <property name="geometry">
+      <rect>
+       <x>5</x>
+       <y>86</y>
+       <width>31</width>
+       <height>16</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Col</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_6">
+     <property name="geometry">
+      <rect>
+       <x>119</x>
+       <y>67</y>
+       <width>31</width>
+       <height>16</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Pix</string>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QPushButton" name="pushClose">
+    <property name="geometry">
+     <rect>
+      <x>470</x>
+      <y>71</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Close 
+ windows</string>
+    </property>
+   </widget>
+   <widget class="QFrame" name="frame_4">
+    <property name="geometry">
+     <rect>
+      <x>59</x>
+      <y>80</y>
+      <width>135</width>
+      <height>61</height>
+     </rect>
+    </property>
+    <property name="frameShape">
+     <enum>QFrame::StyledPanel</enum>
+    </property>
+    <property name="frameShadow">
+     <enum>QFrame::Raised</enum>
+    </property>
+    <widget class="QRadioButton" name="radioHld">
+     <property name="geometry">
+      <rect>
+       <x>10</x>
+       <y>6</y>
+       <width>51</width>
+       <height>21</height>
+      </rect>
+     </property>
+     <property name="layoutDirection">
+      <enum>Qt::RightToLeft</enum>
+     </property>
+     <property name="text">
+      <string>hld</string>
+     </property>
+    </widget>
+    <widget class="QRadioButton" name="radioRoot">
+     <property name="geometry">
+      <rect>
+       <x>62</x>
+       <y>6</y>
+       <width>51</width>
+       <height>21</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>root</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushFindNew">
+     <property name="geometry">
+      <rect>
+       <x>27</x>
+       <y>26</y>
+       <width>81</width>
+       <height>31</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>Find Newest</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushFindBack">
+     <property name="geometry">
+      <rect>
+       <x>3</x>
+       <y>26</y>
+       <width>21</width>
+       <height>31</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>&lt;</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushFindForth">
+     <property name="geometry">
+      <rect>
+       <x>111</x>
+       <y>26</y>
+       <width>21</width>
+       <height>31</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>&gt;</string>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QPushButton" name="pushUnpack">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>150</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Unpack</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushRewrite">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>205</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Rewrite</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushEmpty2">
+    <property name="geometry">
+     <rect>
+      <x>500</x>
+      <y>205</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Empty 2</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushSum">
+    <property name="geometry">
+     <rect>
+      <x>300</x>
+      <y>150</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Sum</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushFakes">
+    <property name="geometry">
+     <rect>
+      <x>300</x>
+      <y>205</y>
+      <width>95</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>RMS</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>595</width>
+     <height>20</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
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