forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOUtils.cxx
More file actions
129 lines (112 loc) · 5.23 KB
/
IOUtils.cxx
File metadata and controls
129 lines (112 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "ITS3Reconstruction/IOUtils.h"
#include "ITStracking/IOUtils.h"
#include "ITStracking/TimeFrame.h"
#include "ITStracking/BoundedAllocator.h"
#include "DataFormatsITSMFT/CompCluster.h"
#include "DataFormatsITSMFT/ROFRecord.h"
#include "ITS3Reconstruction/TopologyDictionary.h"
#include "ITSBase/GeometryTGeo.h"
#include "ITS3Base/SpecsV2.h"
#include "ITStracking/TrackingConfigParam.h"
#include "Framework/Logger.h"
#include <limits>
namespace o2::its3::ioutils
{
/// convert compact clusters to 3D spacepoints
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)
{
auto geom = o2::its::GeometryTGeo::Instance();
bool applyMisalignment = false;
const auto& conf = o2::its::TrackerParamConfig::Instance();
for (int il = 0; il < geom->getNumberOfLayers(); ++il) {
if (conf.sysErrY2[il] > 0.f || conf.sysErrZ2[il] > 0.f) {
applyMisalignment = true;
break;
}
}
for (auto& c : clusters) {
float sigmaY2, sigmaZ2, sigmaYZ = 0;
auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
const auto detID = c.getSensorID();
auto& cl3d = output.emplace_back(detID,
(its3::constants::detID::isDetITS3(detID) ? geom->getT2LMatrixITS3(detID, geom->getSensorRefAlpha(detID)) : geom->getMatrixT2L(detID)) ^ locXYZ); // local --> tracking
if (applyMisalignment) {
auto lrID = geom->getLayer(detID);
sigmaY2 += conf.sysErrY2[lrID];
sigmaZ2 += conf.sysErrZ2[lrID];
}
cl3d.setErrors(sigmaY2, sigmaZ2, sigmaYZ);
}
}
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)
{
auto geom = its::GeometryTGeo::Instance();
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
tf->resetROFrameData(rofs.size());
tf->prepareROFrameData(rofs, clusters);
its::bounded_vector<uint8_t> clusterSizeVec(clusters.size(), tf->getMemoryPool().get());
for (size_t iRof{0}; iRof < rofs.size(); ++iRof) {
const auto& rof = rofs[iRof];
for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
auto& c = clusters[clusterId];
auto sensorID = c.getSensorID();
auto isITS3 = its3::constants::detID::isDetITS3(sensorID);
auto layer = geom->getLayer(sensorID);
float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
uint8_t clusterSize{0};
auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2, clusterSize);
clusterSizeVec.push_back(clusterSize);
// Transformation to the local --> global
auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
// for cylindrical layers we have a different alpha for each cluster, for regular silicon detectors instead a single alpha for the whole sensor
float alpha = geom->getSensorRefAlpha(sensorID);
o2::math_utils::Point3D<float> trkXYZ;
if (isITS3) {
// Inverse transformation to the local --> tracking
trkXYZ = geom->getT2LMatrixITS3(sensorID, alpha) ^ locXYZ;
} else {
// Inverse transformation to the local --> tracking
trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
}
tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), alpha,
std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
/// Rotate to the global frame
tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
tf->addClusterExternalIndexToLayer(layer, clusterId);
}
for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
tf->mROFramesClusters[iL][iRof + 1] = tf->getUnsortedClusters()[iL].size();
}
}
tf->setClusterSize(clusterSizeVec);
for (auto& v : tf->mNTrackletsPerCluster) {
v.resize(tf->getUnsortedClusters()[1].size());
}
for (auto& v : tf->mNTrackletsPerClusterSum) {
v.resize(tf->getUnsortedClusters()[1].size() + 1);
}
if (mcLabels != nullptr) {
tf->mClusterLabels = mcLabels;
}
return tf->mNrof;
}
} // namespace o2::its3::ioutils