Skip to content

Commit 6a1c8d9

Browse files
committed
Suppress redundant MCLabels in matching outputs
Both ITS-TPC and XXX-TOF (with XXX either TPC or ITS-TPC) matching were producing the vector of label for match constituents. Now only the label for the match is produced. The conventions are: ITS-TPC => label takes the TPC label (source, event, trackID) and is declared fake if ITS_label != TPC_label XXX-TOF => label takes the TOF label (source, event, trackID) and is declared fake if TOF_label != XXX_label The isFake flag of constituents are ignored in the comparison
1 parent 458056d commit 6a1c8d9

File tree

13 files changed

+141
-239
lines changed

13 files changed

+141
-239
lines changed

Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class MatchTOF
9191
void initTPConly();
9292

9393
///< attach DPL data and run
94-
void run(const gsl::span<const o2::dataformats::TrackTPCITS>& trackArray, const gsl::span<const Cluster>& clusterArray, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>& toflab, const gsl::span<const o2::MCCompLabel>& itslab, const gsl::span<const o2::MCCompLabel>& tpclab);
94+
void run(const gsl::span<const o2::dataformats::TrackTPCITS>& trackArray, const gsl::span<const Cluster>& clusterArray, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>& toflab, const gsl::span<const o2::MCCompLabel>& itstpclab);
9595
void run(const gsl::span<const o2::tpc::TrackTPC>& trackArray, const gsl::span<const Cluster>& clusterArray, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>& toflab, const gsl::span<const o2::MCCompLabel>& tpclab);
9696

9797
///< set tree/chain containing tracks
@@ -113,25 +113,19 @@ class MatchTOF
113113
void setTrackBranchName(const std::string& nm) { mTracksBranchName = nm; }
114114
void setTPCTrackBranchName(const std::string& nm) { mTPCTracksBranchName = nm; }
115115
void setTPCMCTruthBranchName(const std::string& nm) { mTPCMCTruthBranchName = nm; }
116-
void setITSMCTruthBranchName(const std::string& nm) { mITSMCTruthBranchName = nm; }
117116
void setTOFMCTruthBranchName(const std::string& nm) { mTOFMCTruthBranchName = nm; }
118117
void setTOFClusterBranchName(const std::string& nm) { mTOFClusterBranchName = nm; }
119118
void setOutTOFMCTruthBranchName(const std::string& nm) { mOutTOFMCTruthBranchName = nm; }
120-
void setOutTPCMCTruthBranchName(const std::string& nm) { mOutTPCMCTruthBranchName = nm; }
121-
void setOutITSMCTruthBranchName(const std::string& nm) { mOutITSMCTruthBranchName = nm; }
122119
void setOutTracksBranchName(const std::string& nm) { mOutTracksBranchName = nm; }
123120
void setOutCalibBranchName(const std::string& nm) { mOutCalibBranchName = nm; }
124121

125122
///< get input branch names for the input from the tree
126123
const std::string& getTracksBranchName() const { return mTracksBranchName; }
127124
const std::string& getTPCTracksBranchName() const { return mTPCTracksBranchName; }
128125
const std::string& getTPCMCTruthBranchName() const { return mTPCMCTruthBranchName; }
129-
const std::string& getITSMCTruthBranchName() const { return mITSMCTruthBranchName; }
130126
const std::string& getTOFMCTruthBranchName() const { return mTOFMCTruthBranchName; }
131127
const std::string& getTOFClusterBranchName() const { return mTOFClusterBranchName; }
132128
const std::string& getOutTOFMCTruthBranchName() const { return mOutTOFMCTruthBranchName; }
133-
const std::string& getOutTPCMCTruthBranchName() const { return mOutTPCMCTruthBranchName; }
134-
const std::string& getOutITSMCTruthBranchName() const { return mOutITSMCTruthBranchName; }
135129

136130
///< print settings
137131
void print() const;
@@ -177,15 +171,13 @@ class MatchTOF
177171

178172
///< fill matching debug tree
179173
void fillTOFmatchTree(const char* tname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, float intLength, float intTimePion, float timeTOF);
180-
void fillTOFmatchTreeWithLabels(const char* tname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, int TPClabelTrackID, int TPClabelEventID, int TPClabelSourceID, int ITSlabelTrackID, int ITSlabelEventID, int ITSlabelSourceID, int TOFlabelTrackID0, int TOFlabelEventID0, int TOFlabelSourceID0, int TOFlabelTrackID1, int TOFlabelEventID1, int TOFlabelSourceID1, int TOFlabelTrackID2, int TOFlabelEventID2, int TOFlabelSourceID2, float intLength, float intTimePion, float timeTOF);
174+
void fillTOFmatchTreeWithLabels(const char* tname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, int TPClabelTrackID, int TPClabelEventID, int TPClabelSourceID, int TOFlabelTrackID0, int TOFlabelEventID0, int TOFlabelSourceID0, int TOFlabelTrackID1, int TOFlabelEventID1, int TOFlabelSourceID1, int TOFlabelTrackID2, int TOFlabelEventID2, int TOFlabelSourceID2, float intLength, float intTimePion, float timeTOF);
181175
void dumpWinnerMatches();
182176

183177
std::vector<o2::dataformats::MatchInfoTOF>& getMatchedTrackVector() { return mMatchedTracks; }
184178
std::vector<o2::dataformats::CalibInfoTOF>& getCalibVector() { return mCalibInfoTOF; }
185179

186180
std::vector<o2::MCCompLabel>& getMatchedTOFLabelsVector() { return mOutTOFLabels; } ///< get vector of TOF label of matched tracks
187-
std::vector<o2::MCCompLabel>& getMatchedTPCLabelsVector() { return mOutTPCLabels; } ///< get vector of TPC label of matched tracks
188-
std::vector<o2::MCCompLabel>& getMatchedITSLabelsVector() { return mOutITSLabels; } ///< get vector of ITS label of matched tracks
189181

190182
// this method is deprecated
191183
void setFITRecPoints(const std::vector<o2::ft0::RecPoints>* recpoints)
@@ -312,9 +304,7 @@ class MatchTOF
312304
std::vector<o2::MCCompLabel> mTracksLblWork; ///<TPCITS track labels
313305

314306
gsl::span<const o2::MCCompLabel> mTPCLabels; ///< TPC label of input tracks
315-
gsl::span<const o2::MCCompLabel> mITSLabels; ///< ITS label of input tracks
316307
std::vector<o2::MCCompLabel>* mTPCLabelsVect; ///< TPC label of input tracks (vector to read from tree)
317-
std::vector<o2::MCCompLabel>* mITSLabelsVect; ///< ITS label of input tracks (vector to read from tree)
318308

319309
gsl::span<o2::ft0::RecPoints const> mFITRecPoints; ///< FIT recpoints
320310

@@ -344,8 +334,6 @@ class MatchTOF
344334
//std::vector<o2::dataformats::MatchInfoTOF> mMatchedTracks;
345335
std::vector<o2::dataformats::MatchInfoTOF> mMatchedTracks; // this is the output of the matching
346336
std::vector<o2::MCCompLabel> mOutTOFLabels; ///< TOF label of matched tracks
347-
std::vector<o2::MCCompLabel> mOutTPCLabels; ///< TPC label of matched tracks
348-
std::vector<o2::MCCompLabel> mOutITSLabels; ///< ITS label of matched tracks
349337

350338
int mNumOfTracks; // number of tracks to be matched
351339
std::vector<int> mMatchedTracksIndex; // vector of indexes of the tracks to be matched
@@ -354,15 +342,12 @@ class MatchTOF
354342

355343
std::string mTracksBranchName = "TPCITS"; ///< name of branch containing input matched tracks
356344
std::string mTPCTracksBranchName = "TPCTracks"; ///< name of branch containing actual TPC tracks
357-
std::string mTPCMCTruthBranchName = "MatchTPCMCTruth"; ///< name of branch containing TPC labels
358-
std::string mITSMCTruthBranchName = "MatchITSMCTruth"; ///< name of branch containing ITS labels
345+
std::string mTPCMCTruthBranchName = "MatchMCTruth"; ///< name of branch containing TPC labels
359346
std::string mTOFMCTruthBranchName = "TOFClusterMCTruth"; ///< name of branch containing TOF clusters labels
360347
std::string mTOFClusterBranchName = "TOFCluster"; ///< name of branch containing input ITS clusters
361348
std::string mOutTracksBranchName = "TOFMatchInfo"; ///< name of branch containing output matched tracks
362349
std::string mOutCalibBranchName = "TOFCalibInfo"; ///< name of branch containing output calibration infos
363350
std::string mOutTOFMCTruthBranchName = "MatchTOFMCTruth"; ///< name of branch containing TOF labels for output matched tracks
364-
std::string mOutTPCMCTruthBranchName = "MatchTPCMCTruth"; ///< name of branch containing TOF labels for output matched tracks
365-
std::string mOutITSMCTruthBranchName = "MatchITSMCTruth"; ///< name of branch containing TOF labels for output matched tracks
366351
std::string mOutTPCTrackMCTruthBranchName = "TPCTracksMCTruth"; ///< name of branch containing TPC labels for input TPC tracks
367352

368353
std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;

Detectors/GlobalTracking/include/GlobalTracking/MatchTPCITS.h

Lines changed: 2 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ class MatchTPCITS
451451
void printCandidatesITS() const;
452452

453453
std::vector<o2::dataformats::TrackTPCITS>& getMatchedTracks() { return mMatchedTracks; }
454-
MCLabContTr& getMatchedITSLabels() { return mOutITSLabels; }
455-
MCLabContTr& getMatchedTPCLabels() { return mOutTPCLabels; }
454+
MCLabContTr& getMatchLabels() { return mOutLabels; }
456455

457456
//>>> ====================== options =============================>>>
458457
void setUseMatCorrFlag(MatCorrType f) { mUseMatCorrFlag = f; }
@@ -730,8 +729,7 @@ class MatchTPCITS
730729

731730
///< outputs tracks container
732731
std::vector<o2::dataformats::TrackTPCITS> mMatchedTracks;
733-
MCLabContTr mOutITSLabels; ///< ITS label of matched track
734-
MCLabContTr mOutTPCLabels; ///< TPC label of matched track
732+
MCLabContTr mOutLabels; ///< Labels: = TPC labels with flag isFake set in case of fake matching
735733

736734
o2::its::RecoGeomHelper mRGHelper; ///< helper for cluster and geometry access
737735
float mITSFiducialZCut = 9999.; ///< eliminate TPC seeds outside of this range
@@ -782,113 +780,6 @@ inline bool MatchTPCITS::isDisabledITS(const TrackLocITS& t) const { return t.ma
782780
//______________________________________________
783781
inline bool MatchTPCITS::isDisabledTPC(const TrackLocTPC& t) const { return t.matchID < 0; }
784782

785-
//______________________________________________
786-
inline void MatchTPCITS::removeTPCfromITS(int tpcID, int itsID)
787-
{
788-
///< remove reference to tpcID track from itsID track matches
789-
auto& tITS = mITSWork[itsID];
790-
if (isValidatedITS(tITS)) {
791-
return;
792-
}
793-
int topID = MinusOne, next = tITS.matchID; // ITS MatchRecord
794-
while (next > MinusOne) {
795-
auto& rcITS = mMatchRecordsITS[next];
796-
if (rcITS.partnerID == tpcID) {
797-
if (topID < 0) {
798-
tITS.matchID = rcITS.nextRecID;
799-
} else {
800-
mMatchRecordsITS[topID].nextRecID = rcITS.nextRecID;
801-
}
802-
return;
803-
}
804-
topID = next;
805-
next = rcITS.nextRecID;
806-
}
807-
}
808-
809-
//______________________________________________
810-
inline void MatchTPCITS::removeITSfromTPC(int itsID, int tpcID)
811-
{
812-
///< remove reference to itsID track from matches of tpcID track
813-
auto& tTPC = mTPCWork[tpcID];
814-
if (isValidatedTPC(tTPC)) {
815-
return;
816-
}
817-
int topID = MinusOne, next = tTPC.matchID;
818-
while (next > MinusOne) {
819-
auto& rcTPC = mMatchRecordsTPC[next];
820-
if (rcTPC.partnerID == itsID) {
821-
if (topID < 0) {
822-
tTPC.matchID = rcTPC.nextRecID;
823-
} else {
824-
mMatchRecordsTPC[topID].nextRecID = rcTPC.nextRecID;
825-
}
826-
return;
827-
}
828-
topID = next;
829-
next = rcTPC.nextRecID;
830-
}
831-
}
832-
833-
//______________________________________________
834-
inline void MatchTPCITS::flagUsedITSClusters(const o2::its::TrackITS& track, int rofOffset)
835-
{
836-
// flag clusters used by this track
837-
int clEntry = track.getFirstClusterEntry();
838-
for (int icl = track.getNumberOfClusters(); icl--;) {
839-
mABClusterLinkIndex[rofOffset + mITSTrackClusIdx[clEntry++]] = MinusTen;
840-
}
841-
}
842-
//__________________________________________________________
843-
inline int MatchTPCITS::preselectChipClusters(std::vector<int>& clVecOut, const ClusRange& clRange, const ITSChipClustersRefs& clRefs,
844-
float trackY, float trackZ, float tolerY, float tolerZ,
845-
const o2::MCCompLabel& lblTrc) const // TODO lbl is not needed
846-
{
847-
clVecOut.clear();
848-
int icID = clRange.getFirstEntry();
849-
for (int icl = clRange.getEntries(); icl--;) { // note: clusters within a chip are sorted in Z
850-
int clID = clRefs.clusterID[icID++]; // so, we go in clusterID increasing direction
851-
const auto& cls = mITSClustersArray[clID];
852-
float dz = trackZ - cls.getZ();
853-
auto label = mITSClsLabels->getLabels(clID)[0]; // tmp
854-
// if (!(label == lblTrc)) {
855-
// continue; // tmp
856-
// }
857-
LOG(DEBUG) << "cl" << icl << '/' << clID << " " << label
858-
<< " dZ: " << dz << " [" << tolerZ << "| dY: " << trackY - cls.getY() << " [" << tolerY << "]";
859-
if (dz > tolerZ) {
860-
float clsZ = cls.getZ();
861-
LOG(DEBUG) << "Skip the rest since " << trackZ << " > " << clsZ << "\n";
862-
break;
863-
} else if (dz < -tolerZ) {
864-
LOG(DEBUG) << "Skip cluster dz=" << dz << " Ztr=" << trackZ << " zCl=" << cls.getZ();
865-
continue;
866-
}
867-
if (fabs(trackY - cls.getY()) > tolerY) {
868-
LOG(DEBUG) << "Skip cluster dy= " << trackY - cls.getY() << " Ytr=" << trackY << " yCl=" << cls.getY();
869-
continue;
870-
}
871-
clVecOut.push_back(clID);
872-
}
873-
return clVecOut.size();
874-
}
875-
876-
//______________________________________________
877-
inline void MatchTPCITS::cleanAfterBurnerClusRefCache(int currentIC, int& startIC)
878-
{
879-
// check if some of cached cluster reference from tables startIC to currentIC can be released,
880-
// they will be necessarily in front slots of the mITSChipClustersRefs
881-
while (startIC < currentIC && mInteractions[currentIC].timeBins.getMin() - mInteractions[startIC].timeBins.getMax() > MinTBToCleanCache) {
882-
LOG(INFO) << "CAN REMOVE CACHE FOR " << startIC << " curent IC=" << currentIC;
883-
while (mInteractions[startIC].clRefPtr == &mITSChipClustersRefs.front()) {
884-
LOG(INFO) << "Reset cache pointer" << mInteractions[startIC].clRefPtr << " for IC=" << startIC;
885-
mInteractions[startIC++].clRefPtr = nullptr;
886-
}
887-
LOG(INFO) << "Reset cache slot " << &mITSChipClustersRefs.front();
888-
mITSChipClustersRefs.pop_front();
889-
}
890-
}
891-
892783
//______________________________________________
893784
inline void MatchTPCITS::destroyLastABTrackLinksList()
894785
{

0 commit comments

Comments
 (0)