Logo ROOT   6.18/05
Reference Guide
fitpanel.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// \macro_code
5///
6/// \date 2015-03-22
7/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
8/// \author Axel Naumann <axel@cern.ch>
9
10/*************************************************************************
11 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
12 * All rights reserved. *
13 * *
14 * For the licensing terms see $ROOTSYS/LICENSE. *
15 * For the list of contributors see $ROOTSYS/README/CREDITS. *
16 *************************************************************************/
17
18#include "ROOT/RHist.hxx"
20#include "ROOT/RCanvas.hxx"
21#include "ROOT/RFitPanel.hxx"
22#include "ROOT/RDirectory.hxx"
23
24using namespace ROOT::Experimental;
25
26void fitpanel() {
27
28 // TODO - also keep axis correctly in the help
29 auto xaxis = std::make_shared<RAxisConfig>(10, 0., 10.);
30 // Create the histogram.
31 auto pHist = std::make_shared<RH1D>(*xaxis.get());
32
33 // Fill a few points.
34 pHist->Fill(1);
35 pHist->Fill(2);
36 pHist->Fill(2);
37 pHist->Fill(3);
38
39 auto canvas = RCanvas::Create("Canvas Title");
40 canvas->Draw(pHist); //->SetLineColor(RColor::kRed);
41
42 canvas->Show();
43 canvas->Update(); // need to ensure canvas is drawn
44
45 auto panel = std::make_shared<RFitPanel>("FitPanel Title");
46
47 RDirectory::Heap().Add("fitpanel", panel);
48 RDirectory::Heap().Add("firsthisto", pHist);
49 RDirectory::Heap().Add("firstaxis", xaxis);
50
51 // TODO: how combine there methods together
52 // here std::shread_ptr<> on both sides
53
54 panel->AssignCanvas(canvas);
55 panel->AssignHistogram(pHist);
56
57 canvas->AddPanel(panel);
58}
59