Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TProofLimitsFinder.cxx
Go to the documentation of this file.
1 // @(#)root/proofplayer:$Id$
2 // Author: Maarten Ballintijn 19/04/2002
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TProofLimitsFinder
13 \ingroup proofkernel
14 
15 Class to find axis limits and synchronize them between workers
16 
17 */
18 
19 #include "TProofLimitsFinder.h"
20 #include "TProofServ.h"
21 #include "TSocket.h"
22 #include "TH1.h"
23 #include "TMessage.h"
24 #include "TProofDebug.h"
25 #include "TError.h"
26 
27 ClassImp(TProofLimitsFinder);
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Get bining information. Send current min and max and receive common
31 /// min max in return.
32 
33 void TProofLimitsFinder::AutoBinFunc(TString& key,
34  Double_t& xmin, Double_t& xmax,
35  Double_t& ymin, Double_t& ymax,
36  Double_t& zmin, Double_t& zmax)
37 {
38  if (!gProofServ) return;
39 
40  TSocket *s = gProofServ->GetSocket();
41  TMessage mess(kPROOF_AUTOBIN);
42 
43  PDB(kGlobal, 2) {
44  ::Info("TProofLimitsFinder::AutoBinFunc",
45  "Sending %f, %f, %f, %f, %f, %f", xmin, xmax, ymin, ymax, zmin, zmax);
46  }
47  mess << key << xmin << xmax << ymin << ymax << zmin << zmax;
48 
49  s->Send(mess);
50 
51  Bool_t notdone = kTRUE;
52  while (notdone) {
53  TMessage *answ;
54  if (s->Recv(answ) <= 0 || !answ)
55  return;
56 
57  Int_t what = answ->What();
58  if (what == kPROOF_AUTOBIN) {
59  (*answ) >> key >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
60  notdone = kFALSE;
61  } else {
62  Int_t xrc = gProofServ->HandleSocketInput(answ, kFALSE);
63  if (xrc == -1) {
64  ::Error("TProofLimitsFinder::AutoBinFunc", "command %d cannot be executed while processing", what);
65  } else if (xrc == -2) {
66  ::Error("TProofLimitsFinder::AutoBinFunc", "unknown command %d ! Protocol error?", what);
67  }
68  }
69  delete answ;
70  }
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Find good limits
75 
76 Int_t TProofLimitsFinder::FindGoodLimits(TH1 *h, Axis_t xmin, Axis_t xmax)
77 {
78  Double_t dummy = 0;
79 
80  TString key = h->GetName();
81  AutoBinFunc(key, xmin, xmax, dummy, dummy, dummy, dummy);
82 
83  return THLimitsFinder::FindGoodLimits( h, xmin, xmax);
84 }
85 
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Find good limits
89 
90 Int_t TProofLimitsFinder::FindGoodLimits(TH1 *h, Axis_t xmin, Axis_t xmax, Axis_t ymin, Axis_t ymax)
91 {
92  Double_t dummy = 0;
93 
94  TString key = h->GetName();
95  AutoBinFunc(key, xmin, xmax, ymin, ymax, dummy, dummy);
96 
97  return THLimitsFinder::FindGoodLimits( h, xmin, xmax, ymin, ymax);
98 }
99 
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 /// Find good limits
103 
104 Int_t TProofLimitsFinder::FindGoodLimits(TH1 *h, Axis_t xmin, Axis_t xmax, Axis_t ymin, Axis_t ymax, Axis_t zmin, Axis_t zmax)
105 {
106  TString key = h->GetName();
107  AutoBinFunc(key, xmin, xmax, ymin, ymax, zmin, zmax);
108 
109  return THLimitsFinder::FindGoodLimits( h, xmin, xmax, ymin, ymax, zmin, zmax);
110 }