SetBranchStatus when using a TChain

In my analysis code I would like to inspect a few events, quickly. So when doing so I disable all the branches in the input root file and then enable the event number branch. I then loop over all the entries in the chain looking for events that match my requested event number. When it is found I re-enable all the branches and then do another GetEntry on the chain. Once that is done I print out the info for the event. All the variables are accessed though TChain::SetBranchAddress and I am using root version 4.04/02b. The problem is that I just get all zeros for the variables. But when I look at events in the first file in the TChain it works ok. Is there something special that I need to do here to get this to work right? Thanks. The code snippet is listed below.

    if(onlyInspectEvent) {
      if(evtnum == inspecteventnumber) {
        chain->SetBranchStatus("*", 1);
        chain->SetBranchStatus("*", 0);
        chain->SetBranchStatus("evtnum", 1);


Difficult to say what can be wrong by just looking at your code snippet. My first suggestion is to encourage you to move to a more recent version (ie 5.20).


Wish that I could. I am using the D0 RunII environment. I am not sure what all I should provide as far as the code goes. I know that it is pretty difficult from what I have provided.

Please provide a complete (assuming an empty environment) example that can be run on one of the DZero machine.