From 38ffcb310426eb91a5d90c08ec018002e606e85e Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sun, 5 Apr 2020 08:28:35 +0200 Subject: [PATCH] allow to plot normalize data in mupp --- src/musredit_qt5/mupp/PmuppGui.cpp | 93 +++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 16 deletions(-) diff --git a/src/musredit_qt5/mupp/PmuppGui.cpp b/src/musredit_qt5/mupp/PmuppGui.cpp index 0ee3c1d4..b0b11ccc 100644 --- a/src/musredit_qt5/mupp/PmuppGui.cpp +++ b/src/musredit_qt5/mupp/PmuppGui.cpp @@ -1702,6 +1702,27 @@ void PmuppGui::plot() yLabel = substituteDefaultLabels(yLabel); fout << "yLabel: " << yLabel << endl; + // normalize if wished + if (fNormalize) { + double max=0.0; + for (int k=0; k max) + max = yyy[k][j]; + } + } else { + max = fNormVal; + } + for (int j=0; j &data, double &min, double &max) */ QString PmuppGui::substituteDefaultLabels(QString label) { - if (label == "dataT") - return QString("T (K)"); - else if (label == "dataB") - return QString("B (G)"); - else if (label == "dataE") - return QString("E (keV)"); - else if (!label.compare("sigma", Qt::CaseInsensitive)) - return QString("#sigma (1/#mus)"); - else if (!label.compare("lambda", Qt::CaseInsensitive)) - return QString("#lambda (1/#mus)"); - else if (!label.compare("alpha_LR", Qt::CaseInsensitive)) - return QString("#alpha_{LR}"); - else if (!label.compare("alpha_TB", Qt::CaseInsensitive)) - return QString("#alpha_{TB}"); - else - return label; + QString result(label); + + if (label == "dataT") { + result = QString("T (K)"); + } else if (label == "dataB") { + result = QString("B (G)"); + } else if (label == "dataE") { + result =QString("E (keV)"); + } else if (!label.compare("sigma", Qt::CaseInsensitive)) { + if (fNormalize) { + if (fNormVal == 0.0) + result = QString("#sigma/max(#sigma)"); + else + result = QString("#sigma/%1 (1/#mus)").arg(fNormVal); + } else { + result = QString("#sigma (1/#mus)"); + } + } else if (!label.compare("lambda", Qt::CaseInsensitive)) { + if (fNormalize) { + if (fNormVal == 0.0) + result = QString("#lambda/max(#lambda)"); + else + result = QString("#lambda/%1 (1/#mus)").arg(fNormVal); + } else { + result = QString("#lambda (1/#mus)"); + } + } else if (!label.compare("alpha_LR", Qt::CaseInsensitive)) { + if (fNormalize) { + if (fNormVal == 0.0) + result = QString("#alpha_{LR}/max(#alpha_{LR})"); + else + result = QString("#alpha_{LR}/%1").arg(fNormVal); + } else { + result = QString("#alpha_{LR}"); + } + } else if (!label.compare("alpha_TB", Qt::CaseInsensitive)) { + if (fNormalize) { + if (fNormVal == 0.0) + result = QString("#alpha_{TB}/max(#alpha_{TB})"); + else + result = QString("#alpha_{TB}/%1").arg(fNormVal); + } else { + result = QString("#alpha_{TB}"); + } + } else { + if (fNormalize) { + if (fNormVal == 0.0) { + result = QString("Normalized "); + result += label; + } else { + result = QString("%1/%2").arg(label).arg(fNormVal); + } + } + } + + return result; } //----------------------------------------------------------------------------------------------------