Project
Loading...
Searching...
No Matches
LookUp.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
19
21
22using std::array;
23
24namespace o2
25{
26namespace itsmft
27{
28
29LookUp::LookUp() : mDictionary{}, mTopologiesOverThreshold{0} {}
30
31LookUp::LookUp(std::string fileName)
32{
33 loadDictionary(fileName);
34}
35
36void LookUp::loadDictionary(std::string fileName)
37{
38 mDictionary.readFromFile(fileName);
39 mTopologiesOverThreshold = mDictionary.mCommonMap.size();
40}
41
43{
44 if (dict) {
45 mDictionary = *dict;
46 }
47 mTopologiesOverThreshold = mDictionary.mCommonMap.size();
48}
49
50int LookUp::groupFinder(int nRow, int nCol)
51{
52 int row_index = nRow / TopologyDictionary::RowClassSpan;
53 if (nRow % TopologyDictionary::RowClassSpan == 0) {
54 row_index--;
55 }
56 int col_index = nCol / TopologyDictionary::ColClassSpan;
57 if (nCol % TopologyDictionary::RowClassSpan == 0) {
58 col_index--;
59 }
60 int grNum = -1;
63 } else {
64 grNum = row_index * TopologyDictionary::MaxNumberOfColClasses + col_index;
65 }
66 return grNum;
67}
68
69int LookUp::findGroupID(int nRow, int nCol, const unsigned char patt[ClusterPattern::MaxPatternBytes]) const
70{
71 int nBits = nRow * nCol;
72 if (nBits < 9) { // Small unique topology
73 int ID = mDictionary.mSmallTopologiesLUT[(nCol - 1) * 255 + (int)patt[0]];
74 if (ID >= 0) {
75 return ID;
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;
82 }
83 }
84 if (!mDictionary.mGroupMap.empty()) { // rare valid topology group
85 int index = groupFinder(nRow, nCol);
86 auto res = mDictionary.mGroupMap.find(index);
87 return res == mDictionary.mGroupMap.end() ? CompCluster::InvalidPatternID : res->second;
88 }
90}
91
92} // namespace itsmft
93} // namespace o2
Definition of the ITSMFT compact cluster.
Definition of the LookUp class.
ClassImp(o2::itsmft::LookUp)
uint32_t res
Definition RawData.h:0
static constexpr int MaxPatternBytes
static unsigned long getCompleteHash(int nRow, int nCol, const unsigned char patt[ClusterPattern::MaxPatternBytes])
Compute the complete hash as defined for mHash.
static constexpr unsigned short InvalidPatternID
Definition CompCluster.h:46
void setDictionary(const TopologyDictionary *dict)
Definition LookUp.cxx:42
int findGroupID(int nRow, int nCol, const unsigned char patt[ClusterPattern::MaxPatternBytes]) const
Definition LookUp.cxx:69
static int groupFinder(int nRow, int nCol)
Definition LookUp.cxx:50
void loadDictionary(std::string fileName)
Definition LookUp.cxx:36
static constexpr int NumberOfRareGroups
static constexpr int ColClassSpan
Column span of the classes of rare topologies.
int readFromFile(const std::string &fileName)
static constexpr int MaxNumberOfRowClasses
Maximum number of row classes for the groups of rare topologies.
static constexpr int MaxNumberOfColClasses
Maximum number of col classes for the groups of rare topologies.
static constexpr int RowClassSpan
Row span of the classes of rare topologies.
GLuint index
Definition glcorearb.h:781
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...