Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
histops.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_exp
3///
4/// \macro_code
5///
6/// \date 2015-08-08
7/// \warning This is part of the experimental API, which might change in the future. 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"
19#include <iostream>
20
21void histops()
22{
23
24 using namespace ROOT::Experimental;
25 // Create a 2D histogram with an X axis with equidistant bins, and a y axis
26 // with irregular binning.
27 RH2D hist1({10, 0., 1.}, {{0., 1., 2., 3., 10.}});
28
29 // Fill weight 1. at the coordinate 0.01, 1.02.
30 hist1.Fill({0.01, 1.02});
31
32 RH2D hist2({{{10, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
33 // Fill weight 1. at the coordinate 0.02, 1.03 (that's the same bin).
34 hist2.Fill({0.02, 1.03});
35
36 Add(hist1, hist2);
37
38 int binidx = hist1.GetImpl()->GetBinIndex({0.01, 1.02});
39 std::cout << hist1.GetImpl()->GetBinContent(binidx) << std::endl;
40}
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Definition RHist.hxx:53
void Fill(const CoordArray_t &x, Weight_t weight=(Weight_t) 1) noexcept
Add weight to the bin containing coordinate x.
Definition RHist.hxx:140
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.