From: hadaq Date: Fri, 13 Jun 2025 13:43:24 +0000 (+0200) Subject: latest jsroot files X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=a6d40639be7c433011e595eadebfa3ad67e05098;p=hadesdaq.git latest jsroot files --- diff --git a/hadesroot/EMC.htm b/hadesroot/EMC.htm index b234580..23e2049 100644 --- a/hadesroot/EMC.htm +++ b/hadesroot/EMC.htm @@ -6,11 +6,17 @@ QA - EMC +
- - - - +
+ + + + +
+
+ + +
-
+
diff --git a/hadesroot/MDC.htm b/hadesroot/MDC.htm index b22fc8c..6b0bd2e 100644 --- a/hadesroot/MDC.htm +++ b/hadesroot/MDC.htm @@ -6,12 +6,17 @@ QA - MDC
- - - - - - - - - +
+ + + + + + + + + +
+
+ + +
-
+
@@ -535,7 +562,7 @@ let helptext =
-
+
diff --git a/hadesroot/Main.htm b/hadesroot/Main.htm index 3bba630..eda738e 100644 --- a/hadesroot/Main.htm +++ b/hadesroot/Main.htm @@ -6,13 +6,17 @@ QA - Main
- - - +
+ + + +
+
+ + +
-
+
diff --git a/hadesroot/Physics.htm b/hadesroot/Physics.htm index 0143bca..0cb82fb 100644 --- a/hadesroot/Physics.htm +++ b/hadesroot/Physics.htm @@ -6,12 +6,17 @@ QA - Physics
- - - - - - - - +
+ + + + + + + + +
+
+ + +
-
+
diff --git a/hadesroot/RICH.htm b/hadesroot/RICH.htm index c6183a3..3f70de1 100644 --- a/hadesroot/RICH.htm +++ b/hadesroot/RICH.htm @@ -6,11 +6,17 @@ QA - RICH +
- - - - - - - - +
+ + + + + + + + +
+
+ + +
-
+
diff --git a/hadesroot/RPC.htm b/hadesroot/RPC.htm index 542a818..f984fab 100644 --- a/hadesroot/RPC.htm +++ b/hadesroot/RPC.htm @@ -6,13 +6,17 @@ QA - RPC
- - - - - - - - - +
+ + + + + + + + + +
+
+ + +
-
+
diff --git a/hadesroot/Start.htm b/hadesroot/Start.htm index 7cd1a75..19af689 100644 --- a/hadesroot/Start.htm +++ b/hadesroot/Start.htm @@ -6,13 +6,17 @@ QA - Start
- - - - +
+ + + + +
+
+ + +
-
+
diff --git a/hadesroot/TDC.htm b/hadesroot/TDC.htm new file mode 100644 index 0000000..0b33dae --- /dev/null +++ b/hadesroot/TDC.htm @@ -0,0 +1,200 @@ + + + + + + + QA - Main + + + + + + +
+
+ + + + + + + + + + + +
+
+ + +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/hadesroot/TOF.htm b/hadesroot/TOF.htm index 74bbe6c..cdeb578 100644 --- a/hadesroot/TOF.htm +++ b/hadesroot/TOF.htm @@ -6,14 +6,18 @@ QA - TOF
- - - - - +
+ + + + + +
+
+ + +
-
+
diff --git a/hadesroot/WALL.htm b/hadesroot/WALL.htm index cb4d42e..dfa5ecb 100644 --- a/hadesroot/WALL.htm +++ b/hadesroot/WALL.htm @@ -6,12 +6,17 @@ QA - WALL
- - - - - - - - +
+ + + + + + + + +
+
+ + +
- -
+
diff --git a/hadesroot/files/functions.mjs b/hadesroot/files/functions.mjs index d567199..e029e07 100644 --- a/hadesroot/files/functions.mjs +++ b/hadesroot/files/functions.mjs @@ -1,16 +1,15 @@ import * as root from '/jsroot/modules/main.mjs'; let first_call = {}; -export async function initUpdate(histnames, histoptions, helptext, globalSettings) { - for (var t = 0; t < histnames.length; t++) { +export async function initUpdate(histnames, helptext, globalSettings) { + for (let t = 0; t < histnames.length; t++) { first_call[t] = {}; } if (globalSettings) for (let [key, value] of Object.entries(globalSettings)) { root.settings[key] = value; } // document.getElementsByClassName("tabcontent")[0].style.display = 'flex'; - document.getElementsByClassName("tabcontent")[0].classList.add("active"); - await update(histnames, histoptions); + // document.getElementsByClassName("tabcontent")[0].classList.add("active"); // Array.from(document.getElementsByClassName("tabcontent")).forEach(addhelp); for (let tc = 0; tc < document.getElementsByClassName("tabcontent").length; tc++) { @@ -32,7 +31,7 @@ function deepMerge(target, source) { if (!source) return target; Object.entries(source).forEach(([key, value]) => { - if (value && typeof value === 'object') { + if (value && typeof value === 'object' && !Array.isArray(value)) { deepMerge(target[key] = target[key] || {}, value); return; } @@ -52,12 +51,37 @@ function setPainterSettings(painter, settings) { deepMerge(painter.getPadPainter(), settings.PAD); } -function createLegendEntry(obj, lbl) { - let entry = root.create('TLegendEntry'); - entry.fObject = obj; - entry.fLabel = lbl; - entry.fOption = 'l'; - return entry; +function createLegend(histo, histos, lbls, settings) { + let leg = root.create('TLegend'); + if (settings) Object.assign(leg, settings); + for (let [key, lbl] of Object.entries(lbls)) { + let entry = root.create('TLegendEntry'); + if (typeof lbl === 'object') { + deepMerge(entry, lbl); + entry.fObject = histos[key]; + } + else { + entry.fObject = histos[key]; + entry.fLabel = lbl; + entry.fOption = 'l'; + } + leg.fPrimitives.Add(entry); + } + if (!settings) + histo.fFunctions.Add(leg, 'autoplace'); + else + histo.fFunctions.Add(leg, ''); +} + +function createAxisLabels(lbl_names) { + const ret = root.create('THashList'); + for (let l = 0; l < lbl_names.length; l++) { + let lbl = root.create('TObjString'); + lbl.fString = lbl_names[l]; + lbl.fUniqueID = l + 1; + ret.Add(lbl, ''); + } + return ret; } function AddH2(h1, h2) { @@ -75,132 +99,108 @@ function AddH2(h1, h2) { h1.fArray[iX + (nbinsXh1 + 2) * iY] += h2.fArray[iX + (nbinsXh1 + 2) * iY]; } -export async function update(histnames, histoptions) { - - for (var t = 0; t < histnames.length; t++) { - let tablinks = document.getElementsByClassName("tablinks"); - if (!tablinks[t].className.includes("active")) - continue; +async function getHisto(base, histname, filename, histoption) { + // console.log(base + histname + filename); + let histo = await root.httpRequest(base + histname + filename, 'object'); + // console.log(histo); + deepMerge(histo, histoption); + // console.log(histo); + histo.LABEL = histo?.LABEL == '' ? histo.fTitle : histo.LABEL; + if (histo.XLABEL) histo.fXaxis.fLabels = createAxisLabels(histo.XLABEL); + if (histo.YLABEL) histo.fYaxis.fLabels = createAxisLabels(histo.YLABEL); + if (histo.ZLABEL) histo.fZaxis.fLabels = createAxisLabels(histo.ZLABEL); + for (let i = 0; i < histo.CONTOURS; i++) histo.fContour[i] = -9999; + return histo; +} - for (var i = 0; i < histnames[t].length; i++) { - if (!Array.isArray(histnames[t][i])) { - if (histnames[t][i] == '') continue; - let hist = await root.httpRequest('/qaweb/HadesQA/' + histnames[t][i] + '/root.json.gz?compact=23', 'object'); - if (histoptions[t][i].HIST) deepMerge(hist, histoptions[t][i].HIST); - if(hist.XLABEL) - histoptions[t][i].XLABEL = hist.XLABEL; - if (histoptions[t][i].XLABEL) { - hist.fXaxis.fLabels = root.create('THashList'); - for (let l = 0; l < histoptions[t][i].XLABEL.length; l++) { - let lbl = root.create('TObjString'); - lbl.fString = histoptions[t][i].XLABEL[l]; - lbl.fUniqueID = l + 1; - hist.fXaxis.fLabels.Add(lbl, ''); - } - } - if(hist.YLABEL) - histoptions[t][i].YLABEL = hist.YLABEL; - if (histoptions[t][i].YLABEL) { - hist.fYaxis.fLabels = root.create('THashList'); - for (let l = 0; l < histoptions[t][i].YLABEL.length; l++) { - let lbl = root.create('TObjString'); - lbl.fString = histoptions[t][i].YLABEL[l]; - lbl.fUniqueID = l + 1; - hist.fYaxis.fLabels.Add(lbl, ''); - } - } - let painter = await root.redraw(`t${t}d${i}`, hist, ''); - if (!first_call[t][i]) { - setPainterSettings(painter, histoptions[t][i]); - // painter = await root.redraw(`t${t}d${i}`, hist, ''); - first_call[t][i] = true; - } - // console.log(hist); - // console.log(painter); - // console.log(painter.getFramePainter()); - // console.log(painter.getPadPainter()); +async function updateCanvas(t, i, base, histnames, filename, histoptions, first_call) { + if (!Array.isArray(histnames)) { + if (histnames === '') return false; + getHisto(base, histnames, filename, histoptions).then(async function(histo) { + let painter = await root.redraw(`t${t}d${i}`, histo, ''); + if (!first_call) { + setPainterSettings(painter, histo); + painter = await root.redraw(`t${t}d${i}`, histo, ''); + // first_call = true; } - else { - let histo = []; - let label = {}; - for (var j = 0; j < histnames[t][i].length; j++) { - histo[j] = await root.httpRequest('/qaweb/HadesQA/' + histnames[t][i][j] + '/root.json.gz?compact=23', 'object'); - deepMerge(histo[j], histoptions[t][i][j].HIST); - if (histoptions[t][i][j].LABEL == '') label[j] = histo[j].fTitle; - if (histoptions[t][i][j].LABEL) label[j] = histoptions[t][i][j].LABEL; - if (histoptions[t][i][j].XLABEL) { - histo[j].fXaxis.fLabels = root.create('THashList'); - for (let l = 0; l < histoptions[t][i][j].XLABEL.length; l++) { - let lbl = root.create('TObjString'); - lbl.fString = histoptions[t][i][j].XLABEL[l]; - lbl.fUniqueID = l + 1; - histo[j].fXaxis.fLabels.Add(lbl, ''); - } - } - if (histo.length > 0 && histo[0]._typename.includes('TH2') && histoptions[t][i][0].STACK) - AddH2(histo[0], histo[j]); - // console.log(histo[j]); - } - const stack = root.createTHStack(...histo); - // console.log(stack); - if (histo[0].fTitle) stack.fTitle = histo[0].fTitle; - if (Object.keys(label).length) { - let leg = root.create('TLegend'); - if (histoptions[t][i][Object.keys(label)[0]].LEGENDNOAUTO) - Object.assign(leg, histoptions[t][i][Object.keys(label)[0]].LEGENDNOAUTO); - for (let [key, value] of Object.entries(label)) { - leg.fPrimitives.Add(createLegendEntry(histo[key], value)); - } - // console.log(leg); - if (!histoptions[t][i][Object.keys(label)[0]].LEGENDNOAUTO) - stack.fHists.arr[0].fFunctions.Add(leg, 'autoplace'); - else - stack.fHists.arr[0].fFunctions.Add(leg, ''); - } - let painter; - if (histo[0]._typename.includes('TH2') && histoptions[t][i][0].STACK) - painter = await root.redraw(`t${t}d${i}`, histo[0], ''); - else if (histoptions[t][i][0].STACK) + // console.log(histo); + // console.log(painter); + // console.log(painter.getFramePainter()); + // console.log(painter.getPadPainter()); + }); + } + else { + let promises = []; + for (let j = 0; j < histnames.length; j++) { + promises[j] = getHisto(base, histnames[j], filename, histoptions[j]); + } + Promise.all(promises).then(async function(histos) { + const label = Object.fromEntries( + histos.map((obj, index) => [index, obj.LABEL]).filter(([_, label]) => label !== undefined) + ); + const is2DStack = (histos[0]._typename.includes('TH2') && histos[0].STACK); + if (is2DStack) for (const histo of histos) AddH2(histos[0], histo); + const stack = root.createTHStack(...histos); + if (histos[0].fTitle) stack.fTitle = histos[0].fTitle; + if (label.length > 0 || histos[0].LEGENDNOAUTO) createLegend(histos[0], histos, label, histos[0].LEGENDNOAUTO); + let painter; + if (is2DStack) + painter = await root.redraw(`t${t}d${i}`, histos[0], ''); + else if (histos[0].STACK) + painter = await root.redraw(`t${t}d${i}`, stack, ''); + else + painter = await root.redraw(`t${t}d${i}`, stack, 'nostack'); + if (!first_call) { + setPainterSettings(painter, histos[0]); + if (is2DStack) + painter = await root.redraw(`t${t}d${i}`, histos[0], ''); + else if (histos[0].STACK) painter = await root.redraw(`t${t}d${i}`, stack, ''); else painter = await root.redraw(`t${t}d${i}`, stack, 'nostack'); - if (!first_call[t][i]) { - setPainterSettings(painter, histoptions[t][i][0]); - // if (histo[0]._typename.includes('TH2') && histoptions[t][i][0].STACK) - // painter = await root.redraw(`t${t}d${i}`, histo[0], ''); - // else if (histoptions[t][i][0].STACK) - // painter = await root.redraw(`t${t}d${i}`, stack, ''); - // else - // painter = await root.redraw(`t${t}d${i}`, stack, 'nostack'); - first_call[t][i] = true; - } - // console.log(stack); - // console.log(histo[0]); - // console.log(painter); - // console.log(painter.getFramePainter()); - // console.log(painter.getPadPainter()); + // first_call = true; } + // console.log(stack); + // console.log(histos[0]); + // console.log(painter); + // console.log(painter.getFramePainter()); + // console.log(painter.getPadPainter()); + }); + } + return true; +} + +function update_tab(t, histnames, histoptions, date, time) { + for (let i = 0; i < histnames[t].length; i++) { + let basename, filename; + if (date == 'LIVE' || date == '' || time == '') { + basename = '/qaweb/HadesQA/'; + filename = '/root.json.gz?compact=23'; } + else { + basename = `downloads/backup/${date}/${time}/HadesQA/`; + filename = '.root.json.gz'; + } + first_call[t][i] = updateCanvas(t, i, basename, histnames[t][i], filename, histoptions[t][i], first_call[t][i]); } } -export function openTab(evt, Name) { - // Declare all variables - var i, tabcontent, tablinks; +export function update(histnames, histoptions, date, time) { + for (let t = 0; t < histnames.length; t++) { + let tablinks = document.getElementsByClassName("tablinks"); + if (!tablinks[t].className.includes("active")) + continue; - // Get all elements with class="tabcontent" and hide them - tabcontent = document.getElementsByClassName("tabcontent"); - for (i = 0; i < tabcontent.length; i++) { - tabcontent[i].classList.remove("active"); + update_tab(t, histnames, histoptions, date, time); } +} - // Get all elements with class="tablinks" and remove the class "active" - tablinks = document.getElementsByClassName("tablinks"); - for (i = 0; i < tablinks.length; i++) { - tablinks[i].classList.remove("active"); - } +export function updateOtherTabs(histnames, histoptions, date, time) { + for (let t = 0; t < histnames.length; t++) { + let tablinks = document.getElementsByClassName("tablinks"); + if (tablinks[t].className.includes("active")) + continue; - // Show the current tab, and add an "active" class to the button that opened the tab - document.getElementById(Name).classList.add("active"); - evt.currentTarget.classList.add("active"); + update_tab(t, histnames, histoptions, date, time); + } } diff --git a/hadesroot/files/tab.css b/hadesroot/files/tab.css index e0eb6e1..42c81c1 100644 --- a/hadesroot/files/tab.css +++ b/hadesroot/files/tab.css @@ -103,9 +103,20 @@ body { padding: 0; margin: 0; background-color: #f1f1f1; + display: flex; + justify-content: space-between; + align-items: center; + /* flex-wrap: wrap; */ + gap: 0; + +} + +.tab-buttons { + display: flex; } -.tab button { +.tab button, +.tab a button { background-color: inherit; float: left; border: 1px solid #aaa; @@ -114,6 +125,23 @@ body { padding: 5px 20px; transition: 0.3s; border-radius:10px 10px 0 0; + flex-shrink: 0; +} + +.selector { + display: flex; +} + +.selector select { + background-color: inherit; + top: 5px; + float: right; + border: 1px solid #aaa; + outline: none; + cursor: pointer; + padding: 5px 20px; + transition: 0.3s; + border-radius:10px 10px 0 0; } .tab button:hover { diff --git a/hadesroot/index.htm b/hadesroot/index.htm index b4c4a91..b14a24f 100644 --- a/hadesroot/index.htm +++ b/hadesroot/index.htm @@ -30,7 +30,11 @@
  • RPC
  • Calorimeter
  • Forward Wall
  • +
    + +