Index: equalization_gain/trunk/MySetup.sh
===================================================================
--- equalization_gain/trunk/MySetup.sh	(revision 196)
+++ equalization_gain/trunk/MySetup.sh	(revision 197)
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-export srcDIR="/Users/dagoret-campagnesylvie/MacOsX/EUSO-BALLOON/GainEqualisation/analysis/src"
-export dataDIR="/Users/dagoret-campagnesylvie/MacOsX/EUSO-BALLOON/GainEqualisation/analysis/data/"
+export srcDIR="/Users/dagoret-campagnesylvie/MacOsX/EUSO-BALLOON/GainEqualisation/SVN/analysis/trunk/src"
+export dataDIR="/Users/dagoret-campagnesylvie/MacOsX/EUSO-BALLOON/GainEqualisation/SVN/analysis/trunk/data/"
Index: equalization_gain/trunk/README
===================================================================
--- equalization_gain/trunk/README	(revision 196)
+++ equalization_gain/trunk/README	(revision 197)
@@ -5,4 +5,18 @@
 *
 **********************************************************
+
+Repository
+===========
+
+to see the projects for JEM-EUSO just dou :
+
+==> svn ls https://svn.lal.in2p3.fr/projects/JEM-EUSO
+
+==> svn ls https://svn.lal.in2p3.fr/projects/JEM-EUSO/equalization_gain
+branches/
+tags/
+trunk/
+
+
 The Gain Equalisation files are inside the analysis directory.
 
Index: equalization_gain/trunk/src/PlotScurvesAll-diffFit.cc
===================================================================
--- equalization_gain/trunk/src/PlotScurvesAll-diffFit.cc	(revision 196)
+++ equalization_gain/trunk/src/PlotScurvesAll-diffFit.cc	(revision 197)
@@ -216,5 +216,5 @@
   ofstream out(kFnameOut.Data()); 
 
-  // first loop on channels
+  // first loop on channels to fill histonames
   //----------------------
   for(ch=0;ch<kNch;ch++){
@@ -799,5 +799,5 @@
 //--------------------------------------------------------------------------------------------------------
 void Analysis::PlotScurve(
-	/*	Int_t    kDrawCh=31,
+		Int_t    kDrawCh=31,
 		TString  fname=kFname,
 		TString  fname_ped=kFnamePed, //ASIC_D ped_file
@@ -814,4 +814,22 @@
 {
 
+  // reset all variables
+  Init();
+
+  //OpenGainFile(fname_gain);
+
+  FillHistoName();
+
+  ReadGainFile(fname_gain,kBoard);
+}
+//--------------------------------------------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------------------------------------------
+// Initialize the program by reseting counters or variables and create objects
+//--------------------------------------------------------------------------------------------------------
+void Analysis::Init()
+{
+
   if(input!=0) delete input;
   if(input_ped!=0) delete input_ped;
@@ -831,6 +849,119 @@
 
 
+  // create canvas
+
+  c1                = new TCanvas(kCanvasName1,kCanvasTitle1,200,20,1100,600); //smoothed S-curves
+  c1->Divide(11,6);
+  c2                = new TCanvas(kCanvasName2,kCanvasTitle2,300,50,1100,600); //differentiated histograms of smoothed s-curves
+  c2->Divide(11,6);
+  c5                = new TCanvas(kCanvasName5,kCanvasTitle5,400,70,1100,600);
+  c5->Divide(11,6);
+  c3                = new TCanvas(kCanvasName3,kCanvasTitle3,500,100,1200,300);
+  c3->Divide(4,1);
+  c4                = new TCanvas(kCanvasName4,kCanvasTitle4,900,400,300,300);
+
+
+  // create histos and function
+  hist_scurve       = new TH1D[kNch]; // smoothed S-curves
+  hist_scurve_ped   = new TH1D[kNch]; // S-curves for pedestal runs
+  hist_diff         = new TH1D[kNch]; // differentiated histograms of smoothed s-curves
+  hist_diff_fit     = new TH1D[kNch]; // differentiated histograms of fitted s-curves
+  fit_sdiff         = new TF1[kNch];  // function fitted on differentiated histograms of fitted s-curves
+
+
+ for(ch=0;ch<kNch;ch++){
+    dac_half[ch]=0;
+    dac_ped[ch]=0;
+    dac_spe[ch]=0;
+    dac_sfit[ch]=0;
+    gain_org[ch]=0;
+    mean_diff[ch]=0;
+    sfit_chiS[ch]=0;
+    flag_fit[ch]=0;
+ }
+
+
   
 }
 //--------------------------------------------------------------------------------------------------------
 
+//--------------------------------------------------------------------------------------------------------
+// Initialize the program by reseting counters or variables and create objects
+//--------------------------------------------------------------------------------------------------------
+void Analysis::OpenGainFile(const TString fname_gain)
+{
+  TString input_gain(fname_gain);
+  ifstream in_gain(input_gain.Data());
+  if(!in_gain.good()){
+    cerr << "File " << input_gain << " open failed!" << endl;
+    exit(-1);
+  }
+  in_gain.close();
+  in_gain.clear();
+
+}
+//--------------------------------------------------------------------------------------------------------
+
+//--------------------------------------------------------------------------------------------------------
+// Fill Histogram name
+//--------------------------------------------------------------------------------------------------------
+void Analysis::FillHistoName()
+{
+  
+// first loop on channels to fill histonames
+  //----------------------
+  for(ch=0;ch<kNch;ch++){
+    
+    name_hist[ch]           ="hist";
+    name_hist[ch]          +=ch;
+    name_hist_ped[ch]       ="hist_ped";
+    name_hist_ped[ch]      +=ch;
+    name_hist_diff[ch]      ="hist_diff";
+    name_hist_diff[ch]     +=ch;
+    name_hist_diff_fit[ch]  ="hist_diff_fit";
+    name_hist_diff_fit[ch] +=ch;
+    name_fit_diff[ch]       ="fit_diff";
+    name_fit_diff[ch]      +=ch;
+  }
+
+}
+//--------------------------------------------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------------------------------------------
+// Read the gain
+//--------------------------------------------------------------------------------------------------------
+
+void Analysis::ReadGainFile(const TString fname_gain,Bool_t kBoard)
+{
+  TString input_gain(fname_gain);
+  ifstream in_gain(input_gain.Data());
+  if(!in_gain.good()){
+    cerr << "File " << input_gain << " open failed!" << endl;
+    exit(-1);
+  }
+ // read gain
+  Double_t da;
+  Int_t count=0;
+  ch=0;
+  while(in_gain >> da){
+    if(!kBoard && (count>=128 && count<192)){
+      gain_org[ch]=da;
+      cerr << "!kBoard, count, gain_org[" << ch << "] "
+	   << !kBoard << " " << count << " " << gain_org[ch] << endl;
+      ch++;
+    }
+    if(kBoard && (count>=192 && count<256)){
+      gain_org[ch]=da;
+      cerr << "kBoard, count, gain_org[" << ch << "] "
+	   << kBoard << " " << count << " " << gain_org[ch] << endl;
+      ch++;
+    }
+    count++;
+  }// end if first loop on all channels      
+  in_gain.close();
+  in_gain.clear();
+ 
+
+}
+//--------------------------------------------------------------------------------------------------------
Index: equalization_gain/trunk/src/PlotScurvesAll-diffFit.d
===================================================================
--- equalization_gain/trunk/src/PlotScurvesAll-diffFit.d	(revision 196)
+++ 	(revision )
@@ -1,68 +1,0 @@
-PlotScurvesAll-diffFit.o PlotScurvesAll-diffFit.d : PlotScurvesAll-diffFit.cc \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TROOT.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDirectory.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TNamed.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TObject.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Rtypes.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/RConfig.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/RVersion.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/DllImport.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Rtypeinfo.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/snprintf.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/strlcpy.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TGenericClassInfo.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TSchemaHelper.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TStorage.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVersionCheck.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Riosfwd.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TBuffer.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TString.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TMathBase.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TList.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TSeqCollection.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TCollection.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TIterator.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDatime.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TUUID.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TH1D.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TH1.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAxis.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttAxis.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayD.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArray.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttLine.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttFill.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttMarker.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayC.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayS.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayI.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayF.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Foption.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVectorFfwd.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVectorDfwd.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TFitResultPtr.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TH2D.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TH2.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TMatrixFBasefwd.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TMatrixDBasefwd.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TCanvas.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TPad.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVirtualPad.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttPad.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVirtualX.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttText.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/GuiTypes.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Buttons.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TQObject.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttCanvas.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TCanvasImp.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TF1.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TFormula.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TBits.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TObjArray.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Math/ParamFunctor.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TGraphErrors.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TGraph.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TLine.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TStyle.h \
-  PlotScurvesAll-diffFitConst.h PlotScurvesAll-diffFit.h
Index: equalization_gain/trunk/src/PlotScurvesAll-diffFit.h
===================================================================
--- equalization_gain/trunk/src/PlotScurvesAll-diffFit.h	(revision 196)
+++ equalization_gain/trunk/src/PlotScurvesAll-diffFit.h	(revision 197)
@@ -6,6 +6,12 @@
 #define _PLOTSCURVESALLDIFFFIT_H_
 
+#include <iostream>
+#include "TString.h"
 #include "PlotScurvesAll-diffFitConst.h"
 
+
+class TCanvas;
+class TH1D;
+class TF1;
 
 void PlotScurve(
@@ -61,4 +67,9 @@
 private:
 
+ void Init();
+ void OpenGainFile(const TString);
+ void FillHistoName();
+ void ReadGainFile(const TString,Bool_t);
+
 // common variables to the analysis
      TString *input;
@@ -83,4 +94,28 @@
      Double_t flag_fit[kNch];
 
+     //canvas pointers
+
+     TCanvas *c1; //smoothed S-curves
+     TCanvas *c2; //differentiated histograms of smoothed s-curves
+     TCanvas *c5;
+     TCanvas *c3;            
+     TCanvas *c4;
+
+     //histograms
+
+     TString  name_hist[kNch];
+     TString  name_hist_ped[kNch];
+     TString  name_hist_diff[kNch];
+     TString  name_hist_diff_fit[kNch];
+     TString  name_fit_diff[kNch];
+     TH1D    *hist_scurve; // smoothed S-curves
+     TH1D    *hist_scurve_ped; // S-curves for pedestal runs
+     TH1D    *hist_diff; // differentiated histograms of smoothed s-curves
+     TH1D    *hist_diff_fit; // differentiated histograms of fitted s-curves
+     TF1     *fit_sdiff;  // function fitted on differentiated histograms of fitted s-curves
+
+
+     
+
 };
 
Index: equalization_gain/trunk/src/PlotScurvesAllMain.d
===================================================================
--- equalization_gain/trunk/src/PlotScurvesAllMain.d	(revision 196)
+++ 	(revision )
@@ -1,57 +1,0 @@
-PlotScurvesAllMain.o PlotScurvesAllMain.d : PlotScurvesAllMain.cc \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TRint.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TApplication.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TObject.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Rtypes.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/RConfig.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/RVersion.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/DllImport.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Rtypeinfo.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/snprintf.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/strlcpy.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TGenericClassInfo.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TSchemaHelper.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TStorage.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVersionCheck.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Riosfwd.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TBuffer.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TQObject.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TString.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TMathBase.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TApplicationImp.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TSystem.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TNamed.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TInetAddress.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TTimer.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TSysEvtHandler.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TTime.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TROOT.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDirectory.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TList.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TSeqCollection.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TCollection.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TIterator.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDatime.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TUUID.h \
-  PlotScurvesAllMain.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TFile.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDirectoryFile.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TMap.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/THashTable.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TUrl.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TTree.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TBranch.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TObjArray.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttFill.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDataType.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TDictionary.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/Property.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttLine.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TAttMarker.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayD.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArray.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TArrayI.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TClass.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TObjString.h \
-  /Users/dagoret-campagnesylvie/MacOsX/External/root/root-5.34.06/root/include/TVirtualTreePlayer.h \
-  PlotScurvesAll-diffFit.h PlotScurvesAll-diffFitConst.h
