Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
Package2HTML.cxx
1/*
2 * HalPackage2HTML.cxx
3 *
4 * Created on: 20-10-2013
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "Package2HTML.h"
11#include "Cout.h"
12#include "HtmlCore.h"
13#include "HtmlDiv.h"
14#include "HtmlFile.h"
15#include "HtmlObject.h"
16#include "HtmlTable.h"
17#include "Object.h"
18#include "Package.h"
19#include "Parameter.h"
20
21#include <TArc.h>
22#include <TAttFill.h>
23#include <TAttLine.h>
24#include <TAxis.h>
25#include <TCanvas.h>
26#include <TClass.h>
27#include <TCollection.h>
28#include <TDirectory.h>
29#include <TFile.h>
30#include <TGraph.h>
31#include <TH1.h>
32#include <TH2.h>
33#include <TH3.h>
34#include <THStack.h>
35#include <TKey.h>
36#include <TLatex.h>
37#include <TLine.h>
38#include <TList.h>
39#include <TNamed.h>
40#include <TObjArray.h>
41#include <TObjString.h>
42#include <TPad.h>
43#include <TROOT.h>
44#include <TSystem.h>
45#include <TVector2.h>
46#include <TVirtualPad.h>
47#include <cstring>
48#include <vector>
49
50#include "PicTree.h"
51#include "StdString.h"
52#include <iostream>
53
54namespace Hal {
56 fHTML(nullptr),
57 fFile(nullptr),
58 fDir(""),
59 fDynamicTableCounter(0),
60 fTaskTableCounter(0),
61 fCutContainerPosition(0),
62 fPackageID(0),
63 fCollectionsNo {0, 0, 0, 0},
64 fCurrentCutContainer(nullptr),
65 fListDeep(0),
66 fSoftVer(0) {}
67
68 Package2HTML::Package2HTML(Package* pack, const TString dir, Bool_t main_dir) : Package2HTML() {
69 fDir = dir;
70 for (int i = 0; i < 4; i++)
71 fCollectionsNo[i] = 0;
72 gSystem->MakeDirectory(fDir);
73 fHTML = new HtmlFile(fDir + "/index.html", main_dir);
74 HtmlCell cell;
75 CreatePackageList(cell, pack, eTableStyle::kStandard, fDir, 1, "");
76 fHTML->AddStringContent(cell.GetContent());
77 fHTML->Save();
78 delete fHTML;
79 fHTML = nullptr;
80 }
81
82 Package2HTML::Package2HTML(TString filename, const TString dir) : Package2HTML() { // uzywany
83 fDir = dir;
84 for (int i = 0; i < 4; i++)
85 fCollectionsNo[i] = 0;
86 gSystem->MakeDirectory(fDir);
87 fHTML = new HtmlFile(fDir + "/index.html", kTRUE);
88
89 fFile = new TFile(filename);
91
92 TDirectory* tdir = (TDirectory*) fFile->Get("HalPhysics");
93 if (!tdir) {
94 Hal::Cout::PrintInfo("Cannot find HalPhysics directory", EInfo::kError);
95 return;
96 }
97 //---------------------
98
99 TList* list = tdir->GetListOfKeys();
100 for (fPackageID = 0; fPackageID < list->GetEntries(); fPackageID++) {
101 TString path = Form("%s/superpack_%i", fDir.Data(), fPackageID);
102 TString key_name = ((TKey*) (list->At(fPackageID)))->GetName();
103 TObject* object = tdir->Get(key_name);
104 TString table_name = Form("task_table_%i", fTaskTableCounter++);
105 if (IsHalPackage(object)) {
106 Package* package = (Package*) object;
107 Package* meta_data = (Package*) (package->GetObjectByName("Metadata"));
108 TString analysis_name = GetString(meta_data, "Analysis Name");
109 // object inherits form HalPackage - probably result of physical analysis
110 HtmlDiv div;
111 div.SetId(Form("buttontableM_%i", fPackageID));
112 HtmlTable table;
113 table.SetDefaultClass();
114 HtmlRow firstRow("", Hal::HtmlTableRowClass::TaskStyle(), "");
115 TString button = HtmlCore::GetHideButtonTable(table_name,
116 Form("Hide/Show Pack %s [Package No. "
117 "%i ]",
118 analysis_name.Data(),
119 fPackageID));
120 firstRow.AddContent(HtmlCell(button));
121 table.AddContent(firstRow);
122 div.AddContent(table);
123 fHTML->AddContent(div);
124 HtmlDiv div2;
125 HtmlTable mainTable(table_name, "maintable", "display:none");
126 HtmlRow rowTable("", Hal::HtmlTableRowClass::ExpandableStyle(), "");
127 HtmlCell yellowCell;
128 TryExtractAnaResult(yellowCell, package, path);
129 rowTable.AddContent(yellowCell);
130 mainTable.AddContent(rowTable);
131 div2.AddContent(mainTable);
132 fHTML->AddContent(div2);
133 } else {
134 Cout::PrintInfo(Form("%s found in Physics but don't inherit from HalPackage", key_name.Data()), Hal::EInfo::kLowWarning);
135 }
136 }
137 // delete list;
138 fHTML->AddStringContent("<script>window.onload=checkTask();</script>\n");
139 //----------------------
140 fHTML->Save();
141 delete fHTML;
142 fHTML = nullptr;
143 HtmlCore::ResetMainDir();
144 }
145 /*
146 Package2HTML::Package2HTML(TString filename, const TString dir, TString packname) : Package2HTML() {
147 fDir = dir;
148 for (int i = 0; i < 4; i++)
149 fCollectionsNo[i] = 0;
150 fDynamicTableCounter = 0;
151 gSystem->MakeDirectory(fDir);
152 fHTML = new HtmlFile(fDir + "/index.html", kFALSE);
153 TFile* file = new TFile(filename);
154 TDirectory* tdir = (TDirectory*) file->Get("HalPhysics");
155 //---------------------
156 ExtractRunInfo();
157 if (fSoftVer <= 201612) {
158 Cout::PrintInfo("This file version might be not compatible wtih current version, use "
159 "macro/path/fix_files.C to fix it",
160 Hal::EInfo::kWarning);
161 }
162 TObject* object = tdir->Get(packname);
163 TString table_name = Form("task_table_%i", fTaskTableCounter++);
164 TString path = Form("%s/superpack_0/", fDir.Data());
165 if (object->InheritsFrom("Hal::Package")) {
166 Package* package = (Package*) object;
167 Package* meta_data = (Package*) (((Package*) object)->GetObjectByName("Metadata"));
168 TString analysis_name = ((ParameterString*) meta_data->GetObjectByName("Analysis Name"))->GetValue();
169 HtmlDiv div;
170 div.SetId("buttontableM_0");
171 HtmlTable table;
172 table.SetDefaultClass();
173 HtmlRow firstRow;
174 firstRow.SetClass(Hal::HtmlTableRowClass::TaskStyle());
175 firstRow.AddStringContent(Form("<td><button> %s[%s]</button></td>", packname.Data(), analysis_name.Data()));
176 div.AddContent(table);
177 fHTML->AddContent(div);
178 HtmlDiv div2;
179 HtmlTable table2(table_name, "maintable", "display:table");
180 HtmlRow row;
181 row.SetClass(Hal::HtmlTableRowClass::ExpandableStyle());
182 HtmlCell cell;
183 TryExtractAnaResult(cell, package, path);
184 row.AddContent(cell);
185 table2.AddContent(row);
186 div2.AddContent(table2);
187 fHTML->AddContent(div2);
188 } else {
189 Cout::PrintInfo(Form("%s found in HalPhysics but don't inherit from HalPackage", packname.Data()),
190 Hal::EInfo::kLowWarning);
191 }
192 // delete list;
193 file->Close();
194 fHTML->AddStringContent("<script>window.onload=checkTask();</script>\n");
195 //----------------------
196 fHTML->Save();
197 delete fHTML;
198 fHTML = nullptr;
199 }
200 */
201 Package2HTML::Package2HTML(Package* pack_ana, Package* pack_meta, const TString dir, Int_t task_id) : Package2HTML() {
202 fDir = dir;
203 for (int i = 0; i < 4; i++)
204 fCollectionsNo[i] = 0;
205 gSystem->MakeDirectory(fDir);
206 fHTML = new HtmlFile(fDir + "/index.html", kFALSE);
207 if (pack_meta) {
208 HtmlCell dummyCell;
209 TString temp_dir = Form("%s/global_data/", fDir.Data());
210 // gSystem->MakeDirectory(temp_dir);
211 CreatePackageList(dummyCell, pack_meta, eTableStyle::kMetaData, temp_dir, 2, "drawmerged");
212 fHTML->AddStringContent(dummyCell.GetContent());
213 }
214 Int_t pack_counter = 0;
215 TString table_name = Form("task_table_%i", fTaskTableCounter++);
216 TString path = fDir + "/superpack_0";
217 if (IsHalPackage(pack_ana)) {
218 Package* package = (Package*) pack_ana;
219 Package* meta_data = (Package*) (((Package*) pack_ana)->GetObjectByName("Metadata"));
220 TString analysis_name = GetString(meta_data, "Analysis Name");
221 HtmlDiv div1("buttontableM_0", "", "");
222 HtmlTable table1("", "haltable", "");
223 HtmlRow row1;
224 row1.SetClass(Hal::HtmlTableRowClass::TaskStyle());
225 row1.SetStringContent(Form("<td><button> Task %i "
226 "[%s]</button></td>",
227 task_id,
228 analysis_name.Data()));
229 table1.AddContent(row1);
230 div1.AddContent(table1);
231 fHTML->AddContent(div1);
232 HtmlDiv div2;
233 HtmlTable table2(table_name, "maintable", "display:table");
234 HtmlRow row2;
235 row2.SetClass(Hal::HtmlTableRowClass::ExpandableStyle());
236 HtmlCell cell;
237 TryExtractAnaResult(cell, package, path);
238 row2.AddContent(cell);
239 table2.AddContent(row2);
240 div2.AddContent(table2);
241 fHTML->AddContent(div2);
242 pack_counter++;
243 } else {
244 Cout::PrintInfo(Form("%s is not proper Object", pack_ana->ClassName()), Hal::EInfo::kLowWarning);
245 }
246 //----------------------
247 fHTML->Save();
248 delete fHTML;
249 fHTML = nullptr;
250 }
251
252 void Package2HTML::TryExtractAnaResult(HtmlObject& object, Package* pack, TString path) {
253 fCutContainerPosition = 0;
254 gSystem->mkdir(path);
255 fCurrentCutContainer = NULL;
256 for (int i = 0; i < pack->GetEntries(); i++) {
257 Package* cutpack = (Package*) pack->GetObject(i);
258 if (IsExacltyHalPackage(cutpack)) { // possible canditate
259 TString pack_class_name(cutpack->GetName(), strlen(cutpack->GetName()));
260 if (pack_class_name.EqualTo("Hal::CutContainer")) {
261 fCurrentCutContainer = cutpack; // found break
262 fCutContainerPosition = i + fCutContainerPosition;
263 break;
264 }
265 }
266 }
267 if (fCurrentCutContainer != NULL) GetCollectionsNumbers();
268 CreatePackageList(object, pack, eTableStyle::kStandard, path, 2);
269 TString metadata = Form("%s/metadata/", path.Data());
270 gSystem->mkdir(metadata);
271 CreatePackageList(object, (Package*) pack->GetObjectByName("Metadata"), eTableStyle::kMetaData, metadata, 3, "drawmerged");
272 // //KURWA
273
274 if (fCurrentCutContainer != NULL) {
275 CreateCutAndMonitorList(object, path);
276 ExportCollections(object, path);
277 }
278 fDynamicTableCounter++;
279 }
280
281 TString Package2HTML::GetLinkCutMon(TH1* h1, TH1* h2, Int_t no, TString path) const {
282 TString classname1 = h1->ClassName();
283 TString classname2 = h2->ClassName();
284 if (classname1 != classname2) { return "unknown"; };
285 Bool_t batch = gROOT->IsBatch();
286 gROOT->SetBatch(kTRUE);
287 TString url;
288 if (classname1.BeginsWith("TH1")) {
289 url = GetLink1D(h1, h2, no, path);
290 } else if (classname1.BeginsWith("TH2")) {
291 url = GetLink2D((TH2*) h1, (TH2*) h2, no, path);
292 } else if (classname1.BeginsWith("TH3")) {
293 url = GetLink3D((TH3*) h1, (TH3*) h2, no, path);
294 } else {
295 return "unknown";
296 }
297 gROOT->SetBatch(batch);
298 std::vector<TString> arr = Hal::Std::ExplodeString(path, '/');
299 TString inject = Form("%s/%s/", arr[arr.size() - 2].Data(), arr[arr.size() - 1].Data());
300 url = AddToUrl(inject, url);
301 return url;
302 }
303
304 void Package2HTML::CreateImagePage(TString filename, TString image_flag, Int_t no, TString /*path*/) const {
305 TString id_pic = Form(image_flag.Data(), 0);
306 TObjArray* clones = new TObjArray();
307 clones->SetOwner(kTRUE);
308 for (int i = 0; i < no; i++) {
309 clones->AddLast(new TObjString(Form(image_flag.Data(), i)));
310 }
311
312 TString url = HtmlCore::ClickablePic(id_pic, clones, 796, 572);
313 delete clones;
314
315 HtmlFile file(filename, kFALSE);
316 file.AddStringContent(url);
317 file.AddStringContent("<script type=\'text/javascript\'>");
318 file.AddStringContent("</script></br>");
319 file.Save();
320 }
321
322 void
323 Package2HTML::CreatePackageList(HtmlObject& table, Package* pack, eTableStyle style, TString path, Int_t depth, Option_t* opt) {
324 TString options = opt;
325
326 TString styleTitle, styleLegend, styleCell, styleExtra;
327 styleTitle = Hal::HtmlTableRowClass::TitleStyle();
328 switch (style) {
329 case Package2HTML::eTableStyle::kMetaData: {
330 styleLegend = Hal::HtmlTableRowClass::DarkBlue();
331 styleCell = Hal::HtmlTableRowClass::Grey();
332 styleExtra = Hal::HtmlTableRowClass::ExtraStyle();
333 } break;
334 case Package2HTML::eTableStyle::kStandard: {
335 styleLegend = Hal::HtmlTableRowClass::LegendStyle();
336 styleCell = Hal::HtmlTableRowClass::DefStyle();
337 styleExtra = Hal::HtmlTableRowClass::ExtraStyle();
338 } break;
339 }
340
342 Bool_t drawShowHideButton = kFALSE;
343 Bool_t drawComments = kFALSE;
344 Bool_t drawClassName = kFALSE;
345 Bool_t drawMerged = kFALSE;
346 if (options.Contains("all")) { drawShowHideButton = drawComments = drawClassName = kTRUE; }
347 if (options.Contains("drawbutton")) { drawShowHideButton = kTRUE; }
348 if (options.Contains("drawcomment")) { drawComments = kTRUE; }
349 if (options.Contains("drawclassname")) { drawClassName = kTRUE; }
350 if (options.Contains("drawmerged")) { drawMerged = kTRUE; }
351 HtmlDiv div;
352 TString table_name = Form("dynamic_table_%i", fDynamicTableCounter++);
353 if (drawShowHideButton) {
354 table.AddStringContent("<div id=\"yellow_\" ><table class=\"haltable\" >");
355 table.AddStringContent("<tr class=\"yellow_\"><td><button onclick=\"setTable('");
356 table.AddStringContent(table_name);
357 table.AddStringContent("')\">Hide/Show Main Table</button></td></tr>\n");
358 table.AddStringContent("</table></div>");
359 div.SetId(table_name);
360 div.SetStyle("display:none");
361 } else {
362 div.SetId(table_name);
363 div.SetStyle("display:block");
364 }
365 HtmlTable halTable;
366 halTable.SetDefaultClass();
367 int RowNo = 0;
368 if (drawClassName) {
369 HtmlRow row;
370 row.SetClass(styleTitle);
371 HtmlCellCol cell("", 5);
372 cell.AddStringContent(Form("ClassName : %s", pack->GetName()));
373 row.AddContent(cell);
374 halTable.AddContent(row);
375 RowNo++;
376 }
377 if (drawComments) {
378 HtmlRow row;
379 row.SetClass(styleLegend);
380 HtmlCell cell;
381 cell.SetColSpan(5);
382 cell.AddStringContent(Form("Comment : %s", pack->GetComment().Data()));
383 row.AddContent(cell);
384 halTable.AddContent(row);
385 RowNo++;
386 }
387
388 HtmlCellCol cell(Form("Object List in (%s)", pack->GetName()), 5);
389 HtmlRow row1;
390 row1.SetClass(styleLegend);
391 if (RowNo == 0) row1.SetClass(styleTitle);
392 row1.AddContent(cell);
393 halTable.AddContent(row1);
394 // 486
395
396 HtmlCell cell2;
397 cell2.SetColSpan(5);
398
399 HtmlRow legend1;
400 legend1.SetClass(styleLegend);
401 HtmlCellCol cell3("No", 2);
402 legend1.AddContent(cell3);
403 legend1.AddSimpleCells({"ClassName", "Name", "Value"});
404 halTable.AddContent(legend1);
405
406 // path = fDir;
407 std::vector<TString> out = Hal::Std::ExplodeString(path, '/');
408 TString inject = "";
409 if (depth == 2) { inject = out[out.size() - 1]; }
410 if (depth == 3) { inject = Form("%s/%s", out[out.size() - 2].Data(), out[out.size() - 1].Data()); }
411
412 if (inject.Length() > 0) { inject = inject + "/"; }
413 for (int i = 0; i < pack->GetEntries(); i++) {
414 TObject* object = pack->GetObject(i);
415 TString nameClass = object->ClassName();
416 TString oryginal_class = object->GetName();
417 if (IsExacltyHalPackage(object)) {
418 Package* subpack = (Package*) object;
419 oryginal_class = subpack->GetName();
420 HtmlRow row;
421 row.SetClass(styleCell);
422 if (oryginal_class == "Hal::Metadata") { row.SetClass(styleExtra); }
423 if (oryginal_class == "Hal::CutContainer") { row.SetClass(styleExtra); }
424 HtmlCell first_cell(Hal::Std::RoundToString(i));
425 first_cell.SetColSpan(2);
426 row.AddContent(first_cell);
427 row.AddSimpleCells({nameClass, oryginal_class, AddToUrl(inject, HtmlCore::HTMLExtract(object, i, path))});
428 halTable.AddContent(row);
429
430 } else if (nameClass == "Hal::QAPlotReport") {
431 Object* rep = (Object*) object;
432 rep->HTMLExtractIntoTable(fTObjectCounter["qa"]++, halTable, path, inject);
433 } else if (nameClass != "TList" || fListDeep != 0) {
434 HtmlRow row;
435 row.SetClass(styleCell);
436 HtmlCell first_cell(Hal::Std::RoundToString(i));
437 first_cell.SetColSpan(2);
438 row.AddContent(first_cell);
439 row.AddSimpleCells(
440 {nameClass, oryginal_class, AddToUrl(inject, HtmlCore::HTMLExtract(object, fTObjectCounter["TList"]++, path))});
441 halTable.AddContent(row);
442 } else {
443 CreateListTable(halTable, (TList*) object, fTObjectCounter["TList"]++, path, inject, styleCell);
444 }
445 }
446 if (drawMerged) {
447 HtmlRow merged;
448 merged.SetClass(Hal::HtmlTableRowClass::SummaryStyle());
449 HtmlCell cellM("Number of merged packages");
450 cellM.SetColSpan(4);
451 merged.AddContent(cellM);
452 TString no = Form("%i", pack->GetMerged());
453 merged.AddContent(HtmlCell(no));
454 halTable.AddContent(merged);
455 }
456 div.AddContent(halTable);
457 table.AddContent(div);
458 }
459
460 void Package2HTML::CreateCutAndMonitorList(HtmlObject& table, TString path) {
461 if (fCurrentCutContainer == NULL) return;
462 TString table_name = Form("dynamic_table_%i", fDynamicTableCounter++);
463
464 HtmlTable buttontable;
465 buttontable.SetClass("haltable");
466 HtmlRow rowButton;
467 rowButton.SetClass(Hal::HtmlTableRowClass::ExpandableStyle());
468 rowButton.AddContent(HtmlCell(HtmlCore::GetHideButtonTable(table_name, "Show/hide cuts")));
469
470 buttontable.AddContent(rowButton);
471 HtmlDiv div;
472 div.SetId("buttontable2");
473 div.AddContent(buttontable);
474 table.AddContent(div);
475
476 HtmlTable tableCuts;
477 tableCuts.SetClass("haltable");
478 tableCuts.SetId(table_name);
479 tableCuts.SetStyle("display:none");
480
481 path = Form("%s/cut_monitors", path.Data());
482 gSystem->mkdir(path);
483 Hal::ECutUpdate updList[] = {
484 Hal::ECutUpdate::kEvent, Hal::ECutUpdate::kTrack, Hal::ECutUpdate::kTwoTrack, Hal::ECutUpdate::kTwoTrackBackground};
485 TString colNames[] = {" Event Cut Collections ",
486 " TrackCut Cut Collections ",
487 " TwoTrackCut Cut Collections ",
488 " TwoTrackCut Cut Collections (background) "};
489
490 auto colLoop = [&](Hal::ECutUpdate upd, TString name) {
491 if (fCollectionsNo[static_cast<Int_t>(upd)]) {
492 HtmlRow row;
493 row.SetClass(Hal::HtmlTableRowClass::TitleStyle());
494 HtmlCell cell(name);
495 cell.SetColSpan(8);
496 row.AddContent(cell);
497 tableCuts.AddContent(row);
498 for (int i = 0; i < fCollectionsNo[static_cast<Int_t>(upd)]; i++) {
499 CreateCutHTML(tableCuts, upd, i);
500 }
501 }
502 };
503 for (int i = 0; i < 4; i++)
504 colLoop(updList[i], colNames[i]);
505
506 table_name = Form("dynamic_table_%i", fDynamicTableCounter++);
507
508 HtmlDiv div2;
509 div2.AddContent(tableCuts);
510 table.AddContent(div2);
511 HtmlDiv divCutMonitorButton;
512 divCutMonitorButton.SetId("buttontable3");
513 HtmlTable tableMonitorsButton("", "haltable", "");
514 HtmlRow clicableRow("", Hal::HtmlTableRowClass::ExpandableStyle(), "");
515 HtmlCell cellButton(HtmlCore::GetHideButtonTable(table_name, "Show/hide cut monitors"));
516 clicableRow.AddContent(cellButton);
517 tableMonitorsButton.AddContent(clicableRow);
518 divCutMonitorButton.AddContent(tableMonitorsButton);
519 table.AddContent(tableMonitorsButton);
520 HtmlTable tableMonitors(table_name, "haltable", "display:none");
521 Int_t cut_monitor_counter = 0;
522
523 TString names[] = {"Event Cut Monitors", "Track Cut Monitors", "TwoTrack Cut Monitors", "TwoTrack Cut Monitors (Background)"};
524 auto collectionLoop = [&](Hal::ECutUpdate upd, TString name) {
525 if (fCollectionsNo[static_cast<Int_t>(upd)]) {
526 HtmlRow rowGreen("", Hal::HtmlTableRowClass::TitleStyle(), "");
527 HtmlCellCol cell(name, 9);
528 rowGreen.AddContent(cell);
529 tableMonitors.AddContent(rowGreen);
530 for (int i = 0; i < fCollectionsNo[static_cast<Int_t>(upd)]; i++) {
531 CreateCutMonitorHTML(tableMonitors, upd, i, cut_monitor_counter, path);
532 }
533 }
534 };
535 for (int i = 0; i < 4; i++)
536 collectionLoop(updList[i], names[i]);
537
538 HtmlDiv divCutMonitor;
539 divCutMonitor.AddContent(tableMonitors);
540 table.AddContent(divCutMonitor);
541 }
542
543 void Package2HTML::CreateCutHTML(HtmlObject& table, Hal::ECutUpdate cut_update, Int_t collection_no) {
544 TString group_name, desc, names;
545 group_name = GetGroupListName(cut_update);
546 switch (cut_update) {
547 case Hal::ECutUpdate::kEvent:
548 desc = "EventCollection";
549 names = "Events";
550 break;
551 case Hal::ECutUpdate::kTrack:
552 desc = "TrackCollection";
553 names = "Tracks";
554 break;
555 case Hal::ECutUpdate::kTwoTrack:
556 desc = "TwoTrackCollection";
557 names = "Track TwoTracks";
558 break;
559 case Hal::ECutUpdate::kTwoTrackBackground:
560 desc = "TwoTrackCollectionBackground";
561 names = "Track TwoTracks (Background)";
562 break;
563 default: Cout::PrintInfo("Unknown cut update during HTML export", Hal::EInfo::kLowWarning); break;
564 }
565
566 TList* listA = (TList*) fCurrentCutContainer->GetObjectByName(group_name);
567 if (listA == NULL) return;
568 Package* subcontainer = (Package*) listA->At(collection_no);
569 if (subcontainer == NULL) return;
570 TList* list = (TList*) subcontainer->GetObjectByName("CutList");
571 HtmlRow rowGreen("", Hal::HtmlTableRowClass::TitleStyle(), "");
572 HtmlCell cellGreen(Form("Collection No %i [%s]", collection_no, desc.Data()));
573 cellGreen.SetColSpan(8);
574 rowGreen.AddContent(cellGreen);
575 table.AddContent(rowGreen);
576 HtmlRow rowGreen2;
577 rowGreen2.AddSimpleCells({"No", "Cut name", "Passed", "Failed", "Min", "Max", "Units", "Type"});
578 rowGreen2.SetClass(Hal::HtmlTableRowClass::LegendStyle());
579 table.AddContent(rowGreen2);
580
581 TList* listfast = (TList*) subcontainer->GetObjectByName("FastCutList");
582 if (listfast != 0x0)
583 for (int i = 0; i < listfast->GetEntries(); i++) {
584 CreateCutLink(table, cut_update, (Package*) listfast->At(i), i, kTRUE);
585 }
586 ULong64_t passed = GetULong(subcontainer, "PassedFast");
587 ULong64_t failed = GetULong(subcontainer, "FailedFast");
588 HtmlRow rowFast;
589 rowFast.SetClass(Hal::HtmlTableRowClass::SummaryStyle());
590 rowFast.AddContent(HtmlCell("-"));
591 rowFast.AddContent(HtmlCell(Form("TOTAL %s", names.Data())));
592 rowFast.AddContent(HtmlCell(Hal::Std::RoundToString(passed, -3, "prefix")));
593 rowFast.AddContent(HtmlCell(Hal::Std::RoundToString(failed, -3, "prefix")));
594 for (int i = 0; i < 3; i++)
595 rowFast.AddContent(HtmlCell("-"));
596 rowFast.AddContent(HtmlCell("Fast"));
597 table.AddContent(rowFast);
598 for (int i = 0; i < list->GetEntries(); i++) {
599 CreateCutLink(table, cut_update, (Package*) list->At(i), i, kFALSE);
600 }
601 passed = GetULong(subcontainer, "PassedSlow");
602 failed = GetULong(subcontainer, "FailedSlow");
603 HtmlRow rowSlow;
604 rowSlow.SetClass(Hal::HtmlTableRowClass::SummaryStyle());
605 rowSlow.AddContent(HtmlCell("-"));
606 rowSlow.AddContent(HtmlCell(Form("TOTAL %s", names.Data())));
607 rowSlow.AddContent(HtmlCell(Hal::Std::RoundToString(passed, -3, "prefix")));
608 rowSlow.AddContent(HtmlCell(Hal::Std::RoundToString(failed, -3, "prefix")));
609 for (int i = 0; i < 3; i++)
610 rowSlow.AddContent(HtmlCell("-"));
611 rowSlow.AddContent(HtmlCell("Slow"));
612 table.AddContent(rowSlow);
613 }
614
615 void Package2HTML::CreateCutLink(HtmlObject& table, Hal::ECutUpdate cut_update, Package* cut, Int_t no, Bool_t fast) {
616 TString numer = Hal::Std::RoundToString(no);
617 TString name = cut->GetName();
618 TClass* class_temp = TClass::GetClass(name);
619 Bool_t complex = kFALSE;
620 TString dummy_name = "";
621 auto IsInhert = [](TObject* classTemp, std::initializer_list<TString> list) {
622 for (auto a : list)
623 if (classTemp->InheritsFrom(a)) return kTRUE;
624 return kFALSE;
625 };
626 if (class_temp) {
627 if (IsInhert(class_temp, {"Hal::TrackComplexCut", "Hal::EventComplexCut", "Hal::TwoTrackComplexCut"})) {
628 complex = kTRUE;
629 if (cut->GetObjectByName("CutName_{re}")) { // FIXME new version
630 TString name_real = GetString(cut, "CutName_{re}");
631 if (cut->GetObjectByName("CutName_{im}")) {
632 TString name_img = GetString(cut, "CutName_{im}");
633 dummy_name = Form("<br/>(%s %s)", name_real.Data(), name_img.Data());
634 }
635 }
636 }
637 if (IsInhert(class_temp, {"Hal::TrackRealCut", "Hal::EventRealCut", "Hal::TwoTrackRealCut"})) {
638 if (cut->GetObjectByName("CutName_{re}")) {
639 TString name_real = GetString(cut, "CutName_{re}");
640 dummy_name = Form("<br/>(%s)", name_real.Data());
641 }
642 }
643
644 if (IsInhert(class_temp, {"Hal::TrackImaginaryCut", "Hal::EventImaginaryCut", "Hal::TwoTrackImaginaryCut"})) {
645 if (cut->GetObjectByName("CutName_{im}")) {
646 TString name_real = GetString(cut, "CutName_{im}");
647 dummy_name = Form("<br/>(%s)", name_real.Data());
648 }
649 }
650 }
651
652 if (fSoftVer < 201705) { complex = kFALSE; }
653 Int_t collection_no = ((ParameterInt*) cut->GetObjectByName("CollectionID"))->GetValue();
654 TString passed = Hal::Std::RoundToString((Float_t)(GetULong(cut, "Passed")), -3, "prefix");
655 TString failed = Hal::Std::RoundToString((Float_t)(GetULong(cut, "Failed")), -3, "prefix");
656 const Int_t cut_size = (((ParameterInt*) cut->GetObjectByName("CutSize")))->GetValue();
657 TString type = "Slow";
658 TString address = HtmlCore::GetUrl(GetLinkToCut(cut_update, collection_no, no, fast), name);
659 if (dummy_name.Length() > 0) address = address + dummy_name;
660 if (fast) type = "Fast";
661 if (cut_size == 0) {
662 HtmlRow row;
663 row.SetClass(Hal::HtmlTableRowClass::DefStyle());
664 row.AddSimpleCells({numer, address, passed, failed});
665 for (int i = 0; i < 3; i++)
666 row.AddContent(HtmlCell("-"));
667 row.AddContent(HtmlCell(type));
668 table.AddContent(row);
669 return;
670 }
671 if (complex) {
672 TString passed_re = Hal::Std::RoundToString(GetULong(cut, "Passed_{re}"), -3, "prefix");
673 TString failed_re = Hal::Std::RoundToString(GetULong(cut, "Failed_{re}"), -3, "prefix");
674 TString passed_im = Hal::Std::RoundToString(GetULong(cut, "Passed_{im}"), -3, "prefix");
675 TString failed_im = Hal::Std::RoundToString(GetULong(cut, "Failed_{im}"), -3, "prefix");
676 passed = Form("%s <br/>(%s %s)", passed.Data(), passed_re.Data(), passed_im.Data());
677 failed = Form("%s <br/>(%s %s)", failed.Data(), failed_re.Data(), failed_im.Data());
678 }
679 HtmlRow row;
680 row.SetClass(Hal::HtmlTableRowClass::LightBlue());
681 HtmlCell cell1(numer), cell2(address), cell3(passed), cell4(failed);
682 cell1.SetRowSpan(cut_size);
683 cell2.SetRowSpan(cut_size);
684 cell3.SetRowSpan(cut_size);
685 cell4.SetRowSpan(cut_size);
686 row.AddContent(cell1);
687 row.AddContent(cell2);
688 row.AddContent(cell3);
689 row.AddContent(cell4);
690
691 // i ==1
692 TString minima = Hal::Std::RoundToString(GetDouble(cut, Form("MinCut_%i", 0)), 3);
693 TString maxima = Hal::Std::RoundToString(GetDouble(cut, Form("MaxCut_%i", 0)), 3);
694 TString units = ((ParameterString*) cut->GetObjectByName(Form("UnitName_%i", 0)))->GetValue();
695 row.AddSimpleCells({minima, maxima, units});
696 HtmlCell type_cell(type);
697 type_cell.SetRowSpan(cut_size);
698 row.AddContent(type_cell);
699 table.AddContent(row);
700 TString min, max, unit;
701
702 for (int i = 1; i < cut_size; i++) {
703 std::cout << "SIZED" << address << std::endl;
704 min = Form("MinCut_%i", i);
705 max = Form("MaxCut_%i", i);
706 unit = Form("UnitName_%i", i);
707 minima = Hal::Std::RoundToString(GetDouble(cut, min), 3);
708 maxima = Hal::Std::RoundToString(GetDouble(cut, max), 3);
709 units = GetString(cut, unit);
710 HtmlRow singleCut;
711 singleCut.SetClass(Hal::HtmlTableRowClass::DefStyle());
712 singleCut.AddSimpleCells({minima, maxima, units});
713 table.AddContent(singleCut);
714 }
715 }
716
717 void Package2HTML::CreateCutMonitorLink(HtmlObject& table,
718 Hal::ECutUpdate update,
719 Package* monitor,
720 Int_t no,
721 Int_t counter,
722 TString path) {
723 TString numer = Hal::Std::RoundToString(no);
724 Int_t collection_no = ((ParameterInt*) monitor->GetObjectByName("CollectionID"))->GetValue();
725 TString exupdate = "no";
726 Int_t ex = ((ParameterInt*) monitor->GetObjectByName("ExclusiveUpdate"))->GetValue();
727 if (ex == 1) exupdate = "yes";
728 TString monitor_class = monitor->GetName();
729 TString address = HtmlCore::GetUrl(GetLinkToCutMonitor(update, collection_no, no), monitor_class);
730 TString link =
731 GetLinkCutMon((TH1*) monitor->GetObjectByName("Passed"), (TH1*) monitor->GetObjectByName("Failed"), counter, path);
732
733 HtmlCell cutInfo[9];
734 cutInfo[0].SetStringContent(numer);
735 cutInfo[1].SetStringContent(address);
736 cutInfo[7].SetStringContent(link);
737 cutInfo[8].SetStringContent(exupdate);
738
739 auto fillTable = [&](TString opt) {
740 TString unit = GetString(monitor, Form("Axis%s", opt.Data()));
741 TString cutname = GetString(monitor, Form("Cut%sName", opt.Data()));
742 if (cutname.Contains(")")) cutname = cutname.ReplaceAll("(", "</br>(");
743 TString axisopt =
744 Hal::Std::RoundToString(((ParameterInt*) monitor->GetObjectByName(Form("Cut%sAxis", opt.Data())))->GetValue());
745 TString cutmin = Hal::Std::RoundToString(GetDouble(monitor, Form("Cut%sMin", opt.Data())), 3);
746 TString cutmax = Hal::Std::RoundToString(GetDouble(monitor, Form("Cut%sMax", opt.Data())), 3);
747 cutInfo[2].SetStringContent(cutname);
748 cutInfo[3].SetStringContent(unit);
749 cutInfo[4].SetStringContent(axisopt);
750 cutInfo[5].SetStringContent(cutmin);
751 cutInfo[6].SetStringContent(cutmax);
752 };
753
754
755 Int_t ndim = 0;
756 if (monitor->GetObjectByName("CutXAxis", 0, kTRUE) != nullptr) { ndim = 1; }
757 if (monitor->GetObjectByName("CutYAxis", 0, kTRUE) != nullptr) { ndim = 2; }
758 if (monitor->GetObjectByName("CutZAxis", 0, kTRUE) != nullptr) { ndim = 3; }
759 HtmlRow rowMonitor("", Hal::HtmlTableRowClass::DefStyle(), "");
760
761 cutInfo[8].SetStringContent(exupdate);
762 fillTable("X");
763 switch (ndim) {
764 case 1: {
765 for (int i = 0; i < 9; i++) {
766 rowMonitor.AddContent(cutInfo[i]);
767 }
768 table.AddContent(rowMonitor);
769 } break;
770 case 2: {
771 cutInfo[0].SetRowSpan(2);
772 cutInfo[1].SetRowSpan(2);
773 cutInfo[7].SetRowSpan(2);
774 cutInfo[8].SetRowSpan(2);
775 for (int i = 0; i < 9; i++) {
776 rowMonitor.AddContent(cutInfo[i]);
777 }
778 table.AddContent(rowMonitor);
779 HtmlRow rowMonitor2("", Hal::HtmlTableRowClass::DefStyle(), "");
780 fillTable("Y");
781 for (int i = 2; i < 7; i++) {
782 rowMonitor2.AddContent(cutInfo[i]);
783 }
784 table.AddContent(rowMonitor2);
785
786 } break;
787 case 3: {
788 cutInfo[0].SetRowSpan(3);
789 cutInfo[1].SetRowSpan(3);
790 cutInfo[7].SetRowSpan(3);
791 cutInfo[8].SetRowSpan(3);
792 for (int i = 0; i < 9; i++) {
793 rowMonitor.AddContent(cutInfo[i]);
794 }
795 table.AddContent(rowMonitor);
796 HtmlRow rowMonitor2("", Hal::HtmlTableRowClass::DefStyle(), "");
797 fillTable("Y");
798 for (int i = 2; i < 7; i++) {
799 rowMonitor2.AddContent(cutInfo[i]);
800 }
801 table.AddContent(rowMonitor2);
802 HtmlRow rowMonitor3("", Hal::HtmlTableRowClass::DefStyle(), "");
803 fillTable("Z");
804 for (int i = 2; i < 7; i++) {
805 rowMonitor3.AddContent(cutInfo[i]);
806 }
807 table.AddContent(rowMonitor3);
808 } break;
809 default: {
810 for (int i = 0; i < 7; i++)
811 rowMonitor.AddContent(HtmlCell("-"));
812 rowMonitor.AddContent(cutInfo[7]);
813 rowMonitor.AddContent(HtmlCell("-"));
814 rowMonitor.AddContent(HtmlCell("-"));
815 table.AddContent(rowMonitor);
816 } break;
817 }
818 }
819
820 void Package2HTML::CreateListTable(HtmlObject& table,
821 TList* list,
822 Int_t no,
823 TString path_data,
824 TString path_url,
825 TString drawClass) {
826 if (path_url == "") { path_url = path_data; }
827 fListDeep++; // to prevent draw TList in TList
828 HtmlRow row;
829 row.SetClass(drawClass);
830 HtmlCell cell1(Form("%i", no));
831 cell1.SetColSpan(2);
832 row.AddContent(cell1);
833 row.AddContent(HtmlCell("TList"));
834 row.AddContent(HtmlCell(list->GetName()));
835 TString rowButton = HtmlCore::GetHideButtonRow(Form("list_%i", no), "Show/Hide");
836 row.AddContent(HtmlCell(rowButton));
837 table.AddContent(row);
838 TString list_path = Form("%s/list_%i", path_data.Data(), no);
839 gSystem->mkdir(list_path);
840 TString list_dir = Form("list_%i/", no);
841 TString list_dir2 = list_dir;
842 if (path_url != path_data) list_dir2 = Form("%s/list_%i/", path_url.Data(), no);
843 for (int i = 0; i < list->GetEntries(); i++) {
844 TObject* obj = list->At(i);
845 TString name = obj->GetName();
846 TString classname = obj->ClassName();
847 TString temp_classes = Form("%s list_%i", drawClass.Data(), no);
848 HtmlRow rowElement("", temp_classes, "display:none");
849 rowElement.AddSimpleCells({"", Form("%i", i), classname});
850 if (IsExacltyHalPackage(obj)) {
851 classname = Form("Hal::Package [%s] ",
852 ((Package*) obj)->GetName()); //</br>
853 rowElement.AddContent(HtmlCell(classname));
854 } else {
855 rowElement.AddContent(HtmlCell(obj->GetName()));
856 }
857 rowElement.AddContent(HtmlCell(AddToUrl(list_dir2, HtmlCore::HTMLExtract(obj, i, list_path))));
858 table.AddContent(rowElement);
859 }
860 fListDeep--;
861 }
862
863 void Package2HTML::CreateCutMonitorHTML(HtmlObject& table,
864 Hal::ECutUpdate cut_upd,
865 Int_t collection_no,
866 Int_t& counter,
867 TString path) {
868 TString group_name, desc, names;
869 group_name = GetGroupListName(cut_upd);
870 switch (cut_upd) {
871 case Hal::ECutUpdate::kEvent:
872 desc = "EventCollection";
873 names = "Events";
874 break;
875 case Hal::ECutUpdate::kTrack:
876 desc = "TrackCollection";
877 names = "Tracks";
878 break;
879 case Hal::ECutUpdate::kTwoTrack:
880 desc = "TwoTrackCollection";
881 names = "Track TwoTracks";
882 break;
883 case Hal::ECutUpdate::kTwoTrackBackground:
884 desc = "TwoTrackBackgroundCollection";
885 names = "Track TwoTracks Background";
886 break;
887 default: Cout::PrintInfo("Unhandled monitor group in HalPackage2HTML", Hal::EInfo::kLowWarning); break;
888 }
889 HtmlRow row;
890 row.SetClass(Hal::HtmlTableRowClass::TitleStyle());
891 HtmlCellCol cell(Form("Collection No %i [%s]", collection_no, names.Data()), 9);
892 row.AddContent(cell);
893 table.AddContent(row);
894
895 TList* listA = (TList*) fCurrentCutContainer->GetObjectByName(group_name);
896 if (listA == NULL) return;
897 Package* subcontainer = (Package*) listA->At(collection_no);
898 if (subcontainer == NULL) return;
899 TList* list = (TList*) subcontainer->GetObjectByName("CutMonitorList");
900 if (list == NULL) return;
901 // fHTML<<HalHTML::GetHTMLRow(9,"No","Classname","CutName","Unit","AxisOption","CutMin","CutMax","Stacked</br>Img","Ex</br>Update")<<std::endl;
902 if (list->GetEntries() > 0) {
903 HtmlRow rowE;
904 rowE.SetClass(Hal::HtmlTableRowClass::LegendStyle());
905 rowE.AddSimpleCells(
906 {"No", "ClassName", "CutName", "Unit", "AxisOption", "CutMin", "CutMax", "Stacked</br>Img", "Ex</br>Update"});
907 table.AddContent(rowE);
908 for (int i = 0; i < list->GetEntries(); i++) {
909 CreateCutMonitorLink(table, cut_upd, (Package*) list->At(i), i, ++counter, path);
910 }
911 } else {
912 HtmlRow rowE;
913 rowE.SetClass(Hal::HtmlTableRowClass::DefStyle());
914 HtmlCell cellE("Empty");
915 cellE.SetColSpan(9);
916 rowE.AddContent(cellE);
917 table.AddContent(rowE);
918 }
919 //-------------two track cut table
920 }
921
922 Package2HTML::containerInfo Package2HTML::GetContainerInfo(Package* pack, Bool_t rev) const {
923 Double_t failedF = GetULong(pack, "FailedFast");
924 Double_t passedS = GetULong(pack, "PassedSlow");
925 Double_t failedS = GetULong(pack, "FailedSlow");
926 Double_t passed = passedS;
927 Double_t failed = failedF + failedS;
928 containerInfo info;
929 info.sFraction = passed / (failed + passed);
930 ParameterInt* collectionno = (ParameterInt*) pack->GetObjectByName("CollectionID");
931 info.sColId = collectionno->GetValue();
932 if (!rev) {
933 TList* linkList;
934 if (pack->Exist("NextObj"))
935 linkList = (TList*) pack->GetObjectByName("NextObj"); // backward compatibility
936 else
937 linkList = (TList*) pack->GetObjectByName(Form("NextObj_%i", 0));
938 if (!linkList) return info;
939 for (int i = 0; i < linkList->GetEntries(); i++) {
940 Int_t collection_to = ((ParameterInt*) linkList->At(i))->GetValue();
941 info.sLinks.push_back(collection_to);
942 }
943 } else {
944 TList* linkList;
945 if (pack->Exist("NextObj"))
946 linkList = (TList*) pack->GetObjectByName("NextObj"); // backward compatibility
947 else
948 linkList = (TList*) pack->GetObjectByName(Form("NextObj_%i", 1));
949 if (!linkList) return info;
950 for (int i = 0; i < linkList->GetEntries(); i++) {
951 Int_t collection_to = ((ParameterInt*) linkList->At(i))->GetValue();
952 info.sLinks.push_back(collection_to);
953 }
954 }
955 return info;
956 }
957
958 void Package2HTML::ExportCollections(HtmlObject& object, TString path) {
959 if (fCurrentCutContainer == NULL) return;
960
961 TList* listE = (TList*) fCurrentCutContainer->GetObjectByName(GetGroupListName(Hal::ECutUpdate::kEvent));
962 TList* listT = (TList*) fCurrentCutContainer->GetObjectByName(GetGroupListName(Hal::ECutUpdate::kTrack));
963 TList* listT2 = (TList*) fCurrentCutContainer->GetObjectByName(GetGroupListName(Hal::ECutUpdate::kTwoTrack));
964 TList* listT2B = (TList*) fCurrentCutContainer->GetObjectByName(GetGroupListName(Hal::ECutUpdate::kTwoTrackBackground));
965 Int_t eventCol = 0;
966 Int_t trackCol = 0;
967 Int_t ttrackCol = 0;
968 Int_t ttrackColBckg = 0;
969 Int_t levelsNo = 0;
970 if (listE) {
971 eventCol = listE->GetEntries();
972 levelsNo++;
973 }
974 if (listT) {
975 trackCol = listT->GetEntries();
976 levelsNo++;
977 }
978 if (listT2) {
979 ttrackCol = listT2->GetEntries();
980 levelsNo++;
981 }
982 if (listT2B) { ttrackColBckg = listT2B->GetEntries(); }
983 PicTree pic;
984 for (int i = 0; i < eventCol; i++) {
985 auto pack = (Package*) listE->At(i);
986 auto info = GetContainerInfo(pack);
987 pic.AddPoint(0, info.sColId, 0, info.sFraction);
988 for (auto link : info.sLinks)
989 pic.AddLink({0, 1}, {info.sColId, link}, 0);
990 }
991 for (int i = 0; i < trackCol; i++) {
992 auto pack = (Package*) listT->At(i);
993 if (listT2B) {
994 auto info = GetContainerInfo(pack, true);
995 for (auto link : info.sLinks) {
996 pic.AddLink({1, 2}, {info.sColId, link}, 1);
997 }
998 }
999 if (listT2) {
1000 auto info = GetContainerInfo(pack, false);
1001 for (auto link : info.sLinks) {
1002 pic.AddLink({1, 2}, {info.sColId, link}, 0);
1003 }
1004 }
1005 auto info = GetContainerInfo(pack, false);
1006 pic.AddPoint(1, i, 0, info.sFraction);
1007 }
1008
1009 for (int i = 0; i < ttrackColBckg; i++) {
1010 auto info = GetContainerInfo((Package*) listT2B->At(i), false);
1011 pic.AddPoint(2, i, 1, info.sFraction);
1012 }
1013 for (int i = 0; i < ttrackCol; i++) {
1014 auto info = GetContainerInfo((Package*) listT2->At(i), false);
1015 pic.AddPoint(2, i, 0, info.sFraction);
1016 }
1017 TString short_path = path(fDir.Length() + 1, path.Length());
1018 TString text = Form("<img class=\"pic\" src=\"%s/main_pict.png\" width=\"%i \" height=\"%i "
1019 "\">",
1020 short_path.Data(),
1021 (int) pic.GetWidth(),
1022 (int) pic.GetHeight());
1023 object.AddStringContent(text);
1024 pic.SaveAs(Form("%s/main_pict.png", path.Data()));
1025 }
1026
1027 TString Package2HTML::GetLink1D(TH1* h1, TH1* h2, Int_t no, TString path) const {
1028 TString url;
1029 path = Form("%s/th1_%i", path.Data(), no);
1030 gSystem->mkdir(path);
1031 TString filename = Form("%s/histo.html", path.Data());
1032 TString name = Form("histo_%i", no);
1033 TCanvas* c1 = new TCanvas("cutmon", "cutmon", 0, 0, 800, 600);
1034 gPad->SetLeftMargin(0.15);
1035 THStack* stack = new THStack();
1036 stack->Add(h1);
1037 stack->Add(h2);
1038 stack->Draw();
1039 stack->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
1040 stack->GetYaxis()->SetTitle(h1->GetYaxis()->GetTitle());
1041 stack->SetTitle(h1->GetTitle());
1042 c1->SaveAs(Form("%s/cutmon.root", path.Data()));
1043
1044 HtmlFile file(filename, kFALSE);
1045 file.AddStringContent(HtmlCore::GetJsDiv("cutmon.root", "cutmon;1"));
1046 file.Save();
1047 return HtmlCore::GetUrl(Form("th1_%i/histo.html", no), Form("2x%s", h1->ClassName()));
1048 }
1049
1050 TString Package2HTML::GetLink2D(TH2* h1, TH2* h2, Int_t no, TString path) const {
1051 TString url;
1052 path = Form("%s/th1_%i", path.Data(), no);
1053 gSystem->mkdir(path);
1054 TString filename = Form("%s/histo.html", path.Data());
1055 TCanvas* c1 = new TCanvas("cutmon", "cutmon", 0, 0, 800, 600);
1056 c1->Divide(2, 1);
1057 c1->cd(1);
1058 h1->SetTitle(Form("%s (Passed)", h1->GetTitle()));
1059 h1->Draw("colz");
1060 c1->cd(2);
1061 h2->SetTitle(Form("%s (Failed)", h2->GetTitle()));
1062 h2->Draw("colz");
1063 c1->SetName("cutmon");
1064 c1->SaveAs(Form("%s/cutmon.root", path.Data()));
1065 delete c1;
1066 HtmlFile file(filename, kFALSE);
1067 file.AddStringContent(HtmlCore::GetJsDiv("cutmon.root", "cutmon;1"));
1068 file.Save();
1069 return HtmlCore::GetUrl(Form("th1_%i/histo.html", no), Form("2x%s", h1->ClassName()));
1070 }
1071
1072 TString Package2HTML::GetLink3D(TH3* h1, TH3* h2, Int_t no, TString path) const {
1073 TString url;
1074 path = Form("%s/th1_%i", path.Data(), no);
1075 gSystem->mkdir(path);
1076 TString filename = Form("%s/histo.html", path.Data());
1077 TCanvas* c1 = new TCanvas("cutmon", "cutmon", 0, 0, 800, 600);
1078 c1->Divide(2, 1);
1079 c1->cd(1);
1080 h1->SetTitle(Form("%s (Passed)", h1->GetTitle()));
1081 h1->Draw(Draw_3D_option);
1082 c1->cd(2);
1083 h2->SetTitle(Form("%s (Failed)", h2->GetTitle()));
1084 h2->Draw(Draw_3D_option);
1085 c1->SetName("cutmon");
1086 c1->SaveAs(Form("%s/cutmon.root", path.Data()));
1087 delete c1;
1088 HtmlFile file(filename, kFALSE);
1089 file.AddStringContent(HtmlCore::GetJsDiv("cutmon.root", "cutmon;1"));
1090 file.Save();
1091 return HtmlCore::GetUrl(Form("th1_%i/histo.html", no), Form("2x%s", h1->ClassName()));
1092
1093 /*
1094 TString url;
1095 gSystem->mkdir(Form("%s/th1_%i", path.Data(), no));
1096 TString name = "histo";
1097 TCanvas* c1 = new TCanvas(name, name, 0, 0, 800, 600);
1098 gPad->SetLeftMargin(0.15);
1099 THStack* stack = new THStack();
1100 stack->Add(h1);
1101 stack->Add(h2);
1102 stack->Draw(Draw_3D_option);
1103 c1->SaveAs(Form("%s/th1_%i/histo_0.png", path.Data(), no));
1104 delete c1;
1105 delete stack;
1106 TString filename = Form("%s/th1_%i/histo.html", path.Data(), no);
1107 CreateImagePage(filename, "histo_%i.png", 1, Form("%s/th1_%i", path.Data(), no));
1108 return HtmlCore::GetUrl(Form("th1_%i/histo.html", no), Form("2x%s", h1->ClassName()));*/
1109 }
1110
1111 TString Package2HTML::GetLinkToCut(Hal::ECutUpdate update, Int_t collection_no, Int_t cut_no, Bool_t fast) const {
1112 TString list_name = GetGroupListName(update);
1113 TList* list = (TList*) fCurrentCutContainer->GetObjectByName(list_name);
1114 Package* cut_sub_container = (Package*) list->At(collection_no);
1115 Int_t list_pos = 0;
1116 TString pattern = "CutList";
1117 if (fast) { pattern = "FastCutList"; }
1118 for (list_pos = 0; list_pos < cut_sub_container->GetEntries(); list_pos++) {
1119 TString name = cut_sub_container->GetObject(list_pos)->GetName();
1120 if (name.EqualTo(pattern)) break;
1121 }
1122 Int_t int_update = static_cast<Int_t>(update);
1123 return Form("superpack_%i/pack_%i/list_%i/pack_%i/list_%i/pack_%i/index.html",
1124 fPackageID,
1125 fCutContainerPosition,
1126 2 * int_update + 1,
1127 collection_no,
1128 list_pos,
1129 cut_no);
1130 }
1131
1132 TString Package2HTML::GetLinkToCutMonitor(Hal::ECutUpdate update, Int_t collection_no, Int_t no) const {
1133 TString list_name = GetGroupListName(update);
1134 TList* list = (TList*) fCurrentCutContainer->GetObjectByName(list_name);
1135 Package* cut_sub_container = (Package*) list->At(collection_no);
1136 Int_t list_pos = 0;
1137 TString pattern = "CutMonitorList";
1138 for (list_pos = 0; list_pos < cut_sub_container->GetEntries(); list_pos++) {
1139 TString name = cut_sub_container->GetObject(list_pos)->GetName();
1140 if (name.EqualTo(pattern)) break;
1141 }
1142 Int_t int_update = static_cast<Int_t>(update);
1143 return Form("superpack_%i/pack_%i/list_%i/pack_%i/list_%i/pack_%i/index.html",
1144 fPackageID,
1145 fCutContainerPosition,
1146 2 * int_update + 1,
1147 collection_no,
1148 list_pos,
1149 no);
1150 }
1151
1152 TString Package2HTML::GetGroupListName(Hal::ECutUpdate update) const {
1153 switch (update) {
1154 case Hal::ECutUpdate::kEvent: return "EventCutCollectionList"; break;
1155 case Hal::ECutUpdate::kTrack: return "TrackCutCollectionList"; break;
1156 case Hal::ECutUpdate::kTwoTrack: return "TwoTrackCutCollectionList"; break;
1157 case Hal::ECutUpdate::kTwoTrackBackground: return "TwoTrackBackgroundCutCollectionList"; break;
1158 default: return ""; break;
1159 }
1160 }
1161
1162 Package2HTML::~Package2HTML() {
1163 if (fHTML) delete fHTML;
1164 if (fFile) {
1165 fFile->Close();
1166 delete fFile;
1167 }
1168 }
1169
1170 void Package2HTML::GetCollectionsNumbers() {
1171 TString collection_name[4] = {
1172 "Event_collections_No", "Track_collections_No", "TwoTrack_collections_No", "TwoTrack_collections_background_No"};
1173 ParameterInt* event_collections_no = (ParameterInt*) fCurrentCutContainer->GetObjectByName(collection_name[0], 0);
1174 ParameterInt* track_collections_no = (ParameterInt*) fCurrentCutContainer->GetObjectByName(collection_name[1], 0);
1175 ParameterInt* twotrack_collections_no = (ParameterInt*) fCurrentCutContainer->GetObjectByName(collection_name[2], 0);
1176 ParameterInt* twotrack_collections_background_no =
1177 (ParameterInt*) fCurrentCutContainer->GetObjectByName(collection_name[3], 0);
1178 if (event_collections_no)
1179 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kEvent)] = event_collections_no->GetValue();
1180 else
1181 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kEvent)] = 0;
1182 if (track_collections_no)
1183 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kTrack)] = track_collections_no->GetValue();
1184 else
1185 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kTrack)] = 0;
1186 if (twotrack_collections_no)
1187 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kTwoTrack)] = twotrack_collections_no->GetValue();
1188 else
1189 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kTwoTrack)] = 0;
1190 if (twotrack_collections_background_no) {
1191 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kTwoTrackBackground)] = twotrack_collections_background_no->GetValue();
1192 } else {
1193 fCollectionsNo[static_cast<Int_t>(Hal::ECutUpdate::kTwoTrackBackground)] = 0;
1194 }
1195 }
1196
1197 TString Package2HTML::AddToUrl(TString add_dir, TString url) const {
1198 if (!url.Contains("href")) { return url; }
1199 Int_t start_url = url.First("=") + 2;
1200 TString first = url(0, start_url);
1201 TString end = url(start_url, url.Length());
1202 TString output = Form("%s%s%s", first.Data(), add_dir.Data(), end.Data());
1203 output.ReplaceAll("//", "/");
1204 return output;
1205 }
1206
1207 Double_t Package2HTML::GetDouble(const Package* pack, TString name) const {
1208 return ((ParameterDouble*) pack->GetObjectByName(name))->GetValue();
1209 }
1210
1211 TString Package2HTML::GetString(const Package* pack, TString name) const {
1212 return ((ParameterString*) pack->GetObjectByName(name))->GetValue();
1213 }
1214
1215 ULong64_t Package2HTML::GetULong(const Package* pack, TString name) const {
1216 return (ULong64_t)((ParameterULong64*) pack->GetObjectByName(name))->GetValue();
1217 }
1218
1220 HtmlCell runCell;
1221 TDirectory* global_dir = (TDirectory*) fFile->Get("HalInfo");
1222 if (!global_dir) return kFALSE;
1223 TString temp_dir = Form("%s/global_data", fDir.Data());
1224 // gSystem->MakeDirectory(temp_dir);
1225 Package* pack = (Package*) fFile->Get("HalInfo/RunInfo");
1226 fSoftVer = Hal::Std::VersionId(GetString(pack, "Software ver"));
1227 CreatePackageList(runCell, pack, eTableStyle::kMetaData, temp_dir, 2, "drawmerged");
1228 fHTML->AddStringContent(runCell.GetContent());
1229 return kTRUE;
1230 }
1231
1232} // namespace Hal
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
static TString GetUrl(TString adress, TString text)
Definition HtmlCore.cxx:164
static TString GetHideButtonTable(TString tableName, TString text)
Definition HtmlCore.cxx:249
static TString ClickablePic(TString id_name, TObjArray *strings, Int_t width=796, Int_t height=572)
Definition HtmlCore.cxx:166
static TString GetJsDiv(TString root_file, TString object_name, TString draw_opt="colz", TString draw_div_name="drawing")
Definition HtmlCore.cxx:226
static TString HTMLExtract(TObject *obj, Int_t no, TString dir="")
Definition HtmlCore.cxx:282
static void FixAddress(TString &address)
Definition HtmlCore.cxx:101
static TString GetHideButtonRow(TString listName, TString text)
Definition HtmlCore.cxx:253
void SetClass(TString className)
Definition HtmlObject.h:40
virtual void AddContent(const HtmlObject &obj)
void SetStyle(TString style)
Definition HtmlObject.h:54
void SetId(TString id)
Definition HtmlObject.h:49
virtual void AddContent(const HtmlObject &obj)
Definition HtmlTable.cxx:29
void SetDefaultClass()
Definition HtmlTable.h:40
virtual void AddContent(const HtmlObject &obj)
Definition HtmlTable.cxx:17
virtual void HTMLExtractIntoTable(Int_t, HtmlTable &, TString="", TString="") const
Definition Object.h:56
Bool_t IsExacltyHalPackage(const TObject *obj) const
Bool_t IsHalPackage(const TObject *obj) const
Bool_t Exist(TString name, Int_t index=0, Option_t *opt=" ") const
Definition Package.cxx:300
TObject * GetObject(Int_t i) const
Definition Package.cxx:52
Int_t GetMerged() const
Definition Package.cxx:140
TString GetComment() const
Definition Package.cxx:63
TObject * GetObjectByName(TString name, Int_t index=0, Bool_t quited=kFALSE) const
Definition Package.cxx:67
Int_t GetEntries() const
Definition Package.cxx:61
const char * GetName() const
Definition Package.cxx:167
Int_t GetValue() const
Definition Parameter.h:112
void AddPoint(Int_t depth, Int_t number, Int_t style, Double_t ratio)
Definition PicTree.cxx:35
void AddLink(std::initializer_list< Int_t > depths, std::initializer_list< Int_t > ids, Int_t style)
Definition PicTree.cxx:32
void SaveAs(TString path)
Definition PicTree.cxx:39
Double_t GetWidth() const
Definition PicTree.h:73
Double_t GetHeight() const
Definition PicTree.h:78