63 const std::vector< const Node * >& nodes )
68 , fCoefficient ( 0.0 )
70 , fImportanceRef ( 1.0 )
71 , fRuleEnsemble ( re )
95 , fCoefficient ( 0.0 )
97 , fImportanceRef ( 1.0 )
98 , fRuleEnsemble ( re )
113 , fCoefficient ( 0.0 )
114 , fImportance ( 0.0 )
115 , fImportanceRef ( 1.0 )
116 , fRuleEnsemble ( 0 )
139 UInt_t nvars = fCut->GetNvars();
143 found = (fCut->GetSelector(i) == iv);
145 doneLoop = (found || (i==nvars));
154 fLogger->SetMinType(t);
171 if (mindist<0) useCutValue=
kFALSE;
172 Double_t d = RuleDist( other, useCutValue );
174 if (useCutValue) rval = ( (!(d<0)) && (d<mindist) );
175 else rval = (!(d<0));
191 const UInt_t nvars = fCut->GetNvars();
210 while ((equal) && (in<nvars)) {
212 equal = ( (fCut->GetSelector(in) == (otherCut->
GetSelector(in))) &&
213 (fCut->GetCutDoMin(in) == (otherCut->
GetCutDoMin(in))) &&
214 (fCut->GetCutDoMax(in) == (otherCut->
GetCutDoMax(in))) );
219 vminA = fCut->GetCutMin(in);
220 vmaxA = fCut->GetCutMax(in);
224 rms = fRuleEnsemble->GetRuleFit()->GetMethodBase()->GetRMS(sel);
227 if (fCut->GetCutDoMin(in))
228 smin = ( rms>0 ? (vminA-vminB)/rms : 0 );
229 if (fCut->GetCutDoMax(in))
230 smax = ( rms>0 ? (vmaxA-vmaxB)/rms : 0 );
231 sumdc2 += smin*smin + smax*smax;
237 if (!useCutValue) sumdc2 = (equal ? 0.0:-1.0);
238 else sumdc2 = (equal ?
sqrt(sumdc2) : -1.0);
248 return this->Equal( other,
kTRUE, 1e-3 );
273 return fRuleEnsemble->GetMethodBase()->GetInputLabel(i);
300 const UInt_t nvars = fCut->GetNvars();
301 if (nvars<1) os <<
" *** WARNING - <EMPTY RULE> ***" << std::endl;
306 os <<
" Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) << std::endl;
307 os <<
" Coefficient = " <<
Form(
"%1.4f", fCoefficient) << std::endl;
308 os <<
" Support = " <<
Form(
"%1.4f", fSupport) << std::endl;
309 os <<
" S/(S+B) = " <<
Form(
"%1.4f", fSSB) << std::endl;
311 for (
UInt_t i=0; i<nvars; i++) {
313 sel = fCut->GetSelector(i);
314 valmin = fCut->GetCutMin(i);
315 valmax = fCut->GetCutMax(i);
317 os <<
Form(
"* Cut %2d",i+1) <<
" : " << std::flush;
318 if (fCut->GetCutDoMin(i)) os <<
Form(
"%10.3g",valmin) <<
" < " << std::flush;
319 else os <<
" " << std::flush;
320 os << GetVarName(sel) << std::flush;
321 if (fCut->GetCutDoMax(i)) os <<
" < " <<
Form(
"%10.3g",valmax) << std::flush;
322 else os <<
" " << std::flush;
332 const UInt_t nvars = fCut->GetNvars();
340 <<
"Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) <<
Endl;
342 for (
UInt_t i=0; i<nvars; i++) {
345 sel = fCut->GetSelector(i);
346 valmin = fCut->GetCutMin(i);
347 valmax = fCut->GetCutMax(i);
350 if (fCut->GetCutDoMin(i))
Log() <<
kINFO <<
Form(
"%10.3g",valmin) <<
" < ";
353 if (fCut->GetCutDoMax(i))
Log() <<
kINFO <<
" < " <<
Form(
"%10.3g",valmax);
364 Int_t dp = os.precision();
365 const UInt_t nvars = fCut->GetNvars();
367 << std::setprecision(10)
368 << fImportance <<
" "
369 << fImportanceRef <<
" "
370 << fCoefficient <<
" "
377 os <<
"N(cuts): " << nvars << std::endl;
378 for (
UInt_t i=0; i<nvars; i++) {
379 os <<
"Cut " << i <<
" : " << std::flush;
380 os << fCut->GetSelector(i)
381 << std::setprecision(10)
382 <<
" " << fCut->GetCutMin(i)
383 <<
" " << fCut->GetCutMax(i)
384 <<
" " << (fCut->GetCutDoMin(i) ?
"T":
"F")
385 <<
" " << (fCut->GetCutDoMax(i) ?
"T":
"F")
388 os << std::setprecision(dp);
396 const UInt_t nvars = fCut->GetNvars();
408 for (
UInt_t i=0; i<nvars; i++) {
413 gTools().
AddAttr( cut,
"DoMin", (fCut->GetCutDoMin(i) ?
"T":
"F") );
414 gTools().
AddAttr( cut,
"DoMax", (fCut->GetCutDoMax(i) ?
"T":
"F") );
426 if (nodeName !=
"Rule")
Log() <<
kFATAL <<
"<ReadFromXML> Unexpected node name: " << nodeName <<
Endl;
439 if (fCut)
delete fCut;
441 fCut->SetNvars( nvars );
451 fCut->SetSelector( i, ui );
453 fCut->SetCutMin ( i, d );
455 fCut->SetCutMax ( i, d );
457 fCut->SetCutDoMin( i, (c ==
'T' ?
kTRUE :
kFALSE ) );
459 fCut->SetCutDoMax( i, (c ==
'T' ?
kTRUE : kFALSE ) );
466 if (i != nvars)
Log() <<
kFATAL <<
"<ReadFromXML> Mismatch in number of cuts: " << i <<
" != " << nvars <<
Endl;
486 istr >> dummy >> nvars;
491 if (fCut)
delete fCut;
493 fCut->SetNvars( nvars );
494 for (
UInt_t i=0; i<nvars; i++) {
495 istr >> dummy >> idum;
497 istr >> sel >> cutmin >> cutmax >> bA >> bB;
498 fCut->SetSelector(i,sel);
499 fCut->SetCutMin(i,cutmin);
500 fCut->SetCutMax(i,cutmax);
502 fCut->SetCutDoMax(i,(bB==
'T' ?
kTRUE:kFALSE));
Double_t GetPurity() const
Rule()
the simple constructor
MsgLogger & Endl(MsgLogger &ml)
bool equal(double d1, double d2, double stol=10000)
Double_t GetCutMax(Int_t is) const
Double_t RuleDist(const Rule &other, Bool_t useCutValue) const
Returns: -1.0 : rules are NOT equal, i.e, variables and/or cut directions are wrong >=0: rules are eq...
UInt_t GetSelector(Int_t is) const
Bool_t Equal(const Rule &other, Bool_t useCutValue, Double_t maxdist) const
Compare two rules.
Double_t GetSSBNeve() const
Double_t GetImportanceRef() const
Char_t GetCutDoMax(Int_t is) const
Double_t GetCutMin(Int_t is) const
const RuleCut * GetRuleCut() const
const TString & GetVarName(Int_t i) const
returns the name of a rule
Bool_t operator==(const Rule &other) const
comparison operator ==
Bool_t ContainsVariable(UInt_t iv) const
check if variable in node
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
void ReadFromXML(void *wghtnode)
read rule from XML
Double_t GetImportance() const
void * AddXMLTo(void *parent) const
const RuleEnsemble * GetRuleEnsemble() const
Double_t GetSigma() const
char * Form(const char *fmt,...)
void PrintRaw(std::ostream &os) const
extensive print function used to print info for the weight file
void ReadRaw(std::istream &os)
read function (format is the same as written by PrintRaw)
void PrintLogger(const char *title=0) const
print function
void Copy(const Rule &other)
copy function
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
print the tree recursinvely using the << operator
void Print(std::ostream &os) const
print function
static RooMathCoreReg dummy
Char_t GetCutDoMin(Int_t is) const
Double_t GetCoefficient() const
Bool_t operator<(const Rule &other) const
comparison operator <
void SetMsgType(EMsgType t)
Double_t GetSupport() const
Double_t GetCutNeve() const
virtual ~Rule()
destructor