65 const std::vector< const Node * >& nodes )
70 , fCoefficient ( 0.0 )
72 , fImportanceRef ( 1.0 )
73 , fRuleEnsemble ( re )
97 , fCoefficient ( 0.0 )
99 , fImportanceRef ( 1.0 )
100 , fRuleEnsemble ( re )
115 , fCoefficient ( 0.0 )
116 , fImportance ( 0.0 )
117 , fImportanceRef ( 1.0 )
118 , fRuleEnsemble ( 0 )
141 UInt_t nvars = fCut->GetNvars();
145 found = (fCut->GetSelector(i) == iv);
147 doneLoop = (found || (i==nvars));
156 fLogger->SetMinType(t);
173 if (mindist<0) useCutValue=
kFALSE;
174 Double_t d = RuleDist( other, useCutValue );
176 if (useCutValue) rval = ( (!(
d<0)) && (
d<mindist) );
177 else rval = (!(
d<0));
194 const UInt_t nvars = fCut->GetNvars();
213 while ((equal) && (in<nvars)) {
215 equal = ( (fCut->GetSelector(in) == (otherCut->
GetSelector(in))) &&
216 (fCut->GetCutDoMin(in) == (otherCut->
GetCutDoMin(in))) &&
217 (fCut->GetCutDoMax(in) == (otherCut->
GetCutDoMax(in))) );
222 vminA = fCut->GetCutMin(in);
223 vmaxA = fCut->GetCutMax(in);
227 rms = fRuleEnsemble->GetRuleFit()->GetMethodBase()->GetRMS(sel);
230 if (fCut->GetCutDoMin(in))
231 smin = ( rms>0 ? (vminA-vminB)/rms : 0 );
232 if (fCut->GetCutDoMax(in))
233 smax = ( rms>0 ? (vmaxA-vmaxB)/rms : 0 );
234 sumdc2 += smin*smin + smax*smax;
240 if (!useCutValue) sumdc2 = (equal ? 0.0:-1.0);
241 else sumdc2 = (equal ?
sqrt(sumdc2) : -1.0);
251 return this->Equal( other,
kTRUE, 1
e-3 );
276 return fRuleEnsemble->GetMethodBase()->GetInputLabel(i);
303 const UInt_t nvars = fCut->GetNvars();
304 if (nvars<1) os <<
" *** WARNING - <EMPTY RULE> ***" << std::endl;
309 os <<
" Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) << std::endl;
310 os <<
" Coefficient = " <<
Form(
"%1.4f", fCoefficient) << std::endl;
311 os <<
" Support = " <<
Form(
"%1.4f", fSupport) << std::endl;
312 os <<
" S/(S+B) = " <<
Form(
"%1.4f", fSSB) << std::endl;
314 for (
UInt_t i=0; i<nvars; i++) {
316 sel = fCut->GetSelector(i);
317 valmin = fCut->GetCutMin(i);
318 valmax = fCut->GetCutMax(i);
320 os <<
Form(
"* Cut %2d",i+1) <<
" : " << std::flush;
321 if (fCut->GetCutDoMin(i)) os <<
Form(
"%10.3g",valmin) <<
" < " << std::flush;
322 else os <<
" " << std::flush;
323 os << GetVarName(sel) << std::flush;
324 if (fCut->GetCutDoMax(i)) os <<
" < " <<
Form(
"%10.3g",valmax) << std::flush;
325 else os <<
" " << std::flush;
335 const UInt_t nvars = fCut->GetNvars();
336 if (nvars<1)
Log() << kWARNING <<
"BUG TRAP: EMPTY RULE!!!" <<
Endl;
341 if (title)
Log() << kINFO << title;
343 <<
"Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) <<
Endl;
345 for (
UInt_t i=0; i<nvars; i++) {
347 Log() << kINFO <<
" ";
348 sel = fCut->GetSelector(i);
349 valmin = fCut->GetCutMin(i);
350 valmax = fCut->GetCutMax(i);
352 Log() << kINFO <<
Form(
"Cut %2d",i+1) <<
" : ";
353 if (fCut->GetCutDoMin(i))
Log() << kINFO <<
Form(
"%10.3g",valmin) <<
" < ";
354 else Log() << kINFO <<
" ";
355 Log() << kINFO << GetVarName(sel);
356 if (fCut->GetCutDoMax(i))
Log() << kINFO <<
" < " <<
Form(
"%10.3g",valmax);
357 else Log() << kINFO <<
" ";
367 Int_t dp = os.precision();
368 const UInt_t nvars = fCut->GetNvars();
370 << std::setprecision(10)
371 << fImportance <<
" "
372 << fImportanceRef <<
" "
373 << fCoefficient <<
" "
380 os <<
"N(cuts): " << nvars << std::endl;
381 for (
UInt_t i=0; i<nvars; i++) {
382 os <<
"Cut " << i <<
" : " << std::flush;
383 os << fCut->GetSelector(i)
384 << std::setprecision(10)
385 <<
" " << fCut->GetCutMin(i)
386 <<
" " << fCut->GetCutMax(i)
387 <<
" " << (fCut->GetCutDoMin(i) ?
"T":
"F")
388 <<
" " << (fCut->GetCutDoMax(i) ?
"T":
"F")
391 os << std::setprecision(dp);
399 const UInt_t nvars = fCut->GetNvars();
411 for (
UInt_t i=0; i<nvars; i++) {
416 gTools().
AddAttr( cut,
"DoMin", (fCut->GetCutDoMin(i) ?
"T":
"F") );
417 gTools().
AddAttr( cut,
"DoMax", (fCut->GetCutDoMax(i) ?
"T":
"F") );
429 if (nodeName !=
"Rule")
Log() << kFATAL <<
"<ReadFromXML> Unexpected node name: " << nodeName <<
Endl;
442 if (fCut)
delete fCut;
444 fCut->SetNvars( nvars );
454 fCut->SetSelector( i, ui );
456 fCut->SetCutMin ( i,
d );
458 fCut->SetCutMax ( i,
d );
469 if (i != nvars)
Log() << kFATAL <<
"<ReadFromXML> Mismatch in number of cuts: " << i <<
" != " << nvars <<
Endl;
489 istr >>
dummy >> nvars;
494 if (fCut)
delete fCut;
496 fCut->SetNvars( nvars );
497 for (
UInt_t i=0; i<nvars; i++) {
498 istr >>
dummy >> idum;
500 istr >> sel >> cutmin >> cutmax >> bA >> bB;
501 fCut->SetSelector(i,sel);
502 fCut->SetCutMin(i,cutmin);
503 fCut->SetCutMax(i,cutmax);
static RooMathCoreReg dummy
char * Form(const char *fmt,...)
ostringstream derivative to redirect and format output
A class describing a 'rule cut'.
Double_t GetPurity() const
Double_t GetCutMin(Int_t is) const
UInt_t GetSelector(Int_t is) const
Double_t GetCutNeve() const
Char_t GetCutDoMin(Int_t is) const
Char_t GetCutDoMax(Int_t is) const
Double_t GetCutMax(Int_t is) const
Implementation of a rule.
void SetMsgType(EMsgType t)
void Copy(const Rule &other)
copy function
Double_t GetImportanceRef() const
Double_t GetSSBNeve() const
Double_t GetSupport() const
Bool_t Equal(const Rule &other, Bool_t useCutValue, Double_t maxdist) const
Compare two rules.
void ReadRaw(std::istream &os)
read function (format is the same as written by PrintRaw)
void * AddXMLTo(void *parent) const
void PrintLogger(const char *title=0) const
print function
Bool_t operator==(const Rule &other) const
comparison operator ==
const RuleCut * GetRuleCut() const
Double_t GetCoefficient() const
void Print(std::ostream &os) const
print function
const RuleEnsemble * GetRuleEnsemble() const
virtual ~Rule()
destructor
void ReadFromXML(void *wghtnode)
read rule from XML
Double_t GetImportance() const
void PrintRaw(std::ostream &os) const
extensive print function used to print info for the weight file
Double_t GetSigma() const
const TString & GetVarName(Int_t i) const
returns the name of a rule
Bool_t operator<(const Rule &other) const
comparison operator <
Double_t RuleDist(const Rule &other, Bool_t useCutValue) const
Returns:
Bool_t ContainsVariable(UInt_t iv) const
check if variable in node
Rule()
the simple constructor
std::string GetName(const std::string &scope_name)
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
MsgLogger & Endl(MsgLogger &ml)