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:118
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static TBinIterator End()
Definition THistRange.h:82
int fYmax
Max y value.
Definition THistRange.h:42
int fNx
Total x size (nbins+2)
Definition THistRange.h:36
int fXbin
Bin X number.
Definition THistRange.h:32
int fZmax
Max z value.
Definition THistRange.h:44
void SetGlobalBin()
Compute global bin number given x,y,x bin numbers.
Definition THistRange.h:49
int fYmin
Min y value.
Definition THistRange.h:41
int fZbin
Bin Z number.
Definition THistRange.h:34
int fZmin
Min z value.
Definition THistRange.h:43
int fYbin
Bin y number.
Definition THistRange.h:33
int fNy
y size
Definition THistRange.h:37
int fNz
z size
Definition THistRange.h:38
int fXmax
Max x value.
Definition THistRange.h:40
int fXmin
Min x value.
Definition THistRange.h:39
ERangeType
enum defining option range type:
Definition THistRange.h:70
@ kUnOfBins
collection of all underflow/overflow bins
Definition THistRange.h:74
@ kHistRange
use range provided by histogram
Definition THistRange.h:71
@ kAxisBins
use allbins within axis limits (no underflow/overflows)
Definition THistRange.h:72
@ kAllBins
use all bins including underflows/overflows
Definition THistRange.h:73
int fDim
Histogram dimension.
Definition THistRange.h:46
TClass * IsA() const override
Definition TClass.h:614
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
Int_t GetNumberOfBins() const
Return the number of bins : it should be the size of the bin list.
Definition TH2Poly.cxx:865
static TClass * Class()
THistRange(const TH1 *h1, TBinIterator::ERangeType type=TBinIterator::kHistRange)
TBinIterator fEnd
Definition THistRange.h:154
TBinIterator fBegin
Definition THistRange.h:153
static TClass * Class()
TH1F * h1
Definition legend1.C:5