Changeset 5911


Ignore:
Timestamp:
01/20/05 14:27:59 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5903 r5911  
    2020
    2121                                                 -*-*- 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
    2244
    2345 2005/01/19 Thomas Bretz
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r5836 r5911  
    972972    fLog->ReadEnv(env, prefix, print);
    973973
     974    if (!fParList)
     975    {
     976        *fLog << warn << "WARNING - No parameter list to propagate resources to." << endl;
     977        return kTRUE;
     978    }
     979
    974980    if (fParList->ReadEnv(env, prefix, print)==kERROR)
    975981    {
     
    986992// If 'config=0' kTRUE is returned.
    987993//
    988 Bool_t MEvtLoop::ReadEnv(const char *config)
     994Bool_t MEvtLoop::ReadEnv(const char *config, Bool_t print)
    989995{
    990996    if (!config)
     
    9981004    }
    9991005
    1000     return ReadEnv(TEnv(config));
     1006    return ReadEnv(TEnv(config), "", print);
    10011007}
    10021008
     
    10331039    *fLog << inf << "Writing resources: " << prefix /*TEnv::fRcName << " to " << env.GetRcName()*/ << endl;
    10341040
     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
    10351050    if (fParList->WriteEnv(env, prefix, print)!=kTRUE)
    10361051    {
     
    10381053        return kFALSE;
    10391054    }
    1040 
    1041     fLog->WriteEnv(env, prefix, print);
    10421055
    10431056    return kTRUE;
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r5832 r5911  
    8585    Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
    8686
    87     Bool_t ReadEnv(const char *config);
     87    Bool_t ReadEnv(const char *config, Bool_t print=kFALSE);
    8888
    8989    void RecursiveRemove(TObject *obj);
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r4828 r5911  
    911911{
    912912    if (print)
    913         *fLog << all << "MParList::ReadEnv: " << prefix << " (" << (int)print << ")" << endl;
     913        *fLog << all << "MParList::ReadEnv: " << prefix << endl;
    914914
    915915    MParContainer *cont = NULL;
  • trunk/MagicSoft/Mars/mfbase/MF.cc

    r5883 r5911  
    350350    if (!fF)
    351351    {
     352        if (IsAllowEmpty())
     353            return kTRUE;
     354
    352355        *fLog << err << dbginf << "No filter rule available." << endl;
    353356        return kFALSE;
     
    370373Int_t MF::Process()
    371374{
    372     return fF->CallProcess();
     375    return fF ? fF->CallProcess() : kTRUE;
    373376}
    374377
     
    379382Int_t MF::PostProcess()
    380383{
    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
    387391//
    388392Bool_t MF::IsExpressionTrue() const
    389393{
    390     return fF->IsConditionTrue();
     394    return fF ? fF->IsConditionTrue() : kTRUE;
    391395}
    392396
     
    398402TString MF::GetDataMember() const
    399403{
    400     return fF->GetDataMember();
     404    return fF ? fF->GetDataMember() : "";
    401405}
    402406
     
    422426}
    423427
     428// --------------------------------------------------------------------------
     429//
     430// Print the rule.
     431// if now filter is set up '<n/a>' is printed.
     432//
    424433void MF::Print(Option_t *opt) const
    425434{
    426435    *fLog << all << underline << GetDescriptor() << endl;
    427     fF->Print();
     436    if (fF)
     437        fF->Print();
     438    else
     439        *fLog << "<n/a>";
    428440    *fLog << endl << endl;
    429441}
     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//
     470Int_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  
    3232    void StreamPrimitive(ofstream &out) const;
    3333
     34    enum { kAllowEmpty = BIT(14) };
     35
    3436public:
    3537    MF();
     
    3739    ~MF();
    3840
     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
    3946    TString GetRule() const { return fF ? fF->GetRule() : MFilter::GetRule(); }
    4047    TString GetDataMember() const;
     
    4249    Bool_t IsExpressionTrue() const;
    4350
     51    // MTask
    4452    Int_t PreProcess(MParList *pList);
    4553    Int_t Process();
    4654    Int_t PostProcess();
    4755
     56    // TObject
    4857    void Print(Option_t *opt="") const;
    4958
     59    // MParContainer
    5060    void SetVariables(const TArrayD &arr) { if (fF) fF->SetVariables(arr); }
     61    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    5162
    5263    ClassDef(MF, 0) // A Filter for cuts in any data member
  • trunk/MagicSoft/Mars/mfbase/MFilterList.cc

    r5875 r5911  
    439439}
    440440
    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//
    442447void MFilterList::SetVariables(const TArrayD &arr)
    443448{
Note: See TracChangeset for help on using the changeset viewer.