Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rh1_large.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_rcanvas
3///
4/// This macro generates really large RH1D histogram, fills it with predefined pattern and
5/// draw it in a RCanvas, using Optmize() drawing mode
6///
7/// \macro_image (rcanvas_js)
8/// \macro_code
9///
10/// \date 2020-07-02
11/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
12/// \author Sergey Linev <s.linev@gsi.de>
13
14/*************************************************************************
15 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
16 * All rights reserved. *
17 * *
18 * For the licensing terms see $ROOTSYS/LICENSE. *
19 * For the list of contributors see $ROOTSYS/README/CREDITS. *
20 *************************************************************************/
21
23#include "ROOT/RCanvas.hxx"
24#include "ROOT/RFrameTitle.hxx"
25#include "ROOT/RHistStatBox.hxx"
26#include "ROOT/RFrame.hxx"
27#include "TMath.h"
28#include "TString.h"
29
30
31// macro must be here while cling is not capable to load
32// library automatically for outlined function see ROOT-10336
33R__LOAD_LIBRARY(libROOTHistDraw)
34
35using namespace ROOT::Experimental;
36
37void rh1_large()
38{
39 const int nbins = 5000000;
40
41 // Create the histogram.
42 RAxisConfig xaxis("x", nbins, 0., nbins);
43 auto pHist = std::make_shared<RH1D>(xaxis);
44
45 for(int i=0;i<nbins;++i)
46 pHist->Fill(1.*i, 1000.*(2+TMath::Sin(100.*i/nbins)));
47
48 // Create a canvas to be displayed.
49 auto canvas = RCanvas::Create("Drawing large RH1");
50
51 auto frame = canvas->AddFrame();
52
53 frame->gridX = true;
54 frame->gridY = true;
55 frame->x.zoomMin = nbins*0.2;
56 frame->x.zoomMax = nbins*0.8;
57
58 canvas->Draw<RFrameTitle>(TString::Format("Large RH1D histogram with %d bins",nbins).Data());
59
60 auto draw = canvas->Draw(pHist);
61
62 draw->line.color = RColor::kLime;
63 // draw->fill.color = RColor::kLime;
64 // draw->fill.style = RAttrFill::kSolid;
65 // draw->Line(); // configure line draw option
66 // draw->Bar(); // configure bar draw option
67 // draw->Error(3); // configure error drawing
68 draw->Hist(); // configure hist draw option, default
69
70 draw->optimize = true; // enable draw optimization, reduced data set will be send to clients
71
72 auto stat = canvas->Draw<RHist1StatBox>(pHist, "hist");
73 stat->fill.color = RColor::kBlue;
74 stat->fill.style = RAttrFill::kSolid;
75
76 canvas->SetSize(1000, 700);
77 canvas->Show();
78}
#define R__LOAD_LIBRARY(LIBRARY)
Definition Rtypes.h:491
RAttrValue< RColor > color
! fill color
Definition RAttrFill.hxx:43
Objects used to configure the different axis types.
RAttrFill fill
! fill attributes
Definition RPave.hxx:48
const char * Data() const
Definition TString.h:380
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2356
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:586