Index: trunk/MagicSoft/Mars/macros/readCalibration.C
===================================================================
--- trunk/MagicSoft/Mars/macros/readCalibration.C	(revision 6606)
+++ trunk/MagicSoft/Mars/macros/readCalibration.C	(revision 6607)
@@ -35,46 +35,20 @@
 static const TString inpath = ".";
 //
-// Tell if you want to calibrate times:
-//
-static const  Bool_t useTimes = kTRUE;
-//
-// the default pedestal run for the calibration
-//
-static const Int_t   pedrun = 26210;
-//
 // the default start calibration run 
 //
 static const Int_t   calrun = 26209;
 //
-// A switch to output debugging information about Objects use
-//
-static const Bool_t debug = kFALSE;
-//
 // Tell if you want to use the display:
 //
-static Bool_t useDisplay = kTRUE;
+static Bool_t useDisplay = kFALSE;
 //
-void readCalibration(const Int_t prun=pedrun, const Int_t crun=calrun)
+void readCalibration(const Int_t crun=calrun)
 {
 
-  const TString pedname  = Form("%s/%i-F0.root", (const char*)inpath,prun);
-  const TString calname  = Form("%s/%i-F1.root", (const char*)inpath,crun);
-  const TString testname = Form("%s/%i-Test.root", (const char*)inpath,crun);
-
-  if (gSystem->AccessPathName(pedname, kFileExists))
-    {
-      cout << "Input file " << pedname << " doesn't exist." << endl;
-      return;
-    }
+  const TString calname  = Form("%s/calib%08d.root", (const char*)inpath,crun);
 
   if (gSystem->AccessPathName(calname, kFileExists))
     {
       cout << "Input file " << calname << " doesn't exist." << endl;
-      return;
-    }
-
-  if (gSystem->AccessPathName(testname, kFileExists))
-    {
-      cout << "Input file " << testname << " doesn't exist." << endl;
       return;
     }
@@ -85,28 +59,10 @@
     display = new MStatusDisplay;
 
+  MPedestalCam                 pedcam;
+  MCalibrationChargeCam        chargecam;  
+  MCalibrationQECam            qecam;
+  MCalibrationRelTimeCam       relcam;
+  MBadPixelsCam                badcam;
 
-  MPedestalCam             pedcam;
-  MCalibrationChargeCam    chargecam;  
-  MCalibrationQECam        qecam;
-  MCalibrationRelTimeCam   reltimecam;
-  MBadPixelsCam            badcam;
-  MHCalibrationTestCam     testcam;
-  MHCalibrationTestTimeCam testtime;
-
-  cout << "Reading from file: " << pedname << endl;
-
-  TFile pedfile(pedname, "READ");
-  if (pedcam.Read()<=0)
-    {
-      cout << "Unable to read MPedestalCam from " << pedname << endl;
-      return;
-    }
-  
-  if (useDisplay)
-    {
-      if (display->GetCanvas("Pedestals"))
-        display->Read();
-    }
-  
   cout << "Reading from file: " << calname << endl;
 
@@ -117,5 +73,4 @@
       return;
     }
-
   if (qecam.Read()<=0)
     {
@@ -124,11 +79,5 @@
     }
 
-    if (reltimecam.Read()<=0)
-    {
-      cout << "Unable to read MCalibrationRelTimeCam from " << calname << endl;
-      return;
-    }
-    
-    if (calfile.FindKey("MBadPixelsCam"))
+  if (calfile.FindKey("MBadPixelsCam"))
       {
         MBadPixelsCam bad;
@@ -140,50 +89,38 @@
         badcam.Merge(bad);
       }
+  if (relcam.Read()<=0)
+    {
+      cout << "Unable to read MCalibrationRelTimeCam from " << calname << endl;
+      return;
+    }
+
+  cout << "Size of QECam: "      << qecam.GetSize() << endl;
+  cout << "Size of BlindCam: "   << blindcam.GetSize() << endl;
+  cout << "Size of Chargecam: "  << chargecam.GetSize() << endl;
+  cout << "Size of RelTimeCam: "  << relcam.GetSize() << endl;
+
+   MGeomCamMagic geom;
 
   if (useDisplay)
     display->Read();
-    
-  cout << "Reading from file: " << testname << endl;
+  
+  for (Int_t i=0; i<relcam.GetSize(); i++)
+  {
+      MCalibrationRelTimePix &rpix = (MCalibrationRelTimePix&)relcam[i];
+      cout << "Number of outliers in time pixel: " << i << ": " << rpix.GetNumPickup()+rpix.GetNumBlackout() << endl;
+  } 
 
-  TFile testfile(testname, "READ");
-  if (testcam.Read()<=0)
+  for (Int_t i=0; i<2; i++)
+  {  
+      TArrayF conv = chargecam.GetAveragedConvFADC2PhotPerArea(geom,qecam,i,&badcam);
+      cout << "Average Conv Factor Area idx: " << i << ":  " << conv[0] << "+-" << conv[1] << endl;
+  }
+
+  for (Int_t i=0; i<qecam.GetSize(); i++)
     {
-      cout << "Unable to read MHCalibrationTestCam from " << testname << endl;
-      return;
+      MCalibrationChargePix &cpix = (MCalibrationChargePix&)chargecam[i];
+      MCalibrationQEPix     &qpix = (MCalibrationQEPix&)    qecam[i];
+      cout << "Conversion Factor: " << cpix.GetMeanConvFADC2Phe() / qpix.GetQECascadesFFactor() << endl;
     }
-  if (testtime.Read()<=0)
-    {
-      cout << "Unable to read MHCalibrationTestTimeCam from " << testname << endl;
-      return;
-    }
-  
-  if (useDisplay)
-    display->Read();
-
-  //
-  // List of interesting plots:
-  // 
-/*
-  testcam.GetAverageHiGainArea(0).DrawClone();
-  testcam.GetAverageLoGainArea(0).DrawClone();
-  testcam.GetAverageHiGainArea(1).DrawClone();
-  testcam.GetAverageLoGainArea(1).DrawClone();
-
-  testcam.GetAverageHiGainSector(1).DrawClone();
-  testcam.GetAverageLoGainSector(1).DrawClone();
-  testcam.GetAverageHiGainSector(2).DrawClone();
-  testcam.GetAverageLoGainSector(2).DrawClone();
-  testcam.GetAverageHiGainSector(3).DrawClone();
-  testcam.GetAverageLoGainSector(3).DrawClone();
-  testcam.GetAverageHiGainSector(4).DrawClone();
-  testcam.GetAverageLoGainSector(4).DrawClone();
-  testcam.GetAverageHiGainSector(5).DrawClone();
-  testcam.GetAverageLoGainSector(5).DrawClone();
-  testcam.GetAverageHiGainSector(6).DrawClone();
-  testcam.GetAverageLoGainSector(6).DrawClone();
-*/
-
-
-
 
 }
