output file is updated on every event.
this is an unnecessary amount of I/O - call TTree::Write in end of event action only once every e.g. 1000 events (to not lose everything in the event of crash), and also once in end of run action (to ensure everything is written out).