New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch FastCircleFit to use Eigen, generalize FastCircleFit and RZLine interfaces #15260
Switch FastCircleFit to use Eigen, generalize FastCircleFit and RZLine interfaces #15260
Conversation
…loat With double precision there would be no changes. Moving at the same to float incurs numerical differences, but in simple tests those seem to be smaller than 1 % in the circle parameters. I think this is acceptable given that the class is called "Fast...".
Needed for generic interface, especially for avoiding DynArray when std::array's are given, i.e. we know statically the size.
Since it's already #included outside this package, interface is the proper place (especially now that the class is header-only)
A new Pull Request was created by @makortel (Matti Kortelainen) for CMSSW_8_1_X. It involves the following packages: CommonTools/Utils @cvuosalo, @dmitrijus, @cmsbuild, @slava77, @vanbesien, @davidlange6 can you please review it and eventually sign? Thanks. cms-bot commands are list here #13028 |
@cmsbuild , please test |
The tests are being triggered in jenkins. |
+1 |
z[i] = p.z(); | ||
} | ||
|
||
float simpleCot2 = sqr( (z[n-1]-z[0])/ (r[n-1]-r[0]) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a division by zero possibility here if (r[n-1]-r[0]) == 0
? Or would that be prevented from happening? Or would it take too long to check for the zero value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Note that this code is exactly as before) I guess it could, in principle, happen that the first and last hit would have exactly the same r
, if all hits come from FPix/TID/TEC. But I'd expect this situation to be very unlikely, especially given the constraints of seeds to point towards beamspot (even if loosely on strip-triplet steps).
linearFit(r.data(), z.data(), n, errZ2.data(), cotTheta_, intercept_, covss_, covii_, covsi_); | ||
chi2_ = 0.f; | ||
for(size_t i=0; i<n; ++i) { | ||
chi2_ += sqr( ((z[i]-intercept_) - cotTheta_*r[i]) ) / errZ2[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How safe is this division? Could unusual circumstances cause errZ2
to contain some zero values? Is it worth some possible performance cost to protect against division by zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Note that this code is exactly as before) In practice errZ2
can be zero only if some TrackingRecHit
has zero czz
or zero rerr
. I guess those would be a sign of something going wrong elsewhere.
These fixes could be done in this PR or a later one. |
Jenkins tests show no differences except tiny ones for workflow 10024.0_TTbar_13+TTbar_13TeV_TuneCUETP8M1_2017, as expected. Extended tests with 70 events each against baseline CMSSW_8_1_0_pre9 for workflows 1313.0_QCD_Pt_3000_3500_13, 1316.0_SingleElectronPt1000, and 10024.0_TTbar_13+TTbar_13TeV_TuneCUETP8M1_2017 also show no differences, except for the 2017 one that has numerous, tiny, insignificant differences. |
I'll follow up in a separate PR as this PR is not about By the way, the message from static analyzer is a bit misleading. In 8_1_X there is no FWCore/Utilities/interface/isNotFinite.h, but FWCore/Utilities/interface/isFinite.h, which has both |
+1 For tracking, switching FastCircleFit from using TMatrixD to Eigen. The code changes are satisfactory. Jenkins tests and extended tests described above show no significant differences except for tiny differences in a 2017 Phase 1 workflow. CPU timing tests on workflow 10024.0_TTbar_13+TTbar_13TeV_TuneCUETP8M1_2017 with 70 events against baseline CMSSW_8_1_0_pre9 show a possible very slight improvement for affected modules. Measured with DQM and Validation:
Another measure without DQM and Validation:
These values imply about a 1% improvement in timing, but the measurements should not be taken as definitive since the uncertainty is probably at least comparable to the seeming improvement. |
@cvuosalo Replying to the question you sent via e-mail regarding the timing improvements on The modules affected by this PR are strip triplet seeding (i.e. the ones above) and pixel quadruplet seeding (initialStepPreSplitting, lowPtQuad, detachedQuad). But as I mentioned in the description, the time spent in |
Here are the timing changes for the affected modules mentioned by @makortel above. These results come from the same tests described in my approval message.
These all show about a 1% timing improvement, again with the caveat that the measurement uncertainty is probably at least comparable to this change. |
This PR switches
FastCircleFit
fromTMatrixD
toEigen
and floats (roughly a 3x speedup in the circle fit, but not really visible in global picture). It also generalizes theFastCircleFit
andRZLine
interfaces to work with e.g.std::array
. On the same goRZLine
std::vector
, which reduces the number of memory allocations fromSeedGeneratorFromRegionHitsEDProducer
by ~11 % (phase1 ttbar+35PU; for the full job with tracking-only RECO,DQM,VALIDATION the reduction is ~1 %); no noticeable effect on CPU time though (with igprof)errZ
, to avoidsqr(sqrt(X))
inPixelQuadrupletGenerator
andCAHitQuadrupletGenerator
Tested in 8_1_0_pre8 and CMSSW_8_1_X_2016-07-19-2300. Tiny changes are expected in 2017 workflows from moving from
double
tofloat
inFastCircleFit
and removingsqr(sqrt(X))
. No changes are expected in 2016 or phase2 workflows.Here is a set of MTV plots for phase1 (1000 ttbar+35PU events; with an intermediate point after
double
->float
inFastCircleFit
)https://mkortela.web.cern.ch/mkortela/tracking/validation/CMSSW_8_1_0_pre8_fcf_rzline/
@rovere @VinInn @felicepantaleo