The Gaudi Framework  master (37c0b60a)
readMetaData.C
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <TFile.h>
12 #include <TTree.h>
13 #include <map>
14 #include <stdio.h>
15 #include <string>
16 
17 #include <TApplication.h>
18 #include <TColor.h>
19 #include <TDatime.h>
20 #include <TGColorSelect.h>
21 #include <TGComboBox.h>
22 #include <TGHtml.h>
23 #include <TGLabel.h>
24 #include <TGNumberEntry.h>
25 #include <TROOT.h>
26 #include <TTimeStamp.h>
27 
28 using namespace std;
29 
30 class Widget {
31 private:
32  TString fHeader; // HTML header
33  TString fFooter; // HTML footer
34  TString fHtml_text; // output HTML string
35 
36  TGMainFrame* fMain; // main frame
37  TGHtml* fHtml; // html widget to display HTML calendar
38 public:
39  void MakeHeader();
40  void MakeFooter();
42  virtual ~Widget();
43  TString Html() const { return fHtml_text; }
45 };
47  fHeader = "<html><head><title>Meta Data Viewer</title></head>";
48  fHeader += "<body>\n";
49  fHeader += "<center><H2>Meta Data Viewer</H2></center>";
50 }
51 void Widget::MakeFooter() { fFooter = "</body></html>"; }
52 
54  MakeHeader();
55  MakeFooter();
56 
58 
59  fHtml_text = fHeader;
60  fHtml_text += "<table border='1' style='width:100%'>";
61 
62  for ( iter = md.begin(); iter != md.end(); iter++ ) {
63  fHtml_text += "<tr><td><font color='black'><b>";
64  fHtml_text += iter->first;
65  fHtml_text += "</b></font></td><td><font color='blue'><b>";
66  fHtml_text += iter->second;
67  fHtml_text += "</b></font></td></tr>";
68  }
69  fHtml_text += "</table>";
70  fHtml_text += fFooter;
71 
72  // Main window.
73  fMain = new TGMainFrame( gClient->GetRoot(), 10, 10, kVerticalFrame );
74  fMain->SetCleanup( kDeepCleanup ); // delete all subframes on exit
75  // create HTML widget
76  fHtml = new TGHtml( fMain, 1, 1 );
77  fMain->AddFrame( fHtml, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 5, 2, 2 ) );
78  fHtml->ParseText( (char*)fHtml_text.Data() );
79  // terminate ROOT session when window is closed
80  fMain->Connect( "CloseWindow()", "TApplication", gApplication, "Terminate()" );
81  fMain->DontCallClose();
82 
83  fMain->MapSubwindows();
84  fMain->Resize( 700, 700 );
85 
86  // set minimum size of main window
87  fMain->SetWMSizeHints( fMain->GetDefaultWidth(), fMain->GetDefaultHeight(), 1000, 1000, 0, 0 );
88  fMain->MapRaised();
89 }
90 Widget::~Widget() { delete fMain; }
91 void readMetaData() {
92  TFile mFile( "TupleEx.root" ); // TODO update name of the file
93  map<string, string>* mdMap = (map<string, string>*)mFile.Get( "info" );
94  map<string, string> newMap = *mdMap;
95  new Widget( newMap );
96 }
Widget::MakeHeader
void MakeHeader()
Definition: readMetaData.C:46
Widget::fHtml
TGHtml * fHtml
Definition: readMetaData.C:37
Widget::Widget
Widget(map< string, string > md)
Definition: readMetaData.C:53
Widget::~Widget
virtual ~Widget()
Definition: readMetaData.C:90
std::map
STL class.
Widget::ClassDef
ClassDef(Widget, 0)
Widget::fHeader
TString fHeader
Definition: readMetaData.C:32
Widget::Html
TString Html() const
Definition: readMetaData.C:43
std::map::begin
T begin(T... args)
std
STL namespace.
Widget::MakeFooter
void MakeFooter()
Definition: readMetaData.C:51
std::map::end
T end(T... args)
Widget
Definition: readMetaData.C:30
Widget::fFooter
TString fFooter
Definition: readMetaData.C:33
Widget::fMain
TGMainFrame * fMain
Definition: readMetaData.C:36
Widget::fHtml_text
TString fHtml_text
Definition: readMetaData.C:34
readMetaData
void readMetaData()
Definition: readMetaData.C:91