Changeset 8996


Ignore:
Timestamp:
07/05/08 20:01:55 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8994 r8996  
    1919                                                 -*-*- END OF LINE -*-*-
    2020
     21 2008/07/05 Thomas Bretz
     22
     23   * datacenter/macros/fillcamera.C, datacenter/macros/findcacofiles.C:
     24     - changed JOIN to use USING
     25     - removed dependence on TEnv
     26     - some improvement to includes
     27
     28   * datacenter/macros/filldotrbk.C, datacenter/macros/fillganymed.C,
     29     datacenter/macros/filloptical.C, datacenter/macros/fillsignal.C,
     30     datacenter/macros/fillsources.C, datacenter/macros/fillstar.C,
     31     datacenter/macros/getdolist.C, datacenter/macros/insertcacofile.C,
     32     datacenter/macros/insertdataset.C, datacenter/macros/plotoptical.C,
     33     datacenter/macros/plotrundb.C, datacenter/macros/plotstat.C,
     34     datacenter/macros/resetallruns.C,
     35     datacenter/macros/writedatasetfile.C:
     36     - removed dependence on TEnv
     37     - some improvement to includes
     38
     39   * datacenter/macros/filldotrun.C:
     40     - make it fail for everything except Magic 1
     41     - removed dependence on TEnv
     42     - some improvement to includes
     43
     44   * datacenter/macros/plotoptical.C:
     45     - removed MPlot, use MPlot from plotdb instead
     46
     47   * datacenter/macros/setstatus.C:
     48     - some improvement to includes
     49
     50   * mbase/MTime.[h,cc]:
     51     - added function returning day of sunrise as MTime
     52
     53   * mhflux/MHAlpha.cc:
     54     - use BinError instead of BinContents to decide whether the
     55       excess time is plotted or not
     56
     57   * mimage/MHHillas.cc:
     58     - changed title of "Center"
     59
     60   * mjobs/JobsLinkDef.h, mjobs/Makefile:
     61     - added new class MSequenceSQL
     62
     63   * mjobs/MSequenceSQL.[h,cc]:
     64     - added
     65
     66   * mjobs/MSequence.[h,cc]:
     67     - replaced ReadLightCondition by the more flexible GetLightCondition
     68     - added a new constrcutor constructing a MSequence from the database
     69     - fixed the output in the comments in Print()
     70     - The day and night was printed in a different format than
     71       expected when readin a sequence
     72     - fLightCondition and the f*RunsSub were missing in the copy-
     73       constructor
     74
     75   * mjobs/Makefile:
     76     - added include of msql
     77
     78   * msql/MSQLMagic.[h,cc]:
     79     - added a comment to ExistStr and allow to set an additional
     80       where-clause
     81
     82   * msql/MSQLServer.cc:
     83     - allow to init MSQLServer either by an url or from a named
     84       resource file
     85     - changed JOIN to use USING
     86     - if doing an automatic join join _all_ primaries
     87
     88   * mtools/MCalendar.cc:
     89     - added include of TObjArray needed in newer root versions
     90
     91
     92
    2193 2008/07/03 Thomas Bretz
    2294
     
    44116
    45117   * sponde.cc:
    46      - display only the base name of the ganymed file, not the full path
     118     - display only the base name of the ganymed file, not the
     119       full path
    47120
    48121   * mbase/MMath.[h,cc]:
  • trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C

    r8760 r8996  
    4747#include <iomanip>
    4848
    49 #include <TEnv.h>
    5049#include <TRegexp.h>
    5150#include <TObjectTable.h>
     
    656655//                        "where MCRunData.fRunNumber=%d;", RunNum));
    657656    TString query3(Form("SELECT fMCParticleName, fSpectrum FROM MCRunData "
    658                         "LEFT JOIN MCParticle ON MCRunData.fMCParticleKEY=MCParticle.fMCParticleKEY "
    659                         "LEFT JOIN Spectrum ON Spectrum.fSpectrumKEY=MCRunData.fSpectrumKEY "
     657                        "LEFT JOIN MCParticle USING (fMCParticleKEY) "
     658                        "LEFT JOIN Spectrum USING (fSpectrumKEY) "
    660659                        "WHERE MCRunData.fRunNumber=%d;", RunNum));
    661660    res = serv.Query(query3);
     
    773772int fillcamera(TString fname, Bool_t dummy=kTRUE)
    774773{
    775     TEnv env("sql.rc");
    776 
    777     MSQLMagic serv(env);
     774    MSQLMagic serv("sql.rc");
    778775    if (!serv.IsConnected())
    779776    {
     
    797794int fillcamera(TString path="/magic/montecarlo/camera", Bool_t dummy=kTRUE)
    798795{
    799     TEnv env("mcsql.rc");
    800 
    801     MSQLMagic serv(env);
     796    MSQLMagic serv("mcsql.rc");
    802797    if (!serv.IsConnected())
    803798    {
  • trunk/MagicSoft/Mars/datacenter/macros/filldotrbk.C

    r7460 r8996  
    6464#include <fstream>
    6565
    66 #include <TEnv.h>
    6766#include <TRegexp.h>
    6867
     
    206205int filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE)
    207206{
    208     TEnv env("sql.rc");
    209 
    210     MSQLServer serv(env);
     207    MSQLServer serv("sql.rc");
    211208    if (!serv.IsConnected())
    212209    {
  • trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C

    r8993 r8996  
    7979#include <fstream>
    8080
    81 #include <TEnv.h>
    8281#include <TMath.h>
    8382#include <TRegexp.h>
     
    148147            {
    149148                cout << "First character is not an M." << endl;
     149                cout << strng << endl;
     150                strng.ReadLine(fin);
     151                continue;
     152            }
     153            if (strng[1]!='1')
     154            {
     155                cout << "Only MAGIC 1 implemented so far." << endl;
    150156                cout << strng << endl;
    151157                strng.ReadLine(fin);
     
    580586int filldotrun(const TString path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE)
    581587{
    582     TEnv env("sql.rc");
    583 
    584     MSQLMagic serv(env);
     588    MSQLMagic serv("sql.rc");
    585589    if (!serv.IsConnected())
    586590    {
  • trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C

    r7777 r8996  
    5555#include <iomanip>
    5656
    57 #include <TEnv.h>
    5857#include <TRegexp.h>
    5958
     
    218217int fillganymed(TString fname, Bool_t dummy=kTRUE)
    219218{
    220     TEnv env("sql.rc");
    221 
    222     MSQLServer serv(env);
     219    MSQLServer serv("sql.rc");
    223220    if (!serv.IsConnected())
    224221    {
  • trunk/MagicSoft/Mars/datacenter/macros/filloptical.C

    r8404 r8996  
    4646#include <TVector3.h>
    4747
    48 #include <TEnv.h>
    4948#include <TRegexp.h>
    5049
     
    274273int filloptical(TString path, Bool_t dummy=kTRUE)
    275274{
    276     TEnv env("sql.rc");
    277 
    278     MSQLMagic serv(env);
     275    MSQLMagic serv("sql.rc");
    279276    if (!serv.IsConnected())
    280277    {
  • trunk/MagicSoft/Mars/datacenter/macros/fillsources.C

    r7518 r8996  
    3636#include <fstream>
    3737
    38 #include <TEnv.h>
    39 
    40 #include <MSQLServer.h>
    4138#include <TSQLRow.h>
    4239#include <TSQLResult.h>
     40
     41#include "MSQLServer.h"
    4342
    4443using namespace std;
     
    6766int fillsources(TString catalog)
    6867{
    69     TEnv env("sql.rc");
    70 
    71     MSQLServer serv(env);
     68    MSQLServer serv("sql.rc");
    7269    if (!serv.IsConnected())
    7370    {
  • trunk/MagicSoft/Mars/datacenter/macros/fillstar.C

    r8987 r8996  
    5959#include <iomanip>
    6060
    61 #include <TEnv.h>
    6261#include <TRegexp.h>
    6362
     
    310309int fillstar(TString fname, Bool_t dummy=kTRUE)
    311310{
    312     TEnv env("sql.rc");
    313 
    314     MSQLMagic serv(env);
     311    MSQLMagic serv("sql.rc");
    315312    if (!serv.IsConnected())
    316313    {
  • trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C

    r8482 r8996  
    5757#include <fstream>
    5858
    59 #include <TEnv.h>
    6059#include <TSystem.h>
    6160
    62 #include "MSQLMagic.h"
    6361#include <TSQLRow.h>
    6462#include <TSQLResult.h>
     63
     64#include "MSQLMagic.h"
    6565
    6666using namespace std;
     
    6969int findcacofiles()
    7070{
    71     TEnv env("sql.rc");
    72 
    73     MSQLMagic serv(env);
     71    MSQLMagic serv("sql.rc");
    7472    if (!serv.IsConnected())
    7573    {
     
    8785    query+=" DATE_FORMAT(ADDDATE(if(fRunStart='0000-00-00 00:00:00', fRunStop, fRunStart), INTERVAL +13 HOUR), '%Y/%m/%d') ";
    8886    query+=" FROM RunProcessStatus ";
    89     query+=" LEFT JOIN RunData ON RunData.fRunNumber=RunProcessStatus.fRunNumber ";
    90     query+=" LEFT JOIN Source ON RunData.fSourceKEY=Source.fSourceKEY ";
     87    query+=" LEFT JOIN RunData USING (fRunNumber) ";
     88    query+=" LEFT JOIN Source USING (fSourceKEY) ";
    9189    query+=" WHERE IsNull(fCaCoFileFound) AND fExcludedFDAKEY=1 ";
    9290    query+=" AND RunProcessStatus.fRunNumber > 10000 AND NOT IsNull(fCCFileAvail)";
     
    115113
    116114        query ="SELECT MAX(fCaCoFileFound) FROM RunProcessStatus ";
    117         query+=" LEFT JOIN RunData ON RunData.fRunNumber=RunProcessStatus.fRunNumber ";
     115        query+=" LEFT JOIN RunData USING (fRunNumber) ";
    118116        query+=Form("WHERE DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%%Y/%%m/%%d')='%s' ",
    119117                    (*row)[1]);
  • trunk/MagicSoft/Mars/datacenter/macros/getdolist.C

    r7501 r8996  
    6868#include <TSystem.h>
    6969
    70 #include <MSQLServer.h>
    7170#include <TSQLRow.h>
    7271#include <TSQLResult.h>
    7372
     73#include "MSQLServer.h"
     74
    7475using namespace std;
    7576
     
    7778int getdolist(TString table, TString column, TString date, TString listpath)
    7879{
    79     TEnv env("sql.rc");
    80 
    81     MSQLServer serv(env);
     80    MSQLServer serv("sql.rc");
    8281    if (!serv.IsConnected())
    8382    {
  • trunk/MagicSoft/Mars/datacenter/macros/insertcacofile.C

    r7460 r8996  
    5757#include <fstream>
    5858
    59 #include <TEnv.h>
    6059#include <TSystem.h>
    6160
    62 #include <MSQLServer.h>
    6361#include <TSQLRow.h>
    6462#include <TSQLResult.h>
     63
     64#include "MSQLServer.h"
    6565
    6666using namespace std;
     
    6868int insertcacofile(TString runnumber, TString newrunnumber)
    6969{
    70     TEnv env("sql.rc");
    71 
    72     MSQLServer serv(env);
     70    MSQLServer serv("sql.rc");
    7371    if (!serv.IsConnected())
    7472    {
  • trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C

    r8108 r8996  
    5454#include <iomanip>
    5555
    56 #include <TEnv.h>
    57 
    5856#include "MSQLMagic.h"
    5957
     
    6260int insertdataset(TString number, TString source, TString wobble, TString comment, Bool_t dummy=kTRUE)
    6361{
    64     TEnv env("sql.rc");
    65 
    66     MSQLMagic serv(env);
     62    MSQLMagic serv("sql.rc");
    6763    if (!serv.IsConnected())
    6864    {
  • trunk/MagicSoft/Mars/datacenter/macros/plotoptical.C

    r8752 r8996  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: plotoptical.C,v 1.8 2007-10-07 21:11:01 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: plotoptical.C,v 1.9 2008-07-05 19:01:42 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    7878//
    7979/////////////////////////////////////////////////////////////////////////////
    80 #include <iostream>
    81 #include <iomanip>
    82 
    83 #include <TH1.h>
    84 #include <TEnv.h>
    85 #include <TPad.h>
    86 #include <TLine.h>
    87 #include <TText.h>
    88 #include <TFrame.h>
    89 #include <TStyle.h>
    90 #include <TCanvas.h>
    91 #include <TPRegexp.h>
    92 #include <TSQLRow.h>
    93 #include <TSQLResult.h>
    94 #include <TGraphErrors.h>
    95 
    96 #include "MTime.h"
    97 #include "MAstro.h"
    98 #include "MDataSet.h"
    99 #include "MSQLMagic.h"
    100 #include "MStatusDisplay.h"
    101 
    102 class MPlot : public MParContainer
    103 {
    104 public:
    105     // Possible constants to group-by (average) over a certain period
    106     enum GroupBy_t
    107     {
    108         kNone,
    109         kGroupByPrimary,
    110         kGroupByHour,
    111         kGroupByNight,
    112         kGroupByWeek,
    113         kGroupByMonth,
    114         kGroupBySeason,
    115         kGroupByYear
    116     };
    117 
    118 private:
    119     MSQLMagic &fServer;         // Reference to the sql-server class
    120 
    121     MDataSet *fDataSet;         // A possible dtaset to highlite single points
    122 
    123     TString   fPrimaryDate;     // The name of the data we plot
    124     TString   fPrimaryNumber;   // The corresponding name for the key number
    125     TString   fSecondary;       // The value versus which the second plot is made
    126 
    127     TString   fRequestFrom;     // Start of a requested date range
    128     TString   fRequestTo;       // End of a requested date range
    129     Int_t     fRequestPeriod;   // A possible requested period
    130 
    131     Float_t   fPlotMin;
    132     Float_t   fPlotMax;
    133 
    134     Float_t   fHistMin;
    135     Float_t   fHistMax;
    136 
    137     TString   fDescription;     // The description (title) of the plot
    138     TString   fNameTab;         // The name of the tab in the display
    139 
    140     TString   fCondition;       // An additional condition added to the query
    141     GroupBy_t fGroupBy;         // A possible Group-By flag
    142 
    143     // --------------------------------------------------------------------------
    144     //
    145     // Function to plot the result of the query
    146     //
    147     void PlotTable(TSQLResult &res, TString name, Float_t fmin, Float_t fmax, Float_t resolution)
    148     {
    149         // Enable all otions in the statistics box
    150         gStyle->SetOptStat(111111);
    151 
    152         // Create TGraph objects
    153         TGraph &gt = res.GetFieldCount()>4 ? *new TGraphErrors : *new TGraph;
    154         gt.SetNameTitle(name, Form("%s vs Time", name.Data()));
    155         gt.SetMarkerStyle(kFullDotMedium);
    156 
    157         TGraph gz;
    158         gz.SetNameTitle(name, Form("%s vs <Zd>", name.Data()));
    159         gz.SetMarkerStyle(kFullDotMedium);
    160 
    161         TGraph gt0, gt1;
    162         gt0.SetMarkerColor(kRed);
    163         gt1.SetMarkerColor(kBlue);
    164         gt0.SetMarkerStyle(kFullDotLarge);
    165         gt1.SetMarkerStyle(kFullDotLarge);
    166 
    167         TGraph gz0, gz1;
    168         gz0.SetMarkerColor(kRed);
    169         gz1.SetMarkerColor(kBlue);
    170         gz0.SetMarkerStyle(kFullDotLarge);
    171         gz1.SetMarkerStyle(kFullDotLarge);
    172 
    173         Int_t first = -1;
    174         Int_t last  = -1;
    175 
    176         // Loop over the data
    177         TSQLRow *row=0;
    178         while ((row=res.Next()))
    179         {
    180             // Get all fields of this row
    181             const char *date = (*row)[0];
    182             const char *zd   = (*row)[1];
    183             const char *val  = (*row)[2];
    184             const char *snum = res.GetFieldCount()>3 ? (*row)[3] : 0;
    185             const char *verr = res.GetFieldCount()>4 ? (*row)[5] : 0;
    186 
    187             delete row;
    188 
    189             if (!date || !val || !zd)
    190                 continue;
    191 
    192             // check if date is valid
    193             MTime t(date);
    194             if (!t.SetSqlDateTime(date))
    195                 continue;
    196 
    197             // check if it belongs to the requested MAGIC period
    198             if (fRequestPeriod>0 && MAstro::GetMagicPeriod(t.GetMjd())!=fRequestPeriod)
    199                 continue;
    200 
    201             // Get axis range
    202             if (first<0)
    203                 first = TMath::Nint(TMath::Floor(t.GetMjd()));
    204             last = TMath::Nint(TMath::Ceil(t.GetMjd()));
    205 
    206             // Convert a possible key number into a integer
    207             UInt_t seq = snum ? atoi(snum) : 0;
    208 
    209             // convert primary and secondary value into floats
    210             Float_t value = atof(val);
    211             Float_t zenith = atof(zd);
    212 
    213             // If a datset is given add the point to the special TGraphs
    214             // used for highliting these dates
    215             if (fDataSet)
    216             {
    217                 if (fDataSet->HasOnSequence(seq))
    218                 {
    219                     gt1.SetPoint(gt1.GetN(), t.GetAxisTime(), value);
    220                     gz1.SetPoint(gz1.GetN(), zenith, value);
    221                 }
    222 
    223                 if (fDataSet->HasOffSequence(seq))
    224                 {
    225                     gt0.SetPoint(gt0.GetN(), t.GetAxisTime(), value);
    226                     gz0.SetPoint(gz0.GetN(), zenith, value);
    227                 }
    228             }
    229 
    230             // Add Data to TGraph
    231             gt.SetPoint(gt.GetN(), t.GetAxisTime(), value);
    232             gz.SetPoint(gz.GetN(), zenith, value);
    233 
    234             // Set error-bar, if one
    235             if (verr)
    236                 static_cast<TGraphErrors&>(gt).SetPointError(gt.GetN()-1, 0, atof(verr));
    237         }
    238 
    239         // If this is done earlier the plots remain empty since root 5.12/00
    240         if (fmax>fmin)
    241         {
    242             gt.SetMinimum(fmin);
    243             gt.SetMaximum(fmax);
    244             gz.SetMinimum(fmin);
    245             gz.SetMaximum(fmax);
    246         }
    247 
    248         gROOT->SetSelectedPad(0);
    249 
    250         // Create a TCanvas or open a new tab
    251         TString title = fNameTab.IsNull() ? name(name.First('.')+2, name.Length()) : fNameTab;
    252         TCanvas &c = fDisplay ? fDisplay->AddTab(title) : *new TCanvas;
    253         // Set fillcolor, remove border and divide pad
    254         c.SetFillColor(kWhite);
    255         c.SetBorderMode(0);
    256         c.Divide(1,2);
    257 
    258         // Output mean and rms to console
    259         cerr << setprecision(4) << setw(10) << title << ":   ";
    260         if (gt.GetN()==0)
    261         {
    262             cerr << "     <empty>" << endl;
    263             return;
    264         }
    265         cerr << setw(8) << gt.GetMean(2) << "+-" << setw(8) << gt.GetRMS(2) << "   ";
    266         if (gt0.GetN()>0 || gt1.GetN()>0)
    267         {
    268             cerr << setw(8) << gt1.GetMean(2) << "+-" << setw(8) << gt1.GetRMS(2) << "   ";
    269             cerr << setw(8) << gt0.GetMean(2) << "+-" << setw(8) << gt0.GetRMS(2);
    270         }
    271         cerr << endl;
    272 
    273         TVirtualPad *pad = gPad;
    274 
    275         // draw contants of pad 2 (counting starts at 0)
    276         pad->cd(2);
    277         gPad->SetBorderMode(0);
    278         gPad->SetFrameBorderMode(0);
    279         gPad->SetGridy();
    280 
    281         gPad->SetLeftMargin(0.06);
    282         gPad->SetRightMargin(0.06);
    283         gPad->SetBottomMargin(0.08);
    284 
    285         // format axis
    286         TH1 *h = gt.GetHistogram();
    287 
    288         h->SetXTitle("Time");
    289         h->SetYTitle(name);
    290         h->GetXaxis()->SetTimeDisplay(1);
    291         h->GetYaxis()->SetTitleOffset(0.8);
    292         h->GetXaxis()->SetTitleOffset(1.0);
    293         h->GetXaxis()->SetLabelOffset(0.01);
    294 
    295         // draw TGraph
    296         gt.DrawClone("AP");
    297         if (gt0.GetN()>0)
    298             gt0.DrawClone("P");
    299         if (gt1.GetN()>0)
    300             gt1.DrawClone("P");
    301 
    302         // Add lines and text showing the MAGIC periods
    303         TLine l;
    304         TText t;
    305         Int_t num=0;
    306         l.SetLineStyle(kDotted);
    307         l.SetLineColor(kBlue);
    308         t.SetTextColor(kBlue);
    309         l.SetLineWidth(1);
    310         t.SetTextSize(h->GetXaxis()->GetLabelSize());
    311         t.SetTextAlign(21);
    312         Int_t p0 = MAstro::GetMagicPeriod(first);
    313         for (Int_t p = first; p<last; p++)
    314         {
    315             Int_t p1 = MAstro::GetMagicPeriod(p);
    316             if (p1!=p0)
    317             {
    318                 l.DrawLine(MTime(p).GetAxisTime(), h->GetMinimum(), MTime(p).GetAxisTime(), h->GetMaximum());
    319                 t.DrawText(MTime(p+15).GetAxisTime(), h->GetMaximum(), Form("%d", p1));
    320                 num++;
    321             }
    322             p0 = p1;
    323         }
    324         if (num<4)
    325             gPad->SetGridx();
    326 
    327         const Double_t min = fHistMin>fHistMax ? h->GetMinimum()-resolution/2 : fHistMin;
    328         const Double_t max = fHistMin>fHistMax ? h->GetMaximum()+resolution/2 : fHistMax;
    329 
    330         // Use this to save the pad with the time development to a file
    331         //gPad->SaveAs(Form("plotdb-%s.eps", title.Data()));
    332 
    333         // Go back to first (upper) pad, format it and divide it again
    334         pad->cd(1);
    335         gPad->SetBorderMode(0);
    336         gPad->SetFrameBorderMode(0);
    337         gPad->Divide(2,1);
    338 
    339         TVirtualPad *pad2 = gPad;
    340 
    341         // format left pad
    342         pad2->cd(1);
    343         gPad->SetBorderMode(0);
    344         gPad->SetFrameBorderMode(0);
    345         gPad->SetGridx();
    346         gPad->SetGridy();
    347 
    348         // Create histogram
    349         const Int_t n = resolution>0 ? TMath::Nint((max-min)/resolution) : 50;
    350 
    351         TH1F hist("Hist", Form("Distribution of %s", fDescription.IsNull() ? name.Data() : fDescription.Data()), n, min, max);
    352         hist.SetDirectory(0);
    353 
    354         // Fill data into histogra,
    355         for (int i=0; i<gt.GetN(); i++)
    356             hist.Fill(gt.GetY()[i]);
    357 
    358         // Format histogram
    359         if (fDescription.IsNull())
    360             hist.SetXTitle(name);
    361         hist.SetYTitle("Counts");
    362 
    363         // plot histogram
    364         hist.DrawCopy("");
    365 
    366         // format right pad
    367         pad2->cd(2);
    368         gPad->SetBorderMode(0);
    369         gPad->SetFrameBorderMode(0);
    370         gPad->SetGridy();
    371 
    372         // format graph
    373         TH1 *h2 = gz.GetHistogram();
    374 
    375         h2->SetXTitle("Zd");
    376         h2->SetYTitle(name);
    377 
    378         // draw graph
    379         gz.DrawClone("AP");
    380 
    381         if (gz0.GetN()>0)
    382             gz0.DrawClone("P");
    383         if (gz1.GetN()>0)
    384             gz1.DrawClone("P");
    385     }
    386 
    387 public:
    388     MPlot(MSQLMagic &server) : fServer(server), fDataSet(NULL),
    389         fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1), fGroupBy(kNone)
    390     {
    391     }
    392     ~MPlot()
    393     {
    394         if (fDataSet)
    395             delete fDataSet;
    396     }
    397     void SetDataSet(const TString filename)
    398     {
    399         if (fDataSet)
    400         {
    401             delete fDataSet;
    402             fDataSet = NULL;
    403         }
    404         if (!filename.IsNull())
    405             fDataSet = new MDataSet(filename);
    406     }
    407     void SetPlotRange(Float_t min, Float_t max, Int_t n=5) { fPlotMin = min; fPlotMax = max; }
    408     void SetHistRange(Float_t min, Float_t max) { fHistMin = min; fHistMax = max; }
    409     void SetRequestRange(const char *from="", const char *to="") { fRequestFrom = from; fRequestTo = to; }
    410     void SetRequestPeriod(Int_t n=-1) { fRequestPeriod = n; }
    411     void SetCondition(const char *cond="") { fCondition = cond; }
    412     void SetDescription(const char *d, const char *t=0) { fDescription = d; fNameTab = t; }
    413     void SetGroupBy(GroupBy_t b=kGroupByWeek) { fGroupBy=b; }
    414     void SetPrimaryDate(const char *ts) { fPrimaryDate=ts; }
    415     void SetPrimaryNumber(const char *ts) { fPrimaryNumber=ts; }
    416     void SetSecondary(const char *ts) { fSecondary=ts; }
    417 
    418     Int_t QueryKeyOfSource(TString src)
    419     {
    420         return fServer.QueryKeyOfName("Object", src, kFALSE);
    421     }
    422 
    423     Bool_t Plot(const char *value, Float_t min=0, Float_t max=-1, Float_t resolution=0)
    424     {
    425         TString named  = fPrimaryDate;
    426         TString named2 = fSecondary;
    427         TString namev  = value;
    428 
    429         TString tablev = namev(0, namev.First('.'));
    430         TString valuev = namev(namev.First('.')+1, namev.Length());
    431 
    432         TString tabled = named(0, named.First('.'));
    433         TString valued = named(named.First('.')+1, named.Length());
    434 
    435         TString query="SELECT ";
    436         switch (fGroupBy)
    437         {
    438         case kNone:
    439         case kGroupByPrimary:
    440             query += Form("%s AS %s", valued.Data(), valued.Data()+1);
    441             break;
    442         case kGroupByHour:
    443             query += Form("DATE_FORMAT(%s, '%%Y-%%m-%%d %%H:30:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
    444             break;
    445         case kGroupByNight:
    446             query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-%%d 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
    447             break;
    448         case kGroupByWeek:
    449             query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%x%%v') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
    450             break;
    451         case kGroupByMonth:
    452             query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
    453             break;
    454         case kGroupBySeason:
    455             //query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
    456             break;
    457         case kGroupByYear:
    458             query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-08-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
    459             break;
    460         }
    461 
    462         if (fGroupBy==kNone)
    463         {
    464             query += ", ";
    465             query += fSecondary;
    466             query += ", ";
    467             query += value;
    468             query += ", ";
    469             query += fPrimaryNumber;
    470             query += " ";
    471         }
    472         else
    473         {
    474             query += ", AVG(";
    475             query += fSecondary;
    476             query += "), AVG(";
    477             query += value;
    478             query += "), ";
    479             query += fPrimaryNumber;
    480             query += ", STD(";
    481             query += fSecondary;
    482             query += "), STD(";
    483             query += value;
    484             query += ") ";
    485         }
    486 
    487         query += Form("FROM %s ", tabled.Data());
    488 
    489         TString where(fCondition);
    490 
    491         const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull();
    492         if (interval)
    493         {
    494             if (!where.IsNull())
    495                 where += " AND ";
    496             where += Form("%s BETWEEN '%s' AND '%s' ",
    497                           fPrimaryDate.Data(), fRequestFrom.Data(), fRequestTo.Data());
    498         }
    499 
    500         if (!where.IsNull())
    501             where += " AND ";
    502         where += fCondition;
    503         where += " ";
    504 
    505         // ------------------------------
    506 
    507         query += fServer.GetJoins(tabled, query+" "+where);
    508 
    509         if (!where.IsNull())
    510         {
    511             query += "WHERE ";
    512             query += where;
    513         }
    514 
    515         if (fGroupBy!=kNone)
    516         {
    517             query += Form("GROUP BY %s ", valued.Data()+1);
    518             //query += Form(" HAVING COUNT(%s)=(COUNT(*)+1)/2 ", valuev.Data());
    519         }
    520         query += Form("ORDER BY %s ", valued.Data()+1);
    521 
    522         // ------------------------------
    523 
    524         TSQLResult *res = fServer.Query(query);
    525         if (!res)
    526             return kFALSE;
    527 
    528         if (max>min)
    529             PlotTable(*res, namev, min, max, resolution);
    530         else
    531             PlotTable(*res, namev, fPlotMin, fPlotMax, resolution);
    532 
    533         delete res;
    534         return kTRUE;
    535     }
    536 };
    537 
    538 void plotall(MPlot &plot, TString source)
     80#include "plotdb.C"
     81
     82void plotalloptical(MPlot &plot, TString source)
    53983{
    54084    // Setup here the values for timestamp and secondary (upper/right) plot
     
    54892    if (!source.IsNull())
    54993    {
    550         const Int_t key = plot.QueryKeyOfSource(source);
     94        const Int_t key = plot.GetServer().QueryKeyOfName("Object", source, kFALSE);
    55195        if (key<0)
    55296            return;
    55397        cond += Form(" AND Object.fObjectKEY=%d", key);
    554 
    55598    }
    55699
     
    625168int plotoptical(TString from, TString to, const char *source=0)
    626169{
    627     TEnv env("sql.rc");
    628 
    629     MSQLMagic serv(env);
     170    MSQLMagic serv("sql.rc");
    630171    if (!serv.IsConnected())
    631172    {
     
    648189    plot.SetDisplay(d);
    649190    plot.SetRequestRange(from, to);
    650     plotall(plot, source);
     191    plotalloptical(plot, source);
    651192    // Use this to create output plots automatically
    652193    //  d->SaveAsRoot("plotoptical.root");
     
    658199int plotoptical(const char *source)
    659200{
    660     TEnv env("sql.rc");
    661 
    662     MSQLMagic serv(env);
     201    MSQLMagic serv("sql.rc");
    663202    if (!serv.IsConnected())
    664203    {
     
    681220    plot.SetDisplay(d);
    682221    plot.SetRequestRange("", "");
    683     plotall(plot, source);
     222    plotalloptical(plot, source);
    684223    // Use this to create output plots automatically
    685224    //  d->SaveAsRoot("plotoptical.root");
     
    691230int plotoptical(Int_t period, const char *source="")
    692231{
    693     TEnv env("sql.rc");
    694 
    695     MSQLMagic serv(env);
     232    MSQLMagic serv("sql.rc");
    696233    if (!serv.IsConnected())
    697234    {
     
    714251    plot.SetDisplay(d);
    715252    plot.SetRequestPeriod(period);
    716     plotall(plot, source);
     253    plotalloptical(plot, source);
    717254
    718255    // Use this to create output plots automatically
  • trunk/MagicSoft/Mars/datacenter/macros/plotrundb.C

    r8994 r8996  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: plotrundb.C,v 1.5 2008-07-03 16:29:48 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: plotrundb.C,v 1.6 2008-07-05 19:01:42 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    111111int plotrundb(TString from, TString to, const char *dataset=0)
    112112{
    113     TEnv env("sql.rc");
    114 
    115     MSQLMagic serv(env);
     113    MSQLMagic serv("sql.rc");
    116114    if (!serv.IsConnected())
    117115    {
     
    143141int plotrundb(const char *ds)
    144142{
    145     TEnv env("sql.rc");
    146 
    147     MSQLMagic serv(env);
     143    MSQLMagic serv("sql.rc");
    148144    if (!serv.IsConnected())
    149145    {
     
    175171int plotrundb(Int_t period, const char *dataset="")
    176172{
    177     TEnv env("sql.rc");
    178 
    179     MSQLMagic serv(env);
     173    MSQLMagic serv("sql.rc");
    180174    if (!serv.IsConnected())
    181175    {
  • trunk/MagicSoft/Mars/datacenter/macros/plotstat.C

    r8983 r8996  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.6 2008-06-19 15:18:57 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.7 2008-07-05 19:01:42 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    4848
    4949#include <TH2.h>
    50 #include <TEnv.h>
    5150#include <TPad.h>
    5251#include <TLine.h>
     
    663662int plotstat(Int_t first=-1, Int_t last=-1)
    664663{
    665     TEnv env("sql.rc");
    666 
    667     MSQLServer serv(env);
     664    MSQLServer serv("sql.rc");
    668665    if (!serv.IsConnected())
    669666    {
  • trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C

    r7460 r8996  
    4949#include <fstream>
    5050
    51 #include <TEnv.h>
    52 
    53 #include <MSQLServer.h>
    5451#include <TSQLRow.h>
    5552#include <TSQLResult.h>
     53
     54#include "MSQLServer.h"
    5655
    5756using namespace std;
     
    6059int resetallruns(TString filename, TString column)
    6160{
    62     TEnv env("sql.rc");
    63 
    64     MSQLServer serv(env);
     61    MSQLServer serv("sql.rc");
    6562    if (!serv.IsConnected())
    6663    {
  • trunk/MagicSoft/Mars/datacenter/macros/setstatus.C

    r7486 r8996  
    1818!   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2006
     20!   Copyright: MAGIC Software Development, 2000-2008
    2121!
    2222!
     
    5050//
    5151/////////////////////////////////////////////////////////////////////////////
    52 
    5352#include <iostream>
    5453#include <iomanip>
     
    5655
    5756#include <TEnv.h>
    58 
    59 #include <MTime.h>
    60 
    61 #include <MSQLServer.h>
    6257#include <TSQLRow.h>
    6358#include <TSQLResult.h>
     59
     60#include "MTime.h"
     61#include "MSQLServer.h"
    6462
    6563using namespace std;
  • trunk/MagicSoft/Mars/datacenter/macros/writedatasetfile.C

    r8248 r8996  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: writedatasetfile.C,v 1.2 2007-01-12 17:33:10 snruegam Exp $
     2! $Name: not supported by cvs2svn $:$Id: writedatasetfile.C,v 1.3 2008-07-05 19:01:43 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    2020!   Author(s): Thomas Bretz, 11/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
    2121!
    22 !   Copyright: MAGIC Software Development, 2000-2006
     22!   Copyright: MAGIC Software Development, 2000-2008
    2323!
    2424!
     
    5050#include <TSQLResult.h>
    5151
    52 #include <TEnv.h>
    5352#include <errno.h>
    5453
     
    9190    //get sequence information from database
    9291    TString query0(Form("SELECT fSourceName, fComment, fDataSetName, fRunTime, fObservationModeKEY"
    93                        " FROM DataSets LEFT JOIN Source ON"
    94                        " Source.fSourceKEY=DataSets.fSourceKEY"
     92                       " FROM DataSets LEFT JOIN Source USING (fSourceKEY)"
    9593                       " WHERE fDataSetNumber=%d", dsno));
    9694
     
    167165int writedatasetfile(Int_t dsno, TString seqpath)
    168166{
    169     TEnv env("sql.rc");
    170 
    171     MSQLMagic serv(env);
     167    MSQLMagic serv("sql.rc");
    172168    if (!serv.IsConnected())
    173169    {
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r8946 r8996  
    138138// --------------------------------------------------------------------------
    139139//
     140// Return date as year(y), month(m), day(d). If the time is afternoon
     141// (>=13:00:00) the date of the next day is returned.
     142//
     143MTime MTime::GetDateOfSunrise() const
     144{
     145    UShort_t y;
     146    Byte_t m;
     147    Byte_t d;
     148
     149    MAstro::Mjd2Ymd(fMjd, y, m, d);
     150
     151    return MTime(y, m, d);
     152}
     153
     154// --------------------------------------------------------------------------
     155//
    140156// GetMoonPhase - calculate phase of moon as a fraction:
    141157//  Returns -1 if calculation failed
     
    167183//   53257.8 --> 53258
    168184//   53258.3 --> 53258
    169 // Which is the time between 13h and 12:59h of the following day. To
     185 // Which is the time between 13h and 12:59h of the following day. To
    170186// this day-period we assign the moon-period at midnight. To get
    171187// the MAGIC definition we now substract 284.
  • trunk/MagicSoft/Mars/mbase/MTime.h

    r8988 r8996  
    117117    TString  GetFileName() const;
    118118    void     GetDate(UShort_t &y, Byte_t &m, Byte_t &d) const;
     119    MTime    GetDateOfSunrise() const;
    119120    void     GetDateOfSunrise(UShort_t &y, Byte_t &m, Byte_t &d) const;
    120121    TTime    GetRootTime() const;
  • trunk/MagicSoft/Mars/mhflux/MHAlpha.cc

    r8991 r8996  
    780780        delete pad->GetPad(2);
    781781
    782     if (fTimeEffOn && fTime || fHTime.GetNbinsX()>1 || fHTime.GetBinContent(1)!=0)
     782    if (fTimeEffOn && fTime || fHTime.GetNbinsX()>1 || fHTime.GetBinError(1)>0)
    783783    {
    784784        pad->cd(3);
  • trunk/MagicSoft/Mars/mimage/MHHillas.cc

    r8677 r8996  
    109109    bins.Apply(*fSize);
    110110
    111     fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445);
     111    fCenter = new TH2F("Center", "Center of gravity", 51, -445, 445, 51, -445, 445);
    112112    fCenter->SetDirectory(NULL);
    113113    fCenter->SetXTitle("x [mm]");
  • trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h

    r8988 r8996  
    66
    77#pragma link C++ class MSequence+;
     8#pragma link C++ class MSequenceSQL+;
    89#pragma link C++ class MDataSet+;
    910
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r8989 r8996  
    171171//
    172172/////////////////////////////////////////////////////////////////////////////
    173 #include "MSequence.h"
     173#include "MSequenceSQL.h"
    174174
    175175#include <stdlib.h>
     
    575575// --------------------------------------------------------------------------
    576576//
    577 // Get LightCondition from resource file and convert it to LIghtCondition_t
    578 //
    579 MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env, const char *prefix) const
    580 {
    581     TString str = GetEnvValue2(env, prefix, "LightConditions", "n/a");
     577// Get LightCondition from str and convert it to LightCondition_t
     578//
     579MSequence::LightCondition_t MSequence::GetLightCondition(const TString &str) const
     580{
    582581    if (!str.CompareTo("n/a", TString::kIgnoreCase))
    583582        return kNA;
     
    634633    fPeriod    = GetEnvValue2(env, prefix, "Period",    -1);
    635634
    636     fLightCondition = ReadLightCondition(env, prefix);
    637 
    638635    TString str;
     636    str = GetEnvValue2(env, prefix, "LightConditions", "n/a");
     637    fLightCondition = GetLightCondition(str);
     638
    639639    str = GetEnvValue2(env, prefix, "Start", "");
    640640    fStart.SetSqlDateTime(str);
     641
    641642    str = GetEnvValue2(env, prefix, "Night", "");
    642643    str += " 00:00:00";
     
    667668        env.PrintUntouched();
    668669    }
     670}
     671
     672MSequence::MSequence(const char *fname, UInt_t seq)
     673{
     674    *this = MSequenceSQL(fname, seq);
    669675}
    670676
     
    875881        return;
    876882    }
    877     out << "# Path: " << GetFileName() << endl;
    878     out << "# Name: " << GetBaseName() << endl;
     883    if (!fFileName.IsNull())
     884        out << "# FileName: " << fFileName << endl;
     885    if (!fDataPath.IsNull())
     886        out << "# DataPath: " << fDataPath << endl;
    879887    out << endl;
    880888    if (pre.IsNull())
     
    885893        out << pre << "Period:         " << fPeriod << endl;
    886894    if (fNight!=MTime())
    887         out << pre << "Night:          " << fNight << endl;
     895        out << pre << "Night:          " << fNight.GetStringFmt("%Y-%m-%d") << endl;
    888896    out << endl;
    889897    out << pre << "LightCondition: ";
     
    894902    case kTwilight: out << "Twilight" << endl; break;
    895903    case kMoon:     out << "Moon" << endl;     break;
    896     case kDay:      out << "Day" << endl;     break;
     904    case kDay:      out << "Day" << endl;      break;
    897905    }
    898906
    899907    if (fStart!=MTime())
    900         out << pre << "Start:          " << fStart << endl;
     908        out << pre << "Start:          " << fStart.GetSqlDateTime() << endl;
    901909    if (fLastRun>=0)
    902910        out << pre << "LastRun:        " << fLastRun << endl;
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r8989 r8996  
    1414class MSequence : public MParContainer
    1515{
     16    friend class MSequenceSQL;
    1617public:
    1718    enum LightCondition_t { kNA, kNoMoon, kTwilight, kMoon, kDay };
     
    6768    void    Split(const TEnv &env, const TString &prefix, const char *name, TArrayI &data, TArrayI &sub) const;
    6869
    69     LightCondition_t ReadLightCondition(TEnv &env, const char *prefix) const;
     70    LightCondition_t GetLightCondition(const TString &str) const;
    7071
    7172    // Helper for file setup
     
    9293public:
    9394    MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
    94         fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE)
     95        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA), fMonteCarlo(kFALSE)
    9596    {
    9697        fName  = "MSequence";
     
    9899    }
    99100    MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
     101    MSequence(const char *fname, UInt_t seq);
    100102    MSequence(const MSequence &s) : MParContainer(s),
    101103        fFileName(s.fFileName), fDataPath(s.fDataPath),
    102104        fSequence(s.fSequence), fStart(s.fStart),
    103105        fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
    104         fNight(s.fNight), fProject(s.fProject), fSource(s.fSource),
     106        fNight(s.fNight), fLightCondition(s.fLightCondition),
     107        fProject(s.fProject), fSource(s.fSource),
    105108        fTriggerTable(s.fTriggerTable), fHvSettings(s.fHvSettings),
    106         fRuns(s.fRuns), fCalRuns(s.fCalRuns), fPedRuns(s.fPedRuns),
    107         fDatRuns(s.fDatRuns), fMonteCarlo(s.fMonteCarlo) { }
     109        fRuns(s.fRuns), fRunsSub(s.fRunsSub), fCalRuns(s.fCalRuns),
     110        fCalRunsSub(s.fCalRunsSub), fPedRuns(s.fPedRuns),
     111        fPedRunsSub(s.fPedRunsSub), fDatRuns(s.fDatRuns),
     112        fDatRunsSub(s.fDatRunsSub), fExclRuns(s.fExclRuns),
     113        fExclRunsSub(s.fExclRunsSub), fMonteCarlo(s.fMonteCarlo) { }
    108114
    109115    // I/O
  • trunk/MagicSoft/Mars/mjobs/Makefile

    r8988 r8996  
    2424           -I../mtools -I../mimage -I../mpointing -I../mastro -I../mfbase \
    2525           -I../mhvstime -I../mtrigger -I../mmuon -I../mmc -I../mmovie \
    26            -I../mextralgo -I../mhflux
     26           -I../mextralgo -I../mhflux -I../msql
    2727
    2828SRCFILES = MSequence.cc \
     29           MSequenceSQL.cc \
    2930           MDataSet.cc \
    3031           MJob.cc \
  • trunk/MagicSoft/Mars/msql/MSQLMagic.cc

    r8987 r8996  
    187187}
    188188
    189 Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test)
    190 {
    191     TString query(Form("SELECT %s FROM %s WHERE %s='%s'", column, table, column, test));
     189// --------------------------------------------------------------------------
     190//
     191// Check if the column of an entry in a table is existing and not null.
     192// The entry is defined by column=test (column name) and a optional
     193// WHERE statement.
     194//
     195Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test, const char *where)
     196{
     197    TString query(Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:""));
    192198    TSQLResult *res = Query(query);
    193199    if (!res)
  • trunk/MagicSoft/Mars/msql/MSQLMagic.h

    r8942 r8996  
    4444    Int_t   QueryKeyOfVal(const char *col, const char *val);
    4545    Int_t   QueryKeyOf(const char *col, const char *ext, const char *val);
    46     Bool_t  ExistStr(const char *column, const char *table, const char *test);
     46    Bool_t  ExistStr(const char *column, const char *table, const char *test, const char *where=0);
    4747
    4848    Int_t Insert(const char *table, const char *vars, const char *where=0);
  • trunk/MagicSoft/Mars/msql/MSQLServer.cc

    r8907 r8996  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.15 2008-06-02 08:46:49 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.16 2008-07-05 18:57:35 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    668668}
    669669
     670// --------------------------------------------------------------------------
     671//
     672// Instantiate a dabase connection either by
     673//   mysql://user:password@url/database
     674// or by a resource file (in teh given string doesn't contain mysql://)
     675//
    670676MSQLServer::MSQLServer(const char *u) : fType(kIsZombie) /*FOLD00*/
    671677{
    672     TString url(u);
    673     TString user, pasw;
    674 
    675     if (!Split(url, user, pasw))
    676     {
    677         fType = kIsZombie;
    678         return;
    679     }
    680     Init(url, user, pasw);
     678    if (TString(u).Contains("mysql://", TString::kIgnoreCase))
     679    {
     680        TString url(u);
     681        TString user, pasw;
     682
     683        if (!Split(url, user, pasw))
     684        {
     685            fType = kIsZombie;
     686            return;
     687        }
     688        Init(url, user, pasw);
     689    }
     690    else
     691    {
     692        TEnv env(u);
     693        InitEnv(env);
     694    }
    681695}
    682696
     
    781795        if (key=="PRI")
    782796        {
    783             rc = (*row)[0];
    784             break;
     797            if (!rc.IsNull())
     798                rc += ", ";
     799            rc += (*row)[0];
    785800        }
    786801        delete row;
     
    823838
    824839        const TString tab = expr(0, expr.First('.'));
    825         const TString var = expr(expr.First('.')+1, expr.Length());
     840        //const TString var = expr(expr.First('.')+1, expr.Length());
    826841
    827842        // If the table found is the primary table itself skip it.
     
    838853            continue;
    839854
    840         joins += Form("LEFT JOIN %s ON %s.%s=%s.%s ", tab.Data(),
    841                       table, prim.Data(), tab.Data(), prim.Data());
     855        joins += Form("LEFT JOIN %s USING (%s) ", tab.Data(), prim.Data());
    842856    }
    843857
  • trunk/MagicSoft/Mars/mtools/MCalendar.cc

    r8958 r8996  
    262262#include <TPaveText.h>
    263263#include <THashList.h>
     264#include <TObjArray.h>
    264265
    265266#include "MEnv.h"
Note: See TracChangeset for help on using the changeset viewer.