Project
Loading...
Searching...
No Matches
TopologyDictionary.h
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
14
15#ifndef ALICEO2_ITS3_TOPOLOGYDICTIONARY_H
16#define ALICEO2_ITS3_TOPOLOGYDICTIONARY_H
17
20
21namespace o2::its3
22{
23
24class BuildTopologyDictionary;
25class LookUp;
26
28 static constexpr int STopoSize{(8 * 255) + 1};
29 std::array<int, STopoSize> mSmallTopologiesLUT{};
30 std::vector<itsmft::GroupStruct> mVectorOfIDs;
31 std::unordered_map<unsigned long, int> mCommonMap;
32 std::unordered_map<int, int> mGroupMap;
33
34 void print() const noexcept;
35
37};
38
40{
41 public:
43 TopologyDictionary(const std::string& fileName);
44
47 static constexpr int RowClassSpan = 4;
48 static constexpr int ColClassSpan = 4;
49 static constexpr int MaxNumberOfRowClasses = 1 + ((itsmft::ClusterPattern::MaxRowSpan - 1) / RowClassSpan);
50 static constexpr int MaxNumberOfColClasses = 1 + ((itsmft::ClusterPattern::MaxColSpan - 1) / ColClassSpan);
51 static constexpr int NumberOfRareGroups = MaxNumberOfRowClasses * MaxNumberOfColClasses;
53 void reset() noexcept;
54 void resetMaps(bool IB = true) noexcept;
56 friend std::ostream& operator<<(std::ostream& os, const its3::TopologyDictionary& dictionary);
58 void writeBinaryFile(const std::string& outputFile);
60 void readBinaryFile(const std::string& fileName);
61 void readFromFile(const std::string& fileName);
62 void print() const noexcept;
63
65 [[nodiscard]] float getXCOG(int n, bool IB = true) const
66 {
67 const auto& data = (IB) ? mDataIB : mDataOB;
68 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
69 return data.mVectorOfIDs[n].mXCOG;
70 }
72 [[nodiscard]] float getErrX(int n, bool IB = true) const
73 {
74 const auto& data = (IB) ? mDataIB : mDataOB;
75 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
76 return data.mVectorOfIDs[n].mErrX;
77 }
79 [[nodiscard]] float getZCOG(int n, bool IB = true) const
80 {
81 const auto& data = (IB) ? mDataIB : mDataOB;
82 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
83 return data.mVectorOfIDs[n].mZCOG;
84 }
86 [[nodiscard]] float getErrZ(int n, bool IB = true) const
87 {
88 const auto& data = (IB) ? mDataIB : mDataOB;
89 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
90 return data.mVectorOfIDs[n].mErrZ;
91 }
93 [[nodiscard]] float getErr2X(int n, bool IB = true) const
94 {
95 const auto& data = (IB) ? mDataIB : mDataOB;
96 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
97 return data.mVectorOfIDs[n].mErr2X;
98 }
100 [[nodiscard]] float getErr2Z(int n, bool IB = true) const
101 {
102 const auto& data = (IB) ? mDataIB : mDataOB;
103 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
104 return data.mVectorOfIDs[n].mErr2Z;
105 }
107 [[nodiscard]] unsigned long getHash(int n, bool IB = true) const
108 {
109 const auto& data = (IB) ? mDataIB : mDataOB;
110 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
111 return data.mVectorOfIDs[n].mHash;
112 }
114 [[nodiscard]] int getNpixels(int n, bool IB = true) const
115 {
116 const auto& data = (IB) ? mDataIB : mDataOB;
117 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
118 return data.mVectorOfIDs[n].mNpixels;
119 }
121 [[nodiscard]] double getFrequency(int n, bool IB = true) const
122 {
123 const auto& data = (IB) ? mDataIB : mDataOB;
124 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
125 return data.mVectorOfIDs[n].mFrequency;
126 }
128 [[nodiscard]] bool isGroup(int n, bool IB = true) const
129 {
130 const auto& data = (IB) ? mDataIB : mDataOB;
131 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
132 return data.mVectorOfIDs[n].mIsGroup;
133 }
135 [[nodiscard]] const itsmft::ClusterPattern& getPattern(int n, bool IB = true) const
136 {
137 const auto& data = (IB) ? mDataIB : mDataOB;
138 assert(n >= 0 || n < (int)data.mVectorOfIDs.size());
139 return data.mVectorOfIDs[n].mPattern;
140 }
141
143 [[nodiscard]] TH1F* getTopologyDistribution(const std::string_view hname, bool IB = true) const;
145 [[nodiscard]] int getSize(bool IB) const
146 {
147 return static_cast<int>((IB) ? mDataIB.mVectorOfIDs.size() : mDataOB.mVectorOfIDs.size());
148 }
150
152 template <typename T = float>
153 math_utils::Point3D<T> getClusterCoordinates(const itsmft::CompClusterExt& cl) const;
154
156 template <typename T = float>
157 static math_utils::Point3D<T> getClusterCoordinates(const itsmft::CompClusterExt& cl, const itsmft::ClusterPattern& patt, bool isGroup = true);
158
159 static TopologyDictionary* loadFrom(const std::string& fileName = "", const std::string& objName = "ccdb_object");
160
162 friend its3::LookUp;
163
164 private:
167
169};
170} // namespace o2::its3
171
172#endif
Definition of the ClusterTopology class.
const itsmft::ClusterPattern & getPattern(int n, bool IB=true) const
Returns the pattern of the topology.
float getErr2Z(int n, bool IB=true) const
Returns the error^2 on the z position of the COG for the n_th element.
float getErrZ(int n, bool IB=true) const
Returns the error on the z position of the COG for the n_th element.
unsigned long getHash(int n, bool IB=true) const
Returns the hash of the n_th element.
int getNpixels(int n, bool IB=true) const
Returns the number of fired pixels of the n_th element.
double getFrequency(int n, bool IB=true) const
Returns the frequency of the n_th element;.
float getErrX(int n, bool IB=true) const
Returns the error on the x position of the COG for the n_th element.
float getZCOG(int n, bool IB=true) const
Returns the z position of the COG for the n_th element.
int getSize(bool IB) const
Returns the number of elements in the dicionary;.
bool isGroup(int n, bool IB=true) const
Returns true if the element corresponds to a group of rare topologies.
float getErr2X(int n, bool IB=true) const
Returns the error^2 on the x position of the COG for the n_th element.
static constexpr uint8_t MaxRowSpan
static constexpr uint8_t MaxColSpan
TGeoManager * readFromFile(std::string filename)
GLdouble n
Definition glcorearb.h:1982
GLboolean * data
Definition glcorearb.h:298
Defining DataPointCompositeObject explicitly as copiable.
std::unordered_map< unsigned long, int > mCommonMap
Map of pair <hash, position in mVectorOfIDs>
std::vector< itsmft::GroupStruct > mVectorOfIDs
Vector of topologies and groups.
ClassDefNV(TopologyDictionaryData, 1)
std::unordered_map< int, int > mGroupMap
Map of pair <groudID, position in mVectorOfIDs>
std::array< int, STopoSize > mSmallTopologiesLUT
Look-Up Table for the topologies with 1-byte linearised matrix.