Changeset 9039 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
07/23/08 14:15:14 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9038 r9039  
    4040   * mjobs/MJCalibrateSignal.cc:
    4141     - changed again the wrong names of the tasklists
     42
     43   * mjobs/MSequence.[h,cc]:
     44     - set default telescope to 1 so that reading old sequence files
     45       gives valid sequences.
     46     - overwrote Read to allow reading also old sequences which
     47       have no default name in the files
     48     - removed output of "DataPath" from Print
     49
     50   * msql/MSQLMagic.[h,cc]:
     51     - added a second InsertUpdate
     52     - added ExistRow
    4253
    4354
  • trunk/MagicSoft/Mars/mbase/MStatusArray.cc

    r9026 r9039  
    4444#include "MStatusArray.h"
    4545
    46 #include <TH1.h>       // TH1::AddDirectoryStatus();
     46#include <TH1.h>              // TH1::AddDirectoryStatus();
     47#include <TFile.h>            // gFile
    4748#include <TClass.h>
    4849#include <TCanvas.h>
     
    344345    Delete();
    345346
     347    const TString keyname = name?name:"MStatusDisplay";
     348
     349    // Check if key exists (to suppress an error on the console
     350    if (!gDirectory->GetListOfKeys()->FindObject(keyname))
     351    {
     352        gLog << inf << keyname << " [MStatusArray] not found." << endl;
     353        return 0;
     354    }
     355
    346356    // Make sure newly read histograms are not added to the current directory
    347357    const Bool_t store = TH1::AddDirectoryStatus();
    348358    TH1::AddDirectory(kFALSE);
    349     const Int_t rc = TObjArray::Read(name?name:"MStatusDisplay");
     359    const Int_t rc = TObjArray::Read(keyname);
    350360    TH1::AddDirectory(store);
    351361
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r9038 r9039  
    22392239                list.Add(new TNamed(GetName(), GetTitle()));
    22402240
     2241            c->SetTitle(gFile->GetName());
    22412242            list.Add(c);
    22422243        }
     
    22462247        if (list.GetEntries()==0)
    22472248        {
    2248             *fLog << warn << "MStatusDisplay::Read: No objects read." << endl;
     2249            *fLog << warn << "MStatusDisplay::Read: No objects read from " << gFile->GetName() << endl;
    22492250            return 0;
    22502251        }
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r9028 r9039  
    13941394    }
    13951395
    1396     if (!fDataPath.IsNull())
    1397         out << endl << pre << "DataPath: " << fDataPath << endl;
     1396//    if (!fDataPath.IsNull())
     1397//        out << endl << pre << "DataPath: " << fDataPath << endl;
    13981398
    13991399    if (!str.IsNull())
     
    15121512
    15131513    fPeriod = fNight.GetMagicPeriod();
     1514}
     1515
     1516// --------------------------------------------------------------------------
     1517//
     1518// Read a sequence from gDirectory. If the default is given we try
     1519// to find a sequence with name GetName. If a key with name name
     1520// exists in the file read this key. Otherwise loop over all keys
     1521// and return the first key matching the TPRegex (regular expression)
     1522// matching defined by the argument.
     1523//
     1524Int_t MSequence::Read(const char *name)
     1525{
     1526    if (!name || !gFile)
     1527        return MParContainer::Read(name);
     1528
     1529    if (!gDirectory->GetListOfKeys()->FindObject(name))
     1530        return MParContainer::Read(name);
     1531
     1532    TPRegexp regexp(name);
     1533
     1534    TIter NextK(gDirectory->GetListOfKeys());
     1535    TObject *key = 0;
     1536    while ((key=NextK()))
     1537        if (TString(key->GetName())(regexp)==key->GetName())
     1538            return MParContainer::Read(key->GetName());
     1539
     1540    *fLog << warn << "WARNING - No key in " << gDirectory->GetName() << " matching " << name << "." << endl;
     1541    return 0;
    15141542}
    15151543
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r9023 r9039  
    131131
    132132public:
    133     MSequence() : fTelescope(0), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
     133    MSequence() : fTelescope(1), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
    134134        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA), fMonteCarlo(kFALSE)
    135135    {
     
    158158
    159159    // I/O
     160    Int_t  Read(const char *name=0);
    160161    Bool_t ReadDatabase(TString sql, UInt_t seq=0, UShort_t tel=0);
    161162    Bool_t ReadFile(const char *filename, UInt_t id=(UInt_t)-1);
  • trunk/MagicSoft/Mars/msql/MSQLMagic.cc

    r9001 r9039  
    195195Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test, const char *where)
    196196{
    197     TString query(Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:""));
     197    TString query = test ?
     198        Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:"") :
     199        Form("SELECT %s FROM %s WHERE %s", column, table, where);
     200
    198201    TSQLResult *res = Query(query);
    199202    if (!res)
     
    211214    delete res;
    212215    return rc;
     216}
     217
     218// --------------------------------------------------------------------------
     219//
     220// Check if at least one row with one field exists in table
     221// defined by where
     222//
     223Bool_t MSQLMagic::ExistRow(const char *table, const char *where)
     224{
     225    return ExistStr("*", table, 0, where);
    213226}
    214227
     
    306319// --------------------------------------------------------------------------
    307320//
     321// An abbreviation for checking whether a row with the condition where
     322// exists. If no such row exist Insert vars into table, otherwise update
     323// vars in table at row(s) defined by where.
     324//
     325Int_t MSQLMagic::InsertUpdate(const char *table, const char *vars, const char *where)
     326{
     327    return ExistRow(table, where) ?
     328        Update(table, vars, where) :
     329        Insert(table, vars);
     330}
     331
     332// --------------------------------------------------------------------------
     333//
    308334// An abbreviation for a Dalete-Query.
    309335//
  • trunk/MagicSoft/Mars/msql/MSQLMagic.h

    r9001 r9039  
    4545    Int_t   QueryKeyOf(const char *col, const char *ext, const char *val);
    4646    Bool_t  ExistStr(const char *column, const char *table, const char *test, const char *where=0);
     47    Bool_t  ExistRow(const char *table, const char *where);
    4748
    4849    Int_t Insert(const char *table, const char *vars, const char *where=0);
     
    5051    Int_t Delete(const char *table, const char *where);
    5152    Int_t InsertUpdate(const char *table, const char *col, const char *val, const char *vars);
     53    Int_t InsertUpdate(const char *table, const char *vars, const char *where);
    5254
    5355    void Delete(const Option_t *o) { TObject::Delete(o); }
  • trunk/MagicSoft/Mars/showplot.cc

    r9038 r9039  
    199199    //
    200200    const TString kInput = InflatePath(arg);
    201     const TString kTitle = kInput.IsNull() ? kInput + "..."  : kInput;
     201    const TString kTitle = kInput.IsNull() ? arg.GetArgumentStr(0) + "..."  : kInput;
    202202
    203203    //
Note: See TracChangeset for help on using the changeset viewer.