Index: /trunk/MagicSoft/Mars/macros/calibration.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/calibration.C	(revision 2659)
+++ /trunk/MagicSoft/Mars/macros/calibration.C	(revision 2660)
@@ -105,7 +105,6 @@
     read2.DisableAutoScheme();
 
-    MExtractSignal   sigsig;
-    MCalibrationCalc calcalc;
-//    calcalc.SetSkipTFits();
+    MExtractSignal        sigsig;
+    MCalibrationCalc     calcalc;
     MExtractedSignalCam   sigcam;
 
@@ -170,5 +169,5 @@
     MHCamera disp6   (geomcam, "MCalibrationCam;t", "Arrival Times");
     MHCamera disp7   (geomcam, "MCalibrationCam;sigmat", "Sigma of Arrival Times");
-    MHCamera disp8   (geomcam, "MCalibrationCam;probt", "Probability of Time Fit");
+    MHCamera disp8   (geomcam, "MCalibrationCam;probt", "Chi Square of Time Fit");
     MHCamera disp9   (geomcam, "MCalibrationCam;ped", "Pedestals");
     MHCamera disp10  (geomcam, "MCalibrationCam;pedrms", "Pedestal RMS");
@@ -214,5 +213,5 @@
     disp6.SetYTitle("T [FADC slices]");
     disp7.SetYTitle("\\Delta T [FADC slices]");
-    disp8.SetYTitle("P [au]");
+    disp8.SetYTitle("\\Chi^2 T [au]");
     disp9.SetYTitle("P [Total FADC counts ]");
     disp10.SetYTitle("RMS_{P} [Total FADC counts ]");
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc	(revision 2659)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc	(revision 2660)
@@ -345,4 +345,12 @@
 	    pix.SetChargesInGraph(sumhi,sumlo);
 
+	    if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
+	      *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: " 
+		    << pixid << " signal = " << sumlo  << " event Nr: " << fEvents << endl;
+		
+	    if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
+	      *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: " 
+		    << pixid << " signal = " << sumhi  << " event Nr: " << fEvents << endl;
+
 	    if (logain)
 	      {
@@ -355,8 +363,4 @@
 		  *fLog << warn << "Could not fill Lo Gain Time of pixel: " 
 			<< pixid << " time = " << mtime << endl;
-		
-		if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
-		  *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: " 
-			<< pixid << " signal = " << sumlo  << " event Nr: " << fEvents << endl;
 		
 	      }
@@ -371,7 +375,4 @@
 			<< pixid << " time = " << mtime << endl;
 		
-		if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
-		  *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: " 
-			<< pixid << " signal = " << sumhi  << " event Nr: " << fEvents << endl;
 	      }
 	    break;
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc	(revision 2659)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc	(revision 2660)
@@ -405,4 +405,7 @@
 {
 
+  if (idx > GetSize())
+    return kFALSE;
+
   switch (type)
     {
@@ -429,5 +432,5 @@
       break;
     case 7:
-      val = (*this)[idx].GetTimeProb();
+      val = (*this)[idx].GetTimeChiSquare();
       break;
     case 8:
@@ -438,5 +441,8 @@
       break;
     case 10:
-      val = TMath::Sqrt((*this)[idx].GetRSigmaSquare());
+      if ((*this)[idx].GetRSigmaSquare() > 0.)
+	val = TMath::Sqrt((*this)[idx].GetRSigmaSquare());
+      else
+	val = -1.;
       break;
     case 15:
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h	(revision 2659)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h	(revision 2660)
@@ -22,4 +22,7 @@
 #endif
 
+#ifndef ROOT_TH1F
+#include <TH1F.h>
+#endif
 
 class MGeomCam;
@@ -41,4 +44,22 @@
   Float_t fMeanNrPhotInnerPix;       // The mean number of photons in an inner pixel  
   Float_t fMeanNrPhotInnerPixErr;    // The uncertainty about the number of photons in an inner pixel  
+
+  TH1F* fHChargeAllPixels;
+  TH1F* fHChargeErrAllPixels;
+  TH1F* fHChargeSigmaAllPixels;
+  TH1F* fHChargeProbAllPixels;
+
+  TH1F* fHTimeAllPixels;
+  TH1F* fHTimeSigmaAllPixels;
+  TH1F* fHTimeProbAllPixels;
+
+  TH1F* fHPedAllPixels;
+  TH1F* fHPedRMSAllPixels;
+
+  TH1F* fHSigmaPerChargeAllPixels;
+  TH1F* fHPhEAllPixels;
+
+  TH1F* fHConvPhEperFADCAllPixels;
+  TH1F* fHConvPhperFADCAllPixels;
 
 public:
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2659)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2660)
@@ -56,5 +56,5 @@
       fTime(-1.),
       fSigmaTime(-1.),
-      fTimeProb(-1.),
+      fTimeChiSquare(-1.),
       fFactor(1.3),
       fPheFFactorMethod(-1.),
@@ -201,7 +201,7 @@
     }
     
-  fTime       = fHist->GetTimeMean();
-  fSigmaTime  = fHist->GetTimeSigma();
-  fTimeProb   = fHist->GetTimeProb();
+  fTime          = fHist->GetTimeMean();
+  fSigmaTime     = fHist->GetTimeSigma();
+  fTimeChiSquare = fHist->GetTimeChiSquare();
 
   return kTRUE;
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2659)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2660)
@@ -26,5 +26,5 @@
   Float_t fTime;                // The mean arrival time after the fit  
   Float_t fSigmaTime;           // The error of the mean arrival time after the fit
-  Float_t fTimeProb;            // The probability of the fit function 
+  Float_t fTimeChiSquare;       // The probability of the fit function 
   
   Float_t fFactor;                  // The laboratory F-factor
@@ -53,10 +53,10 @@
   Float_t GetSigmaCharge()    const    { return fSigmaCharge;    }
   Float_t GetErrSigmaCharge() const    { return fErrSigmaCharge; }
-  Float_t GetTime()           const    { return fTime;         }
-  Float_t GetSigmaTime()      const    { return fSigmaTime;    }
-  Float_t GetTimeProb()       const    { return fTimeProb;     }    
+  Float_t GetTime()           const    { return fTime;           }
+  Float_t GetSigmaTime()      const    { return fSigmaTime;      }
+  Float_t GetTimeChiSquare()  const    { return fTimeChiSquare;  }    
   
-  Float_t GetPed()            const    { return fPed;       }
-  Float_t GetPedRms()         const    { return fPedRms;    }    
+  Float_t GetPed()            const    { return fPed;            }
+  Float_t GetPedRms()         const    { return fPedRms;         }    
 
   void SetPedestal(Float_t ped, Float_t pedrms);
Index: /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2659)
+++ /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2660)
@@ -211,4 +211,5 @@
 
 	    sumLo += *ptr;
+
 	    if (*ptr >= fSaturationLimit)
 	      {
@@ -219,4 +220,5 @@
 	      }
 	  }
+
 	pix.SetExtractedSignal((float)sumHi - pedes*(float)fNumHiGainSamples,
 			       pedrms*fSqrtHiGainSamples,
Index: /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2659)
+++ /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2660)
@@ -431,5 +431,7 @@
 	c->cd(3);
 	gROOT->SetSelectedPad(NULL);
+	gStyle->SetOptFit();
 	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
+	fHiGainvsLoGain->Fit("p1","q");
 	gPad->Modified();
 	gPad->Update();
@@ -464,5 +466,7 @@
 	
 	gROOT->SetSelectedPad(NULL);
+	gStyle->SetOptFit();
 	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
+	fHiGainvsLoGain->Fit("p1","q");
 	gPad->Modified();
 	gPad->Update();
@@ -493,5 +497,5 @@
 	if (fTimeGausFit)
 	  {
-	    if (fTimeProb > gkProbLimit) 
+	    if (fTimeChisquare > 20.) 
 	      fTimeGausFit->SetLineColor(kRed);
 	    else
@@ -507,5 +511,5 @@
 	if (fTimeGausFit)
 	  {
-	    if (fTimeProb > gkProbLimit) 
+	    if (fTimeChisquare > 20.) 
 	      fTimeGausFit->SetLineColor(kRed);
 	    else
@@ -588,5 +592,5 @@
   fTimeSigma     = fTimeGausFit->GetParameter(2);
 
-  if (fTimeProb < gkProbLimit) 
+  if (fTimeChisquare > 20.)  // Cannot use Probability because Ndf is sometimes < 1
     {
       *fLog << warn << "Fit of the Arrival times failed ! " << endl;
@@ -644,5 +648,5 @@
   fTimeSigma     = fTimeGausFit->GetParameter(2);
 
-  if (fTimeProb < gkProbLimit) 
+  if (fTimeChisquare > 20.)  // Cannot use Probability because Ndf is sometimes < 1
     {
       *fLog << warn << "Fit of the Arrival times failed ! " << endl;
