Project
Loading...
Searching...
No Matches
IOUtils.cxx
Go to the documentation of this file.
1// Copyright 2019-2026 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
21namespace o2::its3::ioutils
22{
23
25void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
26 gsl::span<const unsigned char>::iterator& pattIt,
27 std::vector<o2::BaseCluster<float>>& output,
28 const its3::TopologyDictionary* dict)
29{
31 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
32
33 bool applyMisalignment = false;
34 const auto& conf = o2::its::TrackerParamConfig::Instance();
35 for (int il = 0; il < geom->getNumberOfLayers(); ++il) {
36 if (conf.sysErrY2[il] > 0.f || conf.sysErrZ2[il] > 0.f) {
37 applyMisalignment = true;
38 break;
39 }
40 }
41
42 for (auto& c : clusters) {
43 float sigmaY2 = NAN, sigmaZ2 = NAN;
44 auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
45 const auto detID = c.getSensorID();
46 // NOTE: this is not consistent with the TRK definition below!
47 // There we put the alpha for everything cluster to its phi
48 // here we extract it from the middle of the tile
49 auto& cl3d = output.emplace_back(detID, geom->getMatrixT2L(detID) ^ locXYZ); // local --> tracking
50 if (applyMisalignment) {
51 const auto lrID = geom->getLayer(detID);
52 sigmaY2 += conf.sysErrY2[lrID];
53 sigmaZ2 += conf.sysErrZ2[lrID];
54 }
55 cl3d.setErrors(sigmaY2, sigmaZ2, 0.f);
56 }
57}
58
60 gsl::span<const o2::itsmft::ROFRecord> rofs,
61 gsl::span<const itsmft::CompClusterExt> clusters,
62 gsl::span<const unsigned char>::iterator& pattIt,
63 const its3::TopologyDictionary* dict,
65{
66 auto geom = its::GeometryTGeo::Instance();
67 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
68
69 // tf->resetROFrameData(rofs.size()); // FIXME
70 // tf->prepareROFrameData(rofs, clusters); FIXME
71
72 its::bounded_vector<uint8_t> clusterSizeVec(clusters.size(), tf->getMemoryPool().get());
73
74 for (size_t iRof{0}; iRof < rofs.size(); ++iRof) {
75 const auto& rof = rofs[iRof];
76 for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
77 const auto& c = clusters[clusterId];
78 const auto sensorID = c.getSensorID();
79 const auto layer = geom->getLayer(sensorID);
80
81 float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
82 uint8_t clusterSize{0};
83 const auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2, clusterSize);
84 clusterSizeVec.push_back(clusterSize);
85
86 // Transformation to the local --> global
87 const auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
88
89 // Inverse transformation to the local --> tracking
90 const o2::math_utils::Point3D<float> trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
91
92 // Tracking alpha angle
93 // We want that each cluster rotates its tracking frame to the clusters phi
94 // that way the track linearization around the measurement is less biases to the arc
95 // this means automatically that the measurement on the arc is at 0 for the curved layers
96 float alpha = geom->getSensorRefAlpha(sensorID);
97 float x = trkXYZ.x(), y = trkXYZ.y();
98 if (constants::detID::isDetITS3(sensorID)) {
99 y = 0.f;
100 x = std::hypot(gloXYZ.x(), gloXYZ.y());
101 alpha = std::atan2(gloXYZ.y(), gloXYZ.x());
102 }
103 math_utils::detail::bringToPMPi(alpha); // alpha is defined on -Pi,Pi
104
105 tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), x, alpha,
106 std::array<float, 2>{y, trkXYZ.z()},
107 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
108
110 tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
111 tf->addClusterExternalIndexToLayer(layer, clusterId);
112 }
113 for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
114 tf->mROFramesClusters[iL][iRof + 1] = (int)tf->getUnsortedClusters()[iL].size();
115 }
116 }
117
118 // tf->setClusterSize(clusterSizeVec); FIXME
119
120 for (auto& v : tf->mNTrackletsPerCluster) {
121 v.resize(tf->getUnsortedClusters()[1].size());
122 }
123 for (auto& v : tf->mNTrackletsPerClusterSum) {
124 v.resize(tf->getUnsortedClusters()[1].size() + 1);
125 }
126
127 if (mcLabels != nullptr) {
128 // tf->mClusterLabels = mcLabels; // FIXME
129 }
130 return 0;
131}
132} // namespace o2::its3::ioutils
Definition of the ITSMFT compact cluster.
Definition of the BuildTopologyDictionary class for ITS3.
Definition of the GeometryTGeo class.
Definition of the ITSMFT ROFrame (trigger) record.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
uint32_t c
Definition RawData.h:2
int clusterSize
A container to hold and manage MC truth information/labels.
static GeometryTGeo * Instance()
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
GLsizeiptr size
Definition glcorearb.h:659
const GLdouble * v
Definition glcorearb.h:832
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
bool isDetITS3(T detID)
Definition SpecsV2.h:210
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const o2::its3::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:25
o2::math_utils::Point3D< T > extractClusterData(const itsmft::CompClusterExt &c, iterator &iter, const o2::its3::TopologyDictionary *dict, T &sig2y, T &sig2z)
Definition IOUtils.h:37
int loadROFrameDataITS3(its::TimeFrame< 7 > *tf, gsl::span< const o2::itsmft::ROFRecord > rofs, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, const o2::its3::TopologyDictionary *dict, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
Definition IOUtils.cxx:59
std::pmr::vector< T > bounded_vector
std::unique_ptr< GPUReconstructionTimeframe > tf
static constexpr int L2G
Definition Cartesian.h:54
static constexpr int T2L
Definition Cartesian.h:55
std::vector< Cluster > clusters