Ignore:
Timestamp:
05/21/06 16:17:05 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.h

    r7701 r7724  
    1414class MJTrainSeparation : public MJTrainRanForest
    1515{
     16public:
     17    enum Type_t { kTrainOn, kTrainOff, kTestOn, kTestOff };
     18
    1619private:
    1720    MDataSet fDataSetTest;
    1821    MDataSet fDataSetTrain;
    1922
    20     UInt_t fNumTrainOn;
    21     UInt_t fNumTrainOff;
     23    UInt_t fNum[4];
    2224
    23     UInt_t fNumTestOn;
    24     UInt_t fNumTestOff;
    25 
    26     TList fPreTasksOn;
    27     TList fPreTasksOff;
    28     TList fPostTasksOn;
    29     TList fPostTasksOff;
     25    TList fPreTasksSet[4];
     26    TList fPostTasksSet[4];
    3027
    3128    Bool_t fAutoTrain;
    3229    Bool_t fUseRegression;
    33     Bool_t fEnableWeightsOn;
    34     Bool_t fEnableWeightsOff;
    3530
    36     Float_t fFlux;
     31    Bool_t fEnableWeights[4];
    3732
    38     void DisplayResult(MH3 &h31, MH3 &h32);
     33    Float_t fFluxTrain;
     34    Float_t fFluxTest;
    3935
     36    // Result
     37    void     DisplayResult(MH3 &h31, MH3 &h32, Float_t ontime);
     38
     39    // Auto training
    4040    Bool_t   GetEventsProduced(MDataSet &set, Double_t &num, Double_t &min, Double_t &max) const;
    4141    Double_t GetDataRate(MDataSet &set, Double_t &num) const;
    4242    Double_t GetNumMC(MDataSet &set) const;
    43     Bool_t   AutoTrain(MDataSet &set, UInt_t &on, UInt_t &off);
     43    Float_t  AutoTrain(MDataSet &set, Type_t typon, Type_t typoff, Float_t flux);
    4444
    4545public:
    4646    MJTrainSeparation() :
    47         fNumTrainOn((UInt_t)-1), fNumTrainOff((UInt_t)-1),
    48         fNumTestOn((UInt_t)-1), fNumTestOff((UInt_t)-1),
    4947        fAutoTrain(kFALSE), fUseRegression(kFALSE),
    50         fEnableWeightsOn(kFALSE), fEnableWeightsOff(kFALSE), fFlux(2e-7)
    51     { }
     48        fFluxTrain(2e-7), fFluxTest(2e-7)
     49    { for (int i=0; i<4; i++) { fEnableWeights[i]=kFALSE; fNum[i] = (UInt_t)-1; } }
    5250
    5351    void SetDataSetTrain(const MDataSet &ds, UInt_t non=(UInt_t)-1, UInt_t noff=(UInt_t)-1)
     
    5755        fDataSetTrain.SetNumAnalysis(1);
    5856
    59         fNumTrainOn = non;
    60         fNumTrainOff = noff;
     57        fNum[kTrainOn] = non;
     58        fNum[kTrainOff] = noff;
    6159    }
    6260    void SetDataSetTest(const MDataSet &ds, UInt_t non=(UInt_t)-1, UInt_t noff=(UInt_t)-1)
     
    6664        fDataSetTest.SetNumAnalysis(1);
    6765
    68         fNumTestOn = non;
    69         fNumTestOff = noff;
     66        fNum[kTestOn] = non;
     67        fNum[kTestOff] = noff;
    7068    }
    7169
    72     void AddPreTaskOn(MTask *t)                     { Add(fPreTasksOn,  t); }
    73     void AddPreTaskOn(const char *rule,
    74                       const char *name="MWeight")   { AddPar(fPreTasksOn, rule, name); }
     70    // Deprecated, used for test purpose
     71    void AddPreTask(Type_t typ, MTask *t)                                      { Add(fPreTasksSet[typ],  t); }
     72    void AddPreTask(Type_t typ, const char *rule, const char *name="MWeight")  { AddPar(fPreTasksSet[typ], rule, name); }
    7573
    76     void AddPreTaskOff(MTask *t)                    { Add(fPreTasksOff, t); }
    77     void AddPreTaskOff(const char *rule,
    78                        const char *name="MWeight")  { AddPar(fPreTasksOff, rule, name); }
     74    void AddPostTask(Type_t typ, MTask *t)                                     { Add(fPostTasksSet[typ],  t); }
     75    void AddPostTask(Type_t typ, const char *rule, const char *name="MWeight") { AddPar(fPostTasksSet[typ], rule, name); }
    7976
    80     void AddPostTaskOn(MTask *t)                    { Add(fPostTasksOn,  t); }
    81     void AddPostTaskOn(const char *rule,
    82                        const char *name="MWeight")  { AddPar(fPostTasksOn, rule, name); }
     77    void SetWeights(Type_t typ, const char *rule)  { if (fEnableWeights[typ]) return; fEnableWeights[typ]=kTRUE; AddPostTask(typ, rule); }
     78    void SetWeights(Type_t typ, MTask *t)          { if (fEnableWeights[typ]) return; fEnableWeights[typ]=kTRUE; AddPostTask(typ, t); }
    8379
    84     void AddPostTaskOff(MTask *t)                   { Add(fPostTasksOff, t); }
    85     void AddPostTaskOff(const char *rule,
    86                         const char *name="MWeight") { AddPar(fPostTasksOff, rule, name); }
     80    // Standard user interface
     81    void AddPreTaskOn(MTask *t)                                       { AddPreTask(kTrainOn, t); AddPreTask(kTestOn, t); }
     82    void AddPreTaskOn(const char *rule, const char *name="MWeight")   { AddPreTask(kTrainOn, rule, name); AddPreTask(kTestOn, rule, name); }
     83    void AddPreTaskOff(MTask *t)                                      { AddPreTask(kTrainOff, t); AddPreTask(kTestOff, t); }
     84    void AddPreTaskOff(const char *rule, const char *name="MWeight")  { AddPreTask(kTrainOff, rule, name); AddPreTask(kTestOff, rule, name); }
    8785
    88     void SetWeightsOn(const char *rule)  { if (fEnableWeightsOn) return;  fEnableWeightsOn=kTRUE;  AddPostTaskOn(rule); }
    89     void SetWeightsOn(MTask *t)          { if (fEnableWeightsOn) return;  fEnableWeightsOn=kTRUE;  AddPostTaskOn(t);    }
     86    void AddPostTaskOn(MTask *t)                                      { AddPostTask(kTrainOn, t); AddPostTask(kTestOn, t); }
     87    void AddPostTaskOn(const char *rule, const char *name="MWeight")  { AddPostTask(kTrainOn, rule, name); AddPostTask(kTestOn, rule, name); }
     88    void AddPostTaskOff(MTask *t)                                     { AddPostTask(kTrainOff, t); AddPostTask(kTestOff, t); }
     89    void AddPostTaskOff(const char *rule, const char *name="MWeight") { AddPostTask(kTrainOff, rule, name); AddPostTask(kTestOff, rule, name); }
    9090
    91     void SetWeightsOff(const char *rule) { if (fEnableWeightsOff) return; fEnableWeightsOff=kTRUE; AddPostTaskOff(rule); }
    92     void SetWeightsOff(MTask *t)         { if (fEnableWeightsOff) return; fEnableWeightsOff=kTRUE; AddPostTaskOff(t);    }
     91    void SetWeightsOn(const char *rule)  { SetWeights(kTrainOn, rule); SetWeights(kTestOn, rule); }
     92    void SetWeightsOn(MTask *t)          { SetWeights(kTrainOn, t); SetWeights(kTestOn, t); }
     93    void SetWeightsOff(const char *rule) { SetWeights(kTrainOff, rule); SetWeights(kTestOff, rule); }
     94    void SetWeightsOff(MTask *t)         { SetWeights(kTrainOff, t); SetWeights(kTestOff, t); }
    9395
    94     void SetFlux(Float_t f) { fFlux = f; }
     96    void SetFluxTrain(Float_t f) { fFluxTrain = f; }
     97    void SetFluxTest(Float_t f)  { fFluxTest  = f; }
     98    void SetFlux(Float_t f)      { SetFluxTrain(f); SetFluxTest(f); }
    9599
    96100    void EnableAutoTrain(Bool_t b=kTRUE)      { fAutoTrain     =  b; }
Note: See TracChangeset for help on using the changeset viewer.