Ignore:
Timestamp:
12/20/03 13:46:17 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MArgs.cc

    r2529 r2728  
    3030// This is a helper class for executables to parse command line arguments
    3131//
     32// Arguments beginning with a trailing '-' are called 'options'.
     33// Arguments without a trailing '-' are considered 'arguments'
     34//
    3235//////////////////////////////////////////////////////////////////////////////
    3336#include "MArgs.h"
     
    8285// --------------------------------------------------------------------------
    8386//
    84 // Print all arguments parsed.
     87// Print everything parsed.
     88// Using 'options' as option only 'options' are printed.
     89// Using 'arguments' as option only 'arguments' are printed.
    8590//
    8691void MArgs::Print(const Option_t *o) const
    8792{
    8893    gLog << all << underline << fName << ":" << endl;
     94
     95    const TString str(o);
     96
     97    if (!str.CompareTo("options", TString::kIgnoreCase))
     98    {
     99        TIter Next(fArgv);
     100        TString *s = NULL;
     101        while ((s=dynamic_cast<TString*>(Next())))
     102            if (s->BeginsWith("-"))
     103                gLog << *s << endl;
     104        return;
     105    }
     106
     107    if (!str.CompareTo("arguments", TString::kIgnoreCase))
     108    {
     109        TIter Next(fArgv);
     110        TString *s = NULL;
     111        while ((s=dynamic_cast<TString*>(Next())))
     112            if (!s->BeginsWith("-"))
     113                gLog << *s << endl;
     114        return;
     115    }
     116
    89117    fArgv->Print();
    90118}
     
    246274// --------------------------------------------------------------------------
    247275//
     276// return the number of arguments with a trainling '-'
     277//
     278Int_t MArgs::GetNumOptions() const
     279{
     280    Int_t num = 0;
     281
     282    TIter Next(fArgv);
     283    TString *s = NULL;
     284    while ((s=dynamic_cast<TString*>(Next())))
     285        if (s->BeginsWith("-"))
     286            num++;
     287
     288    return num;
     289}
     290
     291// --------------------------------------------------------------------------
     292//
     293// return the total number of entries
     294//
     295Int_t MArgs::GetNumEntries() const
     296{
     297    return fArgv->GetSize();
     298}
     299
     300// --------------------------------------------------------------------------
     301//
    248302// Checks whether an argument beginning with 'n' is existing, eg:
    249303//  executable -value5
     
    259313    while ((s=dynamic_cast<TString*>(Next())))
    260314        if (s->BeginsWith(name))
     315            return kTRUE;
     316    return kFALSE;
     317}
     318
     319// --------------------------------------------------------------------------
     320//
     321// Checks whether an argument beginning with 'n' is existing, eg:
     322//  executable -value5
     323//   HasOption("-value") will return false
     324//  executable -value
     325//   HasOption("-value") will return true
     326//
     327Bool_t MArgs::HasOnly(const TString n) const
     328{
     329    const TString name = n.Strip(TString::kBoth);
     330
     331    TIter Next(fArgv);
     332    TString *s = NULL;
     333    while ((s=dynamic_cast<TString*>(Next())))
     334        if (*s==name)
    261335            return kTRUE;
    262336    return kFALSE;
     
    284358    return kFALSE;
    285359}
     360
     361// --------------------------------------------------------------------------
     362//
     363// Checks whether an argument beginning with 'n' is exists and a
     364// corresponding option is available, eg.
     365//  executable -value5
     366//  HasOption("-value") will return false
     367// but:
     368//  executable -value
     369//  HasOption("-value") will return true
     370//
     371// The argument is removed from the internal list.
     372//
     373Bool_t MArgs::HasOnlyAndRemove(const TString n)
     374{
     375    const TString name = n.Strip(TString::kBoth);
     376
     377    TIter Next(fArgv);
     378    TString *s = NULL;
     379    while ((s=dynamic_cast<TString*>(Next())))
     380        if (*s==name)
     381        {
     382            delete fArgv->Remove(dynamic_cast<TObject*>(s));
     383            return kTRUE;
     384        }
     385
     386    return kFALSE;
     387}
  • trunk/MagicSoft/Mars/mbase/MArgs.h

    r2529 r2728  
    4747    TString  GetStringAndRemove(const TString name);
    4848
    49     Bool_t Has(const TString name) const;
    50     Bool_t HasOption(const TString name) const;
     49    Bool_t   Has(const TString name) const;
     50    Bool_t   HasOnly(const TString name) const;
     51    Bool_t   HasOption(const TString name) const;
     52    Bool_t   HasOnlyAndRemove(const TString name);
    5153
    52     TString GetArgumentStr(Int_t i) const;
    53     Int_t   GetArgumentInt(Int_t i) const;
    54     Float_t GetArgumentFloat(Int_t i) const;
    55     Int_t   GetNumArguments() const;
     54    TString  GetArgumentStr(Int_t i) const;
     55    Int_t    GetArgumentInt(Int_t i) const;
     56    Float_t  GetArgumentFloat(Int_t i) const;
     57    Int_t    GetNumArguments() const;
     58    Int_t    GetNumOptions() const;
     59    Int_t    GetNumEntries() const;
    5660
    5761    ClassDef(MArgs, 0)  //Class to parse command line arguments
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r2490 r2728  
    2525
    2626//////////////////////////////////////////////////////////////////////////////
    27 //                                                                          //
    28 // MEvtLoop                                                                 //
    29 //                                                                          //
    30 // This class is the core of each event processing.                         //
    31 // First you must set the parameter list to use. The parameter list         //
    32 // must contain the task list (MTaskList) to use. The name of the task      //
    33 // list can be specified if you call Eventloop. The standard name is        //
    34 // "MTaskList". The name you specify must match the name of the MTaskList   //
    35 // object.                                                                  //
    36 //                                                                          //
    37 // If you call Eventloop() first all PreProcess functions - with the        //
    38 // parameter list as an argument - of the tasks in the task list are        //
    39 // executed. If one of them returns kFALSE then the execution is stopped.   //
    40 // If the preprocessing was ok, The Process function of the tasks are       //
    41 // executed as long as one function returns kSTOP. Only the tasks which     //
    42 // are marked as "All" or with a string which matches the MInputStreamID    //
    43 // of MTaskList are executed. If one tasks returns kCONTINUE the pending    //
    44 // tasks in the list are skipped and the execution in continued with        //
    45 // the first one in the list.                                               //
    46 // Afterwards the PostProcess functions are executed.                       //
    47 //                                                                          //
    48 // If you want to display the progress in a gui you can use SetProgressBar  //
    49 // and a TGProgressBar or a MProgressBar. If you set a MStatusDisplay       //
    50 // using SetDisplay, the Progress bar from this display is used.            //
    51 //                                                                          //
    52 // You can create a macro from a completely setup eventloop by:             //
    53 //   evtloop.MakeMacro("mymacro.C");                                        //
    54 //                                                                          //
    55 // You will always need to check the macro, it will not run, but it         //
    56 // should have al important information.                                    //
    57 //                                                                          //
    58 //                                                                          //
    59 // You can also write all this information to a root file:                  //
    60 //   TFile file("myfile.root");                                             //
    61 //   evtloop.Write("MyEvtloopKey");                                         //
    62 //                                                                          //
    63 // You can afterwards read the information from an open file by:            //
    64 //   evtloop.Read("MyEvtloopKey");                                          //
    65 //                                                                          //
    66 // To lookup the information write it to a file using MakeMacro             //
    67 //                                                                          //
     27//
     28// MEvtLoop
     29//
     30// This class is the core of each event processing.
     31// First you must set the parameter list to use. The parameter list
     32// must contain the task list (MTaskList) to use. The name of the task
     33// list can be specified if you call Eventloop. The standard name is
     34// "MTaskList". The name you specify must match the name of the MTaskList
     35// object.
     36//
     37// If you call Eventloop() first all PreProcess functions - with the
     38// parameter list as an argument - of the tasks in the task list are
     39// executed. If one of them returns kFALSE then the execution is stopped.
     40// If the preprocessing was ok, The Process function of the tasks are
     41// executed as long as one function returns kSTOP. Only the tasks which
     42// are marked as "All" or with a string which matches the MInputStreamID
     43// of MTaskList are executed. If one tasks returns kCONTINUE the pending
     44// tasks in the list are skipped and the execution in continued with
     45// the first one in the list.
     46// Afterwards the PostProcess functions are executed.
     47//
     48// If you want to display the progress in a gui you can use SetProgressBar
     49// and a TGProgressBar or a MProgressBar. If you set a MStatusDisplay
     50// using SetDisplay, the Progress bar from this display is used.
     51//
     52// You can create a macro from a completely setup eventloop by:
     53//   evtloop.MakeMacro("mymacro.C");
     54//
     55// You will always need to check the macro, it will not run, but it
     56// should have al important information.
     57//
     58//
     59// You can also write all this information to a root file:
     60//   TFile file("myfile.root");
     61//   evtloop.Write("MyEvtloopKey");
     62//
     63// You can afterwards read the information from an open file by:
     64//   evtloop.Read("MyEvtloopKey");
     65//
     66// To lookup the information write it to a file using MakeMacro
     67//
    6868//////////////////////////////////////////////////////////////////////////////
    6969#include "MEvtLoop.h"
     
    393393// for developers or use in special jobs only!
    394394//
    395 Int_t MEvtLoop::Process(Int_t maxcnt)
     395Int_t MEvtLoop::Process(UInt_t maxcnt)
    396396{
    397397    if (!fTaskList)
     
    404404    *fLog << all <<"Eventloop running (";
    405405
    406     if (maxcnt<0)
     406    if (maxcnt==0)
    407407        *fLog << "all";
    408408    else
     
    411411    *fLog << " events)..." << flush;
    412412
    413     Int_t entries = INT_MAX;
     413    UInt_t entries = kMaxUInt;
    414414    fNumEvents = 0;
    415415
     
    420420
    421421#ifdef __MARS__
    422         // limits.h
    423422        MRead *read = (MRead*)fTaskList->FindObject("MRead");
    424423        if (read && read->GetEntries()>0)
     
    429428            fNumEvents = TMath::Min(maxcnt, entries);
    430429        else
    431             if (entries!=INT_MAX)
     430            if (entries!=kMaxUInt)
    432431                fNumEvents = entries;
    433432    }
     
    439438    }
    440439
    441     Int_t dummy = maxcnt<0 ? 0 : maxcnt;
    442 
    443440    //
    444441    // start a stopwatch
     
    449446    //
    450447    // This is the MAIN EVENTLOOP which processes the data
    451     // if maxcnt<0 the number of processed events is counted
     448    // if maxcnt==0 the number of processed events is counted
    452449    // else only maxcnt events are processed
    453450    //
    454     Int_t numcnts = 0;
     451    UInt_t numcnts = 0;
     452    UInt_t dummy   = maxcnt;
    455453
    456454    Int_t rc = kTRUE;
    457     if (maxcnt<0)
     455    if (maxcnt==0)
    458456        // process first and increment if sucessfull
    459457        while ((rc=fTaskList->Process())==kTRUE)
     
    529527// See class description above. Returns kTRUE if PreProcessing,
    530528// Processing and PostProcessing was successfull, otherwise kFALSE.
    531 //
    532 Bool_t MEvtLoop::Eventloop(Int_t maxcnt, const char *tlist)
     529// maxcnt==0 means: all events
     530// tlist is the name of the task-list to be used. Be carefull, this
     531// feature is not finally implemented - it will only work if no
     532// task will access the tasklist.
     533//
     534Bool_t MEvtLoop::Eventloop(UInt_t maxcnt, const char *tlist)
    533535{
    534536    TDatime d;
    535537    *fLog << inf << underline << "Eventloop: " << fName << " started at " << d.AsString() << endl;
    536538
    537     Bool_t rc = PreProcess();
     539    Bool_t rc = PreProcess(tlist);
    538540
    539541    //
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r2490 r2728  
    6363
    6464    Bool_t PreProcess(const char *tlist="MTaskList");
    65     Int_t  Process(Int_t maxcnt);
     65    Int_t  Process(UInt_t maxcnt);
    6666    Bool_t PostProcess() const;
    6767
    68     Bool_t Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
     68    Bool_t Eventloop(UInt_t maxcnt=0, const char *tlist="MTaskList");
    6969
    7070    void MakeMacro(const char *filename="evtloop.C");
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r2678 r2728  
    2727// MTime
    2828//
    29 // A generalized MARS time stamp
     29// A generalized MARS time stamp.
    3030//
    3131// WARNING: Be carefull changing this class. It is also used in the
    3232//          MAGIC drive software cosy!
     33//
     34// Remarke: If you encounter strange behaviour, check the casting.
     35//          Note, that on Linux machines ULong_t and UInt_t is the same.
    3336//
    3437// Version 1:
     
    206209
    207210    fMjd = mjd+1;
     211}
     212
     213// --------------------------------------------------------------------------
     214//
     215// Update the magic time. Make sure, that the MJD is set correctly.
     216// It must be the MJD of the corresponding night. You can set it
     217// by Set(2003, 12, 24);
     218//
     219// It is highly important, that the time correspoding to the night is
     220// between 13:00:00.0 (day of dawning) and 12:59:59.999 (day of sunrise)
     221//
     222Bool_t MTime::UpdMagicTime(Byte_t h, Byte_t m, Byte_t s, UShort_t ms)
     223{
     224    if (h>23 || m>59 || s>59 || ms>999)
     225         return kFALSE;
     226
     227    const ULong_t tm = ((((h*60+m)*60)+s)*1000)+ms;
     228
     229    fTime = (Long_t)(tm < kHour*13 ? tm  : tm-kDay); // day of sunrise?
     230    //fNanoSec = ns;
     231
     232    return kTRUE;
     233
    208234}
    209235
  • trunk/MagicSoft/Mars/mbase/MTime.h

    r2636 r2728  
    2626class MTime : public MParContainer
    2727{
    28 private:
     28public:
    2929    static const UInt_t kHour; // [ms] one hour
    3030    static const UInt_t kDay;  // [ms] one day
    3131
     32private:
    3233    UInt_t fMjd;     // [d]  Day in the century        (Day of sun rise)
    3334    TTime  fTime;    // [ms] Time of Day               (-11h<=x<13h)
     
    7475
    7576    Bool_t   Set(UInt_t mjd, ULong_t ms, UInt_t ns=0);
    76     Bool_t   Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h, Byte_t min, Byte_t s, UShort_t ms, UInt_t ns=0);
     77    Bool_t   Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h=13, Byte_t min=0, Byte_t s=0, UShort_t ms=0, UInt_t ns=0);
    7778    void     Set(const struct timeval &tv);
    7879    void     SetCT1Time(UInt_t mjd, UInt_t t1, UInt_t t0);
     80    Bool_t   UpdMagicTime(Byte_t h, Byte_t m, Byte_t s, UShort_t ms);
    7981    void     SetMjd(Double_t m);
    8082    Double_t GetMjd() const;
Note: See TracChangeset for help on using the changeset viewer.