51 static Int_t icanvas = -1;
52 Int_t ixc = 100 + (icanvas)*40;
53 Int_t iyc = 0 + (icanvas+1)*20;
58 ixc, 0 + (icanvas+1)*20, 1000, 650 );
68 while ((key = (
TKey*)next())) {
81 cout <<
"Big troubles in \"draw_network\" (1)" << endl;
84 std::cout<<h->
GetName()<<
"----"<<hName<<std::endl;
90 for (
Int_t i = 0; i < n1; i++) {
91 for (
Int_t j = 0; j < n2; j++) {
93 if (maxWeight < weight) maxWeight = weight;
99 cout <<
"Error: could not find histograms" << endl;
108 while ((key = (
TKey*)next())) {
118 cout <<
"Big troubles in \"draw_network\" (2)" << endl;
124 draw_layer(dataset,c, h, count++, numHists+1, maxWeight);
137 t->
DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() - 0.033,
138 Form(
"Epoch: %s", epoch.
Data() ) );
148 TString dirname =
"movieplots";
149 TString foutname = dirname +
"/" + hName;
154 cout <<
"storing file: " << foutname << endl;
160 TString fname = dataset+
"/plots/network";
174 const Double_t LABEL_HEIGHT = 0.032;
176 Double_t effWidth = 0.8*(1.0-LABEL_WIDTH)/nLayers;
178 Double_t margY = LABEL_HEIGHT - height;
180 for (
Int_t i = 0; i < nLayers; i++) {
182 if (i == nLayers-1) label =
"Output layer";
183 Double_t cx = i*(1.0-LABEL_WIDTH)/nLayers+1.0/(2.0*nLayers)+LABEL_WIDTH;
205 Double_t effHeight = 0.8*LABEL_HEIGHT;
208 if (varNames == 0) exit(1);
212 for (
Int_t i = 0; i < nInputs; i++) {
213 if (i != nInputs-1) input = varNames[i];
214 else input =
"Bias node";
223 t->
DrawText( x, y+0.018, input +
" :");
231 const TString directories[6] = {
"InputVariables_NoTransform",
232 "InputVariables_DecorrTransform",
233 "InputVariables_PCATransform",
235 "InputVariables_Norm",
236 "InputVariables_Deco"};
239 for (
Int_t i=0; i<6; i++) {
244 cout <<
"*** Big troubles in macro \"network.cxx\": could not find directory for input variables, " 245 <<
"and hence could not determine variable names --> abort" << endl;
256 while ((key = (
TKey*)next())) {
257 if (key->GetCycle() != 1)
continue;
259 if (!
TString(key->GetName()).Contains(
"__S") &&
260 !
TString(key->GetName()).Contains(
"__r") &&
261 !
TString(key->GetName()).Contains(
"Regression"))
263 if (
TString(key->GetName()).Contains(
"target"))
269 TH1 *sig = (
TH1*)key->ReadObj();
272 vars[ivar] = hname; ivar++;
274 if (ivar > nVars-1)
break;
277 if (ivar != nVars-1) {
278 cout <<
"*** Troubles in \"network.cxx\": did not reproduce correct number of " 279 <<
"input variables: " << ivar <<
" != " << nVars << endl;
288 TImage *activation = NULL;
290 switch (whichActivation) {
298 cout <<
"Activation index " << whichActivation <<
" is not known." << endl;
299 cout <<
"You messed up or you need to modify network.cxx to introduce a new " 300 <<
"activation function (and image) corresponding to this index" << endl;
303 if (activation == NULL) {
304 cout <<
"Could not create an image... exit" << endl;
313 TPad* p =
new TPad(name+
"", name+
"", cx-radx, cy-rady, cx+radx, cy+rady);
325 const Double_t MAX_NEURONS_NICE = 12;
335 cx1 = iHist*(1.0-LABEL_WIDTH)/nLayers + 1.0/(2.0*nLayers) + LABEL_WIDTH;
339 cx2 = (iHist+1)*(1.0-LABEL_WIDTH)/nLayers + 1.0/(2.0*nLayers) + LABEL_WIDTH;
343 if (nNeurons1 > MAX_NEURONS_NICE)
344 effRad1 = 0.8*(1.0-LABEL_HEIGHT)/(2.0*nNeurons1);
346 for (
Int_t i = 0; i < nNeurons1; i++) {
347 cy1[nNeurons1-i-1] = i*(1.0-LABEL_HEIGHT)/nNeurons1 + 1.0/(2.0*nNeurons1) + LABEL_HEIGHT;
352 effRad1*ratio, effRad1, 0, 360, 0 );
359 if (nNeurons1 > MAX_NEURONS_NICE)
continue;
361 Int_t whichActivation = 0;
362 if (iHist==0 || iHist==nLayers-1 || i==0) whichActivation = 1;
364 rad*ratio, rad, whichActivation);
368 if (iHist == 0)
draw_input_labels(dataset,nNeurons1, cy1, rad, (1.0-LABEL_WIDTH)/nLayers);
371 if (nNeurons2 > MAX_NEURONS_NICE)
372 effRad2 = 0.8*(1.0-LABEL_HEIGHT)/(2.0*nNeurons2);
374 for (
Int_t i = 0; i < nNeurons2; i++) {
375 cy2[nNeurons2-i-1] = i*(1.0-LABEL_HEIGHT)/nNeurons2 + 1.0/(2.0*nNeurons2) + LABEL_HEIGHT;
378 new TEllipse(cx2, cy2[nNeurons2-i-1], effRad2*ratio, effRad2, 0, 360, 0);
385 if (nNeurons2 > MAX_NEURONS_NICE)
continue;
387 Int_t whichActivation = 0;
388 if (iHist+1==0 || iHist+1==nLayers-1 || i==0) whichActivation = 1;
389 draw_activation(c, cx2, cy2[nNeurons2-i-1], rad*ratio, rad, whichActivation);
392 for (
Int_t i = 0; i < nNeurons1; i++) {
393 for (
Int_t j = 0; j < nNeurons2; j++) {
394 draw_synapse(cx1, cy1[i], cx2, cy2[j], effRad1*ratio, effRad2*ratio,
411 if (weightNormed == 0)
return;
419 arrow->
SetLineColor((
Int_t)((weightNormed+1.0)/2.0*(MAX_COLOR-MIN_COLOR)+MIN_COLOR+0.5));
434 while( (key = (
TKey*)next()) ) {
435 if (!
TString(key->GetName()).BeginsWith(
"Method_MLP"))
continue;
436 if( !
gROOT->GetClass(key->GetClassName())->InheritsFrom(
"TDirectory") )
continue;
438 cout <<
"--- Found directory: " << ((
TDirectory*)key->ReadObj())->
GetName() << endl;
444 while((titkey = (
TKey*)keyIt())) {
445 if( !
gROOT->GetClass(titkey->GetClassName())->InheritsFrom(
"TDirectory") )
continue;
452 cout <<
"No titles found for Method_MLP" << endl;
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
void imgconv(TCanvas *c, const TString &fname)
virtual TList * GetListOfKeys() const
Color_t GetTitleTextColor() const
static Int_t c_DarkBackground
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
TString & ReplaceAll(const TString &s1, const TString &s2)
R__EXTERN TStyle * gStyle
TFile * OpenFile(const TString &fin)
virtual const char * GetClassName() const
virtual void SetConstRatio(Bool_t constRatio=kTRUE)
Set (constRatio = kTRUE) or unset (constRadio = kFALSE) the ratio flag.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
UInt_t GetListOfKeys(TList &keys, TString inherits, TDirectory *dir=0)
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
An abstract interface to image processing library.
static constexpr double rad
void draw_activation(TCanvas *c, Double_t cx, Double_t cy, Double_t radx, Double_t rady, Int_t whichActivation)
void SetCanvasColor(Color_t color=19)
void SetTitleBorderSize(Width_t size=2)
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
static const double x2[5]
virtual TText * DrawTextNDC(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates in NDC.
virtual void Draw(Option_t *option="")
Draw this arrow with its current attributes.
UInt_t GetWindowHeight() const
void Clear()
Clear string without changing its capacity.
Base class for several text objects.
void SetTitleTextColor(Color_t color=1)
Book space in a file, create I/O buffers, to fill them, (un)compress them.
void network(TString dataset, TString fin="TMVA.root", Bool_t useTMVAStyle=kTRUE)
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
void draw_network(TString dataset, TFile *f, TDirectory *d, const TString &hName="weights_hist", Bool_t movieMode=kFALSE, const TString &epoch="")
void draw_layer(TString dataset, TCanvas *c, TH2F *h, Int_t iHist, Int_t nLayers, Double_t maxWeight)
virtual void Draw(Option_t *option="")
Draw this ellipse with its current attributes.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
A Pave (see TPave) with a text centered in the Pave.
TStyle objects may be created to define special styles.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void Initialize(Bool_t useTMVAStyle=kTRUE)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
2-D histogram with a float per channel (see TH1 documentation)}
The most important graphics class in the ROOT system.
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"...
The ROOT global object gROOT contains a list of all defined classes.
void plot_logo(Float_t v_scale=1.0, Float_t skew=1.0)
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
virtual TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory named "apath".
Color_t GetTitleFillColor() const
Width_t GetTitleBorderSize() const
static const double x1[5]
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
UInt_t GetWindowWidth() const
Describe directory structure in memory.
void draw_synapse(Double_t cx1, Double_t cy1, Double_t cx2, Double_t cy2, Double_t rad1, Double_t rad2, Double_t weightNormed)
TString * get_var_names(TString dataset, Int_t nVars)
virtual TObject * ReadObj()
To read a TObject* from the file.
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
void SetTitleFillColor(Color_t color=1)
void draw_input_labels(TString dataset, Int_t nInputs, Double_t *cy, Double_t rad, Double_t layerWidth)
void draw_layer_labels(Int_t nLayers)
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Color_t GetCanvasColor() const
virtual Int_t GetNbinsX() const
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Draw all kinds of Arrows.
virtual void SetBorderSize(Int_t bordersize=4)
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
virtual const char * GetTitle() const
Returns title of object.
virtual Int_t GetNbinsY() const
TImage * findImage(const char *imageName)
const char * Data() const
UInt_t GetListOfTitles(TDirectory *rfdir, TList &titles)