00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4HistogramStatus.h"
00015
00016 #include "Riostream.h"
00017 #include "TH1.h"
00018 #include "TH2.h"
00019 #include "TH3.h"
00020
00021 #include "TGo4Log.h"
00022
00023 TGo4HistogramStatus::TGo4HistogramStatus(TH1* his, Bool_t allstatistics)
00024 : TGo4ObjectStatus(his, allstatistics),
00025 fiDim(0),fiNbinX(0), fiNbinY(0), fiNbinZ(0),
00026 fdXmin(0), fdXmax(0), fdYmin(0), fdYmax(0), fdZmin(0), fdZmax(0),
00027 fdEntries(0), fdXmean(0), fdYmean(0), fdZmean(0),
00028 fdXrms(0), fdYrms(0), fdZrms(0)
00029 {
00030 GO4TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus(TH1*)",__LINE__, __FILE__));
00031
00032 if(his!=0)
00033 {
00034 fiDim=his->GetDimension();
00035 fiNbinX=his->GetNbinsX();
00036 fiNbinY=his->GetNbinsY();
00037 fiNbinZ=his->GetNbinsZ();
00038 TAxis* xax=his->GetXaxis();
00039 if(xax)
00040 {
00041 fdXmin=xax->GetXmin();
00042 fdXmax=xax->GetXmax();
00043 }
00044 else
00045 {
00046 }
00047 TAxis* yax=his->GetYaxis();
00048 if(yax)
00049 {
00050 fdYmin=yax->GetXmin();
00051 fdYmax=yax->GetXmax();
00052 }
00053 else
00054 {
00055 }
00056 TAxis* zax=his->GetZaxis();
00057 if(zax)
00058 {
00059 fdZmin=zax->GetXmin();
00060 fdZmax=zax->GetXmax();
00061 }
00062 else
00063 {
00064 }
00065 fdEntries = his->GetEntries();
00068 Int_t fieldsize=0;
00069
00070
00071 if(his->InheritsFrom(TH1D::Class()))
00072 {
00073 TH1D* dhis=dynamic_cast<TH1D*>(his);
00074 fieldsize=sizeof(Double_t)*dhis->GetSize();
00075 }
00076 else if(his->InheritsFrom(TH1F::Class()))
00077 {
00078 TH1F* fhis=dynamic_cast<TH1F*>(his);
00079 fieldsize=sizeof(Float_t)*fhis->GetSize();
00080 }
00081 else if(his->InheritsFrom(TH1I::Class()))
00082 {
00083 TH1I* ihis=dynamic_cast<TH1I*>(his);
00084 fieldsize=sizeof(Int_t)*ihis->GetSize();
00085 }
00086 else if(his->InheritsFrom(TH1S::Class()))
00087 {
00088 TH1S* shis=dynamic_cast<TH1S*>(his);
00089 fieldsize=sizeof(Short_t)*shis->GetSize();
00090 }
00091 else if(his->InheritsFrom(TH1C::Class()))
00092 {
00093 TH1C* chis=dynamic_cast<TH1C*>(his);
00094 fieldsize=sizeof(Char_t)*chis->GetSize();
00095 }
00096 else if(his->InheritsFrom(TH2D::Class()))
00097 {
00098 TH2D* dhis=dynamic_cast<TH2D*>(his);
00099 fieldsize=sizeof(Double_t)*dhis->GetSize();
00100 }
00101 else if(his->InheritsFrom(TH2F::Class()))
00102 {
00103 TH2F* fhis=dynamic_cast<TH2F*>(his);
00104 fieldsize=sizeof(Float_t)*fhis->GetSize();
00105 }
00106 else if(his->InheritsFrom(TH2I::Class()))
00107 {
00108 TH2I* ihis=dynamic_cast<TH2I*>(his);
00109 fieldsize=sizeof(Int_t)*ihis->GetSize();
00110 }
00111 else if(his->InheritsFrom(TH2S::Class()))
00112 {
00113 TH2S* shis=dynamic_cast<TH2S*>(his);
00114 fieldsize=sizeof(Short_t)*shis->GetSize();
00115 }
00116 else if(his->InheritsFrom(TH2C::Class()))
00117 {
00118 TH2C* chis=dynamic_cast<TH2C*>(his);
00119 fieldsize=sizeof(Char_t)*chis->GetSize();
00120 }
00121 else if(his->InheritsFrom(TH3D::Class()))
00122 {
00123 TH3D* dhis=dynamic_cast<TH3D*>(his);
00124 fieldsize=sizeof(Double_t)*dhis->GetSize();
00125 }
00126 else if(his->InheritsFrom(TH3F::Class()))
00127 {
00128 TH3F* fhis=dynamic_cast<TH3F*>(his);
00129 fieldsize=sizeof(Float_t)*fhis->GetSize();
00130 }
00131 else if(his->InheritsFrom(TH3I::Class()))
00132 {
00133 TH3I* ihis=dynamic_cast<TH3I*>(his);
00134 fieldsize=sizeof(Int_t)*ihis->GetSize();
00135 }
00136 else if(his->InheritsFrom(TH3S::Class()))
00137 {
00138 TH3S* shis=dynamic_cast<TH3S*>(his);
00139 fieldsize=sizeof(Short_t)*shis->GetSize();
00140 }
00141 else if(his->InheritsFrom(TH3C::Class()))
00142 {
00143 TH3C* chis=dynamic_cast<TH3C*>(his);
00144 fieldsize=sizeof(Char_t)*chis->GetSize();
00145 }
00146 fiObjectSize+=fieldsize;
00148
00149 if(allstatistics)
00150 {
00151
00152
00153
00154 fdXmean=his->GetMean(1);
00155 fdYmean=his->GetMean(2);
00156 fdZmean=his->GetMean(3);
00157
00158 fdXrms=his->GetRMS(1);
00159 fdYrms=his->GetRMS(2);
00160 fdZrms=his->GetRMS(3);
00161
00162 }
00163 }
00164 }
00165
00166
00167
00168 TGo4HistogramStatus::TGo4HistogramStatus() : TGo4ObjectStatus(),
00169 fiDim(0),fiNbinX(0), fiNbinY(0), fiNbinZ(0),
00170 fdXmin(0), fdXmax(0), fdYmin(0), fdYmax(0), fdZmin(0), fdZmax(0),
00171 fdEntries(0), fdXmean(0), fdYmean(0), fdZmean(0),
00172 fdXrms(0), fdYrms(0), fdZrms(0)
00173 {
00174 GO4TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus()",__LINE__, __FILE__));
00175
00176 }
00177
00178
00179 TGo4HistogramStatus::~TGo4HistogramStatus()
00180 {
00181 GO4TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus()",__LINE__, __FILE__));
00182
00183 }
00184
00185
00186
00187
00188 Int_t TGo4HistogramStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00189 {
00190 GO4TRACE((12,"TGo4HistogramStatus::PrintStatus()",__LINE__, __FILE__));
00191
00192 if(buflen<=0 && buffer!=0)
00193 return 0;
00194 Int_t locallen=128000;
00195 Text_t localbuf[128000];
00196 Int_t size=0;
00197 Text_t* current=localbuf;
00198 Int_t restlen=locallen;
00199 Int_t delta= TGo4ObjectStatus::PrintStatus(current,restlen);
00200 restlen-=delta;
00201 current+=delta;
00202 current=PrintIndent(current,restlen);
00203 current=PrintBuffer(current,restlen, "G-OOOO-> Histogram Status Class Printout <-OOOO-G\n");
00204 current=PrintIndent(current,restlen);
00205 current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00206
00207 current=PrintIndent(current,restlen);
00208 current=PrintBuffer(current,restlen, " Dimension: \t%d\n",GetDimension());
00209 current=PrintIndent(current,restlen);
00210 current=PrintBuffer(current,restlen, " Bins X: \t%d\n",GetXbins());
00211 current=PrintIndent(current,restlen);
00212 current=PrintBuffer(current,restlen, " X min: \t\t%f\n",GetXmin());
00213 current=PrintIndent(current,restlen);
00214 current=PrintBuffer(current,restlen, " X max: \t\t%f\n",GetXmax());
00215 current=PrintIndent(current,restlen);
00216 current=PrintBuffer(current,restlen, " X mean: \t%f\n",GetXmean());
00217 current=PrintIndent(current,restlen);
00218 current=PrintBuffer(current,restlen, " X rms: \t\t%f\n",GetXrms());
00219 if(GetDimension()>1)
00220 {
00221 current=PrintIndent(current,restlen);
00222 current=PrintBuffer(current,restlen, " Bins Y: \t%d\n",GetYbins());
00223 current=PrintIndent(current,restlen);
00224 current=PrintBuffer(current,restlen, " Y min: \t\t%f\n",GetYmin());
00225 current=PrintIndent(current,restlen);
00226 current=PrintBuffer(current,restlen, " Y max: \t\t%f\n",GetYmax());
00227 current=PrintIndent(current,restlen);
00228 current=PrintBuffer(current,restlen, " Y mean: \t%f\n",GetYmean());
00229 current=PrintIndent(current,restlen);
00230 current=PrintBuffer(current,restlen, " Y rms: \t\t%f\n",GetYrms());
00231 }
00232 else
00233 { }
00234 if(GetDimension()>2)
00235 {
00236 current=PrintIndent(current,restlen);
00237 current=PrintBuffer(current,restlen, " Bins Z: \t%d\n",GetZbins());
00238 current=PrintIndent(current,restlen);
00239 current=PrintBuffer(current,restlen, " Z min: \t\t%f\n",GetZmin());
00240 current=PrintIndent(current,restlen);
00241 current=PrintBuffer(current,restlen, " Z max: \t\t%f\n",GetZmax());
00242 current=PrintIndent(current,restlen);
00243 current=PrintBuffer(current,restlen, " Z mean: \t%f\n",GetZmean());
00244 current=PrintIndent(current,restlen);
00245 current=PrintBuffer(current,restlen, " Z rms: \t\t%f\n",GetZrms());
00246 }
00247 else
00248 { }
00249 current=PrintIndent(current,restlen);
00250 current=PrintBuffer(current,restlen, " N Entries: \t%f\n",GetEntries());
00251 current=PrintIndent(current,restlen);
00252 current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00253 if(buffer==0)
00254 {
00255 std::cout << localbuf << std::endl;
00256 }
00257 else
00258 {
00259 size=locallen-restlen;
00260 if(size>buflen-1)
00261 size=buflen-1;
00262 strncpy(buffer,localbuf,size);
00263 }
00264 return size;
00265 }