Subversion Repositories f9daq

Rev

Rev 349 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
344 f9daq 1
var funMatrix = [[0, 0, 0, 0],
2
                [0, 0, 0, 0],
3
                [0, 0, 0, 0],
4
                [0, 0, 0, 0],
350 f9daq 5
                [0, 0, 0, 0],
6
                [0, 0, 0, 0],
7
                [0, 0, 0, 0],
8
                [0, 0, 0, 0],
9
                [0, 0, 0, 0],
344 f9daq 10
                [0, 0, 0, 0]]
11
 
12
function initSliders(sframe){
13
  genFunList(sframe);
14
  var obj = JSROOT.GetMainPainter(sframe).draw_object; //get the histogram
15
 
16
  //Initialise all ParameterSliders
17
  $( function() {
18
    $(".ParamSlider"+sframe).each(function() {
19
      var ID = String('#'+this.id);
20
      var n = ID.length;
21
      var paramName = ID.slice(6,n-5);
22
      switch (paramName) {
23
        case 'Amplitude':
24
          var min = 0;
25
          var max = 10000;
26
          var value = 100;
27
          break;
28
 
29
        case 'Mu':
30
          var min = 0;
31
          var max = 1;
32
          var value = 0;
33
          break;
34
 
35
        case 'Sigma':
36
          var min = 0;
37
          var max = 1;
38
          var value = 0.05;
39
          break;
40
 
41
        case 'AmpBW':
42
          var min = 0;
43
          var max = 100;
44
          var value = 1000;
45
          break;
46
 
47
        case 'Gamma':
48
          var min = 0;
49
          var max = 1;
50
          var value = 0.5;
51
          break;
52
 
53
        case 'M':
54
          var min = 0;
55
          var max = 5;
56
          var value = 0;
57
          break;
58
 
59
        default:
60
          var min = -10;
61
          var max = 10;
62
          var value = 0;
63
          break;
64
      }
65
 
66
      $(this).slider({
67
        range: false, min: min, max: max, value:value, step: 0.0001,    
68
        slide: function( event, ui ) {
69
          $( ID.slice(0,n-5)+sframe ).val(ui.value);
70
          calculate(sframe);
71
        },
72
        change: function( event, ui ){
73
          $( ID.slice(0,n-5)+sframe ).val(ui.value);
74
          calculate(sframe);
75
        }
76
      });
77
      setDefaultParameters(paramName, sframe);
78
    })
79
  })
80
  //Script for initialising range sliders
81
  $( function() {
82
    $( "#slider-range"+sframe ).slider({
83
      range: true,
84
      min: obj.fXaxis.fXmin,
85
      max: obj.fXaxis.fXmax,
86
      step: (obj.fXaxis.fXmax-obj.fXaxis.fXmin)/1000,
87
      values: [ obj.fXaxis.fXmin, obj.fXaxis.fXmax ],
88
      slide: function( event, ui ) {
89
        document.getElementById("minRange"+sframe).value = ui.values[0];
90
        document.getElementById("maxRange"+sframe).value = ui.values[1];
91
        calculate(sframe);
92
      }
93
    });
94
    $("#minRange"+sframe).val($( "#slider-range"+sframe ).slider( "values", 0));
95
    $("#maxRange"+sframe).val($( "#slider-range"+sframe ).slider( "values", 1));
96
  });
97
 
98
  //Script for choosing polynomial order
99
  $( function() {
100
    $( "#slider-polOrder"+sframe ).slider({
101
      range: false,
102
      min: 0,
103
      max: 4,
104
      step: 1,
105
      value: 1,
106
      slide: function( event, ui ) {
107
        $( "#polOrderDisplay" + sframe ).val(ui.value);
108
        updatePolParamList(ui.value, sframe);
345 f9daq 109
        var fName = genFunctionName(sframe);
110
        showFormula(fName, sframe);
344 f9daq 111
        calculate(sframe);
112
      }
113
    });
114
    $( "#polOrderDisplay" + sframe ).val( $("#slider-polOrder"+sframe).slider("value") );
115
    updatePolParamList($("#slider-polOrder"+sframe).slider("value"), sframe);
116
  });
117
}
118
 
119
function autoFit(sframe){
120
  //works only if histogram is on canvas
121
  //document.getElementById('status').style.display='block';
122
  var xmin = parseFloat(document.getElementById("minRange"+sframe).value);
123
  var xmax = parseFloat(document.getElementById("maxRange"+sframe).value);
124
 
125
  //var initParam = getManualParameters();//unused
126
  var data = getDataFromHisto(sframe);
127
  var N = data.length;
128
 
129
  var x = [], y = []; //data points
130
  var NdataPoints = 0;
131
  for(var i=0; i<N; ++i){
132
    if( (data[i][0] > xmin) && (data[i][0] < xmax)){
133
      x.push(data[i][0]);
134
      y.push(data[i][1]);
135
      if(data[i][1]>0){NdataPoints++;}
136
    }
137
  }
138
  var p0 = getManualParameters(sframe);
139
  var maskParam = getParametersMask(sframe); //use only these parameters, all others are fixed or un used
140
  var maskParamRange = getParamRangeMask(sframe);
141
  var result = fminsearch(calcMasterFun2, p0, x, y, {maxIter:100, mask:maskParam, maskBond:maskParamRange, sframe:sframe});
142
  var Parm0 = result[0];
143
  var chi2 = result[1];
144
  setManualParameters(Parm0, maskParam, sframe); // set parameters' values
145
  var obj = JSROOT.GetMainPainter(sframe).draw_object;
146
 
147
  funkcija = CreateTF1Fit(Parm0, sframe);
148
  funkcija.fChisquare = chi2;
149
  funkcija.fNDF = NdataPoints-getNparameters(sframe); //calculate ndf
150
  StoreAndDrawFitFunction(obj, funkcija, [xmin, xmax], 1, sframe);
151
}
152
 
153
function getParamRangeMask(sframe){
154
  //return mask to bond parameters inside of range
155
  var varList = ['Amplitude', 'Mu', 'Sigma', 'A0', 'A1', 'A2', 'A3', 'A4', 'AmpExp', 'K', 'AmpBW', 'Gamma', 'M'];
156
  var x = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
157
  var ranges = [];
158
  for(var i=0; i<varList.length; i++){
159
    //find fixed values and mask them
160
    if(document.getElementById('bond'+varList[i] + sframe).checked){
161
      x[i]=1;
162
      ranges.push([parseFloat(document.getElementById('Param'+varList[i]+'min'+sframe).value), parseFloat(document.getElementById('Param'+varList[i]+'max'+sframe).value)]);
163
    }else{
164
      ranges.push([0, 0]);
165
    }
166
  }
167
  return [x, ranges]
168
}
169
 
170
function calculate(h){
171
  //var x = parseFloat(document.getElementById("xValue").value);
172
  var N = 501; // number of points for function ploting
173
  //var funfit = document.getElementById("fitfun").value;
174
 
175
  var xmin = parseFloat(document.getElementById("minRange"+h).value);
176
  var xmax = parseFloat(document.getElementById("maxRange"+h).value);
177
 
178
  var parameters = [];
179
  parameters = getManualParameters(h);
180
 
181
  fitMasterFun(xmin, xmax, N, parameters, h);
182
}
183
 
184
function getManualParameters(sframe){
185
  var parametri = [];
186
  var mu = parseFloat(document.getElementById("ParamMu"+sframe).value);
187
  var sigma = parseFloat(document.getElementById("ParamSigma"+sframe).value);
188
  var amplitude = parseFloat(document.getElementById("ParamAmplitude"+sframe).value);
189
  parametri = [amplitude, mu, sigma];
190
 
191
  var n = document.getElementById("polOrderDisplay" + sframe).value;
192
  for(var i=0; i<5; ++i){
193
    if(i<=n){
194
      parametri.push(parseFloat(document.getElementById("ParamA"+i+sframe).value));
195
    }else{
196
      parametri.push(0); //set higher orders to 0
197
    }
198
  }
199
 
200
  parametri.push(parseFloat(document.getElementById("ParamAmpExp"+sframe).value));
201
  parametri.push(parseFloat(document.getElementById("ParamK"+sframe).value));
202
 
203
  parametri.push(parseFloat(document.getElementById("ParamAmpBW"+sframe).value));
204
  parametri.push(parseFloat(document.getElementById("ParamGamma"+sframe).value));
205
  parametri.push(parseFloat(document.getElementById("ParamM"+sframe).value));
206
 
207
  return parametri
208
}
209
 
210
function setManualParameters(p, mask, sframe){
211
  //sets the value of parameters and correct max or min value if p greater or smaller
212
 
213
  var paramNames = ["Amplitude", "Mu", "Sigma", "A0", "A1", "A2", "A3", "A4", "AmpExp", "K", 'AmpBW', 'Gamma', 'M'];
214
 
215
  for(var i = 0; i<paramNames.length; i++){
216
    if(mask[i]){
217
      document.getElementById("Param"+paramNames[i]+sframe).value = p[i];
218
 
219
      var max = $("#Param"+paramNames[i]+"Set"+sframe).slider("option", "max");
220
      var min = $("#Param"+paramNames[i]+"Set"+sframe).slider("option", "min");
221
 
222
      if(p[i] > max){
223
        $("#Param"+paramNames[i]+"Set"+sframe).slider("option", "max", p[i]);
224
        document.getElementById("Param"+paramNames[i]+"max"+sframe).value = p[i];
225
 
226
      };
227
      if(p[i] < min){
228
        $("#Param"+paramNames[i]+"Set"+sframe).slider("option", "min", p[i]);
229
        document.getElementById("Param"+paramNames[i]+"min"+sframe).value = p[i];
230
 
231
      }
232
 
233
      $("#Param"+paramNames[i]+"Set"+sframe).slider("value", p[i]);
234
    }
235
  }
236
}
237
 
238
function fitMasterFun(xmin, xmax, N, parametri, sframe){
239
  var x = [];
240
  var y = [];
241
 
242
  for(var i = 0; i<N; i++){
243
    x.push((xmax-xmin)*i/N+xmin);
244
    y.push(calcMasterFun(x[i], parametri, sframe));
245
  }
246
 
247
  var data = getDataFromHisto(sframe);
248
  var sum = 0;
249
  var NdataPoints = 0;
250
 
251
  for(var i=0; i<data.length; ++i){
252
    //calculate sum of residuals
253
    if( (data[i][0] > xmin) && (data[i][0] < xmax) && (data[i][1] != 0)){
254
      var yfit = calcMasterFun(data[i][0], parametri, sframe);
255
      var ydata = data[i][1];
256
      sum += Math.pow(ydata-yfit, 2) / ydata;
257
      NdataPoints++;
258
    }
259
  }
260
 
261
  var chi2 = sum.toPrecision(4);
262
  //display chi^2
263
  document.getElementById("chi2Output"+sframe).innerHTML = chi2;
264
 
265
  //calculate ndf
266
  var ndf = NdataPoints;
267
  var Nparameters = getNparameters(sframe);
268
  ndf -= Nparameters;
269
 
270
  document.getElementById("ndfOutput"+sframe).innerHTML = ndf;
271
  document.getElementById("chi2Red"+sframe).innerHTML = (chi2/ndf).toPrecision(4);
272
 
273
  var g = JSROOT.CreateTGraph(N, x, y);
274
  var isTGraphOn = JSROOT.GetMainPainter(sframe).draw_object.fTGraphPlotted;
275
  if (typeof isTGraphOn === "undefined") {
276
    //TGraph does not exist yet
277
    var a = JSROOT.GetMainPainter(sframe).draw_object;
278
    a.fTGraphPlotted = 0;
279
    JSROOT.draw(sframe, g, "", function(){
280
      var obj = JSROOT.GetMainPainter(sframe).draw_object;
281
      obj.fTGraphPlotted = 1;
282
      });
283
  } else {
284
    //replot only if TGraph is already plotted, else: it is plotting
285
    if(isTGraphOn==1){JSROOT.redraw(sframe, g, "");}
286
  }
287
 
288
}
289
 
290
function getNparameters(sframe){
291
  var x = 0;
292
  var funList = getFunList(sframe);
293
  if(funList[0]==1){
294
    //Gaus has 3 parameters
295
    x += 3;
296
  }
297
 
298
  if(funList[1]){
299
    //Substract (polynomial order + 1)
300
    x += parseInt(document.getElementById("polOrderDisplay" + sframe).value)+1;
301
  }
302
 
303
  if(funList[2]){
304
    //Exponential function has 2 parameters
305
    x += 2;
306
  }
307
  return x
308
}
309
 
310
function getParametersMask(sframe){
311
  //return mask to fix parameters
312
  var x = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
313
  var varList = ['Amplitude', 'Mu', 'Sigma', 'A0', 'A1', 'A2', 'A3', 'A4', 'AmpExp', 'K', 'AmpBW', 'Gamma', 'M'];
314
  var i;
315
  var funList = getFunList(sframe);
316
  if(funList[0]==1){
317
    //Gaus has 3 parameters
318
    for(i = 0; i < 3; i++){
319
      x[i] = 1;
320
    }
321
  }
322
  i = 3;
323
  if(funList[1]){
324
    //Substract (polynomial order + 1)
325
    var order = parseInt(document.getElementById("polOrderDisplay" + sframe).value);
326
    for(var j=0; j < order+1; j++){
327
      x[i] = 1;
328
      i++;
329
    }
330
  }
331
 
332
  if(funList[2]){
333
    //Exponential function has 2 parameters
334
    x[8] = 1;
335
    x[9] = 1;
336
  }
337
 
338
  if(funList[3]){
339
    //BW function has 3 parameters
340
    x[10] = 1;
341
    x[11] = 1;
342
    x[12] = 1;
343
  }
344
 
345
  for(var i=0; i<varList.length; i++){
346
    //find fixed values and mask them
347
    if(document.getElementById('fix'+varList[i]+sframe).checked){
348
      x[i]=0;
349
    }
350
  }
351
  return x
352
}
353
 
354
function getDataFromHisto(divid){
355
  //get x and y from ploted histogram, and compute y_fit for ploted x and calculate chi^2
356
  var obj = JSROOT.GetMainPainter(divid).draw_object;
357
  var N = obj.fNcells;
358
  var x = [];
359
  var y = [];
360
  var data = [];
361
  for(var i=1; i<=N-2; ++i){
362
    data.push([obj.fXaxis.GetBinCenter(i), obj.fArray[i]]);
363
  }
364
 
365
  return data
366
}
367
 
368
function calcMasterFun(x, parametri, sframe){
369
  //calculates function gaus + pol + exp
370
  parametriGaus = [parametri[0], parametri[1], parametri[2]];
371
  parametriPol = [parametri[3], parametri[4], parametri[5], parametri[6], parametri[7]];
372
  parametriExp = [parametri[8], parametri[9]];
373
  parametriBW = [parametri[10], parametri[11], parametri[12]];
374
  var funList = getFunList(sframe);
375
  return funList[0]*gaus(x, parametriGaus) + funList[1]*pol(x, parametriPol) + funList[2]*expo(x, parametriExp) + funList[3]*BW(x, parametriBW);
376
}
377
 
378
function calcMasterFun2(x, parametri, sframe){
379
  //calculates function gaus + pol + exp, x must be vector
380
  return x.map(function(xi){return (calcMasterFun(xi, parametri, sframe))});
381
}
382
 
383
function pol(x, p){
384
  var n = p.length;
385
  if(n > 5){
386
    alert("Only pol5 is implemented");
387
    return "Error"
388
  } else {
389
    for(var i = n; i<5; i++){
390
      p[i] = 0;
391
    }
392
    return p[0] + x * p[1] + x**2 * p[2] + x**3 * p[3] + x**4 * p[4];
393
  }
394
}
395
 
396
function gaus(x, p){
397
  var amplitude = p[0]
398
  var mu = p[1];
399
  var sigma = p[2];
400
 
401
  return amplitude * Math.exp(-0.5 * Math.pow((x-mu) / sigma, 2));
402
}      
403
 
404
function expo(x, p){
405
  var a = p[0];
406
  var k = p[1];
407
  return a * Math.exp(k * x);
408
}
409
 
410
function BW(x, p){
411
  var a = p[0];
412
  var gamma = p[1];
413
  var M = p[2];
414
  return a / (2 * Math.PI) * gamma / (Math.pow(x-M, 2) + Math.pow(gamma/2, 2));
415
}
416
 
417
function divClean(divid){
418
  JSROOT.cleanup(divid);
419
}
420
 
421
function getFunList(sframe){
422
  //returns funList from funMatrix
423
  var k = parseInt(sframe.slice(1)); //get histogram number 0, 1, 2, ...
424
  return funMatrix[k]
425
}
426
 
427
function genFunList(sframe){
428
  //sframe - string name: h0, h1, ...
429
  //actualy does not show, but only creates funList, funList should go in TH1.funList?
430
  var funfit = document.getElementById("selectFitFun"+sframe).value;
431
  var funfit2 = funfit.split(/[ +]/);
432
  var implementedFun = ["gaus", "pol", "expo", "BW"] //
433
  var funList = getFunList(sframe);
434
  var k = parseInt(sframe.slice(1)); //get histogram number 0, 1, 2, ...
435
 
436
  for (var i = 0; i < implementedFun.length; i++) {
437
    if (funfit2.includes(implementedFun[i])) {
438
      funList[i] = 1;
439
      funMatrix[k][i] = 1;
440
      document.getElementById(implementedFun[i]+"FitPanel"+sframe).style.display = "block";
441
    } else {
442
      funList[i] = 0;
443
      funMatrix[k][i] = 0;
444
      document.getElementById(implementedFun[i]+"FitPanel"+sframe).style.display = "none";
445
    }
446
  }
447
 
345 f9daq 448
  var fName = genFunctionName(sframe);
344 f9daq 449
  showFormula(fName, sframe);
450
  if((funMatrix[k][0]+funMatrix[k][1]+funMatrix[k][2]+funMatrix[k][3]) == 0){ alert("These are implemented functions:\n" + implementedFun.toString()) } //
451
}
452
 
453
function genFunctionName(sframe){
454
  var funList = getFunList(sframe);
455
  var fName = "";
456
  var Npar = 0;
457
  if(funList[0]){
458
    //Gaus function
459
    fName =  "N \\cdot e^{-(\\frac{x-\\mu}{2 \\sigma})^2}";
460
    Npar += 3;
461
  }
462
 
463
  if(funList[1]){
464
    //pol function
465
    var n = parseInt(document.getElementById("polOrderDisplay"+sframe).value);
466
 
467
    for(var i=0; i<=n; ++i){
468
      if((i>0) || (Npar > 0)){
469
        fName += " + ";
470
      }
471
 
472
      if(i==0){
473
        fName += "p" + String(i);
474
      }else{
475
        if(i==1){
476
          fName += "p" + String(i) + " \\cdot x";
477
        }else{
478
          fName += "p" + String(i) + " \\cdot x^" + String(i);
479
        }
480
      }
481
    }
482
    Npar += n+1;
483
  }
484
 
485
  if(funList[2]){
486
    if((Npar > 0)){
487
      fName += " + ";
488
    }
489
    fName += "N_{exp} \\cdot e^{K \\cdot x}";
490
    Npar += 2;
491
  }
492
 
493
  if(funList[3]){
494
    if((Npar > 0)){
495
      fName += " + ";
496
    }
347 f9daq 497
    fName += "N_{BW} \\cdot  \\frac{1}{2 \\pi} \\frac{\\Gamma}{(x - M_{BW})^2 + (\\Gamma/2)^2} "; // * [Gamma] / ((x - [MeanBW])^2 + ([Gamma]/2)^2)
344 f9daq 498
 
499
    Npar += 3;
500
  }
501
  return fName;
502
}
503
 
504
function updatePolParamList(n, sframe){
505
  //disables or enables inputs in table for diferent parameters
506
  if(n>=0){
507
    disableInput(false, "listA0"+sframe, sframe);
508
  }else{
509
    disableInput(true, "listA0"+sframe, sframe);
510
  }
511
 
512
  if(n>=1){
513
    disableInput(false, "listA1"+sframe, sframe);
514
  }else{
515
    disableInput(true, "listA1"+sframe, sframe);
516
  }
517
 
518
  if(n>=2){
519
    disableInput(false, "listA2"+sframe, sframe);
520
  }else{
521
    disableInput(true, "listA2"+sframe, sframe);
522
  }
523
 
524
  if(n>=3){
525
    disableInput(false, "listA3"+sframe, sframe);
526
  }else{
527
    disableInput(true, "listA3"+sframe, sframe);
528
  }
529
 
530
  if(n>=4){
531
    disableInput(false, "listA4"+sframe, sframe);
532
  }else{
533
    disableInput(true, "listA4"+sframe, sframe);
534
  }
535
 
536
  if(n>4){
537
    alert("Only pol4 is inplemented!");
538
  }else{
539
    if(n<0){alert("Error, wrong number " + n);}
540
  }
541
}
542
 
543
function disableInput(state, objId, sframe){
544
  //Change disabled state of parameters inputs
545
  disableParamSlider(state, objId, sframe);
546
  var obj = document.getElementById(objId).getElementsByTagName("input");//find inputs inside of row
547
  for (var i = 0; i < obj.length; i++) {
548
    obj[i].disabled = state; //set state of inputs
549
  }
550
}
551
 
552
function disableParamSlider(state, objId, sframe){
553
  //Disables slider if state is true and enables if state is false.
554
  var name = String(objId[objId.length-2])+ String(objId[objId.length-1]);
555
  switch (state) {
556
    case true:
557
      $("#Param"+name+"Set"+sframe).slider("disable");
558
      break;
559
 
560
    case false:
561
      $("#Param"+name+"Set"+sframe).slider("enable");
562
      break;
563
 
564
    default:
565
      break;
566
  }
567
}
568
 
569
 
570
function setDefaultParameters(name, sframe){
571
  //this function is used for setting parameters back to their default value after page refresh
572
  $( "#Param"+name+sframe).val( $("#Param"+name+"Set"+sframe).slider("value") );
573
  $( "#Param"+name+"min"+sframe ).val( $("#Param"+name+"Set"+sframe).slider("option", "min") );
574
  $( "#Param"+name+"max"+sframe ).val( $("#Param"+name+"Set"+sframe).slider("option", "max") );
575
  $( "#Param"+name+"step"+sframe ).val( $("#Param"+name+"Set"+sframe).slider("option", "step") );
576
}
577
 
578
function updateSetSlider(id){
579
  //Get id to update its slider ?min? value
580
  var sframe = id.id.slice(id.id.length-2);
581
  var last = id.id[id.id.length-3]; //it can be steP, maX or miN
582
  switch (last) {
583
    case "p":
584
      $("#Param"+id.name+"Set"+sframe).slider("option", "step", parseFloat(id.value));
585
      break;
586
 
587
    case "x":
588
      $("#Param"+id.name+"Set"+sframe).slider("option", "max", parseFloat(id.value));
589
      break;
590
 
591
    case "n":
592
      $("#Param"+id.name+"Set"+sframe).slider("option", "min", parseFloat(id.value));
593
      break;
594
 
595
    default:
596
      if(id.value > $("#Param"+id.name+"Set"+sframe).slider("option", "max")){ alert("Inserted value is to big."); }
597
      if(id.value < $("#Param"+id.name+"Set"+sframe).slider("option", "min")){ alert("Inserted value is to small."); }
598
      $("#Param"+id.name+"Set"+sframe).slider("value", parseFloat(id.value));
599
      break;
600
  }
601
}
602
 
603
function insertHTML(sframe, callback){
604
  var r = document.getElementById('fit'+sframe);
605
  var htmlCode = generateHTMLcode(sframe);
606
  r.insertAdjacentHTML('beforeend', htmlCode);
607
  if(callback!=null){callback(sframe)}
608
}
609
 
610
function generateHTMLcode(sframe){
611
 
349 f9daq 612
  mform = '<button type="button" onclick="calculate('+ "'" + sframe + "'"+')" style="display:none" >Draw Function</button>';        
344 f9daq 613
  mform += '<button type="button" onclick="autoFit('+ "'" + sframe + "'"+')">Click to fit</button>';
614
  mform += '<div class="rangeSettings">';
615
  mform += 'Range: min = <input type="text" size="2" value="-5" name="min" id="minRange'+sframe+'" disabled=true>';
616
  mform += 'max = <input type="text" size="2" value="5" name="max" id="maxRange'+sframe+'" disabled=true>';
617
  mform += '<div style="display: inline-block;">';
618
  mform += '&nbsp; &chi;²/ndf = <output id="chi2Output'+ sframe +'"></output> / <output id="ndfOutput'+ sframe +'"></output> = <output id="chi2Red'+ sframe +'"></output> <br>';
619
  mform += '</div>';
620
  mform += '<div class="slidecontainer" style="width:600px">';
621
  mform += '<div class="slider-range" id="slider-range'+ sframe +'"></div>';
622
  mform += '</div>';
623
  mform += '</div>'
624
  mform += '        <div id="fitPanel">'
625
  mform += '          <div class="functionSelect">'
626
  mform += '            Function:'
627
  mform += '            <select  name="fitfun" id="selectFitFun'+sframe+'" onclick="genFunList(' + "'" + sframe + "'"+ ')">'
628
  mform += '              <option value="gaus">Gaus</option>'
629
  mform += '              <option value="pol">Poly</option>'
630
  mform += '              <option value="expo">Expo</option>'
631
  mform += '              <option value="BW">Breit-Wigner</option>'
347 f9daq 632
  mform += '              <option disabled="disabled">--------</option>'
344 f9daq 633
  mform += '              <option value="gaus+pol">Gaus + Poly</option>'
634
  mform += '              <option value="gaus+expo">Gaus + Expo</option>'
635
  mform += '              <option value="BW+gaus">Gaus + Breit-Wigner</option>'
636
  mform += '              <option value="pol+expo">Poly + Expo</option>'
637
  mform += '              <option value="BW+pol">Poly + Breit-Wigner</option>'
638
  mform += '              <option value="BW+expo">Expo + Breit-Wigner</option>'
347 f9daq 639
  mform += '              <option disabled="disabled">--------</option>'
344 f9daq 640
  mform += '              <option value="BW+expo+pol">Breit-Wigner + Poly + Expo</option>'
641
  mform += '              <option value="BW+gaus+pol">Breit-Wigner + Poly + Gaus</option>'
642
  mform += '              <option value="BW+expo+gaus">Breit-Wigner + Expo + Gaus</option>'
643
  mform += '              <option value="gaus+pol+expo">Gaus + Poly + Expo</option>'
644
  mform += '              <option value="BW+expo+gaus+pol">Breit-Wigner + Expo + Gaus + Poly</option>'
645
  mform += '            </select>'
347 f9daq 646
  mform += '            <span id="functionDisplay'+sframe+'" style="font-size:32px"></span>'
344 f9daq 647
  mform += '          </div>'
648
  mform += '          <!--'
649
  mform += '            This was replaced b select:option'
650
  mform += '            <input type="text" name="fitfun" id="fitfun" value="pol" onblur="genFunList()"><br>'
651
  mform += '          -->'
652
  mform += '          <div id="gausFitPanel' + sframe + '" class="FitPanel">'
653
  mform += '            <table class="inputParametersTable" id="inputParamTableGaus">'
654
  mform += '              <tbody>'
655
  mform += '                <tr class="description">'
656
  mform += '                  <td>Name</td>'
349 f9daq 657
  mform += '                  <td class="hideFix-Bond">Fix</td>'
658
  mform += '                  <td class="hideFix-Bond">Bond</td>'
344 f9daq 659
  mform += '                  <td>Value</td>'
660
  mform += '                  <td>Min</td>'
661
  mform += '                  <td>Set</td>'
662
  mform += '                  <td>Max</td>'
663
  mform += '                  <td>Step</td>'
664
  mform += '                </tr>'
665
  mform += '                <tr id="listMu">'
666
  mform += '                  <td><li>&mu;:</td>'
667
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixMu'+sframe+'"></td>'
668
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondMu'+sframe+'"></td>'
669
  mform += '                  <td><input type="text" class="inputParam" id="ParamMu'+sframe+'" name="Mu" value="0" onblur="updateSetSlider(this)"></td>'
670
  mform += '                  <td><input type="text" class="inputParam" id="ParamMumin'+sframe+'" name="Mu" onkeyup="updateSetSlider(this)"></td>'
671
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamMuSet'+sframe+'"></div></td>'
672
  mform += '                  <td><input type="text" class="inputParam" id="ParamMumax'+sframe+'" name="Mu" onkeyup="updateSetSlider(this)"></td>'
673
  mform += '                  <td><input type="text" class="inputParam" id="ParamMustep'+sframe+'" name="Mu" value="0.1" onkeyup="updateSetSlider(this)"></td>'
674
  mform += '                </tr>'
675
  mform += '                <tr id="listSigma">'
676
  mform += '                  <td><li>&sigma;:</td>'
677
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixSigma'+sframe+'"></td>'
678
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondSigma'+sframe+'"></td>'
679
  mform += '                  <td><input type="text" class="inputParam" id="ParamSigma'+sframe+'" name="Sigma" value="1" onblur="updateSetSlider(this)"></td>'
680
  mform += '                  <td><input type="text" class="inputParam" id="ParamSigmamin'+sframe+'" name="Sigma" onkeyup="updateSetSlider(this)"></td>'
681
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamSigmaSet'+sframe+'"></div></td>'
682
  mform += '                  <td><input type="text" class="inputParam" id="ParamSigmamax'+sframe+'" name="Sigma" onkeyup="updateSetSlider(this)"></td>'
683
  mform += '                  <td><input type="text" class="inputParam" id="ParamSigmastep'+sframe+'" name="Sigma" value="0.1" onkeyup="updateSetSlider(this)"></td>'
684
  mform += '                </tr>'
685
  mform += '                <tr id="listAmplitude">'
347 f9daq 686
  mform += '                  <td><li>N:</td>'
344 f9daq 687
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixAmplitude'+sframe+'"></td>'
688
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondAmplitude'+sframe+'"></td>'
689
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmplitude'+sframe+'" name="Amplitude" value="1" onblur="updateSetSlider(this)"></td>'
690
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmplitudemin'+sframe+'" name="Amplitude" onkeyup="updateSetSlider(this)"></td>'
691
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamAmplitudeSet'+sframe+'"></div></td>'
692
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmplitudemax'+sframe+'" name="Amplitude" onkeyup="updateSetSlider(this)"></td>'
693
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmplitudestep'+sframe+'" name="Amplitude" value="0.1" onkeyup="updateSetSlider(this)"></td>'
694
  mform += '                </tr>'
695
  mform += '              </tbody>'
696
  mform += '            </table>'
697
  mform += '          </div>'
698
 
699
  mform += '          <div id="polFitPanel' + sframe + '" class="FitPanel">'
700
  mform += '            Polynomial order: <input type="text" name="polOrder" id="polOrderDisplay' + sframe + '" size="1" disabled=true>'
701
  mform += '            <div style="width: 100px;display: inline-block;" id="slider-polOrder' + sframe + '"></div>'
702
  mform += '            <table class="inputParametersTable">'
703
  mform += '              <tbody>'
704
  mform += '                <tr class="description">'
705
  mform += '                  <td>Name</td>'
349 f9daq 706
  mform += '                  <td class="hideFix-Bond">Fix</td>'
707
  mform += '                  <td class="hideFix-Bond">Bond</td>'
344 f9daq 708
  mform += '                  <td>Value</td>'
709
  mform += '                  <td>Min</td>'
710
  mform += '                  <td>Set</td>'
711
  mform += '                  <td>Max</td>'
712
  mform += '                  <td>Step</td>'
713
  mform += '                </tr>'
714
  mform += '                <tr class="pol" id="listA0'+sframe+'">'
347 f9daq 715
  mform += '                  <td><li>p0:</td>'
344 f9daq 716
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixA0'+sframe+'"></td>'
717
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondA0'+sframe+'"></td>'
718
  mform += '                  <td><input type="text" class="inputParam" id="ParamA0'+sframe+'" name="A0" value="0" disabled=true onblur="updateSetSlider(this)"></td>'
719
  mform += '                  <td><input type="text" class="inputParam" id="ParamA0min'+sframe+'" name="A0" onkeyup="updateSetSlider(this)"></td>'
720
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamA0Set'+sframe+'"></div></td>'
721
  mform += '                  <td><input type="text" class="inputParam" id="ParamA0max'+sframe+'" name="A0" onkeyup="updateSetSlider(this)"></td>'
722
  mform += '                  <td><input type="text" class="inputParam" id="ParamA0step'+sframe+'" name="A0" value="0.1" onkeyup="updateSetSlider(this)"></td>'
723
  mform += '                </tr>'
724
  mform += '                <tr class="pol" id="listA1'+sframe+'">'
725
  mform += '                  <div id="rowA1">'
347 f9daq 726
  mform += '                    <td><li>p1:</td>'
344 f9daq 727
  mform += '                    <td><input type="checkbox" class="inputParamBox" id="fixA1'+sframe+'"></td>'
728
  mform += '                    <td><input type="checkbox" class="inputParamBox" id="bondA1'+sframe+'"></td>'
729
  mform += '                    <td><input type="text" class="inputParam" id="ParamA1'+sframe+'" name="A1" value="0" disabled=true onblur="updateSetSlider(this)"></td>'
730
  mform += '                    <td><input type="text" class="inputParam" id="ParamA1min'+sframe+'" name="A1" onkeyup="updateSetSlider(this)"></td>'
731
  mform += '                    <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamA1Set'+sframe+'"></div></td>'
732
  mform += '                    <td><input type="text" class="inputParam" id="ParamA1max'+sframe+'" name="A1" onkeyup="updateSetSlider(this)"></td>'
733
  mform += '                    <td><input type="text" class="inputParam" id="ParamA1step'+sframe+'" name="A1" value="0.1" onkeyup="updateSetSlider(this)"></td>'
734
  mform += '                  </div>'
735
  mform += '                </tr>'
736
  mform += '                <tr class="pol" id="listA2'+sframe+'">'
347 f9daq 737
  mform += '                  <td><li>p2:</td>'
344 f9daq 738
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixA2'+sframe+'"></td>'
739
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondA2'+sframe+'"></td>'
740
  mform += '                  <td><input type="text" class="inputParam" id="ParamA2'+sframe+'" name="A2" value="0" disabled=true onblur="updateSetSlider(this)"></td>'
741
  mform += '                  <td><input type="text" class="inputParam" id="ParamA2min'+sframe+'" name="A2" onkeyup="updateSetSlider(this)"></td>'
742
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamA2Set'+sframe+'"></div></td>'
743
  mform += '                  <td><input type="text" class="inputParam" id="ParamA2max'+sframe+'" name="A2" onkeyup="updateSetSlider(this)"></td>'
744
  mform += '                  <td><input type="text" class="inputParam" id="ParamA2step'+sframe+'" name="A2" value="0.1" onkeyup="updateSetSlider(this)"></td>'
745
  mform += '                </tr>'
746
  mform += '                <tr class="pol" id="listA3'+sframe+'">'
347 f9daq 747
  mform += '                  <td><li>p3:</td>'
344 f9daq 748
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixA3'+sframe+'"></td>'
749
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondA3'+sframe+'"></td>'
750
  mform += '                  <td><input type="text" class="inputParam" id="ParamA3'+sframe+'"  name="A3" value="0" disabled=true onblur="updateSetSlider(this)"></td>'
751
  mform += '                  <td><input type="text" class="inputParam" id="ParamA3min'+sframe+'" name="A3" onkeyup="updateSetSlider(this)"></td>'
752
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamA3Set'+sframe+'"></div></td>'
753
  mform += '                  <td><input type="text" class="inputParam" id="ParamA3max'+sframe+'" name="A3" onkeyup="updateSetSlider(this)"></td>'
754
  mform += '                  <td><input type="text" class="inputParam" id="ParamA3step'+sframe+'" name="A3" value="0.1" onkeyup="updateSetSlider(this)"></td>'
755
  mform += '                </tr>'
756
  mform += '                <tr class="pol" id="listA4'+sframe+'">'
347 f9daq 757
  mform += '                  <td><li>p4:</td>'
344 f9daq 758
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixA4'+sframe+'"></td>'
759
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondA4'+sframe+'"></td>'
760
  mform += '                  <td><input type="text" class="inputParam" id="ParamA4'+sframe+'" name="A4" value="0" disabled=true onblur="updateSetSlider(this)"></td>'
761
  mform += '                  <td><input type="text" class="inputParam" id="ParamA4min'+sframe+'" name="A4" onkeyup="updateSetSlider(this)"></td>'
762
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamA4Set'+sframe+'"></div></td>'
763
  mform += '                  <td><input type="text" class="inputParam" id="ParamA4max'+sframe+'" name="A4" onkeyup="updateSetSlider(this)"></td>'
764
  mform += '                  <td><input type="text" class="inputParam" id="ParamA4step'+sframe+'" name="A4" value="0.1" onkeyup="updateSetSlider(this)"></td>'
765
  mform += '                </tr>'
766
  mform += '              </tbody>'
767
  mform += '            </table>'
768
  mform += '          </div>'
769
 
770
 
771
  mform += '          <div id="BWFitPanel' + sframe + '" class="FitPanel">'
772
  mform += '            <table class="inputParametersTable" id="inputParamTableBW">'
773
  mform += '              <tbody>'
774
  mform += '                <tr class="description">'
775
  mform += '                  <td>Name</td>'
349 f9daq 776
  mform += '                  <td class="hideFix-Bond">Fix</td>'
777
  mform += '                  <td class="hideFix-Bond">Bond</td>'
344 f9daq 778
  mform += '                  <td>Value</td>'
779
  mform += '                  <td>Min</td>'
780
  mform += '                  <td>Set</td>'
781
  mform += '                  <td>Max</td>'
782
  mform += '                  <td>Step</td>'
783
  mform += '                </tr>'
784
  mform += '                <tr id="listGamma">'
785
  mform += '                  <td><li>&Gamma;:</td>'
786
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixGamma'+sframe+'"></td>'
787
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondGamma'+sframe+'"></td>'
788
  mform += '                  <td><input type="text" class="inputParam" id="ParamGamma'+sframe+'" name="Gamma" value="0" onblur="updateSetSlider(this)"></td>'
789
  mform += '                  <td><input type="text" class="inputParam" id="ParamGammamin'+sframe+'" name="Gamma" onkeyup="updateSetSlider(this)"></td>'
790
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamGammaSet'+sframe+'"></div></td>'
791
  mform += '                  <td><input type="text" class="inputParam" id="ParamGammamax'+sframe+'" name="Gamma" onkeyup="updateSetSlider(this)"></td>'
792
  mform += '                  <td><input type="text" class="inputParam" id="ParamGammastep'+sframe+'" name="Gamma" value="0.1" onkeyup="updateSetSlider(this)"></td>'
793
  mform += '                </tr>'
794
  mform += '                <tr id="listM">'
347 f9daq 795
  mform += '                  <td><li>M<sub>BW</sub>:</td>'
344 f9daq 796
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixM'+sframe+'"></td>'
797
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondM'+sframe+'"></td>'
798
  mform += '                  <td><input type="text" class="inputParam" id="ParamM'+sframe+'" name="M" value="1" onblur="updateSetSlider(this)"></td>'
799
  mform += '                  <td><input type="text" class="inputParam" id="ParamMmin'+sframe+'" name="M" onkeyup="updateSetSlider(this)"></td>'
800
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamMSet'+sframe+'"></div></td>'
801
  mform += '                  <td><input type="text" class="inputParam" id="ParamMmax'+sframe+'" name="M" onkeyup="updateSetSlider(this)"></td>'
802
  mform += '                  <td><input type="text" class="inputParam" id="ParamMstep'+sframe+'" name="M" value="0.1" onkeyup="updateSetSlider(this)"></td>'
803
  mform += '                </tr>'
804
  mform += '                <tr id="listAmpBW">'
347 f9daq 805
  mform += '                  <td><li>N<sub>BW</sub>:</td>'
344 f9daq 806
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixAmpBW'+sframe+'"></td>'
807
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondAmpBW'+sframe+'"></td>'
808
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpBW'+sframe+'" name="AmpBW" value="1" onblur="updateSetSlider(this)"></td>'
809
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpBWmin'+sframe+'" name="AmpBW" onkeyup="updateSetSlider(this)"></td>'
810
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamAmpBWSet'+sframe+'"></div></td>'
811
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpBWmax'+sframe+'" name="AmpBW" onkeyup="updateSetSlider(this)"></td>'
812
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpBWstep'+sframe+'" name="AmpBW" value="0.1" onkeyup="updateSetSlider(this)"></td>'
813
  mform += '                </tr>'
814
  mform += '              </tbody>'
815
  mform += '            </table>'
816
  mform += '          </div>'
817
 
818
  mform += '          <div id="expoFitPanel' + sframe + '" class="FitPanel">'
819
  mform += '            <table class="inputParametersTable" id="inputParamTableExpo">'
820
  mform += '              <tbody>'
821
  mform += '                <tr class="description">'
822
  mform += '                  <td>Name</td>'
349 f9daq 823
  mform += '                  <td class="hideFix-Bond">Fix</td>'
824
  mform += '                  <td class="hideFix-Bond">Bond</td>'
344 f9daq 825
  mform += '                  <td>Value</td>'
826
  mform += '                  <td>Min</td>'
827
  mform += '                  <td>Set</td>'
828
  mform += '                  <td>Max</td>'
829
  mform += '                  <td>Step</td>'
830
  mform += '                </tr>'
831
  mform += '                <tr id="listK">'
832
  mform += '                  <td><li>K:</td>'
833
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixK'+sframe+'"></td>'
834
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondK'+sframe+'"></td>'
835
  mform += '                  <td><input type="text" class="inputParam" id="ParamK'+sframe+'" name="K" value="0" onblur="updateSetSlider(this)"></td>'
836
  mform += '                  <td><input type="text" class="inputParam" id="ParamKmin'+sframe+'" name="K" onkeyup="updateSetSlider(this)"></td>'
837
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamKSet'+sframe+'"></div></td>'
838
  mform += '                  <td><input type="text" class="inputParam" id="ParamKmax'+sframe+'" name="K" onkeyup="updateSetSlider(this)"></td>'
839
  mform += '                  <td><input type="text" class="inputParam" id="ParamKstep'+sframe+'" name="K" value="0.1" onkeyup="updateSetSlider(this)"></td>'
840
  mform += '                </tr>'
841
  mform += '                <tr id="listAmpExp">'
347 f9daq 842
  mform += '                  <td><li>N<sub>exp</sub>:</td>'
344 f9daq 843
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="fixAmpExp'+sframe+'"></td>'
844
  mform += '                  <td><input type="checkbox" class="inputParamBox" id="bondAmpExp'+sframe+'"></td>'
845
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpExp'+sframe+'" name="AmpExp" value="1" onblur="updateSetSlider(this)"></td>'
846
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpExpmin'+sframe+'" name="AmpExp" onkeyup="updateSetSlider(this)"></td>'
847
  mform += '                  <td><div name="ParamSlider" class="ParamSlider'+sframe+'" id="ParamAmpExpSet'+sframe+'"></div></td>'
848
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpExpmax'+sframe+'" name="AmpExp" onkeyup="updateSetSlider(this)"></td>'
849
  mform += '                  <td><input type="text" class="inputParam" id="ParamAmpExpstep'+sframe+'" name="AmpExp" value="0.1" onkeyup="updateSetSlider(this)"></td>'
850
  mform += '                </tr>'
851
  mform += '              </tbody>'
852
  mform += '            </table>'
853
  mform += '          </div>'
854
  mform += '        </div>'
855
 
856
  return mform
857
}
858