Event loop for difference in same variable

Dear ROOT users,

I am struggling to find an example of an event loop that gets out the difference of one variable from a branch.

ie, I have data on several cars and their distances travelled. I would like to loop over this branch and get the maximum distance a car travels.

I’m using a macro from ->MakeClass, but I’ll probably make my own as the pointers are somewhat confusing for me. If you can help I’d be grateful. Thanks



You would need to add a datamember to old the previous value.
And then do something like:

travel = car_distance - previous_car_distance; previous_car_distance = car_distance;