Automatic pointer for a TBranch

Dear ROOTers,

@pcanal I have a TTree with a branch of type [1][1][48][48]/b. It is necessary that for future data I change it to [1][1][48][48]/F. Still, I would like to be able to read both old and new data with the same software. To read values from the array I used to declare unsigned char pcd[a][b][c][d], set the branch address to it with SetBranchAddress and loop over the tree. Now, the variable type has to be changed accordingly to the branch type. With new “auto” wonders in C++ and ROOT, I wonder if it is possible to automatically set a proper type for the pcd variable?


Please read tips for efficient and successful posting and posting code

_ROOT Version:6.18
Platform: Not Provided
Compiler: Not Provided


Unfortunately schema evolution is not supported for “leaflist” branches (i.e. your cases) and thus you will have to read the 2 set of files separately :frowning: or if you use a TChain you will need to switch the branch address at each file boundary.

If the data was the same size (not your case, eg long to float), then since the memory area would have been the same size, a single SetBranchAddress would work but still require to interpret the data differently for each file.

Cheers,
Philippe.

Thanks. So I’ll need some ifs based on the type set in the TTree.

Perhaps you could consider adding the schema evolution in the future, if possible?

Unlikely - the future is RNTuple and we cannot provide that and new TTree features with the resources we have…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.