Ignore:
Timestamp:
07/17/08 12:59:54 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r8999 r9002  
    170170//   + fExclRunsSub
    171171//
     172//  Class Version 6:
     173//  ----------------
     174//   + fTelescope
     175//
    172176/////////////////////////////////////////////////////////////////////////////
    173177#include "MSequenceSQL.h"
     
    514518TString MSequence::GetFileName(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type) const
    515519{
    516     const Int_t tel = 1;
    517     return InflateRunName(fNight, arr[i]>999999?tel:0, fMonteCarlo?-arr[i]:arr[i], sub.GetSize()>0?sub[i]:0, type);
     520    return InflateRunName(fNight, arr[i]>999999?fTelescope:0, fMonteCarlo?-arr[i]:arr[i], sub.GetSize()>0?sub[i]:0, type);
    518521}
    519522
     
    652655        fSequence = (UInt_t)-1;
    653656
     657
    654658    const TString prefix = Form("Sequence%08d", fSequence);
    655659
     660    fTelescope = GetEnvValue2(env, prefix, "Telescope",  1);
    656661    fLastRun   = GetEnvValue2(env, prefix, "LastRun",   -1);
    657662    fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
     
    695700}
    696701
    697 MSequence::MSequence(const char *fname, UInt_t seq)
    698 {
    699     *this = MSequenceSQL(fname, seq);
     702MSequence::MSequence(const char *fname, UInt_t seq, UShort_t tel)
     703{
     704    *this = MSequenceSQL(fname, seq, tel);
    700705}
    701706
     
    913918    if (pre.IsNull())
    914919        out << "Sequence:       " << fSequence << endl;
     920    if (fTelescope!=1)
     921        out << "Telescope:      " << fTelescope << endl;
    915922    if (fMonteCarlo)
    916923        out << pre << "MonteCarlo:     Yes" << endl;
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r8999 r9002  
    2626    TString fDataPath;         // Path to data files
    2727
    28     UInt_t fSequence;          // Sequence number
    29 
    30     // FIXME: UShort_t fTelescopeNumber ???
     28    UShort_t fTelescope;       // Telescope number
     29    UInt_t   fSequence;        // Sequence number
    3130
    3231    MTime  fStart;             // Start time of sequence
     
    9493
    9594public:
    96     MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
     95    MSequence() : fTelescope(0), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
    9796        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA), fMonteCarlo(kFALSE)
    9897    {
     
    101100    }
    102101    MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
    103     MSequence(const char *fname, UInt_t seq);
     102    MSequence(const char *fname, UInt_t seq, UShort_t tel=1);
    104103    MSequence(const MSequence &s) : MParContainer(s),
    105104        fFileName(s.fFileName), fDataPath(s.fDataPath),
     105        fTelescope(s.fTelescope),
    106106        fSequence(s.fSequence), fStart(s.fStart),
    107107        fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
     
    125125
    126126    // Genaral interface
    127     Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
     127    Bool_t IsValid() const { return fTelescope>0 && fSequence!=(UInt_t)-1; }
    128128    Bool_t IsMonteCarlo() const { return fMonteCarlo; }
    129129    Bool_t IsExcluded(UInt_t run, UInt_t file) const { return IsContained(fExclRuns, fExclRunsSub, run, file); }
     
    146146    UInt_t GetNumExclRuns() const { return fExclRuns.GetSize(); }
    147147
     148    UShort_t GetTelescope() const { return fTelescope; }
    148149    UInt_t GetSequence() const { return fSequence; }
    149150    UInt_t GetLastRun() const  { return fLastRun; }
     
    186187    static TString InflateRunPath(const MTime &night, Bool_t mc=kFALSE);
    187188
    188     ClassDef(MSequence, 5) // Describes a sequences, reads and writes sequence files
     189    ClassDef(MSequence, 6) // Describes a sequences, reads and writes sequence files
    189190};
    190191
  • trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc

    r8996 r9002  
    9191    while ((row = res->Next()) && evts<nevts)
    9292    {
    93         AddFile(atoi((*row)[0]), 0, type);
    94         evts += atoi((*row)[1]);
     93        AddFile(atoi((*row)[0]), atoi((*row)[1]), type);
     94        evts += atoi((*row)[2]);
    9595        cnt++;
    9696    }
     
    178178
    179179    // Now prepare queries to request the runs from the database
    180     TString where(Form(" FROM RunData WHERE fSequenceFirst=%d AND fExcludedFDAKEY=1"
    181                        " AND fRunTypeKEY%%s", fSequence));
    182 
    183     const TString query1(Form("SELECT fRunNumber, fNumEvents %s", where.Data()));
     180    TString where(Form(" FROM RunData WHERE"
     181                       " fTelescopeTelescope=%d AND fSequenceFirst=%d AND"
     182                       " fExcludedFDAKEY=1 AND fRunTypeKEY%%s",
     183                       fTelescope, fSequence));
     184
     185    const TString query1(Form("SELECT fRunNumber, fFileNumber, fNumEvents %s", where.Data()));
    184186    const TString query2(Form("SELECT fRunStart, fRunStop %s", where.Data()));
    185187
    186     const TString queryA(Form(query1.Data(), " BETWEEN 2 AND 4 ORDER BY fRunNumber"));
    187     const TString queryC(Form(query1.Data(), "=4 ORDER BY fRunNumber"));
    188     const TString queryD(Form(query1.Data(), "=2 ORDER BY fRunNumber"));
    189     const TString queryT(Form(query2.Data(), "=4 ORDER BY fRunNumber LIMIT 1"));
     188    const TString queryA(Form(query1.Data(), " BETWEEN 2 AND 4 ORDER BY fRunNumber*1000+fFileNumber"));
     189    const TString queryC(Form(query1.Data(), "=4 ORDER BY fRunNumber*1000+fFileNumber"));
     190    const TString queryD(Form(query1.Data(), "=2 ORDER BY fRunNumber*1000+fFileNumber"));
     191    const TString queryT(Form(query2.Data(), "=4 ORDER BY fRunNumber*1000+fFileNumber LIMIT 1"));
    190192
    191193    // Try to get a valid time for the first calibration run
     
    266268//  kTrue in case of success.
    267269//
    268 Bool_t MSequenceSQL::GetFromDatabase(MSQLMagic &serv, Int_t sequno)
     270Bool_t MSequenceSQL::GetFromDatabase(MSQLMagic &serv, Int_t sequno, Int_t tel)
    269271{
    270272    // Check if we are connected to the sql server
     
    275277    }
    276278
    277     // check if any sequence number os avlid
     279    // check if any telescope number is avlid
     280    if (tel<=0 && fTelescope<=0)
     281    {
     282        *fLog << err << "ERROR - No telescope number given in GetSeqFromDatabase." << endl;
     283        return kFALSE;
     284    }
     285
     286    // check if any sequence number is avlid
    278287    if (sequno<0 && fSequence<0)
    279288    {
     
    284293    // set "filename" and sequence number
    285294    fFileName = serv.GetName();
     295    if (tel>0)
     296        fTelescope = tel;
    286297    if (sequno>=0)
    287298        fSequence = sequno;
     
    292303                  " fLightConditionsKEY, fRunStart, fNumEvents, "
    293304                  " fZenithDistanceMin, fZenithDistanceMax "
    294                   " FROM Sequences WHERE fSequenceFirst=");
    295     query += fSequence;
     305                  " FROM Sequences WHERE ");
     306    query += Form("fTelescopeNumber=%d AND fSequenceFirst=%d",
     307                  fTelescope, fSequence);
    296308
    297309    // Request information from database
     
    302314    // invalidate sequence if retrieval failed
    303315    if (!rc)
    304         fSequence = (UInt_t)-1;
     316    {
     317        fTelescope = 0;
     318        fSequence  = (UInt_t)-1;
     319    }
    305320
    306321    // return result
     
    330345//  kTrue in case of success.
    331346//
    332 Bool_t MSequenceSQL::GetFromDatabase(const char *rc, Int_t sequno)
     347Bool_t MSequenceSQL::GetFromDatabase(const char *rc, Int_t sequno, Int_t tel)
    333348{
    334349    MSQLMagic serv(rc);
    335     return GetFromDatabase(serv, sequno);
    336 }
     350    return GetFromDatabase(serv, sequno, tel);
     351}
  • trunk/MagicSoft/Mars/mjobs/MSequenceSQL.h

    r8996 r9002  
    2020
    2121public:
    22     MSequenceSQL(MSQLMagic &serv, Int_t seqno=-1)  { GetFromDatabase(serv, seqno); }
    23     MSequenceSQL(const char *rc, Int_t seqno=-1)   { GetFromDatabase(rc, seqno); }
    24     MSequenceSQL(Int_t seqno=-1)                   { GetFromDatabase(seqno); }
     22    MSequenceSQL(MSQLMagic &serv, Int_t seqno=-1, Int_t tel=-1)  { GetFromDatabase(serv, seqno, tel); }
     23    MSequenceSQL(const char *rc, Int_t seqno=-1, Int_t tel=-1)   { GetFromDatabase(rc, seqno, tel); }
     24    MSequenceSQL(Int_t seqno=-1, Int_t tel=-1)                   { GetFromDatabase(seqno, tel); }
    2525
    26     Bool_t GetFromDatabase(MSQLMagic &serv, Int_t seqno=-1);
    27     Bool_t GetFromDatabase(const char *rc, Int_t seqno=-1);
    28     Bool_t GetFromDatabase(Int_t seqno=-1) { return GetFromDatabase("sql.rc", seqno); }
     26    Bool_t GetFromDatabase(MSQLMagic &serv, Int_t seqno=-1, Int_t tel=-1);
     27    Bool_t GetFromDatabase(const char *rc, Int_t seqno=-1, Int_t tel=-1);
     28    Bool_t GetFromDatabase(Int_t seqno=-1, Int_t tel=-1) { return GetFromDatabase("sql.rc", seqno, tel); }
    2929
    3030    ClassDef(MSequenceSQL, 0) // Extension of MSequence to get a sequence from a database
Note: See TracChangeset for help on using the changeset viewer.