Re: [ROOT] Update a projection

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat May 10 2003 - 18:03:17 MEST


Hi Thomas,

In the current version in CVS, I have extended the functionality
of TH2::ProjectionX,Y and ProfileX,Y.
If the projection already exists in the pad or current directory,
the projection is reset and filled again with the current contents
of the TH2. 

With this new functionality it is now trivial to implement what
you required by using a TExec object. Example
  TH2F *h2; //an existing 2-d histogram with name "h2"

  TCanvas c1;
  TExec ex1("ex1","h2->ProjectionX(\"px\",-1,-1,\"d\");")
  ex1.Draw();

  now in your loop, you fill h2 and at regular intervals, you
  c1->Modified();
  The TExec::Paint function will automatically execute the
  instruction specified in the constructor. The projection "px"
  will be recomputed and drawn.

Note that the TExec class can be used to execute objects
while painting the pad. This is quite powerful. An alternative
solution would be to use the signal/slots mechanism. However,
the TExec solution has the advantage that it will also work
in a batch program.

Rene Brun


On Fri, 
9 
May 2003, Thomas Bretz wrote:

> Hi all,
> 
> I have some kind of online display in which I can display histograms
> (TH?D drawn in a TRootEmbeddedCanvas). When our calculation is filling
> the histogram I update the histogram continously (let's say each 5sec)
> by calling pad->Modified() pad->Update() for the corresponding pad. This
> works fine for the histograms we fill ourself, but how can I provide
> online update of Projections of 2D histograms? I don't want to rebuild
> the object every time. In principal it would be enough if I could update
> the contants of a projection from the contants of its 'parent'
> histogram. Any idea how I can do this (without Copy&Paste the code from
> TH2::Project to my code)?
> 
> Thanks in advance,
> Thomas.
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET