Skip to content

Commit d1c21d2

Browse files
committed
Fix in cluster topology Lookup::findGroupID
1 parent 9b69f37 commit d1c21d2

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

DataFormats/Detectors/ITSMFT/common/include/DataFormatsITSMFT/TopologyDictionary.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ class TopologyDictionary
171171
friend TopologyFastSimulation;
172172

173173
private:
174+
static constexpr int STopoSize = 8 * 255 + 1;
174175
std::unordered_map<unsigned long, int> mCommonMap; ///< Map of pair <hash, position in mVectorOfIDs>
175176
std::unordered_map<int, int> mGroupMap; ///< Map of pair <groudID, position in mVectorOfIDs>
176-
int mSmallTopologiesLUT[8 * 255 + 1]; ///< Look-Up Table for the topologies with 1-byte linearised matrix
177+
int mSmallTopologiesLUT[STopoSize]; ///< Look-Up Table for the topologies with 1-byte linearised matrix
177178
std::vector<GroupStruct> mVectorOfIDs; ///< Vector of topologies and groups
178179

179180
ClassDefNV(TopologyDictionary, 4);

DataFormats/Detectors/ITSMFT/common/src/TopologyDictionary.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ namespace o2
3333
namespace itsmft
3434
{
3535

36-
TopologyDictionary::TopologyDictionary() : mSmallTopologiesLUT{-1} {}
36+
TopologyDictionary::TopologyDictionary()
37+
{
38+
memset(mSmallTopologiesLUT, -1, STopoSize * sizeof(int));
39+
}
3740

3841
TopologyDictionary::TopologyDictionary(const std::string& fileName)
3942
{

Detectors/ITSMFT/common/reconstruction/src/LookUp.cxx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/// \author Luca Barioglio, University and INFN of Torino
1616

1717
#include "ITSMFTReconstruction/LookUp.h"
18+
#include "DataFormatsITSMFT/CompCluster.h"
1819

1920
ClassImp(o2::itsmft::LookUp);
2021

@@ -68,27 +69,24 @@ int LookUp::groupFinder(int nRow, int nCol)
6869
int LookUp::findGroupID(int nRow, int nCol, const unsigned char patt[ClusterPattern::MaxPatternBytes]) const
6970
{
7071
int nBits = nRow * nCol;
71-
// Small topology
72-
if (nBits < 9) {
72+
if (nBits < 9) { // Small unique topology
7373
int ID = mDictionary.mSmallTopologiesLUT[(nCol - 1) * 255 + (int)patt[0]];
7474
if (ID >= 0) {
7575
return ID;
76-
} else { //small rare topology (inside groups)
77-
int index = groupFinder(nRow, nCol);
78-
auto res = mDictionary.mGroupMap.find(index);
79-
return res == mDictionary.mGroupMap.end() ? -1 : res->second;
76+
}
77+
} else { // Big unique topology
78+
unsigned long hash = ClusterTopology::getCompleteHash(nRow, nCol, patt);
79+
auto ret = mDictionary.mCommonMap.find(hash);
80+
if (ret != mDictionary.mCommonMap.end()) {
81+
return ret->second;
8082
}
8183
}
82-
// Big topology
83-
unsigned long hash = ClusterTopology::getCompleteHash(nRow, nCol, patt);
84-
auto ret = mDictionary.mCommonMap.find(hash);
85-
if (ret != mDictionary.mCommonMap.end()) {
86-
return ret->second;
87-
} else { // Big rare topology (inside groups)
84+
if (!mDictionary.mGroupMap.empty()) { // rare valid topology group
8885
int index = groupFinder(nRow, nCol);
8986
auto res = mDictionary.mGroupMap.find(index);
90-
return res == mDictionary.mGroupMap.end() ? -1 : res->second;
87+
return res == mDictionary.mGroupMap.end() ? CompCluster::InvalidPatternID : res->second;
9188
}
89+
return CompCluster::InvalidPatternID;
9290
}
9391

9492
} // namespace itsmft

0 commit comments

Comments
 (0)