-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathhyperk_esd_html_summary.C
227 lines (192 loc) · 5.64 KB
/
hyperk_esd_html_summary.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#include "hyperk_esd_html_summary.h"
#include <WCSimRootEvent.hh>
//==============================================================================
//==============================================================================
//______________________________________________________________________________
HtmlObjTable::HtmlObjTable(const char *name, Int_t nfields, Bool_t exp) :
fName(name), fNFields(nfields), fExpand(exp)
{
// Constructor.
fNValues=0;
fValues = new TArrayF[fNFields];
fIsInt = new bool[fNFields];
for (int ix=0;ix<fNFields;ix++)
{
//fValues[ix].Set(nvals);
fIsInt[ix]=kFALSE;
}
fLabels = new TString[fNFields];
}
void HtmlObjTable::SetValue(Int_t col, Int_t row, Float_t val)
{
if(row+1>fNValues)
{
fValues[col].Set(row+1);
}
fValues[col].SetAt(val, row);
}
//______________________________________________________________________________
HtmlObjTable::~HtmlObjTable()
{
// Destructor.
delete [] fValues;
delete [] fIsInt;
delete [] fLabels;
}
//______________________________________________________________________________
void HtmlObjTable::Build()
{
// Build HTML code.
fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
BuildTitle();
if (fExpand && (fNFields > 0) && (fNValues > 0)) {
BuildLabels();
BuildTable();
}
fHtml += "</table>";
}
//______________________________________________________________________________
void HtmlObjTable::BuildTitle()
{
// Build table title.
fHtml += "<tr><td colspan=";
fHtml += Form("%d>", fNFields+1);
fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
fHtml += "<tr><td align=left>";
fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
fHtml += fName;
fHtml += "</i></b></font></td>";
fHtml += "<td>";
fHtml += "<td align=right> ";
fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
//fHtml += Form("Size = %d", fNValues);
fHtml += "</i></b></font></td></tr>";
fHtml += "</table>";
fHtml += "</td></tr>";
}
//______________________________________________________________________________
void HtmlObjTable::BuildLabels()
{
// Build table labels.
Int_t i;
fHtml += "<tr bgcolor=c0c0ff>";
//fHtml += "<th> </th>"; // for the check boxes
for (i=0;i<fNFields;i++) {
fHtml += "<th> ";
fHtml += fLabels[i];
fHtml += " </th>"; // for the check boxes
}
fHtml += "</tr>";
}
//______________________________________________________________________________
void HtmlObjTable::BuildTable()
{
// Build part of table with values.
for (int i = 0; i < (fNValues+1); i++) {
if (i%2)
fHtml += "<tr bgcolor=e0e0ff>";
else
fHtml += "<tr bgcolor=ffffff>";
TString name = fName;
name.ReplaceAll(" ", "_");
// checkboxes
// fHtml += "<td bgcolor=d0d0ff align=\"center\">";
// fHtml += "<input type=\"checkbox\" name=\"";
// fHtml += name;
// fHtml += Form("[%d]\">",i);
// fHtml += "</td>";
fHtml += Form("<td> %s", fRowNames[i].Data());
fHtml += "</td>";
for (int j = 1; j < fNFields; j++) {
fHtml += "<td width=";
fHtml += Form("%d%%", 100/fNFields);
fHtml += " align=\"center\"";
fHtml += ">";
if(fIsInt[j])
fHtml += Form("%2i", (int)fValues[j][i]);
else
fHtml += Form("%1.2f", fValues[j][i]);
fHtml += "</td>";
}
fHtml += "</tr> ";
}
}
//______________________________________________________________________________
HtmlSummary::HtmlSummary(const char *title) : fNTables(0), fTitle(title)
{
// Constructor.
fObjTables = new TOrdCollection();
}
//______________________________________________________________________________
HtmlSummary::~HtmlSummary()
{
// Destructor.
Reset();
}
//______________________________________________________________________________
HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields,
Bool_t exp, Option_t *option)
{
// Add a new table in our list of tables.
TString opt = option;
opt.ToLower();
HtmlObjTable *table = new HtmlObjTable(name, nfields, exp);
fNTables++;
if (opt.Contains("first"))
fObjTables->AddFirst(table);
else
fObjTables->Add(table);
return table;
}
//______________________________________________________________________________
void HtmlSummary::Clear(Option_t *option)
{
// Clear the table list.
if (option && option[0] == 'D')
fObjTables->Delete(option);
else
fObjTables->Clear(option);
fNTables = 0;
}
//______________________________________________________________________________
void HtmlSummary::Reset(Option_t *)
{
// Reset (delete) the table list;
delete fObjTables; fObjTables = 0;
fNTables = 0;
}
//______________________________________________________________________________
void HtmlSummary::Build()
{
// Build the summary.
MakeHeader();
for (int i=0;i<fNTables;i++) {
GetTable(i)->Build();
fHtml += GetTable(i)->Html();
}
MakeFooter();
}
//______________________________________________________________________________
void HtmlSummary::MakeHeader()
{
// Make HTML header.
fHeader = "<html><head><title>";
fHeader += fTitle;
fHeader += "</title></head><body>";
fHeader += "<center><h2><font color=#2222ee><i>";
fHeader += fTitle;
fHeader += "</i></font></h2></center>";
fHtml = fHeader;
}
//______________________________________________________________________________
void HtmlSummary::MakeFooter()
{
// Make HTML footer.
fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
// fFooter += "Example of using Html widget to display tabular data";
// fFooter += "<br>";
// fFooter += "(c) 2007-2010 Bertrand Bellenot";
fFooter += "</font></strong></center></body></html>";
fHtml += fFooter;
}
//==============================================================================