Loading [MathJax]/extensions/tex2jax.js
Logo ROOT  
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
draw_rh1.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// This macro generates a small V7 TH1D, fills it and draw it in a V7 canvas.
5/// The canvas is display in the web browser
6///
7/// \macro_code
8///
9/// \date 2015-03-22
10/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
11/// \author Axel Naumann <axel@cern.ch>
12
13/*************************************************************************
14 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
15 * All rights reserved. *
16 * *
17 * For the licensing terms see $ROOTSYS/LICENSE. *
18 * For the list of contributors see $ROOTSYS/README/CREDITS. *
19 *************************************************************************/
20
22#include "ROOT/RCanvas.hxx"
23#include "TRandom.h"
24
25// macro must be here while cling is not capable to load
26// library automatically for outlined function see ROOT-10336
27R__LOAD_LIBRARY(libROOTHistDraw)
28
29using namespace ROOT::Experimental;
30
31void draw_rh1()
32{
33 // Create the histogram.
34 RAxisConfig xaxis(25, 0., 10.);
35 auto pHist = std::make_shared<RH1D>(xaxis);
36 auto pHist2 = std::make_shared<RH1D>(xaxis);
37
38 for (int n=0;n<1000;n++) {
39 pHist->Fill(gRandom->Gaus(3,0.8));
40 pHist2->Fill(gRandom->Gaus(7,1.2));
41 }
42
43 // Create a canvas to be displayed.
44 auto canvas = RCanvas::Create("Canvas Title");
45 auto draw1 = canvas->Draw(pHist);
46 draw1->AttrLine().SetColor(RColor::kRed).SetWidth(2);
47
48 auto draw2 = canvas->Draw(pHist2);
49 draw2->AttrLine().SetColor(RColor::kBlue).SetWidth(4);
50
51 canvas->SetSize(1000, 700);
52 canvas->Show();
53}
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:469
@ kRed
Definition: Rtypes.h:64
@ kBlue
Definition: Rtypes.h:64
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
Objects used to configure the different axis types.
Definition: RAxisConfig.hxx:35
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:263
const Int_t n
Definition: legend1.C:16