00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4ComCreateHistogram.h"
00017
00018 #include "TROOT.h"
00019 #include "TH1.h"
00020
00021 #include "Go4Log/TGo4Log.h"
00022 #include "Go4Analysis/TGo4AnalysisImp.h"
00023 #include "Go4AnalysisClient/TGo4AnalysisClientImp.h"
00024
00025 TGo4ComCreateHistogram::TGo4ComCreateHistogram(const char* obname, const char* classname)
00026 :TGo4ComCreateObject(obname,classname)
00027 {
00028 TRACE((12,"TGo4ComCreateHistogram::TGo4ComCreateHistogram(Text_t*,..) ctor",__LINE__, __FILE__));
00029 SetName("ANCreateHisto");
00030 fxHistoStatus.SetName(obname);
00031 }
00032
00033 TGo4ComCreateHistogram::TGo4ComCreateHistogram() : TGo4ComCreateObject()
00034 {
00035 TRACE((12,"TGo4ComCreateHistogram::TGo4ComCreateHistogram() ctor",__LINE__, __FILE__));
00036 SetName("ANCreateHisto");
00037 }
00038
00039
00040 TGo4ComCreateHistogram::~TGo4ComCreateHistogram()
00041 {
00042 TRACE((12,"TGo4ComCreateHistogram::~TGo4ComCreateHistogram() dtor",__LINE__, __FILE__));
00043 }
00044
00045 Int_t TGo4ComCreateHistogram::ExeCom()
00046 {
00047 TRACE((12,"TGo4ComCreateHistogram::ExeCom()",__LINE__, __FILE__));
00048
00049 TGo4Analysis* ana=0;
00050 TGo4AnalysisClient* cli=dynamic_cast<TGo4AnalysisClient*> (fxReceiverBase);
00051 if(cli)
00052 {
00053 ana=TGo4Analysis::Instance();
00054 if(ana)
00055 {
00056 TObject* ob=0;
00057 TH1* his=dynamic_cast<TH1*> (CreateObject());
00058 if(his)
00059 {
00060 his->SetName(fxHistoStatus.GetName());
00061 his->SetTitle(fxHistoStatus.GetTitle());
00062 his->SetDirectory(gROOT);
00063
00064 TAxis* yax=his->GetYaxis();
00065 TAxis* zax=his->GetZaxis();
00066 Int_t dimension=fxHistoStatus.GetDimension();
00067 switch(dimension)
00068 {
00069 case 1:
00070 yax->Set(1,0.,1.);
00071 his->SetBins(fxHistoStatus.GetXbins(),
00072 fxHistoStatus.GetXmin(),
00073 fxHistoStatus.GetXmax());
00074 break;
00075 case 2:
00076
00077 yax->Set(1,0.,1.);
00078 zax->Set(1,0.,1.);
00079 his->SetBins(fxHistoStatus.GetXbins(),
00080 fxHistoStatus.GetXmin(),
00081 fxHistoStatus.GetXmax(),
00082 fxHistoStatus.GetYbins(),
00083 fxHistoStatus.GetYmin(),
00084 fxHistoStatus.GetYmax());
00085 break;
00086
00087 case 3:
00088 yax->Set(1,0.,1.);
00089 zax->Set(1,0.,1.);
00090 his->SetBins(fxHistoStatus.GetXbins(),
00091 fxHistoStatus.GetXmin(),
00092 fxHistoStatus.GetXmax(),
00093 fxHistoStatus.GetYbins(),
00094 fxHistoStatus.GetYmin(),
00095 fxHistoStatus.GetYmax(),
00096 fxHistoStatus.GetZbins(),
00097 fxHistoStatus.GetZmin(),
00098 fxHistoStatus.GetZmax());
00099 break;
00100
00101 default:
00102 cli->SendStatusMessage(3, kFALSE,"ERROR on creating new histogram %s: no dimension specified !!! ",
00103 GetObjectName());
00104 delete his;
00105 return 1;
00106 break;
00107
00108 }
00109
00110 Bool_t ok=ana->AddHistogram(his);
00111 if(ok)
00112 {
00113 his->SetBit(TGo4Status::kGo4CanDelete);
00114 cli->SendStatusMessage(1, kFALSE,"Added new histogram %s to Go4 folders.",
00115 GetObjectName());
00116 }
00117 else
00118 {
00119 cli->SendStatusMessage(3, kFALSE,"ERROR on adding new histogram %s ",
00120 GetObjectName());
00121 delete his;
00122 }
00123
00124 }
00125 else
00126 {
00127 cli->SendStatusMessage(3, kFALSE,"ERROR on creating new histogram %s ",
00128 GetObjectName());
00129 delete ob;
00130 }
00131
00132 }
00133 else
00134 {
00135 cli->SendStatusMessage(3, kTRUE," %s ERROR no analysis",
00136 GetName());
00137 }
00138
00139
00140
00141 }
00142 else
00143 {
00144 TRACE((11,"TGo4ComCreateHistogram::ExeCom() - no receiver specified ERROR!",__LINE__, __FILE__));
00145 TGo4Log::Debug(" !!! ComInitAnalysis ''%s'': NO RECEIVER ERROR!!!",GetName());
00146 return 1;
00147 }
00148
00149 return -1;
00150 }
00151
00152