31 #ifndef ROOT_TMVA_Rule
32 #define ROOT_TMVA_Rule
46 std::ostream& operator<<( std::ostream& os,
const Rule & rule );
51 friend std::ostream& operator<< ( std::ostream& os,
const Rule & rule );
56 Rule( RuleEnsemble *re,
const std::vector< const TMVA::Node * > & nodes );
59 Rule( RuleEnsemble *re );
62 Rule(
const Rule & other ) { Copy( other ); }
70 void SetMsgType( EMsgType t );
73 void SetRuleEnsemble(
const RuleEnsemble *re ) { fRuleEnsemble = re; }
76 void SetRuleCut( RuleCut *rc ) { fCut = rc; }
79 void SetNorm(Double_t norm) { fNorm = (norm>0 ? 1.0/norm:1.0); }
82 void SetCoefficient(Double_t v) { fCoefficient=v; }
85 void SetSupport(Double_t v) { fSupport=v; fSigma = TMath::Sqrt(v*(1.0-v));}
88 void SetSSB(Double_t v) { fSSB=v; }
91 void SetSSBNeve(Double_t v) { fSSBNeve=v; }
94 void SetImportanceRef(Double_t v) { fImportanceRef=(v>0 ? v:1.0); }
97 void CalcImportance() { fImportance = TMath::Abs(fCoefficient)*fSigma; }
100 Double_t GetRelImportance()
const {
return fImportance/fImportanceRef; }
106 inline Bool_t EvalEvent(
const Event& e )
const;
109 Bool_t Equal(
const Rule & other, Bool_t useCutValue, Double_t maxdist )
const;
112 Double_t RuleDist(
const Rule & other, Bool_t useCutValue )
const;
115 Double_t GetSSB()
const {
return fSSB; }
116 Double_t GetSSBNeve()
const {
return fSSBNeve; }
117 Bool_t IsSignalRule()
const {
return (fSSB>0.5); }
120 void operator=(
const Rule & other ) { Copy( other ); }
123 Bool_t operator==(
const Rule & other )
const;
125 Bool_t operator<(
const Rule & other )
const;
128 UInt_t GetNumVarsUsed()
const {
return fCut->GetNvars(); }
131 UInt_t GetNcuts()
const {
return fCut->GetNcuts(); }
134 Bool_t ContainsVariable(UInt_t iv)
const;
137 const RuleCut* GetRuleCut()
const {
return fCut; }
138 const RuleEnsemble* GetRuleEnsemble()
const {
return fRuleEnsemble; }
139 Double_t GetCoefficient()
const {
return fCoefficient; }
140 Double_t GetSupport()
const {
return fSupport; }
141 Double_t GetSigma()
const {
return fSigma; }
142 Double_t GetNorm()
const {
return fNorm; }
143 Double_t GetImportance()
const {
return fImportance; }
144 Double_t GetImportanceRef()
const {
return fImportanceRef; }
147 void PrintLogger(
const char *title=0 )
const;
150 void PrintRaw ( std::ostream& os )
const;
151 void* AddXMLTo (
void* parent )
const;
153 void ReadRaw ( std::istream& os );
154 void ReadFromXML(
void* wghtnode );
159 void SetSigma(Double_t v) { fSigma=v; }
162 void Print( std::ostream& os )
const;
165 void Copy(
const Rule & other );
168 const TString & GetVarName( Int_t i)
const;
174 Double_t fCoefficient;
175 Double_t fImportance;
176 Double_t fImportanceRef;
177 const RuleEnsemble* fRuleEnsemble;
181 mutable MsgLogger* fLogger;
182 MsgLogger& Log()
const {
return *fLogger; }
189 inline Bool_t TMVA::Rule::EvalEvent(
const TMVA::Event& e )
const
194 return fCut->EvalEvent(e);