@@ -82,6 +82,17 @@ void TrackInterpolation::process(const o2::globaltracking::RecoContainer& inp, c
8282 mTrackData .reserve (nSeeds);
8383 mClRes .reserve (nSeeds * param::NPadRows);
8484
85+ // to obtain ITS-TPC-TRD-TOF track from ITS-TPC-TRD track we fill the trkMap
86+ std::unordered_map<GTrackID, int > trkMap;
87+ for (int iTrk = 0 ; iTrk < nSeeds; ++iTrk) {
88+ const auto & gidTable = (*mGIDtables )[iTrk];
89+ if (!(gidTable[GTrackID::TRD ].isIndexSet () && gidTable[GTrackID::TOF ].isIndexSet ())) {
90+ // no more ITS-TPC-TRD-TOF tracks
91+ break ;
92+ }
93+ trkMap.emplace (std::make_pair (gidTable[GTrackID::ITSTPCTRD ], iTrk));
94+ }
95+
8596 // In case we have more input tracks available than are required per TF
8697 // we want to sample them. But we still prefer global ITS-TPC-TRD-TOF tracks
8798 // over ITS-TPC-TRD tracks and so on. So we have to shuffle the indices
@@ -92,6 +103,7 @@ void TrackInterpolation::process(const o2::globaltracking::RecoContainer& inp, c
92103 std::mt19937 g (rd ());
93104 std::vector<int > trackIndices (nSeeds);
94105 std::iota (trackIndices.begin (), trackIndices.end (), 0 );
106+
95107 std::shuffle (trackIndices.begin (), trackIndices.begin () + trkCounters.at (GTrackID::Source::ITSTPCTRDTOF ), g);
96108 int nTracks = trkCounters.at (GTrackID::Source::ITSTPCTRDTOF );
97109 std::shuffle (trackIndices.begin () + nTracks, trackIndices.begin () + nTracks + trkCounters.at (GTrackID::Source::ITSTPCTRD ), g);
@@ -100,17 +112,30 @@ void TrackInterpolation::process(const o2::globaltracking::RecoContainer& inp, c
100112 nTracks += trkCounters.at (GTrackID::Source::ITSTPCTOF );
101113 std::shuffle (trackIndices.begin () + nTracks, trackIndices.begin () + nTracks + trkCounters.at (GTrackID::Source::ITSTPC ), g);
102114
103- for (int iSeed = 0 ; iSeed < nSeeds; ++iSeed) {
115+ std::vector<int > globalTracksToCheck;
116+ for (int iSeed = trkCounters.at (GTrackID::Source::ITSTPCTRDTOF ); iSeed < nSeeds; ++iSeed) {
104117 if (mMaxTracksPerTF >= 0 && mTrackDataCompact .size () >= mMaxTracksPerTF ) {
105118 LOG (info) << " Maximum number of tracks per TF reached. Skipping the remaining " << nSeeds - iSeed << " tracks." ;
106119 break ;
107120 }
121+ if (auto search = trkMap.find ((*mGIDs )[iSeed]); search != trkMap.end ()) {
122+ globalTracksToCheck.push_back (search->second );
123+ }
108124 if (gids[trackIndices[iSeed]].includesDet (DetID::TRD ) || gids[trackIndices[iSeed]].includesDet (DetID::TOF )) {
109125 interpolateTrack (trackIndices[iSeed]);
110126 } else {
111127 extrapolateTrack (trackIndices[iSeed]);
112128 }
113129 }
130+ // irrespective of the number of tracks already processed, interpolate the ITS-TPC-TRD-TOF tracks
131+ // which belong to the ITS-TPC-TRD tracks that were already processed, to allow their analysis
132+ // offline
133+ // Q: Or should we for these tracks just skip the ITS-TPC-TRD part and do only ITS-TPC-TRD-TOF?
134+ // might still be interesting to compare the two?
135+ LOGP (info, " Processing {} ITS-TPC-TRD-TOF tracks for which the ITS-TPC-TRD track was already done" , globalTracksToCheck.size ());
136+ for (auto iTrk : globalTracksToCheck) {
137+ interpolateTrack (iTrk);
138+ }
114139
115140 LOG (info) << " Could process " << mTrackData .size () << " tracks successfully" ;
116141}
@@ -284,11 +309,7 @@ void TrackInterpolation::interpolateTrack(int iSeed)
284309 }
285310
286311 trackData.gid = (*mGIDs )[iSeed];
287- trackData.x = (*mSeeds )[iSeed].getX ();
288- trackData.alpha = (*mSeeds )[iSeed].getAlpha ();
289- for (int i = 0 ; i < o2::track::kNParams ; ++i) {
290- trackData.p [i] = (*mSeeds )[iSeed].getParam (i);
291- }
312+ trackData.par = (*mSeeds )[iSeed];
292313 trackData.chi2TRD = gidTable[GTrackID::TRD ].isIndexSet () ? mRecoCont ->getITSTPCTRDTrack <o2::trd::TrackTRD>(gidTable[GTrackID::ITSTPCTRD ]).getChi2 () : 0 ;
293314 trackData.chi2TPC = trkTPC.getChi2 ();
294315 trackData.chi2ITS = trkITS.getChi2 ();
@@ -365,11 +386,7 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
365386 ++nMeasurements;
366387 }
367388 trackData.gid = (*mGIDs )[iSeed];
368- trackData.x = (*mSeeds )[iSeed].getX ();
369- trackData.alpha = (*mSeeds )[iSeed].getAlpha ();
370- for (int i = 0 ; i < o2::track::kNParams ; ++i) {
371- trackData.p [i] = (*mSeeds )[iSeed].getParam (i);
372- }
389+ trackData.par = (*mSeeds )[iSeed];
373390 trackData.chi2TPC = trkTPC.getChi2 ();
374391 trackData.chi2ITS = trkITS.getChi2 ();
375392 trackData.nClsTPC = trkTPC.getNClusterReferences ();
@@ -437,7 +454,7 @@ bool TrackInterpolation::compareToHelix(const TrackData& trk, TrackParams& param
437454 std::array<float , param::NPadRows> yLab;
438455 std::array<float , param::NPadRows> sPath ;
439456
440- float curvature = fabsf (trk.p [o2::track::ParLabels:: kQ2Pt ] * mBz * o2::constants::physics::LightSpeedCm2S * 1e-14f );
457+ float curvature = fabsf (trk.par . getQ2Pt () * mBz * o2::constants::physics::LightSpeedCm2S * 1e-14f );
441458 int secFirst = clsRes[0 ].sec ;
442459 float phiSect = (secFirst + .5f ) * o2::constants::math::SectorSpanRad;
443460 float snPhi = sin (phiSect);
0 commit comments