Skip to content

Commit 590f5a6

Browse files
authored
Merge 109c166 into sapling-pr-archive-ktf
2 parents 305149f + 109c166 commit 590f5a6

31 files changed

Lines changed: 711 additions & 444 deletions

File tree

CCDB/src/CcdbApi.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ void CcdbApi::init(std::string const& host)
213213
snapshotReport += ')';
214214
}
215215

216-
mNeedAlienToken = (host.find("https://") != std::string::npos) || (host.find("alice-ccdb.cern.ch") != std::string::npos);
217-
216+
mNeedAlienToken = (host.find("https://") != std::string::npos) || (host.find("alice-ccdb.cern.ch") != std::string::npos) || (host.find("ccdb-test.cern.ch") != std::string::npos);
218217
// Set the curl timeout. It can be forced with an env var or it has different defaults based on the deployment mode.
219218
if (getenv("ALICEO2_CCDB_CURL_TIMEOUT_DOWNLOAD")) {
220219
auto timeout = atoi(getenv("ALICEO2_CCDB_CURL_TIMEOUT_DOWNLOAD"));

DataFormats/Detectors/ITSMFT/ITS/include/DataFormatsITS/TrackITS.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ class TrackITSExt : public TrackITS
192192
getClusterRefs().setEntries(ncl);
193193
}
194194

195-
GPUhdi() const int& getClusterIndex(int lr) const { return mIndex[lr]; }
195+
GPUhdi() const int getClusterIndex(int lr) const { return mIndex[lr]; }
196+
197+
GPUh() const int getFirstLayerClusterIndex() const
198+
{
199+
int firstLayer = getFirstClusterLayer();
200+
return getClusterIndex(firstLayer);
201+
}
196202

197203
GPUhdi() void setExternalClusterIndex(int layer, int idx, bool newCluster = false)
198204
{

Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void CheckResidSpec::init(InitContext& ic)
132132
int maxLanes = ic.services().get<const o2::framework::DeviceSpec>().maxInputTimeslices;
133133
std::string nm = params.outname;
134134
if (maxLanes > 1) {
135-
o2::conf::ConfigurableParam::updateFromString(fmt::format("checkresid.outname={}_{}", nm, lane));
135+
o2::conf::ConfigurableParam::updateFromString(fmt::format("checkresid.outname={}_t{}", nm, lane));
136136
}
137137
if (mDraw) {
138138
mFillHistos = true;
@@ -173,8 +173,7 @@ void CheckResidSpec::init(InitContext& ic)
173173
mNThreads = 1;
174174
#endif
175175
if (mFillTree) {
176-
nm += ".root";
177-
mDBGOut = std::make_unique<o2::utils::TreeStreamRedirector>(nm.c_str(), "recreate");
176+
mDBGOut = std::make_unique<o2::utils::TreeStreamRedirector>(fmt::format("{}.root", params.outname).c_str(), "recreate");
178177
}
179178
}
180179

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackerTraitsGPU.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
387387
mTimeFrameGPU->downloadTrackITSExtDevice();
388388

389389
auto& tracks = mTimeFrameGPU->getTrackITSExt();
390-
this->acceptTracks(iteration, tracks, firstClusters, sharedFirstClusters);
390+
this->acceptTracks(iteration, tracks, firstClusters);
391391
mTimeFrameGPU->loadUsedClustersDevice();
392392
}
393-
this->markTracks(iteration, sharedFirstClusters);
393+
this->markTracks(iteration);
394394
// wipe the artefact memory
395395
mTimeFrameGPU->popMemoryStack(iteration);
396396
};

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ struct TrackingParameters {
7070
float DiamondCov[6] = {25.e-6f, 0.f, 0.f, 25.e-6f, 0.f, 36.f};
7171

7272
/// General parameters
73-
bool AllowSharingFirstCluster = false;
7473
int ClusterSharing = 0;
7574
int MinTrackLength = 7;
7675
int MaxHoles = 0;
@@ -98,6 +97,12 @@ struct TrackingParameters {
9897
bool PrintMemory = false; // print allocator usage in epilog report
9998
size_t MaxMemory = std::numeric_limits<size_t>::max();
10099
bool DropTFUponFailure = false;
100+
101+
// Selections on tracks sharing clusters
102+
bool AllowSharingFirstCluster = false;
103+
float SharedClusterMaxDeltaPhi = 0.05f; // For tracks sharing clusters, maximum allowed delta phi at the cluster position
104+
float SharedClusterMaxDeltaEta = 0.03f; // For tracks sharing clusters, maximum allowed delta eta at the cluster position
105+
bool SharedClusterOppositeSign = false; // For tracks sharing clusters, require opposite sign of the tracklets
101106
};
102107

103108
struct VertexingParameters {

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class TrackerTraits
5555
template <typename InputSeed>
5656
void processNeighbours(int iteration, int defaultCellTopologyId, int iLevel, const bounded_vector<InputSeed>& currentCellSeed, const bounded_vector<int>& currentCellId, const bounded_vector<int>& currentCellTopologyId, bounded_vector<TrackSeedN>& updatedCellSeed, bounded_vector<int>& updatedCellId, bounded_vector<int>& updatedCellTopologyId);
5757

58-
void acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters, bounded_vector<bounded_vector<int>>& sharedFirstClusters);
59-
void markTracks(int iteration, bounded_vector<bounded_vector<int>>& sharedFirstClusters);
58+
void acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters);
59+
void markTracks(int iteration);
6060

6161
void updateTrackingParameters(const std::vector<TrackingParameters>& trkPars)
6262
{

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerPara
102102
size_t maxMemory = std::numeric_limits<size_t>::max();
103103
bool dropTFUponFailure = false;
104104
bool fataliseUponFailure = true; // granular management of the fatalisation in async mode
105+
106+
// Selections on tracks sharing clusters
105107
bool allowSharingFirstCluster = false; // allow first cluster sharing among tracks
108+
float sharedClusterMaxDeltaPhi = 0.05f; // Maximum allowed delta phi at the cluster position
109+
float sharedClusterMaxDeltaEta = 0.03f; // Maximum allowed delta eta at the cluster position
110+
bool sharedClusterOppositeSign = false; // Require opposite sign of the tracklets
106111

107112
O2ParamDef(TrackerParamConfig, "ITSCATrackerParam");
108113
};

Detectors/ITSMFT/ITS/tracking/src/Configuration.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ std::vector<TrackingParameters> TrackingMode::getTrackingParameters(TrackingMode
204204
p.SaveTimeBenchmarks = tc.saveTimeBenchmarks;
205205
p.FataliseUponFailure = tc.fataliseUponFailure;
206206
p.AllowSharingFirstCluster = tc.allowSharingFirstCluster;
207+
p.SharedClusterMaxDeltaPhi = tc.sharedClusterMaxDeltaPhi;
208+
p.SharedClusterMaxDeltaEta = tc.sharedClusterMaxDeltaEta;
209+
p.SharedClusterOppositeSign = tc.sharedClusterOppositeSign;
207210
const auto iter = &p - trackParams.data();
208211
if (iter < constants::MaxIter) {
209212
p.MaxHoles = tc.maxHolesIter[iter];

Detectors/ITSMFT/ITS/tracking/src/FastMultEst.cxx

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -168,85 +168,41 @@ int FastMultEst::selectROFs(const std::array<gsl::span<const o2::itsmft::ROFReco
168168
ROFMaskTableN& sel)
169169
{
170170
const auto& multEstConf = FastMultEstConfig::Instance(); // parameters for mult estimation and cuts
171-
const int selectionLayer = overlapView.getClock();
172-
int multLayer = std::clamp(multEstConf.cutMultClusLayer, 0, NLayers - 1);
173-
if (doStaggering && rofs[multLayer].empty()) {
174-
LOGP(info, "FastMultEst multiplicity layer {} has no ROFs, falling back to selection layer {}", multLayer, selectionLayer);
175-
multLayer = selectionLayer;
176-
}
177-
178-
const auto multCounts = buildMultiplicityCounts<NLayers>(rofs, clus, doStaggering, multLayer);
171+
const int selectionLayer = multEstConf.isMultCutRequested() ? std::clamp(multEstConf.cutMultClusLayer, 0, NLayers - 1) : overlapView.getClock();
172+
const auto multCounts = buildMultiplicityCounts<NLayers>(rofs, clus, doStaggering, selectionLayer);
179173
const int selectionRofCount = doStaggering ? static_cast<int>(rofs[selectionLayer].size()) : static_cast<int>(rofs[0].size());
180174

181175
sel.resetMask();
182176
lastRandomSeed = gRandom->GetSeed();
183177
const o2::InteractionRecord tfStartIR{0, firstTForbit};
184-
185-
if (!trig.empty()) {
178+
// mask ROFs which are not good from the multiplicity selection (if any) POV
179+
struct ROFStatus {
180+
int entry = 0, priority = 0;
181+
};
182+
std::vector<ROFStatus> selROFs;
183+
selROFs.reserve(selectionRofCount);
184+
bool selmult = multEstConf.isMultCutRequested();
185+
for (int selectionRof = 0; selectionRof < selectionRofCount; ++selectionRof) {
186+
selROFs.emplace_back(selectionRof, (selmult && !multEstConf.isPassingMultCut(process(multCounts[selectionRof]))) ? -1 : 0);
187+
}
188+
if (!trig.empty() && multEstConf.preferTriggered) {
186189
const auto& selectionLayerTiming = overlapView.getLayer(selectionLayer);
187-
const auto& multLayerTiming = overlapView.getLayer(multLayer);
188-
189190
for (const auto& trigger : trig) {
190191
const int selectionRof = findROFForIR(trigger.ir, tfStartIR, selectionLayerTiming);
191-
if (selectionRof < 0) {
192-
continue;
193-
}
194-
if (multEstConf.cutRandomFraction > 0.f && gRandom->Rndm() < multEstConf.cutRandomFraction) {
195-
continue;
196-
}
197-
if (multEstConf.isMultCutRequested()) {
198-
const int triggerMultRof = doStaggering ? findROFForIR(trigger.ir, tfStartIR, multLayerTiming) : selectionRof;
199-
if (triggerMultRof < 0 || triggerMultRof >= static_cast<int>(multCounts.size())) {
200-
continue;
201-
}
202-
if (!multEstConf.isPassingMultCut(process(multCounts[triggerMultRof]))) {
203-
continue;
204-
}
205-
}
206-
enableCompatibleROFs<NLayers>(selectionLayer, selectionRof, overlapView, sel);
207-
}
208-
} else {
209-
LOGP(info, "FastMultEst received no physics/TRD triggers, falling back to ROF-driven filtering on layer {}", selectionLayer);
210-
for (int selectionRof = 0; selectionRof < selectionRofCount; ++selectionRof) {
211-
if (multEstConf.isMultCutRequested()) {
212-
bool passes = false;
213-
if (!doStaggering || selectionLayer == multLayer) {
214-
if (selectionRof < static_cast<int>(multCounts.size())) {
215-
passes = multEstConf.isPassingMultCut(process(multCounts[selectionRof]));
216-
}
217-
} else {
218-
const auto& overlap = overlapView.getOverlap(selectionLayer, multLayer, selectionRof);
219-
for (int rof = overlap.getFirstEntry(); rof < overlap.getEntriesBound(); ++rof) {
220-
if (rof < static_cast<int>(multCounts.size())) {
221-
if (multEstConf.isPassingMultCut(process(multCounts[rof]))) {
222-
passes = true;
223-
break;
224-
}
225-
}
226-
}
227-
}
228-
if (!passes) {
229-
continue;
230-
}
231-
}
232-
if (multEstConf.cutRandomFraction > 0.f && gRandom->Rndm() < multEstConf.cutRandomFraction) {
192+
if (selectionRof < 0 || selROFs[selectionRof].priority < 0) {
233193
continue;
234194
}
235-
enableCompatibleROFs<NLayers>(selectionLayer, selectionRof, overlapView, sel);
195+
selROFs[selectionRof].priority++; // increment trigger counter
236196
}
197+
sort(selROFs.begin(), selROFs.end(), [](const ROFStatus& a, const ROFStatus& b) { return a.priority > b.priority; }); // order in number of triggers, masked will go to the end
237198
}
238-
239-
const auto selView = sel.getView();
240199
int nsel = 0;
241-
for (int irof = 0; irof < selectionRofCount; ++irof) {
242-
nsel += selView.isROFEnabled(selectionLayer, irof);
243-
}
244-
245-
if (!trig.empty() && multEstConf.preferTriggered) {
246-
LOGP(debug, "FastMultEst preferTriggered is ignored in trigger-driven mask mode");
200+
for (auto& rof : selROFs) {
201+
if (rof.priority >= 0 && (multEstConf.cutRandomFraction <= 0.f || (gRandom->Rndm() > multEstConf.cutRandomFraction))) {
202+
enableCompatibleROFs<NLayers>(selectionLayer, rof.entry, overlapView, sel);
203+
nsel++;
204+
}
247205
}
248-
249206
LOGP(debug, "NSel = {} of {} rofs on layer {} Seeds: before {} after {}", nsel, selectionRofCount, selectionLayer, lastRandomSeed, gRandom->GetSeed());
250-
251207
return nsel;
252208
}

Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,7 @@ template <int NLayers>
661661
void TrackerTraits<NLayers>::findRoads(const int iteration)
662662
{
663663
bounded_vector<bounded_vector<int>> firstClusters(mTrkParams[iteration].NLayers, bounded_vector<int>(mMemoryPool.get()), mMemoryPool.get());
664-
bounded_vector<bounded_vector<int>> sharedFirstClusters(mTrkParams[iteration].NLayers, bounded_vector<int>(mMemoryPool.get()), mMemoryPool.get());
665664
firstClusters.resize(mTrkParams[iteration].NLayers);
666-
sharedFirstClusters.resize(mTrkParams[iteration].NLayers);
667665
const auto propagator = o2::base::Propagator::Instance();
668666
const TrackingFrameInfo* tfInfos[NLayers]{};
669667
const Cluster* unsortedClusters[NLayers]{};
@@ -787,13 +785,13 @@ void TrackerTraits<NLayers>::findRoads(const int iteration)
787785
return track::isBetter(a, b);
788786
});
789787

790-
acceptTracks(iteration, tracks, firstClusters, sharedFirstClusters);
788+
acceptTracks(iteration, tracks, firstClusters);
791789
}
792-
markTracks(iteration, sharedFirstClusters);
790+
markTracks(iteration);
793791
}
794792

795793
template <int NLayers>
796-
void TrackerTraits<NLayers>::acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters, bounded_vector<bounded_vector<int>>& sharedFirstClusters)
794+
void TrackerTraits<NLayers>::acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters)
797795
{
798796
auto& trks = mTimeFrame->getTracks();
799797
trks.reserve(trks.size() + tracks.size());
@@ -860,34 +858,51 @@ void TrackerTraits<NLayers>::acceptTracks(int iteration, bounded_vector<TrackITS
860858

861859
if (mTrkParams[iteration].AllowSharingFirstCluster) {
862860
firstClusters[firstLayer].push_back(firstCluster);
863-
if (isFirstShared) {
864-
sharedFirstClusters[firstLayer].push_back(firstCluster);
865-
}
866861
}
867862
}
868863
}
869864

870865
template <int NLayers>
871-
void TrackerTraits<NLayers>::markTracks(int iteration, bounded_vector<bounded_vector<int>>& sharedFirstClusters)
866+
void TrackerTraits<NLayers>::markTracks(int iteration)
872867
{
873868
if (mTrkParams[iteration].AllowSharingFirstCluster) {
874869
/// Now we have to set the shared cluster flag
875-
for (int iLayer{0}; iLayer < mTrkParams[iteration].NLayers; ++iLayer) {
876-
std::sort(sharedFirstClusters[iLayer].begin(), sharedFirstClusters[iLayer].end());
877-
}
870+
auto& tracks = mTimeFrame->getTracks();
878871

879-
for (auto& track : mTimeFrame->getTracks()) {
880-
int firstLayer{mTrkParams[iteration].NLayers}, firstCluster{constants::UnusedIndex};
881-
for (int iLayer{0}; iLayer < mTrkParams[iteration].NLayers; ++iLayer) {
882-
if (track.getClusterIndex(iLayer) == constants::UnusedIndex) {
883-
continue;
884-
}
885-
firstLayer = iLayer;
886-
firstCluster = track.getClusterIndex(iLayer);
887-
break;
872+
bounded_vector<int> fclusSort(tracks.size(), mMemoryPool.get());
873+
std::iota(fclusSort.begin(), fclusSort.end(), 0);
874+
std::sort(fclusSort.begin(), fclusSort.end(), [&tracks](int a, int b) {
875+
return tracks[a].getFirstLayerClusterIndex() < tracks[b].getFirstLayerClusterIndex();
876+
});
877+
878+
auto areTracksSelected = [this, iteration](const TrackITSExt& t1, const TrackITSExt& t2) {
879+
const auto t1FirstLayer{t1.getFirstClusterLayer()}, t2FirstLayer{t2.getFirstClusterLayer()};
880+
if (t1FirstLayer != t2FirstLayer) {
881+
return false;
882+
}
883+
if (mTimeFrame->getClusterROF(t1FirstLayer, t1.getClusterIndex(t1FirstLayer)) != mTimeFrame->getClusterROF(t2FirstLayer, t2.getClusterIndex(t2FirstLayer))) {
884+
return false;
885+
}
886+
if (!math_utils::isPhiDifferenceBelow(t1.getPhi(), t2.getPhi(), mTrkParams[iteration].SharedClusterMaxDeltaPhi)) {
887+
return false;
888+
}
889+
if (std::abs(t1.getEta() - t2.getEta()) > mTrkParams[iteration].SharedClusterMaxDeltaEta) {
890+
return false;
888891
}
889-
if (std::binary_search(sharedFirstClusters[firstLayer].begin(), sharedFirstClusters[firstLayer].end(), firstCluster)) {
890-
track.setSharedClusters();
892+
if (mTrkParams[iteration].SharedClusterOppositeSign && t1.getSign() == t2.getSign()) {
893+
return false;
894+
}
895+
return true;
896+
};
897+
898+
for (int i{0}; i < static_cast<int>(fclusSort.size()); ++i) {
899+
auto& track = tracks[fclusSort[i]];
900+
for (int j{i + 1}; j < static_cast<int>(fclusSort.size()) && tracks[fclusSort[j]].getFirstLayerClusterIndex() == track.getFirstLayerClusterIndex(); ++j) {
901+
auto& track2 = tracks[fclusSort[j]];
902+
if (areTracksSelected(track, track2)) {
903+
track.setSharedClusters();
904+
track2.setSharedClusters();
905+
}
891906
}
892907
}
893908
}

0 commit comments

Comments
 (0)