10#include "Package2HTML.h"
15#include "HtmlObject.h"
27#include <TCollection.h>
28#include <TDirectory.h>
41#include <TObjString.h>
46#include <TVirtualPad.h>
59 fDynamicTableCounter(0),
61 fCutContainerPosition(0),
63 fCollectionsNo {0, 0, 0, 0},
64 fCurrentCutContainer(nullptr),
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);
75 CreatePackageList(cell, pack, eTableStyle::kStandard, fDir, 1,
"");
76 fHTML->AddStringContent(cell.GetContent());
84 for (
int i = 0; i < 4; i++)
85 fCollectionsNo[i] = 0;
86 gSystem->MakeDirectory(fDir);
87 fHTML =
new HtmlFile(fDir +
"/index.html", kTRUE);
89 fFile =
new TFile(filename);
92 TDirectory* tdir = (TDirectory*) fFile->Get(
"HalPhysics");
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++);
106 Package*
package = (Package*) object;
107 Package* meta_data = (
Package*) (package->GetObjectByName(
"Metadata"));
108 TString analysis_name = GetString(meta_data,
"Analysis Name");
111 div.
SetId(Form(
"buttontableM_%i", fPackageID));
114 HtmlRow firstRow(
"", Hal::HtmlTableRowClass::TaskStyle(),
"");
115 TString button = HtmlCore::GetHideButtonTable(table_name,
116 Form(
"Hide/Show Pack %s [Package No. "
118 analysis_name.Data(),
123 fHTML->AddContent(div);
125 HtmlTable mainTable(table_name,
"maintable",
"display:none");
126 HtmlRow rowTable(
"", Hal::HtmlTableRowClass::ExpandableStyle(),
"");
128 TryExtractAnaResult(yellowCell, package, path);
132 fHTML->AddContent(div2);
134 Cout::PrintInfo(Form(
"%s found in Physics but don't inherit from HalPackage", key_name.Data()), Hal::EInfo::kLowWarning);
138 fHTML->AddStringContent(
"<script>window.onload=checkTask();</script>\n");
143 HtmlCore::ResetMainDir();
203 for (
int i = 0; i < 4; i++)
204 fCollectionsNo[i] = 0;
205 gSystem->MakeDirectory(fDir);
206 fHTML =
new HtmlFile(fDir +
"/index.html", kFALSE);
209 TString temp_dir = Form(
"%s/global_data/", fDir.Data());
211 CreatePackageList(dummyCell, pack_meta, eTableStyle::kMetaData, temp_dir, 2,
"drawmerged");
212 fHTML->AddStringContent(dummyCell.GetContent());
214 Int_t pack_counter = 0;
215 TString table_name = Form(
"task_table_%i", fTaskTableCounter++);
216 TString path = fDir +
"/superpack_0";
218 Package*
package = (Package*) pack_ana;
220 TString analysis_name = GetString(meta_data,
"Analysis Name");
221 HtmlDiv div1(
"buttontableM_0",
"",
"");
224 row1.
SetClass(Hal::HtmlTableRowClass::TaskStyle());
225 row1.SetStringContent(Form(
"<td><button> Task %i "
226 "[%s]</button></td>",
228 analysis_name.Data()));
231 fHTML->AddContent(div1);
233 HtmlTable table2(table_name,
"maintable",
"display:table");
235 row2.
SetClass(Hal::HtmlTableRowClass::ExpandableStyle());
237 TryExtractAnaResult(cell, package, path);
241 fHTML->AddContent(div2);
244 Cout::PrintInfo(Form(
"%s is not proper Object", pack_ana->ClassName()), Hal::EInfo::kLowWarning);
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++) {
259 TString pack_class_name(cutpack->
GetName(), strlen(cutpack->
GetName()));
260 if (pack_class_name.EqualTo(
"Hal::CutContainer")) {
261 fCurrentCutContainer = cutpack;
262 fCutContainerPosition = i + fCutContainerPosition;
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");
274 if (fCurrentCutContainer != NULL) {
275 CreateCutAndMonitorList(
object, path);
276 ExportCollections(
object, path);
278 fDynamicTableCounter++;
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);
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);
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);
304 void Package2HTML::CreateImagePage(TString filename, TString image_flag, Int_t no, TString )
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)));
316 file.AddStringContent(url);
317 file.AddStringContent(
"<script type=\'text/javascript\'>");
318 file.AddStringContent(
"</script></br>");
323 Package2HTML::CreatePackageList(
HtmlObject& table,
Package* pack, eTableStyle style, TString path, Int_t depth, Option_t* opt) {
324 TString options = opt;
326 TString styleTitle, styleLegend, styleCell, styleExtra;
327 styleTitle = Hal::HtmlTableRowClass::TitleStyle();
329 case Package2HTML::eTableStyle::kMetaData: {
330 styleLegend = Hal::HtmlTableRowClass::DarkBlue();
331 styleCell = Hal::HtmlTableRowClass::Grey();
332 styleExtra = Hal::HtmlTableRowClass::ExtraStyle();
334 case Package2HTML::eTableStyle::kStandard: {
335 styleLegend = Hal::HtmlTableRowClass::LegendStyle();
336 styleCell = Hal::HtmlTableRowClass::DefStyle();
337 styleExtra = Hal::HtmlTableRowClass::ExtraStyle();
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; }
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);
362 div.
SetId(table_name);
372 cell.AddStringContent(Form(
"ClassName : %s", pack->
GetName()));
382 cell.AddStringContent(Form(
"Comment : %s", pack->
GetComment().Data()));
391 if (RowNo == 0) row1.
SetClass(styleTitle);
403 legend1.AddSimpleCells({
"ClassName",
"Name",
"Value"});
407 std::vector<TString> out = Hal::Std::ExplodeString(path,
'/');
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()); }
412 if (inject.Length() > 0) { inject = inject +
"/"; }
413 for (
int i = 0; i < pack->
GetEntries(); i++) {
415 TString nameClass =
object->ClassName();
416 TString oryginal_class =
object->GetName();
419 oryginal_class = subpack->
GetName();
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);
427 row.AddSimpleCells({nameClass, oryginal_class, AddToUrl(inject,
HtmlCore::HTMLExtract(
object, i, path))});
430 }
else if (nameClass ==
"Hal::QAPlotReport") {
433 }
else if (nameClass !=
"TList" || fListDeep != 0) {
436 HtmlCell first_cell(Hal::Std::RoundToString(i));
437 first_cell.SetColSpan(2);
440 {nameClass, oryginal_class, AddToUrl(inject,
HtmlCore::HTMLExtract(
object, fTObjectCounter[
"TList"]++, path))});
443 CreateListTable(halTable, (TList*)
object, fTObjectCounter[
"TList"]++, path, inject, styleCell);
448 merged.
SetClass(Hal::HtmlTableRowClass::SummaryStyle());
449 HtmlCell cellM(
"Number of merged packages");
452 TString no = Form(
"%i", pack->
GetMerged());
460 void Package2HTML::CreateCutAndMonitorList(
HtmlObject& table, TString path) {
461 if (fCurrentCutContainer == NULL)
return;
462 TString table_name = Form(
"dynamic_table_%i", fDynamicTableCounter++);
467 rowButton.
SetClass(Hal::HtmlTableRowClass::ExpandableStyle());
472 div.
SetId(
"buttontable2");
478 tableCuts.
SetId(table_name);
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) "};
490 auto colLoop = [&](Hal::ECutUpdate upd, TString name) {
491 if (fCollectionsNo[
static_cast<Int_t
>(upd)]) {
493 row.
SetClass(Hal::HtmlTableRowClass::TitleStyle());
498 for (
int i = 0; i < fCollectionsNo[static_cast<Int_t>(upd)]; i++) {
499 CreateCutHTML(tableCuts, upd, i);
503 for (
int i = 0; i < 4; i++)
504 colLoop(updList[i], colNames[i]);
506 table_name = Form(
"dynamic_table_%i", fDynamicTableCounter++);
512 divCutMonitorButton.
SetId(
"buttontable3");
513 HtmlTable tableMonitorsButton(
"",
"haltable",
"");
514 HtmlRow clicableRow(
"", Hal::HtmlTableRowClass::ExpandableStyle(),
"");
518 divCutMonitorButton.
AddContent(tableMonitorsButton);
520 HtmlTable tableMonitors(table_name,
"haltable",
"display:none");
521 Int_t cut_monitor_counter = 0;
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(),
"");
530 for (
int i = 0; i < fCollectionsNo[static_cast<Int_t>(upd)]; i++) {
531 CreateCutMonitorHTML(tableMonitors, upd, i, cut_monitor_counter, path);
535 for (
int i = 0; i < 4; i++)
536 collectionLoop(updList[i], names[i]);
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";
551 case Hal::ECutUpdate::kTrack:
552 desc =
"TrackCollection";
555 case Hal::ECutUpdate::kTwoTrack:
556 desc =
"TwoTrackCollection";
557 names =
"Track TwoTracks";
559 case Hal::ECutUpdate::kTwoTrackBackground:
560 desc =
"TwoTrackCollectionBackground";
561 names =
"Track TwoTracks (Background)";
563 default:
Cout::PrintInfo(
"Unknown cut update during HTML export", Hal::EInfo::kLowWarning);
break;
566 TList* listA = (TList*) fCurrentCutContainer->
GetObjectByName(group_name);
567 if (listA == NULL)
return;
569 if (subcontainer == NULL)
return;
571 HtmlRow rowGreen(
"", Hal::HtmlTableRowClass::TitleStyle(),
"");
572 HtmlCell cellGreen(Form(
"Collection No %i [%s]", collection_no, desc.Data()));
573 cellGreen.SetColSpan(8);
577 rowGreen2.AddSimpleCells({
"No",
"Cut name",
"Passed",
"Failed",
"Min",
"Max",
"Units",
"Type"});
578 rowGreen2.
SetClass(Hal::HtmlTableRowClass::LegendStyle());
581 TList* listfast = (TList*) subcontainer->
GetObjectByName(
"FastCutList");
583 for (
int i = 0; i < listfast->GetEntries(); i++) {
584 CreateCutLink(table, cut_update, (
Package*) listfast->At(i), i, kTRUE);
586 ULong64_t passed = GetULong(subcontainer,
"PassedFast");
587 ULong64_t failed = GetULong(subcontainer,
"FailedFast");
589 rowFast.
SetClass(Hal::HtmlTableRowClass::SummaryStyle());
594 for (
int i = 0; i < 3; i++)
598 for (
int i = 0; i < list->GetEntries(); i++) {
599 CreateCutLink(table, cut_update, (
Package*) list->At(i), i, kFALSE);
601 passed = GetULong(subcontainer,
"PassedSlow");
602 failed = GetULong(subcontainer,
"FailedSlow");
604 rowSlow.
SetClass(Hal::HtmlTableRowClass::SummaryStyle());
609 for (
int i = 0; i < 3; i++)
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);
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) {
623 if (classTemp->InheritsFrom(a))
return kTRUE;
627 if (IsInhert(class_temp, {
"Hal::TrackComplexCut",
"Hal::EventComplexCut",
"Hal::TwoTrackComplexCut"})) {
630 TString name_real = GetString(cut,
"CutName_{re}");
632 TString name_img = GetString(cut,
"CutName_{im}");
633 dummy_name = Form(
"<br/>(%s %s)", name_real.Data(), name_img.Data());
637 if (IsInhert(class_temp, {
"Hal::TrackRealCut",
"Hal::EventRealCut",
"Hal::TwoTrackRealCut"})) {
639 TString name_real = GetString(cut,
"CutName_{re}");
640 dummy_name = Form(
"<br/>(%s)", name_real.Data());
644 if (IsInhert(class_temp, {
"Hal::TrackImaginaryCut",
"Hal::EventImaginaryCut",
"Hal::TwoTrackImaginaryCut"})) {
646 TString name_real = GetString(cut,
"CutName_{im}");
647 dummy_name = Form(
"<br/>(%s)", name_real.Data());
652 if (fSoftVer < 201705) { complex = kFALSE; }
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");
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";
663 row.
SetClass(Hal::HtmlTableRowClass::DefStyle());
664 row.AddSimpleCells({numer, address, passed, failed});
665 for (
int i = 0; i < 3; i++)
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());
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);
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);
695 row.AddSimpleCells({minima, maxima, units});
697 type_cell.SetRowSpan(cut_size);
700 TString min, max, unit;
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);
711 singleCut.
SetClass(Hal::HtmlTableRowClass::DefStyle());
712 singleCut.AddSimpleCells({minima, maxima, units});
717 void Package2HTML::CreateCutMonitorLink(
HtmlObject& table,
718 Hal::ECutUpdate update,
723 TString numer = Hal::Std::RoundToString(no);
725 TString exupdate =
"no";
727 if (ex == 1) exupdate =
"yes";
728 TString monitor_class = monitor->
GetName();
729 TString address =
HtmlCore::GetUrl(GetLinkToCutMonitor(update, collection_no, no), monitor_class);
734 cutInfo[0].SetStringContent(numer);
735 cutInfo[1].SetStringContent(address);
736 cutInfo[7].SetStringContent(link);
737 cutInfo[8].SetStringContent(exupdate);
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>(");
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);
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(),
"");
761 cutInfo[8].SetStringContent(exupdate);
765 for (
int i = 0; i < 9; i++) {
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++) {
779 HtmlRow rowMonitor2(
"", Hal::HtmlTableRowClass::DefStyle(),
"");
781 for (
int i = 2; i < 7; i++) {
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++) {
796 HtmlRow rowMonitor2(
"", Hal::HtmlTableRowClass::DefStyle(),
"");
798 for (
int i = 2; i < 7; i++) {
802 HtmlRow rowMonitor3(
"", Hal::HtmlTableRowClass::DefStyle(),
"");
804 for (
int i = 2; i < 7; i++) {
810 for (
int i = 0; i < 7; i++)
820 void Package2HTML::CreateListTable(
HtmlObject& table,
826 if (path_url ==
"") { path_url = path_data; }
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});
851 classname = Form(
"Hal::Package [%s] ",
863 void Package2HTML::CreateCutMonitorHTML(
HtmlObject& table,
864 Hal::ECutUpdate cut_upd,
868 TString group_name, desc, names;
869 group_name = GetGroupListName(cut_upd);
871 case Hal::ECutUpdate::kEvent:
872 desc =
"EventCollection";
875 case Hal::ECutUpdate::kTrack:
876 desc =
"TrackCollection";
879 case Hal::ECutUpdate::kTwoTrack:
880 desc =
"TwoTrackCollection";
881 names =
"Track TwoTracks";
883 case Hal::ECutUpdate::kTwoTrackBackground:
884 desc =
"TwoTrackBackgroundCollection";
885 names =
"Track TwoTracks Background";
887 default:
Cout::PrintInfo(
"Unhandled monitor group in HalPackage2HTML", Hal::EInfo::kLowWarning);
break;
890 row.
SetClass(Hal::HtmlTableRowClass::TitleStyle());
891 HtmlCellCol cell(Form(
"Collection No %i [%s]", collection_no, names.Data()), 9);
895 TList* listA = (TList*) fCurrentCutContainer->
GetObjectByName(group_name);
896 if (listA == NULL)
return;
898 if (subcontainer == NULL)
return;
899 TList* list = (TList*) subcontainer->
GetObjectByName(
"CutMonitorList");
900 if (list == NULL)
return;
902 if (list->GetEntries() > 0) {
904 rowE.
SetClass(Hal::HtmlTableRowClass::LegendStyle());
906 {
"No",
"ClassName",
"CutName",
"Unit",
"AxisOption",
"CutMin",
"CutMax",
"Stacked</br>Img",
"Ex</br>Update"});
908 for (
int i = 0; i < list->GetEntries(); i++) {
909 CreateCutMonitorLink(table, cut_upd, (
Package*) list->At(i), i, ++counter, path);
913 rowE.
SetClass(Hal::HtmlTableRowClass::DefStyle());
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;
929 info.sFraction = passed / (failed + passed);
931 info.sColId = collectionno->
GetValue();
934 if (pack->
Exist(
"NextObj"))
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);
945 if (pack->
Exist(
"NextObj"))
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);
958 void Package2HTML::ExportCollections(
HtmlObject&
object, TString path) {
959 if (fCurrentCutContainer == NULL)
return;
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));
968 Int_t ttrackColBckg = 0;
971 eventCol = listE->GetEntries();
975 trackCol = listT->GetEntries();
979 ttrackCol = listT2->GetEntries();
982 if (listT2B) { ttrackColBckg = listT2B->GetEntries(); }
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);
991 for (
int i = 0; i < trackCol; i++) {
992 auto pack = (
Package*) listT->At(i);
994 auto info = GetContainerInfo(pack,
true);
995 for (
auto link : info.sLinks) {
996 pic.
AddLink({1, 2}, {info.sColId, link}, 1);
1000 auto info = GetContainerInfo(pack,
false);
1001 for (
auto link : info.sLinks) {
1002 pic.
AddLink({1, 2}, {info.sColId, link}, 0);
1005 auto info = GetContainerInfo(pack,
false);
1006 pic.
AddPoint(1, i, 0, info.sFraction);
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);
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);
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 "
1023 object.AddStringContent(text);
1024 pic.
SaveAs(Form(
"%s/main_pict.png", path.Data()));
1027 TString Package2HTML::GetLink1D(TH1* h1, TH1* h2, Int_t no, TString path)
const {
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();
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()));
1047 return HtmlCore::GetUrl(Form(
"th1_%i/histo.html", no), Form(
"2x%s", h1->ClassName()));
1050 TString Package2HTML::GetLink2D(TH2* h1, TH2* h2, Int_t no, TString path)
const {
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);
1058 h1->SetTitle(Form(
"%s (Passed)", h1->GetTitle()));
1061 h2->SetTitle(Form(
"%s (Failed)", h2->GetTitle()));
1063 c1->SetName(
"cutmon");
1064 c1->SaveAs(Form(
"%s/cutmon.root", path.Data()));
1069 return HtmlCore::GetUrl(Form(
"th1_%i/histo.html", no), Form(
"2x%s", h1->ClassName()));
1072 TString Package2HTML::GetLink3D(TH3* h1, TH3* h2, Int_t no, TString path)
const {
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);
1080 h1->SetTitle(Form(
"%s (Passed)", h1->GetTitle()));
1081 h1->Draw(Draw_3D_option);
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()));
1091 return HtmlCore::GetUrl(Form(
"th1_%i/histo.html", no), Form(
"2x%s", h1->ClassName()));
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);
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;
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",
1125 fCutContainerPosition,
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);
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;
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",
1145 fCutContainerPosition,
1152 TString Package2HTML::GetGroupListName(Hal::ECutUpdate update)
const {
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;
1162 Package2HTML::~Package2HTML() {
1163 if (fHTML)
delete fHTML;
1170 void Package2HTML::GetCollectionsNumbers() {
1171 TString collection_name[4] = {
1172 "Event_collections_No",
"Track_collections_No",
"TwoTrack_collections_No",
"TwoTrack_collections_background_No"};
1178 if (event_collections_no)
1179 fCollectionsNo[
static_cast<Int_t
>(Hal::ECutUpdate::kEvent)] = event_collections_no->
GetValue();
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();
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();
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();
1193 fCollectionsNo[
static_cast<Int_t
>(Hal::ECutUpdate::kTwoTrackBackground)] = 0;
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(
"//",
"/");
1207 Double_t Package2HTML::GetDouble(
const Package* pack, TString name)
const {
1211 TString Package2HTML::GetString(
const Package* pack, TString name)
const {
1215 ULong64_t Package2HTML::GetULong(
const Package* pack, TString name)
const {
1221 TDirectory* global_dir = (TDirectory*) fFile->Get(
"HalInfo");
1222 if (!global_dir)
return kFALSE;
1223 TString temp_dir = Form(
"%s/global_data", fDir.Data());
1226 fSoftVer = Hal::Std::VersionId(GetString(pack,
"Software ver"));
1227 CreatePackageList(runCell, pack, eTableStyle::kMetaData, temp_dir, 2,
"drawmerged");
1228 fHTML->AddStringContent(runCell.GetContent());
static void PrintInfo(TString text, Hal::EInfo status)
static TString GetUrl(TString adress, TString text)
static TString GetHideButtonTable(TString tableName, TString text)
static TString ClickablePic(TString id_name, TObjArray *strings, Int_t width=796, Int_t height=572)
static TString GetJsDiv(TString root_file, TString object_name, TString draw_opt="colz", TString draw_div_name="drawing")
static TString HTMLExtract(TObject *obj, Int_t no, TString dir="")
static void FixAddress(TString &address)
static TString GetHideButtonRow(TString listName, TString text)
void SetClass(TString className)
virtual void AddContent(const HtmlObject &obj)
void SetStyle(TString style)
virtual void AddContent(const HtmlObject &obj)
virtual void AddContent(const HtmlObject &obj)
virtual void HTMLExtractIntoTable(Int_t, HtmlTable &, TString="", TString="") const
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
TObject * GetObject(Int_t i) const
TString GetComment() const
TObject * GetObjectByName(TString name, Int_t index=0, Bool_t quited=kFALSE) const
const char * GetName() const
void AddPoint(Int_t depth, Int_t number, Int_t style, Double_t ratio)
void AddLink(std::initializer_list< Int_t > depths, std::initializer_list< Int_t > ids, Int_t style)
void SaveAs(TString path)
Double_t GetWidth() const
Double_t GetHeight() const