Ignore:
Timestamp:
07/19/08 12:55:42 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r9012 r9015  
    4747//   Sequence:     31015
    4848//
    49 //   # Observation Period (not needed)
    50 //   Period:       18
     49//   # Observation Period (not needed, calculated from Night)
     50//   # Period:       18
    5151//
    5252//   # Date of sunrise of the observation night - necessary if the path
     
    7474//   # Total number of data-events in sequence (not needed)
    7575//   NumEvents:    250914
     76//
     77//   # Brightest light condition of the contained runs (not needed)
     78//   LightCondition: Twilight
    7679//
    7780//   # Whether this is MC data or not (necessary in case of MCs if
     
    661664    fLastRun   = GetEnvValue2(env, prefix, "LastRun",   -1);
    662665    fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
    663     fPeriod    = GetEnvValue2(env, prefix, "Period",    -1);
    664666
    665667    TString str;
    666     str = GetEnvValue2(env, prefix, "LightConditions", "n/a");
     668    str = GetEnvValue2(env, prefix, "LightCondition", "n/a");
    667669    fLightCondition = GetLightCondition(str);
    668670
     
    673675    str += " 00:00:00";
    674676    fNight.SetSqlDateTime(str);
     677
     678    fPeriod = fNight.GetMagicPeriod();
    675679
    676680    fProject      = GetEnvValue2(env, prefix, "Project", "");
     
    688692
    689693    // Dummies:
     694    env.Touch("Period");
    690695    env.Touch("ZdMin");
    691696    env.Touch("ZdMax");
     
    700705}
    701706
     707// --------------------------------------------------------------------------
     708//
     709// Create a sequence from the database, e.g.
     710//
     711//    TString mysql     = "mysql://MAGIC:password@vela/MyMagic";
     712//    Int_t   sequence  = 100002;
     713//    Int_t   telescope = 1;
     714//
     715//    MSequence seq(mysql, sequence, telescope);
     716//
     717// For more details see MSequenceSQL.
     718//
    702719MSequence::MSequence(const char *fname, UInt_t seq, UShort_t tel)
    703720{
     
    705722}
    706723
     724// --------------------------------------------------------------------------
     725//
     726// Some helper functions for the comparison functions
     727//
    707728static int operator==(const TArrayI &a, const TArrayI &b)
    708729{
    709     return a.GetSize()==b.GetSize() ?
    710         memcmp(a.GetArray(), b.GetArray(), a.GetSize()*sizeof(Int_t))==0 :
    711         false;
    712 }
    713 
    714 static int IsNull(const TArrayI &a)
    715 {
    716     if (a.GetSize()==0)
    717         return true;
    718 
    719     return a.GetSize()==0 ? true : a==TArrayI(a.GetSize());
     730    return a.GetSize()==b.GetSize() &&
     731        memcmp(a.GetArray(), b.GetArray(), a.GetSize()*sizeof(Int_t));
    720732}
    721733
    722734static int IsNull(const TArrayI &a, const TArrayI &b)
    723735{
    724     return IsNull(a) && IsNull(b);
    725 }
    726 
    727 Bool_t MSequence::IsSimilar(const MSequence &s) const
     736    return a==TArrayI(a.GetSize()) && b==TArrayI(b.GetSize());
     737}
     738
     739static int Check(const TArrayI &a, const TArrayI &b)
     740{
     741    return a==b || IsNull(a, b);
     742}
     743
     744// --------------------------------------------------------------------------
     745//
     746// Here we test all things mandatory for a sequence:
     747//   fTelescope
     748//   fSequence
     749//   fNight
     750//   fMonteCarlo
     751//   fCalRuns
     752//   fCalRunsSub
     753//   fPedRuns
     754//   fPedRunsSub
     755//   fDatRuns
     756//   fDatRunsSub
     757//   fExclRuns
     758//   fExclRunsSub
     759//
     760Bool_t MSequence::IsCompatible(const MSequence &s) const
    728761{
    729762    return // Mandatory
    730         fTelescope==s.fTelescope && fSequence==s.fSequence &&
    731         fNight==s.fNight
    732         && fLightCondition==s.fLightCondition &&
    733 
    734         fMonteCarlo==s.fMonteCarlo &&
    735 
    736         (fRunsSub    ==s.fRunsSub     || IsNull(fRunsSub,     s.fRunsSub))     &&
    737         (fCalRunsSub ==s.fCalRunsSub  || IsNull(fCalRunsSub,  s.fCalRunsSub))  &&
    738         (fPedRunsSub ==s.fPedRunsSub  || IsNull(fPedRunsSub,  s.fPedRunsSub))  &&
    739         (fDatRunsSub ==s.fDatRunsSub  || IsNull(fDatRunsSub,  s.fDatRunsSub))  &&
    740         (fExclRunsSub==s.fExclRunsSub || IsNull(fExclRunsSub, s.fExclRunsSub))
    741         ;
    742 }
    743 
     763        fTelescope   == s.fTelescope   &&
     764        fSequence    == s.fSequence    &&
     765        fNight       == s.fNight       &&
     766
     767        fMonteCarlo  == s.fMonteCarlo  &&
     768
     769        fCalRuns     == s.fCalRuns     &&
     770        fPedRuns     == s.fPedRuns     &&
     771        fDatRuns     == s.fDatRuns     &&
     772        fExclRuns    == s.fExclRuns    &&
     773
     774        Check(fCalRunsSub,  s.fCalRunsSub) &&
     775        Check(fPedRunsSub,  s.fPedRunsSub) &&
     776        Check(fDatRunsSub,  s.fDatRunsSub) &&
     777        Check(fExclRunsSub, s.fExclRunsSub);
     778}
     779
     780// --------------------------------------------------------------------------
     781//
     782// Here we test whether all values of a sequence are identical
     783//   IsCompaticle(s)
     784//   fStart
     785//   fLastRun
     786//   fNumEvents
     787//   fPeriod
     788//   fProject
     789//   fSource
     790//   fRuns
     791//   fHvSettings
     792//   fTriggerTable
     793//   fLightCondition
     794//   fRuns
     795//   fRunsSub
     796//
     797Bool_t MSequence::operator==(const MSequence &s) const
     798{
     799    return IsCompatible(s) &&
     800        // Unnecessary
     801        fStart          == s.fStart          &&
     802        fLastRun        == s.fLastRun        &&
     803        fNumEvents      == s.fNumEvents      &&
     804        fPeriod         == s.fPeriod         &&
     805        fProject        == s.fProject        &&
     806        fSource         == s.fSource         &&
     807        fRuns           == s.fRuns           &&
     808        fHvSettings     == s.fHvSettings     &&
     809        fTriggerTable   == s.fTriggerTable   &&
     810        fLightCondition == s.fLightCondition &&
     811        Check(fRunsSub, s.fRunsSub);
     812}
     813
     814// --------------------------------------------------------------------------
     815//
     816// Check whether the sequence has also identical source, i.e.
     817// the sequence filepath and the datapath in addition to operator==
     818//
    744819Bool_t MSequence::IsIdentical(const MSequence &s) const
    745820{
    746     return IsSimilar(s) &&
    747         // Unnecessary
    748         fStart==s.fStart         && fLastRun==s.fLastRun   &&
    749         fNumEvents==s.fNumEvents && fPeriod==s.fPeriod     &&
    750         fProject==s.fProject     && fSource==s.fSource     &&
    751         /*fTriggerTable==s.fTriggerTable &&*/ fHvSettings==s.fHvSettings;
    752 }
    753 
    754 Bool_t MSequence::operator==(const MSequence &s) const
    755 {
    756     return IsIdentical(s) &&
     821    return *this==s &&
    757822        // Obsolete
    758823        fDataPath==s.fDataPath && fFileName==s.fFileName;
     
    9811046        out << pre << "Night:          " << fNight.GetStringFmt("%Y-%m-%d") << endl;
    9821047    out << endl;
    983     out << pre << "LightConditions: ";
     1048    out << pre << "LightCondition: ";
    9841049    switch (fLightCondition)
    9851050    {
     
    10181083    else
    10191084    {
     1085        // FIXME: This needs more check!
     1086        // Could we make "Runs" an automatic summary of all runs?
     1087        // Should we add a check forbidding the same run in
     1088        // Cal/Ped/Data? What about the Exclude?
    10201089        str += PrintRuns(out, pre, "Runs:     ", fRuns,     fRunsSub);
    10211090        /*str +=*/ PrintRuns(out, pre, "CalRuns:  ", fCalRuns,  fCalRunsSub);
     
    11961265        f = &fCalRunsSub;
    11971266        break;
     1267    case 'X':
     1268        r = &fExclRuns;
     1269        f = &fExclRunsSub;
     1270        break;
    11981271    default:
    11991272        r = &fRuns;
     
    12041277    AddEntry(run, file, *r, *f);
    12051278
    1206     MJob::SortArray(fExclRuns);
    1207 }
    1208 
    1209 // --------------------------------------------------------------------------
    1210 //
    1211 // Exclude this run (i.e. add it to fExclRuns)
    1212 //
    1213 void MSequence::ExcludeFile(UInt_t run, UInt_t file/*, Bool_t force*/)
    1214 {
    1215 //    if (force && IsExcluded(run, file))
    1216 //        return;
    1217 
    1218     AddEntry(run, file, fExclRuns, fExclRunsSub);
    1219 
    1220     MJob::SortArray(fExclRuns);
     1279    SortArrays(*r, *f);
    12211280}
    12221281
     
    12681327    fNight.SetSqlDateTime(night);
    12691328
    1270     fPeriod = MAstro::GetMagicPeriod(fNight.GetMjd());
     1329    fPeriod = fNight.GetMagicPeriod();
    12711330}
    12721331
Note: See TracChangeset for help on using the changeset viewer.