Skip to content

Commit

Permalink
Fixes confusing controls when dcp is defined cyclicly differently bet…
Browse files Browse the repository at this point in the history
…ween plots.
  • Loading branch information
luketpickering committed May 9, 2019
1 parent 035c78c commit ba84869
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tools/OscConstraintWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ class PlotPoint {
};

class ConstraintAxes {
constructor(namef, titlef, minf, maxf, tickArgsf = [5], exp_scalef = 1) {
constructor(namef, titlef, minf, maxf, tickArgsf = [5], exp_scalef = 1, param_namef=undefined) {
this.name = namef;
this.title = titlef;
this.min = minf * exp_scalef;
this.max = maxf * exp_scalef;
this.tickArgs = tickArgsf;
this.exp_scale = exp_scalef;
this.param_name = param_namef;
if(this.param_name === undefined){
this.param_name = this.name;
}
}
};

Expand All @@ -128,8 +132,8 @@ class ConstraintWidget {
this.last_OscParamPoint.remove();
}

let x = oscParams.Get(this.xAxis.name);
let y = oscParams.Get(this.yAxis.name);
let x = oscParams.Get(this.xAxis.param_name);
let y = oscParams.Get(this.yAxis.param_name);

this.last_OscParamPoint = this.svg.append("circle")
.attr("class", `cpoint ${point_class}`)
Expand Down Expand Up @@ -206,8 +210,8 @@ class ConstraintWidget {
RenderLatexLabel(this.svg.append("text").text(this.yAxis.title), this.svg,
"25ex", "10ex", -120, -80, 1, 1, -90);

let xAxis_name = this.xAxis.name;
let yAxis_name = this.yAxis.name;
let xAxis_name = this.xAxis.param_name;
let yAxis_name = this.yAxis.param_name;

function clickHandler(owner) {
// Get x/y in axes coords
Expand Down Expand Up @@ -385,11 +389,11 @@ function InitializeConstraintWidgets(el, onchanged_callback, on_hover_callback,

let ax_dcp_mpi_pi =
new ConstraintAxes("dcp", "\\(\\delta_{\\rm {\\small cp}} /\\pi\\)",
-Math.PI, Math.PI, [2], 1.0 / Math.PI);
-Math.PI, Math.PI, [2], 1.0 / Math.PI, "dcp_mpi_pi");

let ax_dcp_0_2pi =
new ConstraintAxes("dcp", "\\(\\delta_{\\rm {\\small cp}} /\\pi\\)",
0, 2*Math.PI, [2], 1.0 / Math.PI);
0, 2*Math.PI, [2], 1.0 / Math.PI, "dcp_0_2pi");


let ax_S2Th13 = new ConstraintAxes("S2Th13", GetParamLatexName("S2Th13"),
Expand Down
25 changes: 25 additions & 0 deletions tools/OscUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"use strict";

function myfmod(a, b) {
return Number((a - (Math.floor(a / b) * b)).toPrecision(8));
};

/// Helper class for wrapping up the Prob3.js BargerPropagator into a slightly more easy-to-use interface (set experimental/osc parameters once, identify neutrinos with pdg numbers rather than Prob3++ enum, ...)
class OscHelper {
constructor() {
Expand Down Expand Up @@ -83,7 +87,20 @@ class OscParams {
} else if (name === "S2Th13") {
this.S2Th13 = value;
} else if (name === "dcp") {
this.dcp = myfmod(value, 2 * Math.PI);
if (this.dcp < -Math.PI) {
this.dcp = (this.dcp + 2 * Math.PI);
}
if (this.dcp > Math.PI) {
this.dcp = (this.dcp - 2 * Math.PI);
}
} else if (name === "dcp_mpi_pi") {
this.dcp = value;
} else if (name === "dcp_0_2pi") {
this.dcp = value;
if (this.dcp > Math.PI) {
this.dcp = (this.dcp - 2 * Math.PI);
}
}
}

Expand All @@ -96,6 +113,14 @@ class OscParams {
return this.S2Th13;
} else if (name === "dcp") {
return this.dcp;
} else if (name === "dcp_mpi_pi") {
return this.dcp;
} else if (name === "dcp_0_2pi") {
let rtn = this.dcp;
if (rtn < 0) {
rtn = (2 * Math.PI + rtn);
}
return rtn;
}
}

Expand Down

0 comments on commit ba84869

Please sign in to comment.