Logo ROOT   6.08/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 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/THist.hxx"
19 #include <iostream>
20 
21 void histops() {
22 
23  // Create a 2D histogram with an X axis with equidistant bins, and a y axis
24  // with irregular binning.
25  Experimental::TH2D hist1({100, 0., 1.}, {{0., 1., 2., 3.,10.}});
26 
27  // Fill weight 1. at the coordinate 0.01, 1.02.
28  hist1.Fill({0.01, 1.02});
29 
30 
31  Experimental::TH2D hist2({{ {10, 0., 1.}, {{0., 1., 2., 3.,10.}} }});
32  // Fill weight 1. at the coordinate 0.01, 1.02.
33  hist2.Fill({0.01, 1.02});
34 
35  Experimental::Add(hist1, hist2);
36 
37  int binidx = hist1.GetImpl()->GetBinIndex({0.01, 1.02});
38  std::cout << hist1.GetImpl()->GetBinContent(binidx) << std::endl;
39 }
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
Definition: THist.hxx:327
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D
Definition: THist.hxx:307