Subversion Repositories f9daq

Rev

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