StMagUtilities profiling


Looking at some recent Run 13 pp510 production jobs, I saw numbers like: time spent in tpcChain ~30% of the BFC chain, and tpcHitMover ~80% of tpcChain, so tpcHitMover is ~1/4th of the BFC chain time. While tpcHitMover also does alignment, some of the time is spent on distortion corrections, so I think it's worthwhile profiling how time is spent within the distortion correction code to understand whether there is fruit to be picked here...


I used TTimeStamp (nanosecond resolution?) to profile how much time is spent in StMagUtilities correction subroutines. Those routines I indexed as:
  1. B
  2. 2D B
  3. (unused)
  4. Padrow13
  5. Twist
  6. Clock
  7. Membrane
  8. Endcap
  9. IFC Shift
  10. SpaceCharge (R2)
  11. Shorted Ring
  12. GridLeak (3D)
  13. GGVoltError
  14. SectorAlign
I processed the first 10 events from st_physics_14079008_raw_1920004.daq (Run 13 pp510 data) using the corrections for items 2,4,5,6,9,10,11,12.

  • First hit, initializing the local arrays for each subroutine
    • GridLeak takes the longest to initialize (~1.6 sec), followed by ShortedRing (~0.6 sec).
    • As this is time spent only once, these are small fractions of the total time for the reconstruction jobs, which now take on the order of ~1 minute per event to process (multiplied by thousands of events per job).

  • All hits, focusing only on the time range down near the 1-10 μsec range
    • SpaceCharge & GridLeak each take nearly an order of magnitude longer than the other subroutines, though perhaps only a factor of ~4-5x longer than Shorted ring.
    • It is not at all clear that TTimeStamp actually has nanosecond resolution, as there seem to be time steps at the ~1 μsec level, but good enough for our purposes.


The code used for ShortedRing is nearly identical to that used in IFCShift, GGVoltError (not typically used), and the original (now unused) SpaceCharge corrections. It would be rather simple to merge these subroutines into one to reduce time spent in each of these alone. But it's clear that doing so would at best save much less than 10% of StMagUtilities' time, as SpaceCharge & GridLeak combine to be an order of magnitude longer. Addressing the speed of those two subroutines for each hit would be the optimal targets, as they may account for up to ~20% of the total reconstruction time.