Results caching in Rivet
A major element in Rivet's design is that calculations should be efficient - after all, calculating a thrust measure is a computationally significant task, so why do it twice? To this end, Rivet projections are written to automatically cache their results, so that the second time that that thrust is required (for a given event) the result is returned from the cache rather than by doing the whole computation again.
All this is hidden from the projection/analysis author when using other projections, so you can just write your code and more or less take it as a gift from above that Rivet is automatically efficient.
If you're writing your own projection which might be used by several other projections or analyses, keep in mind that your
analyze method should cache as many results as seem sensible in member variables, so that a
const pointer to your projection can still be used to get all your results. Maybe that sounds intimidating - it shouldn't be; just look at any of the existing projections as a guide to what you should be doing.