Changeset 5956 for trunk/MagicSoft/Mars/mdata
- Timestamp:
- 01/24/05 11:07:29 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mdata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mdata/MDataChain.cc
r5832 r5956 749 749 return fMember->SetVariables(arr); 750 750 } 751 752 // -------------------------------------------------------------------------- 753 // 754 // Check for corresponding entries in resource file and setup data chain. 755 // 756 // Assuming your MDataChain is called (Set/GetName): MyData 757 // 758 // Now setup the condition, eg: 759 // MyData.Rule: log10(MHillas.fSize) 760 // or 761 // MyData.Rule: log10(MHillas.fSize) - 4.1 762 // 763 // If you want to use more difficult rules you can split the 764 // condition into subrules. Subrules are identified 765 // by {}-brackets. Avoid trailing 0's! For example: 766 // 767 // MyData.Rule: log10(MHillas.fSize) + {0} - {1} 768 // MyData.0: 5.5*MHillas.fSize 769 // MyData.1: 2.3*log10(MHillas.fSize) 770 // 771 // The numbering must be continous and start with 0. You can use 772 // a subrules more than once. All {}-brackets are simply replaced 773 // by the corresponding conditions. The rules how conditions can 774 // be written can be found in the class description of MDataChain. 775 // 776 Int_t MDataChain::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 777 { 778 Bool_t rc = kFALSE; 779 if (!IsEnvDefined(env, prefix, "Rule", print)) 780 return rc; 781 782 TString rule = GetEnvValue(env, prefix, "Rule", ""); 783 rule.ReplaceAll(" ", ""); 784 785 Int_t idx=0; 786 while (1) 787 { 788 TString cond; 789 if (IsEnvDefined(env, prefix, Form("%d", idx), print)) 790 { 791 cond += "("; 792 cond += GetEnvValue(env, prefix, Form("%d", idx), ""); 793 cond += ")"; 794 } 795 796 if (cond.IsNull()) 797 break; 798 799 rule.ReplaceAll(Form("{%d}", idx), cond); 800 idx++; 801 } 802 803 if (fMember) 804 { 805 delete fMember; 806 fMember = 0; 807 } 808 809 if (rule.IsNull()) 810 { 811 *fLog << warn << "MDataChain::ReadEnv - ERROR: Empty rule found." << endl; 812 return kERROR; 813 } 814 815 if (!(fMember=ParseString(rule, 1))) 816 { 817 *fLog << err << "MDataChain::ReadEnv - ERROR: Parsing '" << rule << "' failed." << endl; 818 return kERROR; 819 } 820 821 if (print) 822 { 823 *fLog << inf << "found: "; 824 fMember->Print(); 825 *fLog << endl; 826 } 827 828 return kTRUE; 829 } -
trunk/MagicSoft/Mars/mdata/MDataChain.h
r3788 r5956 17 17 { 18 18 private: 19 MData 19 MData *fMember; // Filter 20 20 21 21 // PLEASE, always add new enums to the end of the enumeration, … … 54 54 ~MDataChain(); 55 55 56 // MData 56 57 Double_t GetValue() const; 57 Bool_t PreProcess(const MParList *plist);58 58 59 59 Bool_t IsValid() const { return fMember ? kTRUE : kFALSE; } 60 Bool_t IsReadyToSave() const; 61 62 // void Print(Option_t *opt = "") const; 60 Bool_t PreProcess(const MParList *plist); 63 61 64 62 TString GetRule() const; 65 63 TString GetDataMember() const; 66 64 65 // MParContainer 66 Bool_t IsReadyToSave() const; 67 67 void SetVariables(const TArrayD &arr); 68 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 68 69 69 70 ClassDef(MDataChain, 1) // A chain/concatenation of MData objects
Note:
See TracChangeset
for help on using the changeset viewer.