Re: [ROOT] online histo-display

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Feb 26 2001 - 17:48:52 MET


Hi Wen,

Add the line
  gPad->Update();
after your line h->Draw();

Rene Brun

Mei Wen wrote:
> 
> Dear rooters,
>    I have an online histogram need to be displayed and it has been done in
> a right way. But for some reason which I don't know I am not able to
> update the histogram with the Update function of TH1 class. In order to
> update the histogram on corrent pad I have to delete and then recreate the
> Canvas. My source code is as following. Could you give me any help?
> --------------------------------------------------------------------------
> 
> Tcanvas *smap;
> 
>   smap = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(obj->GetName());
> 
>   if (smap) {
> // hope not delete smap if already exist
>     smap->Delete();
>     smap = new TCanvas(obj->GetName(), obj->GetName());
> //
>   } else {
>     smap = new TCanvas(obj->GetName(), obj->GetName());
>   }
>         smap->cd();
> 
>         objs = gDirectory->Get(obj->GetName());
> 
>         if (objs) {
> 
>           if (objs->IsA() == TH1F::Class()) {
> 
> //__________Get histo from host
> 
>              netm = SDPtr->GetNMPtr();
>              if (netm) {
> 
>                netm->sendget((char*)objs->GetName(), smap);
> 
>                smap->Update();
>              }
> //
>           }
>         }
> 
> /**********************************************************/
> void NetManager::sendget(char* hname, TPad *fig)
> /**********************************************************/
> {
>   TMessage* mess;
>   int len;
> 
>   // the client tells the server the histo name
> 
>   socket->Send(hname, kMESS_STRING);
>   // now it receives such histo
>   len = socket->Recv(mess);
>   if (len<=0)
>     {
>       cout << "ERROR in Recv histogram!" << endl;
>     }
>   else
>     {
>       if (mess->What() == kMESS_OBJECT) {
>           //char answer[3];
> 
>            if (mess->IsA() == TH1F::Class()){
>              TH1F *h = (TH1F*) mess->ReadObject(mess->GetClass());
>              fig->cd();
>              h->Draw();
> 
>            }
> 
>       } else if (mess->What() == kMESS_STRING){
>         char str[64];
>         mess->ReadString(str, 64);
>         cout << "ERROR: " << str <<  endl;
>       }
>       delete mess;
>     }
> }
> 
> MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
>                             M
>    Wen    Mei               M
>                             M
>  DAQ-KLOE-LNF-INFN          M
>  via E. Fermi 40            M
>  I-00044 Frascati (RM)      W
>  Italy                      W
>                             W
>  tel: 94032753              W
>                             W
> WWWWWWWWWWWWWWWWWWWWWWWWWWWWW



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET