99 fInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogBDT",
this,
"SetItree()");
116 std::ifstream fin(
fWfile );
118 cout <<
"*** ERROR: Weight file: " <<
fWfile <<
" does not exist" << endl;
131 cout <<
"*** Huge problem: could not locate term \"NTrees\" in BDT weight file: " 133 cout <<
"==> panic abort (please contact the TMVA authors)" << endl;
139 fNtrees = dummy.ReplaceAll(
"\"",
"").Atoi();
148 if(nodeName==
"Weights") {
155 cout <<
"--- Found " <<
fNtrees <<
" decision trees in weight file" << endl;
169 if (xsize>0.15) xsize=0.1;
171 TLine *a1 =
new TLine(x-xscale/4,y-ysize,x-xscale,y-ysize*2);
177 TLine *a1 =
new TLine(x+xscale/4,y-ysize,x+xscale,y-ysize*2);
188 t->SetFillStyle(1001);
197 sprintf( buffer,
"S/(S+B)=%4.3f", n->
GetPurity() );
214 cout <<
"--- Reading Tree " << itree <<
" from weight file: " <<
fWfile << endl;
217 std::ifstream fin(
fWfile );
219 cout <<
"*** ERROR: Weight file: " <<
fWfile <<
" does not exist" << endl;
228 cout <<
"*** ERROR: requested decision tree: " << itree
229 <<
", but number of trained trees only: " <<
fNtrees << endl;
236 while (!dummy.
Contains(
"#VAR")) fin >> dummy;
237 fin >> dummy >> dummy >>
dummy;
241 fin >> dummy >> nVars;
245 for (
Int_t i = 0; i < nVars; i++) fin >> vars[i] >> dummy >> dummy >> dummy >>
dummy;
246 vars[nVars]=
"FisherCrit";
250 sprintf(buffer,
"Tree %d",itree);
252 while (!dummy.Contains(buffer)) {
253 fin.getline(line,256);
263 cout <<
"*** ERROR: requested decision tree: " << itree
264 <<
", but number of trained trees only: " <<
fNtrees << endl;
275 if(nodeName==
"Variables"){
279 for (
Int_t i = 0; i < nVars; i++){
283 vars[nVars]=
"FisherCrit";
285 if(nodeName==
"Weights")
break;
306 cout <<
"--- Tree depth: " << depth << endl;
318 Int_t MyPalette[100];
327 TString tbuffer =
Form(
"Decision Tree no.: %d", itree );
350 signalleaf->
AddText(
"Pure Signal Nodes");
354 ydown = ydown - ystep/2.5 -dy;
355 yup = yup - ystep/2.5 -dy;
361 backgroundleaf->
AddText(
"Pure Backgr. Nodes");
363 backgroundleaf->
Draw();
368 cout <<
"--- Creating image: " << fname << endl;
390 cout <<
"*** Error in macro \"BDT.C\": cannot find directory \"Method_BDT\" in file: " << fin << endl;
397 std::vector<TString> methname;
398 std::vector<TString> path;
399 std::vector<TString> wfile;
400 while ((key = (
TKey*)next())) {
403 cout <<
"*** Error in macro \"BDT.C\": cannot find sub-directory: " << key->
GetName()
404 <<
" in directory: " << dir->
GetName() << endl;
411 if (!strPath || !strWFile) {
412 cout <<
"*** Error in macro \"BDT.C\": could not find TObjStrings \"TrainingPath\" and/or \"WeightFileName\" *** " << endl;
413 cout <<
"*** Maybe you are using TMVA >= 3.8.15 with an older training target file ? *** " << endl;
417 methname.push_back( key->GetName() );
419 wfile .push_back( strWFile->
GetString() );
424 BDT_Global__cbar.push_back(cbar);
426 for (
UInt_t im=0; im<path.size(); im++) {
428 if (fname[fname.
Length()-1] !=
'/') fname +=
"/";
430 TString macro =
Form(
"TMVA::BDT(\"%s\",0,\"%s\",\"%s\")",dataset.
Data(), fname.
Data(), methname[im].Data() );
431 cbar->
AddButton( fname, macro,
"Plot decision trees from this weight file",
"button" );
435 #if ROOT_VERSION_CODE < ROOT_VERSION(5,19,0) 436 cbar->
AddButton(
"Close",
Form(
"BDT_DeleteTBar(%i)", BDT_Global__cbar.size()-1),
"Close this control bar",
"button" );
453 delete BDT_Global__cbar[i];
454 BDT_Global__cbar[i] = 0;
465 wfile = dataset+
"/weights/TMVAnalysis_test_BDT.weights.txt";
468 std::ifstream fin( wfile );
470 cout <<
"*** ERROR: Weight file: " << wfile <<
" does not exist" << endl;
474 std::cout <<
"test1";
void Show()
Show control bar.
virtual const char * GetName() const
Returns name of object.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
void DrawTree(Int_t itree)
void AddButton(TControlBarButton *button)
Add button.
void imgconv(TCanvas *c, const TString &fname)
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
virtual TList * GetListOfKeys() const
void SetTextColor(const char *colorName)
Sets text color for control bar buttons, e.g.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Float_t GetNEvents(void) const
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
Collectable string class.
void BDT(TString dataset, const TString &fin="TMVA.root")
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
virtual void Read(std::istream &istr, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
Read the binary tree from an input stream.
TFile * OpenFile(const TString &fin)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
return next to xmlnode node if realnode==kTRUE, any special nodes in between will be skipped ...
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Bool_t GetCutType(void) const
virtual DecisionTreeNode * GetRoot() const
void SetCanvasColor(Color_t color=19)
TMVA::DecisionTree * ReadTree(TString *&vars, Int_t itree)
StatDialogBDT(TString dataset, const TGWindow *p, TString wfile, TString methName="BDT", Int_t itree=0)
Float_t GetCutValue(void) const
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
TStyle objects may be created to define special styles.
TGTextButton * fDrawButton
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
const TString & GetString() const
Int_t GetNodeType(void) const
void Initialize(Bool_t useTMVAStyle=kTRUE)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Implementation of a Decision Tree.
char * Form(const char *fmt,...)
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
virtual void ReadXML(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
virtual TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory named "apath".
Float_t GetPurity(void) const
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
A Pave (see TPave) with text, lines or/and boxes inside.
TGHorizontalFrame * fButtons
static StatDialogBDT * fThis
virtual Double_t GetNumber() const
Describe directory structure in memory.
static RooMathCoreReg dummy
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TGTextButton * fCloseButton
UInt_t GetTotalTreeDepth() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
virtual void Draw(Option_t *option="")
Draw a canvas.
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xml node
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual DecisionTreeNode * GetLeft() const
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual DecisionTreeNode * GetRight() const
Color_t GetCanvasColor() const
Short_t GetSelector() const
virtual void Update()
Update canvas pad buffers.
static Int_t CreateGradientColorTable(UInt_t Number, Double_t *Stops, Double_t *Red, Double_t *Green, Double_t *Blue, UInt_t NColors, Float_t alpha=1.)
Static function creating a color table with several connected linear gradients.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
void DrawNode(TMVA::DecisionTreeNode *n, Double_t x, Double_t y, Double_t xscale, Double_t yscale, TString *vars)
recursively puts an entries in the histogram for the node and its daughters
virtual void SetBorderSize(Int_t bordersize=4)
const char * Data() const
void BDT_DeleteTBar(int i)