@@ -842,12 +842,14 @@ struct strangederivedbuilder {
842842
843843 // __________________________________________________
844844 // mark mcParticles for referencing
845- for (auto const & v0 : V0s)
845+ for (auto const & v0 : V0s) {
846846 if (v0.has_mcMotherParticle ())
847847 motherReference[v0.mcMotherParticleId ()] = 0 ;
848- for (auto const & ca : Cascades)
848+ }
849+ for (auto const & ca : Cascades) {
849850 if (ca.has_mcMotherParticle ())
850851 motherReference[ca.mcMotherParticleId ()] = 0 ;
852+ }
851853 // __________________________________________________
852854 // Figure out the numbering of the new mcMother table
853855 // assume filling per order
@@ -859,10 +861,20 @@ struct strangederivedbuilder {
859861 }
860862 // __________________________________________________
861863 // populate track references
862- for (auto const & v0 : V0s)
863- v0mothers (motherReference[v0.mcMotherParticleId ()]); // joinable with V0Datas
864- for (auto const & ca : Cascades)
865- cascmothers (motherReference[ca.mcMotherParticleId ()]); // joinable with CascDatas
864+ for (auto const & v0 : V0s) {
865+ if (v0.mcMotherParticleId () > -1 ) {
866+ v0mothers (motherReference[v0.mcMotherParticleId ()]); // joinable with V0Datas
867+ } else {
868+ v0mothers (-1 ); // joinable with V0Datas
869+ }
870+ }
871+ for (auto const & ca : Cascades) {
872+ if (ca.mcMotherParticleId () > -1 ) {
873+ cascmothers (motherReference[ca.mcMotherParticleId ()]); // joinable with CascDatas
874+ } else {
875+ cascmothers (-1 ); // joinable with CascDatas
876+ }
877+ }
866878 // __________________________________________________
867879 // populate motherMCParticles
868880 for (auto const & tr : mcParticles) {
0 commit comments