Logo ROOT   6.14/05
Reference Guide
histfitserver.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_http
3 /// This program demonstrates simultaneous update of histogram and fitted function.
4 /// Every second new random entries add and histogram fitted again.
5 /// Required at least JSROOT version 5.1.1 to see correct fit function update in browser
6 ///
7 /// \macro_code
8 ///
9 /// \author Sergey Linev
10 
11 
12 #include "THttpServer.h"
13 #include "TH1F.h"
14 #include "TCanvas.h"
15 #include "TF1.h"
16 #include "TSystem.h"
17 
18 
19 void histfitserver(void)
20 {
21  auto serv = new THttpServer("http:8081");
22  auto h1 = new TH1F("h1", "histogram 1", 100, -5, 5);
23  auto c1 = new TCanvas("c1");
24  auto f1 = new TF1("f1", "gaus", -10, 10);
25 
26  c1->cd();
27  h1->Draw();
28 
29  while (!gSystem->ProcessEvents()) {
30  h1->FillRandom("gaus", 100);
31  h1->Fit(f1);
32  c1->Modified();
33  c1->Update();
34  gSystem->Sleep(1000);
35  }
36 }
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:424
return c1
Definition: legend1.C:41
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:285
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:445
TH1F * h1
Definition: legend1.C:5
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3421
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2974
The Canvas class.
Definition: TCanvas.h:31
1-Dim function class
Definition: TF1.h:211
TF1 * f1
Definition: legend1.C:11
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
Definition: TH1.cxx:3695