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 bool applyMisalignment = false;
37 const auto& conf = o2::its::TrackerParamConfig::Instance();
38 for (int il = 0; il < geom->getNumberOfLayers(); ++il) {
39 if (conf.sysErrY2[il] > 0.f || conf.sysErrZ2[il] > 0.f) {
40 applyMisalignment = true;
41 break;
42 }
43 }
44
45 for (auto& c : clusters) {
46 float sigmaY2, sigmaZ2, sigmaYZ = 0;
47 auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
48 const auto detID = c.getSensorID();
49 auto& cl3d = output.emplace_back(detID,
50 (its3::constants::detID::isDetITS3(detID) ? geom->getT2LMatrixITS3(detID, geom->getSensorRefAlpha(detID)) : geom->getMatrixT2L(detID)) ^ locXYZ); // local --> tracking
51 if (applyMisalignment) {
52 auto lrID = geom->getLayer(detID);
53 sigmaY2 += conf.sysErrY2[lrID];
54 sigmaZ2 += conf.sysErrZ2[lrID];
55 }
56 cl3d.setErrors(sigmaY2, sigmaZ2, sigmaYZ);
57 }
58}
59
61 gsl::span<o2::itsmft::ROFRecord> rofs,
62 gsl::span<const itsmft::CompClusterExt> clusters,
63 gsl::span<const unsigned char>::iterator& pattIt,
64 const its3::TopologyDictionary* dict,
66{
67 tf->resetROFrameData();
68
69 auto geom = its::GeometryTGeo::Instance();
70 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
71
72 tf->mNrof = 0;
73
74 its::bounded_vector<uint8_t> clusterSizeVec(clusters.size(), tf->getMemoryPool().get());
75
76 for (auto& rof : rofs) {
77 for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
78 auto& c = clusters[clusterId];
79 auto sensorID = c.getSensorID();
80 auto isITS3 = its3::constants::detID::isDetITS3(sensorID);
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 // for cylindrical layers we have a different alpha for each cluster, for regular silicon detectors instead a single alpha for the whole sensor
92 float alpha = geom->getSensorRefAlpha(sensorID);
94 if (isITS3) {
95 // Inverse transformation to the local --> tracking
96 trkXYZ = geom->getT2LMatrixITS3(sensorID, alpha) ^ locXYZ;
97 } else {
98 // Inverse transformation to the local --> tracking
99 trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
100 }
101
102 tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), alpha,
103 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
104 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
105
107 tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
108 tf->addClusterExternalIndexToLayer(layer, clusterId);
109 }
110 for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
111 tf->mROFramesClusters[iL].push_back(tf->getUnsortedClusters()[iL].size());
112 }
113 tf->mNrof++;
114 }
115
116 tf->setClusterSize(clusterSizeVec);
117
118 for (auto& v : tf->mNTrackletsPerCluster) {
119 v.resize(tf->getUnsortedClusters()[1].size());
120 }
121 for (auto& v : tf->mNTrackletsPerClusterSum) {
122 v.resize(tf->getUnsortedClusters()[1].size() + 1);
123 }
124
125 if (mcLabels != nullptr) {
126 tf->mClusterLabels = mcLabels;
127 }
128 return tf->mNrof;
129}
130} // 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
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 its3::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:30
int loadROFrameDataITS3(its::TimeFrame< 7 > *tf, gsl::span< 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:60
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