TProofLimitsFinder.cxx

Go to the documentation of this file.
00001 // @(#)root/proofplayer:$Id: TProofLimitsFinder.cxx 26381 2008-11-22 17:15:24Z ganis $
00002 // Author: Maarten Ballintijn   19/04/2002
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TProofLimitsFinder                                                   //
00015 //                                                                      //
00016 // Class to find nice axis limits and synchronize them between workers  //
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    // Get bining information. Send current min and max and receive common
00037    // min max in return.
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    // Find good limits
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    // Find good limits
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    // Find good limits
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 }

Generated on Tue Jul 5 14:52:19 2011 for ROOT_528-00b_version by  doxygen 1.5.1