-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathROframe.h
More file actions
190 lines (157 loc) · 6.02 KB
/
ROframe.h
File metadata and controls
190 lines (157 loc) · 6.02 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// 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.
///
/// \file ROframe.h
/// \brief
///
#ifndef TRACKINGITSU_INCLUDE_ROFRAME_H_
#define TRACKINGITSU_INCLUDE_ROFRAME_H_
#include <array>
#include <vector>
#include <utility>
#include <cassert>
#include <gsl/gsl>
#include "ITStracking/Cluster.h"
#include "ITStracking/Constants.h"
#include "ReconstructionDataFormats/Vertex.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "SimulationDataFormat/MCTruthContainer.h"
namespace o2
{
namespace its
{
using Vertex = o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>;
class ROframe final
{
public:
ROframe(int ROframeId, int nLayers);
int getROFrameId() const;
const float3& getPrimaryVertex(const int) const;
int getPrimaryVerticesNum() const;
void addPrimaryVertex(const float, const float, const float);
void addPrimaryVertices(std::vector<Vertex> vertices);
void addPrimaryReconstructedVertex(const float, const float, const float);
void printPrimaryVertices() const;
int getTotalClusters() const;
bool empty() const;
const auto& getClusters() const { return mClusters; }
const std::vector<Cluster>& getClustersOnLayer(int layerId) const;
const std::vector<TrackingFrameInfo>& getTrackingFrameInfoOnLayer(int layerId) const;
const auto& getTrackingFrameInfo() const { return mTrackingFrameInfo; }
const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const;
const MCCompLabel& getClusterFirstLabel(int layerId, const Cluster& cl) const;
const MCCompLabel& getClusterFirstLabel(int layerId, const int clId) const;
const gsl::span<const o2::MCCompLabel> getClusterLabels(int layerId, const int clId) const;
const gsl::span<const o2::MCCompLabel> getClusterLabels(int layerId, const Cluster& cl) const;
int getClusterExternalIndex(int layerId, const int clId) const;
std::vector<int> getTracksId(const int layerId, const std::vector<Cluster>& cl);
template <typename... T>
void addClusterToLayer(int layer, T&&... args);
template <typename... T>
void addTrackingFrameInfoToLayer(int layer, T&&... args);
void setMClabelsContainer(const dataformats::MCTruthContainer<MCCompLabel>* ptr);
void addClusterExternalIndexToLayer(int layer, const int idx);
bool hasMCinformation() const;
void clear();
private:
const int mROframeId;
const o2::dataformats::MCTruthContainer<MCCompLabel>* mMClabels = nullptr;
std::vector<float3> mPrimaryVertices;
std::vector<std::vector<Cluster>> mClusters;
std::vector<std::vector<TrackingFrameInfo>> mTrackingFrameInfo;
std::vector<std::vector<int>> mClusterExternalIndices;
};
inline int ROframe::getROFrameId() const { return mROframeId; }
inline const float3& ROframe::getPrimaryVertex(const int vertexIndex) const { return mPrimaryVertices[vertexIndex]; }
inline int ROframe::getPrimaryVerticesNum() const { return mPrimaryVertices.size(); }
inline bool ROframe::empty() const { return getTotalClusters() == 0; }
inline const std::vector<Cluster>& ROframe::getClustersOnLayer(int layerId) const
{
return mClusters[layerId];
}
inline const std::vector<TrackingFrameInfo>& ROframe::getTrackingFrameInfoOnLayer(int layerId) const
{
return mTrackingFrameInfo[layerId];
}
inline const TrackingFrameInfo& ROframe::getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const
{
return mTrackingFrameInfo[layerId][cl.clusterId];
}
inline const MCCompLabel& ROframe::getClusterFirstLabel(int layerId, const Cluster& cl) const
{
return getClusterFirstLabel(layerId, cl.clusterId);
}
inline const MCCompLabel& ROframe::getClusterFirstLabel(int layerId, const int clId) const
{
return *(mMClabels->getLabels(getClusterExternalIndex(layerId, clId)).begin());
}
inline const gsl::span<const o2::MCCompLabel> ROframe::getClusterLabels(int layerId, const int clId) const
{
return mMClabels->getLabels(getClusterExternalIndex(layerId, clId));
}
inline const gsl::span<const o2::MCCompLabel> ROframe::getClusterLabels(int layerId, const Cluster& cl) const
{
return getClusterLabels(layerId, cl.clusterId);
}
inline int ROframe::getClusterExternalIndex(int layerId, const int clId) const
{
return mClusterExternalIndices[layerId][clId];
}
inline std::vector<int> ROframe::getTracksId(const int layerId, const std::vector<Cluster>& cl)
{
std::vector<int> tracksId;
for (auto& cluster : cl) {
tracksId.push_back(getClusterFirstLabel(layerId, cluster).isNoise() ? -1 : getClusterFirstLabel(layerId, cluster).getTrackID());
}
return tracksId;
}
template <typename... T>
void ROframe::addClusterToLayer(int layer, T&&... values)
{
mClusters[layer].emplace_back(std::forward<T>(values)...);
}
template <typename... T>
void ROframe::addTrackingFrameInfoToLayer(int layer, T&&... values)
{
mTrackingFrameInfo[layer].emplace_back(std::forward<T>(values)...);
}
inline void ROframe::setMClabelsContainer(const dataformats::MCTruthContainer<MCCompLabel>* ptr)
{
mMClabels = ptr;
}
inline void ROframe::addClusterExternalIndexToLayer(int layer, const int idx)
{
mClusterExternalIndices[layer].push_back(idx);
}
inline void ROframe::clear()
{
for (unsigned int iL = 0; iL < mClusters.size(); ++iL) {
mClusters[iL].clear();
mTrackingFrameInfo[iL].clear();
// mClusterLabels[iL].clear();
mClusterExternalIndices[iL].clear();
}
mPrimaryVertices.clear();
mMClabels = nullptr;
}
inline bool ROframe::hasMCinformation() const
{
// for (const auto& vect : mClusterLabels) {
// if (!vect.empty()) {
// return true;
// }
// }
// return false;
return mMClabels;
}
} // namespace its
} // namespace o2
#endif /* TRACKINGITSU_INCLUDE_ROFRAME_H_ */