Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3550)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3551)
@@ -18,4 +18,24 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/03/19: Markus Gaug
+
+   * mcalib/MHCalibrationChargePix.cc
+     - added some style sto the default Draw in order to see the 
+       label and axis titles better
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - store and display more informaiton on the average pxiels
+
+   * mcalib/MCalibrationCam.cc
+     - the GetPixelContent flag were not correct any more, fixed them 
+       
+   * macros/calibration.C
+     - fixed GetPixelContent flags
+     - draw radial profile of the variables
+
+   * mjobs/MJCalibration.cc
+     - fixed GetPixelContent flags
+
+
  2004/03/18: Raquel de los Reyes
 
Index: trunk/MagicSoft/Mars/macros/calibration.C
===================================================================
--- trunk/MagicSoft/Mars/macros/calibration.C	(revision 3550)
+++ trunk/MagicSoft/Mars/macros/calibration.C	(revision 3551)
@@ -24,47 +24,57 @@
 #include "MAGIC.h"
 
-
 void calibration()
 {
 
-//    const char *inpath = "/remote/home/pc2/operator/NewCalBoxTest/";
-//    const char *inpath = "/remote/home/pc2/operator/Crab20040214/";
-//    const char *inpath = "./";
-    //const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
-    //const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_01_26/";
+  //const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
+  //const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_01_26/";
   const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_01_27/";
-    //const TString inpath = "/mnt/Data/rootdata/Miscellaneous/2003_12_19/";
-
-    MRunIter pruns;
-    MRunIter cruns;
-
-    pruns.AddRun(12386,inpath);
-    cruns.AddRun(12525,inpath);
-    //    pruns.AddRun(14400,inpath);
-    //    cruns.AddRuns(14401,14409,inpath);
-//    pruns.AddRuns(15487,15494,inpath);
-//    cruns.AddRuns(15495,15508,inpath);
-//    pruns.AddRun(19816,inpath);  // CalboxTest
-//    cruns.AddRun(19820,inpath); // 3blue
-//    cruns.AddRun(19820,inpath);   // 1blue
-
-    gStyle->SetOptStat(1111);
-    gStyle->SetOptFit();
-
-    MStatusDisplay *display = new MStatusDisplay;
-    display->SetUpdateTime(3000);
-    display->Resize(850,700);
-
-    MJPedestal pedloop;
-    pedloop.SetInput(&pruns);
-    pedloop.SetDisplay(display);
-
-    if (!pedloop.Process())
-        return;
-
-    // 
-    // Now the short version: 
-    //
-/*
+  //const TString inpath = "/mnt/Data/rootdata/Miscellaneous/2003_12_19/";
+  //  const TString inpath = "/mnt/Data/rootdata/Miscellaneous/2004_03_03/";
+  //    const TString inpath = "/home/rootdata/BlindPixel/";
+
+  //  const TString inpath = ".";
+  MRunIter pruns;
+  MRunIter cruns;
+
+  //  pruns.AddRun(20491,inpath);
+  //  pruns.AddRun(20123,inpath);
+
+  pruns.AddRun(12386,inpath);
+  //    pruns.AddRun(14400,inpath);
+  //    cruns.AddRuns(14401,14409,inpath);
+  //    pruns.AddRuns(15487,15494,inpath);
+ //  cruns.AddRuns(12525,12529,inpath);
+  cruns.AddRun(12525,inpath);
+  //    cruns.AddRuns(15495,15508,inpath);
+  //  cruns.AddRun(20491,inpath);
+  //  cruns.AddRun(20129,inpath);
+
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+  
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+  
+  MBadPixelsCam badcam;
+  badcam.AsciiRead("badpixels.dat");
+
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+  
+  MJPedestal pedloop;
+  pedloop.SetInput(&pruns);
+  pedloop.SetDisplay(display);
+  pedloop.SetBadPixels(badcam);
+
+  if (!pedloop.Process())
+    return;
+
+  // 
+  // Now the short version: 
+  //
+  /*
     MJCalibration calloop;
     calloop.SetInput(&cruns);
@@ -72,427 +82,485 @@
     if (!calloop.Process(pedloop.GetPedestalCam()))
         return;
-#if 0
-*/
-    // 
-    // The longer version:
-    //
-
-    //
-    // Create a empty Parameter List and an empty Task List 
-    //
-    MParList  plist;
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-    plist.AddToList(&pedloop.GetPedestalCam());
-
-    gLog << endl;;
-    gLog << "Calculate MCalibrationCam from Runs " << cruns.GetRunsAsString() << endl;
-    gLog << endl;
-
-    MReadMarsFile read("Events");
-    read.DisableAutoScheme();
-    static_cast<MRead&>(read).AddFiles(cruns);
-
-    MGeomCamMagic              geomcam;
-    MExtractedSignalCam        sigcam;
-    MArrivalTimeCam            timecam;
-    MCalibrationChargeCam      calcam;
-    MCalibrationChargePINDiode pindiode;   
-    MCalibrationChargeBlindPix blindpix;   
-    
-    MHCalibrationRelTimeCam     histtime;
-    MHCalibrationChargeCam      histcharge;
-    MHCalibrationChargePINDiode histpin;
-    MHCalibrationChargeBlindPix histblind;
-//    histblind.SetSinglePheCut(80);
-    //
-    // As long, as we don't have digital modules,
-    // we have to set the color of the pulser LED by hand
-    //
-    blindpix.SetColor(kCT1);
-    //    pindiode.SetColor(kCT1);
-    //
-    // Get the previously created MPedestalCam into the new Parameter List 
-    //
-    plist.AddToList(&geomcam);
-    plist.AddToList(&sigcam);
-    plist.AddToList(&timecam);
-    plist.AddToList(&calcam);
-    plist.AddToList(&histtime);
-    plist.AddToList(&histcharge);
-//    plist.AddToList(&histpin);
-    plist.AddToList(&histblind);
-    plist.AddToList(&pedloop.GetBadPixels());    
-
-    //
-    // We saw that the signal jumps between slices, 
-    // thus take the sliding window
-    //		
-    MExtractSignal2        sigcalc2;
-    MExtractPINDiode       pincalc;
-    MExtractBlindPixel     blindcalc;
-//    blindcalc.SetRange(11,16);
-
-    MArrivalTimeCalc2      timecalc;
-    MCalibrationChargeCalc calcalc;
-    MGeomApply             geomapl;
-
-    MFillH filltime( "MHCalibrationRelTimeCam"    , "MArrivalTimeCam");
-//   MFillH fillpin  ("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
-    MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
-    MFillH fillcam  ("MHCalibrationChargeCam"     , "MExtractedSignalCam");
-
-    //
-    // Skip the HiGain vs. LoGain calibration
-    // 
-    calcalc.SkipHiLoGainCalibration();
-
-    // 
-    // Apply a filter against cosmics
-    // (was directly in MCalibrationCalc in earlier versions)
-    //
-    MFCosmics            cosmics;
-    MContinue            cont(&cosmics);
-
-    tlist.AddToList(&read);
-    tlist.AddToList(&geomapl);
-    tlist.AddToList(&sigcalc2);
-    tlist.AddToList(&blindcalc);
-//    tlist.AddToList(&pincalc);
-    //
-    // In case, you want to skip the cosmics rejection, 
-    // uncomment the next line
-    //
-    tlist.AddToList(&cont);
-    //
-    // In case, you want to skip the somewhat lengthy calculation
-    // of the arrival times using a spline, uncomment the next two lines
-    //
-    tlist.AddToList(&timecalc);
-    tlist.AddToList(&filltime);
-//    tlist.AddToList(&fillpin);
-    tlist.AddToList(&fillblind);
-    tlist.AddToList(&fillcam);
-    //
-    tlist.AddToList(&calcalc);
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-    evtloop.SetDisplay(display);
-    
-    //
-    // Execute second analysis
-    //
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist.PrintStatistics();
-
-    //
-    // print the most important results of all pixels to a file
-    //
-    MLog gauglog;
-    gauglog.SetOutputFile(Form("%s%s",calcam.GetName(),".txt"),1);
-    calcam.SetLogStream(&gauglog);
-    calcam.Print();
-    calcam.SetLogStream(&gLog);
-    //
-    // just one example how to get the plots of individual pixels
-    //
-    //    histblind.DrawClone("all");
-    //    histcharge[5].DrawClone("all");
-    //    histcharge(5).DrawClone("all");
-    //    histtime[5].DrawClone("fourierevents");
-
-    // Create histograms to display
-    MHCamera disp1  (geomcam, "Cal;Charge",         "Fitted Mean Charges");
-    MHCamera disp2  (geomcam, "Cal;SigmaCharge",    "Sigma of Fitted Charges");
-    MHCamera disp3  (geomcam, "Cal;FitProb",        "Probability of Fit");
-    MHCamera disp4  (geomcam, "Cal;RSigma",         "Reduced Sigmas");
-    MHCamera disp5  (geomcam, "Cal;RSigma/Charge",  "Reduced Sigma per Charge");
-    MHCamera disp6  (geomcam, "Cal;FFactorPh",      "Nr. of Photo-electrons (F-Factor Method)");
-    MHCamera disp7  (geomcam, "Cal;FFactorConv",    "Conversion Factor to photons (F-Factor Method)");
-    MHCamera disp8  (geomcam, "Cal;FFactorFFactor", "Total F-Factor (F-Factor Method)");
-    MHCamera disp9  (geomcam, "Cal;BlindPixPh",     "Photon flux inside plexiglass (Blind Pixel Method)");
-    MHCamera disp10 (geomcam, "Cal;BlindPixConv",   "Conversion Factor to photons (Blind Pixel Method)");
-    MHCamera disp11 (geomcam, "Cal;BlindPixFFactor","Total F-Factor (Blind Pixel Method)");
-    MHCamera disp12 (geomcam, "Cal;PINDiodePh",     "Photon flux outside plexiglass (PIN Diode Method)");
-    MHCamera disp13 (geomcam, "Cal;PINDiodeConv",   "Conversion Factor tp photons (PIN Diode Method)");
-    MHCamera disp14 (geomcam, "Cal;PINDiodeFFactor","Total F-Factor (PIN Diode Method)");
-    MHCamera disp15 (geomcam, "Cal;Excluded",       "Pixels previously excluded");
-    MHCamera disp16 (geomcam, "Cal;NotFitted",      "Pixels that could not be fitted");
-    MHCamera disp17 (geomcam, "Cal;NotFitValid",    "Pixels with not valid fit results");
-    MHCamera disp18 (geomcam, "Cal;HiGainOscillating",     "Oscillating Pixels HI Gain");
-    MHCamera disp19 (geomcam, "Cal;LoGainOscillating",     "Oscillating Pixels LO Gain");
-    MHCamera disp20 (geomcam, "Cal;HiGainPickup",          "Number Pickup events Hi Gain");
-    MHCamera disp21 (geomcam, "Cal;LoGainPickup",          "Number Pickup events Lo Gain");
-    MHCamera disp22 (geomcam, "Cal;Saturation",            "Pixels with saturated Hi Gain");
-    MHCamera disp23 (geomcam, "Cal;FFactorValid",          "Pixels with valid F-Factor calibration");
-    MHCamera disp24 (geomcam, "Cal;BlindPixelValid",       "Pixels with valid BlindPixel calibration");
-    MHCamera disp25 (geomcam, "Cal;PINdiodeFFactorValid",  "Pixels with valid PINDiode calibration");
-
-    MHCamera disp26 (geomcam, "Cal;Ped",         "Pedestals");
-    MHCamera disp27 (geomcam, "Cal;PedRms",      "Pedestal RMS");
-
-    MHCamera disp28 (geomcam, "time;Time",        "Rel. Arrival Times");
-    MHCamera disp29 (geomcam, "time;SigmaTime",   "Sigma of Rel. Arrival Times");
-    MHCamera disp30 (geomcam, "time;TimeProb",    "Probability of Time Fit");
-    MHCamera disp31 (geomcam, "time;NotFitValid", "Pixels with not valid fit results");
-    MHCamera disp32 (geomcam, "time;Oscillating", "Oscillating Pixels");
-
-    MHCamera disp33 (geomcam, "Cal;AbsTimeMean", "Abs. Arrival Times");
-    MHCamera disp34 (geomcam, "Cal;AbsTimeRms",  "RMS of Arrival Times");
-
-    // Fitted charge means and sigmas
-    disp1.SetCamContent(calcam,  0);
-    disp1.SetCamError(  calcam,  1);
-    disp2.SetCamContent(calcam,  2);
-    disp2.SetCamError(  calcam,  3);
-
-    // Fit probabilities
-    disp3.SetCamContent(calcam,  4);
-
-    // Reduced Sigmas and reduced sigmas per charge
-    disp4.SetCamContent(calcam,  5);
-    disp4.SetCamError(  calcam,  6);
-    disp5.SetCamContent(calcam,  7);
-    disp5.SetCamError(  calcam,  8);
-
-    // F-Factor Method
-    disp6.SetCamContent(calcam,  9);
-    disp6.SetCamError(  calcam, 10);
-    disp7.SetCamContent(calcam, 11);
-    disp7.SetCamError(  calcam, 12);
-    disp8.SetCamContent(calcam, 13);
-    disp8.SetCamError(  calcam, 14);
-
-    /// Blind Pixel Method
-    disp9.SetCamContent(calcam, 15);
-    disp9.SetCamError(  calcam, 16);
-    disp10.SetCamContent(calcam,17);
-    disp10.SetCamError(  calcam,18);
-    disp11.SetCamContent(calcam,19);
-    disp11.SetCamError(  calcam,20);
-
-    // PIN Diode Method
-    disp12.SetCamContent(calcam,21);
-    disp12.SetCamError(  calcam,22);
-    disp13.SetCamContent(calcam,23);
-    disp13.SetCamError(  calcam,24);
-    disp14.SetCamContent(calcam,25);
-    disp14.SetCamError(  calcam,26);
-
-    // Pixels with defects
-    disp15.SetCamContent(calcam,27);
-    disp16.SetCamContent(calcam,28);
-    disp17.SetCamContent(calcam,29);
-    disp18.SetCamContent(calcam,30);
-    disp19.SetCamContent(calcam,31);
-    disp20.SetCamContent(calcam,32);
-    disp21.SetCamContent(calcam,33);
-
-    // Lo Gain calibration
-    disp22.SetCamContent(calcam,34);
-
-    // Valid flags
-    disp23.SetCamContent(calcam,35);
-    disp24.SetCamContent(calcam,36);
-    disp25.SetCamContent(calcam,37);
-
-    // Pedestals
-    disp26.SetCamContent(calcam,38);
-    disp26.SetCamError(  calcam,39);
-    disp27.SetCamContent(calcam,40);
-    disp27.SetCamError(  calcam,41);
-
-    // Relative Times
-    disp28.SetCamContent(histtime,0);
-    disp28.SetCamError(  histtime,1);
-    disp29.SetCamContent(histtime,2);
-    disp29.SetCamError(  histtime,3);
-    disp30.SetCamContent(histtime,4);
-    disp31.SetCamContent(histtime,5);
-    disp32.SetCamContent(histtime,6);
-
-    // Absolute Times
-    disp33.SetCamContent(calcam,42);
-    disp33.SetCamError(  calcam,43);
-    disp34.SetCamContent(calcam,43);
-
-    disp1.SetYTitle("Charge [FADC units]");
-    disp2.SetYTitle("\\sigma_{Charge} [FADC units]");
-    disp3.SetYTitle("P_{Charge} [1]");
-
-    disp4.SetYTitle("\\sqrt{\\sigma^{2}_{Charge} - RMS^{2}_{Ped}} [FADC Counts]");
-    disp5.SetYTitle("Reduced Sigma / Mean Charge [1]");
-
-    disp6.SetYTitle("Nr. Photo-electrons [1]");
-    disp7.SetYTitle("Conversion Factor [Ph/FADC Count]");
-    disp8.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1] ");
-
-    disp9.SetYTitle("Photon flux [ph/mm^2]");
-    disp10.SetYTitle("Conversion Factor [Phot/FADC Count]");
-    disp11.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
-
-    disp12.SetYTitle("Photon flux [ph/mm^2]");
-    disp13.SetYTitle("Conversion Factor [Phot/FADC Count]");
-    disp14.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
-
-    disp15.SetYTitle("[1]");
-    disp16.SetYTitle("[1]");
-    disp17.SetYTitle("[1]");
-    disp18.SetYTitle("[1]");
-    disp19.SetYTitle("[1]");
-    disp20.SetYTitle("[1]");
-    disp21.SetYTitle("[1]");
-    disp22.SetYTitle("[1]");
-    disp23.SetYTitle("[1]");
-    disp24.SetYTitle("[1]");
-    disp25.SetYTitle("[1]");
-
-    disp26.SetYTitle("Ped [FADC Counts ]");
-    disp27.SetYTitle("RMS_{Ped} [FADC Counts ]");
-
-    disp28.SetYTitle("Time Offset [ns]");
-    disp29.SetYTitle("Timing resolution [ns]");
-    disp30.SetYTitle("P_{Time} [1]");
-
-    disp31.SetYTitle("[1]");
-    disp32.SetYTitle("[1]");
-
-    disp33.SetYTitle("Mean Abs. Time [FADC slice]");
-    disp34.SetYTitle("RMS Abs. Time [FADC slices]");
-
-    gStyle->SetOptStat(1111);
-    gStyle->SetOptFit();
-    
-    // Charges
-    TCanvas &c1 = display->AddTab("Fit.Charge");
-    c1.Divide(2, 3);
-
-    CamDraw(c1, disp1,calcam,1, 2 , 2);
-    CamDraw(c1, disp2,calcam,2, 2 , 2);
-
-    // Fit Probability
-    TCanvas &c2 = display->AddTab("Fit.Prob");
-    c2.Divide(1,3);
-
-    CamDraw(c2, disp3,calcam,1, 1 , 4);
-
-    // Reduced Sigmas
-    TCanvas &c3 = display->AddTab("Red.Sigma");
-    c3.Divide(2,3);
-
-    CamDraw(c3, disp4,calcam,1, 2 , 2);
-    CamDraw(c3, disp5,calcam,2, 2 , 2);
-
-    // F-Factor Method
-    TCanvas &c4 = display->AddTab("F-Factor");
-    c4.Divide(3,3);
-
-    CamDraw(c4, disp6,calcam,1, 3 , 2);
-    CamDraw(c4, disp7,calcam,2, 3 , 2);
-    CamDraw(c4, disp8,calcam,3, 3 , 2);
-
-    // Blind Pixel Method
-    TCanvas &c5 = display->AddTab("BlindPix");
-    c5.Divide(3, 3);
-
-    CamDraw(c5, disp9,calcam,1, 3 ,  9);
-    CamDraw(c5, disp10,calcam,2, 3 , 2);
-    CamDraw(c5, disp11,calcam,3, 3 , 2);
-
-    // PIN Diode Method
-    TCanvas &c6 = display->AddTab("PINDiode");
-    c6.Divide(3,3);
-
-    CamDraw(c6, disp12,calcam,1, 3 , 9);
-    CamDraw(c6, disp13,calcam,2, 3 , 2);
-    CamDraw(c6, disp14,calcam,3, 3 , 2);
-
-    // Defects
-    TCanvas &c7 = display->AddTab("Defects");
-    c7.Divide(7,2);
-
-    CamDraw(c7, disp15,calcam,1,7, 0);
-    CamDraw(c7, disp16,calcam,2,7, 0);
-    CamDraw(c7, disp17,calcam,3,7, 0);
-    CamDraw(c7, disp18,calcam,4,7, 0);
-    CamDraw(c7, disp19,calcam,5,7, 0);
-    CamDraw(c7, disp20,calcam,6,7, 0);
-    CamDraw(c7, disp21,calcam,7,7, 0);
-
-    // Valid flags
-    TCanvas &c8 = display->AddTab("Validity");
-    c8.Divide(4,2);
-
-    CamDraw(c8, disp22,calcam,1,4,0);
-    CamDraw(c8, disp23,calcam,2,4,0);
-    CamDraw(c8, disp24,calcam,3,4,0);
-    CamDraw(c8, disp25,calcam,4,4,0);
-
-
-    // Pedestals
-    TCanvas &c9 = display->AddTab("Pedestals");
-    c9.Divide(2,3);
-
-    CamDraw(c9,disp26,calcam,1,2,1);
-    CamDraw(c9,disp27,calcam,2,2,2);
-
-    // Rel. Times
-    TCanvas &c10 = display->AddTab("Fitted Rel. Times");
-    c10.Divide(3,3);
-
-    CamDraw(c10,disp28,calcam,1,3,2);
-    CamDraw(c10,disp29,calcam,2,3,2);
-    CamDraw(c10,disp30,calcam,3,3,4);
-
-    // Time Defects
-    TCanvas &c11 = display->AddTab("Time Def.");
-    c11.Divide(2,2);
-
-    CamDraw(c11, disp31,calcam,1,2, 0);
-    CamDraw(c11, disp32,calcam,2,2, 0);
-
-    // Abs. Times
-    TCanvas &c12 = display->AddTab("Abs. Times");
-    c12.Divide(2,3);
-
-    CamDraw(c12,disp33,calcam,1,2,2);
-    CamDraw(c12,disp34,calcam,2,2,2);
-
-#endif
+        //        #if 0
+  */
+  // 
+  // The longer version:
+  //
+  
+  //
+  // Create a empty Parameter List and an empty Task List 
+  //
+  MParList  plist;
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+  plist.AddToList(&pedloop.GetPedestalCam());
+  plist.AddToList(&badcam);
+
+  gLog << endl;;
+  gLog << "Calculate MCalibrationCam from Runs " << cruns.GetRunsAsString() << endl;
+  gLog << endl;
+  
+  MReadMarsFile read("Events");
+  read.DisableAutoScheme();
+  static_cast<MRead&>(read).AddFiles(cruns);
+  
+  MGeomCamMagic              geomcam;
+  MExtractedSignalCam        sigcam;
+  MArrivalTimeCam            timecam;
+  MCalibrationChargeCam      calcam;
+  MCalibrationChargePINDiode pindiode;   
+  MCalibrationChargeBlindPix blindpix;   
+  
+  MHCalibrationRelTimeCam     histtime;
+  MHCalibrationChargeCam      histcharge;
+  MHCalibrationChargePINDiode histpin;
+  MHCalibrationChargeBlindPix histblind;
+  histblind.SetSinglePheCut(1000);
+  //
+  // As long, as we don't have digital modules,
+  // we have to set the color of the pulser LED by hand
+  //
+  blindpix.SetColor(kCT1);
+  //    pindiode.SetColor(kCT1);
+  //
+  // Get the previously created MPedestalCam into the new Parameter List 
+  //
+  plist.AddToList(&geomcam);
+  plist.AddToList(&sigcam);
+  plist.AddToList(&timecam);
+  plist.AddToList(&calcam);
+  plist.AddToList(&histtime);
+  plist.AddToList(&histcharge);
+  //    plist.AddToList(&histpin);
+  plist.AddToList(&histblind);
+  plist.AddToList(&pedloop.GetBadPixels());    
+  
+  //
+  // We saw that the signal jumps between slices, 
+  // thus take the sliding window
+  //		
+  MExtractSignal2        sigcalc2;
+  MExtractPINDiode       pincalc;
+  MExtractBlindPixel     blindcalc;
+  sigcalc2.SetRange(2,15,6,5,14,6);
+  blindcalc.SetRange(11,29);
+
+  MArrivalTimeCalc2      timecalc;
+  MCalibrationChargeCalc calcalc;
+  MGeomApply             geomapl;
+  
+  MFillH filltime( "MHCalibrationRelTimeCam"    , "MArrivalTimeCam");
+  //   MFillH fillpin  ("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
+  MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
+  MFillH fillcam  ("MHCalibrationChargeCam"     , "MExtractedSignalCam");
+  
+  //
+  // Skip the HiGain vs. LoGain calibration
+  // 
+  calcalc.SkipHiLoGainCalibration();
+  
+  // 
+  // Apply a filter against cosmics
+  // (was directly in MCalibrationCalc in earlier versions)
+  //
+  MFCosmics            cosmics;
+  MContinue            cont(&cosmics);
+  
+  tlist.AddToList(&read);
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&sigcalc2);
+  tlist.AddToList(&blindcalc);
+  //    tlist.AddToList(&pincalc);
+  //
+  // In case, you want to skip the cosmics rejection, 
+  // uncomment the next line
+  //
+  tlist.AddToList(&cont);
+  //
+  // In case, you want to skip the somewhat lengthy calculation
+  // of the arrival times using a spline, uncomment the next two lines
+  //
+  tlist.AddToList(&timecalc);
+  tlist.AddToList(&filltime);
+  //    tlist.AddToList(&fillpin);
+  tlist.AddToList(&fillblind);
+  tlist.AddToList(&fillcam);
+  //
+  tlist.AddToList(&calcalc);
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  evtloop.SetDisplay(display);
+  
+  //
+  // Execute second analysis
+  //
+  if (!evtloop.Eventloop())
+    return;
+  
+  tlist.PrintStatistics();
+  
+  //
+  // print the most important results of all pixels to a file
+  //
+  MLog gauglog;
+  gauglog.SetOutputFile(Form("%s%s",calcam.GetName(),".txt"),1);
+  calcam.SetLogStream(&gauglog);
+  badcam.Print();
+  //    calcam.Print();
+  calcam.SetLogStream(&gLog);
+  //
+  // just one example how to get the plots of individual pixels
+  //
+  //    histblind.DrawClone("all");
+  //histcharge[5].DrawClone("all");
+  //    histcharge(5).DrawClone("all");
+  //    histtime[5].DrawClone("fourierevents");
+  
+  // Create histograms to display
+  MHCamera disp1  (geomcam, "Cal;Charge",         "Fitted Mean Charges");
+  MHCamera disp2  (geomcam, "Cal;SigmaCharge",    "Sigma of Fitted Charges");
+  MHCamera disp3  (geomcam, "Cal;FitProb",        "Probability of Fit");
+  MHCamera disp4  (geomcam, "Cal;RSigma",         "Reduced Sigmas");
+  MHCamera disp5  (geomcam, "Cal;RSigma/Charge",  "Reduced Sigma per Charge");
+  MHCamera disp6  (geomcam, "Cal;FFactorPh",      "Nr. of Photo-electrons (F-Factor Method)");
+  MHCamera disp7  (geomcam, "Cal;FFactorConv",    "Conversion Factor to photons (F-Factor Method)");
+  MHCamera disp8  (geomcam, "Cal;FFactorFFactor", "Total F-Factor (F-Factor Method)");
+  MHCamera disp9  (geomcam, "Cal;BlindPixConv",   "Conversion Factor to photons (Blind Pixel Method)");
+  MHCamera disp10 (geomcam, "Cal;BlindPixFFactor","Total F-Factor (Blind Pixel Method)");
+  MHCamera disp11 (geomcam, "Cal;PINDiodeConv",   "Conversion Factor tp photons (PIN Diode Method)");
+  MHCamera disp12 (geomcam, "Cal;PINDiodeFFactor","Total F-Factor (PIN Diode Method)");
+  MHCamera disp13 (geomcam, "Cal;Excluded",       "Pixels previously excluded");
+  MHCamera disp14 (geomcam, "Cal;NotFitted",      "Pixels that could not be fitted");
+  MHCamera disp15 (geomcam, "Cal;NotFitValid",    "Pixels with not valid fit results");
+  MHCamera disp16 (geomcam, "Cal;HiGainOscillating",     "Oscillating Pixels HI Gain");
+  MHCamera disp17 (geomcam, "Cal;LoGainOscillating",     "Oscillating Pixels LO Gain");
+  MHCamera disp18 (geomcam, "Cal;HiGainPickup",          "Number Pickup events Hi Gain");
+  MHCamera disp19 (geomcam, "Cal;LoGainPickup",          "Number Pickup events Lo Gain");
+  MHCamera disp20 (geomcam, "Cal;Saturation",            "Pixels with saturated Hi Gain");
+  MHCamera disp21 (geomcam, "Cal;FFactorValid",          "Pixels with valid F-Factor calibration");
+  MHCamera disp22 (geomcam, "Cal;BlindPixelValid",       "Pixels with valid BlindPixel calibration");
+  MHCamera disp23 (geomcam, "Cal;PINdiodeFFactorValid",  "Pixels with valid PINDiode calibration");
+  
+  MHCamera disp24 (geomcam, "Cal;Ped",         "Pedestals");
+  MHCamera disp25 (geomcam, "Cal;PedRms",      "Pedestal RMS");
+  
+  MHCamera disp26 (geomcam, "time;Time",        "Rel. Arrival Times");
+  MHCamera disp27 (geomcam, "time;SigmaTime",   "Sigma of Rel. Arrival Times");
+  MHCamera disp28 (geomcam, "time;TimeProb",    "Probability of Time Fit");
+  MHCamera disp29 (geomcam, "time;NotFitValid", "Pixels with not valid fit results");
+  MHCamera disp30 (geomcam, "time;Oscillating", "Oscillating Pixels");
+  
+  MHCamera disp31 (geomcam, "Cal;AbsTimeMean", "Abs. Arrival Times");
+  MHCamera disp32 (geomcam, "Cal;AbsTimeRms",  "RMS of Arrival Times");
+  
+  // Fitted charge means and sigmas
+  disp1.SetCamContent(calcam,  0);
+  disp1.SetCamError(  calcam,  1);
+  disp2.SetCamContent(calcam,  2);
+  disp2.SetCamError(  calcam,  3);
+  
+  // Fit probabilities
+  disp3.SetCamContent(calcam,  4);
+  
+  // Reduced Sigmas and reduced sigmas per charge
+  disp4.SetCamContent(calcam,  5);
+  disp4.SetCamError(  calcam,  6);
+  disp5.SetCamContent(calcam,  7);
+  disp5.SetCamError(  calcam,  8);
+  
+  // F-Factor Method
+  disp6.SetCamContent(calcam,  9);
+  disp6.SetCamError(  calcam, 10);
+  disp7.SetCamContent(calcam, 11);
+  disp7.SetCamError(  calcam, 12);
+  disp8.SetCamContent(calcam, 13);
+  disp8.SetCamError(  calcam, 14);
+  
+  // Blind Pixel Method
+  disp9.SetCamContent(calcam, 16);
+  disp9.SetCamError(  calcam, 17);
+  disp10.SetCamContent(calcam,18);
+  disp10.SetCamError(  calcam,19);
+  
+  // PIN Diode Method
+  disp11.SetCamContent(calcam,21);
+  disp11.SetCamError(  calcam,22);
+  disp12.SetCamContent(calcam,23);
+  disp12.SetCamError(  calcam,24);
+  
+  // Pixels with defects
+  disp13.SetCamContent(calcam,26);
+  disp14.SetCamContent(calcam,27);
+  disp15.SetCamContent(badcam,9);
+  disp16.SetCamContent(badcam,16);
+  disp17.SetCamContent(badcam,15);
+  disp18.SetCamContent(calcam,28);
+  disp19.SetCamContent(calcam,29);
+  
+  // Lo Gain calibration
+  disp20.SetCamContent(calcam,30);
+  
+  // Valid flags
+  disp21.SetCamContent(calcam,15);
+  disp22.SetCamContent(calcam,20);
+  disp23.SetCamContent(calcam,25);
+  
+  // Pedestals
+  disp24.SetCamContent(calcam,31);
+  disp24.SetCamError(  calcam,32);
+  disp25.SetCamContent(calcam,33);
+  disp25.SetCamError(  calcam,34);
+  
+  // Relative Times
+  disp26.SetCamContent(histtime,0);
+  disp26.SetCamError(  histtime,1);
+  disp27.SetCamContent(histtime,2);
+  disp27.SetCamError(  histtime,3);
+  disp28.SetCamContent(histtime,4);
+  disp29.SetCamContent(histtime,5);
+  disp30.SetCamContent(histtime,6);
+  
+  // Absolute Times
+  disp31.SetCamContent(calcam,35);
+  disp31.SetCamError(  calcam,35);
+  disp32.SetCamContent(calcam,36);
+  
+  disp1.SetYTitle("Charge [FADC units]");
+  disp2.SetYTitle("\\sigma_{Charge} [FADC units]");
+  disp3.SetYTitle("P_{Charge} [1]");
+  
+  disp4.SetYTitle("\\sqrt{\\sigma^{2}_{Charge} - RMS^{2}_{Ped}} [FADC Counts]");
+  disp5.SetYTitle("Reduced Sigma / Mean Charge [1]");
+  
+  disp6.SetYTitle("Nr. Photo-electrons [1]");
+  disp7.SetYTitle("Conversion Factor [Ph/FADC Count]");
+  disp8.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1] ");
+  
+  disp9.SetYTitle("Conversion Factor [Phot/FADC Count]");
+  disp10.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
+  
+  disp11.SetYTitle("Conversion Factor [Phot/FADC Count]");
+  disp12.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
+  
+  disp13.SetYTitle("[1]");
+  disp14.SetYTitle("[1]");
+  disp15.SetYTitle("[1]");
+  disp16.SetYTitle("[1]");
+  disp17.SetYTitle("[1]");
+  disp18.SetYTitle("[1]");
+  disp19.SetYTitle("[1]");
+  disp20.SetYTitle("[1]");
+  disp21.SetYTitle("[1]");
+  disp22.SetYTitle("[1]");
+  disp23.SetYTitle("[1]");
+  
+  disp24.SetYTitle("Ped [FADC Counts ]");
+  disp25.SetYTitle("RMS_{Ped} [FADC Counts ]");
+  
+  disp26.SetYTitle("Time Offset [ns]");
+  disp27.SetYTitle("Timing resolution [ns]");
+  disp28.SetYTitle("P_{Time} [1]");
+  
+  disp29.SetYTitle("[1]");
+  disp30.SetYTitle("[1]");
+  
+  disp31.SetYTitle("Mean Abs. Time [FADC slice]");
+  disp32.SetYTitle("RMS Abs. Time [FADC slices]");
+  
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+
+  // Charges
+  TCanvas &c1 = display->AddTab("Fit.Charge");
+  c1.Divide(2, 4);
+  
+  CamDraw(c1, disp1,calcam,1, 2 , 2);
+  CamDraw(c1, disp2,calcam,2, 2 , 2);
+  
+  // Fit Probability
+  TCanvas &c2 = display->AddTab("Fit.Prob");
+  c2.Divide(1,4);
+  
+  CamDraw(c2, disp3,calcam,1,1,4);
+  
+  // Reduced Sigmas
+  TCanvas &c3 = display->AddTab("Red.Sigma");
+  c3.Divide(2,4);
+  
+  CamDraw(c3, disp4,calcam,1, 2 , 2);
+  CamDraw(c3, disp5,calcam,2, 2 , 2);
+
+  
+  // F-Factor Method
+  TCanvas &c4 = display->AddTab("F-Factor");
+  c4.Divide(3,4);
+  
+  CamDraw(c4, disp6,calcam,1, 3 , 2);
+  CamDraw(c4, disp7,calcam,2, 3 , 2);
+  CamDraw(c4, disp8,calcam,3, 3 , 2);
+  
+
+  // Blind Pixel Method
+  TCanvas &c5 = display->AddTab("BlindPix");
+  c5.Divide(2, 4);
+  
+  CamDraw(c5, disp9 ,calcam,1,2, 2);
+  CamDraw(c5, disp10,calcam,2,2, 2);
+  
+  // PIN Diode Method
+  TCanvas &c6 = display->AddTab("PINDiode");
+  c6.Divide(2,4);
+  
+  CamDraw(c6, disp11,calcam,1,2, 2);
+  CamDraw(c6, disp12,calcam,2,2, 2);
+  
+  // Defects
+  TCanvas &c7 = display->AddTab("Defects");
+  c7.Divide(4,2);
+  
+  CamDraw(c7, disp13,calcam,1,4, 0);
+  CamDraw(c7, disp14,calcam,2,4, 0);
+  CamDraw(c7, disp18,calcam,3,4, 0);
+  CamDraw(c7, disp19,calcam,4,4, 0);
+  
+  // BadCam
+  TCanvas &c8 = display->AddTab("Defects");
+  c8.Divide(3,2);
+  
+  CamDraw(c8, disp15,badcam,1,3, 0);
+  CamDraw(c8, disp16,badcam,2,3, 0);
+  CamDraw(c8, disp17,badcam,3,3, 0);
+  
+  // Valid flags
+  TCanvas &c9 = display->AddTab("Validity");
+  c9.Divide(4,2);
+  
+  CamDraw(c9, disp20,calcam,1,4,0);
+  CamDraw(c9, disp21,calcam,2,4,0);
+  CamDraw(c9, disp22,calcam,3,4,0);
+  CamDraw(c9, disp23,calcam,4,4,0);
+  
+  // Pedestals
+  TCanvas &c10 = display->AddTab("Pedestals");
+  c10.Divide(2,4);
+  
+  CamDraw(c10,disp24,calcam,1,2,1);
+  CamDraw(c10,disp25,calcam,2,2,2);
+  
+  // Rel. Times
+  TCanvas &c11 = display->AddTab("Fitted Rel. Times");
+  c11.Divide(3,4);
+  
+  CamDraw(c11,disp26,calcam,1,3,2);
+  CamDraw(c11,disp27,calcam,2,3,2);
+  CamDraw(c11,disp28,calcam,3,3,4);
+  
+  // Time Defects
+  TCanvas &c12 = display->AddTab("Time Def.");
+  c12.Divide(2,2);
+  
+  CamDraw(c12, disp29,calcam,1,2, 0);
+  CamDraw(c12, disp30,calcam,2,2, 0);
+  
+  // Abs. Times
+  TCanvas &c13 = display->AddTab("Abs. Times");
+  c13.Divide(2,4);
+  
+  CamDraw(c13,disp31,calcam,1,2,2);
+  CamDraw(c13,disp32,calcam,2,2,2);
+
 }
 
-void CamDraw(TCanvas &c, MHCamera &cam, MCamEvent &evt, Int_t i, Int_t j, Int_t fit)
+
+void CamDraw(TCanvas &c, MHCamera &cam, TObject &evt, Int_t i, Int_t j, Int_t fit)
 {
+  
+  TArrayI s0(6);
+  s0[0] = 1;
+  s0[1] = 2;
+  s0[2] = 3;
+  s0[3] = 4;
+  s0[4] = 5;
+  s0[5] = 6;
+
+  TArrayI s1(3);
+  s1[0] = 6;
+  s1[1] = 1;
+  s1[2] = 2;
+  
+  TArrayI s2(3);
+  s2[0] = 3;
+  s2[1] = 4;
+  s2[2] = 5;
+  
+  TArrayI inner(1);
+  inner[0] = 0;
+  
+  TArrayI outer(1);
+  outer[0] = 1;
 
   c.cd(i);
   gPad->SetBorderMode(0);
-  MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
-  //  obj1->AddNotify(evt);
-  
+  gPad->SetTicks();
+  MHCamera *obj1 = (MHCamera*)cam.DrawCopy("hist");
+  obj1->SetDirectory(NULL);
+
   c.cd(i+j);
-  gPad->SetBorderMode(0);
+  //  obj1->AddNotify(&evt);
+  obj1->SetPrettyPalette();
   obj1->Draw();
-  ((MHCamera*)obj1)->SetPrettyPalette();
 
   if (fit != 0)
     {
+
       c.cd(i+2*j);
       gPad->SetBorderMode(0);
-      TH1D *obj2 = (TH1D*)obj1->Projection(obj1.GetName());
-      
-//      obj2->Sumw2();
+      gPad->SetTicks();
+      TProfile *obj2 = obj1->RadialProfile(Form("%s%s",obj1->GetName(),"_rad"));
+      obj2->SetDirectory(NULL);
       obj2->Draw();
       obj2->SetBit(kCanDelete);
-
-      const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
-      const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
-      const Double_t integ = obj2->Integral("width")/2.5066283;
-      const Double_t mean  = obj2->GetMean();
-      const Double_t rms   = obj2->GetRMS();
+      
+      TProfile *hprof[2];
+      hprof[0] = obj1->RadialProfileS(s0, inner,Form("%s%s",obj1->GetName(), "Inner"));
+      hprof[1] = obj1->RadialProfileS(s0, outer,Form("%s%s",obj1->GetName(), "Outer"));
+
+      
+      for (Int_t k=0; k<2; k++)      
+        {
+          Double_t min = cam.GetGeomCam().GetMinRadius(k);
+          Double_t max = cam.GetGeomCam().GetMaxRadius(k);
+
+          hprof[k]->SetLineColor(kRed+k);
+          hprof[k]->SetDirectory(0);
+          hprof[k]->SetBit(kCanDelete);
+          hprof[k]->Draw("same");
+          hprof[k]->Fit("pol1","Q","",min,max);
+          hprof[k]->GetFunction("pol1")->SetLineColor(kRed+k);
+        }
+      
+      gPad->Modified();
+      gPad->Update();
+
+      c.cd(i+3*j);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      TH1D *obj3 = (TH1D*)obj1->Projection(Form("%s%s",obj1->GetName(),"_py"));
+      obj3->SetDirectory(NULL);
+//      obj3->Sumw2();
+      obj3->Draw();
+      obj3->SetBit(kCanDelete);
+
+      gPad->Modified();
+      gPad->Update();
+
+      const Double_t min   = obj3->GetBinCenter(obj3->GetXaxis()->GetFirst());
+      const Double_t max   = obj3->GetBinCenter(obj3->GetXaxis()->GetLast());
+      const Double_t integ = obj3->Integral("width")/2.5066283;
+      const Double_t mean  = obj3->GetMean();
+      const Double_t rms   = obj3->GetRMS();
       const Double_t width = max-min;
 
@@ -510,6 +578,6 @@
           sgaus->SetParLimits(1,min,max);
           sgaus->SetParLimits(2,0,width/1.5);
-          obj2->Fit("sgaus","QLR");
-          obj2->GetFunction("sgaus")->SetLineColor(kYellow);
+          obj3->Fit("sgaus","QLR");
+          obj3->GetFunction("sgaus")->SetLineColor(kYellow);
           break;
 
@@ -530,6 +598,6 @@
           dgaus->SetParLimits(4,mean,max-(width/10.));
           dgaus->SetParLimits(5,0,width/2.);
-          obj2->Fit("dgaus","QLRM");
-          obj2->GetFunction("dgaus")->SetLineColor(kYellow);
+          obj3->Fit("dgaus","QLRM");
+          obj3->GetFunction("dgaus")->SetLineColor(kYellow);
           break;
           
@@ -558,48 +626,34 @@
           tgaus->SetParLimits(7,min,max);
           tgaus->SetParLimits(8,width/4.,width/1.5);
-          obj2->Fit("tgaus","QLRM");
-          obj2->GetFunction("tgaus")->SetLineColor(kYellow);
+          obj3->Fit("tgaus","QLRM");
+          obj3->GetFunction("tgaus")->SetLineColor(kYellow);
           break;
         case 4:
-          obj2->Fit("pol0","Q");
-          obj2->GetFunction("pol0")->SetLineColor(kYellow);
+          obj3->Fit("pol0","Q");
+          obj3->GetFunction("pol0")->SetLineColor(kYellow);
           break;
         case 9:
           break;
         default:
-          obj2->Fit("gaus","Q");
-          obj2->GetFunction("gaus")->SetLineColor(kYellow);
+          obj3->Fit("gaus","Q");
+          obj3->GetFunction("gaus")->SetLineColor(kYellow);
           break;
         }
       
-        TArrayI s0(3);
-        s0[0] = 6;
-        s0[1] = 1;
-        s0[2] = 2;
-
-        TArrayI s1(3);
-        s1[0] = 3;
-        s1[1] = 4;
-        s1[2] = 5;
-
-        TArrayI inner(1);
-        inner[0] = 0;
-
-        TArrayI outer(1);
-        outer[0] = 1;
+
 
         // Just to get the right (maximum) binning
         TH1D *half[4];
-        half[0] = obj1->ProjectionS(s0, inner, "Sector 6-1-2 Inner");
-        half[1] = obj1->ProjectionS(s1, inner, "Sector 3-4-5 Inner");
-        half[2] = obj1->ProjectionS(s0, outer, "Sector 6-1-2 Outer");
-        half[3] = obj1->ProjectionS(s1, outer, "Sector 3-4-5 Outer");
-
-        for (int i=0; i<4; i++)      
+        half[0] = (TH1D*)obj1->ProjectionS(s1, inner, "Sector 6-1-2 Inner");
+        half[1] = (TH1D*)obj1->ProjectionS(s2, inner, "Sector 3-4-5 Inner");
+        half[2] = (TH1D*)obj1->ProjectionS(s1, outer, "Sector 6-1-2 Outer");
+        half[3] = (TH1D*)obj1->ProjectionS(s2, outer, "Sector 3-4-5 Outer");
+
+        for (Int_t k=0; k<4; k++)      
         {
-            half[i]->SetLineColor(kRed+i);
-            half[i]->SetDirectory(0);
-            half[i]->SetBit(kCanDelete);
-            half[i]->Draw("same");
+            half[k]->SetLineColor(kRed+k);
+            half[k]->SetDirectory(0);
+            half[k]->SetBit(kCanDelete);
+            half[k]->Draw("same");
         }
 
@@ -610,3 +664,2 @@
 }
 
-
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3550)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3551)
@@ -62,5 +62,5 @@
 // =============================================
 //
-// 9: Number of Photo-electrons obtained with the F-Factor method
+//  9: Number of Photo-electrons obtained with the F-Factor method
 // 10: Error on Number of Photo-electrons obtained with the F-Factor method
 // 11: Mean conversion factor obtained with the F-Factor method
@@ -68,50 +68,42 @@
 // 13: Overall F-Factor of the readout obtained with the F-Factor method
 // 14: Error on Overall F-Factor of the readout obtained with the F-Factor method
-// 15: Number of Photons inside Plexiglass obtained with the Blind Pixel method
-// 16: Error on Number of Photons inside Plexiglass obtained with the Blind Pixel method
-// 17: Mean conversion factor obtained with the Blind Pixel method
-// 18: Error on the mean conversion factor obtained with the Blind Pixel method
-// 19: Overall F-Factor of the readout obtained with the Blind Pixel method
-// 20: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
-// 21: Number of Photons outside Plexiglass obtained with the PIN Diode method
-// 22: Error on Number of Photons outside Plexiglass obtained with the PIN Diode method
-// 23: Mean conversion factor obtained with the PIN Diode method
-// 24: Error on the mean conversion factor obtained with the PIN Diode method
-// 25: Overall F-Factor of the readout obtained with the PIN Diode method
-// 26: Error on Overall F-Factor of the readout obtained with the PIN Diode method
+// 15: Pixels with valid calibration by the F-Factor-Method
+// 16: Mean conversion factor obtained with the Blind Pixel method
+// 17: Error on the mean conversion factor obtained with the Blind Pixel method
+// 18: Overall F-Factor of the readout obtained with the Blind Pixel method
+// 19: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
+// 20: Pixels with valid calibration by the Blind Pixel-Method
+// 21: Mean conversion factor obtained with the PIN Diode method
+// 22: Error on the mean conversion factor obtained with the PIN Diode method
+// 23: Overall F-Factor of the readout obtained with the PIN Diode method
+// 24: Error on Overall F-Factor of the readout obtained with the PIN Diode method
+// 25: Pixels with valid calibration by the PIN Diode-Method
 //
 // Localized defects:
 // ==================
 //
-// 27: Excluded Pixels
-// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
-// 29: Number of probable pickup events in the Hi Gain 
-// 30: Number of probable pickup events in the Lo Gain
+// 26: Excluded Pixels
+// 27: Pixels where the fit did not succeed --> results obtained only from the histograms
+// 28: Number of probable pickup events in the Hi Gain 
+// 29: Number of probable pickup events in the Lo Gain
 //
 // Other classifications of pixels:
 // ================================
 //
-// 31: Pixels with saturated Hi-Gain
-//
-// Classification of validity of the calibrations:
-// ===============================================
-//
-// 32: Pixels with valid calibration by the F-Factor-Method
-// 33: Pixels with valid calibration by the Blind Pixel-Method
-// 34: Pixels with valid calibration by the PIN Diode-Method
+// 30: Pixels with saturated Hi-Gain
 //
 // Used Pedestals:
 // ===============
 //
-// 35: Mean Pedestal over the entire range of signal extraction
-// 36: Error on the Mean Pedestal over the entire range of signal extraction
-// 37: Pedestal RMS over the entire range of signal extraction
-// 38: Error on the Pedestal RMS over the entire range of signal extraction
+// 31: Mean Pedestal over the entire range of signal extraction
+// 32: Error on the Mean Pedestal over the entire range of signal extraction
+// 33: Pedestal RMS over the entire range of signal extraction
+// 34: Error on the Pedestal RMS over the entire range of signal extraction
 //
 // Calculated absolute arrival times (very low precision!):
 // ========================================================
 //
-// 39: Absolute Arrival time of the signal
-// 40: RMS of the Absolute Arrival time of the signal
+// 35: Absolute Arrival time of the signal
+// 36: RMS of the Absolute Arrival time of the signal
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -422,8 +414,17 @@
 // 8: Error of Reduced Sigma per Charge 
 //
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to Charge distribution
+// 5: Reduced Sigma of fitted Charge --> sqrt(sigma_Q^2 - PedRMS^2)
+// 6: Error Reduced Sigma of fitted Charge 
+// 7: Reduced Sigma per Charge 
+// 8: Error of Reduced Sigma per Charge 
+//
 // Results of the different calibration methods:
 // =============================================
 //
-// 9: Number of Photo-electrons obtained with the F-Factor method
+//  9: Number of Photo-electrons obtained with the F-Factor method
 // 10: Error on Number of Photo-electrons obtained with the F-Factor method
 // 11: Mean conversion factor obtained with the F-Factor method
@@ -431,50 +432,42 @@
 // 13: Overall F-Factor of the readout obtained with the F-Factor method
 // 14: Error on Overall F-Factor of the readout obtained with the F-Factor method
-// 15: Number of Photons inside Plexiglass obtained with the Blind Pixel method
-// 16: Error on Number of Photons inside Plexiglass obtained with the Blind Pixel method
-// 17: Mean conversion factor obtained with the Blind Pixel method
-// 18: Error on the mean conversion factor obtained with the Blind Pixel method
-// 19: Overall F-Factor of the readout obtained with the Blind Pixel method
-// 20: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
-// 21: Number of Photons outside Plexiglass obtained with the PIN Diode method
-// 22: Error on Number of Photons outside Plexiglass obtained with the PIN Diode method
-// 23: Mean conversion factor obtained with the PIN Diode method
-// 24: Error on the mean conversion factor obtained with the PIN Diode method
-// 25: Overall F-Factor of the readout obtained with the PIN Diode method
-// 26: Error on Overall F-Factor of the readout obtained with the PIN Diode method
+// 15: Pixels with valid calibration by the F-Factor-Method
+// 16: Mean conversion factor obtained with the Blind Pixel method
+// 17: Error on the mean conversion factor obtained with the Blind Pixel method
+// 18: Overall F-Factor of the readout obtained with the Blind Pixel method
+// 19: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
+// 20: Pixels with valid calibration by the Blind Pixel-Method
+// 21: Mean conversion factor obtained with the PIN Diode method
+// 22: Error on the mean conversion factor obtained with the PIN Diode method
+// 23: Overall F-Factor of the readout obtained with the PIN Diode method
+// 24: Error on Overall F-Factor of the readout obtained with the PIN Diode method
+// 25: Pixels with valid calibration by the PIN Diode-Method
 //
 // Localized defects:
 // ==================
 //
-// 27: Excluded Pixels
-// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
-// 29: Number of probable pickup events in the Hi Gain 
-// 30: Number of probable pickup events in the Lo Gain
+// 26: Excluded Pixels
+// 27: Pixels where the fit did not succeed --> results obtained only from the histograms
+// 28: Number of probable pickup events in the Hi Gain 
+// 29: Number of probable pickup events in the Lo Gain
 //
 // Other classifications of pixels:
 // ================================
 //
-// 31: Pixels with saturated Hi-Gain
-//
-// Classification of validity of the calibrations:
-// ===============================================
-//
-// 32: Pixels with valid calibration by the F-Factor-Method
-// 33: Pixels with valid calibration by the Blind Pixel-Method
-// 34: Pixels with valid calibration by the PIN Diode-Method
+// 30: Pixels with saturated Hi-Gain
 //
 // Used Pedestals:
 // ===============
 //
-// 35: Mean Pedestal over the entire range of signal extraction
-// 36: Error on the Mean Pedestal over the entire range of signal extraction
-// 37: Pedestal RMS over the entire range of signal extraction
-// 38: Error on the Pedestal RMS over the entire range of signal extraction
+// 31: Mean Pedestal over the entire range of signal extraction
+// 32: Error on the Mean Pedestal over the entire range of signal extraction
+// 33: Pedestal RMS over the entire range of signal extraction
+// 34: Error on the Pedestal RMS over the entire range of signal extraction
 //
 // Calculated absolute arrival times (very low precision!):
 // ========================================================
 //
-// 39: Absolute Arrival time of the signal
-// 40: RMS of the Absolute Arrival time of the signal
+// 35: Absolute Arrival time of the signal
+// 36: RMS of the Absolute Arrival time of the signal
 //
 Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
@@ -592,68 +585,68 @@
       break;
     case 15:
-      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
-        return kFALSE;
-      //      val = fBlindPixel->GetMeanFluxInsidePlexiglass()*area;
-      val = 1.;
+      if ((*this)[idx].IsExcluded())
+        return kFALSE;
+      if ((*this)[idx].IsFFactorMethodValid())
+        val = 1;
+      else
+        return kFALSE;
       break;
     case 16:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
-      //      val = fBlindPixel->GetMeanFluxErrInsidePlexiglass()*area;
-      val = 1.;
+      val = (*this)[idx].GetMeanConversionBlindPixelMethod();
       break;
     case 17:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
-      val = (*this)[idx].GetMeanConversionBlindPixelMethod();
+      val = (*this)[idx].GetConversionBlindPixelMethodErr();
       break;
     case 18:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
-      val = (*this)[idx].GetConversionBlindPixelMethodErr();
+      val = (*this)[idx].GetTotalFFactorBlindPixelMethod();
       break;
     case 19:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
-      val = (*this)[idx].GetTotalFFactorBlindPixelMethod();
+      val = (*this)[idx].GetTotalFFactorBlindPixelMethodErr();
       break;
     case 20:
-      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
-        return kFALSE;
-      val = (*this)[idx].GetTotalFFactorBlindPixelMethodErr();
+      if ((*this)[idx].IsExcluded())
+        return kFALSE;
+      if ((*this)[idx].IsBlindPixelMethodValid())
+        val = 1;
+      else
+        return kFALSE;
       break;
     case 21:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
-      //      val = fPINDiode->GetMeanFluxOutsidePlexiglass()*area;
-      val = 1.;
+      val = (*this)[idx].GetMeanConversionPINDiodeMethod();
       break;
     case 22:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
-      //      val = fPINDiode->GetMeanFluxErrOutsidePlexiglass()*area;
-      val = 1.;
+      val = (*this)[idx].GetConversionPINDiodeMethodErr();
       break;
     case 23:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
-      val = (*this)[idx].GetMeanConversionPINDiodeMethod();
+      val = (*this)[idx].GetTotalFFactorPINDiodeMethod();
       break;
     case 24:
       if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
-      val = (*this)[idx].GetConversionPINDiodeMethodErr();
+      val = (*this)[idx].GetTotalFFactorPINDiodeMethodErr();
       break;
     case 25:
-      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
-        return kFALSE;
-      val = (*this)[idx].GetTotalFFactorPINDiodeMethod();
+      if ((*this)[idx].IsExcluded())
+        return kFALSE;
+      if ((*this)[idx].IsPINDiodeMethodValid())
+        val = 1;
+      else
+        return kFALSE;
       break;
     case 26:
-      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
-        return kFALSE;
-      val = (*this)[idx].GetTotalFFactorPINDiodeMethodErr();
-      break;
-    case 27:
       if ((*this)[idx].IsExcluded())
         val = 1.;
@@ -661,5 +654,5 @@
         return kFALSE;
       break;
-    case 28:
+    case 27:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
@@ -669,69 +662,45 @@
         return kFALSE;
       break;
+    case 28:
+      if ((*this)[idx].IsExcluded())
+        return kFALSE;
+      val = (*this)[idx].GetHiGainNumPickup();
+      break;
     case 29:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      val = (*this)[idx].GetHiGainNumPickup();
+      val = (*this)[idx].GetLoGainNumPickup();
       break;
     case 30:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      val = (*this)[idx].GetLoGainNumPickup();
+      val = (*this)[idx].IsHiGainSaturation();
       break;
     case 31:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      val = (*this)[idx].IsHiGainSaturation();
+      val = (*this)[idx].GetPed();
       break;
     case 32:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      if ((*this)[idx].IsFFactorMethodValid())
-        val = 1;
-      else
-        return kFALSE;
+      val = (*this)[idx].GetPedErr();
       break;
     case 33:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      if ((*this)[idx].IsBlindPixelMethodValid())
-        val = 1;
-      else
-        return kFALSE;
+      val = (*this)[idx].GetPedRms();
       break;
     case 34:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      if ((*this)[idx].IsPINDiodeMethodValid())
-        val = 1;
-      else
-        return kFALSE;
+      val = (*this)[idx].GetPedErr()/2.;
       break;
     case 35:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
-      val = (*this)[idx].GetPed();
+      val = (*this)[idx].GetAbsTimeMean();
       break;
     case 36:
-      if ((*this)[idx].IsExcluded())
-        return kFALSE;
-      val = (*this)[idx].GetPedErr();
-      break;
-    case 37:
-      if ((*this)[idx].IsExcluded())
-        return kFALSE;
-      val = (*this)[idx].GetPedRms();
-      break;
-    case 38:
-      if ((*this)[idx].IsExcluded())
-        return kFALSE;
-      val = (*this)[idx].GetPedErr()/2.;
-      break;
-    case 39:
-      if ((*this)[idx].IsExcluded())
-        return kFALSE;
-      val = (*this)[idx].GetAbsTimeMean();
-      break;
-    case 40:
       if ((*this)[idx].IsExcluded())
         return kFALSE;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3550)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3551)
@@ -20,7 +20,5 @@
 !   Copyright: MAGIC Software Development, 2000-2004
 !
-!
 \* ======================================================================== */
-
 /////////////////////////////////////////////////////////////////////////////
 //                                                                         //
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 3550)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 3551)
@@ -89,7 +89,7 @@
 const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr   = 0.002;
 
-const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        = 1400;
-const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -200.5;
-const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 1199.5;
+const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        = 5300;
+const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -100.5;
+const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 5199.5;
 
 const Float_t  MHCalibrationChargeBlindPix::fgSinglePheCut       = 200.;
@@ -116,4 +116,6 @@
     SetSinglePheCut();
     SetNumSinglePheLimit();
+
+    SetBinsAfterStripping(30);
 
     fHGausHist.SetName("HCalibrationChargeBlindPix");
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 3550)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 3551)
@@ -65,4 +65,6 @@
 #include <TCanvas.h>
 #include <TPad.h>
+#include <TText.h>
+#include <TPaveText.h>
 
 #include "MLog.h"
@@ -151,4 +153,16 @@
     fNumOuterPixels = 0; 
     fNumExcluded    = 0;
+
+    fAverageInnerSat            = 0;
+    fAverageOuterSat            = 0;  
+    fAverageInnerPixSigma       = 0.;
+    fAverageOuterPixSigma       = 0.;  
+    fAverageInnerPixSigmaErr    = 0.;
+    fAverageOuterPixSigmaErr    = 0.;  
+    fAverageInnerPixRelSigma    = 0.;
+    fAverageOuterPixRelSigma    = 0.;  
+    fAverageInnerPixRelSigmaErr = 0.;
+    fAverageOuterPixRelSigmaErr = 0.;  
+
 }
 
@@ -169,4 +183,5 @@
   delete fAverageHiGainOuterPix;
   delete fAverageLoGainOuterPix;
+
 }
 
@@ -542,13 +557,13 @@
     FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
 
-    fCam->GetAverageInnerPix()->SetSigmaCharge   (fCam->GetAverageInnerPix()->GetSigmaCharge()   
-                                                  *TMath::Sqrt((Float_t)fNumInnerPixels));
-    fCam->GetAverageOuterPix()->SetSigmaCharge   (fCam->GetAverageOuterPix()->GetSigmaCharge()   
-                                                  *TMath::Sqrt((Float_t)fNumOuterPixels));
-    fCam->GetAverageInnerPix()->SetSigmaChargeErr(fCam->GetAverageInnerPix()->GetSigmaChargeErr()
-                                                  *TMath::Sqrt((Float_t)fNumInnerPixels));
-    fCam->GetAverageOuterPix()->SetSigmaChargeErr(fCam->GetAverageOuterPix()->GetSigmaChargeErr()
-                                                  *TMath::Sqrt((Float_t)fNumOuterPixels));
-    
+    FinalizeAveragePix(*fCam->GetAverageInnerPix(),fNumInnerPixels, 
+                       fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
+                       fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr,
+                       fAverageInnerSat);
+    FinalizeAveragePix(*fCam->GetAverageOuterPix(),fNumOuterPixels, 
+                       fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
+                       fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr,
+                       fAverageOuterSat);
+
     return kTRUE;
 }
@@ -693,4 +708,30 @@
       }
 }    
+
+void MHCalibrationChargeCam::FinalizeAveragePix(MCalibrationChargePix &pix, Int_t npix, 
+                                                Float_t &sigma, Float_t &sigmaerr, 
+                                                Float_t &relsigma, Float_t &relsigmaerr, 
+                                                Bool_t &b)
+{
+
+  if (pix.IsHiGainSaturation())
+    b = kTRUE;
+
+  sigma    = pix.GetSigmaCharge    () * TMath::Sqrt((Float_t)npix);
+  sigmaerr = pix.GetSigmaChargeErr () * TMath::Sqrt((Float_t)npix);
+
+  relsigma     = sigma / pix.GetMeanCharge();
+
+  relsigmaerr  = sigmaerr*sigmaerr / sigma / sigma;
+  relsigmaerr += pix.GetMeanChargeErr()*pix.GetMeanChargeErr() / pix.GetMeanCharge() / pix.GetMeanCharge();
+
+  relsigmaerr *= relsigma;
+  relsigmaerr  = TMath::Sqrt(relsigmaerr);
+
+  pix.SetSigmaCharge   (sigma);
+  pix.SetSigmaChargeErr(sigmaerr);
+
+}
+
 
 Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
@@ -729,25 +770,69 @@
   pad->cd(1);
 
-  if (!fAverageHiGainInnerPix->IsEmpty())
-    gPad->SetLogy();
   fAverageHiGainInnerPix->Draw(opt);
+  
+  if (!fAverageInnerSat)
+    DrawAverageSigma(fAverageInnerSat, 1,
+                     fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
+                     fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr);
 
   pad->cd(2);
 
-  if (!fAverageLoGainInnerPix->IsEmpty())
-    gPad->SetLogy();
   fAverageLoGainInnerPix->Draw(opt);
 
+  if (fAverageInnerSat)
+    DrawAverageSigma(fAverageInnerSat, 1,
+                     fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
+                     fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr);
+
   pad->cd(3);
 
-  if (!fAverageHiGainOuterPix->IsEmpty())
-    gPad->SetLogy();
   fAverageHiGainOuterPix->Draw(opt);
 
+  if (!fAverageOuterSat)
+    DrawAverageSigma(fAverageOuterSat, 0,
+                     fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
+                     fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr);
+
   pad->cd(4);
 
-  if (!fAverageLoGainOuterPix->IsEmpty())
-    gPad->SetLogy();
   fAverageLoGainOuterPix->Draw(opt);
 
-}
+  if (fAverageOuterSat)
+    DrawAverageSigma(fAverageOuterSat, 0,
+                     fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
+                     fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr);
+}
+
+void MHCalibrationChargeCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
+                                              Float_t sigma, Float_t sigmaerr,
+                                              Float_t relsigma, Float_t relsigmaerr) const 
+{
+  
+  if (sigma != 0)
+    {
+      
+      TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
+      newpad->SetFillStyle(4000);
+      newpad->Draw();
+      newpad->cd();
+      
+      TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
+      text->SetTextSize(0.07);
+      const TString line1 = Form("%s%s%s",inner ? "Inner" : "Outer",
+                                 " Pixels ", sat ? "Low Gain" : "High Gain");
+      TText *txt1 = text->AddText(line1.Data());
+      const TString line2 = Form("Sigma per Pixel: %2.2f #pm %2.2f",sigma,sigmaerr);
+      TText *txt2 = text->AddText(line2.Data());
+      const TString line3 = Form("Rel. Sigma per Pixel: %2.2f #pm %2.2f",relsigma,relsigmaerr);
+      TText *txt3 = text->AddText(line3.Data());
+      text->Draw("");
+      
+      text->SetBit(kCanDelete);
+      txt1->SetBit(kCanDelete);
+      txt2->SetBit(kCanDelete);
+      txt3->SetBit(kCanDelete);
+      newpad->SetBit(kCanDelete);
+    }
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 3550)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 3551)
@@ -13,4 +13,5 @@
 #endif
 
+class TText;
 class MRawEvtData;
 class MGeomCam;
@@ -47,7 +48,29 @@
   Int_t fNumExcluded;
 
+  Bool_t  fAverageInnerSat;
+  Bool_t  fAverageOuterSat;  
+  
+  Float_t fAverageInnerPixSigma;
+  Float_t fAverageOuterPixSigma;  
+  
+  Float_t fAverageInnerPixSigmaErr;
+  Float_t fAverageOuterPixSigmaErr;  
+
+  Float_t fAverageInnerPixRelSigma;
+  Float_t fAverageOuterPixRelSigma;  
+  
+  Float_t fAverageInnerPixRelSigmaErr;
+  Float_t fAverageOuterPixRelSigmaErr;  
+
   void FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
   void FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
-
+  void FinalizeAveragePix (MCalibrationChargePix &pix, Int_t npix,
+                           Float_t &sigma, Float_t &sigmaerr,
+                           Float_t &relsigma, Float_t &relsigmaerr, 
+                           Bool_t &b);
+  void DrawAverageSigma(Bool_t sat, Bool_t inner,
+                        Float_t sigma, Float_t sigmaerr,
+                        Float_t relsigma, Float_t relsigmaerr) const; 
+  
 public:
 
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3550)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3551)
@@ -211,4 +211,12 @@
   gPad->SetTicks();
 
+  fHGausHist.GetXaxis()->SetLabelSize(0.06);
+  fHGausHist.GetYaxis()->SetLabelSize(0.07);
+  fHGausHist.GetXaxis()->SetLabelOffset(0.01);
+  fHGausHist.GetYaxis()->SetLabelOffset(0.01);
+  fHGausHist.GetXaxis()->SetTitleSize(0.065);
+  fHGausHist.GetYaxis()->SetTitleSize(0.07);
+  fHGausHist.GetXaxis()->SetTitleOffset(0.6);
+  fHGausHist.GetYaxis()->SetTitleOffset(0.6);
   fHGausHist.Draw(opt); 
   if (fFGausFit)
@@ -220,4 +228,13 @@
   pad->cd(2);
   gPad->SetTicks();
+
+  fHAbsTime.GetXaxis()->SetLabelSize(0.06);
+  fHAbsTime.GetYaxis()->SetLabelSize(0.07);
+  fHAbsTime.GetXaxis()->SetLabelOffset(0.01);
+  fHAbsTime.GetYaxis()->SetLabelOffset(0.01);
+  fHAbsTime.GetXaxis()->SetTitleSize(0.065);
+  fHAbsTime.GetYaxis()->SetTitleSize(0.07);
+  fHAbsTime.GetXaxis()->SetTitleOffset(0.6);
+  fHAbsTime.GetYaxis()->SetTitleOffset(0.6);
   fHAbsTime.Draw(opt);
 
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3550)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3551)
@@ -594,36 +594,36 @@
 TProfile *MHCamera::RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name, const Int_t nbins) const
 {
-
-    // Create the projection histogram
-    TString pname(name);
-    if (name=="_rad")
-    {
-        pname.Prepend(GetName());
-        if (sector.GetSize()>0)
+  
+  // Create the projection histogram
+  TString pname(name);
+  if (name=="_rad")
+    {
+      pname.Prepend(GetName());
+      if (sector.GetSize()>0)
         {
-            pname += ";";
-            for (int i=0; i<sector.GetSize(); i++)
-                pname += sector[i];
+          pname += ";";
+          for (int i=0; i<sector.GetSize(); i++)
+            pname += sector[i];
         }
-        if (aidx.GetSize()>0)
+      if (aidx.GetSize()>0)
         {
-            pname += ";";
-            for (int i=0; i<aidx.GetSize(); i++)
-                pname += aidx[i];
+          pname += ";";
+          for (int i=0; i<aidx.GetSize(); i++)
+            pname += aidx[i];
         }
     }
-
-    TProfile *h1=0;
-
-    //check if histogram with identical name exist
-    TObject *h1obj = gROOT->FindObject(pname);
-    if (h1obj && h1obj->InheritsFrom("TProfile")) {
-        h1 = (TProfile*)h1obj;
-        h1->Reset();
-    }
-
-    if (!h1)
-    {
-
+  
+  TProfile *h1=0;
+  
+  //check if histogram with identical name exist
+  TObject *h1obj = gROOT->FindObject(pname);
+  if (h1obj && h1obj->InheritsFrom("TProfile")) {
+    h1 = (TProfile*)h1obj;
+    h1->Reset();
+  }
+  
+  if (!h1)
+    {
+      
       Double_t min = 0.;
       Double_t max = fGeomCam->GetMaxRadius();
@@ -638,11 +638,11 @@
       h1->SetYTitle(GetYaxis()->GetTitle());
     }
-    
-    // Fill the projected histogram
-    for (Int_t idx=0; idx<fNcells-2; idx++)
-      if (IsUsed(idx) && MatchSector(idx, sector, aidx))
-        h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()),
-                 GetBinContent(idx+1));
-    return h1;
+  
+  // Fill the projected histogram
+  for (Int_t idx=0; idx<fNcells-2; idx++)
+    if (IsUsed(idx) && MatchSector(idx, sector, aidx))
+      h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()),
+               GetBinContent(idx+1));
+  return h1;
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3550)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3551)
@@ -236,9 +236,9 @@
 
     TProfile *RadialProfile(const char *name="_rad") const { return  RadialProfileS(TArrayI(), TArrayI(), name);}
-    TProfile *RadialProfileS(Int_t sector, Int_t aidx, const char *name="_rad", const Int_t nbins=20) const
+    TProfile *RadialProfileS(Int_t sector, Int_t aidx, const char *name="_rad", const Int_t nbins=25) const
     {
         return RadialProfileS(TArrayI(1, &sector), TArrayI(1, &aidx), name, nbins);
     }
-    TProfile *RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=20) const;
+    TProfile *RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=25) const;
     
     const MGeomCam &GetGeomCam() const { return *fGeomCam; }
