[PWGEM] [WIP] Fix TTCA weight calculation in fillTrackWeightMap#47
Closed
[PWGEM] [WIP] Fix TTCA weight calculation in fillTrackWeightMap#47
Conversation
…ght calculation Agent-Logs-Url: https://github.com/feisenhu/O2Physics/sessions/a1ab7ba4-281c-421f-89c7-98bf25837d71 Co-authored-by: feisenhu <53603353+feisenhu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix TTCA weight calculation in fillTrackWeightMap
Fix: cfgRequireTrueAssociation not respected in TTCA weight calculation
Apr 14, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes an inconsistency between fillTrackWeightMap (TTCA weight computation) and runQCMC when cfgRequireTrueAssociation = true, ensuring TTCA weights are computed only from tracks that will actually be used for histogram filling.
Changes:
- Add a
cfgRequireTrueAssociationguard in the dielectron branch offillTrackWeightMap. - Add the same guard in the dimuon branch of
fillTrackWeightMap.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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,fillTrackWeightMapstill counted ambiguous track associations across all collisions, producing weights of1/Neven thoughrunQCMCwould only fill histograms for the true collision — resulting in systematic under-correction.Changes
PWGEM/Dilepton/Core/SingleTrackQCMC.h: Added the true association guard infillTrackWeightMapfor both the Dielectron and Dimuon track loops, mirroring the existing check inrunQCMC:This ensures
passed_trackIdsonly contains tracks that will actually be used downstream, so the computed1/Nweight is consistent with what gets filled into histograms.Original prompt
Bug: cfgRequireTrueAssociation wird bei TTCA-Gewichtsberechnung nicht beachtet
Problem
In der
fillTrackWeightMap-Funktion des SingleTrackQCMC.h werden die TTCA-Gewichte berechnet, ohne diecfgRequireTrueAssociation-Einstellung zu berücksichtigen. Dies führt zu inkonsistentem Verhalten:Szenario mit cfgRequireTrueAssociation = TRUE:
fillTrackWeightMap: Weight wird als 1/3 berechnet (Track wird in allen 3 Collisionen akzeptiert)runQCMC: Track wird nur in C1 gefüllt (wegen True Association Check)Ursache
Die Bedingung
cfgRequireTrueAssociation && (mctrack.emmceventId() != collision.emmceventId())fehlt infillTrackWeightMapfür beide Lepton-Typen (Dielectron und Dimuon).Lösung
Die True Association-Bedingung in
fillTrackWeightMaphinzufügen, damit:runQCMCderselbe Check angewendet wirdDateien
PWGEM/Dilepton/Core/SingleTrackQCMC.h(Zeilen 1025-1119)Betroffene Code-Stellen
cfgEventGeneratorTypeCheckcfgEventGeneratorTypeCheckThe 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.333In fillTrackInfo (Zeile 635-638):