-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsahistprojpage.html
591 lines (546 loc) · 20 KB
/
psahistprojpage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="plotly-latest.min.js"></script>
<title>Pixie-Net PSA Histogram</title>
<style type="text/css">
body { background-color:#d0d0d0; font-family:sans-serif; }
h1 { margin:0; font-size:24px }
h2 { margin-top:15px; font-size:20px; font-weight:normal; border-bottom:1px solid #ff9040 }
p { font-size:14px }
li { font-size:14px }
a { color:#6060d0; text-decoration:none }
a:hover { text-decoration:underline }
.header { padding: 20px; text-align: center; background: #1e73be; color: white; }
.header h1 { font-size: 40px; }
/* Ensure proper sizing */
* { box-sizing: border-box; }
/* Column container */
.row { display: flex; flex-wrap: wrap; }
/* Sidebar/left column */
.side { height: 100%; width: 180px; position: fixed; background-color: white; padding: 20px; }
.side a { float: left; display: block; color: #002b80; text-align: left; padding: 10px 10px; text-decoration: none; }
.side a:hover { background-color: #ddd; color: #1e73be; }
/* bottom help section */
.fixed_bot { position: fixed; bottom: 0; left: 0; width: 180px; padding: 20px }
.fixed_bot p {font-size: 11px; }
.fixed_bot a {font-size: 12px; }
/* Main column */
.main { margin-left: 180px; padding: 20px; }
.w3-card-2{
background-color:white;
border-radius:3px;
padding: 10px;
margin-bottom: 20px;
box-shadow:0 4px 10px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)
}
.tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; }
.tooltip .tooltiptext {
visibility: hidden;
width: 250px;
background-color: #1e73be;
color: white;
text-align: left;
border-radius: 6px;
padding: 5px 5px;
position: absolute;
z-index: 1;
}
.tooltip:hover .tooltiptext { visibility: visible; width: 250px; top: 100%; left: 80%; margin-left: -60px; }
</style>
</head>
<body>
<div class="header">
<h1>Pixie-Net PSA Histogram</h1>
</div>
<div class="row">
<div class="side">
<img src="xialogo.jpg" width="140" height=auto alt="XIA Logo">
<p> </p>
<a href="/index.html"> Home </a>
<a href="cgitraces.cgi"> Current ADC traces </a>
<a href="cgistats.cgi"> Current run statistics </a>
<a href="mcapage.html">Most recent <br> MCA spectra</a>
<a href="/webops/webopsindex.html"> Web interface </a>
<div class="fixed_bot">
<h2>Help</h2>
<i><p>This page displays the PSA spectra saved to file psa2D.csv by startdaq, acquire, etc. </p>
<p>Hover over plot to see plot options </p>
<p>Use browser button to refresh </p></i>
</div>
</div>
<div class="main">
<div class="w3-card-2">
<h2> Channel 0 </h2>
<div id="Ch0" style="width:520px; height:400px;"></div>
<p style="color:#9e662e;"> Threshold for n/g separation:
<input id='PSA_TH0' type='text' value = 80> </input> </p>
<p style="color:#334d99;"> Emin for projection of PSA value:
<input id='Emin0' type='text' value = 0> </input> </p>
<p> Total <span id = "allgamma0"> 0 </span> gammas and <span id = "allneutron0"> 0 </span> neutrons </p>
</div>
<div class="w3-card-2">
<h2> Channel 1 </h2>
<div id="Ch1" style="width:520px; height:400px;"></div>
<p style="color:#9e662e;"> Threshold for n/g separation:
<input id='PSA_TH1' type='text' value = 80> </input> </p>
<p style="color:#334d99;"> Emin for projection of PSA value:
<input id='Emin1' type='text' value = 0> </input> </p>
<p> Total <span id = "allgamma1"> 0 </span> gammas and <span id = "allneutron1"> 0 </span> neutrons </p>
</div>
<div class="w3-card-2">
<h2> Channel 2 </h2>
<div id="Ch2" style="width:520px; height:400px;"></div>
<p style="color:#9e662e;"> Threshold for n/g separation:
<input id='PSA_TH2' type='text' value = 80> </input> </p>
<p style="color:#334d99;"> Emin for projection of PSA value:
<input id='Emin2' type='text' value = 0> </input> </p>
<p> Total <span id = "allgamma2"> 0 </span> gammas and <span id = "allneutron2"> 0 </span> neutrons </p>
</div>
<div class="w3-card-2">
<h2> Channel 3 </h2>
<div id="Ch3" style="width:520px; height:400px;"></div>
<p style="color:#9e662e;"> Threshold for n/g separation:
<input id='PSA_TH3' type='text' value = 80> </input> </p>
<p style="color:#334d99;"> Emin for projection of PSA value:
<input id='Emin3' type='text' value = 0> </input> </p>
<p> Total <span id = "allgamma3"> 0 </span> gammas and <span id = "allneutron3"> 0 </span> neutrons </p>
</div>
</div>
</div>
<script>
// define global constants
var Nbins=100;
Plotly.d3.csv('psa2D.csv', function(err, rows){
// "Plotly.d3.csv" must be a function defined in plotly
// reading the csv file and executing a function on the data loaded into rows
function unpack(rows, key) {
return rows.map(function(row) { return row[key]; });
}
// defines the unpack function
// where .map creates a new array with the result of calling a function for each array element
// here extracting the key'th element of a row
// user input
var PSATH0 = document.getElementById('PSA_TH0').value;
var EMIN0 = document.getElementById('Emin0').value;
var PSATH1 = document.getElementById('PSA_TH1').value;
var EMIN1 = document.getElementById('Emin1').value;
var PSATH2 = document.getElementById('PSA_TH2').value;
var EMIN2 = document.getElementById('Emin2').value;
var PSATH3 = document.getElementById('PSA_TH3').value;
var EMIN3 = document.getElementById('Emin3').value;
// define the color scheme
var psacolor = [
['0.000', 'rgb(245,245,245)'],
['0.002', 'rgb(255,100,100)'],
['0.010', 'rgb(255, 0, 0)'],
['0.020', 'rgb(255, 64, 0)'],
['0.030', 'rgb(255,128, 0)'],
['0.040', 'rgb(255,191, 0)'],
['0.050', 'rgb(255,255, 0)'],
['0.075', 'rgb(191,255, 0)'],
['0.100', 'rgb(128,255, 0)'],
['0.130', 'rgb( 64,255, 0)'],
['0.160', 'rgb( 0,255, 0)'],
['0.200', 'rgb( 0,255, 64)'],
['0.250', 'rgb( 0,255,128)'],
['0.300', 'rgb( 0,255,191)'],
['0.360', 'rgb( 0,191,255)'],
['0.420', 'rgb( 0,128,255)'],
['0.480', 'rgb( 0, 64,255)'],
['0.540', 'rgb( 0, 0,255)'],
['0.700', 'rgb( 64, 0,255)'],
['0.750', 'rgb(128, 0,255)'],
['0.850', 'rgb(191, 0,255)'],
['0.980', 'rgb(255, 0,255)'],
['1.000', 'rgb( 0, 0, 0)'],
];
// ------------- extract the data --------------------
// ------------------------
var sum_data0 = [ ];
var sum_upper0 = [ ];
var z_data0=[ ] ;
for(i=0;i< Nbins;i++)
{
var m = i;
z_data0.push(unpack(rows,i));
sum_data0[m] = 0;
for(k=EMIN0;k< Nbins;k++)
{
sum_data0[m] = sum_data0[m] + Number(z_data0[m][k]);
}
}
var psaproj0 = sum_data0.map(String); // convert back to string array [1D projection]
var psathline0 = [ ];
var eminline0 = [ ];
for(k=0;k< Nbins;k++)
{
sum_data0[k] = 0 ;
sum_upper0[k] = 0;
psathline0[k] = PSATH0;
eminline0[k] = EMIN0 ;
}
var gtotal0 = 0 ;
var ntotal0 = 0;
for(k=EMIN0;k< Nbins;k++)
{
for(i=PSATH0;i<Nbins;i++)
{
sum_upper0[k] = sum_upper0[k] + Number(z_data0[i][k]);
}
for(i=0;i<PSATH0;i++)
{
sum_data0[k] = sum_data0[k] + Number(z_data0[i][k]);
}
ntotal0 = ntotal0 + sum_upper0[k];
gtotal0 = gtotal0 + sum_data0[k] ;
}
var eproj0 = sum_data0.map(String); // convert back to string array [1D projection]
var eprojup0 = sum_upper0.map(String) ;
document.getElementById("allneutron0").innerHTML = ntotal0;
document.getElementById("allgamma0").innerHTML = gtotal0;
// ------------------------
var sum_data1 = [ ];
var sum_upper1 = [ ];
var z_data1=[ ] ;
for(i=Nbins;i< Nbins*2;i++)
{
var m = i-Nbins;
z_data1.push(unpack(rows,i));
sum_data1[m] = 0;
for(k=EMIN1;k< Nbins;k++)
{
sum_data1[m] = sum_data1[m] + Number(z_data1[m][k]);
}
}
var psaproj1 = sum_data1.map(String); // convert back to string array [1D projection]
var psathline1 = [ ];
var eminline1 = [ ];
for(k=0;k< Nbins;k++)
{
sum_data1[k] = 0 ;
sum_upper1[k] = 0;
psathline1[k] = PSATH1;
eminline1[k] = EMIN1 ;
}
var gtotal1 = 0 ;
var ntotal1 = 0;
for(k=EMIN1;k< Nbins;k++)
{
for(i=PSATH1;i<Nbins;i++)
{
sum_upper1[k] = sum_upper1[k] + Number(z_data1[i][k]);
}
for(i=0;i<PSATH1;i++)
{
sum_data1[k] = sum_data1[k] + Number(z_data1[i][k]);
}
ntotal1 = ntotal1 + sum_upper1[k];
gtotal1 = gtotal1 + sum_data1[k] ;
}
var eproj1 = sum_data1.map(String); // convert back to string array [1D projection]
var eprojup1 = sum_upper1.map(String) ;
document.getElementById("allneutron1").innerHTML = ntotal1;
document.getElementById("allgamma1").innerHTML = gtotal1;
// -----------------------------------
var sum_data2 = [ ];
var sum_upper2 = [ ];
var z_data2=[ ] ;
for(i=Nbins*2;i< Nbins*3;i++)
{
var m = i-Nbins*2;
z_data2.push(unpack(rows,i));
sum_data2[m] = 0;
for(k=EMIN2;k< Nbins;k++)
{
sum_data2[m] = sum_data2[m] + Number(z_data2[m][k]);
}
}
var psaproj2 = sum_data2.map(String); // convert back to string array [1D projection]
var psathline2 = [ ];
var eminline2 = [ ];
for(k=0;k< Nbins;k++)
{
sum_data2[k] = 0 ;
sum_upper2[k] = 0;
psathline2[k] = PSATH2;
eminline2[k] = EMIN2 ;
}
var gtotal2 = 0 ;
var ntotal2 = 0;
for(k=EMIN2;k< Nbins;k++)
{
for(i=PSATH2;i<Nbins;i++)
{
sum_upper2[k] = sum_upper2[k] + Number(z_data2[i][k]);
}
for(i=0;i<PSATH2;i++)
{
sum_data2[k] = sum_data2[k] + Number(z_data2[i][k]);
}
ntotal2 = ntotal2 + sum_upper2[k];
gtotal2 = gtotal2 + sum_data2[k] ;
}
var eproj2 = sum_data2.map(String); // convert back to string array [1D projection]
var eprojup2 = sum_upper2.map(String) ;
document.getElementById("allneutron2").innerHTML = ntotal2;
document.getElementById("allgamma2").innerHTML = gtotal2;
// -----------------------------------
var sum_data3 = [ ];
var sum_upper3 = [ ];
var z_data3=[ ] ;
for(i=Nbins*3;i< Nbins*4;i++)
{
var m = i-Nbins*3;
z_data3.push(unpack(rows,i));
sum_data3[m] = 0;
for(k=EMIN2;k< Nbins;k++)
{
sum_data3[m] = sum_data3[m] + Number(z_data3[m][k]);
}
}
var psaproj3 = sum_data3.map(String); // convert back to string array [1D projection]
var psathline3 = [ ];
var eminline3 = [ ];
for(k=0;k< Nbins;k++)
{
sum_data3[k] = 0 ;
sum_upper3[k] = 0;
psathline3[k] = PSATH3;
eminline3[k] = EMIN3 ;
}
var gtotal3 = 0 ;
var ntotal3 = 0;
for(k=EMIN3;k< Nbins;k++)
{
for(i=PSATH3;i<Nbins;i++)
{
sum_upper3[k] = sum_upper3[k] + Number(z_data3[i][k]);
}
for(i=0;i<PSATH3;i++)
{
sum_data3[k] = sum_data3[k] + Number(z_data3[i][k]);
}
ntotal3 = ntotal3 + sum_upper3[k];
gtotal3 = gtotal3 + sum_data3[k] ;
}
var eproj3 = sum_data3.map(String); // convert back to string array [1D projection]
var eprojup3 = sum_upper3.map(String) ;
document.getElementById("allneutron3").innerHTML = ntotal3;
document.getElementById("allgamma3").innerHTML = gtotal3;
// ------------- assemble plot traces --------------
var psatrace0 = {
x: psaproj0,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(0, 0, 0)',},
type: 'scatter',
showlegend: false,
xaxis: 'x2'
};
var psathtrace0 = {
y: psathline0,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(158, 102, 46)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var etrace0 = {
y: eproj0,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)',},
type: 'scatter',
showlegend: false,
yaxis: 'y2'
};
var etraceup0 = {
y: eprojup0,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y3'
};
var emintrace0 = {
x: eminline0,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(51, 77, 153)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var hm0 = {
z: z_data0,
xaxis: 'x',
yaxis: 'y',
type: 'heatmap',
colorscale: psacolor
};
var data0 = [hm0, psatrace0,etrace0,etraceup0,psathtrace0,emintrace0];
// -----------------------------------
var psatrace1 = {
x: psaproj1,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
xaxis: 'x2'
};
var psathtrace1 = {
y: psathline1,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(158, 102, 46)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var etrace1 = {
y: eproj1,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y2'
};
var etraceup1 = {
y: eprojup1,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y3'
};
var emintrace1 = {
x: eminline1,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(51, 77, 153)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var hm1 = {
z: z_data1,
xaxis: 'x',
yaxis: 'y',
type: 'heatmap',
colorscale: psacolor
};
var data1 = [hm1, psatrace1,etrace1,etraceup1,psathtrace1,emintrace1];
// -----------------------------------
var psatrace2 = {
x: psaproj2,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
xaxis: 'x2'
};
var psathtrace2 = {
y: psathline2,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(158, 102, 46)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var etrace2 = {
y: eproj2,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y2'
};
var etraceup2 = {
y: eprojup2,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y3'
};
var emintrace2 = {
x: eminline2,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(51, 77, 153)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var hm2 = {
z: z_data2,
xaxis: 'x',
yaxis: 'y',
type: 'heatmap',
colorscale: psacolor
};
var data2 = [hm2, psatrace2,etrace2,etraceup2,psathtrace2,emintrace2];
// -----------------------------------
var psatrace3 = {
x: psaproj3,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
xaxis: 'x2'
};
var psathtrace3 = {
y: psathline3,
mode: 'lines',
line: {shape: 'vhv', color: 'rgb(158, 102, 46)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var etrace3 = {
y: eproj3,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y2'
};
var etraceup3 = {
y: eprojup3,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(0, 0, 0)'},
type: 'scatter',
showlegend: false,
yaxis: 'y3'
};
var emintrace3 = {
x: eminline3,
mode: 'lines',
line: {shape: 'hvh', color: 'rgb(51, 77, 153)', dash: 'dot'},
type: 'scatter',
hoverinfo: 'skip',
showlegend: false
};
var hm3 = {
z: z_data3,
xaxis: 'x',
yaxis: 'y',
type: 'heatmap',
colorscale: psacolor
};
var data3 = [hm3, psatrace3,etrace3,etraceup3,psathtrace3,emintrace3];
// ------------------- plot it ------------------------
var layout = {
xaxis: { showgrid: false, zeroline: false,title: 'Energy', domain: [0.0, 0.85]},
yaxis: { showgrid: false, zeroline: false,title: 'PSA value', domain: [0.00, 0.70] },
xaxis2: { showgrid: false, zeroline: false, domain: [0.85, 1.00], tickangle: 90 },
yaxis2: { showgrid: false, zeroline: false,title: 'gamma', titlefont:{size: '9'}, domain: [0.70, 0.85] },
yaxis3: { showgrid: false, zeroline: false,title: 'neutron', titlefont:{size: '9'}, domain: [0.85, 1.00] },
margin: {t: 20, l: 50},
autosize: true
};
Plotly.newPlot('Ch0', data0, layout);
Plotly.newPlot('Ch1', data1, layout);
Plotly.newPlot('Ch2', data2, layout);
Plotly.newPlot('Ch3', data3, layout);
});
</script>
</body>
</html>