@@ -923,28 +923,26 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
923923 return ;
924924 } // / end of performPvRefitTrack function
925925
926- // / Partition for PV contributors
927-
926+ // / Selection tag for tracks
927+ // / \param collision is the collision iterator
928+ // / \param tracks is the entire track table
929+ // / \param trackIndicesCollision are the track indices associated to this collision (from track-to-collision-associator)
930+ // / \param pvContrCollision are the PV contributors of this collision
931+ // / \param bcWithTimeStamps is the bc with timestamp for PVrefit
932+ // / \param pvRefitDcaPerTrack is a vector to be filled with track dcas after PV refit
933+ // / \param pvRefitPvCoordPerTrack is a vector to be filled with PV coordinates after PV refit
934+ // / \param pvRefitPvCovMatrixPerTrack is a vector to be filled with PV coordinate covariances after PV refit
935+ // / \return true if the track is compatible with a proton hypothesis
928936 template <int pidStrategy, typename TTracks, typename GroupedTrackIndices, typename GroupedPvContributors>
929937 void runTagSelTracks (aod::Collision const & collision,
930- TTracks const & tracks, // all tracks
931- GroupedTrackIndices const & trackIndicesCollision, // track indices associated to this collision (from track-to-collision-associator)
932- GroupedPvContributors const & pvContrCollision, // PV contributors of this collision
933- aod::BCsWithTimestamps const & bcWithTimeStamps, // for PV refit
934- int64_t numTracksThisColl, // number of tracks in this collision (for PV refit)
935- int64_t offsetTracksThisColl) // offset of tracks in this collision with respect to total table (for PV refit)
938+ TTracks const & tracks,
939+ GroupedTrackIndices const & trackIndicesCollision,
940+ GroupedPvContributors const & pvContrCollision,
941+ aod::BCsWithTimestamps const & bcWithTimeStamps,
942+ std::vector<std::array<float , 2 >>& pvRefitDcaPerTrack,
943+ std::vector<std::array<float , 3 >>& pvRefitPvCoordPerTrack,
944+ std::vector<std::array<float , 6 >>& pvRefitPvCovMatrixPerTrack)
936945 {
937- // prepare vectors to cache quantities needed for PV refit
938- std::vector<std::array<float , 2 >> pvRefitDcaPerTrack{};
939- std::vector<std::array<float , 3 >> pvRefitPvCoordPerTrack{};
940- std::vector<std::array<float , 6 >> pvRefitPvCovMatrixPerTrack{};
941- if (doPvRefit) {
942- pvRefitDcaPerTrack.resize (numTracksThisColl);
943- pvRefitPvCoordPerTrack.resize (numTracksThisColl);
944- pvRefitPvCovMatrixPerTrack.resize (numTracksThisColl);
945- tabPvRefitTrack.reserve (numTracksThisColl);
946- }
947-
948946 auto thisCollId = collision.globalIndex ();
949947 for (const auto & trackId : trackIndicesCollision) {
950948 int statusProng = BIT (CandidateType::NCandidateTypes) - 1 ; // all bits on
@@ -980,9 +978,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
980978 }
981979 performPvRefitTrack (collision, bcWithTimeStamps, vecPvContributorGlobId, vecPvContributorTrackParCov, track, pvRefitPvCoord, pvRefitPvCovMatrix, pvRefitDcaXYDcaZ);
982980 // we subtract the offset since trackIdx is the global index referred to the total track table
983- pvRefitDcaPerTrack[trackIdx - offsetTracksThisColl ] = pvRefitDcaXYDcaZ;
984- pvRefitPvCoordPerTrack[trackIdx - offsetTracksThisColl ] = pvRefitPvCoord;
985- pvRefitPvCovMatrixPerTrack[trackIdx - offsetTracksThisColl ] = pvRefitPvCovMatrix;
981+ pvRefitDcaPerTrack[trackIdx] = pvRefitDcaXYDcaZ;
982+ pvRefitPvCoordPerTrack[trackIdx] = pvRefitPvCoord;
983+ pvRefitPvCovMatrixPerTrack[trackIdx] = pvRefitPvCovMatrix;
986984 } else if (track.collisionId () != thisCollId) {
987985 auto bc = collision.bc_as <o2::aod::BCsWithTimestamps>();
988986 initCCDB (bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2);
@@ -1008,21 +1006,25 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
10081006 int8_t isProton = isSelectedProton<pidStrategy>(track);
10091007 rowSelectedTrack (statusProng, isProton);
10101008 }
1009+ }
10111010
1012- if (doPvRefit) { // / fill table with PV refit info (it has to be filled per track and not track index)
1013- for (auto iTrack{0 }; iTrack < numTracksThisColl; ++iTrack) {
1014- tabPvRefitTrack (pvRefitPvCoordPerTrack[iTrack][0 ], pvRefitPvCoordPerTrack[iTrack][1 ], pvRefitPvCoordPerTrack[iTrack][2 ],
1015- pvRefitPvCovMatrixPerTrack[iTrack][0 ], pvRefitPvCovMatrixPerTrack[iTrack][1 ], pvRefitPvCovMatrixPerTrack[iTrack][2 ], pvRefitPvCovMatrixPerTrack[iTrack][3 ], pvRefitPvCovMatrixPerTrack[iTrack][4 ], pvRefitPvCovMatrixPerTrack[iTrack][5 ],
1016- pvRefitDcaPerTrack[iTrack][0 ], pvRefitDcaPerTrack[iTrack][1 ]);
1017- }
1011+ // / Helper function to fill PVrefit table
1012+ // / \param pvRefitDcaPerTrack is a vector to be filled with track dcas after PV refit
1013+ // / \param pvRefitPvCoordPerTrack is a vector to be filled with PV coordinates after PV refit
1014+ // / \param pvRefitPvCovMatrixPerTrack is a vector to be filled with PV coordinate covariances after PV refit
1015+ // / \return true if the track is compatible with a proton hypothesis
1016+ void fillPvRefitTable (std::vector<std::array<float , 2 >>& pvRefitDcaPerTrack,
1017+ std::vector<std::array<float , 3 >>& pvRefitPvCoordPerTrack,
1018+ std::vector<std::array<float , 6 >>& pvRefitPvCovMatrixPerTrack)
1019+ {
1020+ for (auto iTrack{0u }; iTrack < pvRefitDcaPerTrack.size (); ++iTrack) {
1021+ tabPvRefitTrack (pvRefitPvCoordPerTrack[iTrack][0 ], pvRefitPvCoordPerTrack[iTrack][1 ], pvRefitPvCoordPerTrack[iTrack][2 ],
1022+ pvRefitPvCovMatrixPerTrack[iTrack][0 ], pvRefitPvCovMatrixPerTrack[iTrack][1 ], pvRefitPvCovMatrixPerTrack[iTrack][2 ], pvRefitPvCovMatrixPerTrack[iTrack][3 ], pvRefitPvCovMatrixPerTrack[iTrack][4 ], pvRefitPvCovMatrixPerTrack[iTrack][5 ],
1023+ pvRefitDcaPerTrack[iTrack][0 ], pvRefitDcaPerTrack[iTrack][1 ]);
10181024 }
10191025 }
10201026
10211027 Preslice<TrackAssoc> trackIndicesPerCollision = aod::track_association::collisionId;
1022- Preslice<TracksWithSelAndDca> tracksPerCollision = aod::track_association::collisionId;
1023- Preslice<TracksWithSelAndDcaAndPidTpc> tracksWithPidTpcPerCollision = aod::track_association::collisionId;
1024- Preslice<TracksWithSelAndDcaAndPidTof> tracksWithPidTofPerCollision = aod::track_association::collisionId;
1025- Preslice<TracksWithSelAndDcaAndPidTpcTof> tracksWithPidTpcTofPerCollision = aod::track_association::collisionId;
10261028 Partition<TracksWithSelAndDca> pvContributors = ((aod::track::flags & (uint32_t )aod::track::PVContributor) == (uint32_t )aod::track::PVContributor);
10271029 Partition<TracksWithSelAndDcaAndPidTpc> pvContributorsWithPidTpc = ((aod::track::flags & (uint32_t )aod::track::PVContributor) == (uint32_t )aod::track::PVContributor);
10281030 Partition<TracksWithSelAndDcaAndPidTof> pvContributorsWithPidTof = ((aod::track::flags & (uint32_t )aod::track::PVContributor) == (uint32_t )aod::track::PVContributor);
@@ -1034,13 +1036,27 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
10341036 aod::BCsWithTimestamps const & bcWithTimeStamps)
10351037 {
10361038 rowSelectedTrack.reserve (tracks.size ());
1039+ // prepare vectors to cache quantities needed for PV refit
1040+ std::vector<std::array<float , 2 >> pvRefitDcaPerTrack{};
1041+ std::vector<std::array<float , 3 >> pvRefitPvCoordPerTrack{};
1042+ std::vector<std::array<float , 6 >> pvRefitPvCovMatrixPerTrack{};
1043+ if (doPvRefit) {
1044+ auto numTracks = tracks.size ();
1045+ pvRefitDcaPerTrack.resize (numTracks);
1046+ pvRefitPvCoordPerTrack.resize (numTracks);
1047+ pvRefitPvCovMatrixPerTrack.resize (numTracks);
1048+ tabPvRefitTrack.reserve (numTracks);
1049+ }
10371050
10381051 for (const auto & collision : collisions) {
10391052 auto thisCollId = collision.globalIndex ();
10401053 auto groupedTrackIndices = trackIndices.sliceBy (trackIndicesPerCollision, thisCollId);
1041- auto groupedTracks = tracks.sliceBy (tracksPerCollision, thisCollId); // we need to know the number of tracks in this collision and the offset for the PV refit
10421054 auto pvContrCollision = pvContributors->sliceByCached (aod::track::collisionId, thisCollId, cache);
1043- runTagSelTracks<NoPid>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, groupedTracks.size (), groupedTracks.offset ());
1055+ runTagSelTracks<NoPid>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
1056+ }
1057+
1058+ if (doPvRefit) { // / fill table with PV refit info (it has to be filled per track and not track index)
1059+ fillPvRefitTable (pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
10441060 }
10451061 }
10461062
@@ -1052,13 +1068,27 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
10521068 aod::BCsWithTimestamps const & bcWithTimeStamps)
10531069 {
10541070 rowSelectedTrack.reserve (tracks.size ());
1071+ // prepare vectors to cache quantities needed for PV refit
1072+ std::vector<std::array<float , 2 >> pvRefitDcaPerTrack{};
1073+ std::vector<std::array<float , 3 >> pvRefitPvCoordPerTrack{};
1074+ std::vector<std::array<float , 6 >> pvRefitPvCovMatrixPerTrack{};
1075+ if (doPvRefit) {
1076+ auto numTracks = tracks.size ();
1077+ pvRefitDcaPerTrack.resize (numTracks);
1078+ pvRefitPvCoordPerTrack.resize (numTracks);
1079+ pvRefitPvCovMatrixPerTrack.resize (numTracks);
1080+ tabPvRefitTrack.reserve (numTracks);
1081+ }
10551082
10561083 for (const auto & collision : collisions) {
10571084 auto thisCollId = collision.globalIndex ();
10581085 auto groupedTrackIndices = trackIndices.sliceBy (trackIndicesPerCollision, thisCollId);
1059- auto groupedTracks = tracks.sliceBy (tracksWithPidTpcPerCollision, thisCollId); // we need to know the number of tracks in this collision and the offset for the PV refit
10601086 auto pvContrCollision = pvContributorsWithPidTpc->sliceByCached (aod::track::collisionId, thisCollId, cache);
1061- runTagSelTracks<PidTpcOnly>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, groupedTracks.size (), groupedTracks.offset ());
1087+ runTagSelTracks<PidTpcOnly>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
1088+ }
1089+
1090+ if (doPvRefit) { // / fill table with PV refit info (it has to be filled per track and not track index)
1091+ fillPvRefitTable (pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
10621092 }
10631093 }
10641094
@@ -1070,13 +1100,27 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
10701100 aod::BCsWithTimestamps const & bcWithTimeStamps)
10711101 {
10721102 rowSelectedTrack.reserve (tracks.size ());
1103+ // prepare vectors to cache quantities needed for PV refit
1104+ std::vector<std::array<float , 2 >> pvRefitDcaPerTrack{};
1105+ std::vector<std::array<float , 3 >> pvRefitPvCoordPerTrack{};
1106+ std::vector<std::array<float , 6 >> pvRefitPvCovMatrixPerTrack{};
1107+ if (doPvRefit) {
1108+ auto numTracks = tracks.size ();
1109+ pvRefitDcaPerTrack.resize (numTracks);
1110+ pvRefitPvCoordPerTrack.resize (numTracks);
1111+ pvRefitPvCovMatrixPerTrack.resize (numTracks);
1112+ tabPvRefitTrack.reserve (numTracks);
1113+ }
10731114
10741115 for (const auto & collision : collisions) {
10751116 auto thisCollId = collision.globalIndex ();
10761117 auto groupedTrackIndices = trackIndices.sliceBy (trackIndicesPerCollision, thisCollId);
1077- auto groupedTracks = tracks.sliceBy (tracksWithPidTofPerCollision, thisCollId); // we need to know the number of tracks in this collision and the offset for the PV refit
10781118 auto pvContrCollision = pvContributorsWithPidTof->sliceByCached (aod::track::collisionId, thisCollId, cache);
1079- runTagSelTracks<PidTofOnly>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, groupedTracks.size (), groupedTracks.offset ());
1119+ runTagSelTracks<PidTofOnly>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
1120+ }
1121+
1122+ if (doPvRefit) { // / fill table with PV refit info (it has to be filled per track and not track index)
1123+ fillPvRefitTable (pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
10801124 }
10811125 }
10821126
@@ -1088,13 +1132,27 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
10881132 aod::BCsWithTimestamps const & bcWithTimeStamps)
10891133 {
10901134 rowSelectedTrack.reserve (tracks.size ());
1135+ // prepare vectors to cache quantities needed for PV refit
1136+ std::vector<std::array<float , 2 >> pvRefitDcaPerTrack{};
1137+ std::vector<std::array<float , 3 >> pvRefitPvCoordPerTrack{};
1138+ std::vector<std::array<float , 6 >> pvRefitPvCovMatrixPerTrack{};
1139+ if (doPvRefit) {
1140+ auto numTracks = tracks.size ();
1141+ pvRefitDcaPerTrack.resize (numTracks);
1142+ pvRefitPvCoordPerTrack.resize (numTracks);
1143+ pvRefitPvCovMatrixPerTrack.resize (numTracks);
1144+ tabPvRefitTrack.reserve (numTracks);
1145+ }
10911146
10921147 for (const auto & collision : collisions) {
10931148 auto thisCollId = collision.globalIndex ();
10941149 auto groupedTrackIndices = trackIndices.sliceBy (trackIndicesPerCollision, thisCollId);
1095- auto groupedTracks = tracks.sliceBy (tracksWithPidTpcTofPerCollision, thisCollId); // we need to know the number of tracks in this collision and the offset for the PV refit
10961150 auto pvContrCollision = pvContributorsWithPidTpcTof->sliceByCached (aod::track::collisionId, thisCollId, cache);
1097- runTagSelTracks<PidTpcOrTof>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, groupedTracks.size (), groupedTracks.offset ());
1151+ runTagSelTracks<PidTpcOrTof>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
1152+ }
1153+
1154+ if (doPvRefit) { // / fill table with PV refit info (it has to be filled per track and not track index)
1155+ fillPvRefitTable (pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
10981156 }
10991157 }
11001158
@@ -1106,13 +1164,27 @@ struct HfTrackIndexSkimCreatorTagSelTracks {
11061164 aod::BCsWithTimestamps const & bcWithTimeStamps)
11071165 {
11081166 rowSelectedTrack.reserve (tracks.size ());
1167+ // prepare vectors to cache quantities needed for PV refit
1168+ std::vector<std::array<float , 2 >> pvRefitDcaPerTrack{};
1169+ std::vector<std::array<float , 3 >> pvRefitPvCoordPerTrack{};
1170+ std::vector<std::array<float , 6 >> pvRefitPvCovMatrixPerTrack{};
1171+ if (doPvRefit) {
1172+ auto numTracks = tracks.size ();
1173+ pvRefitDcaPerTrack.resize (numTracks);
1174+ pvRefitPvCoordPerTrack.resize (numTracks);
1175+ pvRefitPvCovMatrixPerTrack.resize (numTracks);
1176+ tabPvRefitTrack.reserve (numTracks);
1177+ }
11091178
11101179 for (const auto & collision : collisions) {
11111180 auto thisCollId = collision.globalIndex ();
11121181 auto groupedTrackIndices = trackIndices.sliceBy (trackIndicesPerCollision, thisCollId);
1113- auto groupedTracks = tracks.sliceBy (tracksWithPidTpcTofPerCollision, thisCollId); // we need to know the number of tracks in this collision and the offset for the PV refit
11141182 auto pvContrCollision = pvContributorsWithPidTpcTof->sliceByCached (aod::track::collisionId, thisCollId, cache);
1115- runTagSelTracks<PidTpcAndTof>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, groupedTracks.size (), groupedTracks.offset ());
1183+ runTagSelTracks<PidTpcAndTof>(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
1184+ }
1185+
1186+ if (doPvRefit) { // / fill table with PV refit info (it has to be filled per track and not track index)
1187+ fillPvRefitTable (pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack);
11161188 }
11171189 }
11181190
0 commit comments