Changeset 2728 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 12/20/03 13:46:17 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MArgs.cc
r2529 r2728 30 30 // This is a helper class for executables to parse command line arguments 31 31 // 32 // Arguments beginning with a trailing '-' are called 'options'. 33 // Arguments without a trailing '-' are considered 'arguments' 34 // 32 35 ////////////////////////////////////////////////////////////////////////////// 33 36 #include "MArgs.h" … … 82 85 // -------------------------------------------------------------------------- 83 86 // 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. 85 90 // 86 91 void MArgs::Print(const Option_t *o) const 87 92 { 88 93 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 89 117 fArgv->Print(); 90 118 } … … 246 274 // -------------------------------------------------------------------------- 247 275 // 276 // return the number of arguments with a trainling '-' 277 // 278 Int_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 // 295 Int_t MArgs::GetNumEntries() const 296 { 297 return fArgv->GetSize(); 298 } 299 300 // -------------------------------------------------------------------------- 301 // 248 302 // Checks whether an argument beginning with 'n' is existing, eg: 249 303 // executable -value5 … … 259 313 while ((s=dynamic_cast<TString*>(Next()))) 260 314 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 // 327 Bool_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) 261 335 return kTRUE; 262 336 return kFALSE; … … 284 358 return kFALSE; 285 359 } 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 // 373 Bool_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 47 47 TString GetStringAndRemove(const TString name); 48 48 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); 51 53 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; 56 60 57 61 ClassDef(MArgs, 0) //Class to parse command line arguments -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r2490 r2728 25 25 26 26 ////////////////////////////////////////////////////////////////////////////// 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 // 68 68 ////////////////////////////////////////////////////////////////////////////// 69 69 #include "MEvtLoop.h" … … 393 393 // for developers or use in special jobs only! 394 394 // 395 Int_t MEvtLoop::Process( Int_t maxcnt)395 Int_t MEvtLoop::Process(UInt_t maxcnt) 396 396 { 397 397 if (!fTaskList) … … 404 404 *fLog << all <<"Eventloop running ("; 405 405 406 if (maxcnt <0)406 if (maxcnt==0) 407 407 *fLog << "all"; 408 408 else … … 411 411 *fLog << " events)..." << flush; 412 412 413 Int_t entries = INT_MAX;413 UInt_t entries = kMaxUInt; 414 414 fNumEvents = 0; 415 415 … … 420 420 421 421 #ifdef __MARS__ 422 // limits.h423 422 MRead *read = (MRead*)fTaskList->FindObject("MRead"); 424 423 if (read && read->GetEntries()>0) … … 429 428 fNumEvents = TMath::Min(maxcnt, entries); 430 429 else 431 if (entries!= INT_MAX)430 if (entries!=kMaxUInt) 432 431 fNumEvents = entries; 433 432 } … … 439 438 } 440 439 441 Int_t dummy = maxcnt<0 ? 0 : maxcnt;442 443 440 // 444 441 // start a stopwatch … … 449 446 // 450 447 // This is the MAIN EVENTLOOP which processes the data 451 // if maxcnt <0 the number of processed events is counted448 // if maxcnt==0 the number of processed events is counted 452 449 // else only maxcnt events are processed 453 450 // 454 Int_t numcnts = 0; 451 UInt_t numcnts = 0; 452 UInt_t dummy = maxcnt; 455 453 456 454 Int_t rc = kTRUE; 457 if (maxcnt <0)455 if (maxcnt==0) 458 456 // process first and increment if sucessfull 459 457 while ((rc=fTaskList->Process())==kTRUE) … … 529 527 // See class description above. Returns kTRUE if PreProcessing, 530 528 // 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 // 534 Bool_t MEvtLoop::Eventloop(UInt_t maxcnt, const char *tlist) 533 535 { 534 536 TDatime d; 535 537 *fLog << inf << underline << "Eventloop: " << fName << " started at " << d.AsString() << endl; 536 538 537 Bool_t rc = PreProcess( );539 Bool_t rc = PreProcess(tlist); 538 540 539 541 // -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r2490 r2728 63 63 64 64 Bool_t PreProcess(const char *tlist="MTaskList"); 65 Int_t Process( Int_t maxcnt);65 Int_t Process(UInt_t maxcnt); 66 66 Bool_t PostProcess() const; 67 67 68 Bool_t Eventloop( Int_t maxcnt=-1, const char *tlist="MTaskList");68 Bool_t Eventloop(UInt_t maxcnt=0, const char *tlist="MTaskList"); 69 69 70 70 void MakeMacro(const char *filename="evtloop.C"); -
trunk/MagicSoft/Mars/mbase/MTime.cc
r2678 r2728 27 27 // MTime 28 28 // 29 // A generalized MARS time stamp 29 // A generalized MARS time stamp. 30 30 // 31 31 // WARNING: Be carefull changing this class. It is also used in the 32 32 // 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. 33 36 // 34 37 // Version 1: … … 206 209 207 210 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 // 222 Bool_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 208 234 } 209 235 -
trunk/MagicSoft/Mars/mbase/MTime.h
r2636 r2728 26 26 class MTime : public MParContainer 27 27 { 28 p rivate:28 public: 29 29 static const UInt_t kHour; // [ms] one hour 30 30 static const UInt_t kDay; // [ms] one day 31 31 32 private: 32 33 UInt_t fMjd; // [d] Day in the century (Day of sun rise) 33 34 TTime fTime; // [ms] Time of Day (-11h<=x<13h) … … 74 75 75 76 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); 77 78 void Set(const struct timeval &tv); 78 79 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); 79 81 void SetMjd(Double_t m); 80 82 Double_t GetMjd() const;
Note:
See TracChangeset
for help on using the changeset viewer.