67 const std::vector< const Node * >& nodes )
72 , fCoefficient ( 0.0 )
74 , fImportanceRef ( 1.0 )
75 , fRuleEnsemble ( re )
99 , fCoefficient ( 0.0 )
100 , fImportance ( 0.0 )
101 , fImportanceRef ( 1.0 )
102 , fRuleEnsemble ( re )
117 , fCoefficient ( 0.0 )
118 , fImportance ( 0.0 )
119 , fImportanceRef ( 1.0 )
120 , fRuleEnsemble ( 0 )
143 UInt_t nvars = fCut->GetNvars();
147 found = (fCut->GetSelector(i) == iv);
149 doneLoop = (found || (i==nvars));
158 fLogger->SetMinType(t);
175 if (mindist<0) useCutValue=
kFALSE;
176 Double_t d = RuleDist( other, useCutValue );
178 if (useCutValue) rval = ( (!(
d<0)) && (
d<mindist) );
179 else rval = (!(
d<0));
196 const UInt_t nvars = fCut->GetNvars();
215 while ((equal) && (in<nvars)) {
217 equal = ( (fCut->GetSelector(in) == (otherCut->
GetSelector(in))) &&
218 (fCut->GetCutDoMin(in) == (otherCut->
GetCutDoMin(in))) &&
219 (fCut->GetCutDoMax(in) == (otherCut->
GetCutDoMax(in))) );
223 sel = fCut->GetSelector(in);
224 vminA = fCut->GetCutMin(in);
225 vmaxA = fCut->GetCutMax(in);
229 rms = fRuleEnsemble->GetRuleFit()->GetMethodBase()->GetRMS(
sel);
232 if (fCut->GetCutDoMin(in))
233 smin = ( rms>0 ? (vminA-vminB)/rms : 0 );
234 if (fCut->GetCutDoMax(in))
235 smax = ( rms>0 ? (vmaxA-vmaxB)/rms : 0 );
236 sumdc2 += smin*smin + smax*smax;
242 if (!useCutValue) sumdc2 = (equal ? 0.0:-1.0);
243 else sumdc2 = (equal ? sqrt(sumdc2) : -1.0);
253 return this->Equal( other,
kTRUE, 1
e-3 );
278 return fRuleEnsemble->GetMethodBase()->GetInputLabel(i);
305 const UInt_t nvars = fCut->GetNvars();
306 if (nvars<1) os <<
" *** WARNING - <EMPTY RULE> ***" << std::endl;
311 os <<
" Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) << std::endl;
312 os <<
" Coefficient = " <<
Form(
"%1.4f", fCoefficient) << std::endl;
313 os <<
" Support = " <<
Form(
"%1.4f", fSupport) << std::endl;
314 os <<
" S/(S+B) = " <<
Form(
"%1.4f", fSSB) << std::endl;
316 for (
UInt_t i=0; i<nvars; i++) {
318 sel = fCut->GetSelector(i);
319 valmin = fCut->GetCutMin(i);
320 valmax = fCut->GetCutMax(i);
322 os <<
Form(
"* Cut %2d",i+1) <<
" : " << std::flush;
323 if (fCut->GetCutDoMin(i)) os <<
Form(
"%10.3g",valmin) <<
" < " << std::flush;
324 else os <<
" " << std::flush;
325 os << GetVarName(
sel) << std::flush;
326 if (fCut->GetCutDoMax(i)) os <<
" < " <<
Form(
"%10.3g",valmax) << std::flush;
327 else os <<
" " << std::flush;
337 const UInt_t nvars = fCut->GetNvars();
338 if (nvars<1) Log() << kWARNING <<
"BUG TRAP: EMPTY RULE!!!" <<
Endl;
343 if (title) Log() << kINFO << title;
345 <<
"Importance = " <<
Form(
"%1.4f", fImportance/fImportanceRef) <<
Endl;
347 for (
UInt_t i=0; i<nvars; i++) {
349 Log() << kINFO <<
" ";
350 sel = fCut->GetSelector(i);
351 valmin = fCut->GetCutMin(i);
352 valmax = fCut->GetCutMax(i);
354 Log() << kINFO <<
Form(
"Cut %2d",i+1) <<
" : ";
355 if (fCut->GetCutDoMin(i)) Log() << kINFO <<
Form(
"%10.3g",valmin) <<
" < ";
356 else Log() << kINFO <<
" ";
357 Log() << kINFO << GetVarName(
sel);
358 if (fCut->GetCutDoMax(i)) Log() << kINFO <<
" < " <<
Form(
"%10.3g",valmax);
359 else Log() << kINFO <<
" ";
369 Int_t dp = os.precision();
370 const UInt_t nvars = fCut->GetNvars();
372 << std::setprecision(10)
373 << fImportance <<
" "
374 << fImportanceRef <<
" "
375 << fCoefficient <<
" "
382 os <<
"N(cuts): " << nvars << std::endl;
383 for (
UInt_t i=0; i<nvars; i++) {
384 os <<
"Cut " << i <<
" : " << std::flush;
385 os << fCut->GetSelector(i)
386 << std::setprecision(10)
387 <<
" " << fCut->GetCutMin(i)
388 <<
" " << fCut->GetCutMax(i)
389 <<
" " << (fCut->GetCutDoMin(i) ?
"T":
"F")
390 <<
" " << (fCut->GetCutDoMax(i) ?
"T":
"F")
393 os << std::setprecision(dp);
401 const UInt_t nvars = fCut->GetNvars();
413 for (
UInt_t i=0; i<nvars; i++) {
418 gTools().
AddAttr( cut,
"DoMin", (fCut->GetCutDoMin(i) ?
"T":
"F") );
419 gTools().
AddAttr( cut,
"DoMax", (fCut->GetCutDoMax(i) ?
"T":
"F") );
431 if (nodeName !=
"Rule") Log() << kFATAL <<
"<ReadFromXML> Unexpected node name: " << nodeName <<
Endl;
444 if (fCut)
delete fCut;
446 fCut->SetNvars( nvars );
456 fCut->SetSelector( i, ui );
458 fCut->SetCutMin ( i,
d );
460 fCut->SetCutMax ( i,
d );
471 if (i != nvars) Log() << kFATAL <<
"<ReadFromXML> Mismatch in number of cuts: " << i <<
" != " << nvars <<
Endl;
491 istr >> dummy >> nvars;
496 if (fCut)
delete fCut;
498 fCut->SetNvars( nvars );
499 for (
UInt_t i=0; i<nvars; i++) {
500 istr >> dummy >> idum;
502 istr >>
sel >> cutmin >> cutmax >> bA >> bB;
503 fCut->SetSelector(i,
sel);
504 fCut->SetCutMin(i,cutmin);
505 fCut->SetCutMax(i,cutmax);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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
void PrintLogger(const char *title=nullptr) const
print function
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
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:
Double_t fSSB
S/(S+B) for rule.
RuleCut * fCut
all cuts associated with the rule
Bool_t ContainsVariable(UInt_t iv) const
check if variable in node
Rule()
the simple constructor
Double_t fSSBNeve
N(events) reaching the last node in reevaluation.
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
MsgLogger & Endl(MsgLogger &ml)