MakeProxy questions & Problems (5.14/5.17.02)

Hi,
I’m having some trouble with TTree::MakeProxy.

  1. I couldn’t find documentation for it in the user’s guide, in comments online or in the auto generated documentation. Is that right?

  2. If I want to use it as a base for analysis, and run it from a program rather than load it in a root command line (i.e. I want to draw multiple things), what is the standard way people do this? I ended up running MakeProxy, and then subclassing it and putting my code in the subclass.

  3. In 5.17/02, on Windows, I ran make proxy as below and got the below result:

root [1] CollectionTree->MakeProxy("testProxy", "doit.h") Error: C++ exception caught (tmpfile)(1) (Int_t)(0) *** Interpreter error recovered ***
I don’t have access to 5.17/02 on Linux, so I can’t tell if this is a ROOT problem or a Linux problem.

  1. I ran MakeProxy in 5.14 and it failed to produce good code when it encountered vector and vector<vector >. I see that the first type will be correctly supported in 5.17 (a notice in the forum from P. Canal - thanks!). Will the vector> be supported?

  2. I modified the code that came out of 5.16 in order to work with vector (not too difficult). But I couldn’t figure out how to make the array’s auto load - the first event was always empty. Actually, in general, if I want to adjust a MakeProxy to support a datatype it doesn’t normally support, what code do I need to write?

  3. When I did the above I used doit.h as the method. When I look at the source file that resulted (see testProxy.h below) in 5.16, it looks like doit.h is included twice – once at the top of the file and again to inject the code into the class. Is this because I didn’t use MakeProxy correctly or is this a bug? (or is it fixed now in 5.17!).

  4. The second argument to MakeProxy has a default value of “NULL” – but if you only give MakeProxy the output class name you’ll get an error - you have to give that second argument, it seems. So perhaps that second argument shouldn’t have a default value?

Ok… I think that is it. :slight_smile: If I need to update my versino of root to get this working, that is fine; I’ll do it… just don’t want to upset a nicely working environment until I know…

Many thanks for help and suggestions!

Cheers,
Gordon.

P.S. You can find a copy of the root file I used to run MakeProxy on at the following location:
d0.phys.washington.edu/~gwatts/t … 00001.root
(in about 5 minutes).
testProxy.h (43.7 KB)

[quote]1) I couldn’t find documentation for it in the user’s guide, in comments online or in the auto generated documentation. Is that right? [/quote]Partially. Currently the documentation is only in the reference guide (root.cern.ch/root/html/TTree.htm … :MakeProxy).

[quote]2) If I want to use it as a base for analysis, and run it from a program rather than load it in a root command line (i.e. I want to draw multiple things), what is the standard way people do this? I ended up running MakeProxy, and then subclassing it and putting my code in the subclass. [/quote]It is a possible use. However the recommended use is to write your code into the file doit.C and doit.h. In order to fit the whole thing in a standard build system, you also should write a simple testProxy.C which only include testProxy.h.

[quote]3) In 5.17/02, on Windows, I ran make proxy as below and got the below result: [/quote]I don’t know :slight_smile: What is the debugger saying? To investigate I would need one more important part (the doit.C).

[quote]4) I ran MakeProxy in 5.14 and it failed to produce good code when it encountered vector and vector<vector >. I see that the first type will be correctly supported in 5.17 (a notice in the forum from P. Canal - thanks!). Will the vector> be supported? [/quote]It should be.

[quote]5) I modified the code that came out of 5.16 in order to work with vector (not too difficult). But I couldn’t figure out how to make the array’s auto load - the first event was always empty. Actually, in general, if I want to adjust a MakeProxy to support a datatype it doesn’t normally support, what code do I need to write? [/quote]It is non trivial :slight_smile:
and required the addition of new helper classes (see checkins). You might be able to import the code from 5.17/02 … but then again it might just be easier to use 5.17/02 :slight_smile:

[quote]
6) When I did the above I used doit.h as the method. When I look at the source file that resulted (see testProxy.h below) in 5.16, it looks like doit.h is included twice – once at the top of the file and again to inject the code into the class. Is this because I didn’t use MakeProxy correctly or is this a bug? (or is it fixed now in 5.17!). [/quote]
I guess it is somewhat of a bug … the intent is that you create the MakeProxy around a .C (or .cxx or .cpp) file and that the corresponding header file will be included (one is for code, the other for includes). I should protect against this double inclusion :slight_smile:

[quote]7) The second argument to MakeProxy has a default value of “NULL”[/quote]I’ll have to check into this …

Cheers,
Philippe.

Philippe,
Thanks for your answers!

First, I see there was an error in my posting. Everywhere I said “5.16” I really meant “5.14b” - sorry if this caused any confusion. I had only two versions of root to play with, my home-built windows 5.14b and the official build of 5.17/02.

Interesting. I guess this is so it is well matched to PROOF in the future, right? How do people handle generating 10 or 20 histograms in a situation like this? Since my analysis is I/O bound, it is more efficient for me to generate all the histograms in one go rather than have seperate loops for each one.

I also have to say I have yet to write even a small analysis in a single file. I always build things up out of multiple objects. This style is very FORTRAN like. :smiley:

I have no idea! :slight_smile: For once I was using the offical build of ROOT instead of my home grown one. I don’t have the source code for that guy (you guys make that too hard for me. :slight_smile:). But doit.C was really really simple:

double doit (void) {return 1.0;}… and the ROOT file is linked at the end of the original post…

I’m in Europe now, which is cool, but I’ve no home internet yet (don’t ask) and so I don’t have regular access to the build VM that I setup for ROOT, so I’ve not been able to build anything recently.

[quote]It is non trivial
and required the addition of new helper classes (see checkins). You might be able to import the code from 5.17/02 … but then again it might just be easier to use 5.17/02 [/quote]

Interesting – Once I looked carefully at the source code in 5.14 that was generating the Proxy I was able to guess the code it was trying to put in (it failed on the “This” object inside the vector) I was able to guess what it did – and it worked! My other problem was my stand-alone program was linked against the debug version of the C++ libraries, and when you have vectors, that leads to all sorts of problems becasue Microsoft, for a reason I understand but don’t agree with, made changes to the interface.

Thanks!

Cheers,
Gordon.

[quote]How do people handle generating 10 or 20 histograms in a situation like this?[/quote] (Almost) The same way as for any other TSelector :slight_smile:.
You would have a doit.C like:[code]TH1F one_of_many;
void doit_Begin(TTree
)
{
one_of_many = new THF1(…);
}

double doit() {
one_of_many->Fill( myevent->GetSomeValue() );
}

void doit_Terminate()
{
one_of_many->Draw();
}[/code]

See $ROOTSYS/tutorials/h1analysis_Proxy* for a complete example.

That’s the beauty :slight_smile: of the MakeProxy, you can use any arbitrary C++ in it, even FORTRAN like :slight_smile:

Cheers,
Philippe

Hi,
Thanks – when I said multiple objects – I implicitly meant multiple files: I tend to have about 20 files or so in one analysis job (translate to TLV from electron array variables, select the electrons, translate to TLV from MC4 vectors, select TLV, match ele and MC vectors, etc., etc.). That way I can reuse them – well, more importantly, I can figure out how to debug them! :slight_smile:

Did you get a further chance to try my roottuple? Do you know what causes the crash? Is it me or is it ROOT?

Cheers,
Gordon.

[quote] Did you get a further chance to try my roottuple? Do you know what causes the crash? Is it me or is it ROOT? [/quote]Yes, I finally looked at it :slight_smile:, there was a missing protection which I now added to the svn trunk.

[quote]I tend to have about 20 files.[/quote]What kind of files? C++ Source files or ROOT files?

Cheers,
Philippe.

C++ source files, of course! Multiple ROOT files I know how to handle easily. :slight_smile: Actually, I can do C++ files as well, concat them all together – but that is pretty ugly. I think I’m mostly complaining about the “whole analysis in one file” problem – which, of course, is rooted in the fact there are no standards for build systems!

Ok – so in the next update that MakeProxy should just work for that root tuple? Great! Thanks!

Cheers,
Gordon.

[quote]Actually, I can do C++ files as well, concat them all together – but that is pretty ugly.[/quote]One way is to have a central dummy source file #including the real files and passing this dummy file to ACLiC … of course this is a bit of sledge hammer solution :slight_smile:

Philippe

Right. And violates all those “good C++ coding rules” I did my best to learn. :smiling_imp: Easy come, easy go…

As you said, it is a trade-off between simplicity/cleanlines of the code or the build system :slight_smile:

Philippe