Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
custom.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_http
3 /// This program creates and fills one and two dimensional histogram
4 /// Macro used to demonstrate usage of custom HTML page in custom.htm
5 /// One can use plain JavaScript to assign different actions with HTML buttons
6 ///
7 /// \macro_code
8 ///
9 /// \author Sergey Linev
10 
11 #include <TH1.h>
12 #include <TH2.h>
13 #include <THttpServer.h>
14 #include <TRandom3.h>
15 
16 void custom()
17 {
18  // Create two histograms
19  TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
20  TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
21 
22  // http server with port 8080, use jobname as top-folder name
23  THttpServer* serv = new THttpServer("http:8080");
24 
25  // use custom web page as default
26  serv->SetDefaultPage("custom.htm");
27 
28  // Fill histograms randomly
29  TRandom3 random;
30  Float_t px, py;
31 
32  // press Ctrl-C to stop macro
33  while (!gSystem->ProcessEvents()) {
34  random.Rannor(px,py);
35  hpx->Fill(px);
36  hpxpy->Fill(px,py);
37  }
38 }