Hi,
I have a chain of very large trees (a few M events). These trees contain TClonesArray’s and other branches. What I want to do is: loop through the events, identify a handful of “interesting” events (through an event list that I have), and then make a skim tree with only those events.
Since these trees are very large, I do not want to unpack all the branches in the event loop for the majority of the events. Therefore, I disable all branches except for one that contains the event information (run #, event #), and if the event should be kept, I then want to enable all the branches and make a copy of the tree for that particular event, or process the event, etc. The logic looks like this:
Initialization:
- Load chain of trees
- Disable all braches (i.e. SetBranchStatus("*", 0) )
- Enable branches with event, run numbers only
Event loop
-
chain->GetEntry(i);
-
get event #, run #
-
if (interesting event){
// enable all branches
SetBranchStatus("*", 1);
// load event again (all branches this time)
chain->GetEntry(i);Make copy of tree, process event, etc.
Disable all braches again (i.e. SetBranchStatus("*", 0) )
Enable branches with event, run numbers only
}
Now, my problem is that when I try to load the event again in the “interesting event” loop, I get a segmentation fault. I do not understand why…
Part of my confusion is the lack of experience with calling SetBranchStatus("*", 1 or 0) inside the event loop. At what point do I need to do things like
Event *event = new Event();
chain.SetBranchAddress(“event”, &event);
Just outside the event loop? Does turning the branch off and then on again screw up the above?
How do I deal with the fact that I have chain (and not a sigle tree)? Do I need to re-set the branch address when I read the next tree in the chain?
Probably too many questions, but I’m a little lost.
Thanks a lot!
–Christos