Fork me on GitHub

source: git/display/DelphesHtmlSummary.cc@ a6e8029

Last change on this file since a6e8029 was 341014c, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

apply .clang-format to all .h, .cc and .cpp files

  • Property mode set to 100644
File size: 6.5 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 "TEveElement.h"
21#include "TEveEventManager.h"
22#include "TEveManager.h"
23#include "TEvePointSet.h"
24#include "TEveTrack.h"
25#include "TGHtml.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 {
65 BuildLabels();
66 BuildTable();
67 }
68
69 fHtml += "</table>";
70}
71
72//______________________________________________________________________________
73void DelphesHtmlObjTable::BuildTitle()
74{
75 // Build table title.
76
77 fHtml += "<tr><td colspan=";
78 fHtml += Form("%d>", fNFields + 1);
79 fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
80 fHtml += "<tr><td align=left>";
81 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
82 fHtml += fName;
83 fHtml += "</i></b></font></td>";
84 fHtml += "<td>";
85 fHtml += "<td align=right> ";
86 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
87 fHtml += Form("Size = %d", fNValues);
88 fHtml += "</i></b></font></td></tr>";
89 fHtml += "</table>";
90 fHtml += "</td></tr>";
91}
92
93//______________________________________________________________________________
94void DelphesHtmlObjTable::BuildLabels()
95{
96 // Build table labels.
97
98 Int_t i;
99 fHtml += "<tr bgcolor=c0c0ff>";
100 fHtml += "<th> </th>"; // for the check boxes
101 for(i = 0; i < fNFields; i++)
102 {
103 fHtml += "<th> ";
104 fHtml += fLabels[i];
105 fHtml += " </th>"; // for the check boxes
106 }
107 fHtml += "</tr>";
108}
109
110//______________________________________________________________________________
111void DelphesHtmlObjTable::BuildTable()
112{
113 // Build part of table with values.
114
115 for(int i = 0; i < fNValues; i++)
116 {
117 if(i % 2)
118 fHtml += "<tr bgcolor=e0e0ff>";
119 else
120 fHtml += "<tr bgcolor=ffffff>";
121
122 TString name = fName;
123 name.ReplaceAll(" ", "_");
124 // checkboxes
125 fHtml += "<td bgcolor=d0d0ff align=\"center\">";
126 fHtml += "<input type=\"checkbox\" name=\"";
127 fHtml += name;
128 fHtml += Form("[%d]\">", i);
129 fHtml += "</td>";
130
131 for(int j = 0; j < fNFields; j++)
132 {
133 fHtml += "<td width=";
134 fHtml += Form("%d%%", 100 / fNFields);
135 fHtml += " align=\"center\"";
136 fHtml += ">";
137 fHtml += Form("%1.4f", fValues[j][i]);
138 fHtml += "</td>";
139 }
140 fHtml += "</tr> ";
141 }
142}
143
144//______________________________________________________________________________
145DelphesHtmlSummary::DelphesHtmlSummary(const char *title) :
146 fNTables(0), fTitle(title)
147{
148 // Constructor.
149
150 fObjTables = new TOrdCollection();
151}
152
153//______________________________________________________________________________
154DelphesHtmlSummary::~DelphesHtmlSummary()
155{
156 // Destructor.
157
158 Reset();
159}
160
161//______________________________________________________________________________
162DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
163 Bool_t exp, Option_t *option)
164{
165 // Add a new table in our list of tables.
166
167 TString opt = option;
168 opt.ToLower();
169 DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp);
170 fNTables++;
171 if(opt.Contains("first"))
172 fObjTables->AddFirst(table);
173 else
174 fObjTables->Add(table);
175 return table;
176}
177
178//______________________________________________________________________________
179void DelphesHtmlSummary::Clear(Option_t *option)
180{
181 // Clear the table list.
182
183 if(option && option[0] == 'D')
184 fObjTables->Delete(option);
185 else
186 fObjTables->Clear(option);
187 fNTables = 0;
188}
189
190//______________________________________________________________________________
191void DelphesHtmlSummary::Reset(Option_t *)
192{
193 // Reset (delete) the table list;
194
195 delete fObjTables;
196 fObjTables = 0;
197 fNTables = 0;
198}
199
200//______________________________________________________________________________
201void DelphesHtmlSummary::Build()
202{
203 // Build the summary.
204
205 MakeHeader();
206 for(int i = 0; i < fNTables; i++)
207 {
208 GetTable(i)->Build();
209 fHtml += GetTable(i)->Html();
210 }
211 MakeFooter();
212}
213
214//______________________________________________________________________________
215void DelphesHtmlSummary::MakeHeader()
216{
217 // Make HTML header.
218
219 fHeader = "<html><head><title>";
220 fHeader += fTitle;
221 fHeader += "</title></head><body>";
222 fHeader += "<center><h2><font color=#2222ee><i>";
223 fHeader += fTitle;
224 fHeader += "</i></font></h2></center>";
225 fHtml = fHeader;
226}
227
228//______________________________________________________________________________
229void DelphesHtmlSummary::MakeFooter()
230{
231 // Make HTML footer.
232
233 fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
234 fFooter += "Example of using Html widget to display tabular data";
235 fFooter += "<br>";
236 fFooter += "(c) 2007-2010 Bertrand Bellenot";
237 fFooter += "</font></strong></center></body></html>";
238 fHtml += fFooter;
239}
Note: See TracBrowser for help on using the repository browser.