Skip to content

Commit a7d1de4

Browse files
mconcasshahor02
authored andcommitted
Add track dumping in standalone debugger
1 parent 00a24b0 commit a7d1de4

File tree

7 files changed

+120
-9
lines changed

7 files changed

+120
-9
lines changed

Detectors/ITSMFT/ITS/tracking/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ o2_add_library(ITStracking
1717
src/Label.cxx
1818
src/PrimaryVertexContext.cxx
1919
src/Road.cxx
20-
# src/StandaloneDebugger.cxx
20+
src/StandaloneDebugger.cxx
2121
src/Tracker.cxx
2222
src/TrackerTraitsCPU.cxx
2323
src/TrackingConfigParam.cxx
@@ -36,6 +36,7 @@ o2_target_root_dictionary(ITStracking
3636
HEADERS include/ITStracking/ClusterLines.h
3737
include/ITStracking/Tracklet.h
3838
include/ITStracking/TrackingConfigParam.h
39+
include/ITStracking/StandaloneDebugger.h
3940
LINKDEF src/TrackingLinkDef.h)
4041

4142
if(CUDA_ENABLED)

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: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,91 @@
1515
#ifndef O2_ITS_STANDALONE_DEBUGGER_H_
1616
#define O2_ITS_STANDALONE_DEBUGGER_H_
1717

18+
#include <string>
19+
#include <iterator>
20+
21+
// Tracker
22+
#include "DataFormatsITS/TrackITS.h"
23+
#include "ITStracking/ROframe.h"
24+
1825
namespace o2
1926
{
2027

21-
class MCCompLabel;
28+
// class MCCompLabel;
2229

2330
namespace utils
2431
{
2532
class TreeStreamRedirector;
2633
}
2734

35+
// namespace its
36+
// {
37+
// class TrackITSExt;
38+
// }
39+
2840
namespace its
2941
{
3042
class Tracklet;
3143
class Line;
3244
class ROframe;
45+
class ClusterLines;
46+
47+
using constants::its::UnusedIndex;
48+
49+
struct FakeTrackInfo {
50+
public:
51+
FakeTrackInfo();
52+
FakeTrackInfo(const ROframe& event, TrackITSExt& track) : isFake{false}, isAmbiguousId{false}, mainLabel{UnusedIndex, UnusedIndex, UnusedIndex, false}
53+
{
54+
occurrences.clear();
55+
for (size_t iCluster{0}; iCluster < 7; ++iCluster) {
56+
int extIndex = track.getClusterIndex(iCluster);
57+
o2::MCCompLabel mcLabel = event.getClusterLabels(iCluster, extIndex);
58+
bool found = false;
59+
60+
for (size_t iOcc{0}; iOcc < occurrences.size(); ++iOcc) {
61+
std::pair<o2::MCCompLabel, int>& occurrence = occurrences[iOcc];
62+
if (mcLabel == occurrence.first) {
63+
++occurrence.second;
64+
found = true;
65+
}
66+
}
67+
if (!found) {
68+
occurrences.emplace_back(mcLabel, 1);
69+
}
70+
}
71+
if (occurrences.size() > 1) {
72+
isFake = true;
73+
}
74+
std::sort(std::begin(occurrences), std::end(occurrences), [](auto e1, auto e2) {
75+
return e1.second > e2.second;
76+
});
77+
mainLabel = occurrences[0].first;
78+
79+
for (auto iOcc{1}; iOcc < occurrences.size(); ++iOcc) {
80+
if (occurrences[iOcc].second == occurrences[0].second) {
81+
isAmbiguousId = true;
82+
break;
83+
}
84+
}
85+
for (auto iCluster{0}; iCluster < TrackITSExt::MaxClusters; ++iCluster) {
86+
int extIndex = track.getClusterIndex(iCluster);
87+
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
89+
clusStatuses[iCluster] = 1;
90+
} else {
91+
clusStatuses[iCluster] = 0;
92+
++nFakeClusters;
93+
}
94+
}
95+
}
96+
std::vector<std::pair<MCCompLabel, int>> occurrences;
97+
MCCompLabel mainLabel;
98+
std::array<int, 7> clusStatuses = {-1, -1, -1, -1, -1, -1, -1};
99+
bool isFake;
100+
bool isAmbiguousId;
101+
int nFakeClusters = 0;
102+
};
33103

34104
class StandaloneDebugger
35105
{
@@ -59,6 +129,9 @@ class StandaloneDebugger
59129
void fillXYZHistogramTree(std::array<std::vector<int>, 3>, const std::array<int, 3>);
60130
void fillVerticesInfoTree(float x, float y, float z, int size, int rId, int eId, float pur);
61131

132+
// Tracker debug utilities
133+
void dumpTrackToBranchWithInfo(const ROframe event, o2::its::TrackITSExt track, std::string branchName);
134+
62135
static int getBinIndex(const float, const int, const float, const float);
63136

64137
private:

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
#include "Framework/Logger.h"
4040

41+
#ifdef CA_DEBUG
42+
#include "ITStracking/StandaloneDebugger.h"
43+
#endif
44+
4145
namespace o2
4246
{
4347
namespace gpu
@@ -108,6 +112,10 @@ class Tracker
108112
std::vector<MCCompLabel> mTrackLabels;
109113
o2::base::MatLayerCylSet* mMatLayerCylSet = nullptr;
110114
o2::gpu::GPUChainITS* mRecoChain = nullptr;
115+
116+
#ifdef CA_DEBUG
117+
StandaloneDebugger* mDebugger;
118+
#endif
111119
};
112120

113121
inline void Tracker::setParameters(const std::vector<MemoryParameters>& memPars, const std::vector<TrackingParameters>& trkPars)

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

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

15-
#include <string>
16-
#include <iterator>
15+
1716
#include "ITStracking/Cluster.h"
1817
#include "ITStracking/Tracklet.h"
1918
#include "ITStracking/ClusterLines.h"
2019
#include "CommonUtils/TreeStreamRedirector.h"
21-
#include "ITStracking/ROframe.h"
2220
#include "ITStracking/StandaloneDebugger.h"
21+
22+
23+
2324
#include "TH1I.h"
2425
#include "TMath.h"
2526

@@ -257,5 +258,21 @@ int StandaloneDebugger::getBinIndex(const float value, const int size, const flo
257258
return std::distance(divisions.begin(), TMath::BinarySearch(divisions.begin(), divisions.end(), value));
258259
}
259260

261+
// Tracker
262+
void StandaloneDebugger::dumpTrackToBranchWithInfo(ROframe event, o2::its::TrackITSExt track,
263+
std::string branchName)
264+
{
265+
// FakeTrackInfo t{event, track};
266+
267+
(*mTreeStream)
268+
<< branchName.data()
269+
<< track
270+
<< "\n";
271+
272+
// (*mTreeStream)
273+
// << "TracksInfo"
274+
// << tInfo
275+
// << "\n";
276+
}
260277
} // namespace its
261278
} // namespace o2

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,21 @@ Tracker::Tracker(o2::its::TrackerTraits* traits)
3939
/// Initialise standard configuration with 1 iteration
4040
mTrkParams.resize(1);
4141
mMemParams.resize(1);
42-
assert(traits != nullptr);
42+
assert(mTracks != nullptr);
4343
mTraits = traits;
4444
mPrimaryVertexContext = mTraits->getPrimaryVertexContext();
45+
#ifdef CA_DEBUG
46+
mDebugger = new StandaloneDebugger("dbg_ITSTrackerCPU.root");
47+
#endif
4548
}
46-
49+
#ifdef CA_DEBUG
50+
Tracker::~Tracker()
51+
{
52+
delete mDebugger;
53+
}
54+
#else
4755
Tracker::~Tracker() = default;
56+
#endif
4857

4958
void Tracker::clustersToTracks(const ROframe& event, std::ostream& timeBenchmarkOutputStream)
5059
{
@@ -293,6 +302,9 @@ void Tracker::findTracks(const ROframe& event)
293302
temporaryTrack.getParamOut() = temporaryTrack;
294303
temporaryTrack.resetCovariance();
295304
fitSuccess = fitTrack(event, temporaryTrack, mTrkParams[0].NLayers - 1, -1, -1, mTrkParams[0].FitIterationMaxChi2[1]);
305+
#ifdef CA_DEBUG
306+
mDebugger->dumpTrackToBranchWithInfo(event, temporaryTrack, "testBranch");
307+
#endif
296308
if (!fitSuccess) {
297309
continue;
298310
}

Detectors/ITSMFT/ITS/tracking/src/TrackingLinkDef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#pragma link C++ class o2::its::Tracklet + ;
1919

2020
#pragma link C++ class o2::its::VertexerParamConfig + ;
21-
#pragma link C++ class o2::conf::ConfigurableParamHelper <o2::its::VertexerParamConfig> + ;
21+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::VertexerParamConfig> + ;
2222

2323
#pragma link C++ class o2::its::TrackerParamConfig + ;
2424
#pragma link C++ class o2::conf::ConfigurableParamHelper <o2::its::TrackerParamConfig> + ;

0 commit comments

Comments
 (0)