Project
Loading...
Searching...
No Matches
TopologyClassifier.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
20
21#ifndef ALICEO2_IOTOF_TOPOLOGYCLASSIFIER_H
22#define ALICEO2_IOTOF_TOPOLOGYCLASSIFIER_H
23
24#include <array>
25#include <cstdint>
26#include <unordered_map>
27
28#include <TFile.h>
29
34
35// TO BE REMOVED BEFORE PUSH
36#include "Framework/Logger.h"
37
38namespace o2
39{
40namespace iotof
41{
42
62
64 int mSizeX = 0;
65 int mSizeZ = 0;
68 float mXMean = 0.f;
69 float mZMean = 0.f;
70 float mXSigma2 = 0.f;
71 float mZSigma2 = 0.f;
72 int mNPixels = 0;
73 int mFrequency = 0;
75 uint16_t mPattern;
76
77 void print() const
78 {
79 LOG(info) << "---> TopologyInfo: Topology = " << static_cast<int>(mTopology)
80 << ", SizeX = " << mSizeX << ", SizeZ = " << mSizeZ
81 << ", OffsetXToCOG = " << mOffsetXToCOG << ", OffsetZToCOG = " << mOffsetZToCOG
82 << ", XMean = " << mXMean << ", ZMean = " << mZMean
83 << ", XSigma2 = " << mXSigma2 << ", ZSigma2 = " << mZSigma2
84 << ", NPixels = " << mNPixels
85 << ", Frequency = " << mFrequency
86 << ", Pattern (bitmask) = 0x" << std::hex << mPattern;
87 }
88};
89
91{
92 public:
93 // Define limits for domain validation
94 static constexpr uint8_t MaxRowSpan = 255;
95 static constexpr uint8_t MaxColSpan = 255;
96 static constexpr uint16_t MaxBitmask = 65535;
97
99 {
100 sSegmentation = o2::iotof::Segmentation::Instance();
101 }
102 TopologyClassifier(std::unordered_map<uint32_t, TopologyInfo> map) : mTopologyCache(std::move(map))
103 {
104 sSegmentation = o2::iotof::Segmentation::Instance();
105 }
106
107 const std::unordered_map<uint32_t, TopologyInfo>& getTopologyMap() const { return mTopologyCache; };
108 void getTopology(uint16_t bitmask, uint16_t minRow, uint8_t spanRow, uint16_t minCol, uint8_t spanCol, uint32_t& topology);
110 void accountTopology(uint16_t bitmask, uint16_t minRow, uint8_t spanRow, uint16_t minCol, uint8_t spanCol);
111 void computeCOG(uint16_t bitmask, uint16_t minRow, uint8_t spanRow, uint16_t minCol, uint8_t spanCol, TopologyInfo& topoInfo);
112
113 math_utils::Point3D<float> getClusterCoordinates(const Cluster& cluster);
114
115 void saveCacheToFile(const char* filename);
116 void print();
117
118 float getErrX(uint32_t pattID) { return std::sqrt(getTopologyFeatures(pattID).mXSigma2); };
119 float getErrZ(uint32_t pattID) { return std::sqrt(getTopologyFeatures(pattID).mZSigma2); };
120 float getNPixels(uint32_t pattID) { return getTopologyFeatures(pattID).mNPixels; };
121 float getMeanX(uint32_t pattID) { return getTopologyFeatures(pattID).mXMean; };
122 float getMeanZ(uint32_t pattID) { return getTopologyFeatures(pattID).mZMean; };
123
124 // Provide the common iotof::GeometryTGeo to access matrices and segmentation
125 void setGeometry(const o2::iotof::GeometryTGeo* gm) { mGeometry = gm; }
126
127 static uint32_t makeKey(uint8_t spanRow, uint8_t spanCol, uint16_t bitmask)
128 {
129 return (static_cast<uint32_t>(spanRow) << 24) |
130 (static_cast<uint32_t>(spanCol) << 16) |
131 static_cast<uint32_t>(bitmask);
132 }
133
134 private:
136 [[nodiscard]] static constexpr uint32_t packKey(uint8_t spanRow, uint8_t spanCol, uint16_t bitmask) noexcept
137 {
138 return (static_cast<uint32_t>(spanRow) << 24) |
139 (static_cast<uint32_t>(spanCol) << 16) |
140 static_cast<uint32_t>(bitmask);
141 }
142
143 std::unordered_map<uint32_t, TopologyInfo> mTopologyCache;
144 const o2::iotof::GeometryTGeo* mGeometry = nullptr;
145 static o2::iotof::Segmentation* sSegmentation;
146};
147
148} // namespace iotof
149} // namespace o2
150
151#endif // ALICEO2_IOTOF_TOPOLOGYCLASSIFIER_H
Definition of the IOTOF cluster.
std::bitset< 80 > bitmask
Definition of the Segmentation class.
StringRef key
Segmentation and response for pixels in inner and outer TOF of the ALICE 3 apparatus.
void saveCacheToFile(const char *filename)
void computeCOG(uint16_t bitmask, uint16_t minRow, uint8_t spanRow, uint16_t minCol, uint8_t spanCol, TopologyInfo &topoInfo)
static constexpr uint8_t MaxColSpan
float getMeanX(uint32_t pattID)
const std::unordered_map< uint32_t, TopologyInfo > & getTopologyMap() const
void accountTopology(uint16_t bitmask, uint16_t minRow, uint8_t spanRow, uint16_t minCol, uint8_t spanCol)
void getTopology(uint16_t bitmask, uint16_t minRow, uint8_t spanRow, uint16_t minCol, uint8_t spanCol, uint32_t &topology)
float getNPixels(uint32_t pattID)
static constexpr uint16_t MaxBitmask
void setGeometry(const o2::iotof::GeometryTGeo *gm)
TopologyClassifier(std::unordered_map< uint32_t, TopologyInfo > map)
static uint32_t makeKey(uint8_t spanRow, uint8_t spanCol, uint16_t bitmask)
math_utils::Point3D< float > getClusterCoordinates(const Cluster &cluster)
TopologyInfo getTopologyFeatures(uint32_t key)
float getMeanZ(uint32_t pattID)
static constexpr uint8_t MaxRowSpan
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
uint16_t mPattern
Bitmask of fired pixels.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"