/// Generates the root file output of the macro MacroName void makerootfile(const char *MacroName, const char *IN, const char *OutDir, bool cp, bool py) { // Execute the macro as a C++ one or a Python one. if (!py) gROOT->ProcessLine(Form(".x %s",MacroName)); else gROOT->ProcessLine(Form("TPython::ExecScript(\"%s\");",MacroName)); // If needed, copy the macro in the documentation directory. if (cp) { TString MN = MacroName; Int_t i = MN.Index("("); Int_t l = MN.Length(); if (i>0) MN.Remove(i, l); gSystem->Exec(TString::Format("cp %s %s/macros", MN.Data(), OutDir)); } // Iterate over all the pads generated by the macro and produce the corresponding pictures. TIter iCanvas(gROOT->GetListOfCanvases()); TCanvas* canvas = 0; int ImageNum = 0; auto f = new TFile( TString::Format("%s/html/%s.root",OutDir,IN),"RECREATE"); while ((canvas = (TCanvas*) iCanvas())) { ImageNum++; canvas->SetName(TString::Format("pict%d_%s",ImageNum,IN)); canvas->Write(); } f->Close(); // Build the html file inlining the JS pictures int i; FILE *fh = fopen(TString::Format("%s/macros/%s.html",OutDir,IN), "w"); TIter next(gROOT->GetListOfCanvases()); int cw, ch; fprintf(fh,"
\n"); for (i=1; i<=ImageNum; i++) { canvas = (TCanvas*)next(); cw = canvas->GetWindowWidth(); ch = canvas->GetWindowHeight(); fprintf(fh,"
\n", i,IN,cw,ch); } fprintf(fh,"
\n"); fprintf(fh,"\n"); fprintf(fh,"\n"); fclose(fh); }