From c524c820609a294e69658d3f624f0c6c5bbed82c Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <fwinkl@cern> Date: Thu, 23 Jul 2020 14:43:26 +0200 Subject: [PATCH] TrigValTools: Delete TRoot2Html Delete obsolete TRoot2Html (ATR-20090). ROOT files can just be browsed directly with jsroot (see root2html.py). --- .../TrigValTools/CMakeLists.txt | 3 - .../TrigValTools/TrigValTools/TRoot2Html.h | 92 -------- .../TrigValTools/TrigValToolsDict.h | 3 +- .../TrigValTools/TrigValTools/selection.xml | 3 +- .../TrigValTools/html/root2html/index.html | 12 - .../TrigValTools/html/root2html/tree.html | 63 ------ .../TrigValTools/src/TRoot2Html.cxx | 211 ------------------ 7 files changed, 2 insertions(+), 385 deletions(-) delete mode 100644 Trigger/TrigValidation/TrigValTools/TrigValTools/TRoot2Html.h delete mode 100644 Trigger/TrigValidation/TrigValTools/html/root2html/index.html delete mode 100644 Trigger/TrigValidation/TrigValTools/html/root2html/tree.html delete mode 100644 Trigger/TrigValidation/TrigValTools/src/TRoot2Html.cxx diff --git a/Trigger/TrigValidation/TrigValTools/CMakeLists.txt b/Trigger/TrigValidation/TrigValTools/CMakeLists.txt index 6bc41d4302e..45e23e0bfbd 100644 --- a/Trigger/TrigValidation/TrigValTools/CMakeLists.txt +++ b/Trigger/TrigValidation/TrigValTools/CMakeLists.txt @@ -23,9 +23,6 @@ atlas_install_python_modules( python/*.py python/TrigValSteering bin/chainDump.p atlas_install_scripts( bin/*.py test/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_scripts( bin/*.pl bin/*.sh ) atlas_install_data( share/*.json share/*.conf ) -atlas_install_generic( html/root2html/*.html - DESTINATION share/TrigValTools/root2html - EXECUTABLE ) # Unit tests: atlas_add_test( TrigValSteering_unit_test diff --git a/Trigger/TrigValidation/TrigValTools/TrigValTools/TRoot2Html.h b/Trigger/TrigValidation/TrigValTools/TrigValTools/TRoot2Html.h deleted file mode 100644 index 10c5dd2b9ca..00000000000 --- a/Trigger/TrigValidation/TrigValTools/TrigValTools/TRoot2Html.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGVALTOOLS_TROOT2HTML_H -#define TRIGVALTOOLS_TROOT2HTML_H - -/** - * @file TRoot2Html.h - * @brief TRoot2Html class - * @author Frank Winklmeier - * - * $Id: TRoot2Html.h 702373 2015-10-22 13:55:56Z fwinkl $ - */ - -#include <fstream> -#include <vector> - -#include "TMultiFileLooper.h" -#include "TDirectory.h" -#include "TString.h" -#include "TH1.h" - -class TPRegexp; - -/** - * @class TRoot2Html - * @brief Create a (static) web page from ROOT histograms - * @author Frank Winklmeier - * - * Create images from histograms in root files and assemble them in - * a web page with a tree like naviation structure. - */ -class TRoot2Html : public TMultiFileLooper { - public: - - /// C'tor - TRoot2Html(); - /// D'tor - virtual ~TRoot2Html() {} - /// Copy C'tor (needed for Reflex dictionary generation) - TRoot2Html(const TRoot2Html& other); - - /// \name Processing hooks - //@{ - virtual void beginJob(); - virtual void endJob(); - virtual void beforeFile(); - virtual void afterFile(); - virtual void beforeDir(); - virtual void afterDir(); - virtual void processKey(TDirectory& dir, TKey& key); - //@} - - /// Output directory for HTML pages - void setOutputDir(const char* dir) {m_outDir = dir;} - - /// Set image size - void setImageSize(Int_t width, Int_t height) {m_imgWidth = width; m_imgHeight = height;} - - /// Add draw options for images (selected by regular expression on name) - void addDrawOptions(const char* regexp, const char* options); - - /// Add draw options for images (selected by regular expression on class name) - void addClassDrawOptions(const char* regexp, const char* options); - - /// Show full file name in tree - void showFullFileName(Bool_t show = kTRUE) {m_showFullFileName = show;} - - private: - TString m_fileList; - TString m_outDir; - Int_t m_imgHeight, m_imgWidth; - std::ofstream m_xml; - Int_t m_nodeId; - - Bool_t m_showFullFileName; - std::vector< std::pair<TPRegexp*,TString> > m_drawOptions; - std::vector< std::pair<TPRegexp*,TString> > m_classDrawOptions; - - TString hist2Png(TDirectory& dir, const TString& name); - TString getDrawOptions(const TH1& h); - - TString xmlTreeItem(const char* text); - TString xmlTreeItemClose(); - TString xmlUserData(const char* name, const char* data); - - // Not copyable due to the ofstream. - TRoot2Html& operator= (const TRoot2Html&); -}; - -#endif diff --git a/Trigger/TrigValidation/TrigValTools/TrigValTools/TrigValToolsDict.h b/Trigger/TrigValidation/TrigValTools/TrigValTools/TrigValToolsDict.h index 28064c13111..f95c08a5c7e 100644 --- a/Trigger/TrigValidation/TrigValTools/TrigValTools/TrigValToolsDict.h +++ b/Trigger/TrigValidation/TrigValTools/TrigValTools/TrigValToolsDict.h @@ -1,10 +1,9 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "TrigValTools/TRootCompare.h" #include "TrigValTools/TFileLooper.h" #include "TrigValTools/TMultiFileLooper.h" -#include "TrigValTools/TRoot2Html.h" #include "TPRegexp.h" diff --git a/Trigger/TrigValidation/TrigValTools/TrigValTools/selection.xml b/Trigger/TrigValidation/TrigValTools/TrigValTools/selection.xml index 512c9989451..2102ba54f93 100644 --- a/Trigger/TrigValidation/TrigValTools/TrigValTools/selection.xml +++ b/Trigger/TrigValidation/TrigValTools/TrigValTools/selection.xml @@ -2,5 +2,4 @@ <class name="TRootCompare" /> <class name="TFileLooper" /> <class name="TMultiFileLooper" /> - <class name="TRoot2Html" /> -</lcgdict> \ No newline at end of file +</lcgdict> diff --git a/Trigger/TrigValidation/TrigValTools/html/root2html/index.html b/Trigger/TrigValidation/TrigValTools/html/root2html/index.html deleted file mode 100644 index faa2a8df09b..00000000000 --- a/Trigger/TrigValidation/TrigValTools/html/root2html/index.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- Main html file for root2html --!> - -<html> - <head> - <title>HLT monitoring histograms</title> - </head> - <frameset cols="320,*" border="0"> - <frame src="tree.html" name="tree"></frame> - <frame src="" name="img"></frame> - </frameset> -</html> diff --git a/Trigger/TrigValidation/TrigValTools/html/root2html/tree.html b/Trigger/TrigValidation/TrigValTools/html/root2html/tree.html deleted file mode 100644 index fc7a2ea9109..00000000000 --- a/Trigger/TrigValidation/TrigValTools/html/root2html/tree.html +++ /dev/null @@ -1,63 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- Tree navigation for root2html --> - -<html> - <body> - <link rel="STYLESHEET" type="text/css" href="http://atlas-project-trigger-release-validation.web.cern.ch/atlas-project-trigger-release-validation/www/dhtmlxTree/css/dhtmlXTree.css"> - <script src="http://atlas-project-trigger-release-validation.web.cern.ch/atlas-project-trigger-release-validation/www/dhtmlxTree/js/dhtmlXCommon.js"></script> - <script src="http://atlas-project-trigger-release-validation.web.cern.ch/atlas-project-trigger-release-validation/www/dhtmlxTree/js/dhtmlXTree.js"></script> - - <input type="button" name="draw" value="Show selected" onClick="drawSelected()"></input> - <input type="button" name="clear" value="ClearAll" onClick="clearAll()"></input> - <p><font size="-2"> - To show histograms, click on single leaf or select multiple and click on "Show selected". - (Please be patient while the tree loads...) - </font></p> - <div id="naviTree" style="width:300"></div> - <div id="footer"><font size="-2">Created by root2html<br>(C) Frank Winklmeier<br>powered by <a href="http://www.scbr.com/docs/products/dhtmlxTree/" target="new">dhtmlXTree</a></font></div> - <script language="JavaScript"> - tree = new dhtmlXTreeObject('naviTree',"100%","80%",0); - tree.setImagePath("http://atlas-project-trigger-release-validation.web.cern.ch/atlas-project-trigger-release-validation/www/dhtmlxTree/imgs/"); - tree.enableCheckBoxes(true); - tree.enableThreeStateCheckboxes(true); - tree.loadXML("tree.xml"); - tree.setOnClickHandler(doOnClick); - - // onClick event handler - // Load image path on click - function doOnClick(nodeId) { - var imgPath = tree.getUserData(nodeId,"img"); - if (imgPath != undefined) parent["img"].location.href = imgPath; - } - - // show all selected plots - function drawSelected() { - var doc = parent["img"].document; - doc.open(); - doc.write("<html><body>"); - - // get list of all selected elements - var ids = tree.getAllChecked().split(','); - // loop over all elements and write <img> tag into frame - for (var i in ids) { - var imgPath = tree.getUserData(ids[i],"img"); - if (imgPath != undefined) { - doc.write('<img src="'); - doc.write(imgPath); - doc.write('"'); - } - } - doc.write("</body></html>"); - doc.close() - } - - // clear all selected items - function clearAll() { - for (var i in tree.getAllChecked().split(',')) { - tree.setCheck(i,false); - } - } - </script> - - </body> -</html> diff --git a/Trigger/TrigValidation/TrigValTools/src/TRoot2Html.cxx b/Trigger/TrigValidation/TrigValTools/src/TRoot2Html.cxx deleted file mode 100644 index 93d24229bec..00000000000 --- a/Trigger/TrigValidation/TrigValTools/src/TRoot2Html.cxx +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration -*/ - -/** - * @file TRoot2Html.cxx - * @brief TRoot2Html implementation - * @author Frank Winklmeier - * - * $Id: TRoot2Html.cxx,v 1.1 2008-07-28 11:02:00 fwinkl Exp $ - */ - -#include "TrigValTools/TRoot2Html.h" - -#include <iostream> -#include <sstream> -#include "TError.h" -#include "TClass.h" -#include "TH1.h" -#include "TFile.h" -#include "TCanvas.h" -#include "TSystem.h" -#include "TKey.h" -#include "TPRegexp.h" - -using namespace std; - -TRoot2Html::TRoot2Html() : - m_nodeId(1), - m_showFullFileName(kFALSE) -{ - setOutputDir("./"); - setImageSize(400,400); -} - -TRoot2Html::TRoot2Html(const TRoot2Html& other): - TMultiFileLooper(other), - m_imgHeight(other.m_imgHeight), - m_imgWidth(other.m_imgWidth), - m_nodeId(other.m_nodeId), - m_showFullFileName(other.m_showFullFileName) -{ -} - -void TRoot2Html::beginJob() -{ - m_xml.open(m_outDir+"/tree.xml"); - if (!m_xml) { - cout << "Cannot write to directory " << m_outDir << endl; - return; - } - - m_xml << "<?_xml version='1.0' encoding='iso-8859-1'?>" << endl; - m_xml << "<!-- This file was auto generated by root2html -->" << endl; - m_xml << "<!-- Use it with the dhtmlxTree component (http://www.scbr.com/docs/products/dhtmlxTree) -->" << endl; - m_xml << "<tree id=\"0\">" << endl; - m_nodeId = 1; -} - -void TRoot2Html::endJob() -{ - m_xml << "</tree>" << endl; - m_xml.close(); -} - - -void TRoot2Html::beforeFile() -{ - TString treeNodeName; - if (m_showFullFileName) treeNodeName = file()->GetName(); - else treeNodeName = gSystem->BaseName(file()->GetName()); - - m_xml << "<!-- Start of " << treeNodeName << " -->" << endl; - m_xml << xmlTreeItem(treeNodeName).Data() << endl; - - // Create output directory - gSystem->mkdir(m_outDir+"/img", true); -} - -void TRoot2Html::afterFile() -{ - m_xml << xmlTreeItemClose().Data() << endl; -} - - -void TRoot2Html::beforeDir() -{ - TString s(getPathFromDir(*gDirectory)); - TString imgDir = TString(m_outDir) + "/img/" + s; - gSystem->mkdir(imgDir, true); - - m_xml << xmlTreeItem(gDirectory->GetName()).Data() << endl; -} - -void TRoot2Html::afterDir() -{ - m_xml << xmlTreeItemClose().Data() << endl; -} - - -void TRoot2Html::processKey(TDirectory& dir, TKey& key) -{ - dir.cd(); - - TObject* obj = key.ReadObj(); - if (obj->IsA()->InheritsFrom("TH1")) { - m_xml << xmlTreeItem(key.GetName()).Data() << endl; - TString imgPath = hist2Png(*gDirectory, key.GetName()); - if (imgPath!="") { - m_xml << xmlUserData("img",imgPath).Data() << endl; - } - m_xml << xmlTreeItemClose().Data() << endl; - } -} - - -// Save histogram 'name' from 'dir' in 'm_outDir/img' -// Return "" on error otherwise image path relative to m_outDir -TString TRoot2Html::hist2Png(TDirectory& dir, const TString& name) -{ - TH1* h = (TH1*)dir.Get(name); - if (h==0) { - cout << "hist2Png: Cannot load histogram " << name << endl; - return ""; - } - - TCanvas c("c","c",m_imgWidth,m_imgHeight); - TString options(getDrawOptions(*h)); - if (m_verbose) cout << "Drawing histogram " << h->GetName() - << " (" << h->ClassName() << ") with options '" - << options << "'" << endl; - h->Draw(options); - TString s(getPathFromDir(dir)); - TString pngName = "img/" + s + "/" + name + ".png"; - - // Suppress the info message when saving file - Int_t oldIgnoreLevel = gErrorIgnoreLevel; - if (!m_verbose) gErrorIgnoreLevel = kWarning; - c.SaveAs(m_outDir+"/"+pngName); - - gErrorIgnoreLevel = oldIgnoreLevel; - - return pngName; -} - - -// Set draw options for all histograms matching re -void TRoot2Html::addDrawOptions(const char* regexp, const char* options) -{ - if (regexp && options) { - TPRegexp* re = new TPRegexp(regexp); - if (re) m_drawOptions.push_back(std::pair<TPRegexp*,TString>(re,options)); - } -} - -void TRoot2Html::addClassDrawOptions(const char* regexp, const char* options) -{ - if (regexp && options) { - TPRegexp* re = new TPRegexp(regexp); - if (re) m_classDrawOptions.push_back(std::pair<TPRegexp*,TString>(re,options)); - } -} - - -// return draw options for specified histogram -TString TRoot2Html::getDrawOptions(const TH1& h) -{ - TString options(""); - - // First check if we have class wide draw options for this histogram - vector< pair<TPRegexp*,TString> >::iterator iter; - for (iter=m_classDrawOptions.begin(); iter!=m_classDrawOptions.end(); iter++) { - if (iter->first->Match(h.ClassName())>0) { - options = iter->second; - break; - } - } - - // Check if any regexp matches the histogram name - for (iter=m_drawOptions.begin(); iter!=m_drawOptions.end(); iter++) { - if (iter->first->Match(h.GetName())>0) { - options = iter->second; - break; - } - } - - return options; -} - -// Tree node with text and id -TString TRoot2Html::xmlTreeItem(const char* text) -{ - TString s; - s.Form("<item text=\"%s\" id=\"%d\">",text,m_nodeId); - m_nodeId++; - return s; -} - -// Tree node close -TString TRoot2Html::xmlTreeItemClose() -{ - return "</item>"; -} - -// User data for tree node -TString TRoot2Html::xmlUserData(const char* name, const char* data) -{ - TString s; - s.Form("<userdata name=\"%s\">%s</userdata>",name,data); - return s; -} -- GitLab