Changeset 9867 for trunk/Mars/mjoptim


Ignore:
Timestamp:
08/16/10 09:07:43 (14 years ago)
Author:
tbretz
Message:
Improved comments in MJOptimizeBase.
Location:
trunk/Mars/mjoptim
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mjoptim/MJOptimizeBase.cc

    r8643 r9867  
    1818!   Author(s): Thomas Bretz 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2005-2007
     20!   Copyright: MAGIC Software Development, 2005-2010
    2121!
    2222!
     
    3030//
    3131// The order when reading a file is:
    32 //   1) Execution of PreTasks  (set by user)
    33 //   2) Execution of PreCuts   (set by user)
     32//   1) Execution of PreTasks
     33//   2) Execution of PreCuts, TestCuts, TrainCuts
    3434//   3) Selector               (calculated from number of requested events)
    3535//   4) Splitter               (if sample is split automatically in test/train)
     
    3939// you calculate a vlue which is not needed for your PreCuts, you can
    4040// calculate it afterwards, which will speed up execution.
     41//
     42// void AddPreTask(MTask *t)
     43//    Add a task which is executed just after reading the events from the file
     44//    this can be any kind of task or even a task list. You can use dedicated
     45//    tasks performing some analysis, but also cuts (e.g. MContinue) or a
     46//    general task to evaluate new parameters (e.g. MParameterCalc)
     47//
     48// void AddPreTask(const char *rule, const char *name="MWeight")
     49//    This is a short cut to AddPreTask(MTask*) which will add a
     50//    MParameterCalc to the list evaluating the given rule and storing the
     51//    result in a MParameterD with the given name. For the default "MWeight",
     52//    for example, the value can later be accessed by MWeight.fVal.
     53//
     54// The same functions are available as
     55//    void AddPostTask(MTask *t)
     56//    void AddPostTask(const char *rule, const char *name="MWeight")
     57//
     58// It is advicable to use these function if the task is not needed for your
     59// event selection. The event selection (by number and by PreCuts) is done
     60// in between PreTasks and PostTasks, i.e. a task which is not needed for the
     61// event selection but needed later is only executed as often as necessary.
     62//
     63// The event selection (apart from the number of target events) can be setup
     64// by the user. Therefore two functions are available
     65//    void AddPreCut(const char *rule)
     66//    void AddPreCut(MFilter *f)
     67// Both add cuts which are executed after the PreTasks but before the
     68// PostTasks. They are executed in both training and testing. To execute cuts
     69// only in training or testing use
     70//    void AddTrainCut(const char *rule)
     71//    void AddTrainCut(MFilter *f)
     72// or
     73//    void AddTestCut(const char *rule)
     74//    void AddTestCut(MFilter *f)
     75//
     76// To weight the events of your train- and test sample the following functions
     77// can be used
     78//    void SetWeights(const char *rule)
     79//    void SetWeights(MTask *t)
     80// This either adds a MParameterCalc to the list of post tasks or a MTask,
     81// which is supposed to fill a MParameterD named "MWeight".
     82//
     83// Last but not least a function if available to add additional tasks to the
     84// end of the task list for testing. This can for example be used to add
     85// the filling and display of an addition histogram (e.g. add a MFillH)
     86// or to do some calculation and write out the result. Basically everything
     87// can be done in this way.
     88//    void AddTestTask(MTask *t)
     89//    void AddTestTask(const char *rule, const char *name="MWeight")
     90//
     91//
     92// REMARK: Note that the actual behavior might still vary a bit
     93//         depeding of the implementation in the derived class.
    4194//
    4295/////////////////////////////////////////////////////////////////////////////
     
    98151//------------------------------------------------------------------------
    99152//
    100 // Add a parameter used in your filters (see AddFilter) The parameter
    101 // index is returned,
     153// Add a parameter to the list of parameters. The index in the list is
     154// returned.
    102155//
    103156//   Int_t idx = AddParameter("log10(MHillas.fSize)");
    104157//
    105 // The indices are starting with 0 always.
     158// Indices are starting with 0.
    106159//
    107160Int_t MJOptimizeBase::AddParameter(const char *rule)
  • trunk/Mars/mjoptim/MJOptimizeBase.h

    r8698 r9867  
    2323    TList fPreTasks;        // Tasks executed before cut execution
    2424    TList fPostTasks;       // Tasks executed after cut execution
    25     TList fTestTasks;       // Tasks executed after cut execution for testing
     25    TList fTestTasks;       // Tasks executed at the end of the testing tasklist
    2626
    2727    void AddCut(TList &l, const char *rule);
     
    3434    }
    3535
     36    // MJOptimizeBase
     37    void SetDebug(Bool_t b=kTRUE) { fDebug = b; }
     38
     39    // Add a parameter to the list of parameters
     40    Int_t AddParameter(const char *rule);
     41
     42    // Tasks which are executed after reading (training and testing if available)
    3643    void AddPreTask(MTask *t)                    { Add(fPreTasks,  t); }
    3744    void AddPreTask(const char *rule,
    3845                    const char *name="MWeight")  { AddPar(fPreTasks, rule, name); }
    3946
     47    // Cuts which are executed after the pre-tasks (training and testing if available)
     48    void AddPreCut(const char *rule)             { AddCut(fPreCuts, rule); }
     49    void AddPreCut(MFilter *f)                   { Add(fPreCuts, (MTask*)(f)); }
     50
     51    // Same as pre-cuts but only executed in taining or testing
     52    void AddTrainCut(const char *rule)           { AddCut(fTrainCuts, rule); }
     53    void AddTrainCut(MFilter *f)                 { Add(fTrainCuts, (MTask*)(f)); }
     54
     55    void AddTestCut(const char *rule)            { AddCut(fTestCuts, rule); }
     56    void AddTestCut(MFilter *f)                  { Add(fTestCuts, (MTask*)(f)); }
     57
     58    // Tasks which are excuted after event selection (training and testing if available)
    4059    void AddPostTask(MTask *t)                   { Add(fPostTasks, t); }
    4160    void AddPostTask(const char *rule,
    4261                     const char *name="MWeight") { AddPar(fPostTasks, rule, name); }
    4362
     63    // Tasks executed at the end of the testing tasklist
    4464    void AddTestTask(MTask *t)                   { Add(fTestTasks, t); }
    4565    void AddTestTask(const char *rule,
    4666                     const char *name="MWeight") { AddPar(fTestTasks, rule, name); }
    4767
    48     void SetDebug(Bool_t b=kTRUE)      { fDebug = b; }
    49 
     68    // Add calculation of weights to list of post tasks. Set fEnableWeights
    5069    void SetWeights(const char *rule)  { if (fEnableWeights) return; fEnableWeights=kTRUE; AddPostTask(rule); }
    5170    void SetWeights(MTask *t)          { if (fEnableWeights) return; fEnableWeights=kTRUE; AddPostTask(t);    }
    52 
    53     void AddPreCut(const char *rule)   { AddCut(fPreCuts, rule); }
    54     void AddPreCut(MFilter *f)         { Add(fPreCuts, (MTask*)(f)); }
    55 
    56     void AddTrainCut(const char *rule) { AddCut(fTrainCuts, rule); }
    57     void AddTrainCut(MFilter *f)       { Add(fTrainCuts, (MTask*)(f)); }
    58 
    59     void AddTestCut(const char *rule)  { AddCut(fTestCuts, rule); }
    60     void AddTestCut(MFilter *f)        { Add(fTestCuts, (MTask*)(f)); }
    61 
    62     Int_t AddParameter(const char *rule);
    6371
    6472    ClassDef(MJOptimizeBase, 0)//Base class for all optimizations and trainings
Note: See TracChangeset for help on using the changeset viewer.