Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TSystem.h"
16#include <string>
17
18void custom()
19{
20 // Create two histograms
21 TH1F *hpx = new TH1F("hpx", "This is the px distribution", 100, -4, 4);
22 TH2F *hpxpy = new TH2F("hpxpy", "py vs px", 40, -4, 4, 40, -4, 4);
23
24 // http server with port 8080, use jobname as top-folder name
25 THttpServer *serv = new THttpServer("http:8080");
26
27 // Detect macro file location to specify full path to the HTML file
28 std::string fname = __FILE__;
29 auto pos = fname.find("custom.C");
30 if (pos > 0)
31 fname.resize(pos);
32 else
33 fname.clear();
34 fname.append("custom.htm");
35
36 // use custom web page as default
37 serv->SetDefaultPage(fname);
38
39 // Fill histograms randomly
40 TRandom3 random;
41 Float_t px, py;
42
43 // press Ctrl-C to stop macro
44 while (!gSystem->ProcessEvents()) {
45 random.Rannor(px,py);
46 hpx->Fill(px);
47 hpxpy->Fill(px,py);
48 }
49}
float Float_t
Definition RtypesCore.h:57
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition TH1.cxx:3344
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:393
Online http server for arbitrary ROOT application.
Definition THttpServer.h:31
void SetDefaultPage(const std::string &filename="")
Set default HTML page.
Random number generator class based on M.
Definition TRandom3.h:27
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition TRandom.cxx:507
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416