00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "TProofLimitsFinder.h"
00021 #include "TProofServ.h"
00022 #include "TSocket.h"
00023 #include "TH1.h"
00024 #include "TMessage.h"
00025 #include "TProofDebug.h"
00026 #include "TError.h"
00027
00028 ClassImp(TProofLimitsFinder)
00029
00030
00031 void TProofLimitsFinder::AutoBinFunc(TString& key,
00032 Double_t& xmin, Double_t& xmax,
00033 Double_t& ymin, Double_t& ymax,
00034 Double_t& zmin, Double_t& zmax)
00035 {
00036
00037
00038
00039 if (!gProofServ) return;
00040
00041 TSocket *s = gProofServ->GetSocket();
00042 TMessage mess(kPROOF_AUTOBIN);
00043
00044 PDB(kGlobal, 2) {
00045 ::Info("TProofLimitsFinder::AutoBinFunc",
00046 "Sending %f, %f, %f, %f, %f, %f", xmin, xmax, ymin, ymax, zmin, zmax);
00047 }
00048 mess << key << xmin << xmax << ymin << ymax << zmin << zmax;
00049
00050 s->Send(mess);
00051
00052 Bool_t notdone = kTRUE;
00053 while (notdone) {
00054 TMessage *answ;
00055 if (s->Recv(answ) <= 0 || !answ)
00056 return;
00057
00058 Int_t what = answ->What();
00059 if (what == kPROOF_AUTOBIN) {
00060 (*answ) >> key >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
00061 notdone = kFALSE;
00062 } else {
00063 Int_t xrc = gProofServ->HandleSocketInput(answ, kFALSE);
00064 if (xrc == -1) {
00065 ::Error("TProofLimitsFinder::AutoBinFunc", "command %d cannot be executed while processing", what);
00066 } else if (xrc == -2) {
00067 ::Error("TProofLimitsFinder::AutoBinFunc", "unknown command %d ! Protocol error?", what);
00068 }
00069 }
00070 delete answ;
00071 }
00072 }
00073
00074
00075 Int_t TProofLimitsFinder::FindGoodLimits(TH1 *h, Axis_t xmin, Axis_t xmax)
00076 {
00077
00078
00079 Double_t dummy = 0;
00080
00081 TString key = h->GetName();
00082 AutoBinFunc(key, xmin, xmax, dummy, dummy, dummy, dummy);
00083
00084 return THLimitsFinder::FindGoodLimits( h, xmin, xmax);
00085 }
00086
00087
00088
00089 Int_t TProofLimitsFinder::FindGoodLimits(TH1 *h, Axis_t xmin, Axis_t xmax, Axis_t ymin, Axis_t ymax)
00090 {
00091
00092
00093 Double_t dummy = 0;
00094
00095 TString key = h->GetName();
00096 AutoBinFunc(key, xmin, xmax, ymin, ymax, dummy, dummy);
00097
00098 return THLimitsFinder::FindGoodLimits( h, xmin, xmax, ymin, ymax);
00099 }
00100
00101
00102
00103 Int_t TProofLimitsFinder::FindGoodLimits(TH1 *h, Axis_t xmin, Axis_t xmax, Axis_t ymin, Axis_t ymax, Axis_t zmin, Axis_t zmax)
00104 {
00105
00106
00107 TString key = h->GetName();
00108 AutoBinFunc(key, xmin, xmax, ymin, ymax, zmin, zmax);
00109
00110 return THLimitsFinder::FindGoodLimits( h, xmin, xmax, ymin, ymax, zmin, zmax);
00111 }