Fork me on GitHub

source: git/display/DelphesHtmlSummary.cc@ f4900ab

Last change on this file since f4900ab 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
RevLine 
[37deb3b]1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
[1fa50c2]4 *
[37deb3b]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.
[1fa50c2]9 *
[37deb3b]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.
[1fa50c2]14 *
[37deb3b]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
[5fbcfe8]19#include "display/DelphesHtmlSummary.h"
20#include "TEveElement.h"
21#include "TEveEventManager.h"
[341014c]22#include "TEveManager.h"
[5fbcfe8]23#include "TEvePointSet.h"
24#include "TEveTrack.h"
[341014c]25#include "TGHtml.h"
[5fbcfe8]26
27//==============================================================================
28
29DelphesHtmlSummary *fgDelphesHtmlSummary = 0;
[341014c]30TGHtml *fgHtml = 0;
[5fbcfe8]31
32//==============================================================================
33
34//______________________________________________________________________________
[341014c]35DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) :
36 fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
[5fbcfe8]37{
[341014c]38 // Constructor.
[5fbcfe8]39
[341014c]40 fValues = new TArrayF[fNFields];
41 for(int i = 0; i < fNFields; i++)
42 fValues[i].Set(nvals);
43 fLabels = new TString[fNFields];
[5fbcfe8]44}
45
46//______________________________________________________________________________
47DelphesHtmlObjTable::~DelphesHtmlObjTable()
48{
[341014c]49 // Destructor.
[5fbcfe8]50
[341014c]51 delete[] fValues;
52 delete[] fLabels;
[5fbcfe8]53}
54
55//______________________________________________________________________________
56void DelphesHtmlObjTable::Build()
57{
[341014c]58 // Build HTML code.
[5fbcfe8]59
[341014c]60 fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
[5fbcfe8]61
[341014c]62 BuildTitle();
63 if(fExpand && (fNFields > 0) && (fNValues > 0))
64 {
65 BuildLabels();
66 BuildTable();
67 }
[5fbcfe8]68
[341014c]69 fHtml += "</table>";
[5fbcfe8]70}
71
72//______________________________________________________________________________
73void DelphesHtmlObjTable::BuildTitle()
74{
[341014c]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>";
[5fbcfe8]91}
92
93//______________________________________________________________________________
94void DelphesHtmlObjTable::BuildLabels()
95{
[341014c]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>";
[5fbcfe8]108}
109
110//______________________________________________________________________________
111void DelphesHtmlObjTable::BuildTable()
112{
[341014c]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]);
[5fbcfe8]138 fHtml += "</td>";
[341014c]139 }
140 fHtml += "</tr> ";
141 }
[5fbcfe8]142}
143
144//______________________________________________________________________________
[341014c]145DelphesHtmlSummary::DelphesHtmlSummary(const char *title) :
146 fNTables(0), fTitle(title)
[5fbcfe8]147{
[341014c]148 // Constructor.
[5fbcfe8]149
[341014c]150 fObjTables = new TOrdCollection();
[5fbcfe8]151}
152
153//______________________________________________________________________________
154DelphesHtmlSummary::~DelphesHtmlSummary()
155{
[341014c]156 // Destructor.
[5fbcfe8]157
[341014c]158 Reset();
[5fbcfe8]159}
160
161//______________________________________________________________________________
162DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
[341014c]163 Bool_t exp, Option_t *option)
[5fbcfe8]164{
[341014c]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;
[5fbcfe8]176}
177
178//______________________________________________________________________________
179void DelphesHtmlSummary::Clear(Option_t *option)
180{
[341014c]181 // Clear the table list.
[5fbcfe8]182
[341014c]183 if(option && option[0] == 'D')
184 fObjTables->Delete(option);
185 else
186 fObjTables->Clear(option);
187 fNTables = 0;
[5fbcfe8]188}
189
190//______________________________________________________________________________
191void DelphesHtmlSummary::Reset(Option_t *)
192{
[341014c]193 // Reset (delete) the table list;
[5fbcfe8]194
[341014c]195 delete fObjTables;
196 fObjTables = 0;
197 fNTables = 0;
[5fbcfe8]198}
199
200//______________________________________________________________________________
201void DelphesHtmlSummary::Build()
202{
[341014c]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();
[5fbcfe8]212}
213
214//______________________________________________________________________________
215void DelphesHtmlSummary::MakeHeader()
216{
[341014c]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;
[5fbcfe8]226}
227
228//______________________________________________________________________________
229void DelphesHtmlSummary::MakeFooter()
230{
[341014c]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;
[5fbcfe8]239}
Note: See TracBrowser for help on using the repository browser.