Fork me on GitHub

source: git/display/DelphesHtmlSummary.cc@ cf4a208

ImprovedOutputFile Timing dual_readout llp
Last change on this file since cf4a208 was 8b04b31, checked in by Christophe Delaere <christophe.delaere@…>, 10 years ago

Working summary table

Not all collections are in. To be checked why.

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