59 const std::vector< const Node * >& nodes )
64 , fCoefficient ( 0.0 )
66 , fImportanceRef ( 1.0 )
67 , fRuleEnsemble ( re )
91 , fCoefficient ( 0.0 )
93 , fImportanceRef ( 1.0 )
94 , fRuleEnsemble ( re )
109 , fCoefficient ( 0.0 )
110 , fImportance ( 0.0 )
111 , fImportanceRef ( 1.0 )
112 , fRuleEnsemble ( 0 )
135 UInt_t nvars = fCut->GetNvars();
139 found = (fCut->GetSelector(i) == iv);
141 doneLoop = (found || (i==nvars));
150 fLogger->SetMinType(t);
167 if (mindist<0) useCutValue=
kFALSE;
168 Double_t d = RuleDist( other, useCutValue );
170 if (useCutValue) rval = ( (!(d<0)) && (d<mindist) );
171 else rval = (!(d<0));
187 const UInt_t nvars = fCut->GetNvars();
206 while ((equal) && (in<nvars)) {
208 equal = ( (fCut->GetSelector(in) == (otherCut->
GetSelector(in))) &&
209 (fCut->GetCutDoMin(in) == (otherCut->
GetCutDoMin(in))) &&
210 (fCut->GetCutDoMax(in) == (otherCut->
GetCutDoMax(in))) );
215 vminA = fCut->GetCutMin(in);
216 vmaxA = fCut->GetCutMax(in);
220 rms = fRuleEnsemble->GetRuleFit()->GetMethodBase()->GetRMS(sel);
223 if (fCut->GetCutDoMin(in))
224 smin = ( rms>0 ? (vminA-vminB)/rms : 0 );
225 if (fCut->GetCutDoMax(in))
226 smax = ( rms>0 ? (vmaxA-vmaxB)/rms : 0 );
227 sumdc2 += smin*smin + smax*smax;
233 if (!useCutValue) sumdc2 = (equal ? 0.0:-1.0);
234 else sumdc2 = (equal ?
sqrt(sumdc2) : -1.0);
244 return this->Equal( other,
kTRUE, 1e-3 );
269 return fRuleEnsemble->GetMethodBase()->GetInputLabel(i);
296 const UInt_t nvars = fCut->GetNvars();
297 if (nvars<1) os <<
" *** WARNING - <EMPTY RULE> ***" << std::endl;
302 os <<
" Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) << std::endl;
303 os <<
" Coefficient = " <<
Form(
"%1.4f", fCoefficient) << std::endl;
304 os <<
" Support = " <<
Form(
"%1.4f", fSupport) << std::endl;
305 os <<
" S/(S+B) = " <<
Form(
"%1.4f", fSSB) << std::endl;
307 for (
UInt_t i=0; i<nvars; i++) {
309 sel = fCut->GetSelector(i);
310 valmin = fCut->GetCutMin(i);
311 valmax = fCut->GetCutMax(i);
313 os <<
Form(
"* Cut %2d",i+1) <<
" : " << std::flush;
314 if (fCut->GetCutDoMin(i)) os <<
Form(
"%10.3g",valmin) <<
" < " << std::flush;
315 else os <<
" " << std::flush;
316 os << GetVarName(sel) << std::flush;
317 if (fCut->GetCutDoMax(i)) os <<
" < " <<
Form(
"%10.3g",valmax) << std::flush;
318 else os <<
" " << std::flush;
328 const UInt_t nvars = fCut->GetNvars();
336 <<
"Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) <<
Endl;
338 for (
UInt_t i=0; i<nvars; i++) {
341 sel = fCut->GetSelector(i);
342 valmin = fCut->GetCutMin(i);
343 valmax = fCut->GetCutMax(i);
346 if (fCut->GetCutDoMin(i))
Log() <<
kINFO <<
Form(
"%10.3g",valmin) <<
" < ";
349 if (fCut->GetCutDoMax(i))
Log() <<
kINFO <<
" < " <<
Form(
"%10.3g",valmax);
360 Int_t dp = os.precision();
361 const UInt_t nvars = fCut->GetNvars();
363 << std::setprecision(10)
364 << fImportance <<
" "
365 << fImportanceRef <<
" "
366 << fCoefficient <<
" "
373 os <<
"N(cuts): " << nvars << std::endl;
374 for (
UInt_t i=0; i<nvars; i++) {
375 os <<
"Cut " << i <<
" : " << std::flush;
376 os << fCut->GetSelector(i)
377 << std::setprecision(10)
378 <<
" " << fCut->GetCutMin(i)
379 <<
" " << fCut->GetCutMax(i)
380 <<
" " << (fCut->GetCutDoMin(i) ?
"T":
"F")
381 <<
" " << (fCut->GetCutDoMax(i) ?
"T":
"F")
384 os << std::setprecision(dp);
392 const UInt_t nvars = fCut->GetNvars();
404 for (
UInt_t i=0; i<nvars; i++) {
409 gTools().
AddAttr( cut,
"DoMin", (fCut->GetCutDoMin(i) ?
"T":
"F") );
410 gTools().
AddAttr( cut,
"DoMax", (fCut->GetCutDoMax(i) ?
"T":
"F") );
422 if (nodeName !=
"Rule")
Log() <<
kFATAL <<
"<ReadFromXML> Unexpected node name: " << nodeName <<
Endl;
435 if (fCut)
delete fCut;
437 fCut->SetNvars( nvars );
447 fCut->SetSelector( i, ui );
449 fCut->SetCutMin ( i, d );
451 fCut->SetCutMax ( i, d );
453 fCut->SetCutDoMin( i, (c ==
'T' ?
kTRUE :
kFALSE ) );
455 fCut->SetCutDoMax( i, (c ==
'T' ?
kTRUE : kFALSE ) );
462 if (i != nvars)
Log() <<
kFATAL <<
"<ReadFromXML> Mismatch in number of cuts: " << i <<
" != " << nvars <<
Endl;
482 istr >> dummy >> nvars;
487 if (fCut)
delete fCut;
489 fCut->SetNvars( nvars );
490 for (
UInt_t i=0; i<nvars; i++) {
491 istr >> dummy >> idum;
493 istr >> sel >> cutmin >> cutmax >> bA >> bB;
494 fCut->SetSelector(i,sel);
495 fCut->SetCutMin(i,cutmin);
496 fCut->SetCutMax(i,cutmax);
498 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
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