Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5875)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5876)
@@ -76,4 +76,8 @@
      - fixed default weights files for pedestal extraction for cosmcis
 
+ 2005/01/17 Nadia Tonello and Markus Gaug
+
+   * mcalib/MCalibrationChargeCam.cc
+     - some fit improvements in the function GetAveragedConvFADC2PhotPerArea
 
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 5875)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 5876)
@@ -691,7 +691,24 @@
   TH1D *h = convcam.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750);
   h->SetDirectory(NULL);
-  h->Fit("gaus","Q");
-  TF1 *fit = h->GetFunction("gaus");
-  
+
+  TF1 *fit = NULL;
+
+  if (geom.InheritsFrom("MGeomCamMagic"))
+    {
+
+      fit = new TF1("fit","gaus",0.4,5.);
+      
+      // Fix the ranges, as found by Nadia
+      if(aidx == 0)
+        {h->Fit("fit","REQ", "",0.4,1.5);}
+      else
+        {h->Fit("fit","REQ", "",1.,5.);}
+    }
+  else
+    {
+      h->Fit("gaus","Q");
+      fit = h->GetFunction("gaus");
+    }
+
   Float_t ci2   = fit->GetChisquare();
   Float_t sigma = fit->GetParameter(2);
@@ -699,6 +716,17 @@
   if (ci2 > 500. || sigma > sg)
     {
-      h->Fit("gaus","QM");
-      fit = h->GetFunction("gaus");
+      if (geom.InheritsFrom("MGeomCamMagic"))
+        {
+          // Fix the ranges, as found by Nadia
+          if(aidx == 0)
+            {h->Fit("fit","REQ", "",0.4,1.5);}
+          else
+            {h->Fit("fit","REQ", "",1.,5.);}
+        }
+      else
+        {
+          h->Fit("gaus","MREQ");
+          fit = h->GetFunction("gaus");
+        }
       
       ci2   = fit->GetChisquare();
@@ -720,4 +748,5 @@
         << "  Chisquare: " << Form("%4.3f",fit->GetChisquare()) << "  NDF  : " << ndf << endl;          
   
+  delete fit;
   delete h;
   gROOT->GetListOfFunctions()->Remove(fit);
