Ttree proxy using TLorenzVector

Hello,

I have a ttree with some branches in it holding momentum and energy values. I want to take these values and do some simple manipulation using TLorentzVector. I could write a selector to loop over the ttree, sure, but I want to know if it can be done using this proxy trick, where you put the code in a cxx file.

I tried doing this:

myMass.cxx:
#include "TLorentzVector.h"
double myMass() { TLorentzVector v; v.SetPxPyPzE(px,py,pz,E); return v.M(); }

root prompt:
tree->Draw("myMass.cxx")

but this produces lots of compile errors refering to TMatrixXXX stuff.

What do I need to add/change about this file?

Thanks!

Hi,

The MakeProxy cxx input file can not contain any #include. Instead use 2 files;[code]
//myMass.h
#include “TLorentzVector.h”

//myMass.cxx:
double myMass() { TLorentzVector v; v.SetPxPyPzE(px,py,pz,E); return v.M(); }[/code]

Cheers,
Philippe.

Thanks Philippe, that does appear to work…

… next question though, is why things do not appear to work if I enable proof. Of the documentation I can find, it suggests I should be able to use proxies with proof (although no specific example is given). However, when I try to do the “Draw” command, things don’t work…

OBJ: TStatusing PROOF_Statusts .ERROR(1 workers still sending)
TProofDrawHist::CompileVariables: Error compiling variables
Max worker virtual memory: 242.32 MB Max worker resident memory: 92.86 MB
Max master virtual memory: -0.00 MB Max master resident memory: -0.00 MB
Info in TProofDrawHist::SetDrawAtt: att: 1000
Lite-0: all output objects have been merged
Error in TCanvas::Range: illegal world coordinates range: x1=0.000000, y1=-0.131250, x2=0.000000, y2=1.181250
Error in TCanvas::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=0.000000, xmax=0.000000, ymax=1.050000

Is there a way around this? I imagine it’s about using the generated selector and "Process"ing it rather than calling draw…and I assume I can then access the output histogram via the usual htemp on the gDirectory?

If this is all correct, can it be added to future versions to make proxies work transparently with proof enabled?

Thanks!

To answer my own question a bit… I have found that I need to do the following to run some proxy code on proof-lite on a tchain. In my “proxyTest.cxx” file I added:

void proxyTest_SlaveBegin(TTree*) {
   if (htemp == 0) {
      htemp = new TH1D("htemp","htemp",10,-1000000,1000000);//this sucks but maybe I could add options to the option string to better specify. The TBranchProxyDirector histo is useless - a) it's a TH1F (urgh), and b) it resizes so no good for merging. 
      fObject = htemp;
   }
}
void proxyTest_Terminate() {gDirectory->Add(fOutput->FindObject("htemp"));}
void proxyTest_SlaveTerminate() {fOutput->Add(htemp);}
root [3] chain->MakeProxy("tmpProxy","proxyTest.cxx")
root [4] chain->SetProof(true)
root [5] TProof::Open("")
root [6] .L tmpProxy.h++
root [7] gProof->Exec("gSystem->Load(\"/path/to/tmpProxy_h.so\")") //to get the library to the workers...
root [8] chain->Process("tmpProxy.h+")

Then I can access the htemp histogram from my gDirectory and draw it or otherwise clone it or whatever.

Is this the simplest/best/only way to make a proxy work with proof? It would be very nice if the code generated as part of MakeProxy included these necessary lines to make things super proof-compatible. The dream is to be able to do (both with and without proof):

chain->Draw("proxyTest.cxx>>myHisto");

Where the Draw method picks up the “myHisto” and passes it to the proxy for use.