2020
2121// Tracker
2222#include " DataFormatsITS/TrackITS.h"
23+ #include " ITStracking/PrimaryVertexContext.h"
2324#include " ITStracking/ROframe.h"
2425
2526namespace o2
2627{
2728
28- // class MCCompLabel;
29-
3029namespace utils
3130{
3231class TreeStreamRedirector ;
3332}
3433
35- // namespace its
36- // {
37- // class TrackITSExt;
38- // }
39-
4034namespace its
4135{
4236class Tracklet ;
@@ -46,14 +40,21 @@ class ClusterLines;
4640
4741using constants::its::UnusedIndex;
4842
43+ template <int numClusters = TrackITSExt::MaxClusters>
4944struct 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
104130class 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
0 commit comments