Project
Loading...
Searching...
No Matches
IOUtils.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
13#include "ITStracking/IOUtils.h"
20#include "ITS3Base/SpecsV2.h"
22#include "Framework/Logger.h"
23
24#include <limits>
25
26namespace o2::its3::ioutils
27{
28
30void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
31 gsl::span<const unsigned char>::iterator& pattIt,
32 std::vector<o2::BaseCluster<float>>& output,
33 const its3::TopologyDictionary* dict)
34{
36 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
37
38 bool applyMisalignment = false;
39 const auto& conf = o2::its::TrackerParamConfig::Instance();
40 for (int il = 0; il < geom->getNumberOfLayers(); ++il) {
41 if (conf.sysErrY2[il] > 0.f || conf.sysErrZ2[il] > 0.f) {
42 applyMisalignment = true;
43 break;
44 }
45 }
46
47 for (auto& c : clusters) {
48 float sigmaY2, sigmaZ2, sigmaYZ = 0;
49 auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
50 const auto detID = c.getSensorID();
51 auto& cl3d = output.emplace_back(detID, geom->getMatrixT2L(detID) ^ locXYZ); // local --> tracking
52 if (applyMisalignment) {
53 auto lrID = geom->getLayer(detID);
54 sigmaY2 += conf.sysErrY2[lrID];
55 sigmaZ2 += conf.sysErrZ2[lrID];
56 }
57 cl3d.setErrors(sigmaY2, sigmaZ2, sigmaYZ);
58 }
59}
60
62 gsl::span<const o2::itsmft::ROFRecord> rofs,
63 gsl::span<const itsmft::CompClusterExt> clusters,
64 gsl::span<const unsigned char>::iterator& pattIt,
65 const its3::TopologyDictionary* dict,
67{
68 auto geom = its::GeometryTGeo::Instance();
69 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
70
71 tf->resetROFrameData(rofs.size());
72 tf->prepareROFrameData(rofs, clusters);
73
74 its::bounded_vector<uint8_t> clusterSizeVec(clusters.size(), tf->getMemoryPool().get());
75
76 for (size_t iRof{0}; iRof < rofs.size(); ++iRof) {
77 const auto& rof = rofs[iRof];
78 for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
79 auto& c = clusters[clusterId];
80 auto sensorID = c.getSensorID();
81 auto layer = geom->getLayer(sensorID);
82
83 float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
84 uint8_t clusterSize{0};
85 auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2, clusterSize);
86 clusterSizeVec.push_back(clusterSize);
87
88 // Transformation to the local --> global
89 auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
90
91 // Inverse transformation to the local --> tracking
92 o2::math_utils::Point3D<float> trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
93
94 // Tracking alpha angle
95 float alpha = geom->getSensorRefAlpha(sensorID);
96
97 tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), alpha,
98 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
99 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
100
102 tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
103 tf->addClusterExternalIndexToLayer(layer, clusterId);
104 }
105 for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
106 tf->mROFramesClusters[iL][iRof + 1] = tf->getUnsortedClusters()[iL].size();
107 }
108 }
109
110 tf->setClusterSize(clusterSizeVec);
111
112 for (auto& v : tf->mNTrackletsPerCluster) {
113 v.resize(tf->getUnsortedClusters()[1].size());
114 }
115 for (auto& v : tf->mNTrackletsPerClusterSum) {
116 v.resize(tf->getUnsortedClusters()[1].size() + 1);
117 }
118
119 if (mcLabels != nullptr) {
120 tf->mClusterLabels = mcLabels;
121 }
122 return tf->mNrof;
123}
124} // 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
GLsizeiptr size
Definition glcorearb.h:659
const GLdouble * v
Definition glcorearb.h:832
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
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 its3::TopologyDictionary *dict, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
Definition IOUtils.cxx:61
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const its3::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:30
o2::math_utils::Point3D< T > extractClusterData(const itsmft::CompClusterExt &c, iterator &iter, const its3::TopologyDictionary *dict, T &sig2y, T &sig2z)
Definition IOUtils.h:30
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