Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2660)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2661)
@@ -5,4 +5,10 @@
                                                  -*-*- END OF LINE -*-*-
  
+ 2003/12/12: Markus Gaug
+   * manalysis/MExtractedSignalPix:
+	- Added fTailArrivalTime
+   * manalysis/MExtractSignals:
+	- SetArrivalTimes modified to 3 arguments (sorry!)
+
  2003/12/11: Sebastian Raducci & Villi Scalzotto
 
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc	(revision 2660)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc	(revision 2661)
@@ -45,4 +45,6 @@
 #include "MLogManip.h"
 
+#include "TCanvas.h"
+
 #include "MGeomCam.h"
 
@@ -59,5 +61,7 @@
     : fMeanNrPhotAvailable(kFALSE),
       fMeanNrPhotInnerPix(-1.),
-      fMeanNrPhotInnerPixErr(-1.)
+      fMeanNrPhotInnerPixErr(-1.),
+      fOffsets(NULL),
+      fSlopes(NULL)
 {
     fName  = name  ? name  : "MCalibrationCam";
@@ -83,5 +87,41 @@
   delete fBlindPixel;
   delete fPINDiode;
-}
+
+  if (fOffsets)
+    delete fOffsets;
+  if (fSlopes)
+    delete fSlopes;
+
+}
+
+void MCalibrationCam::DrawHiLoFits()
+{
+
+  fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-300.,300.);
+  fSlopes  = new TH1D("mm","Slopess of the HiGain LoGain Fit",100,-3.,3.);
+
+  TIter Next(fPixels);
+  MCalibrationPix *pix;
+  while ((pix=(MCalibrationPix*)Next()))
+    {
+
+      fOffsets->Fill(pix->GetHist()->GetOffset());
+      fSlopes->Fill(pix->GetHist()->GetSlope());
+
+    }
+
+  TCanvas *c1 = new TCanvas();
+  c1->Divide(1,2);
+  c1->cd(1);
+  fOffsets->Draw();
+  gPad->Modified();
+  gPad->Update();
+
+  c1->cd(2);
+  fSlopes->Draw();
+  gPad->Modified();
+  gPad->Update();
+}
+
 
 // --------------------------------------------------------------------------
@@ -490,4 +530,5 @@
 Bool_t MCalibrationCam::CalcNrPhotInnerPixel()
 {
+
   if (!fBlindPixel->IsFitOK())
     return kFALSE;
@@ -522,4 +563,13 @@
 
   fMeanNrPhotAvailable = kTRUE;
+
+  TIter Next(fPixels);
+  MCalibrationPix *pix;
+  while ((pix=(MCalibrationPix*)Next()))
+    {
+      
+      if((pix->GetCharge() > 0.) && (fMeanNrPhotInnerPix > 0.))
+	pix->SetConversionBlindPixelMethod(fMeanNrPhotInnerPix/pix->GetCharge(), 0., 0.);
+    }
   return kTRUE;
 }
@@ -536,5 +586,24 @@
       return kFALSE;
 
-  mean = fMeanNrPhotInnerPix / (*this)[ipx].GetCharge();
+  mean  = (*this)[ipx].GetMeanConversionBlindPixelMethod();
+  err   = (*this)[ipx].GetErrorConversionBlindPixelMethod();
+  sigma = (*this)[ipx].GetSigmaConversionBlindPixelMethod();
+
+  return kTRUE;
+}
+
+
+Bool_t MCalibrationCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
+{
+  
+  if (ipx < 0 || !IsPixelFitted(ipx))
+    return kFALSE;
+
+  Float_t conv = (*this)[ipx].GetConversionFFactorMethod();
+
+  if (conv < 0.)
+    return kFALSE;
+
+  mean = conv;
 
   //
@@ -548,28 +617,12 @@
 
 
-Bool_t MCalibrationCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
-{
-  
-  if (ipx < 0 || !IsPixelFitted(ipx))
-    return kFALSE;
-
-  Float_t conv = (*this)[ipx].GetConversionFFactorMethod();
-
-  if (conv < 0.)
-    return kFALSE;
-
-  mean = conv;
-
-  //
-  // Not yet ready , sorry 
-  //
-  err  = -1.;
-  sigma = -1.;
+Bool_t MCalibrationCam::GetConversionFactorPINDiode(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
+{
 
   return kTRUE;
-}
-
-
-Bool_t MCalibrationCam::GetConversionFactorPINDiode(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
+
+}
+
+Bool_t MCalibrationCam::GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
 {
 
@@ -577,9 +630,2 @@
 
 }
-
-Bool_t MCalibrationCam::GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
-{
-
-  return kTRUE;
-
-}
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h	(revision 2660)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h	(revision 2661)
@@ -24,4 +24,8 @@
 #ifndef ROOT_TH1F
 #include <TH1F.h>
+#endif
+
+#ifndef ROOT_TH1D
+#include <TH1D.h>
 #endif
 
@@ -62,4 +66,8 @@
   TH1F* fHConvPhEperFADCAllPixels;
   TH1F* fHConvPhperFADCAllPixels;
+
+  TH1D* fOffsets;
+  TH1D* fSlopes;
+  
 
 public:
@@ -115,4 +123,6 @@
   Bool_t GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma);
   
+  void DrawHiLoFits();
+
   ClassDef(MCalibrationCam, 1)	// Storage Container for all calibration information of the camera
 };
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2660)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2661)
@@ -60,4 +60,12 @@
       fPheFFactorMethod(-1.),
       fConversionFFactorMethod(-1.),
+      fConversionBlindPixelMethod(-1.),
+      fConversionPINDiodeMethod(-1.),
+      fConversionErrorFFactorMethod(-1.),
+      fConversionErrorBlindPixelMethod(-1.),
+      fConversionErrorPINDiodeMethod(-1.),
+      fConversionSigmaFFactorMethod(-1.),
+      fConversionSigmaBlindPixelMethod(-1.),
+      fConversionSigmaPINDiodeMethod(-1.),
       fHiGainSaturation(kFALSE),
       fElectronicPedRms(3.67)
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2660)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2661)
@@ -30,5 +30,16 @@
   Float_t fFactor;                  // The laboratory F-factor
   Float_t fPheFFactorMethod;        // The number of Phe's calculated after the F-factor method
-  Float_t fConversionFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method
+
+  Float_t fConversionFFactorMethod; // The conversion factor to Ph's calculated after the F-factor method
+  Float_t fConversionBlindPixelMethod; // The conversion factor to Ph's calculated after the Blind Pixel method
+  Float_t fConversionPINDiodeMethod;   // The conversion factor to Ph's calculated after the PIN Diode method
+
+  Float_t fConversionErrorFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method
+  Float_t fConversionErrorBlindPixelMethod; // The conversion factor to Phe's calculated after the Blind Pixel method
+  Float_t fConversionErrorPINDiodeMethod;   // The conversion factor to Phe's calculated after the PIN Diode method
+
+  Float_t fConversionSigmaFFactorMethod; // The conversion factor to Ph's calculated after the F-factor method
+  Float_t fConversionSigmaBlindPixelMethod; // The conversion factor to Ph's calculated after the Blind Pixel method
+  Float_t fConversionSigmaPINDiodeMethod;   // The conversion factor to Phd's calculated after the PIN Diode method
 
   Bool_t fHiGainSaturation;     // Is Lo-Gain used at all?
@@ -61,5 +72,37 @@
 
   void SetPedestal(Float_t ped, Float_t pedrms);
-  void SetHiGainSaturation()                 { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); } 
+  void SetHiGainSaturation()                        { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); } 
+
+  void SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)      
+                                                    { 
+						      fConversionFFactorMethod = c;
+						      fConversionErrorFFactorMethod = err;
+						      fConversionSigmaFFactorMethod = sig;
+						    }
+  void SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)     
+                                                    { 
+						      fConversionBlindPixelMethod = c; 
+						      fConversionErrorBlindPixelMethod = err; 
+						      fConversionSigmaBlindPixelMethod = sig; 
+						    }
+
+  void SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
+                                                    { 
+						      fConversionPINDiodeMethod = c ;
+						      fConversionErrorPINDiodeMethod = err; 
+						      fConversionSigmaPINDiodeMethod = sig; 
+						    }
+
+  Float_t GetMeanConversionBlindPixelMethod()          { return fConversionBlindPixelMethod ; }
+  Float_t GetErrorConversionBlindPixelMethod()         { return fConversionErrorBlindPixelMethod ; }
+  Float_t GetSigmaConversionBlindPixelMethod()                   { return fConversionSigmaBlindPixelMethod ; }
+
+  Float_t GetMeanConversionFFactorMethod()             { return fConversionFFactorMethod ; }
+  Float_t GetErrorConversionFFactorMethod()            { return fConversionErrorFFactorMethod ; }
+  Float_t GetSigmaConversionFFactorMethod()            { return fConversionSigmaFFactorMethod ; }
+ 
+  Float_t GetMeanConversionPINDiodeMethod()            { return fConversionPINDiodeMethod ; }
+  Float_t GetErrorConversionPINDiodeMethod()           { return fConversionErrorPINDiodeMethod ; }
+  Float_t GetSigmaConversionPINDiodeMethod()           { return fConversionSigmaPINDiodeMethod ; }
 
   void   SetChargesInGraph(Float_t qhi,Float_t qlo) { fHist->SetPointInGraph(qhi,qlo); }
Index: /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2660)
+++ /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2661)
@@ -230,7 +230,7 @@
 
 	if (satHi)
-	  pix.SetArrivalTimes((float)(midlo+3),0.);
+	  pix.SetArrivalTimes((float)(midlo+3),0.,0.);
 	else
-	  pix.SetArrivalTimes((float)(midhi+3),0.);
+	  pix.SetArrivalTimes((float)(midhi+3),0.,0.);
 
       } /* while (pixel.Next()) */
Index: /trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.h	(revision 2660)
+++ /trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.h	(revision 2661)
@@ -20,4 +20,5 @@
     Float_t fMeanArrivalTime;
     Float_t fWidthArrivalTime;
+    Float_t fTailArrivalTime;
 
 public:
@@ -35,4 +36,5 @@
     Float_t GetMeanArrivalTime()            const   { return fMeanArrivalTime; }
     Float_t GetWidthArrivalTime()           const   { return fWidthArrivalTime; }
+    Float_t GetTailArrivalTime()           const    { return fTailArrivalTime; }
 
     void SetExtractedSignal(Float_t sig, Float_t sigerr)   
@@ -55,7 +57,8 @@
 					  fNumLoGainSaturated = logain; }
 
-    void SetArrivalTimes(Float_t mean, Float_t width) 
+    void SetArrivalTimes(Float_t mean, Float_t width, Float_t tail) 
                                      { fMeanArrivalTime = mean;
                                        fWidthArrivalTime  = width;
+                                       fTailArrivalTime  = tail;
 				     }
 
Index: /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2660)
+++ /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2661)
@@ -45,4 +45,5 @@
 #include <TF1.h>
 #include <TH2.h>
+#include <TProfile.h>
 #include <TCanvas.h>
 #include <TPad.h>
@@ -85,5 +86,7 @@
         fTimeProb(-1.),
         fTimeNdf(-1),
-	fUseLoGain(kFALSE)
+	fUseLoGain(kFALSE),
+	fOffset(0.),
+	fSlope(0.)
 { 
 
@@ -391,6 +394,11 @@
     }
 
-    gStyle->SetOptFit(0);
-    gStyle->SetOptStat(1111111);
+  TProfile *hist = new TProfile("PePe","Shit is still moving",100,0.,1000.,0.,1000.);
+
+  for (Int_t i=0;i<fTotalEntries;i++)
+      hist->Fill(fHiGains->At(i),fLoGains->At(i),1);
+
+  gStyle->SetOptFit(0);
+  gStyle->SetOptStat(1111111);
     
     TCanvas *c = MakeDefCanvas(this,600,900); 
@@ -432,6 +440,15 @@
 	gROOT->SetSelectedPad(NULL);
 	gStyle->SetOptFit();
-	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
-	fHiGainvsLoGain->Fit("p1","q");
+	//	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
+	//	fHiGainvsLoGain->Fit("p1","q");
+	hist->Draw("prof");
+	hist->Fit("pol1","pepe","markus",hist->GetMean()-3.*hist->GetRMS(),hist->GetMean()+2.*hist->GetRMS());
+
+	fOffset = hist->GetFunction("pepe")->GetParameter(0);
+	fSlope  = hist->GetFunction("pepe")->GetParameter(1);
+
+	cout << "Pepe: " << fOffset << " Markus: " << fSlope << endl;
+
+
 	gPad->Modified();
 	gPad->Update();
@@ -467,6 +484,8 @@
 	gROOT->SetSelectedPad(NULL);
 	gStyle->SetOptFit();
-	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
-	fHiGainvsLoGain->Fit("p1","q");
+	hist->Draw("prof");
+	hist->Fit("p1","pepe","markus",hist->GetMean()-3.*hist->GetRMS(),hist->GetMean()+3.*hist->GetRMS());
+	//	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
+	//	fHiGainvsLoGain->Fit("p1","q");
 	gPad->Modified();
 	gPad->Update();
Index: /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h	(revision 2660)
+++ /trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h	(revision 2661)
@@ -85,4 +85,7 @@
 
   Bool_t fUseLoGain;
+
+  Double_t fOffset;
+  Double_t fSlope;
   
   virtual void DrawLegend();
@@ -137,4 +140,7 @@
   const TH1I *GetHChargevsN()               { return fHChargevsNHiGain; }
   const TH1I *GetHChargevsN()         const { return fHChargevsNHiGain; }
+
+  Double_t GetOffset()  { return fOffset; }
+  Double_t GetSlope()   { return fSlope;  }
   
   Bool_t FitChargeHiGain(Option_t *option="RQ0");  
