Skip to content

Commit

Permalink
Suppress redundant MCLabels in matching outputs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shahoian committed Feb 3, 2021
1 parent 218cb71 commit e4063cb
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 239 deletions.
21 changes: 3 additions & 18 deletions Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h
Expand Up @@ -91,7 +91,7 @@ class MatchTOF
void initTPConly();

///< attach DPL data and run
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);
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);
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);

///< set tree/chain containing tracks
Expand All @@ -113,25 +113,19 @@ class MatchTOF
void setTrackBranchName(const std::string& nm) { mTracksBranchName = nm; }
void setTPCTrackBranchName(const std::string& nm) { mTPCTracksBranchName = nm; }
void setTPCMCTruthBranchName(const std::string& nm) { mTPCMCTruthBranchName = nm; }
void setITSMCTruthBranchName(const std::string& nm) { mITSMCTruthBranchName = nm; }
void setTOFMCTruthBranchName(const std::string& nm) { mTOFMCTruthBranchName = nm; }
void setTOFClusterBranchName(const std::string& nm) { mTOFClusterBranchName = nm; }
void setOutTOFMCTruthBranchName(const std::string& nm) { mOutTOFMCTruthBranchName = nm; }
void setOutTPCMCTruthBranchName(const std::string& nm) { mOutTPCMCTruthBranchName = nm; }
void setOutITSMCTruthBranchName(const std::string& nm) { mOutITSMCTruthBranchName = nm; }
void setOutTracksBranchName(const std::string& nm) { mOutTracksBranchName = nm; }
void setOutCalibBranchName(const std::string& nm) { mOutCalibBranchName = nm; }

///< get input branch names for the input from the tree
const std::string& getTracksBranchName() const { return mTracksBranchName; }
const std::string& getTPCTracksBranchName() const { return mTPCTracksBranchName; }
const std::string& getTPCMCTruthBranchName() const { return mTPCMCTruthBranchName; }
const std::string& getITSMCTruthBranchName() const { return mITSMCTruthBranchName; }
const std::string& getTOFMCTruthBranchName() const { return mTOFMCTruthBranchName; }
const std::string& getTOFClusterBranchName() const { return mTOFClusterBranchName; }
const std::string& getOutTOFMCTruthBranchName() const { return mOutTOFMCTruthBranchName; }
const std::string& getOutTPCMCTruthBranchName() const { return mOutTPCMCTruthBranchName; }
const std::string& getOutITSMCTruthBranchName() const { return mOutITSMCTruthBranchName; }

///< print settings
void print() const;
Expand Down Expand Up @@ -177,15 +171,13 @@ class MatchTOF

///< fill matching debug tree
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);
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);
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);
void dumpWinnerMatches();

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

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

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

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

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

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

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

std::string mTracksBranchName = "TPCITS"; ///< name of branch containing input matched tracks
std::string mTPCTracksBranchName = "TPCTracks"; ///< name of branch containing actual TPC tracks
std::string mTPCMCTruthBranchName = "MatchTPCMCTruth"; ///< name of branch containing TPC labels
std::string mITSMCTruthBranchName = "MatchITSMCTruth"; ///< name of branch containing ITS labels
std::string mTPCMCTruthBranchName = "MatchMCTruth"; ///< name of branch containing TPC labels
std::string mTOFMCTruthBranchName = "TOFClusterMCTruth"; ///< name of branch containing TOF clusters labels
std::string mTOFClusterBranchName = "TOFCluster"; ///< name of branch containing input ITS clusters
std::string mOutTracksBranchName = "TOFMatchInfo"; ///< name of branch containing output matched tracks
std::string mOutCalibBranchName = "TOFCalibInfo"; ///< name of branch containing output calibration infos
std::string mOutTOFMCTruthBranchName = "MatchTOFMCTruth"; ///< name of branch containing TOF labels for output matched tracks
std::string mOutTPCMCTruthBranchName = "MatchTPCMCTruth"; ///< name of branch containing TOF labels for output matched tracks
std::string mOutITSMCTruthBranchName = "MatchITSMCTruth"; ///< name of branch containing TOF labels for output matched tracks
std::string mOutTPCTrackMCTruthBranchName = "TPCTracksMCTruth"; ///< name of branch containing TPC labels for input TPC tracks

std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
Expand Down
113 changes: 2 additions & 111 deletions Detectors/GlobalTracking/include/GlobalTracking/MatchTPCITS.h
Expand Up @@ -451,8 +451,7 @@ class MatchTPCITS
void printCandidatesITS() const;

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

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

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

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

//______________________________________________
inline void MatchTPCITS::removeTPCfromITS(int tpcID, int itsID)
{
///< remove reference to tpcID track from itsID track matches
auto& tITS = mITSWork[itsID];
if (isValidatedITS(tITS)) {
return;
}
int topID = MinusOne, next = tITS.matchID; // ITS MatchRecord
while (next > MinusOne) {
auto& rcITS = mMatchRecordsITS[next];
if (rcITS.partnerID == tpcID) {
if (topID < 0) {
tITS.matchID = rcITS.nextRecID;
} else {
mMatchRecordsITS[topID].nextRecID = rcITS.nextRecID;
}
return;
}
topID = next;
next = rcITS.nextRecID;
}
}

//______________________________________________
inline void MatchTPCITS::removeITSfromTPC(int itsID, int tpcID)
{
///< remove reference to itsID track from matches of tpcID track
auto& tTPC = mTPCWork[tpcID];
if (isValidatedTPC(tTPC)) {
return;
}
int topID = MinusOne, next = tTPC.matchID;
while (next > MinusOne) {
auto& rcTPC = mMatchRecordsTPC[next];
if (rcTPC.partnerID == itsID) {
if (topID < 0) {
tTPC.matchID = rcTPC.nextRecID;
} else {
mMatchRecordsTPC[topID].nextRecID = rcTPC.nextRecID;
}
return;
}
topID = next;
next = rcTPC.nextRecID;
}
}

//______________________________________________
inline void MatchTPCITS::flagUsedITSClusters(const o2::its::TrackITS& track, int rofOffset)
{
// flag clusters used by this track
int clEntry = track.getFirstClusterEntry();
for (int icl = track.getNumberOfClusters(); icl--;) {
mABClusterLinkIndex[rofOffset + mITSTrackClusIdx[clEntry++]] = MinusTen;
}
}
//__________________________________________________________
inline int MatchTPCITS::preselectChipClusters(std::vector<int>& clVecOut, const ClusRange& clRange, const ITSChipClustersRefs& clRefs,
float trackY, float trackZ, float tolerY, float tolerZ,
const o2::MCCompLabel& lblTrc) const // TODO lbl is not needed
{
clVecOut.clear();
int icID = clRange.getFirstEntry();
for (int icl = clRange.getEntries(); icl--;) { // note: clusters within a chip are sorted in Z
int clID = clRefs.clusterID[icID++]; // so, we go in clusterID increasing direction
const auto& cls = mITSClustersArray[clID];
float dz = trackZ - cls.getZ();
auto label = mITSClsLabels->getLabels(clID)[0]; // tmp
// if (!(label == lblTrc)) {
// continue; // tmp
// }
LOG(DEBUG) << "cl" << icl << '/' << clID << " " << label
<< " dZ: " << dz << " [" << tolerZ << "| dY: " << trackY - cls.getY() << " [" << tolerY << "]";
if (dz > tolerZ) {
float clsZ = cls.getZ();
LOG(DEBUG) << "Skip the rest since " << trackZ << " > " << clsZ << "\n";
break;
} else if (dz < -tolerZ) {
LOG(DEBUG) << "Skip cluster dz=" << dz << " Ztr=" << trackZ << " zCl=" << cls.getZ();
continue;
}
if (fabs(trackY - cls.getY()) > tolerY) {
LOG(DEBUG) << "Skip cluster dy= " << trackY - cls.getY() << " Ytr=" << trackY << " yCl=" << cls.getY();
continue;
}
clVecOut.push_back(clID);
}
return clVecOut.size();
}

//______________________________________________
inline void MatchTPCITS::cleanAfterBurnerClusRefCache(int currentIC, int& startIC)
{
// check if some of cached cluster reference from tables startIC to currentIC can be released,
// they will be necessarily in front slots of the mITSChipClustersRefs
while (startIC < currentIC && mInteractions[currentIC].timeBins.getMin() - mInteractions[startIC].timeBins.getMax() > MinTBToCleanCache) {
LOG(INFO) << "CAN REMOVE CACHE FOR " << startIC << " curent IC=" << currentIC;
while (mInteractions[startIC].clRefPtr == &mITSChipClustersRefs.front()) {
LOG(INFO) << "Reset cache pointer" << mInteractions[startIC].clRefPtr << " for IC=" << startIC;
mInteractions[startIC++].clRefPtr = nullptr;
}
LOG(INFO) << "Reset cache slot " << &mITSChipClustersRefs.front();
mITSChipClustersRefs.pop_front();
}
}

//______________________________________________
inline void MatchTPCITS::destroyLastABTrackLinksList()
{
Expand Down

0 comments on commit e4063cb

Please sign in to comment.