Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 268 → Rev 269

/belle2/masterclass/index.php
76,7 → 76,7
// addLog('#TF1 ' +JSON.stringify(tf1, null, '\t')+ '$$$<br>');
mtext = '<br/>' + "Fit Function: " + tformula.fFormula+ '<br/>';
mtext +="Chi2/NDF: " + tf1.fChisquare.toPrecision(2) + " / "+ tf1.fNDF+ '<br/>';
mtext +='<table border="0" >';
mtext +='<table border="0" width="50%" >';
for ( var i = 0;i <len;i++){
var name = tformula.fParams[i].first;
var val = tformula.fClingParameters[i];
167,15 → 167,14
mform ='<form method="post" action="th1fit.php" onsubmit="return fitpanel(this);">';
mform += ' <input class="mybutton" type="submit" value=" Fit "/>';
mform += ' Range: min=<input type="text" size="2" value="0" name="min" />';
mform += ' max:<input type="text" size="2" value="10" name="max" />';
mform += ' max:<input type="text" size="2" value="20" name="max" />';
mform += ' Function:<input type="text" size="5" value="gaus" name="fitfun" />';
mform += ' Initial parameters<input type="text" size="5" value="1;2;3" name="prm" />';
mform += ' Initial parameters<input type="text" size="5" value="" name="prm" />';
mform += ' <input id="data'+ sframe +'" type="hidden" value="'+ result.message +'" name="data" />';
mform += ' <input type="hidden" value="'+ sframe +'" name="name" />';
mform += '</form>';
 
fit.insertAdjacentHTML('beforeend', '<div id="param' + sframe +'"></div><br/>');
fit.insertAdjacentHTML('beforeend', mform);
fit.insertAdjacentHTML('beforeend', '<div id="param' + sframe +'"></div><br/>');
r.insertAdjacentHTML('beforeend','<input type="button" onclick="togglevisibility(\'fit'+sframe+'\');" class="mybutton" value="Show/Hide Fit Panel" /><hr/>' );
document.getElementById('data'+ sframe).value=result.message;
//r.insertAdjacentHTML('beforeend', JSON.stringify(result.message));
/belle2/masterclass/th1fit.cc
5,6 → 5,9
#include <TF1.h>
#include <TStyle.h>
#include <TBufferJSON.h>
#include <TString.h>
#include <TObjString.h>
#include <string.h>
//#include <TBufferXML.h>
class Hdr{
public:
34,11 → 37,36
 
gStyle->SetOptFit(1111);
TF1 *f = new TF1("f",func,min,max);
//TCanvas *v =new TCanvas();
 
char *s = (char *)pars;
 
int cntr=0;
char *p = strchr(s,',');
if (p!=NULL){
do {
char tok[0xFF];
strncpy(tok, s, p-s);
tok[p-s]=0;
if (strlen(tok)) {
//printf("*");
f->SetParameter(cntr,atof(tok));
}
//printf("-----[%d] length=%d %s\n", cntr, strlen(tok),tok);
s = p + 1;
cntr++;
p = strchr(s,',');
} while (p!=NULL);
}
if (strlen(s)>0) {
f->SetParameter(cntr,atof(s));
//printf("----[0x] %s\n",s);
}
 
 
h->Fit(f,"RQ");
h->Draw();
//v->Modified();
//v->Update();
 
send_message(1,TBufferJSON::ConvertToJSON(h),0 );
return 0;
}
/belle2/masterclass/th1fit.php
64,7 → 64,7
if (isset($_POST["prm"])){
$prm = $_POST["prm"];
} else {
$prm = "0;1;2";
$prm = "9,11,,99,3,,7";
}
 
if (isset($_POST["name"])){
102,7 → 102,7
 
$cmd0 = ".L th1fit.cc+". PHP_EOL;
$cmd0 .= "double data[]={". $hdata . "};" .PHP_EOL;
$cmd0 .= "th1fit(data, \"$hname\",\"$htitle;$xtitle;$ytitle\", $xbins , $xmin, $xmax, $min ,$max ,\"$fitfun\");". PHP_EOL;
$cmd0 .= "th1fit(data, \"$hname\",\"$htitle;$xtitle;$ytitle\", $xbins , $xmin, $xmax, $min ,$max ,\"$fitfun\",\"$prm\");". PHP_EOL;
 
if (file_exists('/opt/root/bin/thisroot.sh')){
$profile ='/opt/root/bin/thisroot.sh';