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
20
22
23namespace o2::its3
24{
25
26LookUp::LookUp(std::string fileName)
27{
28 loadDictionary(fileName);
29}
30
31void LookUp::loadDictionary(std::string fileName)
32{
33 mDictionary.readFromFile(fileName);
34 mTopologiesOverThreshold = mDictionary.mCommonMap.size();
35}
36
38{
39 if (dict != nullptr) {
40 mDictionary = *dict;
41 }
42 mTopologiesOverThreshold = mDictionary.mCommonMap.size();
43}
44
45int LookUp::groupFinder(int nRow, int nCol)
46{
47 int row_index = nRow / its3::TopologyDictionary::RowClassSpan;
48 if (nRow % TopologyDictionary::RowClassSpan == 0) {
49 row_index--;
50 }
51 int col_index = nCol / its3::TopologyDictionary::ColClassSpan;
52 if (nCol % TopologyDictionary::RowClassSpan == 0) {
53 col_index--;
54 }
55 int grNum = -1;
58 } else {
59 grNum = row_index * its3::TopologyDictionary::MaxNumberOfColClasses + col_index;
60 }
61 return grNum;
62}
63
64int LookUp::findGroupID(int nRow, int nCol, const unsigned char patt[itsmft::ClusterPattern::MaxPatternBytes]) const
65{
66 int nBits = nRow * nCol;
67 if (nBits < 9) { // Small unique topology
68 int ID = mDictionary.mSmallTopologiesLUT[(nCol - 1) * 255 + (int)patt[0]];
69 if (ID >= 0) {
70 return ID;
71 }
72 } else { // Big unique topology
73 unsigned long hash = itsmft::ClusterTopology::getCompleteHash(nRow, nCol, patt);
74 auto ret = mDictionary.mCommonMap.find(hash);
75 if (ret != mDictionary.mCommonMap.end()) {
76 return ret->second;
77 }
78 }
79 if (!mDictionary.mGroupMap.empty()) { // rare valid topology group
80 int index = groupFinder(nRow, nCol);
81 auto res = mDictionary.mGroupMap.find(index);
82 return res == mDictionary.mGroupMap.end() ? itsmft::CompCluster::InvalidPatternID : res->second;
83 }
85}
86
87} // namespace o2::its3
Definition of the ClusterTopology class.
Definition of the ITSMFT compact cluster.
uint32_t res
Definition RawData.h:0
Definition of the LookUp class for its3.
ClassImp(o2::its3::LookUp)
LookUp()=default
int findGroupID(int nRow, int nCol, const unsigned char patt[itsmft::ClusterPattern::MaxPatternBytes]) const
Definition LookUp.cxx:64
void loadDictionary(std::string fileName)
Definition LookUp.cxx:31
static int groupFinder(int nRow, int nCol)
Definition LookUp.cxx:45
void setDictionary(const TopologyDictionary *dict)
Definition LookUp.cxx:37
static constexpr int ColClassSpan
Column span of the classes of rare topologies.
static constexpr int MaxNumberOfRowClasses
Maximum number of row classes for the groups of rare topologies.
static constexpr int NumberOfRareGroups
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.
int readFromFile(const std::string &fileName)
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
GLuint index
Definition glcorearb.h:781