Index: /trunk/Mars/fact/analysis/gain/fit_spectra.C
===================================================================
--- /trunk/Mars/fact/analysis/gain/fit_spectra.C	(revision 17052)
+++ /trunk/Mars/fact/analysis/gain/fit_spectra.C	(revision 17053)
@@ -111,4 +111,7 @@
     bool fast = false; // Switch off using integral
 
+    // Values which should be read from the file but not available atm
+    Int_t integration_window = 30;
+
     // Map for which pixel shall be plotted and which not
     TArrayC usePixel(1440);
@@ -180,18 +183,9 @@
     }
 
-    MParameterI win("IntegrationWindow");
-    if (win.Read()<=0)
-    {
-        cout << "IntegrationWindow not found in '" << filename << "'." << endl;
-        return 5;
-    }
-
-    Int_t integration_window = win.GetVal();
-
     MArrayI ext;
     if (ext.Read("ExtractionRange")<=0)
     {
         cout << "ExtractionRange not found in '" << filename << "'." << endl;
-        return 6;
+        return 5;
 
     }
@@ -215,4 +209,6 @@
     MHCamera cNormGain(fact);
     MHCamera cFitProb(fact);
+    MHCamera cCrosstalkP(fact);
+    MHCamera cCoeffR(fact);
 
     // Set name and title for the histograms
@@ -226,10 +222,12 @@
     cNormGain.SetNameTitle ("NormGain",  "Normalized gain");
     cFitProb.SetNameTitle  ("FitProb",   "Root's fit probability");
+    cCrosstalkP.SetNameTitle("Pxtalk",   "Crosstalk coeff. P");
+    cCoeffR.SetNameTitle   ("CoeffR",    "Coefficient R");
 
     // Instantiate 1D histograms for the distributions
-    TH1F hRate     ("Rate",      "Dark count rate",       200,  0,    10);
+    TH1F hRate     ("Rate",      "Dark count rate",       100,  0,    10);
     TH1F hGain     ("Gain",      "Gain distribution",     100,  0,   400);
     TH1F hRelSigma ("RelSigma",  "Rel. Sigma",            160,  0,  0.40);
-    TH1F hCrosstalk("Crosstalk", "Crosstalk probability", 120,  0,  0.30);
+    TH1F hCrosstalk("Crosstalk", "Crosstalk probability",  90,  0,  0.30);
     TH1F hBaseline ("Baseline",  "Baseline per sample",    75, -7.5, 7.5);
     TH1F hNoise    ("Noise",     "Noise per sample",       60,  0,    30);
@@ -237,4 +235,6 @@
     TH1F hNormGain ("NormGain",  "Normalized gain",        51,  0.5, 1.5);
     TH1F hFitProb  ("FitProb",   "FitProb distribution",  100,  0,     1);
+    TH1F hCrosstalkP("Pxtalk",   "Crosstalk coeff.",       90,  0,   0.3);
+    TH1F hCoeffR   ("CoeffR",    "Coefficient R",          90, -1,     2);
 
     // Histigram for the sum of all spectrums
@@ -347,4 +347,6 @@
     Double_t res_par[7];
     func.GetParameters(res_par);
+
+    //func.FixParameter(6, func.GetParameter(6));                          // Expo
 
     // ------------------ display result -------------------------------
@@ -423,5 +425,5 @@
 
         // For individual spectra, the average fit yields 1 anyway
-        func.FixParameter(6, 1); // Expo
+        func.SetParameter(6, 0); // Expo
 
         // ----------- Fit Pixels spectrum ---------------
@@ -459,7 +461,9 @@
         const float fGain      = func.GetParameter(1);
         const float fGainRMS   = func.GetParameter(2);
+        const float fCrosstalkP= func.GetParameter(3);
         const float fCrosstlk  = xtalk(func);
         const float fOffset    = func.GetParameter(4);
         const float fNoise     = func.GetParameter(5)/sqrt(integration_window);
+        const float fCoeffR    = func.GetParameter(6);
 
         // Fill histograms with result values
@@ -473,4 +477,6 @@
         cNormGain.SetBinContent(  pixel+1, fGain/gain);
         cFitProb.SetBinContent(   pixel+1, fit_prob);
+        cCrosstalkP.SetBinContent(pixel+1, fCrosstalkP);
+        cCoeffR.SetBinContent(    pixel+1, fCoeffR);
 
         // ======================================================
@@ -576,10 +582,12 @@
     cNormGain.SetUsed(usePixel);
     cFitProb.SetUsed(usePixel);
+    cCrosstalkP.SetUsed(usePixel);
+    cCoeffR.SetUsed(usePixel);
 
     // --------------------------------------------------------
     // Display data
 
-    TCanvas *canv = &d->AddTab("Cams");
-    canv->Divide(4,2);
+    TCanvas *canv = &d->AddTab("Cams1");
+    canv->Divide(3,2);
 
     canv->cd(1);
@@ -590,27 +598,37 @@
 
     canv->cd(3);
+    cBaseline.DrawCopy();
+
+    canv->cd(4);
     cRelSigma.DrawCopy();
 
-    canv->cd(4);
+    canv->cd(5);
     cCrosstalk.DrawCopy();
-
-    canv->cd(5);
-    cBaseline.DrawCopy();
 
     canv->cd(6);
     cNoise.DrawCopy();
 
-    canv->cd(7);
+
+    canv = &d->AddTab("Cams2");
+    canv->Divide(3,2);
+
+    canv->cd(1);
     cFitProb.DrawCopy();
 
-    canv->cd(8);
+    canv->cd(2);
     cChi2.DrawCopy();
 
+    canv->cd(4);
+    cCoeffR.DrawCopy();
+
+    canv->cd(5);
+    cCrosstalkP.DrawCopy();
+
     // --------------------------------------------------------
 
     gStyle->SetOptFit(1);
 
-    canv = &d->AddTab("Hists");
-    canv->Divide(4,2);
+    canv = &d->AddTab("Hists1");
+    canv->Divide(3,2);
 
     TH1 *hh = 0;
@@ -624,13 +642,13 @@
 
     canv->cd(3);
+    hh = hBaseline.DrawCopy();
+    hh->Fit("gaus");
+
+    canv->cd(4);
     hh = hRelSigma.DrawCopy();
     hh->Fit("gaus");
 
-    canv->cd(4);
+    canv->cd(5);
     hh = hCrosstalk.DrawCopy();
-    hh->Fit("gaus");
-
-    canv->cd(5);
-    hh = hBaseline.DrawCopy();
     hh->Fit("gaus");
 
@@ -639,10 +657,24 @@
     hh->Fit("gaus");
 
-    canv->cd(7);
+    // --------------------------------------------------------
+
+    canv = &d->AddTab("Hists2");
+    canv->Divide(3,2);
+
+    canv->cd(1);
     gPad->SetLogy();
-    hFitProb.DrawCopy();
-
-    canv->cd(8);
+    hh = hFitProb.DrawCopy();
+    hh->Fit("gaus");
+
+    canv->cd(2);
     hChi2.DrawCopy();
+
+    canv->cd(4);
+    hh = hCoeffR.DrawCopy();
+    hh->Fit("gaus");
+
+    canv->cd(5);
+    hh = hCrosstalkP.DrawCopy();
+    hh->Fit("gaus");
 
     // --------------------------------------------------------
