[PWGEM] Fix TTCA weight miscalculation when cfgRequireTrueAssociation is enabled#46
Closed
[PWGEM] Fix TTCA weight miscalculation when cfgRequireTrueAssociation is enabled#46
Conversation
…o effect of TOF recalculation
Agent-Logs-Url: https://github.com/feisenhu/O2Physics/sessions/299261dd-7222-4d31-bfbe-51b8e64993ce Co-authored-by: feisenhu <53603353+feisenhu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix track weight calculation to respect true association config
Fix TTCA weight miscalculation when cfgRequireTrueAssociation is enabled
Apr 14, 2026
…o effect of TOF recalculation
Owner
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: feisenhu <53603353+feisenhu@users.noreply.github.com>
Author
Owner
|
@copilot revert the previous commit which has introduced the merge conflict. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
cfgRequireTrueAssociation = true,runQCMConly fills histograms for tracks whose MC collision matches the reconstructed collision, butfillTrackWeightMapcounted all ambiguous associations — assigning weight1/Neven though the track only fills histograms once. This caused systematic undercorrection for ambiguous tracks.Changes
PWGEM/Dilepton/Core/SingleTrackQCMC.h—fillTrackWeightMap: Added the samecfgRequireTrueAssociationguard present inrunQCMCto both thekDielectronandkDimuontrack collection loops:This ensures that when
cfgRequireTrueAssociation = true, only the single true-MC-matched association is counted, so the computed weight is1rather than1/N— consistent with how the weight is consumed downstream.Original prompt
Problem
In
PWGEM/Dilepton/Core/SingleTrackQCMC.h, thefillTrackWeightMapfunction calculates TTCA (Time To Collision Association) weights without respecting thecfgRequireTrueAssociationconfiguration.Issue Description
When
cfgRequireTrueAssociation = TRUEis set, only tracks with correct MC collision association should be filled in histograms. However, the weight calculation infillTrackWeightMapdoes not check this condition.Scenario with the bug:
fillTrackWeightMap: weight = 1/3 (counts all 3 collisions)runQCMCwithcfgRequireTrueAssociation = TRUE: track only fills histogram in C1Root Cause
The
fillTrackWeightMapfunction (lines 1025-1119) collects all tracks passing kinematic/PID cuts but does not apply thecfgRequireTrueAssociationcheck. This causes a mismatch between:Solution
Add the
cfgRequireTrueAssociationcheck infillTrackWeightMapso that:cfgRequireTrueAssociation = TRUE: Only count tracks in collisions where MC collision ID matches rec collision IDrunQCMCExpected Behavior After Fix
When both
cfgRequireTrueAssociation = TRUEandcfgApplyWeightTTCA = TRUE:The following is the prior conversation context from the user's chat exploration (may be truncated):
User: In dem Task SingleTrackQCMC.h task gibt es die Configurable cfgRequireTrueAssociation.
Wie beeinflusst diese das füllen der Histogramme?
In dem Task kann zusätzlich die TTCAweigths angewendet werden, die den Beitrag gewichten. Erkläre mir wie diese Gewichte berechnet werden, und ob die cfgRequireTrueAssociation das Gewicht beeinflusst.
cfgRequireTrueAssociation sollte nur dann Tracks in die Histogramme füllen, wenn der Track tatsächlich zur Kollision gehört. Das weight sollte dementsprechend angepasst werden, sodass das weight nur dann von 1 verschieden ist, wenn tracks mehrfach aufgrund der Assoziierung von dem selben tracks zu unterschiedlichen Kollisionen stattfindet und dadurch mehrfach in das selbe Histogramm gefüllt wird.
Assistant: Ich werde mir den Task SingleTrackQCMC.h ansehen und die Auswirkungen von
cfgRequireTrueAssociationund den TTCAweights analysieren.Assistant: Lass mich die konkrete SingleTrackQCMC.h Datei in der Dilepton-Struktur finden:
Assistant: Jetzt habe ich den vollständigen SingleTrackQCMC.h Code. Lassen Sie mich eine detaillierte Analyse erstellen:
Analyse: cfgRequireTrueAssociation und TTCAweights in SingleTrackQCMC
1. Wirkung von cfgRequireTrueAssociation auf die Histogrammfüllung
Die Configurable cfgRequireTrueAssociation (Zeile 101) steuert, ob nur Tracks akzeptiert werden, deren MC-Partikel zur gleichen MC-Collision gehört wie die rekonstruierte Collision.
In der runQCMC-Funktion (Zeile 862-864):
Effekt:
2. TTCA Weights - Berechnung und Zweck
TTCA = "Time To Collision Association"
Die Weights werden in der Funktion fillTrackWeightMap (Zeile 1025-1119) berechnet:
Beispiel:
n = 31/3≈ `0.33...This pull request was created from Copilot chat.