Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 268 → Rev 269

/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;
}