Index: trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C	(revision 9221)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C	(revision 9225)
@@ -235,5 +235,5 @@
     if (impact < 0)
         imax = "NULL";
-    TString numphe    = Form("%5.1f", runheader3->GetNumPheFromDNSB());
+    TString numphe    = Form("%7.3f", runheader3->GetNumPheFromDNSB());
     TString pmin      = Form("%5.1f", runheader3->GetShowerPhiMin());
     TString pmax      = Form("%5.1f", runheader3->GetShowerPhiMax());
@@ -600,5 +600,5 @@
                  "fReflectorVersionKEY=%d, fCameraVersionKEY=%d, "
                  "fObservationModeKEY=%d, fMCParticleKEY=%d, "
-                 "fSequenceFirst=0, fNumTriggers=%d, fNumSumTriggers=%d, fViewconeAngleInner=%5.2f, fViewconeAngleOuter=%5.2f, "
+                 "fNumTriggers=%d, fNumSumTriggers=%d, fViewconeAngleInner=%5.2f, fViewconeAngleOuter=%5.2f, "
                  "fAtmosphericModelKEY=%d, fAmplFadcKEY=%d, fAddSpotSizeKEY=%d, "
                  "fPSFKEY=%d, fViewconeAngleOKEY=%d, fSpectrumKEY=%d, fTriggerFlagKEY=%d ",
@@ -613,6 +613,6 @@
 
         TString vars2 =
-            Form("fRunFilled=Now(), fFileName=\"%s\", fRunNumber=%d ",
-                 fname.Data(), RunNum);
+            Form("fRunFilled=Now(), fFileName=\"%s\", fRunNumber=%d, fPriority=%d ",
+                 fname.Data(), RunNum, RunNum);
 
 
@@ -670,5 +670,5 @@
                      "fReflectorVersionKEY=%d, fCameraVersionKEY=%d, "
                      "fObservationModeKEY=%d, fMCParticleKEY=%d, "
-                     "fSequenceFirst=0, fNumTriggers=%d, fNumSumTriggers=%d, fViewconeAngleInner=%5.2f, fViewconeAngleOuter=%5.2f, "
+                     "fNumTriggers=%d, fNumSumTriggers=%d, fViewconeAngleInner=%5.2f, fViewconeAngleOuter=%5.2f, "
                      "fAtmosphericModelKEY=%d, fAmplFadcKEY=%d, fAddSpotSizeKEY=%d, "
                      "fPSFKEY=%d, fViewconeAngleOKEY=%d, fSpectrumKEY=%d, fTriggerFlagKEY=%d ",
@@ -683,6 +683,6 @@
 
             TString vars2 =
-                Form("fRunFilled=Now(), fFileName=\"%s\", fRunNumber=%d ",
-                     fname.Data(), RunNum);
+                Form("fRunFilled=Now(), fFileName=\"%s\", fRunNumber=%d, fPriority=%d ",
+                     fname.Data(), RunNum, RunNum);
 
 
Index: trunk/MagicSoft/Mars/datacenter/macros/fillmccalib.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillmccalib.C	(revision 9221)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillmccalib.C	(revision 9225)
@@ -61,5 +61,4 @@
 #include <iostream>
 
-#include <TEnv.h>
 #include <TRegexp.h>
 
@@ -141,5 +140,5 @@
     if (!h)
     {
-        cout << "WARNING - Could not find histogram HRelTimeHiGainArea0." << endl;
+        cout << "ERROR - Could not find histogram HRelTimeHiGainArea0." << endl;
         return 2;
     }
@@ -152,5 +151,5 @@
     if (!h)
     {
-        cout << "WARNING - Could not find histogram HRelTimeHiGainArea1." << endl;
+        cout << "ERROR - Could not find histogram HRelTimeHiGainArea1." << endl;
         return 2;
     }
@@ -163,5 +162,5 @@
     if (!c)
     {
-        cout << "WARNING - Could not find MHCamera TotalConv." << endl;
+        cout << "ERROR - Could not find MHCamera TotalConv." << endl;
         return 2;
     }
@@ -264,5 +263,5 @@
              " fConvFactorInner=%s, "
              " fConvFactorOuter=%s, "
-             " fRatioCalEvents=%s, "
+             " fRatioCalEvts=%s, "
              " fRelChargeRmsInner=%s, "
              " fRelChargeRmsOuter=%s, "
Index: trunk/MagicSoft/Mars/datacenter/macros/fillmcsignal.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillmcsignal.C	(revision 9221)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillmcsignal.C	(revision 9225)
@@ -60,5 +60,4 @@
 #include <iomanip>
 
-#include <TEnv.h>
 #include <TRegexp.h>
 
@@ -66,4 +65,5 @@
 #include <TGraph.h>
 #include <TSQLResult.h>
+#include <TSQLRow.h>
 
 #include "MSQLServer.h"
@@ -89,6 +89,6 @@
     }
 
-    Float_t meanextpul = -1;
-    Float_t rmsextpul  = -1;
+    TString meanextpulpos("NULL");
+    TString rmsextpulpos("NULL");
 
     MCalibrationPulseTimeCam *pt;
@@ -96,10 +96,14 @@
     if (pt)
     {
-        meanextpul = pt->GetAverageArea(0).GetHiGainMean();
-        rmsextpul  = pt->GetAverageArea(0).GetHiGainRms();
-
-        meanextpul = TMath::Nint(meanextpul*100)/100.;
-        rmsextpul  = TMath::Nint(rmsextpul*100)/100.;
-    }
+        Double_t meanextpul = pt->GetAverageArea(0).GetHiGainMean();
+        Double_t rmsextpul  = pt->GetAverageArea(0).GetHiGainRms();
+
+        if (meanextpul>=0 || rmsextpulpos>=0)
+        {
+            meanextpulpos.Form("%6.2f", meanextpul);
+            rmsextpulpos.Form("%6.2f", rmsextpul);
+        }
+    }
+
 
     MStatusArray arr;
@@ -113,5 +117,5 @@
     if (!cam)
     {
-        cout << "WARNING - Reading of PedRMS;avg failed." << endl;
+        cout << "ERROR - Reading of PedRMS;avg failed." << endl;
         return 2;
     }
@@ -121,5 +125,5 @@
     if (!pul)
     {
-        cout << "WARNING - Reading of PulsePos;avg failed." << endl;
+        cout << "ERROR - Reading of PulsePos;avg failed." << endl;
         return 2;
     }
@@ -136,10 +140,4 @@
         return 2;
     }
-
-    Double_t medoff;
-    Double_t devoff;
-
-    Double_t medcal;
-    Double_t devcal;
 
     TString medpuloff("NULL");
@@ -148,28 +146,47 @@
     TString devhilocal("NULL");
 
-    MHCamera *hilooff = (MHCamera*)arr.FindObjectInCanvas("HiLoOff;avg", "MHCamera", "HiLoOff");
-    if (!hilooff)
-    {
-        cout << "WARNING - Reading of HiLoOff failed." << endl;
-        return 2;
-    }
-
-    MHCamera *hilocal = (MHCamera*)arr.FindObjectInCanvas("HiLoCal;avg", "MHCamera", "HiLoCal");
-    if (!hilocal)
-    {
-        cout << "WARNING - Reading of HiLoCal failed." << endl;
-        return 2;
-    }
-
-    medoff = TMath::Nint(hilooff->GetMedian()*10000)/10000.;
-    devoff = TMath::Nint(hilooff->GetDev()   *10000)/10000.;
-
-    medcal = TMath::Nint(hilocal->GetMedian()*100)/100.;
-    devcal = TMath::Nint(hilocal->GetDev()   *100)/100.;
-
-    medpuloff.Form("%7.4f", medoff);
-    devpuloff.Form("%7.4f", devoff);
-    medhilocal.Form("%6.2f", medcal);
-    devhilocal.Form("%6.2f", devcal);
+    TString query(Form("SELECT MCSequences.fAmplFadcKEY FROM MCSequences LEFT JOIN "
+                       "AmplFadc on MCSequences.fAmplFadcKEY=AmplFadc.fAmplFadcKEY "
+                       "where fSequenceFirst=%d;",seq.GetSequence()));
+
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+    {
+        cout << "ERROR - Query failed: " << query << endl;
+        return 2;
+    }
+
+    TSQLRow *row = res->Next();
+    if (!row)
+    {
+        cout << "ERROR - Query failed: " << query << endl;
+        return 2;
+    }
+    TString epochkey  = (*row)[0];
+    Int_t epoch = atoi(epochkey.Data());
+
+    delete res;
+
+    if (epoch!=1)
+    {
+        MHCamera *hilooff = (MHCamera*)arr.FindObjectInCanvas("HiLoOff;avg", "MHCamera", "HiLoOff");
+        if (!hilooff)
+        {
+            cout << "ERROR - Reading of HiLoOff failed." << endl;
+            return 2;
+        }
+
+        MHCamera *hilocal = (MHCamera*)arr.FindObjectInCanvas("HiLoCal;avg", "MHCamera", "HiLoCal");
+        if (!hilocal)
+        {
+            cout << "ERROR - Reading of HiLoCal failed." << endl;
+            return 2;
+        }
+
+        medpuloff.Form("%7.4f",  hilooff->GetMedian());
+        devpuloff.Form("%7.4f",  hilooff->GetDev());
+        medhilocal.Form("%6.2f", hilocal->GetMedian());
+        devhilocal.Form("%6.2f", hilocal->GetDev());
+    }
 
     TArrayI inner(1);
@@ -186,5 +203,5 @@
     if (meanrmsi<0 || meanrmso<0)
     {
-        cout << "WARNING - MeanPedRMS inner or outer < 0 " << endl;
+        cout << "ERROR - MeanPedRMS inner or outer < 0 " << endl;
         cout << "MeanPedRMS inner " << meanrmsi << endl;
         cout << "MeanPedRMS outer " << meanrmso << endl;
@@ -192,11 +209,11 @@
     }
 
-    meanrmsi = TMath::Nint(meanrmsi*100)/100.;
-    meanrmso = TMath::Nint(meanrmso*100)/100.;
+    TString meanrmsinner=Form("%6.2f", meanrmsi);
+    TString meanrmsouter=Form("%6.2f", meanrmso);
 
     cam = (MHCamera*)arr.FindObjectInCanvas("Interp'd;avg", "MHCamera", "Interp'd");
     if (!cam)
     {
-        cout << "WARNING - Reading of Interp'd;avg failed." << endl;
+        cout << "ERROR - Reading of Interp'd;avg failed." << endl;
         return 2;
     }
@@ -207,5 +224,5 @@
     if (meansigi<0 || meansigo<0)
     {
-        cout << "WARNING - MeanInterp'd inner or outer < 0 " << endl;
+        cout << "ERROR - MeanInterp'd inner or outer < 0 " << endl;
         cout << "MeanInterp'd inner " << meansigi << endl;
         cout << "MeanInterp'd outer " << meansigo << endl;
@@ -213,27 +230,24 @@
     }
 
-    meansigi = TMath::Nint(meansigi*100)/100.;
-    meansigo = TMath::Nint(meansigo*100)/100.;
+    TString meansiginner =Form("%6.2f", meansigi);
+    TString meansigouter =Form("%6.2f", meansigo);
 
     TString calpos = cal ? Form("%5.1f", cal->GetMean()) : "NULL";
 
-    Stat_t meanpul = pul->GetMean();
-    Stat_t rmspul  = pul->GetRMS();
-
-    if (meanpul<0 || rmspul<0)
-    {
-        cout << "WARNING - PulsePos'd mean or rms < 0 " << endl;
-        cout << "PulsePos'd mean " << meanpul << endl;
-        cout << "PulsePos'd rms  " << rmspul << endl;
-        return 2;
-    }
-
-    meanpul = TMath::Nint(meanpul*100)/100.;
-    rmspul  = TMath::Nint(rmspul *100)/100.;
+    if (pul->GetMean()<0 || pul->GetRMS()<0)
+    {
+        cout << "ERROR - PulsePos'd mean or rms < 0 " << endl;
+        cout << "PulsePos'd mean " << pul->GetMean() << endl;
+        cout << "PulsePos'd rms  " << pul->GetRMS() << endl;
+        return 2;
+    }
+
+    TString meanpulpos = Form("%6.2f", pul->GetMean());
+    TString rmspulpos  = Form("%6.2f", pul->GetRMS());
 
     cam = (MHCamera*)arr.FindObjectInCanvas("Unsuitable;avg", "MHCamera", "Unsuitable");
     if (!cam)
     {
-        cout << "WARNING - Reading of Unsuitable;avg failed." << endl;
+        cout << "ERROR - Reading of Unsuitable;avg failed." << endl;
         return 2;
     }
@@ -242,23 +256,5 @@
     Int_t unsuitable01 = cam->GetNumBinsAboveThreshold(0.01);
 
-    TString meanrmsinner =Form("%6.2f", meanrmsi);
-    TString meanrmsouter =Form("%6.2f", meanrmso);
-    TString meansiginner =Form("%6.2f", meansigi);
-    TString meansigouter =Form("%6.2f", meansigo);
-    TString meanpulpos   =Form("%6.2f", meanpul);
-    TString rmspulpos    =Form("%6.2f", rmspul);
-    TString meanextpulpos=Form("%6.2f", meanextpul);
-    TString rmsextpulpos =Form("%6.2f", rmsextpul);
-
-    if (meanextpul<0 && rmsextpul<0)
-    {
-        meanextpulpos = "NULL";
-        rmsextpulpos  = "NULL";
-    }
-
     // *****************************************************
-
-    // *****************************************************
-
 
     cout << "Sequence #" << seq.GetSequence() << endl;
