GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4HistogramStatus.cxx
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4HistogramStatus.h"
15 
16 #include "TH1.h"
17 #include "TH2.h"
18 #include "TH3.h"
19 
20 #include "TGo4Log.h"
21 
23 {
24 }
25 
26 TGo4HistogramStatus::TGo4HistogramStatus(TH1 *his, Bool_t allstatistics)
27  : TGo4ObjectStatus(his, allstatistics)
28 
29 {
30  GO4TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus(TH1 *)",__LINE__, __FILE__));
31 
32  if (his) {
33  fiDim = his->GetDimension();
34  fiNbinX = his->GetNbinsX();
35  fiNbinY = his->GetNbinsY();
36  fiNbinZ = his->GetNbinsZ();
37  TAxis *xax = his->GetXaxis();
38  if (xax) {
39  fdXmin = xax->GetXmin();
40  fdXmax = xax->GetXmax();
41  } else { // values already initialized as zero
42  }
43  TAxis *yax = his->GetYaxis();
44  if (yax) {
45  fdYmin = yax->GetXmin();
46  fdYmax = yax->GetXmax();
47  } else { // values already initialized as zero
48  }
49  TAxis *zax = his->GetZaxis();
50  if (zax) {
51  fdZmin = zax->GetXmin();
52  fdZmax = zax->GetXmax();
53  } else { // values already initialized as zero
54  }
55  fdEntries = his->GetEntries();
58  Int_t fieldsize = 0;
59  // because of multiple inheritance of histogram types, we
60  // must check for all types separately to downcast the correct TArray:
61  if (his->InheritsFrom(TH1D::Class())) {
62  TH1D *dhis = dynamic_cast<TH1D*>(his);
63  fieldsize = sizeof(Double_t) * dhis->GetSize(); // method of TArray baseclass
64  } else if (his->InheritsFrom(TH1F::Class())) {
65  TH1F *fhis = dynamic_cast<TH1F*>(his);
66  fieldsize = sizeof(Float_t) * fhis->GetSize(); // method of TArray baseclass
67  } else if (his->InheritsFrom(TH1I::Class())) {
68  TH1I *ihis = dynamic_cast<TH1I*>(his);
69  fieldsize = sizeof(Int_t) * ihis->GetSize(); // method of TArray baseclass
70  } else if (his->InheritsFrom(TH1S::Class())) {
71  TH1S *shis = dynamic_cast<TH1S*>(his);
72  fieldsize = sizeof(Short_t) * shis->GetSize(); // method of TArray baseclass
73  } else if (his->InheritsFrom(TH1C::Class())) {
74  TH1C *chis = dynamic_cast<TH1C*>(his);
75  fieldsize = sizeof(Char_t) * chis->GetSize(); // method of TArray baseclass
76  } else if (his->InheritsFrom(TH2D::Class())) {
77  TH2D *dhis = dynamic_cast<TH2D*>(his);
78  fieldsize = sizeof(Double_t) * dhis->GetSize(); // method of TArray baseclass
79  } else if (his->InheritsFrom(TH2F::Class())) {
80  TH2F *fhis = dynamic_cast<TH2F*>(his);
81  fieldsize = sizeof(Float_t) * fhis->GetSize(); // method of TArray baseclass
82  } else if (his->InheritsFrom(TH2I::Class())) {
83  TH2I *ihis = dynamic_cast<TH2I*>(his);
84  fieldsize = sizeof(Int_t) * ihis->GetSize(); // method of TArray baseclass
85  } else if (his->InheritsFrom(TH2S::Class())) {
86  TH2S *shis = dynamic_cast<TH2S*>(his);
87  fieldsize = sizeof(Short_t) * shis->GetSize(); // method of TArray baseclass
88  } else if (his->InheritsFrom(TH2C::Class())) {
89  TH2C *chis = dynamic_cast<TH2C*>(his);
90  fieldsize = sizeof(Char_t) * chis->GetSize(); // method of TArray baseclass
91  } else if (his->InheritsFrom(TH3D::Class())) {
92  TH3D *dhis = dynamic_cast<TH3D*>(his);
93  fieldsize = sizeof(Double_t) * dhis->GetSize(); // method of TArray baseclass
94  } else if (his->InheritsFrom(TH3F::Class())) {
95  TH3F *fhis = dynamic_cast<TH3F*>(his);
96  fieldsize = sizeof(Float_t) * fhis->GetSize(); // method of TArray baseclass
97  } else if (his->InheritsFrom(TH3I::Class())) {
98  TH3I *ihis = dynamic_cast<TH3I*>(his);
99  fieldsize = sizeof(Int_t) * ihis->GetSize(); // method of TArray baseclass
100  } else if (his->InheritsFrom(TH3S::Class())) {
101  TH3S *shis = dynamic_cast<TH3S*>(his);
102  fieldsize = sizeof(Short_t) * shis->GetSize(); // method of TArray baseclass
103  } else if (his->InheritsFrom(TH3C::Class())) {
104  TH3C *chis = dynamic_cast<TH3C*>(his);
105  fieldsize = sizeof(Char_t) * chis->GetSize(); // method of TArray baseclass
106  }
107  fiObjectSize += fieldsize; // add heap field to object stack memory size
109 
110  if (allstatistics) {
111  // note: we do not calculate statistic for nameslist
112  // slows down when processing empty 2d histos!
113  fdXmean = his->GetMean(1);
114  fdYmean = his->GetMean(2);
115  fdZmean = his->GetMean(3);
116  fdXrms = his->GetRMS(1);
117  fdYrms = his->GetRMS(2);
118  fdZrms = his->GetRMS(3);
119  }
120  }
121 }
122 
123 
125 {
126  GO4TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus()",__LINE__, __FILE__));
127 }
128 
129 void TGo4HistogramStatus::Print(Option_t *) const
130 {
132  PrintLine("G-OOOO-> Histogram Status Class Printout <-OOOO-G");
133  PrintLine("G-OOOO-> ---------------------------------------------- <-OOOO-G");
134  // put printout of histogram infos here:
135  PrintLine(" Dimension: \t%d", GetDimension());
136  PrintLine(" Bins X: \t%d", GetXbins());
137  PrintLine(" X min: \t\t%f", GetXmin());
138  PrintLine(" X max: \t\t%f", GetXmax());
139  PrintLine(" X mean: \t%f", GetXmean());
140  PrintLine(" X rms: \t\t%f", GetXrms());
141  if (GetDimension() > 1) {
142  PrintLine(" Bins Y: \t%d", GetYbins());
143  PrintLine(" Y min: \t\t%f", GetYmin());
144  PrintLine(" Y max: \t\t%f", GetYmax());
145  PrintLine(" Y mean: \t%f", GetYmean());
146  PrintLine(" Y rms: \t\t%f", GetYrms());
147  }
148  if (GetDimension() > 2) {
149  PrintLine(" Bins Z: \t%d", GetZbins());
150  PrintLine(" Z min: \t\t%f", GetZmin());
151  PrintLine(" Z max: \t\t%f", GetZmax());
152  PrintLine(" Z mean: \t%f", GetZmean());
153  PrintLine(" Z rms: \t\t%f", GetZrms());
154  }
155  PrintLine(" N Entries: \t%f", GetEntries());
156 }
void Print(Option_t *opt="") const override
Stat_t GetEntries() const
Int_t GetDimension() const
void Print(Option_t *opt="") const override
#define GO4TRACE(X)
Definition: TGo4Log.h:25
static void PrintLine(const char *text,...)
Definition: TGo4Status.cxx:101