Ignore:
Timestamp:
02/18/05 13:59:53 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
2 edited

Legend:

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

    r5692 r6591  
    9393// ===========================================================================
    9494//
     95//  For special cases you can also setup a sequence directly from a macro,
     96//  for example:
     97//
     98//    MDirIter pediter, datiter, caliter;
     99//
     100//    MSequence seq;
     101//    seq.SetNight("2004-07-06");
     102//    seq.AddPedRuns(31751);
     103//    seq.AddCalRuns(31752);
     104//    seq.AddDatRuns(31753, 31764);
     105//    seq.SetupPedRuns(pediter);
     106//    seq.SetupCalRuns(caliter);
     107//    seq.SetupDatRuns(datiter);
     108//
     109//  or
     110//
     111//    MDirIter iter;
     112//
     113//    MSequence seq;
     114//    seq.SetNight("2004-07-06");
     115//    seq.AddRuns(31753, 31764);
     116//    seq.SetupRuns(iter);
     117//    seq.SetupPedRuns(iter, "/mypath", "[DPC]");
     118//
    95119/////////////////////////////////////////////////////////////////////////////
    96120#include "MSequence.h"
     
    105129#include "MLogManip.h"
    106130
     131#include "MAstro.h"
    107132#include "MDirIter.h"
    108133
     
    110135
    111136using namespace std;
     137
     138MSequence::~MSequence()
     139{
     140    /*
     141    TExMapIter iter(&fFileNames);
     142
     143    Long_t key, val;
     144
     145    while (iter.Next(key, val))
     146        delete (TString*)val;
     147        */
     148}
     149
    112150
    113151// --------------------------------------------------------------------------
     
    134172}
    135173
    136 Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw) const
     174UInt_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw) const
    137175{
    138176    TString d(path);
     
    167205
    168206    return iter.GetNumEntries();
     207}
     208
     209// --------------------------------------------------------------------------
     210//
     211// Read the file fname as setup file for the sequence.
     212//
     213void MSequence::GetFileNames(TEnv &env, const TArrayI &arr)
     214{
     215    /*
     216    for (int i=0; i<arr.GetSize(); i++)
     217    {
     218        // Get run number
     219        const Int_t num = arr[i];
     220
     221        // Check if name already set
     222        if (fFileNames.GetValue(num))
     223            continue;
     224
     225        TString *str = new TString(env.GetValue(Form("%d", num), ""));
     226        fFileNames.Add(num, (Long_t)str);
     227        }
     228        */
     229}
     230
     231// --------------------------------------------------------------------------
     232//
     233// Get a file name corresponding to the run-number num, returns 0 if n/a
     234//
     235const char *MSequence::GetFileName(UInt_t num)
     236{
     237    return 0;
     238    /*
     239    TString *str = (TString*)fFileNames.GetValue(num);
     240    return str ? str->Data() : 0;*/
    169241}
    170242
     
    210282    str = env.GetValue("DatRuns", "");
    211283    Split(str, fDatRuns);
     284
     285    GetFileNames(env, fRuns);
     286    GetFileNames(env, fCalRuns);
     287    GetFileNames(env, fPedRuns);
     288    GetFileNames(env, fDatRuns);
    212289}
    213290
     
    260337// Return the number of files added.
    261338//
    262 Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
     339UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
    263340{
    264341    return SetupRuns(iter, fPedRuns, path, id, raw);
     
    273350// Return the number of files added.
    274351//
    275 Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
     352UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
    276353{
    277354    return SetupRuns(iter, fDatRuns, path, id, raw);
     
    286363// Return the number of files added.
    287364//
    288 Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
     365UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
    289366{
    290367    return SetupRuns(iter, fRuns, path, id, raw);
     
    299376// Return the number of files added.
    300377//
    301 Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
     378UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, char *id, Bool_t raw) const
    302379{
    303380    return SetupRuns(iter, fCalRuns, path, id, raw);
    304381}
     382
     383// --------------------------------------------------------------------------
     384//
     385// If you want to add runs manually, use this function.
     386//
     387UInt_t MSequence::AddRuns(UInt_t first, UInt_t last, TArrayI *runs)
     388{
     389    if (last<first)
     390    {
     391        *fLog << warn << "MSequence::AddRuns - WARNING: Last runnumber " << last;
     392        *fLog << " smaller than first " << first << "... ignored." << endl;
     393        return 0;
     394    }
     395    if (!IsValid())
     396    {
     397        *fLog << inf << "Setting Sequence number to #" << first << endl;
     398        fSequence = first;
     399    }
     400
     401    const UInt_t nall = fRuns.GetSize();
     402    const UInt_t nrun = runs ? runs->GetSize() : 0;
     403    const UInt_t add  = last-first+1;
     404
     405    fRuns.Set(nall+add);
     406    if (runs)
     407        runs->Set(nrun+add);
     408
     409    for (UInt_t i=0; i<add; i++)
     410    {
     411        fRuns[nall+i] = first+i;
     412        if (runs)
     413            (*runs)[nrun+i]  = first+i;
     414    }
     415    return add;
     416}
     417
     418// --------------------------------------------------------------------------
     419//
     420// If you want to change or set the night manually.
     421// The Format is
     422//     SetNight("yyyy-mm-dd");
     423//
     424void MSequence::SetNight(const char *txt)
     425{
     426    TString night(txt);
     427    night += " 00:00:00";
     428    fNight.SetSqlDateTime(night);
     429
     430    fPeriod = MAstro::GetMagicPeriod(fNight.GetMjd());
     431}
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r6189 r6591  
    44#ifndef ROOT_TArrayI
    55#include <TArrayI.h>
     6#endif
     7
     8#ifndef ROOT_TExMap
     9#include <TExMap.h>
    610#endif
    711
     
    3539    TArrayI fDatRuns;
    3640
     41    //TExMap fFileNames;
     42
    3743    void Split(TString &runs, TArrayI &data) const;
    38     Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw=kFALSE) const;
     44    void GetFileNames(TEnv &env, const TArrayI &arr);
     45
     46    const char *GetFileName(UInt_t num);
     47
     48    UInt_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, char *id, Bool_t raw=kFALSE) const;
     49    UInt_t AddRuns(UInt_t first, UInt_t last, TArrayI *runs);
    3950
    4051public:
     
    4859        fRuns(s.fRuns), fCalRuns(s.fCalRuns), fPedRuns(s.fPedRuns),
    4960        fDatRuns(s.fDatRuns) { }
     61    ~MSequence();
    5062
     63    // TObject
    5164    void Print(Option_t *o="") const;
    5265
     66    // Genaral interface
    5367    Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
    5468
    55     Int_t SetupPedRuns(MDirIter &iter, const char *path=0, char *id="P", Bool_t raw=kFALSE) const;
    56     Int_t SetupDatRuns(MDirIter &iter, const char *path=0, char *id="D", Bool_t raw=kFALSE) const;
    57     Int_t SetupAllRuns(MDirIter &iter, const char *path=0, char *id="?", Bool_t raw=kFALSE) const;
    58     Int_t SetupCalRuns(MDirIter &iter, const char *path=0, char *id="C", Bool_t raw=kFALSE) const;
    59 
    60     Int_t GetNumAllRuns() const { return fRuns.GetSize(); }
    61     Int_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
    62     Int_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
    63     Int_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
     69    UInt_t SetupPedRuns(MDirIter &iter, const char *path=0, char *id="P", Bool_t raw=kFALSE) const;
     70    UInt_t SetupDatRuns(MDirIter &iter, const char *path=0, char *id="D", Bool_t raw=kFALSE) const;
     71    UInt_t SetupAllRuns(MDirIter &iter, const char *path=0, char *id="?", Bool_t raw=kFALSE) const;
     72    UInt_t SetupCalRuns(MDirIter &iter, const char *path=0, char *id="C", Bool_t raw=kFALSE) const;
    6473
    6574    // Getter
     75    UInt_t GetNumAllRuns() const { return fRuns.GetSize(); }
     76    UInt_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
     77    UInt_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
     78    UInt_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
     79
    6680    UInt_t GetSequence() const { return fSequence; }
    6781    UInt_t GetLastRun() const  { return fLastRun; }
     
    7993    const TString &GetSource() const { return fSource; }
    8094
     95    // Setter
     96    void SetNight(const char*night);
     97
     98    UInt_t AddRuns(UInt_t first, UInt_t last)    { return MSequence::AddRuns(first, last, 0); }
     99    UInt_t AddCalRuns(UInt_t first, UInt_t last) { return MSequence::AddRuns(first, last, &fCalRuns); }
     100    UInt_t AddPedRuns(UInt_t first, UInt_t last) { return MSequence::AddRuns(first, last, &fPedRuns); }
     101    UInt_t AddDatRuns(UInt_t first, UInt_t last) { return MSequence::AddRuns(first, last, &fDatRuns); }
     102
     103    UInt_t AddRuns(UInt_t num)    { return AddRuns(num, num); }
     104    UInt_t AddCalRuns(UInt_t num) { return AddCalRuns(num, num); }
     105    UInt_t AddPedRuns(UInt_t num) { return AddPedRuns(num, num); }
     106    UInt_t AddDatRuns(UInt_t num) { return AddDatRuns(num, num); }
     107
    81108    ClassDef(MSequence, 0)
    82109};
Note: See TracChangeset for help on using the changeset viewer.