Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5652)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5653)
@@ -26,6 +26,8 @@
      - added missing runs where run number does not appear any more in 
        project-name and is not yet set in the digital modules.
-
-
+   * mcalib/MCalibrationIntensityCam.[h,cc]
+   * mcalib/MCalibrationIntensityChargeCam.[h,cc]
+     - added some new functions to display the results of the intensity
+       calibration
 
  2004/12/17: Thomas Bretz
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc	(revision 5652)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc	(revision 5653)
@@ -196,9 +196,11 @@
       const Float_t qerr = pix.GetConvertedMeanErr();
       //
-      const Float_t phe = apix.GetPheFFactorMethod();
-      const Float_t err = apix.GetPheFFactorMethodErr();
-
-      sig[cnt]       = q;
-      sigerr[cnt]    = qerr;
+      const Float_t phe    = apix.GetPheFFactorMethod();
+      const Float_t pheerr = apix.GetPheFFactorMethodErr();
+
+      sig[cnt]       = phe;
+      sigerr[cnt]    = pheerr;
+
+
       phepersig[cnt] = q > 0.00001 ? phe/q : -1.;
 
@@ -207,5 +209,5 @@
       if (q > 0.00001 && phe > 0.00001)
         {
-          var = err * err / phe / phe + qerr*qerr/q/q;
+          var = pheerr * pheerr / phe / phe + qerr*qerr/q/q;
           if (var > 0.00001)
             var = TMath::Sqrt(var)*phepersig[cnt];
@@ -220,5 +222,101 @@
   gr->SetTitle(Form("%s%3i","Pixel ",pixid));
   gr->GetXaxis()->SetTitle("<photo-electrons> [1]");
-  gr->GetYaxis()->SetTitle("<photo-electrons> / Q [FADC cts^{-1}]");      
+  gr->GetYaxis()->SetTitle("<phes> / <Q> [FADC cts^{-1}]");      
+  return gr;
+}
+
+// -------------------------------------------------------------------
+//
+// Returns a TGraphErrors with the mean effective number of photo-electrons divided by 
+// the mean charge of that pixel vs. the mean number of photo-electrons.
+//
+TGraphErrors *MCalibrationIntensityChargeCam::GetPhePerChargePerArea( const Int_t aidx, const MGeomCam &geom, const MCalibrationCam::PulserColor_t col)
+{
+  
+  Int_t size = CountNumEntries(col);
+  
+  if (size == 0)
+    return NULL;
+  
+  TArrayF phepersig(size);
+  TArrayF phepersigerr(size);
+  TArrayF sig(size);
+  TArrayF sigerr(size);
+  
+  Int_t cnt = 0;
+
+  for (Int_t i=0;i<GetSize();i++)
+    {
+      //
+      // Get the calibration cam from the intensity cam
+      //
+      MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
+
+      if (col != MCalibrationCam::kNONE)
+        if (cam->GetPulserColor() != col)
+          continue;
+      //
+      // Get the calibration pix from the calibration cam
+      //
+      const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
+      const Float_t phe          = apix.GetPheFFactorMethod();
+      const Float_t pherelvar    = apix.GetPheFFactorMethodRelVar();
+      const Float_t pheerr       = apix.GetPheFFactorMethodErr();
+
+      *fLog << "PHERELVAR: " << pherelvar << endl;
+      
+      sig[cnt]       = phe;
+      sigerr[cnt]    = pheerr;
+
+      Double_t sig  = 0.;
+      Double_t sig2 = 0.;
+      Int_t    num  = 0;
+
+      for (Int_t i=0; i<cam->GetSize(); i++)
+        {
+          const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[i];
+          //
+          // Don't use bad pixels
+          //
+          if (!pix.IsFFactorMethodValid())
+            continue;
+          //
+          //
+          if (aidx != geom[i].GetAidx())
+            continue;
+          
+          sig  += pix.GetConvertedMean();
+          sig2 += pix.GetConvertedMean() * pix.GetConvertedMean();
+          num++;
+        }
+      
+      if (num > 1)
+        {
+          sig           /= num;
+
+          Double_t var = (sig2 - sig*sig*num) / (num-1);
+          var /= sig*sig;
+          var += pherelvar;
+
+          phepersig[cnt] = phe/sig;
+          if (var > 0.)
+            phepersigerr[cnt] = TMath::Sqrt(var) * phepersig[cnt];
+          else
+            phepersigerr[cnt] = 0.;
+        }
+      else
+        {
+          phepersig[cnt]    = -1.;
+          phepersigerr[cnt] = 0.;
+        }
+      cnt++;
+    }
+  
+  TGraphErrors *gr = new TGraphErrors(size,
+                                     sig.GetArray(),phepersig.GetArray(),
+                                     sigerr.GetArray(),phepersigerr.GetArray());
+  gr->SetTitle(Form("%s%3i","Conv. Factors Area %d Average",aidx));
+  gr->GetXaxis()->SetTitle("<photo-electrons> [1]");
+  gr->GetYaxis()->SetTitle("<phes> / <Q> [FADC cts^{-1}]");      
   return gr;
 }
@@ -235,5 +333,5 @@
 {
   
-  const Int_t size = GetSize();
+  Int_t size = CountNumEntries(col);
   
   TArrayF phe(size);
@@ -242,5 +340,7 @@
   TArrayF sigerr(size);
   
-  for (Int_t i=0;i<size;i++)
+  Int_t cnt = 0;
+
+  for (Int_t i=0;i<GetSize();i++)
     {
       //
@@ -258,12 +358,14 @@
       MCalibrationChargePix &pix = (MCalibrationChargePix&)(cam->GetAverageArea(aidx));
 
-      phe[i]    = pix.GetPheFFactorMethod();
-      pheerr[i] = pix.GetPheFFactorMethodErr();
+      phe[cnt]    = pix.GetPheFFactorMethod();
+      pheerr[cnt] = pix.GetPheFFactorMethodErr();
       //
       // For the calculation of Q, we have to use the 
       // converted value!
       //
-      sig   [i] = pix.GetConvertedMean();
-      sigerr[i] = pix.GetConvertedMeanErr();
+      sig   [cnt] = pix.GetConvertedMean();
+      sigerr[cnt] = pix.GetConvertedMeanErr();
+
+      cnt++;
     }
   
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.h	(revision 5652)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.h	(revision 5653)
@@ -49,4 +49,5 @@
   TGraphErrors *GetPheVsCharge( const UInt_t pixid, const MCalibrationCam::PulserColor_t col=MCalibrationCam::kNONE);
   TGraphErrors *GetPhePerCharge( const UInt_t pixid, const MGeomCam &geom, const MCalibrationCam::PulserColor_t col=MCalibrationCam::kNONE);
+  TGraphErrors *GetPhePerChargePerArea( const Int_t aidx, const MGeomCam &geom, const MCalibrationCam::PulserColor_t col=MCalibrationCam::kNONE);
   TGraphErrors *GetPheVsChargePerArea( const Int_t aidx, const MCalibrationCam::PulserColor_t col=MCalibrationCam::kNONE);
   TH2F         *GetRazmikPlotResults( const Int_t aidx, const MGeomCam &geom );
