Logo ROOT   6.12/07
Reference Guide
histops.cxx
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_v7
3 ///
4 /// \macro_code
5 ///
6 /// \date 2015-08-08
7 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
8 /// is welcome!
9 /// \author Axel Naumann <axel@cern.ch>
10 
11 /*************************************************************************
12  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
13  * All rights reserved. *
14  * *
15  * For the licensing terms see $ROOTSYS/LICENSE. *
16  * For the list of contributors see $ROOTSYS/README/CREDITS. *
17  *************************************************************************/
18 
19 #include "ROOT/THist.hxx"
20 #include <iostream>
21 
22 void histops()
23 {
24 
25  using namespace ROOT;
26  // Create a 2D histogram with an X axis with equidistant bins, and a y axis
27  // with irregular binning.
28  Experimental::TH2D hist1({100, 0., 1.}, {{0., 1., 2., 3., 10.}});
29 
30  // Fill weight 1. at the coordinate 0.01, 1.02.
31  hist1.Fill({0.01, 1.02});
32 
33  Experimental::TH2D hist2({{{10, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
34  // Fill weight 1. at the coordinate 0.01, 1.02.
35  hist2.Fill({0.01, 1.02});
36 
37  Experimental::Add(hist1, hist2);
38 
39  int binidx = hist1.GetImpl()->GetBinIndex({0.01, 1.02});
40  std::cout << hist1.GetImpl()->GetBinContent(binidx) << std::endl;
41 }
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Definition: THist.hxx:33
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
Definition: THist.hxx:308
void Fill(const CoordArray_t &x, Weight_t weight=(Weight_t) 1) noexcept
Add weight to the bin containing coordinate x.
Definition: THist.hxx:138