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 and the corresponding png picture
6/// is generated.
7///
8/// \macro_code
9///
10/// \date 2015-03-22
11/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
12/// \author Axel Naumann <axel@cern.ch>
13
14/*************************************************************************
15 * Copyright (C) 1995-2019, 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 "TRandom.h"
25
26// macro must be here while cling is not capable to load
27// library automatically for outlined function see ROOT-10336
28R__LOAD_LIBRARY(libROOTHistDraw)
29
30using namespace ROOT::Experimental;
31
32void draw_rh1()
33{
34 // Create the histogram.
35 RAxisConfig xaxis(25, 0., 10.);
36 auto pHist = std::make_shared<RH1D>(xaxis);
37 auto pHist2 = std::make_shared<RH1D>(xaxis);
38
39 for (int n=0;n<1000;n++) {
40 pHist->Fill(gRandom->Gaus(3,0.8));
41 pHist2->Fill(gRandom->Gaus(7,1.2));
42 }
43
44 // Create a canvas to be displayed.
45 auto canvas = RCanvas::Create("Canvas Title");
46 auto draw1 = canvas->Draw(pHist);
47 draw1->AttrLine().SetColor(RColor::kRed).SetWidth(2);
48
49 auto draw2 = canvas->Draw(pHist2);
50 draw2->AttrLine().SetColor(RColor::kBlue).SetWidth(4);
51
52 canvas->Show();
53}
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:473
@ 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: RAxis.hxx:300
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