[ROOT] dynamically allocating histograms

From: jcfree@socrates.Berkeley.EDU
Date: Thu Jul 26 2001 - 02:49:55 MEST


Hi everyone, 

	I'm currently writing a simple standalone executable for MSVC++ 6
using ROOT 3.01/05. In the program I've designed a class which contains a
pointer to a TH2D histo, set to NULL in the constructor. During
the execution of the program, a user can request that this histogram data
member be dynamically allocated, i.e., my class contains a member function
w/ the
code

fMyClassHisto = new
TH2D("histo","histo",userXbins,0,userXbins,userYbins,0,userYbins);

Then, in the same function, data is read in to the histogram via
"fMyClassHisto->SetBinContent(x,y, userData)"

Here's where the problem comes in: I want other member functions of my
class to use the information in the (now initialized) histogram. Normally,
the "new" operator is supposed to make an object persistent until "delete"
is called; however, using TStorage I discovered that what "new" does in
this case is NOT set aside a chunk of heap memory large enough to preserve
the binned values, but only 624 bytes, apparently the size of an
unfilled TH2D histogram. So, when I exit the member function in which
fMyClassHisto is filled, the bin contents get written over. My question
is: is there
some way to make the entire histogram -- not just the 624 bytes but also
all the bin values -- persistent in memory until delete is called?



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