Skip to content

Various small optimizations to online TOF code.

Dominik Smith requested to merge d.smith/cbmroot:TofClusterSpeedup into master

Old title: Merged two std::vector::erase calls in cbm::tof::Clusterizer. Makes the algorithm a bit faster.

This is a small optimization, whereby two erase operations (which seem to be a bottle neck in the clusterizer) are combined into a single copy/move sweep through the vector.

Depending on the machine, this cuts 5 - 20 percent out of the runtime of the clusterizer, with the speedup being larger on weaker machines, so it seems worth-while to have this in.

Perhaps @j.decuveland @fweig have further suggestions on how to reformulate this.

Replacing the vectors by iterators entirely is unfortunately not an option here, due to random access. At some point someone might be able to implement a smart container for this, but this is beyond the scope of this MR.

Maybe also of interest to: @f.uhlig @p.-a.loizeau @v.friese

Edit: I'm a bit surprised that this helped. I expected the compiler to already do this.

Edit 2: Added another optimization. Replaced std::map by std::unordered_map in cbm::algo::Calibrate. Increases performance of the class by at least a factor of two. I decided to include this change here, event though it is a bit off topic.

Edit 3: Reintroduced the sort step into the calibrator, as otherwise the digi-index matching is different from the old code. Updated MR title.

Edited by Dominik Smith

Merge request reports