Fork me on GitHub

source: git/display/DelphesHtmlSummary.cc@ 781e3118

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 781e3118 was 1fa50c2, checked in by Pavel Demin <pavel.demin@…>, 10 years ago

fix GPLv3 header

  • Property mode set to 100644
File size: 6.6 KB
Line 
1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "display/DelphesHtmlSummary.h"
20#include "TGHtml.h"
21#include "TEveElement.h"
22#include "TEveManager.h"
23#include "TEveEventManager.h"
24#include "TEvePointSet.h"
25#include "TEveTrack.h"
26
27//==============================================================================
28
29DelphesHtmlSummary *fgDelphesHtmlSummary = 0;
30TGHtml *fgHtml = 0;
31
32//==============================================================================
33
34//______________________________________________________________________________
35DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) :
36 fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
37{
38 // Constructor.
39
40 fValues = new TArrayF[fNFields];
41 for (int i=0;i<fNFields;i++)
42 fValues[i].Set(nvals);
43 fLabels = new TString[fNFields];
44}
45
46//______________________________________________________________________________
47DelphesHtmlObjTable::~DelphesHtmlObjTable()
48{
49 // Destructor.
50
51 delete [] fValues;
52 delete [] fLabels;
53}
54
55//______________________________________________________________________________
56void DelphesHtmlObjTable::Build()
57{
58 // Build HTML code.
59
60 fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
61
62 BuildTitle();
63 if (fExpand && (fNFields > 0) && (fNValues > 0)) {
64 BuildLabels();
65 BuildTable();
66 }
67
68 fHtml += "</table>";
69}
70
71//______________________________________________________________________________
72void DelphesHtmlObjTable::BuildTitle()
73{
74 // Build table title.
75
76 fHtml += "<tr><td colspan=";
77 fHtml += Form("%d>", fNFields+1);
78 fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
79 fHtml += "<tr><td align=left>";
80 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
81 fHtml += fName;
82 fHtml += "</i></b></font></td>";
83 fHtml += "<td>";
84 fHtml += "<td align=right> ";
85 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
86 fHtml += Form("Size = %d", fNValues);
87 fHtml += "</i></b></font></td></tr>";
88 fHtml += "</table>";
89 fHtml += "</td></tr>";
90}
91
92//______________________________________________________________________________
93void DelphesHtmlObjTable::BuildLabels()
94{
95 // Build table labels.
96
97 Int_t i;
98 fHtml += "<tr bgcolor=c0c0ff>";
99 fHtml += "<th> </th>"; // for the check boxes
100 for (i=0;i<fNFields;i++) {
101 fHtml += "<th> ";
102 fHtml += fLabels[i];
103 fHtml += " </th>"; // for the check boxes
104 }
105 fHtml += "</tr>";
106}
107
108//______________________________________________________________________________
109void DelphesHtmlObjTable::BuildTable()
110{
111 // Build part of table with values.
112
113 for (int i = 0; i < fNValues; i++) {
114 if (i%2)
115 fHtml += "<tr bgcolor=e0e0ff>";
116 else
117 fHtml += "<tr bgcolor=ffffff>";
118
119 TString name = fName;
120 name.ReplaceAll(" ", "_");
121 // checkboxes
122 fHtml += "<td bgcolor=d0d0ff align=\"center\">";
123 fHtml += "<input type=\"checkbox\" name=\"";
124 fHtml += name;
125 fHtml += Form("[%d]\">",i);
126 fHtml += "</td>";
127
128 for (int j = 0; j < fNFields; j++) {
129 fHtml += "<td width=";
130 fHtml += Form("%d%%", 100/fNFields);
131 fHtml += " align=\"center\"";
132 fHtml += ">";
133 fHtml += Form("%1.4f", fValues[j][i]);
134 fHtml += "</td>";
135 }
136 fHtml += "</tr> ";
137 }
138}
139
140//______________________________________________________________________________
141DelphesHtmlSummary::DelphesHtmlSummary(const char *title) : fNTables(0), fTitle(title)
142{
143 // Constructor.
144
145 fObjTables = new TOrdCollection();
146}
147
148//______________________________________________________________________________
149DelphesHtmlSummary::~DelphesHtmlSummary()
150{
151 // Destructor.
152
153 Reset();
154}
155
156//______________________________________________________________________________
157DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
158 Bool_t exp, Option_t *option)
159{
160 // Add a new table in our list of tables.
161
162 TString opt = option;
163 opt.ToLower();
164 DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp);
165 fNTables++;
166 if (opt.Contains("first"))
167 fObjTables->AddFirst(table);
168 else
169 fObjTables->Add(table);
170 return table;
171}
172
173//______________________________________________________________________________
174void DelphesHtmlSummary::Clear(Option_t *option)
175{
176 // Clear the table list.
177
178 if (option && option[0] == 'D')
179 fObjTables->Delete(option);
180 else
181 fObjTables->Clear(option);
182 fNTables = 0;
183}
184
185//______________________________________________________________________________
186void DelphesHtmlSummary::Reset(Option_t *)
187{
188 // Reset (delete) the table list;
189
190 delete fObjTables; fObjTables = 0;
191 fNTables = 0;
192}
193
194//______________________________________________________________________________
195void DelphesHtmlSummary::Build()
196{
197 // Build the summary.
198
199 MakeHeader();
200 for (int i=0;i<fNTables;i++) {
201 GetTable(i)->Build();
202 fHtml += GetTable(i)->Html();
203 }
204 MakeFooter();
205}
206
207//______________________________________________________________________________
208void DelphesHtmlSummary::MakeHeader()
209{
210 // Make HTML header.
211
212 fHeader = "<html><head><title>";
213 fHeader += fTitle;
214 fHeader += "</title></head><body>";
215 fHeader += "<center><h2><font color=#2222ee><i>";
216 fHeader += fTitle;
217 fHeader += "</i></font></h2></center>";
218 fHtml = fHeader;
219}
220
221//______________________________________________________________________________
222void DelphesHtmlSummary::MakeFooter()
223{
224 // Make HTML footer.
225
226 fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
227 fFooter += "Example of using Html widget to display tabular data";
228 fFooter += "<br>";
229 fFooter += "(c) 2007-2010 Bertrand Bellenot";
230 fFooter += "</font></strong></center></body></html>";
231 fHtml += fFooter;
232}
233
Note: See TracBrowser for help on using the repository browser.