Index: trunk/MagicSoft/Mars/mmain/MEventDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 4702)
+++ trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 4714)
@@ -33,4 +33,5 @@
 //
 #include <TFile.h>               // TFile
+#include <TTree.h>               // TTree
 #include <TList.h>               // TList::Add
 #include <TStyle.h>              // gStyle->SetOptStat
@@ -51,4 +52,7 @@
 //
 #include "MGList.h"              // MGList
+
+#include "MLog.h"
+#include "MLogManip.h"
 
 #include "MParList.h"            // MParList::AddToList
@@ -93,4 +97,6 @@
 #include "MMcTriggerLvl2.h"        // MMcTriggerLvl2
 
+using namespace std;
+
 ClassImp(MEventDisplay);
 
@@ -135,4 +141,20 @@
 }
 
+Int_t MEventDisplay::GetFileType(const char *tree, const char *fname) const
+{
+    TFile f(fname, "READ");
+    TTree *t = (TTree*)f.Get(tree);
+    if (!t)
+        return -1;
+
+    if (t->FindBranch("MCerPhotEvt."))
+        return 1;
+
+    if (t->FindBranch("MRawEvtData."))
+        return 2;
+
+    return -2;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -148,42 +170,54 @@
     MBadPixelsCam *badpix = new MBadPixelsCam;
 
-    TFile file(pname, "READ");
-    if (!file.IsZombie())
-        pcam = new MPedPhotCam;
-    if (pcam)
+    const Int_t type = GetFileType(tname, fname);
+    switch (type)
     {
-        if (pcam->Read()<=0)
+    case  1: gLog << all << "Calibrated Data File detected..." << endl; break;
+    case  2: gLog << all << "Raw Data File detected..." << endl; break;
+    case -2: gLog << err << "File type unknown... abort." << endl; return;
+    case -1: gLog << err << "Tree " << tname << " not found... abort." << endl; return;
+    }
+
+    if (type==2)
+    {
+        TFile file(pname, "READ");
+        if (!file.IsZombie())
+            pcam = new MPedPhotCam;
+        if (pcam)
         {
-            delete pcam;
-            pcam = NULL;
+            if (pcam->Read()<=0)
+            {
+                delete pcam;
+                pcam = NULL;
+            }
+
+            if (file.FindKey("MBadPixelsCam"))
+            {
+                MBadPixelsCam bad;
+                if (bad.Read()>0)
+                    badpix->Merge(bad);
+            }
         }
-
-        if (file.FindKey("MBadPixelsCam"))
+        file.Close();
+        file.Open(cname, "READ");
+        if (!file.IsZombie())
+            ccam = new MCalibrationChargeCam;
+        if (ccam)
         {
-            MBadPixelsCam bad;
-            if (bad.Read()>0)
-                badpix->Merge(bad);
+            if (ccam->Read()<=0)
+            {
+                delete ccam;
+                ccam = NULL;
+            }
+
+            if (file.FindKey("MBadPixelsCam"))
+            {
+                MBadPixelsCam bad;
+                if (bad.Read()>0)
+                    badpix->Merge(bad);
+            }
         }
+        file.Close();
     }
-    file.Close();
-    file.Open(cname, "READ");
-    if (!file.IsZombie())
-        ccam = new MCalibrationChargeCam;
-    if (ccam)
-    {
-        if (ccam->Read()<=0)
-        {
-            delete ccam;
-            ccam = NULL;
-        }
-
-        if (file.FindKey("MBadPixelsCam"))
-        {
-            MBadPixelsCam bad;
-            if (bad.Read()>0)
-                badpix->Merge(bad);
-        }
-    }
-    file.Close();
 
     //
@@ -265,51 +299,54 @@
 
     // If no pedestal or no calibration file is availble
-    if (!pcam || !ccam)
+    if (type==2)
     {
-        MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
-        MFilter *f2=new MFDataMember("MRawRunHeader.fRunType", '<', 255.5);
-        f1->SetName("MFMonteCarlo");
-        f2->SetName("MFRealData");
-
-        MMcPedestalCopy   *pcopy = new MMcPedestalCopy;
-        MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
-
-        MExtractSignal* extra = new MExtractSignal();
-	extra->SetRange(0, 14, 0, 14);
-	extra->SetSaturationLimit(240);
-
-        MMcCalibrationUpdate* mcupd = new MMcCalibrationUpdate;
-        mcupd->SetOuterPixelsGainScaling(kFALSE);
-
-        MCalibrate* mccal = new MCalibrate;
-        mccal->SetCalibrationMode(MCalibrate::kFfactor);
-
-        // MC
-        extra->SetFilter(f1);
-        mcupd->SetFilter(f1);
-        mccal->SetFilter(f1);
-        trcal->SetFilter(f1);
-        //fill09->SetFilter(f1);
-
-        // Data
-        nanal->SetFilter(f2);
-
-        // TaskList
-        tlist->AddToList(f1);
-        tlist->AddToList(f2);
-        tlist->AddToList(pcopy);
-        tlist->AddToList(pdnsb);
-
-        tlist->AddToList(extra);
-        tlist->AddToList(mcupd);
-        tlist->AddToList(mccal);
-
-  
-	tlist->AddToList(nanal);
-    }
-    else
-    {
-        MCalibrate* calib = new MCalibrate;
-        tlist->AddToList(calib);
+        if (!pcam || !ccam)
+        {
+            MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
+            MFilter *f2=new MFDataMember("MRawRunHeader.fRunType", '<', 255.5);
+            f1->SetName("MFMonteCarlo");
+            f2->SetName("MFRealData");
+
+            MMcPedestalCopy   *pcopy = new MMcPedestalCopy;
+            MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
+
+            MExtractSignal* extra = new MExtractSignal();
+            extra->SetRange(0, 14, 0, 14);
+            extra->SetSaturationLimit(240);
+
+            MMcCalibrationUpdate* mcupd = new MMcCalibrationUpdate;
+            mcupd->SetOuterPixelsGainScaling(kFALSE);
+
+            MCalibrate* mccal = new MCalibrate;
+            mccal->SetCalibrationMode(MCalibrate::kFfactor);
+
+            // MC
+            extra->SetFilter(f1);
+            mcupd->SetFilter(f1);
+            mccal->SetFilter(f1);
+            trcal->SetFilter(f1);
+            //fill09->SetFilter(f1);
+
+            // Data
+            nanal->SetFilter(f2);
+
+            // TaskList
+            tlist->AddToList(f1);
+            tlist->AddToList(f2);
+            tlist->AddToList(pcopy);
+            tlist->AddToList(pdnsb);
+
+            tlist->AddToList(extra);
+            tlist->AddToList(mcupd);
+            tlist->AddToList(mccal);
+
+
+            tlist->AddToList(nanal);
+        }
+        else
+        {
+            MCalibrate* calib = new MCalibrate;
+            tlist->AddToList(calib);
+        }
     }
 
@@ -326,5 +363,5 @@
     tlist->AddToList(fill10);
 
-    if (!pcam || !ccam)
+    if ((!pcam || !ccam) && type==2)
     {
         MArrivalTimeCalc  *tcalc = new MArrivalTimeCalc;
@@ -337,4 +374,10 @@
 	tlist->AddToList(trcal);
 	tlist->AddToList(fill09);
+    }
+
+    if (type==1)
+    {
+        MFillH *fill08 = new MFillH(evt08, "MArrivalTime", "MFillH8");
+        tlist->AddToList(fill08);
     }
 
Index: trunk/MagicSoft/Mars/mmain/MEventDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MEventDisplay.h	(revision 4702)
+++ trunk/MagicSoft/Mars/mmain/MEventDisplay.h	(revision 4714)
@@ -44,4 +44,6 @@
     void ReadinEvent(Int_t dir=0);
 
+    Int_t GetFileType(const char *tree, const char *fname) const;
+
     Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
 
