Subversion Repositories f9daq

Rev

Rev 269 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
268 f9daq 1
#include <stdlib.h>
2
#include <stdio.h>
3
#include <TH1F.h>
4
#include <TCanvas.h>
5
#include <TF1.h>
6
#include <TStyle.h>
7
#include <TBufferJSON.h>
8
//#include <TBufferXML.h>
9
class Hdr{
10
public:
11
  int id;
12
  int len;
13
  int progress;
14
};
15
 
16
void send_message(int id, TString msg, int progress){
17
static Hdr hdr;
18
 
19
   hdr.id = id;
20
   hdr.len= msg.Length();
21
   hdr.progress= progress;
22
   fwrite(&hdr,3*sizeof(int),1,stdout);
23
   fwrite(msg.Data(),hdr.len,1,stdout);
24
   fflush(stdout);
25
 
26
}
27
 
28
 
29
 
30
int th1fit(Double_t *data, const char *name, const char *title, int xbins, double xmin, double xmax, double min=0, double max=1,const char *func=NULL, const char *pars=NULL){
31
 
32
TH1F *h = new TH1F(name,title,xbins, xmin,xmax);
33
for (int i=0;i<xbins+2;i++) h->SetBinContent(i,data[i]);
34
 
35
gStyle->SetOptFit(1111);
36
TF1 *f  = new TF1("f",func,min,max);
37
//TCanvas *v =new TCanvas();
38
h->Fit(f,"RQ");
39
h->Draw();
40
//v->Modified();
41
//v->Update();
42
send_message(1,TBufferJSON::ConvertToJSON(h),0 );
43
return 0;
44
}