Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4HistogramStatus.cxx

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

Generated on Fri Nov 28 12:59:28 2008 for Go4-v3.04-1 by  doxygen 1.4.2