Changeset 5911
- Timestamp:
- 01/20/05 14:27:59 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r5903 r5911 20 20 21 21 -*-*- END OF LINE -*-*- 22 23 2005/01/20 Thomas Bretz 24 25 * mbase/MContinue.[h,cc]: 26 - added ReadEnv member function to support resource files 27 28 * mbase/MEvtLoop.[h,cc]: 29 - added a second arguemtn to reading of the resource file by name 30 - added some checks when reding the resource file and the 31 parameter list hasn't been setup 32 33 * mbase/MParList.cc: 34 - removed an obsolete output from ReadEnv 35 36 * mfbase/MF.[h,cc]: 37 - added ReadEnv member function to support resource files 38 - added kAllowEpty flag to support skipping by resource files 39 40 * mfbase/MFilterList.cc: 41 - added a comment 42 43 22 44 23 45 2005/01/19 Thomas Bretz -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r5836 r5911 972 972 fLog->ReadEnv(env, prefix, print); 973 973 974 if (!fParList) 975 { 976 *fLog << warn << "WARNING - No parameter list to propagate resources to." << endl; 977 return kTRUE; 978 } 979 974 980 if (fParList->ReadEnv(env, prefix, print)==kERROR) 975 981 { … … 986 992 // If 'config=0' kTRUE is returned. 987 993 // 988 Bool_t MEvtLoop::ReadEnv(const char *config )994 Bool_t MEvtLoop::ReadEnv(const char *config, Bool_t print) 989 995 { 990 996 if (!config) … … 998 1004 } 999 1005 1000 return ReadEnv(TEnv(config) );1006 return ReadEnv(TEnv(config), "", print); 1001 1007 } 1002 1008 … … 1033 1039 *fLog << inf << "Writing resources: " << prefix /*TEnv::fRcName << " to " << env.GetRcName()*/ << endl; 1034 1040 1041 fLog->WriteEnv(env, prefix, print); 1042 1043 if (!fParList) 1044 { 1045 *fLog << warn << "WARNING - No parameter list to get resources from." << endl; 1046 return kTRUE; 1047 } 1048 1049 1035 1050 if (fParList->WriteEnv(env, prefix, print)!=kTRUE) 1036 1051 { … … 1038 1053 return kFALSE; 1039 1054 } 1040 1041 fLog->WriteEnv(env, prefix, print);1042 1055 1043 1056 return kTRUE; -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r5832 r5911 85 85 Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const; 86 86 87 Bool_t ReadEnv(const char *config );87 Bool_t ReadEnv(const char *config, Bool_t print=kFALSE); 88 88 89 89 void RecursiveRemove(TObject *obj); -
trunk/MagicSoft/Mars/mbase/MParList.cc
r4828 r5911 911 911 { 912 912 if (print) 913 *fLog << all << "MParList::ReadEnv: " << prefix << " (" << (int)print << ")" <<endl;913 *fLog << all << "MParList::ReadEnv: " << prefix << endl; 914 914 915 915 MParContainer *cont = NULL; -
trunk/MagicSoft/Mars/mfbase/MF.cc
r5883 r5911 350 350 if (!fF) 351 351 { 352 if (IsAllowEmpty()) 353 return kTRUE; 354 352 355 *fLog << err << dbginf << "No filter rule available." << endl; 353 356 return kFALSE; … … 370 373 Int_t MF::Process() 371 374 { 372 return fF ->CallProcess();375 return fF ? fF->CallProcess() : kTRUE; 373 376 } 374 377 … … 379 382 Int_t MF::PostProcess() 380 383 { 381 return fF->CallPostProcess(); 382 } 383 384 // -------------------------------------------------------------------------- 385 // 386 // Return the result of the filter rule. 384 return fF ? fF->CallPostProcess() : kTRUE; 385 } 386 387 // -------------------------------------------------------------------------- 388 // 389 // Return the result of the filter rule. If no filter available the 390 // condition is always true 387 391 // 388 392 Bool_t MF::IsExpressionTrue() const 389 393 { 390 return fF ->IsConditionTrue();394 return fF ? fF->IsConditionTrue() : kTRUE; 391 395 } 392 396 … … 398 402 TString MF::GetDataMember() const 399 403 { 400 return fF ->GetDataMember();404 return fF ? fF->GetDataMember() : ""; 401 405 } 402 406 … … 422 426 } 423 427 428 // -------------------------------------------------------------------------- 429 // 430 // Print the rule. 431 // if now filter is set up '<n/a>' is printed. 432 // 424 433 void MF::Print(Option_t *opt) const 425 434 { 426 435 *fLog << all << underline << GetDescriptor() << endl; 427 fF->Print(); 436 if (fF) 437 fF->Print(); 438 else 439 *fLog << "<n/a>"; 428 440 *fLog << endl << endl; 429 441 } 442 443 // -------------------------------------------------------------------------- 444 // 445 // Check for corresponding entries in resource file and setup filters. 446 // 447 // Assuming your MF-filter is called (Set/GetName): MyFilter 448 // 449 // First you can setup whether the filter is inverted or not: 450 // MyFilter.Inverted: yes, no <default=no> 451 // 452 // Now setup the condition, eg: 453 // MyFilter.Condition: MHillas.fSize<1000 454 // or 455 // MyFilter.Condition: MHillas.fSize>500 && MHillas.fSize<10000 456 // 457 // If you want to use more difficult filters you can split the 458 // condition into subcondistions. Subcondistions are identified 459 // by {}-brackets. Avoid trailing 0's! For example: 460 // 461 // MyFilter.Condition: MHillas.fSize>500 && {0} && {1} 462 // MyFilter.0: MHillas.fSize>1000 463 // MyFilter.1: MHillas.fSize<10000 464 // 465 // The numbering must be continous and start with 0. You can use 466 // a subcondition more than once. All {}-brackets are simply replaced 467 // by the correspodning conditions. The rules how conditions can 468 // be written can be found in the class description of MF and MDataChain. 469 // 470 Int_t MF::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 471 { 472 Bool_t rc = kFALSE; 473 if (IsEnvDefined(env, prefix, "Inverted", print)) 474 { 475 rc = kTRUE; 476 SetInverted(GetEnvValue(env, prefix, "Inverted", IsInverted())); 477 } 478 479 if (!IsEnvDefined(env, prefix, "Condition", print)) 480 return rc; 481 482 TString rule = GetEnvValue(env, prefix, "Condition", ""); 483 rule.ReplaceAll(" ", ""); 484 485 Int_t idx=0; 486 while (1) 487 { 488 TString cond; 489 if (IsEnvDefined(env, prefix, Form("%d", idx), print)) 490 { 491 cond += "("; 492 cond += GetEnvValue(env, prefix, Form("%d", idx), ""); 493 cond += ")"; 494 } 495 496 if (cond.IsNull()) 497 break; 498 499 rule.ReplaceAll(Form("{%d}", idx), cond); 500 idx++; 501 } 502 503 if (fF) 504 { 505 delete fF; 506 fF = 0; 507 } 508 509 if (rule.IsNull()) 510 { 511 *fLog << warn << "MF::ReadEnv - WARNING: Empty condition found." << endl; 512 SetAllowEmpty(); 513 return kTRUE; 514 } 515 516 SetAllowEmpty(kFALSE); 517 518 if (!(fF=ParseString(rule, 1))) 519 { 520 *fLog << err << "MF::ReadEnv - ERROR: Parsing '" << rule << "' failed." << endl; 521 return kERROR; 522 } 523 524 if (print) 525 { 526 *fLog << inf << "found: "; 527 fF->Print(); 528 *fLog << endl; 529 } 530 531 return kTRUE; 532 } -
trunk/MagicSoft/Mars/mfbase/MF.h
r5875 r5911 32 32 void StreamPrimitive(ofstream &out) const; 33 33 34 enum { kAllowEmpty = BIT(14) }; 35 34 36 public: 35 37 MF(); … … 37 39 ~MF(); 38 40 41 // MF 42 void SetAllowEmpty(Bool_t b=kTRUE) { b ? SetBit(kAllowEmpty) : ResetBit(kAllowEmpty); } 43 Bool_t IsAllowEmpty() const { return TestBit(kAllowEmpty); } 44 45 // MFilter 39 46 TString GetRule() const { return fF ? fF->GetRule() : MFilter::GetRule(); } 40 47 TString GetDataMember() const; … … 42 49 Bool_t IsExpressionTrue() const; 43 50 51 // MTask 44 52 Int_t PreProcess(MParList *pList); 45 53 Int_t Process(); 46 54 Int_t PostProcess(); 47 55 56 // TObject 48 57 void Print(Option_t *opt="") const; 49 58 59 // MParContainer 50 60 void SetVariables(const TArrayD &arr) { if (fF) fF->SetVariables(arr); } 61 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 51 62 52 63 ClassDef(MF, 0) // A Filter for cuts in any data member -
trunk/MagicSoft/Mars/mfbase/MFilterList.cc
r5875 r5911 439 439 } 440 440 441 441 // -------------------------------------------------------------------------- 442 // 443 // Loop over all set filters and distribute arr to their SetVariables. 444 // Make sure, that the values are unique (not two filters using the 445 // same index in the array with different meanings) 446 // 442 447 void MFilterList::SetVariables(const TArrayD &arr) 443 448 {
Note:
See TracChangeset
for help on using the changeset viewer.