Logo ROOT  
Reference Guide
lego.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve7
3/// This example display only points in web browser
4///
5/// \macro_code
6///
7
8#include "TRandom.h"
10#include <ROOT/REveScene.hxx>
11#include <ROOT/REveManager.hxx>
12#include <ROOT/REvePointSet.hxx>
13
14namespace REX = ROOT::Experimental;
15
16REX::REvePointSet *createPointSet(int npoints = 2, float s = 2, int color = 28)
17{
18 TRandom &r = *gRandom;
19
20 REX::REvePointSet *ps = new REX::REvePointSet("MyTestPoints", "list of eve points", npoints);
21
22 for (Int_t i=0; i < npoints; ++i)
23 ps->SetNextPoint(r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
24
25 ps->SetMarkerColor(color);
26 ps->SetMarkerSize(3+r.Uniform(1, 2));
27 ps->SetMarkerStyle(4);
28 return ps;
29}
30
31void lego()
32{
34
35 // disable default view
37
38 auto scene = eveMng->SpawnNewScene("Lego", "LegoView");
39 auto view = eveMng->SpawnNewViewer("Lego", "");
40 view->AddScene(scene);
41
42 auto ps = createPointSet(100);
43 scene->AddElement(ps);
44
45 {
46 // gROOT->SetBatch();
47
48 // TPad *p = new TPad("LegoPad", "Lego Pad Tit", 0, 0, 1, 1);
49 TPad *p = new TCanvas("LegoPad", "Lego Pad Tit", 800,400);
50 p->SetMargin(0, 0, 0, 0);
51
52 // *** Simple TH2
53 /*
54 TH2F* h = new TH2F("Booboo","exampul",128,-5,5,64,-2.5,2.5);
55 TRandom r;
56 for(int i=0;i<1000000;++i) {
57 h->Fill(r.Gaus() - 2, r.Gaus());
58 h->Fill(r.Gaus() + 2, r.Gaus());
59 }
60 for(int i=0;i<6000;++i) {
61 h->Fill(0.1*r.Gaus() - 2, 0.1*r.Gaus());
62 h->Fill(0.1*r.Gaus() + 2, 0.1*r.Gaus());
63 }
64 // h->Draw("LEGO2");
65 p->GetListOfPrimitives()->Add(h, "LEGO2");
66 p->Modified(kTRUE);
67 */
68
69 // *** Load std CMS calo demo
70 const char* histFile = "http://amraktad.web.cern.ch/amraktad/cms_calo_hist.root";
72 auto hf = TFile::Open(histFile, "CACHEREAD");
73 auto ecalHist = (TH2F*)hf->Get("ecalLego");
74 auto hcalHist = (TH2F*)hf->Get("hcalLego");
75
76 THStack *s = new THStack("LegoStack", ""); // "ECal undt HCal");
77 ecalHist->SetFillColor(kRed);
78 ecalHist->GetXaxis()->SetLabelSize(1);
79 // ecalHist->GetXaxis()->SetTitle(reinterpret_cast<const char *>(u8"\u03B7"));
80 ecalHist->GetXaxis()->SetTitle("#eta");
81 ecalHist->GetYaxis()->SetLabelSize(1);
82 // ecalHist->GetYaxis()->SetTitle(reinterpret_cast<const char *>(u8"\u03C6"));
83 ecalHist->GetYaxis()->SetTitle("#varphi");
84 ecalHist->GetZaxis()->SetLabelSize(1);
85 s->Add(ecalHist);
86 hcalHist->SetFillColor(kBlue);
87 s->Add(hcalHist);
89
90 TGraph2D *line = new TGraph2D(200);
91 for (int i = 0; i < 200; ++i)
92 line->SetPoint(i, std::cos(i*0.1), std::sin(i*0.1), i*0.25);
95 p->GetListOfPrimitives()->Add(line, "LINE");
96
97 p->Modified(kTRUE);
98
100
101 ps->SetTitle(TBase64::Encode(json).Data());
102
103 s->Draw();
104 }
105
106 eveMng->Show();
107}
ROOT::R::TRInterface & r
Definition: Object.C:4
int Int_t
Definition: RtypesCore.h:45
const Bool_t kTRUE
Definition: RtypesCore.h:100
@ kRed
Definition: Rtypes.h:66
@ kCyan
Definition: Rtypes.h:66
@ kBlue
Definition: Rtypes.h:66
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
REveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
virtual Bool_t SetRnrSelf(Bool_t rnr)
Set render state of this element, i.e.
static REveManager * Create()
If global REveManager* REX::gEve is not set initialize it.
REveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
REveViewer * SpawnNewViewer(const char *name, const char *title="")
Create a new GL viewer.
REveViewerList * GetViewers() const
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
Definition: REveViewer.cxx:58
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetMargin(Float_t left, Float_t right, Float_t bottom, Float_t top)
Set all margins.
Definition: TAttPad.cxx:139
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
Definition: TBase64.cxx:107
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
Definition: TBufferJSON.h:75
The Canvas class.
Definition: TCanvas.h:23
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Definition: TFile.h:324
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:4011
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition: TGraph2D.h:41
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
The Histogram stack class.
Definition: THStack.h:38
virtual void Add(TObject *obj)
Definition: TList.h:87
The most important graphics class in the ROOT system.
Definition: TPad.h:26
TList * GetListOfPrimitives() const override
Definition: TPad.h:239
void Modified(Bool_t flag=1) override
Definition: TPad.h:413
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
Basic string class.
Definition: TString.h:136
ROOT::Experimental::REveManager * eveMng
TLine * line
const char * histFile
Definition: calorimeters.C:13
void lego()
Definition: lego.C:31
REX::REvePointSet * createPointSet(int npoints=2, float s=2, int color=28)
Definition: lego.C:16
static constexpr double s
static constexpr double ps
basic_json< std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, adl_serializer, std::vector< std::uint8_t > > json
Definition: REveElement.hxx:36