Accessing objects from Tree - PROOF


I’m working on a dedicate file (MyEvent) adapted from Event classes example but I have trouble reading objects from the TTree.
The output return strange numbers:

11:52:04 25985 Wrk-0.0 | Info in <TProofServLite::Setup>: fWorkDir: /home/user/.proof
11:52:04 25985 Wrk-0.0 | Info in <TProofServLite::SetupCommon>:  0 global package directories registered
11:52:11 25985 Wrk-0.0 | Info in <TProofServLite::HandleProcess>: calling fPlayer->Process() with selector name: Analysis.C+
11:52:11 25985 Wrk-0.0 | Info in <TProofPlayerSlave::AssertSelector>: Processing via filename (Analysis.C+)
11:52:11 25985 Wrk-0.0 | Info in <TEventIter::TEventIter>: fPackets list 'ProcessedPackets_0.0' created
11:52:11 25985 Wrk-0.0 | Info in <TProofPlayerSlave::Process>: save partial results? 0  per-packet? 0
11:52:11 25985 Wrk-0.0 | Info in <Analysis::Slave Begin>: Starting core analysis with process option:
11:52:11 25985 Wrk-0.0 | SvcMsg in <TProofPlayerSlave::CheckMemUsage>: Memory 465956 virtual 157764 resident event 0
11:52:11 25985 Wrk-0.0 | Info in <TEventIterTree::GetTrees>: the tree cache is in learning phase
11:52:11 25985 Wrk-0.0 | Info in <Analysis::Notify>: processing file: /home/user/Workdir/Fluka/Analiza/Proof_lite/with_par/output.root
++++++++++ Event tracks = -1717986919 ++++++++++
++++++++++ Event tracks = -1717986919 ++++++++++
++++++++++ Event tracks = -1717986919 ++++++++++
++++++++++ Event tracks = -1717986919 ++++++++++
++++++++++ Event tracks = -1717986919 ++++++++++
................same results for each entry in the root file .....

11:52:11 25985 Wrk-0.0 | SvcMsg in <TProofPlayerSlave::CheckMemUsage>: Memory 496744 virtual 158264 resident event 43

the Proof notifications seems to be ok :

root [0] .x RunAnalysis.C
 +++ Starting PROOF-Lite with 2 workers +++
Opening connections to workers: OK (2 workers)
Setting up worker servers: OK (2 workers)
PROOF set to parallel mode (2 workers)
Info in <TPackMgr::Install>: installing myevent.par ...
[TFile::Cp] Total 0.01 MB       |====================| 100.00 % [51.8 MB/s]
building myevent ...
myevent: version change (current: 6.08/02, build: ): cleaning ...
g++ -O -Wall -fPIC  -pthread -std=c++11 -m64 -I/home/user/Root/build-64//include/root -L//home/user/Cernlib/lib -c -fPIC MyEvent.cpp
Generating dictionary MyEventDict.cpp ...
g++ -O -Wall -fPIC  -pthread -std=c++11 -m64 -I/home/user/Root/build-64//include/root -I/home/user/Root/build-64/include/root/ -c -fPIC MyEventDict.cpp
--------------------------------------------- MyEventDict.cpp ... ok -----------------------------------------
g++ -O -Wall -fPIC  -pthread -std=c++11 -m64 -I/home/user/Root/build-64//include/root -c  MyEventDict.cpp
g++ -shared -m64 -fPIC  -O -fPIC  -I/home/user/Root/build-64/include/root/ MyEvent.o MyEventDict.o -o -L/home/user/Root/build-64//lib/root -lCore -lRIO -lNet -l$
--------------------------------------------- ... ok ---------------------------------------------
-------------------------------------------------  DONE  ---------------------------------------------------
building myevent ...
Wrk-0.1: building myevent ...
Wrk-0.0: building myevent ...
Enabled packages ...

*** Enabled packages on client on localhost.localdomain

Start analyzing the chain ...

Info in <TProofLite::SetQueryRunning>: starting query: 1
Info in <TProofQueryResult::SetRunning>: nwrks: 2
Info in <Analysis::Begin >: Starting analysis with process option:
Looking up for exact location of files: OK (1 files)
Looking up for exact location of files: OK (1 files)
Info in <TPacketizer::TPacketizer>: Initial number of workers: 2
Validating files: OK (1 files)
Lite-0: all output objects have been merged
Real time 0:00:08.129114, CP time 0.750
root [1] .q

How to correctly access objects variables for TTree, using pointers of objects?
Please find attached the reading class (Analysis),Proof macro (RunAnalysis.C) and the root file (output.root).
output.root (19 KB)
Analysis.C (5.02 KB)
Analysis.h (2.83 KB)
RunAnalysis.C (422 Bytes)

Dear myk,

I am not sure what the problem is with your selector. I guess the fact that you call SetMakeClass(1), which means decomposition of the object, and then you try to read the full objects MyEvent, MyEventHeader, MyTrack. To debug this I would need the code for those classes.

I have attached two examples to to the same with a decomposed event, reading only the leaves that you need.
MySel uses the standard technique to attach to branches. MySel_tr uses TTreeReader technology which further simplifies things.

Hope it helps.
G Ganis
examples.tgz (3.13 KB)

Dear Ganis,

Unfortunately, if I comment SetMakeClass(1) the result is the same.
Please find attached the classes into the myevent.tar.gz file prepared to archive to par file.
Indeed, the TTreeReader is very interesting and the standard way to get branches is useful if I just want to plot the variables. In my case, I want, firstly, to get tracks number for each event and then loop over those TClonesArray tracks for further selection.

What method you recommend to touch that problem?
Thank you,
myevent.tar.gz (5.43 KB)

Dear Ganis,

I think I figure out to solve the problem.
All I had to do was to call the pointer of MyEventHeader from MyEvent, into Notify() method, but it also work if I call it in Process() method.
I used:
fHeader = (MyEventHeader*)fEvent->GetHeader();

Now it return correct values for the GetEvtTracks() method.
I hope this solution is the correct one and will help other users as well.


Dear myk,

Thanks for the report.
It makes sense, you read Event and you access its content.
Is this without the SetMakeClass(1) call?
Note also that in this way you read the full event, This is probably ok is you use most of it.
If you need only part of it you may want to be more granular an read only the branches/leaves that you need.

G Ganis


Yes, is without SetMakeClass(1), otherwise the error is the same.

thank you for the help!