Viewing all the elements of member array via Inspect()

Hi,
I have a class derived from TNamed. that works as Eventlist header. Hence I need to view all the
data members and their values by Inspect() method. However when I write this class object to .root file,
I can view all the members except arrays. For arrays. I am able to view only first element in array. How to
Display all the elements in the array through Inspect() method ?

Hi,

can you post the class definition and implementation?

Danilo

Hi,
I am sending all the files as tarball . Do make and then execute ./testMRayTracer.
I was quering about the , RIGHT CLICK Inspect(), when .root file is viewed in TBrowser

Will I have to override Inspect() method ?
I hope not …

Hi,

Do you want to expand all the collections content in the inspect canvas? I’m not sure how to properly do that in the case one has lets say millions of entries…

Cheers, Bertrand.

Yes… That is what I would like to do. But instead of collections I have basic data type arrays with let’s say entries in order of 100…
I not in Inspect canvas then is there some other way ??

Hi,

You can implement your own context menu. For example, something like this:
In your MRayTracer.h, add those definitions:

const Double_t *Getxdpix() const { return xdpix; } const Double_t *Getydpix() const { return ydpix; } void InspectArray(const char *array_name, Int_t n); // *MENU*
And in MRayTracer.cxx:

void MRayTracer::InspectArray(const char *array_name, Int_t n=100) { double *array = (double *)gROOT->ProcessLine( Form("((MRayTracer *)0x%lx)->Get%s()", (ULong_t)this, array_name) ); if (array == 0) return; if (n > npixel) n = npixel; for (int i=0;i<n;++i) { cout << array_name << "[" << i << "] = " << array[i] << endl; } } Then you will have a “InspectArray” context menu on your class (in the browser) popping-up a dialog where you can give the array name (e.g. xdpix) and the number of points to display on the terminal. Feel free to modify the code to fulfill your needs

Cheers, Bertrand.