Skip to content

Commit 9f18cc7

Browse files
committed
Make sure extra tracks are randomized to avoid PHOS hole losses
The tracks with TRD/TOF are prioritized as of higher quality and we accept a limited min. amount of tracks per TF (1) before swithing to extra tracks (whose max accepted number is also capped). Therefore this guaranteed minimum will be typically affected by the PHOS hole, the same is true for the ITS-TPC stripped versions of these global tracks which are added for additional processing if ITS only extrapolation is asked. When processing extra tracks, the algorithm was considering only these stripped ITS-TPC tracks, so the ITS extrapolation were also affected by the PHOS hole. This PR makes sure that the extra tracks processing starts from the first seed abandoned due to meeting the condition (1), and that the remaining tracks are processed in the random order.
1 parent bbef7a7 commit 9f18cc7

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

DataFormats/Headers/include/Headers/Stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct Stack {
3939
struct freeobj {
4040
freeobj(memory_resource* mr, size_t s) : resource(mr), size(s) {}
4141
memory_resource* resource{nullptr};
42-
size_t size{0};
42+
size_t size{0};
4343
void operator()(std::byte* ptr) { resource->deallocate(ptr, size, alignof(std::max_align_t)); }
4444
};
4545

Detectors/TPC/calibration/SpacePoints/src/TrackInterpolation.cxx

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void TrackInterpolation::process()
272272
trackIndices.insert(trackIndices.end(), mTrackIndices[mTrackTypes[GTrackID::ITSTPCTOF]].begin(), mTrackIndices[mTrackTypes[GTrackID::ITSTPCTOF]].end());
273273
trackIndices.insert(trackIndices.end(), mTrackIndices[mTrackTypes[GTrackID::ITSTPC]].begin(), mTrackIndices[mTrackTypes[GTrackID::ITSTPC]].end());
274274

275-
int nSeeds = mSeeds.size();
275+
int nSeeds = mSeeds.size(), lastChecked = 0;
276276
int maxOutputTracks = (mMaxTracksPerTF >= 0) ? mMaxTracksPerTF + mAddTracksForMapPerTF : nSeeds;
277277
mTrackData.reserve(maxOutputTracks);
278278
mClRes.reserve(maxOutputTracks * param::NPadRows);
@@ -286,51 +286,65 @@ void TrackInterpolation::process()
286286
if (mParams->enableTrackDownsampling && !isTrackSelected(mSeeds[seedIndex])) {
287287
continue;
288288
}
289+
290+
auto addPart = [this, seedIndex](GTrackID::Source src) {
291+
this->mGIDs.push_back(this->mGIDtables[seedIndex][src]);
292+
this->mGIDtables.push_back(this->mRecoCont->getSingleDetectorRefs(this->mGIDs.back()));
293+
this->mTrackTimes.push_back(this->mTrackTimes[seedIndex]);
294+
this->mSeeds.push_back(this->mSeeds[seedIndex]);
295+
};
296+
297+
GTrackID::mask_t partsAdded;
289298
if (!mSingleSourcesConfigured && !mSourcesConfiguredMap[mGIDs[seedIndex].getSource()]) {
290299
auto src = findValidSource(mSourcesConfiguredMap, static_cast<GTrackID::Source>(mGIDs[seedIndex].getSource()));
291300
if (src == GTrackID::ITSTPCTRD || src == GTrackID::ITSTPC) {
292-
LOGP(debug, "process: Found valid source {}", GTrackID::getSourceName(src));
293-
mGIDs.push_back(mGIDtables[seedIndex][src]);
294-
mGIDtables.push_back(mRecoCont->getSingleDetectorRefs(mGIDs.back()));
295-
mTrackTimes.push_back(mTrackTimes[seedIndex]);
296-
mSeeds.push_back(mSeeds[seedIndex]);
301+
LOGP(debug, "process {}: Found valid source {} for {} | nseeds:{} mSeeds:{} used: {}", iSeed, GTrackID::getSourceName(src), GTrackID::getSourceName(mGIDs[seedIndex].getSource()), nSeeds, mSeeds.size(), mTrackDataCompact.size());
302+
addPart(src);
297303
}
298304
}
299305
if (mMaxTracksPerTF >= 0 && mTrackDataCompact.size() >= mMaxTracksPerTF) {
300-
LOG(debug) << "We already have reached mMaxTracksPerTF, but we continue to create seeds until mAddTracksForMapPerTF is also reached";
306+
if (!maxTracksReached) {
307+
LOGP(info, "We already have reached mMaxTracksPerTF={}, but we continue to create seeds until mAddTracksForMapPerTF={} is also reached, iSeed: {} of {} inital seeds", mMaxTracksPerTF, mAddTracksForMapPerTF, iSeed, nSeeds);
308+
}
309+
maxTracksReached = true;
301310
continue;
302311
}
303312
if (mGIDs[seedIndex].includesDet(DetID::TRD) || mGIDs[seedIndex].includesDet(DetID::TOF)) {
304313
interpolateTrack(seedIndex);
314+
LOGP(debug, "interpolateTrack {} {}, accepted: {}", iSeed, GTrackID::getSourceName(mGIDs[seedIndex].getSource()), mTrackDataCompact.size());
305315
if (mProcessSeeds) {
306-
if (mGIDs[seedIndex].includesDet(DetID::TRD) && mGIDs[seedIndex].includesDet(DetID::TOF)) {
307-
mGIDs.push_back(mGIDtables[seedIndex][GTrackID::ITSTPCTRD]);
308-
mGIDtables.push_back(mRecoCont->getSingleDetectorRefs(mGIDs.back()));
309-
mTrackTimes.push_back(mTrackTimes[seedIndex]);
310-
mSeeds.push_back(mSeeds[seedIndex]);
316+
if (mGIDs[seedIndex].includesDet(DetID::TRD) && mGIDs[seedIndex].includesDet(DetID::TOF) && !partsAdded[GTrackID::ITSTPCTRD]) {
317+
addPart(GTrackID::ITSTPCTRD);
318+
}
319+
if (!partsAdded[GTrackID::ITSTPC]) {
320+
addPart(GTrackID::ITSTPC);
311321
}
312-
mGIDs.push_back(mGIDtables[seedIndex][GTrackID::ITSTPC]);
313-
mGIDtables.push_back(mRecoCont->getSingleDetectorRefs(mGIDs.back()));
314-
mTrackTimes.push_back(mTrackTimes[seedIndex]);
315-
mSeeds.push_back(mSeeds[seedIndex]);
316322
}
317323
} else {
318324
extrapolateTrack(seedIndex);
325+
LOGP(debug, "extrapolateTrack {} {}, accepted: {}", iSeed, GTrackID::getSourceName(mGIDs[seedIndex].getSource()), mTrackDataCompact.size());
319326
}
327+
lastChecked = iSeed;
320328
}
321-
if (mSeeds.size() > nSeeds) {
322-
LOGP(info, "Up to {} tracks out of {} additional seeds will be processed", mAddTracksForMapPerTF, mSeeds.size() - nSeeds);
329+
std::vector<int> remSeeds;
330+
if (mSeeds.size() > ++lastChecked) {
331+
remSeeds.resize(mSeeds.size() - lastChecked);
332+
std::iota(remSeeds.begin(), remSeeds.end(), lastChecked);
333+
std::shuffle(remSeeds.begin(), remSeeds.end(), g);
334+
LOGP(info, "Up to {} tracks out of {} additional seeds will be processed in random order, of which {} are stripped versions, accepted seeds: {}", mAddTracksForMapPerTF, remSeeds.size(), mSeeds.size() - nSeeds, mTrackDataCompact.size());
323335
}
324-
for (int iSeed = nSeeds; iSeed < (int)mSeeds.size(); ++iSeed) {
325-
if (!mProcessSeeds && mAddTracksForMapPerTF > 0 && mTrackDataCompact.size() >= mMaxTracksPerTF + mAddTracksForMapPerTF) {
326-
LOG(info) << "Maximum number of additional tracks per TF reached. Skipping the remaining " << mSeeds.size() - iSeed << " tracks.";
336+
int extraChecked = 0;
337+
for (int iSeed : remSeeds) {
338+
if (mAddTracksForMapPerTF > 0 && mTrackDataCompact.size() >= mMaxTracksPerTF + mAddTracksForMapPerTF) {
339+
LOGP(info, "Maximum number {} of additional tracks per TF reached. Skipping the remaining {} tracks", mAddTracksForMapPerTF, remSeeds.size() - extraChecked);
327340
break;
328341
}
329-
// this loop will only be entered in case mProcessSeeds is set
330-
LOGP(debug, "Processing additional track {}", mGIDs[iSeed].asString());
342+
extraChecked++;
331343
if (mGIDs[iSeed].includesDet(DetID::TRD) || mGIDs[iSeed].includesDet(DetID::TOF)) {
332344
interpolateTrack(iSeed);
345+
LOGP(debug, "extra check {} of {}, seed {} interpolateTrack {}, used: {}", extraChecked, remSeeds.size(), iSeed, GTrackID::getSourceName(mGIDs[iSeed].getSource()), mTrackDataCompact.size());
333346
} else {
347+
LOGP(debug, "extra check {} of {}, seed {} extrapolateTrack {}, used: {}", extraChecked, remSeeds.size(), iSeed, GTrackID::getSourceName(mGIDs[iSeed].getSource()), mTrackDataCompact.size());
334348
extrapolateTrack(iSeed);
335349
}
336350
}

0 commit comments

Comments
 (0)