Subversion Repositories f9daq

Rev

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