Skip to content

Commit c1d6192

Browse files
mconcasshahor02
authored andcommitted
Add TrackDebugInfo into treestream
1 parent a7d1de4 commit c1d6192

File tree

6 files changed

+56
-30
lines changed

6 files changed

+56
-30
lines changed

Detectors/ITSMFT/ITS/tracking/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ o2_add_library(ITStracking
3535
o2_target_root_dictionary(ITStracking
3636
HEADERS include/ITStracking/ClusterLines.h
3737
include/ITStracking/Tracklet.h
38+
include/ITStracking/Cluster.h
3839
include/ITStracking/TrackingConfigParam.h
3940
include/ITStracking/StandaloneDebugger.h
4041
LINKDEF src/TrackingLinkDef.h)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <array>
2020
#endif
2121

22+
#include "GPUCommonRtypes.h"
2223
#include "ITStracking/Definitions.h"
2324
#include "ITStracking/MathUtils.h"
2425

@@ -43,6 +44,8 @@ struct Cluster final {
4344
float rCoordinate; // = -999.f;
4445
int clusterId; // = -1;
4546
int indexTableBinIndex; // = -1;
47+
48+
ClassDefNV(Cluster, 1);
4649
};
4750

4851
struct TrackingFrameInfo {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <array>
2222
#endif
2323

24-
#define CA_DEBUG
24+
// #define CA_DEBUG
2525

2626
#ifdef CA_DEBUG
2727
#define CA_DEBUGGER(x) x

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

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,17 @@
2020

2121
// Tracker
2222
#include "DataFormatsITS/TrackITS.h"
23+
#include "ITStracking/PrimaryVertexContext.h"
2324
#include "ITStracking/ROframe.h"
2425

2526
namespace o2
2627
{
2728

28-
// class MCCompLabel;
29-
3029
namespace utils
3130
{
3231
class TreeStreamRedirector;
3332
}
3433

35-
// namespace its
36-
// {
37-
// class TrackITSExt;
38-
// }
39-
4034
namespace its
4135
{
4236
class Tracklet;
@@ -46,14 +40,21 @@ class ClusterLines;
4640

4741
using constants::its::UnusedIndex;
4842

43+
template <int numClusters = TrackITSExt::MaxClusters>
4944
struct FakeTrackInfo {
5045
public:
5146
FakeTrackInfo();
52-
FakeTrackInfo(const ROframe& event, TrackITSExt& track) : isFake{false}, isAmbiguousId{false}, mainLabel{UnusedIndex, UnusedIndex, UnusedIndex, false}
47+
FakeTrackInfo(PrimaryVertexContext* pvc, const ROframe& event, TrackITSExt& track, bool storeClusters) : isFake{false}, isAmbiguousId{false}, mainLabel{UnusedIndex, UnusedIndex, UnusedIndex, false}
5348
{
5449
occurrences.clear();
55-
for (size_t iCluster{0}; iCluster < 7; ++iCluster) {
50+
for (auto& c : clusStatuses) {
51+
c = -1;
52+
}
53+
for (size_t iCluster{0}; iCluster < numClusters; ++iCluster) {
5654
int extIndex = track.getClusterIndex(iCluster);
55+
if (extIndex == -1) {
56+
continue;
57+
}
5758
o2::MCCompLabel mcLabel = event.getClusterLabels(iCluster, extIndex);
5859
bool found = false;
5960

@@ -62,44 +63,69 @@ struct FakeTrackInfo {
6263
if (mcLabel == occurrence.first) {
6364
++occurrence.second;
6465
found = true;
66+
break;
6567
}
6668
}
6769
if (!found) {
6870
occurrences.emplace_back(mcLabel, 1);
6971
}
7072
}
73+
// LOG(WARN) << "Qui 1";
7174
if (occurrences.size() > 1) {
7275
isFake = true;
7376
}
7477
std::sort(std::begin(occurrences), std::end(occurrences), [](auto e1, auto e2) {
7578
return e1.second > e2.second;
7679
});
7780
mainLabel = occurrences[0].first;
78-
79-
for (auto iOcc{1}; iOcc < occurrences.size(); ++iOcc) {
81+
// LOG(WARN) << "Qui 2";
82+
for (size_t iOcc{1}; iOcc < occurrences.size(); ++iOcc) {
8083
if (occurrences[iOcc].second == occurrences[0].second) {
8184
isAmbiguousId = true;
8285
break;
8386
}
8487
}
85-
for (auto iCluster{0}; iCluster < TrackITSExt::MaxClusters; ++iCluster) {
88+
// LOG(WARN) << "Qui 3";
89+
for (size_t iCluster{0}; iCluster < numClusters; ++iCluster) {
8690
int extIndex = track.getClusterIndex(iCluster);
91+
if (extIndex == -1) {
92+
continue;
93+
}
8794
o2::MCCompLabel lbl = event.getClusterLabels(iCluster, extIndex);
88-
if (lbl == mainLabel && occurrences[0].second > 1 && !lbl.isNoise()) { // if 7 fake clusters -> occurrences[0].second = 1
95+
if (lbl == mainLabel && occurrences[0].second > 1 && !lbl.isNoise()) { // if we have MaxClusters fake clusters -> occurrences[0].second = 1
8996
clusStatuses[iCluster] = 1;
9097
} else {
9198
clusStatuses[iCluster] = 0;
9299
++nFakeClusters;
93100
}
94101
}
102+
// LOG(WARN) << "Qui 3.5";
103+
if (storeClusters) {
104+
for (auto iCluster{0}; iCluster < numClusters; ++iCluster) {
105+
const int index = track.getClusterIndex(iCluster);
106+
if (index != constants::its::UnusedIndex) {
107+
clusters[iCluster] = pvc->getClusters()[iCluster][track.getClusterIndex(iCluster)];
108+
}
109+
// LOG(WARN) << "Qui 3.5.1";
110+
// LOG(WARN) << "\t iCLuster " << iCluster;
111+
// LOG(WARN) << "\t getClusterIndex(iCluster) " << track.getClusterIndex(iCluster);
112+
// LOG(WARN) << "\t externalIndex " << event.getClusterExternalIndex(iCluster, track.getClusterIndex(iCluster));
113+
}
114+
}
115+
// LOG(WARN) << "Qui 4";
95116
}
96-
std::vector<std::pair<MCCompLabel, int>> occurrences;
117+
118+
// Data
119+
std::vector<std::pair<MCCompLabel, int>>
120+
occurrences;
97121
MCCompLabel mainLabel;
98-
std::array<int, 7> clusStatuses = {-1, -1, -1, -1, -1, -1, -1};
122+
std::array<int, numClusters> clusStatuses;
123+
std::array<o2::its::Cluster, numClusters> clusters;
99124
bool isFake;
100125
bool isAmbiguousId;
101126
int nFakeClusters = 0;
102-
};
127+
ClassDefNV(FakeTrackInfo, 1);
128+
}; // namespace its
103129

104130
class StandaloneDebugger
105131
{
@@ -130,7 +156,7 @@ class StandaloneDebugger
130156
void fillVerticesInfoTree(float x, float y, float z, int size, int rId, int eId, float pur);
131157

132158
// Tracker debug utilities
133-
void dumpTrackToBranchWithInfo(const ROframe event, o2::its::TrackITSExt track, std::string branchName);
159+
void dumpTrackToBranchWithInfo(std::string branchName, o2::its::TrackITSExt track, const ROframe event, PrimaryVertexContext* pvc, const bool dumpClusters = false);
134160

135161
static int getBinIndex(const float, const int, const float, const float);
136162

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
/// \brief
1313
/// \author matteo.concas@cern.ch
1414

15-
1615
#include "ITStracking/Cluster.h"
1716
#include "ITStracking/Tracklet.h"
1817
#include "ITStracking/ClusterLines.h"
1918
#include "CommonUtils/TreeStreamRedirector.h"
2019
#include "ITStracking/StandaloneDebugger.h"
2120

22-
23-
2421
#include "TH1I.h"
2522
#include "TMath.h"
2623

@@ -259,20 +256,19 @@ int StandaloneDebugger::getBinIndex(const float value, const int size, const flo
259256
}
260257

261258
// Tracker
262-
void StandaloneDebugger::dumpTrackToBranchWithInfo(ROframe event, o2::its::TrackITSExt track,
263-
std::string branchName)
259+
void StandaloneDebugger::dumpTrackToBranchWithInfo(std::string branchName, o2::its::TrackITSExt track, const ROframe event, PrimaryVertexContext* pvc, const bool dumpClusters)
264260
{
265-
// FakeTrackInfo t{event, track};
261+
FakeTrackInfo<7> t{pvc, event, track, dumpClusters};
266262

267263
(*mTreeStream)
268264
<< branchName.data()
269265
<< track
270266
<< "\n";
271-
272-
// (*mTreeStream)
273-
// << "TracksInfo"
274-
// << tInfo
275-
// << "\n";
267+
268+
(*mTreeStream)
269+
<< "TracksInfo"
270+
<< t
271+
<< "\n";
276272
}
277273
} // namespace its
278274
} // namespace o2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void Tracker::findTracks(const ROframe& event)
303303
temporaryTrack.resetCovariance();
304304
fitSuccess = fitTrack(event, temporaryTrack, mTrkParams[0].NLayers - 1, -1, -1, mTrkParams[0].FitIterationMaxChi2[1]);
305305
#ifdef CA_DEBUG
306-
mDebugger->dumpTrackToBranchWithInfo(event, temporaryTrack, "testBranch");
306+
mDebugger->dumpTrackToBranchWithInfo("testBranch", temporaryTrack, event, mPrimaryVertexContext, true);
307307
#endif
308308
if (!fitSuccess) {
309309
continue;

0 commit comments

Comments
 (0)