Skip to content

Commit 33ce689

Browse files
shahor02sawenzel
authored andcommitted
Store ITS and TPC labels for matched tracks
1 parent e42e84f commit 33ce689

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

Detectors/GlobalTracking/include/GlobalTracking/MatchTPCITS.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct matchRecord {
138138

139139
class MatchTPCITS
140140
{
141+
using MCLabCont = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
141142

142143
public:
143144
///< perform matching for provided input
@@ -176,6 +177,8 @@ class MatchTPCITS
176177
void setITSMCTruthBranchName(const std::string& nm) { mITSMCTruthBranchName = nm; }
177178
void setTPCMCTruthBranchName(const std::string& nm) { mTPCMCTruthBranchName = nm; }
178179
void setOutTPCITSTracksBranchName(const std::string& nm) { mOutTPCITSTracksBranchName = nm; }
180+
void setOutTPCMCTruthBranchName(const std::string& nm) { mOutTPCMCTruthBranchName = nm; }
181+
void setOutITSMCTruthBranchName(const std::string& nm) { mOutITSMCTruthBranchName = nm; }
179182

180183
///< get input branch names for the input from the tree
181184
const std::string& getITSTrackBranchName() const { return mITSTrackBranchName; }
@@ -184,6 +187,8 @@ class MatchTPCITS
184187
const std::string& getITSMCTruthBranchName() const { return mITSMCTruthBranchName; }
185188
const std::string& getTPCMCTruthBranchName() const { return mTPCMCTruthBranchName; }
186189
const std::string& getOutTPCITSTracksBranchName() const { return mOutTPCITSTracksBranchName; }
190+
const std::string& getOutTPCMCTruthBranchName() const { return mOutTPCMCTruthBranchName; }
191+
const std::string& getOutITSMCTruthBranchName() const { return mOutITSMCTruthBranchName; }
187192

188193
///< print settings
189194
void print() const;
@@ -268,7 +273,7 @@ class MatchTPCITS
268273
void doMatching(int sec);
269274

270275
void refitWinners();
271-
bool refitTrackITSTPC(const TrackLocITS& tITS);
276+
bool refitTrackITSTPC(int iITS);
272277
void selectBestMatches();
273278
void buildMatch2TrackTables();
274279
bool validateTPCMatch(int mtID);
@@ -439,6 +444,9 @@ class MatchTPCITS
439444

440445
///<outputs tracks container
441446
std::vector<o2::dataformats::TrackTPCITS> mMatchedTracks;
447+
std::vector<o2::MCCompLabel> mOutITSLabels; ///< ITS label of matched track
448+
std::vector<o2::MCCompLabel> mOutTPCLabels; ///< TPC label of matched track
449+
442450
int mMaxOutputTracksPerEntry = 500; ///< max number of output tracks to store per entry
443451

444452
std::string mITSTrackBranchName = "ITSTrack"; ///< name of branch containing input ITS tracks
@@ -447,6 +455,8 @@ class MatchTPCITS
447455
std::string mITSMCTruthBranchName = "ITSTrackMCTruth"; ///< name of branch containing ITS MC labels
448456
std::string mTPCMCTruthBranchName = "TracksMCTruth"; ///< name of branch containing input TPC tracks
449457
std::string mOutTPCITSTracksBranchName = "TPCITS"; ///< name of branch containing output matched tracks
458+
std::string mOutTPCMCTruthBranchName = "MatchTPCMCTruth"; ///< name of branch for output matched tracks TPC MC
459+
std::string mOutITSMCTruthBranchName = "MatchITSMCTruth"; ///< name of branch for output matched tracks ITS MC
450460

451461
#ifdef _ALLOW_DEBUG_TREES_
452462
std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;

Detectors/GlobalTracking/src/MatchTPCITS.cxx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include "Field/MagFieldFast.h"
1616
#include "ITSBase/GeometryTGeo.h"
1717

18-
#include "SimulationDataFormat/MCTruthContainer.h"
19-
2018
#include "DetectorsBase/Propagator.h"
2119
#include "CommonUtils/TreeStream.h"
2220

@@ -35,7 +33,7 @@
3533
#include <TFile.h>
3634
#include <TGeoGlobalMagField.h>
3735
#include "DataFormatsParameters/GRPObject.h"
38-
36+
#include "SimulationDataFormat/MCTruthContainer.h"
3937
#include "GlobalTracking/MatchTPCITS.h"
4038

4139
using namespace o2::globaltracking;
@@ -131,9 +129,15 @@ void MatchTPCITS::init()
131129

132130
// create output branch
133131
if (mOutputTree) {
132+
LOG(INFO) << "ITS-TPC Matching results will be stored in the tree " << mOutputTree->GetName();
134133
mOutputTree->Branch(mOutTPCITSTracksBranchName.data(), &mMatchedTracks);
135-
LOG(INFO) << "Matched tracks will be stored in " << mOutTPCITSTracksBranchName << " branch of tree "
136-
<< mOutputTree->GetName() << FairLogger::endl;
134+
LOG(INFO) << "Matched tracks branch: " << mOutTPCITSTracksBranchName;
135+
if (mMCTruthON) {
136+
mOutputTree->Branch(mOutTPCMCTruthBranchName.data(), &mOutITSLabels);
137+
LOG(INFO) << "ITS Tracks Labels branch: " << mOutITSMCTruthBranchName;
138+
mOutputTree->Branch(mOutITSMCTruthBranchName.data(), &mOutTPCLabels);
139+
LOG(INFO) << "TPC Tracks Labels branch: " << mOutTPCMCTruthBranchName;
140+
}
137141
} else {
138142
LOG(ERROR) << "Output tree is not attached, matched tracks will not be stored" << FairLogger::endl;
139143
}
@@ -1068,39 +1072,48 @@ void MatchTPCITS::refitWinners()
10681072
mWinnerChi2Refit.resize(mITSWork.size(), -1.f);
10691073
mCurrITSTracksTreeEntry = -1;
10701074
mCurrITSClustersTreeEntry = -1;
1071-
for (int i = 0; i < mITSWork.size(); i++) {
1072-
const auto& its = mITSWork[i];
1073-
if (!refitTrackITSTPC(its)) {
1075+
for (int iITS = 0; iITS < mITSWork.size(); iITS++) {
1076+
if (!refitTrackITSTPC(iITS)) {
10741077
continue;
10751078
}
1076-
mWinnerChi2Refit[i] = mMatchedTracks.back().getChi2Refit();
1079+
mWinnerChi2Refit[iITS] = mMatchedTracks.back().getChi2Refit();
10771080
if (mMatchedTracks.size() == mMaxOutputTracksPerEntry) {
10781081
if (mOutputTree) {
10791082
mTimerRefit.Stop();
10801083
mOutputTree->Fill();
10811084
mTimerRefit.Start(false);
10821085
}
10831086
mMatchedTracks.clear();
1087+
if (mMCTruthON) {
1088+
mOutITSLabels.clear();
1089+
mOutTPCLabels.clear();
1090+
}
10841091
}
10851092
}
10861093
// flush last tracks
10871094
if (mMatchedTracks.size() && mOutputTree) {
10881095
mOutputTree->Fill();
10891096
}
10901097
mMatchedTracks.clear();
1098+
if (mMCTruthON) {
1099+
mOutITSLabels.clear();
1100+
mOutTPCLabels.clear();
1101+
}
10911102
mTimerRefit.Stop();
10921103
}
10931104

10941105
//______________________________________________
1095-
bool MatchTPCITS::refitTrackITSTPC(const TrackLocITS& tITS)
1106+
bool MatchTPCITS::refitTrackITSTPC(int iITS)
10961107
{
10971108
///< refit in inward direction the pair of TPC and ITS tracks
1109+
const auto& tITS = mITSWork[iITS];
10981110
if (tITS.matchID < 0 || isDisabledITS(mMatchesITS[tITS.matchID])) {
10991111
return false; // no match
11001112
}
11011113
const auto& itsMatch = mMatchesITS[tITS.matchID];
11021114
const auto& itsMatchRec = mMatchRecordsITS[itsMatch.first];
1103-
const auto& tTPC = mTPCWork[mTPCMatch2Track[itsMatchRec.matchID]];
1115+
int iTPC = mTPCMatch2Track[itsMatchRec.matchID];
1116+
const auto& tTPC = mTPCWork[iTPC];
11041117

11051118
loadITSClustersChunk(tITS.source.getEvent());
11061119
loadITSTracksChunk(tITS.source.getEvent());
@@ -1162,6 +1175,12 @@ bool MatchTPCITS::refitTrackITSTPC(const TrackLocITS& tITS)
11621175
trfit.setTimeMUS(time, timeErr);
11631176
trfit.setRefTPC(tTPC.source);
11641177
trfit.setRefITS(tITS.source);
1178+
1179+
if (mMCTruthON) { // store MC info
1180+
mOutITSLabels.emplace_back(mITSLblWork[iITS]);
1181+
mOutTPCLabels.emplace_back(mTPCLblWork[iTPC]);
1182+
}
1183+
11651184
return true;
11661185
}
11671186

0 commit comments

Comments
 (0)