Skip to content
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

Add support pixel triplet seeds #242

Merged
merged 3 commits into from
Dec 6, 2019
Merged

Conversation

makortel
Copy link
Collaborator

This PR is to add support for pixel triplet seeds in order to work around a "feature" of CMSSW EDProducer that converts pixel reco::Tracks to TrajectorySeeds (used in the HLT menu today) that ignores the fourth hit of the seed (in the context of #236).

First step is to remove the "minimum number of hits in a seed" cut from the seed cleaner, but that turned out to be insufficient. The story continues in the comments.

@makortel
Copy link
Collaborator Author

@makortel
Copy link
Collaborator Author

This PR (as of now) works fine in the standalone program. When ran from CMSSW with triplet seeds (made from quadruplet pixel tracks, as they are provided within the HLT menu), I get a segfault in

#4  <signal handler called>
#5  Matriplex::MatriplexSym<float, 3, 16>::CopyIn (this=0x7fe97bf1e440, n=<optimized out>, arr=0xc) at ../Matriplex/MatriplexSym.h:98
#6  mkfit::MkFitter::InputTracksAndHits (this=0x7fe97bf1d1c0, tracks=..., layerHits=..., beg=0, end=2079450176) at MkFitter.cc:155

i.e.

mkFit/mkFit/MkFitter.cc

Lines 149 to 155 in d9dfbda

for (int hi = 0; hi < Nhits; ++hi)
{
const int hidx = trk.getHitIdx(hi);
const int hlyr = trk.getHitLyr(hi);
const Hit &hit = layerHits[hlyr].GetHit(hidx);
msErr[hi].CopyIn(itrack, hit.errArray());

The Nhits is set in
void SetNhits(int newnhits) { Nhits = std::min(newnhits, Config::nMaxTrkHits - 1); }

mkFit/mkFit/MkBuilder.cc

Lines 775 to 780 in d9dfbda

inline void MkBuilder::fit_one_seed_set(TrackVec& seedtracks, int itrack, int end,
MkFitter *mkfttr, const bool is_brl[])
{
// debug=true;
mkfttr->SetNhits(Config::nlayers_per_seed);

where Config::nlayers_per_seed ultimately comes from
Config::nlayers_per_seed = 4;

Do I understand correctly that we are setting globally the exact number of hits per seed instead of a maximum?

Any suggestions how to proceed?

@osschar @slava77

@slava77
Copy link
Collaborator

slava77 commented Sep 10, 2019

Any suggestions how to proceed?

an "easy" option now would be to get CMSSW (configurably) do what we want.
However, things will probably go bad again after we start getting a merged seed collection from patatrackers.

@kmcdermo
Copy link
Collaborator

@makortel , this is set during the fit over seeds before processing, which uses the MkFitter routines, which expect an exact number of layers (as the fitting goes layer by layer).

@osschar , correct me if I am wrong -- did you mention on that with Track kaboom this should no longer really problem?

@osschar
Copy link
Collaborator

osschar commented Sep 13, 2019

Why are we fitting seeds here -- this is where the crash happens? For patatrack seeds in our bin files we use the existing track params as input ... we do not refit them. The seed fit is only used for sim track seeds ... and there we do expect them to have 4 layers, indeed, as we construct the seeds by picking the first four hits from sim-track that lay on unique layers, dropping overlaps.

Saying this, there are apparently two things for me to look at:

  1. Fix the seed fit to also handle 3-hit input.
  2. Investigate how LayerPlan has to be modified to properly support 3-hit tracks, especially those that are missing the hit on the last layer ... as steering params are configured right now to ignore the last layer for hit-pickup / finding.

@kmcdermo no ... this has nothing to do with Track Kaboom

@kmcdermo
Copy link
Collaborator

I apologize for leading people astray on this. The last step of MkBuilder::PrepareSeeds() is MkBuilder::fit_seeds() (which is always called), and inside that is MkBuilder::fit_one_seed_set()...

But as already mentioned, inside that last function there is a check if we are using CMSSW seeds, in which case if we are then the fitting is skipped and the seeds are imported directly into MkFitters. Sorry about that.

The crash comes from the MkFitter::InputTracksAndHits() in MkBuilder::find_one_seed_set().

@osschar
Copy link
Collaborator

osschar commented Sep 30, 2019

I disabled fitting for cmssw seeds at an earlier stage (so we never get to the piece of code where we had the crash) and fixed steering-params so that seeds are picked up also on earlier layers (this now expects the seeds to end on layer 2 (or later), i.e., if there is a doublet seed with hits on layers 0 and 1 it will not be picked up).

https://github.com/trackreco/mkFit/tree/store-hits-per-seed

@makortel can you give it a try together with your changes here and with your triplet dataset?

@osschar
Copy link
Collaborator

osschar commented Sep 30, 2019

Grr, I posted a wrong branch:
https://github.com/trackreco/mkFit/tree/seed-fit-fix

@makortel
Copy link
Collaborator Author

makortel commented Oct 2, 2019

https://github.com/trackreco/mkFit/tree/seed-fit-fix

@osschar Thanks. I (in my private repo) cherry-picked that on top of this branch (and rebased on top of devel) and tried again. Now the HLT job fails with

An exception of category 'BadAlloc' occurred while
   [0] Processing  Event run: 1 lumi: 1 event: 17 stream: 0
   [1] Running path 'MC_ReducedIterativeTracking_v12'
   [2] Calling method for module MkFitProducer/'hltIter0PFlowCkfTrackCandidatesMkFit'
Exception Message:
A std::bad_alloc exception was thrown.
The job has probably exhausted the virtual memory available to the process.

But that seems to be caused by #243 (and happens in the offline reconstruction configuration as well). Or, at least if I take my branch of #244, the offline reco works, if I take devel, I get the std::bad_alloc exception.

@makortel
Copy link
Collaborator Author

makortel commented Oct 2, 2019

But that seems to be caused by #243

Probably because I did not do the necessary updates on the CMSSW side yet...

@osschar
Copy link
Collaborator

osschar commented Oct 2, 2019

Do you need me to do / check something? :)

@makortel
Copy link
Collaborator Author

makortel commented Oct 2, 2019

So let me try again

https://github.com/trackreco/mkFit/tree/seed-fit-fix

I (in my private repo) cherry-picked that on top of this branch (and rebased on top of #244) and tried again. At least technically the HLT workflow works now, need to check the physics performance next.

@makortel
Copy link
Collaborator Author

makortel commented Oct 2, 2019

Do you need me to do / check something? :)

Let me remind myself first has to be done from #243 first :)

@makortel
Copy link
Collaborator Author

makortel commented Oct 9, 2019

@osschar I finally got to complete the test, and https://github.com/trackreco/mkFit/tree/seed-fit-fix combined with this PR seems to work fine with pixel triplet seeds. How sould we proceed? (cherry-pick your commit here, two separate PRs, something else?)

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 9, 2019 via email

@makortel
Copy link
Collaborator Author

makortel commented Oct 9, 2019

Let me quote now only efficiency vs. pT, I'll rerun with the full 10k event to have more precise picture
image
Overall looks pretty good, mkFit might be giving lower efficiency for pT > 10 GeV.

@osschar
Copy link
Collaborator

osschar commented Oct 9, 2019

@makortel your call, I can make my PR right away ... but it probably makes more sense for you to cherry-pick the commit and do the full validation.

@makortel
Copy link
Collaborator Author

makortel commented Oct 9, 2019

@osschar Thanks. I'll then cherry-pick it here and provide the full validation.

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 9, 2019 via email

@makortel
Copy link
Collaborator Author

makortel commented Oct 9, 2019

Both have 3-hit seeds (made from 4-hit pixel tracks by dropping the outermost hit).

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 9, 2019 via email

@makortel makortel changed the title [WIP] Add support pixel triplet seeds Add support pixel triplet seeds Oct 9, 2019
@makortel
Copy link
Collaborator Author

makortel commented Oct 9, 2019

I cherry-picked the commit of @osschar. Here are the standalone benchmarks
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_2/
(IIUC should have no impact)

Here is MTV for 10k ttbar+PU50 events comparing HLT iter0 from CMSSW with HLT iter0 with mkFit
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv/
(with both offline- and online-style MTV cuts). I can make a summary of the comparison for Friday.

@slava77
Copy link
Collaborator

slava77 commented Oct 9, 2019

This makes the pt>10GeV note interesting. I am wondering what this may be telling us.

this actually looks quite depressing.
Single percent efficiency drop is usually a big deal. Here we have 20% by 100GeV.

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 9, 2019 via email

@cerati
Copy link
Collaborator

cerati commented Oct 9, 2019

maybe it is not the cause, but are we using the duplicate seed removal? we should disable it for triplets.

@makortel
Copy link
Collaborator Author

makortel commented Oct 9, 2019

maybe it is not the cause, but are we using the duplicate seed removal? we should disable it for triplets.

The duplicate seed cleaning is enabled. I can test again disabling it.

@makortel
Copy link
Collaborator Author

maybe it is not the cause, but are we using the duplicate seed removal? we should disable it for triplets.

The duplicate seed cleaning is enabled. I can test again disabling it.

I updated the plots in https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv/ and the seed cleaning seems to have no effect on efficiency (black=disabled, red=enabled)
image
It does have small effect on duplicate rate
image

@mmasciov
Copy link
Collaborator

About the hit selection windows for pixel layers:

That is, all was done for pixel layers was to slightly reduce the phi selection window for the pixel endcaps.

Naively, I am not sure whether this could be the reason for the inefficiency at large pT.

@osschar
Copy link
Collaborator

osschar commented Oct 22, 2019

Yup, now I have everything, thanks! :)

@osschar
Copy link
Collaborator

osschar commented Oct 23, 2019

I went over comparing seed/sim/cmssw/mkfit tracks of first 20 events (about 100 seeds). I found 3 tracks for which mkfit only finds about 50% of hits (cms finds about 75%) and will look into those in detail. Then there are a couple more that are not so dramatic and I might look into later. All in all, this is about 10 tracks out of 100, so a 10% efficiency drop which seems consistent within +-10% error bar here :)

Another thing I noticed is that about 1% of seeds get rejected in nan_and_silly check because they have negative values on element (5,5) of covariance (theta), e.g.:

Post-cleaning seed silly value check and fix (label=1): (5,5)=-7.445001e-07
Post-cleaning seed silly value check and fix (label=9): (5,5)=-5.498798e-08
Post-cleaning seed silly value check and fix (label=5): (5,5)=-2.132469e-08
Post-cleaning seed silly value check and fix (label=5): (5,5)=-9.654286e-10
Post-cleaning seed silly value check and fix (label=5): (5,5)=-5.437179e-06

There are also two cases with similar values on (4,4) (phi). pT is also rather poor but the error is not negative.

Right now our settings are to discard such seeds (Config::nan_n_silly_remove_bad_seeds = true). We have an option implemented to fix negative values on the diagonal (Config::nan_n_silly_fixup_bad_seeds) but it is off right now. Also, it sets the value to 1 ... there might be a better choice for this, probably depending on which parameter is affected.

Do we want to go into this business tight now? It's a 1% effect at most.

@osschar
Copy link
Collaborator

osschar commented Oct 23, 2019

I went through one track, pT=8.49, eta=-2.39

To get mkfit to find a track of about the same quality as cmssw (10 found hits, pT 8.25, ch2 ~ 60) I had to:

  • increase min_dphi search window x3 for the endcap layers
  • increase max hit chi2 from 15 to 20

And still, a short track with 3 seed hits and a wrong hit picked on the 4th layer, followed by three missed hits wins at the end, mostly because of the chi2 penalty to candidate score (the "good" track has 6 more hits but chi2 of 60 makes it worse). Clearly, our scoring isn't optimal for noisy 3-hit seeds :)

It also seems our detection of hit/miss of a layer is not fuzzy enough ... we might have to consider extending the might-have-missed-the-layer region or increasing N_max_holes.

I will look at two more tracks tomorrow. Then I might have a recommendation for a couple of test runs to see how this shows on a larger statistics.

@slava77
Copy link
Collaborator

slava77 commented Oct 24, 2019

And still, a short track with 3 seed hits and a wrong hit picked on the 4th layer

was this still from the muon gun sample?
I'm curious where is the wrong hit from. Does it have an MC info?

@osschar
Copy link
Collaborator

osschar commented Oct 24, 2019

Yes, muons. i was able to trace it to another track. You can get full event dump by uncommenting all the DUMP_XXX defines in Event.cc:456 and run

mkFit/mkFit --cmssw-n2seeds --input-file /data2/mkortela/hlt_bin/10_4_0_patch1_10mu_hlt_ccc_all_rec.bin --read-cmssw-tracks --build-std --quality-val --num-events 1 --start-event 12

and then the hit that gets picked up is the only hit on layer 54, belogning to track label 1. The track that I was looking at had label 6.

@osschar
Copy link
Collaborator

osschar commented Oct 24, 2019

I looked at three more tracks, here's a short report on what I had to fix to improve mkFit track.
[ Format note: mkFit best track | sim track, CMS track in next line ]

  1. 19 7 4/8 chi2=0.284564 pT=10.207181 eta=2.411617 | 15/15 chi2=12.000000 pT=8.312447 eta=2.411341
    4 with q=-1 pT= 8.143 eta= 2.411 nHits=12 label= 4
  • Increase chi2 per hit cut from 15 -> 20 to pick up the correct hit on on inner layer
  1. 3 6 13/17 chi2=12.091969 pT=7.028310 eta=-1.857068 | 23/23 chi2=16.000000 pT=7.007823 eta=-1.858734
    4 with q=+1 pT= 7.011 eta= -1.858 nHits=18 label= 4
  • Increase N_max_holes from 3 -> 4, apparently layer r/z limits are to "rough", at least in the endcap.
  1. 14 1 5/9 chi2=5.698732 pT=21.901735 eta=-2.483779 | 11/11 chi2=7.000000 pT=9.415405 eta=-2.481886
    4 with q=-1 pT= 9.475 eta= -2.483 nHits= 7 label= 4
  • chi2 -> 30 (28.7)
  • increase N_max_holes
  • reduce chi2 penalty or increase hit bonus
  • a rather hopeless case, note that cmssw also only found 7 hits out of 11.

So, there isn't a single thing that's wrong but rather our whole scoring and best-short-track handling seems to be optimized for 4-hit seeds with better initial parameters.

We need to figure out how to handle this but it seems we need:

  • a good way to automatically tune the track scoring parameters / function,
  • have different config parameter sets for different iterations (or they could be set per seed as well, based on N_hits, pT, eta, initial track parameter errors).

@slava77
Copy link
Collaborator

slava77 commented Oct 25, 2019

19 7 4/8 chi2=0.284564 pT=10.207181 eta=2.411617 | 15/15 chi2=12.000000 pT=8.312447 eta=2.411341

I'm not sure I understand the numbers before chi2. Please clarify what is printed.
What are the seed track parameters in all these cases?

@osschar
Copy link
Collaborator

osschar commented Oct 25, 2019

EventNo Label hits_found/total_hits
Seeds:

  1. 4 q=-1 pT= 10.979 eta= 2.411 nHits=3 label= 7
  2. 4 q=+1 pT= 5.916 eta= -1.858 nHits=3 label= 6
  3. 4 q=-1 pT= 6.122 eta= -2.482 nHits=3 label= 1

@slava77
Copy link
Collaborator

slava77 commented Oct 25, 2019

EventNo Label hits_found/total_hits

is the difference between hits_found and total_hits only in the number of holes between the innermost and the outermost found hit?

@makortel
Copy link
Collaborator Author

Here are MTV plots comparing CMSSW with triplet seeds (blue), mkFit with quadruplet seeds (red), and mkFit with triplet seeds (black) (and to remind, in this specific case the triplet seeds contain the first three hits of the quadruplet seeds)
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv_quad/

image

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 25, 2019 via email

@osschar
Copy link
Collaborator

osschar commented Oct 25, 2019

EventNo Label hits_found/total_hits

is the difference between hits_found and total_hits only in the number of holes between the innermost and the outermost found hit?

No, it's all the not found hits, including the trailing ones. In this case this just tells you the best selected track was the first short track we found, with 4 not found hits at the end.

@cerati
Copy link
Collaborator

cerati commented Oct 25, 2019

One issue we can have at high pT is that our track parameters does not allow to change the charge, while CMSSW allows it (Matti just verified it). So if the seed has the wrong charge we are lost. This is something we should fix in the code (remove the charge as a standalone parameter and get it is the sign of the 1/pt parameter, now q/pt).

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 25, 2019 via email

@cerati
Copy link
Collaborator

cerati commented Oct 25, 2019

we know that on the 10 mu sample (0.5-10 GeV) it ~1% overall but ~8% when looking only at pT>7 GeV and |eta|>2.3. We are now trying to assess the effect on the efficiency, but may need a larger sample to get final conclusions...

@cerati
Copy link
Collaborator

cerati commented Oct 25, 2019

("we" are FNAL+Slava having a small f2f instead of beer on Friday)

@IHateLinus
Copy link
Collaborator

IHateLinus commented Oct 25, 2019 via email

@makortel
Copy link
Collaborator Author

makortel commented Nov 1, 2019

We had some discussion whether we had seen the high-pT inefficiency before (#242 (comment), red (mkFit with quads). vs blue (CMSSW with triplets)
image
)

I ran both CMSSW and mkFit in the offline initialStep with the full 10kevent ttbar+PU50 sample, MTV plots here
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv_offline/
and the efficiency vs. pT below
image

There is some inefficiency in mkFit vs. CMSSW starting around 80 GeV, but the effect is smaller than in the HLT case.

Thinking out loud, one possible cause for the difference is the duplicate cleaning within pixel tracking. I could try what happens in the HLT case for mkFit if I disable that.

@makortel
Copy link
Collaborator Author

makortel commented Nov 4, 2019

Thinking out loud, one possible cause for the difference is the duplicate cleaning within pixel tracking. I could try what happens in the HLT case for mkFit if I disable that.

Plots are here https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv_quad_nopixeltrackclean/
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv_quad_nopixeltrackclean3/

  • blue: CMSSW with triplet seeds
  • red: mkFit with quadruplet seeds
  • black: mkFit with quadruplet seeds with CMSSW-pixel-tracking-side duplicate cleaning disabled

Disabling the pixel track cleaning improves the efficiency closer to offline quadruplets, but at the cost of increasing fakes and duplicates. (mkFit's seed cleaning was enabled for both red and black)

@cerati
Copy link
Collaborator

cerati commented Nov 4, 2019

Hi Matti, I have a hard time reconciling the efficiency plot vs pT with the one vs eta for HLT:
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv_quad_nopixeltrackclean/plots_hltOnline_hltIter0PFlowTrackSelectionHighPurity/effandfakePtEtaPhi.pdf
This has nothing to do with the black dots.
Looking at the one vs eta we have the same or better performance, while vs pT we do significantly worse (not just for pT<0.9 which is not included in the eta plot). I suspect there are different cuts in eta for the plot vs pT (it seems to me there are no blue points beyond |eta|=2.5).

@makortel
Copy link
Collaborator Author

Looking at the one vs eta we have the same or better performance, while vs pT we do significantly worse (not just for pT<0.9 which is not included in the eta plot). I suspect there are different cuts in eta for the plot vs pT (it seems to me there are no blue points beyond |eta|=2.5).

Thanks @cerati for pointing it out, there is clearly something wrong in the blue reference. I re-ran it and made a new set of plots
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_mtv_quad_nopixeltrackclean3/
that look much better.
Legend is the same

  • blue: CMSSW with triplet seeds
  • red: mkFit with quadruplet seeds
  • black: mkFit with quadruplet seeds with CMSSW-pixel-tracking-side duplicate cleaning disabled

@cerati
Copy link
Collaborator

cerati commented Nov 12, 2019 via email

makortel and others added 2 commits December 6, 2019 11:13
This commit is mainly to work around a "feature" of CMSSW EDProducer
that converts pixel reco::Tracks to TrajectorySeeds that ignores the
fourth hit of the seed.

On ther other hand, any seed selection (that depends purely on the
seed properties) should really be done by an independent producer in
CMSSW (or by non-CMSSW-called code within the standalone application)
as that would be much more flexible.
- Do not even enter seed-fit for cmssw seeds. Before the check if we
  are using cmssw seeds was within the inner seed-fit loop after
  loading of seeds into Matriplexes (which bombed for non-quadruplet
  seeds).

- Note: the seed-fit is still not fixed and expects
  Config::nlayers_per_seed hits to be present in incoming seeds.

- Extend steering-parametrs to start seed-candidate pickup on the
  third layer.
@makortel
Copy link
Collaborator Author

makortel commented Dec 6, 2019

Rebased on top of HEAD of devel (merge of #247), and updated README for two new options for the HLT-tracking configuration (when ran in CMSSW). Standalone benchmarks are here
https://mkortela.web.cern.ch/mkortela/tracking/mkfit/PR/PR242_3/

@osschar osschar merged commit 842df5a into trackreco:devel Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants