Skip to content

Commit

Permalink
Adds more useful controls to ND
Browse files Browse the repository at this point in the history
  • Loading branch information
luketpickering committed Dec 5, 2019
1 parent 26c26fb commit 3a26cfb
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 13 deletions.
36 changes: 29 additions & 7 deletions NDComb.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@
<!-- d3.js -->
<script src="https://d3js.org/d3.v5.min.js"></script>

<!-- LALOLib -->
<script src="http://mlweb.loria.fr/lalolib-noglpk-module.min.js"></script>

<!-- Local code -->
<script src="tools/NDConstraintWidget.js"></script>
<script src="tools/plot.js"></script>
Expand Down Expand Up @@ -224,15 +221,40 @@ <h3>MathJax initializing...</h3>

<div class="row">
<div class="col-8">

<div class="row">
<div id="NDCombPlot"></div>
</div>

<div class="row">
<div class="form-group">
<label for="ND280_input">ND280 weight</label>
<input type="text" class="form-control" id="ND280_input" value="1">
</div>
</div>

<div class="row">
<div class="form-group">
<label for="WAGASCI_input">WAGASCI weight</label>
<input type="text" class="form-control" id="WAGASCI_input" value="1">
</div>
</div>

<div class="row">
<div class="form-group">
<label for="INGRID_input">INGRID weight</label>
<input type="text" class="form-control" id="INGRID_input" value="1">
</div>
</div>

</div>

<div class="col-4">
<h5>Click/Drag to choose Coefficients</h5>
<div id="ConstraintControls"></div>
</div>
</div>
<h5>Click/Drag to choose Coefficients</h5>
<div id="ConstraintControls"></div>
</div>
</div> <!--end row -->
</div>


</div>
Expand Down
42 changes: 40 additions & 2 deletions ndapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class ndapp {
this.Widgets.ConstraintControls =
document.getElementById("ConstraintControls");

this.Controls = {};
this.Controls.ND280_El = document.getElementById("ND280_input");
this.Controls.WAGASCI_El = document.getElementById("WAGASCI_input");
this.Controls.INGRID_El = document.getElementById("INGRID_input");

this.ebinning = [0, 0.111111, 0.222222, 0.333333, 0.444444, 0.555556, 0.666667, 0.777778, 0.888889, 1, 1.11111, 1.22222, 1.33333, 1.44444, 1.55556, 1.66667, 1.77778, 1.88889, 2, 2.11111, 2.22222, 2.33333, 2.44444, 2.55556, 2.66667, 2.77778, 2.88889, 3, 3.11111, 3.22222, 3.33333, 3.44444, 3.55556, 3.66667, 3.77778, 3.88889, 4, 4.11111, 4.22222, 4.33333, 4.44444, 4.55556, 4.66667, 4.77778, 4.88889, 5];

this.ND280Flux = [62331, 250248, 615333, 1.18128e+06, 1.81861e+06, 1.86869e+06, 1.42664e+06, 827517, 422623, 241665, 163120, 121161, 97147, 78615, 64391, 55346, 49211, 43076, 37606, 35057, 29522, 27751, 25408, 23698, 22977, 20517, 19658, 19880, 17788, 17849, 16626, 16418, 15611, 14884, 14699, 13962, 13388, 12746, 12416, 11738, 10945, 10710, 9968, 9238, 9022];
Expand Down Expand Up @@ -126,9 +131,38 @@ class ndapp {
this.InitializeConstraintControls();

this.Widgets.NDCombPlot = new OscProbPlot();
this.Widgets.NDCombPlot.DrawAxes(this.Widgets.NDCombPlot_El, 0, 5, -3, 5, "\\(\\textrm{Combined flux}\\)");
this.Widgets.NDCombPlot.DrawAxes(this.Widgets.NDCombPlot_El, 0, 3, -3, 5, "\\(\\textrm{Combined flux}\\)");

this.Update();

this.Controls.ND280_El.addEventListener("change", () => {
let chosen = parseFloat(this.Controls.ND280_El.value);
this.coeffs["ND280"] = chosen;
this.Update();
});
this.Controls.WAGASCI_El.addEventListener("change", () => {
let chosen = parseFloat(this.Controls.WAGASCI_El.value);
this.coeffs["WAGASCI"] = chosen;
this.Update();
});
this.Controls.INGRID_El.addEventListener("change", () => {
let chosen = parseFloat(this.Controls.INGRID_El.value);
this.coeffs["INGRID"] = chosen;
this.Update();
});
}

Update() {
let coeffcopy = Object.create(this.coeffs);

coeffcopy.point_class = this.color_class_wheel[this.wheel_idx];

AddNewConstrainWidgetPoints(coeffcopy);

this.Controls.ND280_El.value = this.coeffs["ND280"];
this.Controls.WAGASCI_El.value = this.coeffs["WAGASCI"];
this.Controls.INGRID_El.value = this.coeffs["INGRID"];

AddNewConstrainWidgetPoints(this.coeffs);
this.AddCurve(this.Widgets.NDCombPlot, this.coeffs, 1);

}
Expand All @@ -146,6 +180,10 @@ class ndapp {

this.AddCurve(this.Widgets.NDCombPlot, coeffcopy, 1);

this.Controls.ND280_El.value = this.coeffs["ND280"];
this.Controls.WAGASCI_El.value = this.coeffs["WAGASCI"];
this.Controls.INGRID_El.value = this.coeffs["INGRID"];

return coeffcopy;
},
(chg_par) => { // On drag
Expand Down
12 changes: 8 additions & 4 deletions tools/NDConstraintWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,20 @@ var constraint_plots = [];
function InitializeNDConstraintWidgets(el, onchanged_callback, on_hover_callback,
off_hover_callback) {

let ax_ND280 = new ConstraintAxes("ND280", "\\(\\textrm{ND280}\\)", -1,1, [3], 1, "ND280");
let ax_Dummy = new ConstraintAxes("Dummy", "\\(\\textrm{Dummy}\\)", -1, 1, [3], 1, "Dummy");

let ax_ND280 = new ConstraintAxes("ND280", "\\(\\textrm{ND280}\\)", -1, 1, [3], 1, "ND280");

let ax_WAGASCI = new ConstraintAxes("WAGASCI", "\\(\\textrm{WAGASCI}\\)", -1, 1, [3], 1, "WAGASCI");

let ax_INGRID = new ConstraintAxes("INGRID", "\\(\\textrm{INGRID}\\)", -1, 1, [3], 1, "INGRID");

constraint_plots.push(new ConstraintWidget(
ax_ND280, ax_WAGASCI));
ax_ND280, ax_Dummy));
constraint_plots.push(new ConstraintWidget(
ax_WAGASCI, ax_Dummy));
constraint_plots.push(new ConstraintWidget(
ax_WAGASCI, ax_INGRID));
ax_INGRID, ax_Dummy));

for (let plot_i = 0; plot_i < constraint_plots.length; ++plot_i) {
constraint_plots[plot_i].Initialize(el, function (pp) {
Expand All @@ -206,6 +210,6 @@ function SetConstrainWidgetPoints() {

function AddNewConstrainWidgetPoints(params) {
for (let plot_j = 0; plot_j < constraint_plots.length; ++plot_j) {
constraint_plots[plot_j].SetParams();
constraint_plots[plot_j].AddNewParams(params);
}
}

0 comments on commit 3a26cfb

Please sign in to comment.