Skip to content

Commit 6b4159b

Browse files
committed
Move ITS/TPC matching from MCTruthContainer to vector for track labels
1 parent 6c7865c commit 6b4159b

3 files changed

Lines changed: 41 additions & 42 deletions

File tree

‎Detectors/GlobalTracking/include/GlobalTracking/MatchTPCITS.h‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ class MatchTPCITS
269269
{
270270
using ITSCluster = o2::BaseCluster<float>;
271271
using ClusRange = o2::dataformats::RangeReference<int, int>;
272-
using MCLabCont = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
272+
using MCLabContCl = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
273+
using MCLabContTr = std::vector<o2::MCCompLabel>;
274+
using MCLabSpan = gsl::span<const o2::MCCompLabel>;
273275
using TPCTransform = o2::gpu::TPCFastTransform;
274276
using BracketF = o2::utils::Bracket<float>;
275277
using Params = o2::globaltracking::MatchITSTPCParams;
@@ -392,19 +394,19 @@ class MatchTPCITS
392394
}
393395

394396
///< set input ITS track MC labels
395-
void setITSTrkLabelsInp(const MCLabCont* lbl)
397+
void setITSTrkLabelsInp(const MCLabSpan& lbl)
396398
{
397399
mITSTrkLabels = lbl;
398400
}
399401

400402
///< set input ITS clusters MC labels
401-
void setITSClsLabelsInp(const MCLabCont* lbl)
403+
void setITSClsLabelsInp(const MCLabContCl* lbl)
402404
{
403405
mITSClsLabels = lbl;
404406
}
405407

406408
///< set input TPC track MC labels
407-
void setTPCTrkLabelsInp(const MCLabCont* lbl)
409+
void setTPCTrkLabelsInp(const MCLabSpan& lbl)
408410
{
409411
mTPCTrkLabels = lbl;
410412
}
@@ -423,8 +425,8 @@ class MatchTPCITS
423425
void printCandidatesITS() const;
424426

425427
std::vector<o2::dataformats::TrackTPCITS>& getMatchedTracks() { return mMatchedTracks; }
426-
std::vector<o2::MCCompLabel>& getMatchedITSLabels() { return mOutITSLabels; }
427-
std::vector<o2::MCCompLabel>& getMatchedTPCLabels() { return mOutTPCLabels; }
428+
MCLabContTr& getMatchedITSLabels() { return mOutITSLabels; }
429+
MCLabContTr& getMatchedTPCLabels() { return mOutTPCLabels; }
428430

429431
//>>> ====================== options =============================>>>
430432
void setUseMatCorrFlag(MatCorrType f) { mUseMatCorrFlag = f; }
@@ -477,8 +479,7 @@ class MatchTPCITS
477479
bool prepareFITInfo();
478480

479481
int preselectChipClusters(std::vector<int>& clVecOut, const ClusRange& clRange, const ITSChipClustersRefs& clRefs,
480-
float trackY, float trackZ, float tolerY, float tolerZ,
481-
const o2::MCCompLabel& lblTrc) const;
482+
float trackY, float trackZ, float tolerY, float tolerZ, const o2::MCCompLabel& lblTrc) const;
482483
void fillClustersForAfterBurner(ITSChipClustersRefs& refCont, int rofStart, int nROFs = 1);
483484
void cleanAfterBurnerClusRefCache(int currentIC, int& startIC);
484485
void flagUsedITSClusters(const o2::its::TrackITS& track, int rofOffset);
@@ -625,9 +626,9 @@ class MatchTPCITS
625626

626627
const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr; ///< struct holding the TPC cluster indices
627628

628-
const MCLabCont* mITSTrkLabels = nullptr; ///< input ITS Track MC labels
629-
const MCLabCont* mITSClsLabels = nullptr; ///< input ITS Cluster MC labels
630-
const MCLabCont* mTPCTrkLabels = nullptr; ///< input TPC Track MC labels
629+
const MCLabContCl* mITSClsLabels = nullptr; ///< input ITS Cluster MC labels
630+
MCLabSpan mITSTrkLabels; ///< input ITS Track MC labels
631+
MCLabSpan mTPCTrkLabels; ///< input TPC Track MC labels
631632
/// <<<-----
632633

633634
std::vector<InteractionCandidate> mInteractions; ///< possible interaction times
@@ -642,8 +643,8 @@ class MatchTPCITS
642643
std::vector<BracketF> mITSROFTimes; ///< min/max times of ITS ROFs in TPC time-bins
643644
std::vector<TrackLocTPC> mTPCWork; ///< TPC track params prepared for matching
644645
std::vector<TrackLocITS> mITSWork; ///< ITS track params prepared for matching
645-
std::vector<o2::MCCompLabel> mTPCLblWork; ///< TPC track labels
646-
std::vector<o2::MCCompLabel> mITSLblWork; ///< ITS track labels
646+
MCLabContTr mTPCLblWork; ///< TPC track labels
647+
MCLabContTr mITSLblWork; ///< ITS track labels
647648
std::vector<float> mWinnerChi2Refit; ///< vector of refitChi2 for winners
648649

649650
std::deque<ITSChipClustersRefs> mITSChipClustersRefs; ///< range of clusters for each chip in ITS (for AfterBurner)
@@ -676,8 +677,8 @@ class MatchTPCITS
676677

677678
///< outputs tracks container
678679
std::vector<o2::dataformats::TrackTPCITS> mMatchedTracks;
679-
std::vector<o2::MCCompLabel> mOutITSLabels; ///< ITS label of matched track
680-
std::vector<o2::MCCompLabel> mOutTPCLabels; ///< TPC label of matched track
680+
MCLabContTr mOutITSLabels; ///< ITS label of matched track
681+
MCLabContTr mOutTPCLabels; ///< TPC label of matched track
681682

682683
o2::its::RecoGeomHelper mRGHelper; ///< helper for cluster and geometry access
683684
float mITSFiducialZCut = 9999.; ///< eliminate TPC seeds outside of this range

‎Detectors/GlobalTracking/src/MatchTPCITS.cxx‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ void MatchTPCITS::printABTracksTree(const ABTrackLinksList& llist) const
6565
return;
6666
}
6767
o2::MCCompLabel lblTrc;
68-
if (mTPCTrkLabels) {
69-
lblTrc = mTPCTrkLabels->getLabels(mTPCWork[llist.trackID].sourceID)[0];
68+
if (mMCTruthON) {
69+
lblTrc = mTPCTrkLabels[mTPCWork[llist.trackID].sourceID];
7070
}
7171
LOG(INFO) << "Matches for track " << llist.trackID << " lowest lr: " << int(llist.lowestLayer) << " " << lblTrc
7272
<< " pT= " << mTPCWork[llist.trackID].getPt();
7373

7474
auto printHyp = [this, &lblTrc](int nextHyp, int cnt) {
75-
printf("#%d Lr/IC/Lnk/ClID/Chi2/Chi2Nrm/{MC}:%c ", cnt++, mTPCTrkLabels ? (lblTrc.isFake() ? 'F' : 'C') : '-');
75+
printf("#%d Lr/IC/Lnk/ClID/Chi2/Chi2Nrm/{MC}:%c ", cnt++, mTPCTrkLabels.size() ? (lblTrc.isFake() ? 'F' : 'C') : '-');
7676
int nFakeClus = 0, nTotClus = 0, parID = nextHyp; // print particular hypothesis
7777
while (1) {
7878
const auto& lnk = mABTrackLinks[parID];
@@ -90,7 +90,7 @@ void MatchTPCITS::printABTracksTree(const ABTrackLinksList& llist) const
9090
mcEv = mcTr = -999; // noise
9191
nFakeClus++;
9292
}
93-
} else if (lnk.isDummyTop() && mTPCTrkLabels) { // top layer, use TPC MC lbl
93+
} else if (lnk.isDummyTop() && mMCTruthON) { // top layer, use TPC MC lbl
9494
mcEv = lblTrc.getEventID();
9595
mcTr = lblTrc.getTrackID();
9696
}
@@ -138,8 +138,8 @@ void MatchTPCITS::dumpABTracksDebugTree(const ABTrackLinksList& llist)
138138
}
139139
LOG(INFO) << "Dump AB Matches for track " << llist.trackID;
140140
o2::MCCompLabel lblTrc;
141-
if (mTPCTrkLabels) {
142-
lblTrc = mTPCTrkLabels->getLabels(mTPCWork[llist.trackID].sourceID)[0]; // tmp
141+
if (mMCTruthON) {
142+
lblTrc = mTPCTrkLabels[mTPCWork[llist.trackID].sourceID]; // tmp
143143
}
144144
int ord = 0;
145145
for (int lowest = llist.lowestLayer; lowest <= mParams->requireToReachLayerAB; lowest++) {
@@ -545,7 +545,7 @@ bool MatchTPCITS::prepareTPCTracks()
545545
continue;
546546
}
547547
if (mMCTruthON) {
548-
mTPCLblWork.emplace_back(mTPCTrkLabels->getLabels(it)[0]);
548+
mTPCLblWork.emplace_back(mTPCTrkLabels[it]);
549549
}
550550

551551
float time0 = trcOrig.getTime0();
@@ -711,7 +711,7 @@ bool MatchTPCITS::prepareITSTracks()
711711
continue; // add to cache only those ITS tracks which reached ref.X and have reasonable snp
712712
}
713713
if (mMCTruthON) {
714-
mITSLblWork.emplace_back(mITSTrkLabels->getLabels(it)[0]);
714+
mITSLblWork.emplace_back(mITSTrkLabels[it]);
715715
}
716716
trc.roFrame = irof;
717717

@@ -1191,7 +1191,7 @@ void MatchTPCITS::addLastTrackCloneForNeighbourSector(int sector)
11911191
// TODO: use faster prop here, no 3d field, materials
11921192
mITSSectIndexCache[sector].push_back(mITSWork.size() - 1); // register track CLONE
11931193
if (mMCTruthON) {
1194-
mITSLblWork.emplace_back(mITSTrkLabels->getLabels(trc.sourceID)[0]);
1194+
mITSLblWork.emplace_back(mITSTrkLabels[trc.sourceID]);
11951195
}
11961196
} else {
11971197
mITSWork.pop_back(); // rotation / propagation failed
@@ -1999,8 +1999,11 @@ int MatchTPCITS::checkABSeedFromLr(int lrSeed, int seedID, ABTrackLinksList& lli
19991999
std::array<int, MaxLadderCand> lad2Check;
20002000
nLad2Check = mFieldON ? findLaddersToCheckBOn(lrTgt, ladIDguess, trcCircle, errYFrac, lad2Check) : findLaddersToCheckBOff(lrTgt, ladIDguess, trcLinPar, errYFrac, lad2Check);
20012001

2002-
const auto& tTPC = mTPCWork[llist.trackID]; // tmp
2003-
auto lblTrc = mTPCTrkLabels->getLabels(tTPC.sourceID)[0]; // tmp
2002+
const auto& tTPC = mTPCWork[llist.trackID]; // tmp
2003+
o2::MCCompLabel lblTrc;
2004+
if (mMCTruthON) {
2005+
lblTrc = mTPCTrkLabels[tTPC.sourceID]; // tmp
2006+
}
20042007
for (int ilad = nLad2Check; ilad--;) {
20052008
int ladID = lad2Check[ilad];
20062009
const auto& lad = lr.ladders[ladID];
@@ -2496,7 +2499,7 @@ bool MatchTPCITS::validateABMatch(int ilink)
24962499
if (linkCl.linkedABTrack != headID) { // best link for this cluster differs from the link we are checking
24972500
return false;
24982501
}
2499-
} else if (lnk.isDummyTop() && mTPCTrkLabels) { // top layer reached, this is winner
2502+
} else if (lnk.isDummyTop()) { // top layer reached, this is winner
25002503
break;
25012504
}
25022505
parID = lnk.parentID; // check next cluster of the same link

‎Detectors/GlobalTrackingWorkflow/src/TPCITSMatchingSpec.cxx‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
#include "DetectorsRaw/HBFUtils.h"
4040

4141
using namespace o2::framework;
42-
using MCLabelContainer = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
42+
using MCLabelsCl = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
43+
using MCLabelsTr = gsl::span<const o2::MCCompLabel>;
4344

4445
namespace o2
4546
{
@@ -197,24 +198,18 @@ void TPCITSMatchingDPL::run(ProcessingContext& pc)
197198
//----------------------------<< TPC Clusters loading <<------------------------------------------
198199

199200
//
200-
const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* lblITSPtr = nullptr;
201-
std::unique_ptr<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>> lblITS;
201+
MCLabelsTr lblITS;
202+
MCLabelsTr lblTPC;
202203

203-
const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* lblClusITSPtr = nullptr;
204-
std::unique_ptr<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>> lblClusITS;
205-
206-
const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* lblTPCPtr = nullptr;
207-
std::unique_ptr<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>> lblTPC;
204+
const MCLabelsCl* lblClusITSPtr = nullptr;
205+
std::unique_ptr<const MCLabelsCl> lblClusITS;
208206

209207
if (mUseMC) {
210-
lblITS = pc.inputs().get<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>*>("trackITSMCTR");
211-
lblITSPtr = lblITS.get();
208+
lblITS = pc.inputs().get<gsl::span<o2::MCCompLabel>>("trackITSMCTR");
209+
lblTPC = pc.inputs().get<gsl::span<o2::MCCompLabel>>("trackTPCMCTR");
212210

213211
lblClusITS = pc.inputs().get<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>*>("clusITSMCTR");
214212
lblClusITSPtr = lblClusITS.get();
215-
216-
lblTPC = pc.inputs().get<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>*>("trackTPCMCTR");
217-
lblTPCPtr = lblTPC.get();
218213
}
219214
//
220215
// create ITS clusters as spacepoints in tracking frame
@@ -234,9 +229,9 @@ void TPCITSMatchingDPL::run(ProcessingContext& pc)
234229
mMatching.setTPCClustersInp(&clusterIndex);
235230

236231
if (mUseMC) {
237-
mMatching.setITSTrkLabelsInp(lblITSPtr);
232+
mMatching.setITSTrkLabelsInp(lblITS);
233+
mMatching.setTPCTrkLabelsInp(lblTPC);
238234
mMatching.setITSClsLabelsInp(lblClusITSPtr);
239-
mMatching.setTPCTrkLabelsInp(lblTPCPtr);
240235
}
241236

242237
if (mUseFT0) {

0 commit comments

Comments
 (0)