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

DR: Excluding Duplicates for CM #267

Open
wants to merge 16 commits into
base: L1TK-dev-14_2_0_pre4
Choose a base branch
from
Open

Conversation

dally96
Copy link

@dally96 dally96 commented Mar 29, 2024

Fixed track comparison in PurgeDuplicate.cc so that the comparison modules ignore duplicate tracks. However, this does not overwrite the stub list if a duplicate is found and is merged.

@tomalin
Copy link
Collaborator

tomalin commented Apr 2, 2024

@dally96 given that in Settings.h , int numTracksComparedPerBin_ remains 9999, this PR should have no effect on tracking performance. But it fails git CI because the tracking performance has got worse. Do you understand why?

@tomalin tomalin requested a review from trholmes April 2, 2024 23:20
@dally96
Copy link
Author

dally96 commented Apr 3, 2024 via email

@dally96 dally96 marked this pull request as draft April 5, 2024 10:05
@tomalin
Copy link
Collaborator

tomalin commented Apr 6, 2024

Does the current code, before this PR, also behave incorrectly, by not overwriting the inputstublists when two tracks are merged?

@tomalin
Copy link
Collaborator

tomalin commented Apr 6, 2024

In your talk, you stated that if you correct this PR, so it does overwrite the inputstublists, then it crashes. My guess is that Tracklet:::proj() which you are calling from PurgeDuplicate is being called with a layer that fails the assert statement in Tracklet::validProj().

@dally96
Copy link
Author

dally96 commented Apr 8, 2024

Does the current code, before this PR, also behave incorrectly, by not overwriting the inputstublists when two tracks are merged?

There are two loops one to check if two tracks are duplicate and the other to merge the tracks if they are duplicates. In the loop to merge tracks, the stubs and stub ids do get merged, but after all the comparisons have been done. This error arises when I try to use the merged stubs for the comparison (although they should really be in one loop for this PR, I will fix that, but the same error persists).

@tomalin
Copy link
Collaborator

tomalin commented Aug 5, 2024

There's been no progress on this PR in 4 months. Shall we close it?

const unsigned int curSeed = aTrack->seedIndex();
static const std::vector<int> ranks{1, 5, 2, 7, 4, 3, 8, 6};
unsigned int curSeed = aTrack->seedIndex();
std::vector<int> ranks{1, 5, 2, 7, 4, 3, 8, 6};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has the "static const" qualifier been removed here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put "static const" back.

@@ -181,38 +187,70 @@ void PurgeDuplicate::execute(std::vector<Track>& outputtracks, unsigned int iSec
if (inputtracklets_.empty())
continue;
const unsigned int numStublists = inputstublists_.size();
std::vector<int> seedRankIdx(numStublists);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment that you're ordering the tracks by seed rank.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment has been included.

@@ -86,6 +87,11 @@ void PurgeDuplicate::execute(std::vector<Track>& outputtracks, unsigned int iSec
inputstublists_.clear();
mergedstubidslists_.clear();

sortedinputtracklets_.clear();
Copy link
Collaborator

@tomalin tomalin Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never understood why all these vectors are declared as class data members. If they were instead declared inside the loop over bins, e.g. near here https://github.com/cms-L1TK/cmssw/blob/dally_CMFix/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc#L140 , they would automatically be deleted and recreated between loops, so no clear would be needed either here nor near L410. Am I missing something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just wanted to mirror the actual class data members, but I can change them to only be declared in the loop over bins

@tomalin
Copy link
Collaborator

tomalin commented Sep 13, 2024

This fails git CI only because the performance of HYBRID_DISPLACED is worse https://gitlab.cern.ch/cms-l1tk/cmssw_CI/-/pipelines/8056886 . The reason it is worse is presumably your discovery that that the DR binning equations need changing to work for displaced tracks.
Since Thomas says that with his new "comparison modules ignore duplicate tracks" idea, the binning is no longer necessary, please try running with only 1 bin, and check compare the performance with what you get currently.

@dally96 dally96 changed the base branch from L1TK-dev-14_0_0_pre2 to L1TK-dev-14_2_0_pre4 December 9, 2024 14:58
@dally96 dally96 marked this pull request as ready for review December 17, 2024 20:11
@dally96
Copy link
Author

dally96 commented Dec 18, 2024

@tomalin It seems the number of CM affects hybrid displaced more than hybrid. I haven't optimized DR for displaced tracking, so would it be fine to merge this anyway?

@tomalin
Copy link
Collaborator

tomalin commented Dec 19, 2024

@tomalin It seems the number of CM affects hybrid displaced more than hybrid. I haven't optimized DR for displaced tracking, so would it be fine to merge this anyway?

The Displaced Tracking fails CI, as the number of reconstructed tracks has gone up by about one quarter. Do you understand why this PR should have this effect? (Recall the git CI runs on ttbar + 0PU). Have you checked what happens in ttbar+200PU?

Hi @dally96 there are still several unanswered review comments. I can't merge until they are answered.

@dally96
Copy link
Author

dally96 commented Dec 19, 2024

@tomalin It seems the number of CM affects hybrid displaced more than hybrid. I haven't optimized DR for displaced tracking, so would it be fine to merge this anyway?

The Displaced Tracking fails CI, as the number of reconstructed tracks has gone up by about one quarter. Do you understand why this PR should have this effect? (Recall the git CI runs on ttbar + 0PU). Have you checked what happens in ttbar+200PU?

Hi @dally96 there are still several unanswered review comments. I can't merge until they are answered.

I don't know why this is the case for the displaced case, since we didn't study the effects of this PR on extended tracking. However, a quick fix would be to increase the number of CMs to 64. When I run on a TTbar + PU200 sample fro 32 CM, this my output
Screenshot 2024-12-19 at 3 09 31 PM

bool barrel = (i > 0 && i <= N_LAYER);
bool endcapA = (i > N_LAYER);
bool endcapB = (i < 0);
int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number 5 not allowed

bool barrel = (i > 0 && i <= N_LAYER);
bool endcapA = (i > N_LAYER);
bool endcapB = (i < 0);
int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number 5 not allowed

@tomalin
Copy link
Collaborator

tomalin commented Dec 19, 2024

@tomalin It seems the number of CM affects hybrid displaced more than hybrid. I haven't optimized DR for displaced tracking, so would it be fine to merge this anyway?

The Displaced Tracking fails CI, as the number of reconstructed tracks has gone up by about one quarter. Do you understand why this PR should have this effect? (Recall the git CI runs on ttbar + 0PU). Have you checked what happens in ttbar+200PU?
Hi @dally96 there are still several unanswered review comments. I can't merge until they are answered.

I don't know why this is the case for the displaced case, since we didn't study the effects of this PR on extended tracking. However, a quick fix would be to increase the number of CMs to 64. When I run on a TTbar + PU200 sample fro 32 CM, this my output Screenshot 2024-12-19 at 3 09 31 PM

How do your ttbar+PU200 results for displaced tracking compare for CM=32, 64 and before you made your PR? I suspect the L1 trigger group would be unhappy if the number of displaced tracks go up by a quarter.

Daniel Ally added 6 commits January 7, 2025 16:25
…=' which accounts for duplicate tracks with the same seed rank
…illing to merging in DR. Changed some magic numbers in PurgeDuplicate.cc when encoding the barrel and disk layers. Created a doCompareAll function to mirror doCompareBest in PurgeDuplicate. Made minor fixes and included comments.
@dally96
Copy link
Author

dally96 commented Jan 7, 2025

@tomalin It seems the number of CM affects hybrid displaced more than hybrid. I haven't optimized DR for displaced tracking, so would it be fine to merge this anyway?

The Displaced Tracking fails CI, as the number of reconstructed tracks has gone up by about one quarter. Do you understand why this PR should have this effect? (Recall the git CI runs on ttbar + 0PU). Have you checked what happens in ttbar+200PU?
Hi @dally96 there are still several unanswered review comments. I can't merge until they are answered.

I don't know why this is the case for the displaced case, since we didn't study the effects of this PR on extended tracking. However, a quick fix would be to increase the number of CMs to 64. When I run on a TTbar + PU200 sample fro 32 CM, this my output Screenshot 2024-12-19 at 3 09 31 PM

How do your ttbar+PU200 results for displaced tracking compare for CM=32, 64 and before you made your PR? I suspect the L1 trigger group would be unhappy if the number of displaced tracks go up by a quarter.

32 CM:
NewDR_32CM_Displaced

64 CM:
NewDR_64CM_Displaced

Before PR with 9999 CM:
OldDR_9999CM_Disaplced

Before PR with 64 CM:
OldDR_64CM_Displaced

@dally96
Copy link
Author

dally96 commented Jan 15, 2025

@tomalin All checks have passed, but I did add a separate comparison of seed rank if hybrid displaced is being run. Hopefully that isn't a problem. I'm assuming once Alaa has looked at the seed ranking of the dispalced seeds, that we can go back to what I originally had in the PR>

@tomalin
Copy link
Collaborator

tomalin commented Jan 20, 2025

A general comment -- please try to keep CMSSW code as short and simple and CPU efficient as possible, since it makes it easier to understand and maintain. PurgeDuplicates.cc is now 915 lines long, which seems a lot for such a simple algorithm.

@dally96
Copy link
Author

dally96 commented Jan 30, 2025

@tomalin I put back in the < comparison instead of <= comparison for only extended seeds. Before I had them for every seed if we ran extended tracking. Here are the results for 9999 CM TTbar+PU200
Screenshot 2025-01-30 at 3 41 01 PM
Instead of a 4% increase in duplicates, it's a 3.4% increase. If this still is a problem, I can just use < for all seeds in extended tracking while we wait for developments to be made on that front

@@ -448,15 +450,15 @@ namespace trklet {
//have the factor if 2
double krprojshiftdisk() const { return 2 * kr(); }

double benddecode(unsigned int ibend, unsigned int layerdisk, bool isPSmodule) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed "unsigned" to "int" in the arguments of function Settings::benddecode()?

if (layerdisk >= N_LAYER && (!isPSmodule))
layerdisk += N_DISK;
double bend = benddecode_[layerdisk][ibend];
assert(bend < 99.0);
return bend;
}

double bendcut(unsigned int ibend, unsigned int layerdisk, bool isPSmodule) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed "unsigned" to "int" in the arguments of Settings::bendcut()?

@tomalin
Copy link
Collaborator

tomalin commented Feb 28, 2025

The git CI runs on ttbar + 0PU.
I therefore tried running myself the prompt tracking "HYBRID" over 100 events of ttbar+200PU, with the following results:

BEFORE THIS PR:
Efficiency = 94.80%
Tracks/event (pt > 2.0) = 165.96
Percentage duplicate tracks = 1.22%

AFTER THIS PR:
Efficiency = 95.07%
Tracks/event (pt > 2.0) = 238.56
Percentage duplicate tracks = 27.00%

There is therefore a significant bug somewhere.

As a sanity check, I also tried running HYBRID on the ttbar+PU0 sample, and also the duplicate rate rises from 0.7% to 3.3%, this causes only a slight increase in the tracks/event, which is why git CI passes.

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.

2 participants