19 cout <<
"read file: " << fileName << endl;
20 cout <<
"kValue = " <<
kValue << endl;
27 TControlBar* cbar =
new TControlBar(
"vertical",
"Choose cell value for plot:", 50, 50 );
29 gDirectory->Get(
"MultiTargetRegressionFoam")) {
30 TString macro =
TString::Format(
"TMVA::Plot(\"%s\",%s, \"Event density\", %s)",
31 fileName.
Data(),
"TMVA::kValueDensity", (useTMVAStyle ?
"kTRUE" :
"kFALSE") );
32 cbar->
AddButton(
"Event density", macro,
"Plot event density",
"button" );
34 TString macro =
TString::Format(
"TMVA::Plot(\"%s\", %s, \"Discriminator\", %s)",
35 fileName.
Data(),
"TMVA::kValue", (useTMVAStyle ?
"kTRUE" :
"kFALSE") );
36 cbar->
AddButton(
"Discriminator", macro,
"Plot discriminator",
"button" );
37 }
else if (
gDirectory->Get(
"MonoTargetRegressionFoam")){
38 TString macro =
TString::Format(
"TMVA::Plot(\"%s\", %s, \"Target\", %s)",
39 fileName.
Data(),
"TMVA::kValue", (useTMVAStyle ?
"kTRUE" :
"kFALSE") );
40 cbar->
AddButton(
"Target", macro,
"Plot target",
"button" );
42 cout <<
"Error: no foams found in file: " << fileName << endl;
46 TString macro_rms =
TString::Format(
"TMVA::Plot(\"%s\", %s, \"Variance\", %s)",
47 fileName.
Data(),
"TMVA::kRms", (useTMVAStyle ?
"kTRUE" :
"kFALSE") );
48 cbar->
AddButton(
"Variance", macro_rms,
"Plot variance",
"button" );
49 TString macro_rms_ov_mean =
TString::Format(
"TMVA::Plot(\"%s\", %s, \"Variance/Mean\", %s)",
50 fileName.
Data(),
"TMVA::kRmsOvMean", (useTMVAStyle ?
"kTRUE" :
"kFALSE") );
51 cbar->
AddButton(
"Variance/Mean", macro_rms_ov_mean,
"Plot variance over mean",
"button" );
52 TString macro_cell_tree =
TString::Format(
"TMVA::PlotCellTree(\"%s\", \"Cell tree\", %s)",
53 fileName.
Data(), (useTMVAStyle ?
"kTRUE" :
"kFALSE") );
54 cbar->
AddButton(
"Cell tree", macro_cell_tree,
"Plot cell tree",
"button" );
63 cout <<
"read file: " << fileName << endl;
66 gStyle->SetNumberContours(999);
70 TMVA::PDEFoam* SignalFoam = (TMVA::PDEFoam*)
gDirectory->Get(
"SignalFoam");
71 TMVA::PDEFoam* BgFoam = (TMVA::PDEFoam*)
gDirectory->Get(
"BgFoam");
72 TMVA::PDEFoam* DiscrFoam = (TMVA::PDEFoam*)
gDirectory->Get(
"DiscrFoam");
73 TMVA::PDEFoam* MultiClassFoam0 = (TMVA::PDEFoam*)
gDirectory->Get(
"MultiClassFoam0");
74 TMVA::PDEFoam* MonoTargetRegressionFoam = (TMVA::PDEFoam*)
gDirectory->Get(
"MonoTargetRegressionFoam");
75 TMVA::PDEFoam* MultiTargetRegressionFoam = (TMVA::PDEFoam*)
gDirectory->Get(
"MultiTargetRegressionFoam");
77 if (SignalFoam && BgFoam) {
78 foam_list.
Add(
new TPair(SignalFoam,
new TObjString(
"Signal Foam")));
79 foam_list.
Add(
new TPair(BgFoam,
new TObjString(
"Background Foam")));
80 }
else if (DiscrFoam) {
81 foam_list.
Add(
new TPair(DiscrFoam,
new TObjString(
"Discriminator Foam")));
82 }
else if (MultiClassFoam0) {
84 TMVA::PDEFoam *fm = NULL;
86 foam_list.
Add(
new TPair(fm,
new TObjString(
TString::Format(
"Discriminator Foam %u",cls))));
89 }
else if (MonoTargetRegressionFoam) {
90 foam_list.
Add(
new TPair(MonoTargetRegressionFoam,
91 new TObjString(
"MonoTargetRegression Foam")));
92 }
else if (MultiTargetRegressionFoam) {
93 foam_list.
Add(
new TPair(MultiTargetRegressionFoam,
94 new TObjString(
"MultiTargetRegression Foam")));
96 cout <<
"ERROR: no Foams found in file: " << fileName << endl;
101 TListIter foamIter(&foam_list);
102 TPair *fm_pair = NULL;
104 while ((fm_pair = (TPair*) foamIter())) {
105 kDim = ((TMVA::PDEFoam*) fm_pair->
Key())->GetTotDim();
106 cout <<
"Foam loaded: " << ((TObjString*) fm_pair->
Value())->String()
107 <<
" (dimension = " << kDim <<
")" << endl;
111 TMVA::PDEFoamKernelBase *kernel =
new TMVA::PDEFoamKernelTrivial();
125 const TString& cell_value_description,
129 TCanvas* canvas = NULL;
130 TH1D* projection = NULL;
133 TListIter it(&foam_list);
134 TPair* fm_pair =
nullptr;
135 while ((fm_pair = (TPair*) it())) {
136 TMVA::PDEFoam* foam = (TMVA::PDEFoam*) fm_pair->
Key();
138 TString foam_caption(((TObjString*) fm_pair->
Value())->String());
142 "1-dimensional PDEFoam", 400, 400);
144 projection = foam->
Draw1Dim(cell_value, 100, kernel);
145 projection->
SetTitle(cell_value_description +
" of " + foam_caption
146 +
";" + variable_name);
156 const TString& cell_value_description,
160 TCanvas* canvas =
nullptr;
161 TH2D* projection =
nullptr;
164 TListIter it(&foam_list);
165 TPair* fm_pair = NULL;
166 while ((fm_pair = (TPair*) it())) {
167 TMVA::PDEFoam* foam = (TMVA::PDEFoam*) fm_pair->
Key();
169 TString foam_caption(((TObjString*) fm_pair->
Value())->String());
170 const Int_t kDim = ((TMVA::PDEFoam*) fm_pair->
Key())->GetTotDim();
173 for (
Int_t i = 0; i < kDim; ++i) {
174 for (
Int_t k = i + 1; k < kDim; ++k) {
178 (
Int_t)(400/(1.-0.2)), 400);
182 cell_value_description.
Data(),
189 projection = foam->
Project2(i, k, cell_value, kernel);
191 projection->
Draw(
"COLZ");
205 cout <<
"read file: " << fileName << endl;
211 TListIter foamIter(
gDirectory->GetListOfKeys());
212 TKey *foam_key =
nullptr;
213 TCanvas *canv =
nullptr;
214 while ((foam_key = (TKey*) foamIter())) {
217 if (!class_name.Contains(
"PDEFoam"))
219 cout <<
"PDEFoam found: " << class_name <<
" " <<
name << endl;
222 TMVA::PDEFoam *foam = (TMVA::PDEFoam*) foam_key->
ReadObj();
243 if (xsize > 0.15) xsize=0.1;
245 TLine *a1 =
new TLine(
x-xscale/4,
y-ysize,
x-xscale,
y-ysize*2);
251 TLine *a1 =
new TLine(
x+xscale/4,
y-ysize,
x+xscale,
y-ysize*2);
257 TPaveText *t =
new TPaveText(
x-xsize,
y-ysize,
x+xsize,
y+ysize,
"NDC");
278 cell->
GetHcub(cellPosi, cellSize);
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
TVectorT< Double_t > TVectorD
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
void Update() override
Update canvas pad buffers.
static Int_t GetColor(const char *hexcolor)
void Show()
Show control bar.
void AddButton(TControlBarButton *button)
Add button.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Close(Option_t *option="") override
Close a file.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
void SetTitle(const char *title) override
Change/set the title.
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual const char * GetClassName() const
virtual TObject * ReadObj()
To read a TObject* from the file.
void Add(TObject *obj) override
UInt_t GetTreeDepth(UInt_t depth=0)
Get depth of cell tree, starting at this cell.
PDEFoamCell * GetDau1() const
PDEFoamCell * GetDau0() const
TObject * GetElement() const
void GetHcub(PDEFoamVect &, PDEFoamVect &) const
Provides size and position of the cell These parameter are calculated by analyzing information in all...
This class is the abstract kernel interface for PDEFoam.
Implementation of PDEFoam.
TObjString * GetVariableName(Int_t idx)
Float_t VarTransformInvers(Int_t idim, Float_t x) const
TH1D * Draw1Dim(ECellValue cell_value, Int_t nbin, PDEFoamKernelBase *kernel=nullptr)
Draws 1-dimensional foam (= histogram).
PDEFoamCell * GetRootCell() const
virtual TH2D * Project2(Int_t idim1, Int_t idim2, ECellValue cell_value=kValue, PDEFoamKernelBase *kernel=nullptr, UInt_t nbin=50)
Project foam variable idim1 and variable idim2 to histogram.
const char * GetName() const override
Returns name of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void Draw(Option_t *option="") override
Draw this pave with its current attributes.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Initialize(Bool_t useTMVAStyle=kTRUE)
void Plot1DimFoams(TList &foam_list, TMVA::ECellValue cell_value, const TString &cell_value_description, TMVA::PDEFoamKernelBase *kernel)
void PlotNDimFoams(TList &foam_list, TMVA::ECellValue cell_value, const TString &cell_value_description, TMVA::PDEFoamKernelBase *kernel)
void PlotFoams(TString fileName="weights/TMVAClassification_PDEFoam.weights_foams.root", bool useTMVAStyle=kTRUE)
void DrawCell(TMVA::PDEFoamCell *cell, TMVA::PDEFoam *foam, Double_t x, Double_t y, Double_t xscale, Double_t yscale)
void Plot(TString fileName, TMVA::ECellValue cv, TString cv_long, bool useTMVAStyle=kTRUE)
void PlotCellTree(TString fileName, TString cv_long, bool useTMVAStyle=kTRUE)