Skip to content

Commit 5b1b343

Browse files
authored
ITS3: use const view of ROFs, prepareROFData (#14694)
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 2a19535 commit 5b1b343

File tree

8 files changed

+38
-31
lines changed

8 files changed

+38
-31
lines changed

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ struct TimeFrame {
9090
int loadROFrameData(const o2::itsmft::ROFRecord& rof, gsl::span<const itsmft::Cluster> clusters,
9191
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
9292

93-
int loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
93+
int loadROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
9494
gsl::span<const itsmft::CompClusterExt> clusters,
9595
gsl::span<const unsigned char>::iterator& pattIt,
9696
const itsmft::TopologyDictionary* dict,
9797
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
9898
void resetROFrameData(size_t nROFs);
99+
void prepareROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
100+
gsl::span<const itsmft::CompClusterExt> clusters);
99101

100102
int getTotalClusters() const;
101103
auto& getTotVertIteration() { return mTotVertPerIteration; }

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ITSTrackingInterface
7878
TimeFrameN* mTimeFrame = nullptr;
7979

8080
protected:
81-
virtual void loadROF(gsl::span<itsmft::ROFRecord>& trackROFspan,
81+
virtual void loadROF(gsl::span<const itsmft::ROFRecord>& trackROFspan,
8282
gsl::span<const itsmft::CompClusterExt> clusters,
8383
gsl::span<const unsigned char>::iterator& pattIt,
8484
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels);

Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,17 @@ void TimeFrame<nLayers>::addPrimaryVerticesContributorLabelsInROF(const bounded_
103103
}
104104

105105
template <int nLayers>
106-
int TimeFrame<nLayers>::loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
106+
int TimeFrame<nLayers>::loadROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
107107
gsl::span<const itsmft::CompClusterExt> clusters,
108108
gsl::span<const unsigned char>::iterator& pattIt,
109109
const itsmft::TopologyDictionary* dict,
110110
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
111111
{
112-
resetROFrameData(rofs.size());
113-
114112
GeometryTGeo* geom = GeometryTGeo::Instance();
115113
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
116114

117-
mNrof = rofs.size();
118-
clearResizeBoundedVector(mClusterSize, clusters.size(), mMemoryPool.get());
119-
std::array<int, nLayers> clusterCountPerLayer{};
120-
for (const auto& clus : clusters) {
121-
++clusterCountPerLayer[geom->getLayer(clus.getSensorID())];
122-
}
123-
for (int iLayer{0}; iLayer < nLayers; ++iLayer) {
124-
mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
125-
mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
126-
mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
127-
}
115+
resetROFrameData(rofs.size());
116+
prepareROFrameData(rofs, clusters);
128117

129118
for (size_t iRof{0}; iRof < rofs.size(); ++iRof) {
130119
const auto& rof = rofs[iRof];
@@ -182,7 +171,7 @@ int TimeFrame<nLayers>::loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
182171
}
183172

184173
return mNrof;
185-
} // namespace o2::its
174+
}
186175

187176
template <int nLayers>
188177
void TimeFrame<nLayers>::resetROFrameData(size_t nRofs)
@@ -201,6 +190,24 @@ void TimeFrame<nLayers>::resetROFrameData(size_t nRofs)
201190
}
202191
}
203192

193+
template <int nLayers>
194+
void TimeFrame<nLayers>::prepareROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
195+
gsl::span<const itsmft::CompClusterExt> clusters)
196+
{
197+
GeometryTGeo* geom = GeometryTGeo::Instance();
198+
mNrof = rofs.size();
199+
clearResizeBoundedVector(mClusterSize, clusters.size(), mMemoryPool.get());
200+
std::array<int, nLayers> clusterCountPerLayer{};
201+
for (const auto& clus : clusters) {
202+
++clusterCountPerLayer[geom->getLayer(clus.getSensorID())];
203+
}
204+
for (int iLayer{0}; iLayer < nLayers; ++iLayer) {
205+
mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
206+
mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
207+
mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
208+
}
209+
}
210+
204211
template <int nLayers>
205212
void TimeFrame<nLayers>::prepareClusters(const TrackingParameters& trkParam, const int maxLayers)
206213
{

Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc)
139139
mTracker->setBz(o2::base::Propagator::Instance()->getNominalBz());
140140

141141
gsl::span<const unsigned char>::iterator pattIt = patterns.begin();
142-
143-
gsl::span<itsmft::ROFRecord> trackROFspan(trackROFvec);
142+
gsl::span<const itsmft::ROFRecord> trackROFspan(trackROFvec);
144143
loadROF(trackROFspan, compClusters, pattIt, labels);
145144
pattIt = patterns.begin();
146-
std::vector<int> savedROF;
145+
147146
auto logger = [&](const std::string& s) { LOG(info) << s; };
148147
auto fatalLogger = [&](const std::string& s) { LOG(fatal) << s; };
149148
auto errorLogger = [&](const std::string& s) { LOG(error) << s; };
@@ -406,7 +405,7 @@ void ITSTrackingInterface::setTraitsFromProvider(VertexerTraitsN* vertexerTraits
406405
mVertexer->setMemoryPool(mMemoryPool);
407406
}
408407

409-
void ITSTrackingInterface::loadROF(gsl::span<itsmft::ROFRecord>& trackROFspan,
408+
void ITSTrackingInterface::loadROF(gsl::span<const itsmft::ROFRecord>& trackROFspan,
410409
gsl::span<const itsmft::CompClusterExt> clusters,
411410
gsl::span<const unsigned char>::iterator& pattIt,
412411
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)

Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/IOUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
7272
const its3::TopologyDictionary* dict);
7373

7474
int loadROFrameDataITS3(its::TimeFrame<7>* tf,
75-
gsl::span<o2::itsmft::ROFRecord> rofs,
75+
gsl::span<const o2::itsmft::ROFRecord> rofs,
7676
gsl::span<const itsmft::CompClusterExt> clusters,
7777
gsl::span<const unsigned char>::iterator& pattIt,
7878
const its3::TopologyDictionary* dict,

Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/TrackingInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ITS3TrackingInterface final : public its::ITSTrackingInterface
2828
void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
2929

3030
protected:
31-
void loadROF(gsl::span<itsmft::ROFRecord>& trackROFspan,
31+
void loadROF(gsl::span<const itsmft::ROFRecord>& trackROFspan,
3232
gsl::span<const itsmft::CompClusterExt> clusters,
3333
gsl::span<const unsigned char>::iterator& pattIt,
3434
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels) final;

Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
5858
}
5959

6060
int loadROFrameDataITS3(its::TimeFrame<7>* tf,
61-
gsl::span<o2::itsmft::ROFRecord> rofs,
61+
gsl::span<const o2::itsmft::ROFRecord> rofs,
6262
gsl::span<const itsmft::CompClusterExt> clusters,
6363
gsl::span<const unsigned char>::iterator& pattIt,
6464
const its3::TopologyDictionary* dict,
6565
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
6666
{
67-
tf->resetROFrameData(rofs.size());
68-
6967
auto geom = its::GeometryTGeo::Instance();
7068
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
7169

72-
tf->mNrof = 0;
70+
tf->resetROFrameData(rofs.size());
71+
tf->prepareROFrameData(rofs, clusters);
7372

7473
its::bounded_vector<uint8_t> clusterSizeVec(clusters.size(), tf->getMemoryPool().get());
7574

76-
for (auto& rof : rofs) {
75+
for (size_t iRof{0}; iRof < rofs.size(); ++iRof) {
76+
const auto& rof = rofs[iRof];
7777
for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
7878
auto& c = clusters[clusterId];
7979
auto sensorID = c.getSensorID();
@@ -108,9 +108,8 @@ int loadROFrameDataITS3(its::TimeFrame<7>* tf,
108108
tf->addClusterExternalIndexToLayer(layer, clusterId);
109109
}
110110
for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
111-
tf->mROFramesClusters[iL].push_back(tf->getUnsortedClusters()[iL].size());
111+
tf->mROFramesClusters[iL][iRof + 1] = tf->getUnsortedClusters()[iL].size();
112112
}
113-
tf->mNrof++;
114113
}
115114

116115
tf->setClusterSize(clusterSizeVec);

Detectors/Upgrades/ITS3/reconstruction/src/TrackingInterface.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void ITS3TrackingInterface::finaliseCCDB(framework::ConcreteDataMatcher& matcher
7474
}
7575
}
7676

77-
void ITS3TrackingInterface::loadROF(gsl::span<itsmft::ROFRecord>& trackROFspan,
77+
void ITS3TrackingInterface::loadROF(gsl::span<const itsmft::ROFRecord>& trackROFspan,
7878
gsl::span<const itsmft::CompClusterExt> clusters,
7979
gsl::span<const unsigned char>::iterator& pattIt,
8080
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)

0 commit comments

Comments
 (0)