Index: /trunk/FACT++/src/getevent.cc
===================================================================
--- /trunk/FACT++/src/getevent.cc	(revision 17819)
+++ /trunk/FACT++/src/getevent.cc	(revision 17820)
@@ -32,5 +32,5 @@
     control.add_options()
         ("target,t", var<string>()->required(),  "")
-        ("event,e",  var<uint32_t>()->required(), "")
+        ("event,e",  var<uint32_t>(), "")
         ;
 
@@ -161,5 +161,5 @@
     }
 */
-    const uint32_t event = conf.Get<uint32_t>("event");
+    const uint32_t event = conf.Has("event") ? conf.Get<uint32_t>("event") : 0;
 
     zfits file(name);
@@ -176,16 +176,23 @@
     const uint32_t nPix = file.GetUInt("NPIX");
 
-    const double start = file.GetUInt("TSTARTI")+file.GetFloat("TSTARTF");
-    const double stop  = file.GetUInt("TSTOPI")+file.GetFloat("TSTOPF");
-
-    const bool     isDrsCalib = file.GetStr("DRSCALIB")=="T";
-    const int16_t  drsStep    = isDrsCalib ? file.GetUInt("DRSSTEP") : -1;
-    const string   runType    = file.GetStr("RUNTYPE");
-    const uint16_t scale      = file.HasKey("SCALE") ? file.GetUInt("SCALE") : 0;
-
-    vector<char> run(80);
-    strncpy(run.data(), runType.c_str(), 79);
-
+    const bool     isMC = file.HasKey("ISMC") && file.GetStr("ISMC")=="T";
+
+    // Is drs calibration file?
+    const int8_t step = file.HasKey("STEP") ? file.GetUInt("STEP") : -1;
+
+    const string strbeg = isMC ? "DATE" : "RUN"+to_string(step)+"-BEG";
+    const string strend = isMC ? "DATE" : "RUN"+to_string(step)+"-END";
+
+    const double start = step==-1 && !isMC ? file.GetUInt("TSTARTI")+file.GetFloat("TSTARTF") : Time(file.GetStr(strbeg)).UnixDate();
+    const double stop  = step==-1 && !isMC ? file.GetUInt("TSTOPI")+file.GetFloat("TSTOPF")   : Time(file.GetStr(strend)).UnixDate();
+
+    const bool     isDrsCalib = file.HasKey("DRSCALIB") &&  file.GetStr("DRSCALIB")=="T";
+    const int16_t  drsStep    = isDrsCalib ? file.GetUInt("DRSSTEP") : step;
+    const string   runType    = step==-1 ? file.GetStr("RUNTYPE") : "";
+    const uint16_t scale      = file.HasKey("SCALE") ? file.GetUInt("SCALE") : (step==-1?0:10);
+
+    vector<char>     run(80);
     vector<int16_t>  data(nRoi*nPix);
+    vector<float>    mean(nRoi*nPix);
     vector<uint32_t> unixTimeUTC(2);
 
@@ -198,12 +205,27 @@
     uint16_t triggerType;
 
-    file.SetRefAddress("EventNum", eventNum);
-    //file.SetRefAddress("TriggerNum", triggerNum);
-    file.SetRefAddress("TriggerType", triggerType);
-    file.SetVecAddress("UnixTimeUTC", unixTimeUTC);
-    file.SetVecAddress("Data", data);
-
-    if (!file.GetRow(event))
+    if (step==-1)
+    {
+        file.SetRefAddress("EventNum", eventNum);
+        //file.SetRefAddress("TriggerNum", triggerNum);
+        file.SetRefAddress("TriggerType", triggerType);
+        if (!isMC)
+            file.SetVecAddress("UnixTimeUTC", unixTimeUTC);
+    }
+
+    switch (step)
+    {
+    case 0:  file.SetVecAddress("BaselineMean",      mean); strcpy( run.data(), "DRS (pedestal 1024)"); break;
+    case 1:  file.SetVecAddress("GainMean",          mean); strcpy( run.data(), "DRS (gain)");          break;
+    case 2:  file.SetVecAddress("TriggerOffsetMean", mean); strcpy( run.data(), "DRS (pedestal roi)");  break;
+    default: file.SetVecAddress("Data",              data); strncpy(run.data(), runType.c_str(), 79);   break;
+    }
+
+    if (!file.GetRow(step==-1 ? event : 0))
         return 2;
+
+    if (step!=-1)
+        for (uint32_t i=0; i<nRoi*nPix; i++)
+            data[i] = round(mean[i]*10);
 
     cout.write(run.data(),                80);
