From 4b5a3903d51756a5a272e8623d8900a67c3fcc9d Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 27 Nov 2013 17:03:59 -0800 Subject: [PATCH 1/4] began expanding functionality for sophisticated beta plots --- efficiencyWidget.css | 9 ++- functions.js | 16 +++- index.html | 188 +++++++++++++++++++++++++++---------------- main.js | 74 ++++++++++------- plumbing.js | 21 ++++- 5 files changed, 203 insertions(+), 105 deletions(-) diff --git a/efficiencyWidget.css b/efficiencyWidget.css index e87d35c..8969e18 100644 --- a/efficiencyWidget.css +++ b/efficiencyWidget.css @@ -136,7 +136,7 @@ h1#title{ /*background-color:#333333 !important;*/ background: transparent !important; font-size:200% !important; - width: 6.5em !important; + width: 7.5em !important; left: auto !important; right: 0px !important; } @@ -315,16 +315,21 @@ select#nHPGeSwitch{ width:3em; } -div#HPGeControl, div#LaBr3Control{ +div#HPGeControl, div#SCEPTARControl{ overflow:hidden; -webkit-transition: height 0.5s ease; -moz-transition: height 0.5s ease; + padding-bottom: 1em; } input#yMin, input#yMax{ width: 3em; } +div.optionalParameters{ + border-top: 1px solid #999999; +} + /*img holder for savable data///////////////////////////////////////*/ img#pngDump{ display:none; diff --git a/functions.js b/functions.js index 5f5d56b..5fe7548 100644 --- a/functions.js +++ b/functions.js @@ -66,7 +66,21 @@ function DESCANTefficiency(logE){ } } -function SCEPTARefficiency(detector, logE){ +//SCEPTAR simulation +function SCEPTAREfficiency(param, loParam, hiParam, logE){ + var logEff = 0, + eff; + + //Evan & Carl requested the 0.8 hack-in instead of param[6] + logEff = 0.8*(1-1/(Math.exp((logE-param[0])/param[1])+1)-1/(Math.exp((logE-param[2])/param[3])+1)-1/(Math.exp((logE-param[4])/param[5])+1)); + eff = Math.exp(logEff); + eff = Math.max(eff, 0.00065); + + return eff + ';' + eff + ';' + eff; +} + +//SCEPTAR & friends estimates +function SCEPTARauxEfficiency(detector, logE){ if(detector == 'SCEPTAR') return '0.8;0.8;0.8'; diff --git a/index.html b/index.html index 5380557..a260db4 100644 --- a/index.html +++ b/index.html @@ -29,9 +29,12 @@ + + + @@ -79,76 +82,119 @@

GRIFFIN

- -
- - -
-
-

Plot Options

- -
HPGe
-
LaBr3
-
Si(Li)
- -

- - - - - - -

- - - - - -

-
- - - - -

- - + + + +
-

- - + +
+ +

Plot Options

-

- - +
HPGe
+
LaBr3
+
Si(Li)
+ + +

+ + + + + + +

+ + + + + +

+
+
+ + + + +

+ + + +

+ + + +

+ + + +
+ + + +
+ Save Plot + +
+
-
- Save Plot - - -
+ +

Beta Test

+
+
@@ -343,10 +389,12 @@

Triples

diff --git a/main.js b/main.js index d97d5cd..dc3f49b 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,8 @@ function setup(){ HPGeSwitch = document.getElementById('enableHPGe'), LaBr3Switch = document.getElementById('enableLaBr3'), SiLiSwitch = document.getElementById('enableSiLi'), + switchToBeta = document.getElementById('toBetaPlots'), + //SCEPTARSwitch = document.getElementById('enableSCEPTAR'); detailMessage = 'HPGe GEANT4 Simulation: 8th order polynomial fit including SCEPTAR and Delrin vacuum chamber.

'; detailMessage +='LaBr3 GEANT4 Simulation: 8th order polynomial fit above 40 keV including SCEPTAR and
Delrin vacuum chamber.

' detailMessage +='Si(Li) Simulation: Relative Efficiency curve shape based on formalism referenced in
Radiation Detection & Measurement (G.F. Knoll, Wiley 2000).
' @@ -13,10 +15,10 @@ function setup(){ detailMessage +='SCEPTAR + ZDS: 65% efficient.
' detailMessage +='SCEPTAR + PACES: 40% efficient.
' detailMessage +='PACES + ZDS: 25% efficient.' - //call the parameter dump loadParameters(); loadLaBrParameters(); + loadSCEPTARParameters(); //SiLi parameters taken from CITATION NEEDED //last parameter is an overall normalization to fix eff(603keV) = 0.0342, per //Masters Thesis of Ryan Dunlop, University of Guelph, 2012, @@ -70,7 +72,23 @@ function setup(){ } chooseGraphs(); } - + switchToBeta.onclick = function(){ + document.getElementById('plots').shuffleTo(1); + } + /* + SCEPTARSwitch.enabled = 0; + SCEPTARSwitch.onclick = function(event){ + if (this.enabled){ + this.style.backgroundColor = '#444444'; + this.enabled = 0; + } else{ + this.style.backgroundColor = '#c0392b'; + this.enabled = 1; + } + toggleSCEPTARControls(); + chooseGraphs(); + } + */ //make sure the file name for image saving gets passed around: document.getElementById('filename').onchange = function(){ //set the filename to whatever the user has requested: @@ -117,6 +135,7 @@ function setup(){ //make sure the plot area is a sane size: document.getElementById('graphDiv').style.width = (window.innerWidth - document.getElementById('controlPanel').offsetWidth)*0.95; document.getElementById('graphDiv').style.height = document.getElementById('controlPanel').offsetHeight*1.05; + document.getElementById('plots').style.height = document.getElementById('controlPanel').offsetHeight*1.1; //Set up widgets/////////////////////////////////////////////////////////////////////// //Singles @@ -136,32 +155,11 @@ function setup(){ nodes[i].onchange = validateNumber.bind(null, nodes[i].id); } - /* - document.getElementById('singlesInputEnergy').onchange = validateNumber.bind(null, 'singlesInputEnergy'); - document.getElementById('singlesBR').onchange = validateNumber.bind(null, 'singlesBR'); - document.getElementById('singlesIntensity').onchange = validateNumber.bind(null, 'singlesIntensity'); - document.getElementById('singlesDutyCycle').onchange = validateNumber.bind(null, 'singlesDutyCycle'); - document.getElementById('nSingles').onchange = validateNumber.bind(null, 'nSingles'); - - document.getElementById('coincInputEnergy1').onchange = validateNumber.bind(null, 'coincInputEnergy1'); - document.getElementById('coincInputEnergy2').onchange = validateNumber.bind(null, 'coincInputEnergy2'); - document.getElementById('coincBR1').onchange = validateNumber.bind(null, 'coincBR1'); - document.getElementById('coincBR2').onchange = validateNumber.bind(null, 'coincBR2'); - document.getElementById('singlesIntensity').onchange = validateNumber.bind(null, 'singlesIntensity'); - document.getElementById('singlesDutyCycle').onchange = validateNumber.bind(null, 'singlesDutyCycle'); - document.getElementById('nSingles').onchange = validateNumber.bind(null, 'nSingles'); - - document.getElementById('singlesInputEnergy').onchange = validateNumber.bind(null, 'singlesInputEnergy'); - document.getElementById('singlesBR').onchange = validateNumber.bind(null, 'singlesBR'); - document.getElementById('singlesIntensity').onchange = validateNumber.bind(null, 'singlesIntensity'); - document.getElementById('singlesDutyCycle').onchange = validateNumber.bind(null, 'singlesDutyCycle'); - document.getElementById('nSingles').onchange = validateNumber.bind(null, 'nSingles'); - */ - //default to on for demo: HPGeSwitch.onclick(); LaBr3Switch.onclick(); SiLiSwitch.onclick(); + //SCEPTARSwitch.onclick(); //evaluate all widgets at defaults computeSingles(); @@ -193,23 +191,31 @@ function chooseGraphs(){ window.HPGeFunc = HPGeEfficiency.bind(null, HPGeCoef[HPGeString], HPGeMinCoef['dummy'], HPGeMaxCoef['dummy']); funcs[funcs.length] = window.HPGeFunc; titles[titles.length] = 'HPGe'; - colors[colors.length] = '#449944'; + colors[colors.length] = colorCodes['HPGe']; } if(document.getElementById('enableLaBr3').enabled){ LaBrString = constructLaBrPlotKey(); window.LaBrFunc = LaBrEfficiency.bind(null, LaBrCoef[LaBrString], HPGeMinCoef['dummy'], HPGeMaxCoef['dummy']); funcs[funcs.length] = window.LaBrFunc; titles[titles.length] = 'LaBr3'; - colors[colors.length] = '#e67e22'; + colors[colors.length] = colorCodes['LaBr3']; } if(document.getElementById('enableSiLi').enabled){ SiLiString = constructSiLiPlotKey(); window.SiLiFunc = SiLiEfficiency.bind(null, SiLiCoef[SiLiString], HPGeMinCoef['dummy'], HPGeMaxCoef['dummy']); funcs[funcs.length] = window.SiLiFunc; titles[titles.length] = 'Si(Li)'; - colors[colors.length] = '#2980b9'; + colors[colors.length] = colorCodes['SiLi']; } - + /* + if(document.getElementById('enableSCEPTAR').enabled){ + SCEPTARString = constructSCEPTARPlotKey(); + window.SCEPTARFunc = SCEPTAREfficiency.bind(null, SCEPTARCoef[SCEPTARString], HPGeMinCoef['dummy'], HPGeMaxCoef['dummy']); + funcs[funcs.length] = window.SCEPTARFunc; + titles[titles.length] = 'SCEPTAR'; + colors[colors.length] = colorCodes['SCEPTAR']; + } + */ deployGraph(funcs, titles, colors, min, max); } @@ -332,6 +338,18 @@ function constructSiLiPlotKey(){ return 'detector'; } +function constructSCEPTARPlotKey(){ + var leptonOptions = document.getElementById('lepton'), + lepton = leptonOptions.options[leptonOptions.selectedIndex].value, + zOptions = document.getElementById('parentZ'), + z = zOptions.options[zOptions.selectedIndex].value, + thresholdOptions = document.getElementById('betaThreshold'), + threshold = thresholdOptions.options[thresholdOptions.selectedIndex].value, + plotKey = ''+lepton+z+threshold; + + return plotKey; +} + //callback to run every time the function repaints function repaint(dygraph){ var xMin = document.getElementById('xMin'), diff --git a/plumbing.js b/plumbing.js index c5f90ab..b2652cd 100644 --- a/plumbing.js +++ b/plumbing.js @@ -25,12 +25,20 @@ function toggleOutput(id, state){ function toggleHPGeControls(){ if(document.getElementById('enableHPGe').enabled){ - document.getElementById('HPGeControl').style.height = '21em'; + document.getElementById('HPGeControl').style.height = '23em'; } else{ document.getElementById('HPGeControl').style.height = 0; } } +function toggleSCEPTARControls(){ + if(document.getElementById('enableSCEPTAR').enabled){ + document.getElementById('SCEPTARControl').style.height = '12em'; + } else{ + document.getElementById('SCEPTARControl').style.height = 0; + } +} + //generate a hidden image and send its data uri to the appropriate place for saving: function prepImageSave(dygraph){ var options = { @@ -173,7 +181,12 @@ function getBase64Image(img) { ctx.fillText('Absorber: ' + absorber + ' mm Delrin', img.width-ctx.measureText('HPGe Distance: ' + HPGeDistance + ' cm').width-20, 140); ctx.fillText('Addback: ' + summing, img.width-ctx.measureText('HPGe Distance: ' + HPGeDistance + ' cm').width-20, 165); } - +/* + if(document.getElementById('enableSCEPTAR').enabled){ + ctx.font = '24px sans-serif'; + //... + } +*/ // Get the data-URL formatted image // Firefox supports PNG and JPEG. You could check img.src to guess the // original format, but be aware the using "image/jpg" will re-encode the image. @@ -211,7 +224,7 @@ function chooseFunction(detector){ else if(detector == 'DESCANT') return DESCANTefficiency; else - return SCEPTARefficiency.bind(null, detector) //SCEPTARefficiency contains a whole stable of detectors, use the catch all for this. + return SCEPTARauxEfficiency.bind(null, detector) //SCEPTARauxEfficiency contains a whole stable of detectors, use the catch all for this. } function sciNot(val, sig){ @@ -275,7 +288,7 @@ function confirm(headline, detailText){ var width = document.getElementById('tempDiv').offsetWidth; document.getElementById('tempDiv').style.left = document.body.offsetWidth/2 - width/2; - //insert submit & abort button + //insert abort button injectDOM('input', 'abortChoice', 'tempDiv', { 'class' : 'standardButton', 'style' : 'width:auto; height:auto; padding:0.5em; margin-bottom:1em', From 6f82f97ad27587f1191e1c92046709483f25da5a Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 29 Nov 2013 15:13:53 -0800 Subject: [PATCH 2/4] implemented view for beta particle eff as a function of Q --- efficiencyWidget.css | 20 +++-- functions.js | 14 +-- index.html | 66 +++++++++++--- main.js | 204 ++++++++++++++++++++++++++++++++++++------- plumbing.js | 51 +++++++---- 5 files changed, 281 insertions(+), 74 deletions(-) diff --git a/efficiencyWidget.css b/efficiencyWidget.css index 8969e18..1e99753 100644 --- a/efficiencyWidget.css +++ b/efficiencyWidget.css @@ -119,7 +119,7 @@ h1#title{ /*graph///////////////////////////////////////////////////////*/ /*container div*/ -#graphDiv{ +#graphDiv, #betaGraphDiv{ margin-bottom: 1em; height: 50em; width: 70%; @@ -193,7 +193,7 @@ h2.widgetTitle{ text-align: center; } -input.widgetInput, input#filename{ +input.widgetInput, input#filename, input#betaFilename{ background-color: #444444; border-radius: 5px; color: #CCCCCC; @@ -253,7 +253,7 @@ div.leftDiv{ } /*Control Panel/////////////////////////////////////////////////////*/ -div#controlPanel{ +div#controlPanel, div#betaControlPanel{ float:right; width:28%; min-width:-webkit-max-content; @@ -263,7 +263,7 @@ div#controlPanel{ padding: 1em; } -div.detectorSwitch, a#savePlot{ +div.detectorSwitch, a#savePlot, a#saveBetaPlot{ display:inline-block; padding:1em; height:3em; @@ -274,14 +274,18 @@ div.detectorSwitch, a#savePlot{ -moz-transition: background-color 0.3s; } -a#savePlot{ +a#savePlot, a#saveBetaPlot{ color:#FFFFFF; text-decoration: none; font-size: 100%; padding:1em; } -input#filename{ +a#savePlot:hover, a#saveBetaPlot:hover{ + background:#777777; +} + +input#filename, input#betaFilename{ width:15em; text-align: left; font-size: 100%; @@ -330,6 +334,10 @@ div.optionalParameters{ border-top: 1px solid #999999; } +div#enableSCEPTAR{ + background-color: #c0392b; +} + /*img holder for savable data///////////////////////////////////////*/ img#pngDump{ display:none; diff --git a/functions.js b/functions.js index 5fe7548..3eba78b 100644 --- a/functions.js +++ b/functions.js @@ -68,13 +68,17 @@ function DESCANTefficiency(logE){ //SCEPTAR simulation function SCEPTAREfficiency(param, loParam, hiParam, logE){ - var logEff = 0, - eff; + var eff, + Q = Math.exp(logE), + leptonOptions = document.getElementById('lepton'), + lepton = leptonOptions.options[leptonOptions.selectedIndex].value; + + if(Q<100) + return '0;0;0'; //Evan & Carl requested the 0.8 hack-in instead of param[6] - logEff = 0.8*(1-1/(Math.exp((logE-param[0])/param[1])+1)-1/(Math.exp((logE-param[2])/param[3])+1)-1/(Math.exp((logE-param[4])/param[5])+1)); - eff = Math.exp(logEff); - eff = Math.max(eff, 0.00065); + eff = 0.8*(1-1/(Math.exp((Q-param[0])/param[1])+1)-1/(Math.exp((Q-param[2])/param[3])+1)-1/(Math.exp((Q-param[4])/param[5])+1)); + if(lepton == 1) eff = Math.max(eff, 0.00065); //only for positrons return eff + ';' + eff + ';' + eff; } diff --git a/index.html b/index.html index a260db4..90cdb08 100644 --- a/index.html +++ b/index.html @@ -82,7 +82,8 @@

GRIFFIN

- + +
@@ -95,7 +96,7 @@

Plot Options

HPGe
LaBr3
Si(Li)
- +

@@ -151,8 +152,47 @@

Plot Options

+
+ Save Plot + + + + - +
+ + +
+
+

Plot Options

+ +
SCEPTAR
+ + +

+ + + + + + +

+ + + + + +

+ +

- - +

- Save Plot - + Save Plot +
- - -

Beta Test

-
@@ -206,6 +241,7 @@

Singles

+ @@ -248,6 +284,7 @@

Coincidences

+ @@ -259,6 +296,7 @@

Coincidences

+ @@ -301,8 +339,8 @@

Triples

- + @@ -317,8 +355,8 @@

Triples

- + @@ -333,8 +371,8 @@

Triples

- + diff --git a/main.js b/main.js index dc3f49b..14fb075 100644 --- a/main.js +++ b/main.js @@ -3,8 +3,9 @@ function setup(){ HPGeSwitch = document.getElementById('enableHPGe'), LaBr3Switch = document.getElementById('enableLaBr3'), SiLiSwitch = document.getElementById('enableSiLi'), + SCEPTARSwitch = document.getElementById('enableSCEPTAR'), switchToBeta = document.getElementById('toBetaPlots'), - //SCEPTARSwitch = document.getElementById('enableSCEPTAR'); + switchToGamma = document.getElementById('toGammaPlots'), detailMessage = 'HPGe GEANT4 Simulation: 8th order polynomial fit including SCEPTAR and Delrin vacuum chamber.

'; detailMessage +='LaBr3 GEANT4 Simulation: 8th order polynomial fit above 40 keV including SCEPTAR and
Delrin vacuum chamber.

' detailMessage +='Si(Li) Simulation: Relative Efficiency curve shape based on formalism referenced in
Radiation Detection & Measurement (G.F. Knoll, Wiley 2000).
' @@ -37,7 +38,7 @@ function setup(){ colorCodes['SCEPTARPACES'] = '#c0392b'; colorCodes['PACESZDS'] = '#f1c40f'; - //set up control panel////////////////////////////////////// + //set up gamma control panel////////////////////////////////////// HPGeSwitch.enabled = 0; HPGeSwitch.onclick = function(event){ if (this.enabled){ @@ -74,33 +75,18 @@ function setup(){ } switchToBeta.onclick = function(){ document.getElementById('plots').shuffleTo(1); + repaintBeta(b); //repaint to make sure the saved image has the right view-dependent imprint } - /* - SCEPTARSwitch.enabled = 0; - SCEPTARSwitch.onclick = function(event){ - if (this.enabled){ - this.style.backgroundColor = '#444444'; - this.enabled = 0; - } else{ - this.style.backgroundColor = '#c0392b'; - this.enabled = 1; - } - toggleSCEPTARControls(); - chooseGraphs(); - } - */ + //make sure the file name for image saving gets passed around: document.getElementById('filename').onchange = function(){ //set the filename to whatever the user has requested: document.getElementById('savePlot').download = this.value; } - - //plot range control////////////////////////////////////// - document.getElementById('xMin').onchange = chooseGraphs; - document.getElementById('xMax').onchange = chooseGraphs; - document.getElementById('yMin').onchange = chooseGraphs; - document.getElementById('yMax').onchange = chooseGraphs; - document.getElementById('yScale').onchange = chooseGraphs; + document.getElementById('betaFilename').onchange = function(){ + //set the filename to whatever the user has requested: + document.getElementById('saveBetaPlot').download = this.value; + } //default No. HPGe to 12: document.getElementById('nHPGeSwitch').value = 12; @@ -109,7 +95,19 @@ function setup(){ document.getElementById('summingScheme').value = 'clover'; //repaint the plot when anything in the form changes: - document.getElementById('plotOptions').onchange = chooseGraphs.bind(null); + document.getElementById('plotOptions').onchange = chooseGraphs; + + //setup beta control panel////////////////////////////////// + SCEPTARSwitch.enabled = 1; //SCEPTAR is the only beta plot now, so always active + SCEPTARSwitch.onclick = chooseBetaGraphs; + + switchToGamma.onclick = function(){ + document.getElementById('plots').shuffleTo(0); + repaint(g); //repaint to make sure the saved image has the right view-dependent imprint + } + + //beta plot range control////////////////////////////////////// + document.getElementById('betaPlotOptions').onchange = chooseBetaGraphs; //button setup////////////////////////////////////////////// document.getElementById('wikiLink').onclick = function(){ @@ -135,6 +133,8 @@ function setup(){ //make sure the plot area is a sane size: document.getElementById('graphDiv').style.width = (window.innerWidth - document.getElementById('controlPanel').offsetWidth)*0.95; document.getElementById('graphDiv').style.height = document.getElementById('controlPanel').offsetHeight*1.05; + document.getElementById('betaGraphDiv').style.width = (window.innerWidth - document.getElementById('controlPanel').offsetWidth)*0.95; + document.getElementById('betaGraphDiv').style.height = document.getElementById('controlPanel').offsetHeight*1.05; document.getElementById('plots').style.height = document.getElementById('controlPanel').offsetHeight*1.1; //Set up widgets/////////////////////////////////////////////////////////////////////// @@ -159,8 +159,7 @@ function setup(){ HPGeSwitch.onclick(); LaBr3Switch.onclick(); SiLiSwitch.onclick(); - //SCEPTARSwitch.onclick(); - + SCEPTARSwitch.onclick(); //evaluate all widgets at defaults computeSingles(); computeCoincidence(); @@ -168,7 +167,7 @@ function setup(){ } -//decide which plots to send to a call to deployGraph +//decide which plots to send to a call to deployGraph for gamma plots function chooseGraphs(){ var funcs = [], titles = [], @@ -207,7 +206,29 @@ function chooseGraphs(){ titles[titles.length] = 'Si(Li)'; colors[colors.length] = colorCodes['SiLi']; } - /* + + deployGraph(funcs, titles, colors, min, max); +} + +//as chooseGraphs but for beta plots +function chooseBetaGraphs(){ + var funcs = [], + titles = [], + colors = [], + min = parseFloat(document.getElementById('betaxMin').value), + max = parseFloat(document.getElementById('betaxMax').value), + HPGeMinCoef = {}, + HPGeMaxCoef = {}, + SCEPTARString, i; + + HPGeMinCoef['dummy'] = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + HPGeMaxCoef['dummy'] = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + + //make sure specified plot maxima aren't silly: + document.getElementById('betaxMax').min = parseFloat(document.getElementById('betaxMin').value); + document.getElementById('betayMax').min = parseFloat(document.getElementById('betayMin').value); + + //should always be true for now if(document.getElementById('enableSCEPTAR').enabled){ SCEPTARString = constructSCEPTARPlotKey(); window.SCEPTARFunc = SCEPTAREfficiency.bind(null, SCEPTARCoef[SCEPTARString], HPGeMinCoef['dummy'], HPGeMaxCoef['dummy']); @@ -215,8 +236,8 @@ function chooseGraphs(){ titles[titles.length] = 'SCEPTAR'; colors[colors.length] = colorCodes['SCEPTAR']; } - */ - deployGraph(funcs, titles, colors, min, max); + + deployBetaGraph(funcs, titles, colors, min, max); } //deploy graphs of [func]tions with [titles] @@ -307,6 +328,94 @@ function deployGraph(func, titles, colors, min, max){ } +//deploy graphs of [func]tions with [titles] for beta plots +function deployBetaGraph(func, titles, colors, min, max){ + var i, j, logx, deltaLow, deltaHigh, eff, + data = 'Q [keV]', + nPoints = 1000, + scaleSelect = document.getElementById("betaxScale"), + scale = scaleSelect.options[scaleSelect.selectedIndex].value; + yScaleSelect = document.getElementById("betayScale"), + yScale = yScaleSelect.options[yScaleSelect.selectedIndex].value; + if(yScale=='true') yScale = true; + else yScale = false; + //don't let the user switch to log scale with a 0 min + if(yScale && parseFloat(document.getElementById('betayMin').value)==0 ) + document.getElementById('betayMin').value = 0.001; + + for(i=0; i