Changeset 5911 for trunk/MagicSoft/Mars/mfbase
- Timestamp:
- 01/20/05 14:27:59 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mfbase
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.