fix to way branches tag_idx_prt0/1 were being filled
I am requesting for the existing tuples to be regenerated since a bug with this ntupling has been found and this is the updated code with this bug fix implemented.
How the code works is that instead of saving branches such as B_variableName, K_variableName, dih_variableName, hp_variableName, hm_variableName, the output branches are of the form tag_variableName and trk_variableName
Tags are objects with end vertices (B mesons, dihadron objects) and tracks are final state particles (K, hp, hm)
This is explained in full detail in the README
After the tuples are generated from AP, these must undergo post-processing to turn these tuples into the "standard form" of having branches for each of the particles in the decay
To do this the branches tag_idx_prt0/1 are used which tell you the indices of a tag particles daughters
The problem discovered was that these branches were being recorded incorrectly in the ntuple, causing wrong particle associations when analyzing decay trees.
Hence after the postprocessing we were seeing odd structures - e.g. it seemed as though the dih had a kaon and pion children when it should have 2 pions
The problem was fixed in Ntuple.py - this is where the actual filling of the ntuple occurs
The problem was that daughter indices were being recorded during recursive processing before parent particles got their final array positions, causing a mismatch between when indices were recorded and when particles were actually positioned in the arrays.
Solution: deferred index recording
Modified the Ntuple.py code to:
- Process all particles and assign their final array positions first
- Record parent-child relationships after all particles have stable indices
- Ensure daughter indices point to the correct array positions
This guarantees that when a parent records its children's indices, those indices correctly correspond to where the children actually ended up in the final arrays.
Checks have been made that this fix works for cases with 1 B candidate in an event or more than 1
Other smaller changes to the code:
- Alteration of MCEventTools.py where the truth matching is done - wanted to add more categories of background to be truth matched
- Change to info.yaml to process more background type types so we can consider misID backgrounds and peaking backgrounds not previously requested
- added new TIS and TOS branches which contains decisions on if Hlt2IncPhi trigger fired or not
These tuples superceed all previous tuples which can be archived after this AP MR has been approved and finished.