Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
THistRange.cxx
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Lorenzo MOneta 11/2020
3
4/*************************************************************************
5 * Copyright (C) 1995-2003, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "THistRange.h"
13
14#include "TH1.h"
15#include "TH2Poly.h"
16#include "TProfile2Poly.h"
17
19{
22}
23
24// implementation of TBinIterator class
25
26/// constructor of TBInIterator taking as input an histogram pointer
27/// This constructors set iterator, the global bin, to its first value (begin)
29 : fNx(0), fNy(0), fNz(0),
30 fXmin(0), fXmax(0), fYmin(0), fYmax(0), fZmin(0), fZmax(0)
31{
32 // deal with special cases (e.g. TH2Poly)
33 if (h->IsA() == TH2Poly::Class() || h->IsA() == TProfile2Poly::Class()) {
34 const TH2Poly *hpoly = static_cast<const TH2Poly *>(h);
35 R__ASSERT(hpoly);
37 // this will loop on all bins (one should exclude 0)
38 fXmin = -9;
39 fXmax = hpoly->GetNumberOfBins();
40 } else if (type == TBinIterator::kUnOfBins) {
41 // overflow bins in TH2Poly are from -9 to -1
42 fXmin = -9;
43 fXmax = -1;
44 } else {
45 // standard bin loop
46 fXmin = 1;
47 fXmax = hpoly->GetNumberOfBins();
48 }
49
50 fYmin = 0;
51 fYmax = 0;
52 fZmin = 0;
53 fZmax = 0;
54 fDim = 1; // this case is equivalent to have one dimension
55 }
56 // general case for TH1,TH2, TH3 and prfile classes
57 else {
58
59 fNx = h->GetNbinsX() + 2;
60 fNy = h->GetNbinsY() + 2;
61 fNz = h->GetNbinsZ() + 2;
62 fDim = h->GetDimension();
63
65 fXmin = h->GetXaxis()->GetFirst();
66 fXmax = h->GetXaxis()->GetLast();
67 fYmin = h->GetYaxis()->GetFirst();
68 fYmax = h->GetYaxis()->GetLast();
69 fZmin = h->GetZaxis()->GetFirst();
70 fZmax = h->GetZaxis()->GetLast();
71 } else if (type == TBinIterator::kAxisBins) {
72 fXmin = 1;
73 fXmax = h->GetNbinsX();
74 fYmin = 1;
75 fYmax = h->GetNbinsY();
76 fZmin = 1;
77 fZmax = h->GetNbinsZ();
79 fXmin = 0;
80 fXmax = h->GetNbinsX() + 1;
81 fYmin = 0;
82 fYmax = h->GetNbinsY() + 1;
83 fZmin = 0;
84 fZmax = h->GetNbinsZ() + 1;
85 }
86 }
87
88 // set bins to initial value
89 fXbin = fXmin;
90 fYbin = fYmin;
91 fZbin = fZmin;
92
94}
#define h(i)
Definition RSha256.hxx:106
#define R__ASSERT(e)
Definition TError.h:120
int type
Definition TGX11.cxx:121
static TBinIterator End()
Definition THistRange.h:82
void SetGlobalBin()
Definition THistRange.h:49
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
Int_t GetNumberOfBins() const
Definition TH2Poly.h:110
THistRange(const TH1 *h1, TBinIterator::ERangeType type=TBinIterator::kHistRange)
TBinIterator fEnd
Definition THistRange.h:154
TBinIterator fBegin
Definition THistRange.h:153
TH1F * h1
Definition legend1.C:5