On 14 May 98 at 11:48, Hans Wenzel wrote: It is C++ scope problem. You defined the hpx object(s) inside of one scope and tried to use it within another one. It made no sense with the CINT interpreter since if one doesn't supply any definition, ROOT (CINT) defines the global object of the proper type alone. But one should avoid this CINT feature to be able to compile his macro code with a "native" compiler. So to be compiled your code should looks as follow (this is Ok for ROOT/CINT as well) > > > #include "TROOT.h" > #include "TApplication.h" > #include "TCanvas.h" > #include "TLine.h" > #include "TPaveLabel.h" > #include "TFile.h" > #include "TH1.h" > #include "TH2.h" > #include "TProfile.h" > #include "TNtuple.h" > #include "TRandom.h" > #include "TSocket.h" > #include "TServerSocket.h" > #include "TInetAddress.h" > #include "TPad.h" > #include "TMessage.h" > #include "TMonitor.h" > #include "TBenchmark.h" > > int main() > { > TROOT hclient("hclient","Test of simple histogram client"); > > gROOT->Reset(); > > gBenchmark->Start("hclient"); > > // Open connection to server > TSocket *sock = new TSocket("localhost", 9090); > > // Wait till we get the start message > char str[32]; > sock->Recv(str, 32); > > // server tells us who we are > int idx = !strcmp(str, "go 0") ? 0 : 1; TH1F *h1px = 0; TH2F *h2px = 0; > if (idx == 0) { > // Create the histogram h1px = new TH1F("hpx","This is the px > TH1F *hpx = new TH1F("hpx","This is the px > distribution",100,-4,4); // hpx->SetFillColor(48); // > set nice fillcolor > } else { h2px = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); > TH2F *hpx = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); > } > > TMessage mess(kMESS_OBJECT); > //TMessage mess(kMESS_OBJECT | kMESS_ACK); > > // Fill histogram randomly > gRandom->SetSeed(); > Float_t px, py; > const int kUPDATE = 1000; > for (int i = 0; i < 25000; i++) { > gRandom->Rannor(px,py); > if (idx == 0) h1px->Fill(px); > hpx->Fill(px); > else h2px->Fill(px,py); > hpx->Fill(px,py); > if (i && (i%kUPDATE) == 0) { > mess.Reset(); // re-use TMessage object > mess.WriteObject(hpx); // write object in message > buffer sock->Send(mess); // send message > } > } > sock->Send("Finished"); // tell server we are finished > > gBenchmark->Show("hclient"); > > // Close the socket > sock->Close(); > > > > return 0; > } > ================================================================= Dr. Valeri Faine (Fine) ------------------- Phone: +1 516 344 7806 Brookhaven National Laboratory FAX : +1 516 344 4206 Bldg. 510A /STAR mailto:fine@bnl.gov Upton, New York, 11973-5000 http://nicewww.cern.ch/~fine USA Dr. Valery Fine Telex : 911621 dubna su ----------- LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80 141980 Dubna, Moscow region Fax : +7 09621 6 51 45 Russia mailto:fine@main1.jinr.dubna.su
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET