How to export the data inside a branch in a ttree to a txt file?

Also, this post explains how to do it with TTree::Scan.