Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4StatusAnalysis/TGo4HistogramStatus.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4HistogramStatus.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TH2.h"
00021 #include "TH3.h"
00022 
00023 #include "Go4Log/TGo4Log.h"
00024 
00025 TGo4HistogramStatus::TGo4HistogramStatus(TH1* his, Bool_t allstatistics)
00026 : TGo4ObjectStatus(his, allstatistics),
00027 fiDim(0),fiNbinX(0), fiNbinY(0), fiNbinZ(0),
00028 fdXmin(0), fdXmax(0), fdYmin(0), fdYmax(0), fdZmin(0), fdZmax(0),
00029 fdEntries(0), fdXmean(0), fdYmean(0), fdZmean(0),
00030 fdXrms(0), fdYrms(0), fdZrms(0)
00031 {
00032    TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus(TH1*)",__LINE__, __FILE__));
00033 
00034    if(his!=0)
00035       {
00036          fiDim=his->GetDimension();
00037          fiNbinX=his->GetNbinsX();
00038          fiNbinY=his->GetNbinsY();
00039          fiNbinZ=his->GetNbinsZ();
00040          TAxis* xax=his->GetXaxis();
00041          if(xax)
00042             {
00043                fdXmin=xax->GetXmin();
00044                fdXmax=xax->GetXmax();
00045             }
00046          else
00047             { // values already initialized as zero
00048             }
00049          TAxis* yax=his->GetYaxis();
00050          if(yax)
00051             {
00052                fdYmin=yax->GetXmin();
00053                fdYmax=yax->GetXmax();
00054             }
00055          else
00056             { // values already initialized as zero
00057             }
00058          TAxis* zax=his->GetZaxis();
00059          if(zax)
00060             {
00061                fdZmin=zax->GetXmin();
00062                fdZmax=zax->GetXmax();
00063             }
00064          else
00065             { // values already initialized as zero
00066             }
00067          fdEntries = his->GetEntries();
00070          Int_t fieldsize=0;
00071          // because of multiple inheritance of histogram types, we
00072          // must check for all types separately to downcast the correct TArray:
00073          if(his->InheritsFrom("TH1D"))
00074             {
00075                 TH1D* dhis=dynamic_cast<TH1D*>(his);
00076                 fieldsize=sizeof(Double_t)*dhis->GetSize(); // method of TArray baseclass
00077             }
00078          else if(his->InheritsFrom("TH1F"))
00079             {
00080                 TH1F* fhis=dynamic_cast<TH1F*>(his);
00081                 fieldsize=sizeof(Float_t)*fhis->GetSize(); // method of TArray baseclass
00082             }
00083          else if(his->InheritsFrom("TH1I"))
00084             {
00085                 TH1I* ihis=dynamic_cast<TH1I*>(his);
00086                 fieldsize=sizeof(Int_t)*ihis->GetSize(); // method of TArray baseclass
00087             }
00088           else if(his->InheritsFrom("TH1S"))
00089             {
00090                 TH1S* shis=dynamic_cast<TH1S*>(his);
00091                 fieldsize=sizeof(Short_t)*shis->GetSize(); // method of TArray baseclass
00092             }
00093          else if(his->InheritsFrom("TH1C"))
00094             {
00095                 TH1C* chis=dynamic_cast<TH1C*>(his);
00096                 fieldsize=sizeof(Char_t)*chis->GetSize(); // method of TArray baseclass
00097             }
00098          else if(his->InheritsFrom("TH2D"))
00099             {
00100                 TH2D* dhis=dynamic_cast<TH2D*>(his);
00101                 fieldsize=sizeof(Double_t)*dhis->GetSize(); // method of TArray baseclass
00102             }
00103          else if(his->InheritsFrom("TH2F"))
00104             {
00105                 TH2F* fhis=dynamic_cast<TH2F*>(his);
00106                 fieldsize=sizeof(Float_t)*fhis->GetSize(); // method of TArray baseclass
00107             }
00108          else if(his->InheritsFrom("TH2I"))
00109             {
00110                 TH2I* ihis=dynamic_cast<TH2I*>(his);
00111                 fieldsize=sizeof(Int_t)*ihis->GetSize(); // method of TArray baseclass
00112             }
00113           else if(his->InheritsFrom("TH2S"))
00114             {
00115                 TH2S* shis=dynamic_cast<TH2S*>(his);
00116                 fieldsize=sizeof(Short_t)*shis->GetSize(); // method of TArray baseclass
00117             }
00118          else if(his->InheritsFrom("TH2C"))
00119             {
00120                 TH2C* chis=dynamic_cast<TH2C*>(his);
00121                 fieldsize=sizeof(Char_t)*chis->GetSize(); // method of TArray baseclass
00122             }
00123          else if(his->InheritsFrom("TH3D"))
00124             {
00125                 TH3D* dhis=dynamic_cast<TH3D*>(his);
00126                 fieldsize=sizeof(Double_t)*dhis->GetSize(); // method of TArray baseclass
00127             }
00128          else if(his->InheritsFrom("TH3F"))
00129             {
00130                 TH3F* fhis=dynamic_cast<TH3F*>(his);
00131                 fieldsize=sizeof(Float_t)*fhis->GetSize(); // method of TArray baseclass
00132             }
00133          else if(his->InheritsFrom("TH3I"))
00134             {
00135                 TH3I* ihis=dynamic_cast<TH3I*>(his);
00136                 fieldsize=sizeof(Int_t)*ihis->GetSize(); // method of TArray baseclass
00137             }
00138           else if(his->InheritsFrom("TH3S"))
00139             {
00140                 TH3S* shis=dynamic_cast<TH3S*>(his);
00141                 fieldsize=sizeof(Short_t)*shis->GetSize(); // method of TArray baseclass
00142             }
00143          else if(his->InheritsFrom("TH3C"))
00144             {
00145                 TH3C* chis=dynamic_cast<TH3C*>(his);
00146                 fieldsize=sizeof(Char_t)*chis->GetSize(); // method of TArray baseclass
00147             }
00148          fiObjectSize+=fieldsize; // add heap field to object stack memory size
00150 
00151          if(allstatistics)
00152          {
00153          // note: we do not calculate statistic for nameslist
00154          // slows down when processing empty 2d histos!
00155          //cout <<"\t" <<GetName()<<" calculating mean/rms..." << endl;
00156          fdXmean=his->GetMean(1);
00157          fdYmean=his->GetMean(2);
00158          fdZmean=his->GetMean(3);
00159          //cout <<"\t"<<GetName()<<" finished mean." << endl;
00160          fdXrms=his->GetRMS(1);
00161          fdYrms=his->GetRMS(2);
00162          fdZrms=his->GetRMS(3);
00163          //cout <<"\t"<<GetName()<<" finished rms." << endl;
00164          }
00165          else
00166           {
00167              //cout <<"\t"<<GetName()<<" without statistics!" << endl;
00168           }
00169       }
00170    else
00171       {
00172 
00173 
00174       } //if(his!=0)
00175 }
00176 
00177 
00178 
00179 TGo4HistogramStatus::TGo4HistogramStatus() : TGo4ObjectStatus(),
00180 fiDim(0),fiNbinX(0), fiNbinY(0), fiNbinZ(0),
00181 fdXmin(0), fdXmax(0), fdYmin(0), fdYmax(0), fdZmin(0), fdZmax(0),
00182 fdEntries(0), fdXmean(0), fdYmean(0), fdZmean(0),
00183 fdXrms(0), fdYrms(0), fdZrms(0)
00184 {
00185 TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus()",__LINE__, __FILE__));
00186 
00187 }
00188 
00189 
00190 TGo4HistogramStatus::~TGo4HistogramStatus()
00191 {
00192 TRACE((14,"TGo4HistogramStatus::TGo4HistogramStatus()",__LINE__, __FILE__));
00193 
00194 }
00195 
00196 Int_t TGo4HistogramStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00197 {
00198    TRACE((12,"TGo4HistogramStatus::PrintStatus()",__LINE__, __FILE__));
00199    //
00200    if(buflen<=0 && buffer!=0)
00201       return 0;
00202    Int_t locallen=128000;
00203    Text_t localbuf[locallen];
00204    Int_t size=0;
00205    Text_t* current=localbuf;
00206    Int_t restlen=locallen;
00207    Int_t delta= TGo4ObjectStatus::PrintStatus(current,restlen);
00208    restlen-=delta;
00209    current+=delta;
00210    current=PrintIndent(current,restlen);
00211    current=PrintBuffer(current,restlen, "G-OOOO-> Histogram Status Class Printout <-OOOO-G\n");
00212    current=PrintIndent(current,restlen);
00213    current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00214    // put printout of histogram infos here:
00215    current=PrintIndent(current,restlen);
00216    current=PrintBuffer(current,restlen, " Dimension: \t%d\n",GetDimension());
00217    current=PrintIndent(current,restlen);
00218    current=PrintBuffer(current,restlen, " Bins X: \t%d\n",GetXbins());
00219    current=PrintIndent(current,restlen);
00220    current=PrintBuffer(current,restlen, " X min: \t\t%f\n",GetXmin());
00221    current=PrintIndent(current,restlen);
00222    current=PrintBuffer(current,restlen, " X max: \t\t%f\n",GetXmax());
00223    current=PrintIndent(current,restlen);
00224    current=PrintBuffer(current,restlen, " X mean: \t%f\n",GetXmean());
00225    current=PrintIndent(current,restlen);
00226    current=PrintBuffer(current,restlen, " X rms: \t\t%f\n",GetXrms());
00227    if(GetDimension()>1)
00228       {
00229          current=PrintIndent(current,restlen);
00230          current=PrintBuffer(current,restlen, " Bins Y: \t%d\n",GetYbins());
00231          current=PrintIndent(current,restlen);
00232          current=PrintBuffer(current,restlen, " Y min: \t\t%f\n",GetYmin());
00233          current=PrintIndent(current,restlen);
00234          current=PrintBuffer(current,restlen, " Y max: \t\t%f\n",GetYmax());
00235          current=PrintIndent(current,restlen);
00236          current=PrintBuffer(current,restlen, " Y mean: \t%f\n",GetYmean());
00237          current=PrintIndent(current,restlen);
00238          current=PrintBuffer(current,restlen, " Y rms: \t\t%f\n",GetYrms());
00239       }
00240    else
00241       { }
00242    if(GetDimension()>2)
00243       {
00244          current=PrintIndent(current,restlen);
00245          current=PrintBuffer(current,restlen, " Bins Z: \t%d\n",GetZbins());
00246          current=PrintIndent(current,restlen);
00247          current=PrintBuffer(current,restlen, " Z min: \t\t%f\n",GetZmin());
00248          current=PrintIndent(current,restlen);
00249          current=PrintBuffer(current,restlen, " Z max: \t\t%f\n",GetZmax());
00250          current=PrintIndent(current,restlen);
00251          current=PrintBuffer(current,restlen, " Z mean: \t%f\n",GetZmean());
00252          current=PrintIndent(current,restlen);
00253          current=PrintBuffer(current,restlen, " Z rms: \t\t%f\n",GetZrms());
00254       }
00255    else
00256       { }
00257    current=PrintIndent(current,restlen);
00258    current=PrintBuffer(current,restlen, " N Entries: \t%f\n",GetEntries());
00259    current=PrintIndent(current,restlen);
00260    current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00261   if(buffer==0)
00262       {
00263           cout << localbuf << endl;
00264       }
00265    else
00266       {
00267          size=locallen-restlen;
00268          if(size>buflen-1)
00269                size=buflen-1;
00270          strncpy(buffer,localbuf,size);
00271       }
00272    return size;
00273 }
00274 
00275 ClassImp(TGo4HistogramStatus)
00276 
00277 
00278 
00279 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:05 2005 for Go4-v2.10-5 by doxygen1.2.15