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"
21#include "ITS3Base/SpecsV2.h"
23#include "Framework/Logger.h"
24
25#include <limits>
26
27namespace o2::its3::ioutils
28{
29
31void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
32 gsl::span<const unsigned char>::iterator& pattIt,
33 std::vector<o2::BaseCluster<float>>& output,
34 const its3::TopologyDictionary* dict)
35{
37 bool applyMisalignment = false;
38 const auto& conf = o2::its::TrackerParamConfig::Instance();
39 for (int il = 0; il < geom->getNumberOfLayers(); ++il) {
40 if (conf.sysErrY2[il] > 0.f || conf.sysErrZ2[il] > 0.f) {
41 applyMisalignment = true;
42 break;
43 }
44 }
45
46 for (auto& c : clusters) {
47 float sigmaY2, sigmaZ2, sigmaYZ = 0;
48 auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
49 const auto detID = c.getSensorID();
50 auto& cl3d = output.emplace_back(detID,
51 (its3::constants::detID::isDetITS3(detID) ? geom->getT2LMatrixITS3(detID, geom->getSensorRefAlpha(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<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->mNrof = 0;
72
73 std::vector<uint8_t> clusterSizeVec;
74 clusterSizeVec.reserve(clusters.size());
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 auto pattID = c.getPatternID();
84 float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
85 uint8_t clusterSize{0};
86 auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2, clusterSize);
87 clusterSizeVec.push_back(clusterSize);
88
89 // Transformation to the local --> global
90 auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
91
92 // for cylindrical layers we have a different alpha for each cluster, for regular silicon detectors instead a single alpha for the whole sensor
93 float alpha = geom->getSensorRefAlpha(sensorID);
95 if (isITS3) {
96 // Inverse transformation to the local --> tracking
97 trkXYZ = geom->getT2LMatrixITS3(sensorID, alpha) ^ locXYZ;
98 } else {
99 // Inverse transformation to the local --> tracking
100 trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
101 }
102
103 tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), alpha,
104 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
105 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
106
108 tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
109 tf->addClusterExternalIndexToLayer(layer, clusterId);
110 }
111 for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
112 tf->mROFramesClusters[iL].push_back(tf->getUnsortedClusters()[iL].size());
113 }
114 tf->mNrof++;
115 }
116
117 tf->setClusterSize(clusterSizeVec);
118
119 for (auto& v : tf->mNTrackletsPerCluster) {
120 v.resize(tf->getUnsortedClusters()[1].size());
121 }
122 for (auto& v : tf->mNTrackletsPerClusterSum) {
123 v.resize(tf->getUnsortedClusters()[1].size() + 1);
124 }
125
126 if (mcLabels != nullptr) {
127 tf->mClusterLabels = mcLabels;
128 }
129 return tf->mNrof;
130}
131} // 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
Definition of the SegmentationAlpide class.
Definition of the SegmentationSuperAlpide class.
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:161
int loadROFrameDataITS3(its::TimeFrame *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: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:31
o2::math_utils::Point3D< T > extractClusterData(const itsmft::CompClusterExt &c, iterator &iter, const its3::TopologyDictionary *dict, T &sig2y, T &sig2z)
Definition IOUtils.h:31
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