00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ROOT_TMVA_RuleCut
00025 #define ROOT_TMVA_RuleCut
00026
00027 #ifndef ROOT_TMVA_Event
00028 #include "TMVA/Event.h"
00029 #endif
00030
00031 namespace TMVA {
00032
00033 class Node;
00034 class MsgLogger;
00035
00036 class RuleCut {
00037
00038 public:
00039
00040
00041 RuleCut( const std::vector< const TMVA::Node * > & nodes );
00042
00043
00044 RuleCut( const RuleCut & other ) : fLogger(0) { Copy( other ); }
00045
00046
00047 RuleCut();
00048
00049
00050 virtual ~RuleCut();
00051
00052
00053 inline Bool_t EvalEvent( const Event &eve );
00054
00055
00056 Bool_t GetCutRange(Int_t sel,Double_t &rmin, Double_t &rmax, Bool_t &dormin, Bool_t &dormax) const;
00057
00058
00059 UInt_t GetNcuts() const;
00060
00061
00062 inline void SetNvars( UInt_t nc );
00063 void SetNeve( Double_t n ) { fCutNeve = n; }
00064 void SetPurity( Double_t ssb ) { fPurity = ssb; }
00065 void SetSelector( Int_t i, UInt_t s ) { fSelector[i] = s; }
00066 void SetCutMin( Int_t i, Double_t v ) { fCutMin[i] = v; }
00067 void SetCutMax( Int_t i, Double_t v ) { fCutMax[i] = v; }
00068 void SetCutDoMin( Int_t i, Bool_t v ) { fCutDoMin[i] = v; }
00069 void SetCutDoMax( Int_t i, Bool_t v ) { fCutDoMax[i] = v; }
00070
00071
00072 UInt_t GetNvars() const { return fSelector.size(); }
00073 UInt_t GetSelector(Int_t is) const { return fSelector[is]; }
00074 Double_t GetCutMin(Int_t is) const { return fCutMin[is]; }
00075 Double_t GetCutMax(Int_t is) const { return fCutMax[is]; }
00076 Char_t GetCutDoMin(Int_t is) const { return fCutDoMin[is]; }
00077 Char_t GetCutDoMax(Int_t is) const { return fCutDoMax[is]; }
00078 Double_t GetCutNeve() const { return fCutNeve; }
00079 Double_t GetPurity() const { return fPurity; }
00080
00081 private:
00082
00083 inline void Copy( const RuleCut & other);
00084
00085
00086 void MakeCuts( const std::vector< const TMVA::Node * > & nodes );
00087
00088 std::vector<UInt_t> fSelector;
00089 std::vector<Double_t> fCutMin;
00090 std::vector<Double_t> fCutMax;
00091 std::vector<Char_t> fCutDoMin;
00092 std::vector<Char_t> fCutDoMax;
00093 Double_t fCutNeve;
00094 Double_t fPurity;
00095
00096
00097 mutable MsgLogger* fLogger;
00098 MsgLogger& Log() const { return *fLogger; }
00099 };
00100 }
00101
00102
00103 inline void TMVA::RuleCut::Copy( const TMVA::RuleCut & other )
00104 {
00105
00106 if (&other != this) {
00107 for (UInt_t ns=0; ns<other.GetNvars(); ns++) {
00108 fSelector.push_back( other.GetSelector(ns) );
00109 fCutMin.push_back( other.GetCutMin(ns) );
00110 fCutMax.push_back( other.GetCutMax(ns) );
00111 fCutDoMin.push_back( other.GetCutDoMin(ns) );
00112 fCutDoMax.push_back( other.GetCutDoMax(ns) );
00113 }
00114 fCutNeve = other.GetCutNeve();
00115 fPurity = other.GetPurity();
00116 }
00117 }
00118
00119
00120 inline Bool_t TMVA::RuleCut::EvalEvent( const Event &eve )
00121 {
00122
00123
00124
00125 Int_t sel;
00126 Double_t val;
00127 Bool_t done=kFALSE;
00128 Bool_t minOK, cutOK;
00129 UInt_t nc=0;
00130 while (!done) {
00131 sel = fSelector[nc];
00132 val = eve.GetValue(sel);
00133 minOK = (fCutDoMin[nc] ? (val>fCutMin[nc]):kTRUE);
00134 cutOK = (minOK ? ((fCutDoMax[nc] ? (val<fCutMax[nc]):kTRUE)) : kFALSE);
00135 nc++;
00136 done = ((!cutOK) || (nc==fSelector.size()));
00137 }
00138
00139 return cutOK;
00140 }
00141
00142
00143 inline void TMVA::RuleCut::SetNvars( UInt_t nc )
00144 {
00145
00146 fSelector.clear();
00147 fCutMin.clear();
00148 fCutMax.clear();
00149 fCutDoMin.clear();
00150 fCutDoMax.clear();
00151
00152 fSelector.resize(nc);
00153 fCutMin.resize(nc);
00154 fCutMax.resize(nc);
00155 fCutDoMin.resize(nc);
00156 fCutDoMax.resize(nc);
00157 }
00158
00159 #endif