Ignore:
Timestamp:
01/24/05 11:07:29 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mdata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mdata/MDataChain.cc

    r5832 r5956  
    749749    return fMember->SetVariables(arr);
    750750}
     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//
     776Int_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  
    1717{
    1818private:
    19     MData    *fMember; // Filter
     19    MData *fMember; // Filter
    2020
    2121    // PLEASE, always add new enums to the end of the enumeration,
     
    5454    ~MDataChain();
    5555
     56    // MData
    5657    Double_t GetValue() const;
    57     Bool_t PreProcess(const MParList *plist);
    5858
    5959    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);
    6361
    6462    TString GetRule() const;
    6563    TString GetDataMember() const;
    6664
     65    // MParContainer
     66    Bool_t IsReadyToSave() const;
    6767    void SetVariables(const TArrayD &arr);
     68    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    6869
    6970    ClassDef(MDataChain, 1) // A chain/concatenation of MData objects
Note: See TracChangeset for help on using the changeset viewer.