Index: trunk/Mars/fact/plots/quality.C
===================================================================
--- trunk/Mars/fact/plots/quality.C	(revision 18249)
+++ trunk/Mars/fact/plots/quality.C	(revision 18258)
@@ -365,4 +365,109 @@
 
     gErrorIgnoreLevel = save;
+}
+
+Int_t PlotSqm(TArrayD **vec, TString fname)
+{
+    fname += ".SQM_CONTROL_DATA.fits";
+
+    fits file(fname.Data());
+    if (!file)
+    {
+        cerr << fname << ": " << gSystem->GetError() << endl;
+        return -2;
+    }
+
+    //cout << fname << endl;
+
+    Double_t time;
+    Float_t mag; // magnitude
+
+    if (!file.SetPtrAddress("Time",  &time))
+        return -1;
+    if (!file.SetPtrAddress("Mag",  &mag))
+        return -1;
+
+    //const int marker_style = kFullDotMedium;
+    const int marker_style = kDot;
+
+    TGraph g1;
+    g1.SetName("SQM");
+
+
+    bool found_first_time = false;
+    while (file.GetNextRow())
+        if (Contains(vec, time))
+        {
+            g1.SetPoint(g1.GetN(), time*24*3600, mag);
+        }
+
+
+    g1.SetMinimum(19.0);
+    g1.SetMaximum(21.5);
+    g1.SetMarkerColor(kBlack);
+    g1.SetMarkerStyle(marker_style);
+    g1.GetXaxis()->SetTimeDisplay(true);
+    g1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
+    g1.GetXaxis()->SetLabelSize(0.12);
+    g1.GetYaxis()->SetLabelSize(0.1);
+    g1.GetYaxis()->SetTitle("SQM [mag]");
+    g1.GetYaxis()->SetTitleOffset(0.2);
+    g1.GetYaxis()->SetTitleSize(0.1);
+    g1.DrawClone("AP");
+
+    return 0;
+}
+
+Int_t PlotSqmLinear(TArrayD **vec, TString fname)
+{
+    fname += ".SQM_CONTROL_DATA.fits";
+
+    fits file(fname.Data());
+    if (!file)
+    {
+        cerr << fname << ": " << gSystem->GetError() << endl;
+        return -2;
+    }
+
+    //cout << fname << endl;
+
+    Double_t time;
+    Float_t mag; // magnitude
+
+    if (!file.SetPtrAddress("Time",  &time))
+        return -1;
+    if (!file.SetPtrAddress("Mag",  &mag))
+        return -1;
+
+    //const int marker_style = kFullDotMedium;
+    const int marker_style = kDot;
+
+    TGraph g1;
+    g1.SetName("SQM");
+
+
+    bool found_first_time = false;
+    while (file.GetNextRow())
+        if (Contains(vec, time))
+        {
+            Double_t mag_double = 4.4 * pow(10, 20) * pow( 10, mag*(-0.4));
+            g1.SetPoint(g1.GetN(), time*24*3600, mag_double);
+        }
+
+
+    g1.SetMinimum(1.e12);
+    g1.SetMaximum(5.e12);
+    g1.SetMarkerColor(kBlack);
+    g1.SetMarkerStyle(marker_style);
+    g1.GetXaxis()->SetTimeDisplay(true);
+    g1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
+    g1.GetXaxis()->SetLabelSize(0.12);
+    g1.GetYaxis()->SetLabelSize(0.1);
+    g1.GetYaxis()->SetTitle("SQM lin [phot./(s sr m^2)]");
+    g1.GetYaxis()->SetTitleOffset(0.2);
+    g1.GetYaxis()->SetTitleSize(0.1);
+    g1.DrawClone("AP");
+
+    return 0;
 }
 
@@ -840,6 +945,6 @@
     }
 
-    TCanvas *c = new TCanvas("quality", Form("Quality %04d/%02d/%02d", y, m, d), 1280, 1120);
-    c->Divide(1, 7, 1e-5, 1e-5);
+    TCanvas *c = new TCanvas("quality", Form("Quality %04d/%02d/%02d", y, m, d), 1280, 1280);
+    c->Divide(1, 8, 1e-5, 1e-5);
 
     gROOT->SetSelectedPad(0);
@@ -897,4 +1002,5 @@
     gPad->SetGrid();
     gPad->SetTopMargin(0);
+    gPad->SetBottomMargin(0);
     gPad->SetRightMargin(0.001);
     gPad->SetLeftMargin(0.04);
@@ -902,4 +1008,13 @@
     cout << PlotHumidity2(runs, fname) << endl;
 
+    gROOT->SetSelectedPad(0);
+    c->cd(8);
+    gPad->SetGrid();
+    gPad->SetTopMargin(0);
+    gPad->SetRightMargin(0.001);
+    gPad->SetLeftMargin(0.04);
+    cout << PlotSqm(runs, fname) << endl;
+
+
     c->SaveAs(Form("%s/%04d%02d%02d.png", outpath, y, m, d));
 
