Error in <TTree::SetBranchStatus>: unknown branch

Hello all,

There are 3 rootfiles with me over which I run my code which writes some root branches and
gives as an output another 3 rootfiles.
The way I am writing the branch is :

I loop over these output rootfiles and in one of the rootfiles I get this error :

In the other rootfiles there is no such error.
Could anybody have some idea as to why this error is coming?
If any other information is required please let me know.

Thanks & Regards,
Shilpi

Could you post the address of one of your ROOT files where this problem appears?

Rene

Hi Rene,

Thanks much.
Here is the address of that root file :

and the other root file which works fine is :

Best Regards.
Shilpi

I cannot access this file. Could you post it on lxplusxxx/tmp ?

Rene

Hi Rene,

Please find the file here :
lxplus248/tmp/ztoeerealdata_31_1_8x5.root

I would like to mention that I am not filling any default values for this
branch. So this variable is an HLT trigger. If in a particular root file,
trigger by this name is found only then it gets filled.
But I was expecting this root branch to get created anyway with may be some random values.

Thanks,
Best Regards,
Shilpi

I checked that your Tree myEvent in the file you posted does not contain a branch named is_HLT_Ele10_LW_L1R_event
So teh error message you get when trying to set the brancg address is correct.

Rene

Hi Rene,

Many thanks.
That I had also checked.
I was thinking if other rootfiles contain this branch then
why is there no branch named “is_HLT_Ele10_LW_L1R_event” in this rootfile
because I am using the same code to generate these rootfiles.
So here I describe how I am filling the branch :

the tree variable is filled only under an 'if condition'. I am not providing any default values to this tree variable. So if the 'if condition' is satisfied, the tree variable gets a value.
Can it be because of this?
But since the branch is defined it should have anyway been written to the
tree?

Thanks for help,
Best Regards,
Shilpi

No this cannot be the cause. You simply do not create the branch. I cannot tell you more without having a simple test case reproducing your problem. I suggest to call TTree::Print abfter the creation of the branches and before filling.

Rene

Hi Rene,

many thanks.
Just to clarify, once the branch is created, even if
I do not fill the tree variable for that branch, it should be there?
I would now try checking what you have suggested and post here
if I find something.

Best Regards,
Shilpi

[quote]the tree variable is filled only under an ‘if condition’.[/quote]I strongly recommend against this techniques. Depending how you implemented this feature you will either ended up with an unbalanced tree where some branches have more entries than other and there is no way to known which branch entries belongs together (i.e. make up a single ‘event’) and you will end up with the branch filled anyway but with random values in the case where you did not ‘fill’ it. The variable name you have suggest that you should always fill it something with the value true, something with the value false. In the case where there is really no possible meaning for a value to filled for some of the entries then the typical solution is to use a container (TClonesArray, std::vector) to hold 0, 1 or more values for each entries.

Cheers,
Philippe.

Hello Philippe,

Thanks a lot for the suggestion.
Though in this case, ‘if condition’ was always satisfies but
I’ll change my code so that every variable gets some default value.

Best Regards,
Shilpi