I have two objectives relating to some new classes I am adding to use with the root framework. I have defined a new class called bx_event that stores two sets of data read from the digitizer. I am saving these bx_events into a root TFile (later will be putting in TTree). I am wondering whether there is a way that when I view these object in TBrowser that I can write some code so that when I double click on a bx_event object it will draw a graph for each of the data sets in the object (much the same way that I can click on a histogram in TBrowser and bring up a visual representation of the histogram). What would I need to do to achieve this?
Also, I am experimenting with the XML interface. I have defined a new class I call setup that stores certain setup data relating to the housekeeping data for our experiment. I then generate a dictionary for this class and generate an XML file. I note in the XML file that the member variable names do not show up as XML tags. However, I would like this to happen so that I can easily parse and search in this file for editing purposes. Is there a way to achieve this?
Thanks in advance.
a quick answer before you get a more official one, on your TBrowser question:
There are two possible ways of implementing this; which one is easier depends on the implementation of your class. You can either put the class into a non-split branch, and overload TObject’s Browse method. Or you can write a method that returns the appropriate values, if the number of objects in the branch is equivalent to the number of data sets on your class (i.e. if the branch containing your class is split). In the current cvs version of root one can double click methods and fill histos with their return values.
Axel has answered the first part of your question
-implement bx_event::Browse (see examples in ROOT classes like
-or better make a TTree with your class and you should be able to
automatically loop on all entries.
Concerning XML, I do not understand. By default, you should see the name of the data members in the file. Which version are you using?
Are you defining some special settings. See:
For example, when drawing an histogram in a canvas c1 and saving the canvas to an xml file
you get a file with (I show only the beginning)
The object I was writing as xml was my own class derived from TObject. I created a dictionary and linked against the dictionary when I compiled. When I looked at the file, I saw the individual values stored in the objects but not the names themselves. Should this work on classes one derives from TObject?
Sure, it shoul;d work on your own classes too.
Did you really generate the dictionary? Did you specify the "+"
in the pragma statement of your LinkDef.h file?
Perhaps my LinkDef file is incorrect. Here is what I have. Please tell me what might be wrong. How come this LinkDef file was sufficient for setting up signals and slots if it isn’t generating the dictionary?
To be honest I don’t really understand how the LinkDef file is used. I am not familiar with the pragma statement. Any guidance on this would be greatly appreciated.
Ok. Here it is:
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pramga link C++ class bx_event;
You have a typo and the “+” missing
#pramga link C++ class bx_event;
it should be
#pragma link C++ class bx_event+;
Thank you. That fixed it and it works now. Thanks for your help as always.
Thanks for your help on setting up TBrowse. However, I am having some problems.
I am not using treesI have overloaded TBrowse in my new class xEvent.h. For test purposes I left the overloaded function blank (i.e., it doesn’t do anything). However, now when I double-click on an object that I have in a Tfile, I get a crash (segmentation violation). What might I be doing wrong here?
overloading void TObject::Browse(TBrowser *b) should work in your case - you can check TH1::Browse as an example. You load the library defining your class, then open the file and a TBrowser, double click on your xEvent and get a segv? Can you post your root version and a traceback of the segv?