Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Detectors/ITSMFT/ITS/tracking/include/ITStracking/IOUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ inline static const o2::itsmft::ChipMappingITS& getChipMappingITS()
return MP;
}

std::vector<std::unordered_map<int, Label>> loadLabels(const int, const std::string&);
void writeRoadsReport(std::ofstream&, std::ofstream&, std::ofstream&, const std::vector<std::vector<Road<5>>>&,
const std::unordered_map<int, Label>&);

template <class iterator, typename T>
o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, iterator& iter, const itsmft::TopologyDictionary* dict, T& sig2y, T& sig2z)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ struct TimeFrame {
bounded_vector<int> mBogusClusters; /// keep track of clusters with wild coordinates

bounded_vector<std::pair<unsigned long long, bool>> mRoadLabels;
int mCutClusterMult;
int mCutVertexMult;
int mCutClusterMult{-999};
int mCutVertexMult{-999};

// Vertexer
std::vector<bounded_vector<int>> mNTrackletsPerROF;
Expand Down
6 changes: 3 additions & 3 deletions Detectors/ITSMFT/ITS/tracking/include/ITStracking/Tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class Tracker
void adoptTimeFrame(TimeFrame<NLayers>& tf);

void clustersToTracks(
LogFunc = [](const std::string& s) { std::cout << s << '\n'; },
LogFunc = [](const std::string& s) { std::cerr << s << '\n'; });
const LogFunc& = [](const std::string& s) { std::cout << s << '\n'; },
const LogFunc& = [](const std::string& s) { std::cerr << s << '\n'; });

void setParameters(const std::vector<TrackingParameters>& p) { mTrkParams = p; }
void setMemoryPool(std::shared_ptr<BoundedMemoryResource>& pool) { mMemoryPool = pool; }
Expand Down Expand Up @@ -113,7 +113,7 @@ class Tracker
Roading,
NStates,
};
State mCurState;
State mCurState{TFInit};
static constexpr std::array<const char*, NStates> StateNames{"TimeFrame initialisation", "Tracklet finding", "Cell finding", "Neighbour finding", "Road finding"};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Vertexer
Finding,
NStates,
};
State mCurState;
State mCurState{Init};
static constexpr std::array<const char*, NStates> StateNames{"Initialisation", "Tracklet finding", "Tracklet validation", "Vertex finding"};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class VertexerTraits
bounded_vector<o2::MCCompLabel>*,
const int iteration = 0);

const bounded_vector<std::pair<int, int>> selectClusters(const int* indexTable,
const std::array<int, 4>& selectedBinsRect,
const IndexTableUtils& utils);
bounded_vector<std::pair<int, int>> selectClusters(const int* indexTable,
const std::array<int, 4>& selectedBinsRect,
const IndexTableUtils& utils);

// utils
auto& getVertexingParameters() { return mVrtParams; }
Expand Down
1 change: 0 additions & 1 deletion Detectors/ITSMFT/ITS/tracking/src/Cluster.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace its

using math_utils::computePhi;
using math_utils::getNormalizedPhi;
using math_utils::hypot;

Cluster::Cluster(const float x, const float y, const float z, const int index)
: xCoordinate{x},
Expand Down
123 changes: 14 additions & 109 deletions Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@

#include "ITStracking/IOUtils.h"

#include <gsl/span>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <tuple>
#include <unordered_set>
#include <utility>

#include "ITSBase/GeometryTGeo.h"
Expand All @@ -35,10 +38,7 @@ constexpr int PrimaryVertexLayerId{-1};
constexpr int EventLabelsSeparator{-1};
} // namespace

namespace o2
{
namespace its
{
using namespace o2::its;

/// convert compact clusters to 3D spacepoints
void ioutils::convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
Expand All @@ -57,8 +57,8 @@ void ioutils::convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clu
}
}

for (auto& c : clusters) {
float sigmaY2, sigmaZ2, sigmaYZ = 0;
for (const auto& c : clusters) {
float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
auto& cl3d = output.emplace_back(c.getSensorID(), geom->getMatrixT2L(c.getSensorID()) ^ locXYZ); // local --> tracking
if (applyMisalignment) {
Expand All @@ -83,9 +83,9 @@ void ioutils::loadEventData(ROframe& event, gsl::span<const itsmft::CompClusterE
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
int clusterId{0};

for (auto& c : clusters) {
int layer = geom->getLayer(c.getSensorID());
float sigmaY2, sigmaZ2, sigmaYZ = 0;
for (const auto& c : clusters) {
const int layer = geom->getLayer(c.getSensorID());
float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
auto sensorID = c.getSensorID();
// Inverse transformation to the local --> tracking
Expand Down Expand Up @@ -118,9 +118,9 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g

auto first = rof.getFirstEntry();
auto clusters_in_frame = rof.getROFData(clusters);
for (auto& c : clusters_in_frame) {
int layer = geom->getLayer(c.getSensorID());
float sigmaY2, sigmaZ2, sigmaYZ = 0;
for (const auto& c : clusters_in_frame) {
const int layer = geom->getLayer(c.getSensorID());
float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
auto locXYZ = extractClusterData(c, pattIt, dict, sigmaY2, sigmaZ2);
auto sensorID = c.getSensorID();
// Inverse transformation to the local --> tracking
Expand All @@ -141,100 +141,5 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g
event.addClusterExternalIndexToLayer(layer, first + clusterId);
clusterId++;
}
return clusters_in_frame.size();
return (int)clusters_in_frame.size();
}

std::vector<std::unordered_map<int, Label>> ioutils::loadLabels(const int eventsNum, const std::string& fileName)
{
std::vector<std::unordered_map<int, Label>> labelsMap{};
std::unordered_map<int, Label> currentEventLabelsMap{};
std::ifstream inputStream{};
std::string line{};
int monteCarloId{}, pdgCode{}, numberOfClusters{};
float transverseMomentum{}, phi{}, pseudorapidity{};

labelsMap.reserve(eventsNum);

inputStream.open(fileName);
std::getline(inputStream, line);

while (std::getline(inputStream, line)) {

std::istringstream inputStringStream(line);

if (inputStringStream >> monteCarloId) {

if (monteCarloId == EventLabelsSeparator) {

labelsMap.emplace_back(currentEventLabelsMap);
currentEventLabelsMap.clear();

} else {

if (inputStringStream >> transverseMomentum >> phi >> pseudorapidity >> pdgCode >> numberOfClusters) {

if (std::abs(pdgCode) == constants::pdgcodes::PionCode && numberOfClusters == 7) {

currentEventLabelsMap.emplace(std::piecewise_construct, std::forward_as_tuple(monteCarloId),
std::forward_as_tuple(monteCarloId, transverseMomentum, phi,
pseudorapidity, pdgCode, numberOfClusters));
}
}
}
}
}

labelsMap.emplace_back(currentEventLabelsMap);

return labelsMap;
}

// void ioutils::writeRoadsReport(std::ofstream& correctRoadsOutputStream, std::ofstream& duplicateRoadsOutputStream,
// std::ofstream& fakeRoadsOutputStream, const std::vector<std::vector<Road<5>>>& roads,
// const std::unordered_map<int, Label>& labelsMap)
// {
// const int numVertices{static_cast<int>(roads.size())};
// std::unordered_set<int> foundMonteCarloIds{};

// correctRoadsOutputStream << EventLabelsSeparator << std::endl;
// fakeRoadsOutputStream << EventLabelsSeparator << std::endl;

// for (int iVertex{0}; iVertex < numVertices; ++iVertex) {

// const std::vector<Road<5>>& currentVertexRoads{roads[iVertex]};
// const int numRoads{static_cast<int>(currentVertexRoads.size())};

// for (int iRoad{0}; iRoad < numRoads; ++iRoad) {

// const Road<5>& currentRoad{currentVertexRoads[iRoad]};
// const int currentRoadLabel{currentRoad.getLabel()};

// if (!labelsMap.count(currentRoadLabel)) {

// continue;
// }

// const Label& currentLabel{labelsMap.at(currentRoadLabel)};

// if (currentRoad.isFakeRoad()) {

// fakeRoadsOutputStream << currentLabel << std::endl;

// } else {

// if (foundMonteCarloIds.count(currentLabel.monteCarloId)) {

// duplicateRoadsOutputStream << currentLabel << std::endl;

// } else {

// correctRoadsOutputStream << currentLabel << std::endl;
// foundMonteCarloIds.emplace(currentLabel.monteCarloId);
// }
// }
// }
// }
// }

} // namespace its
} // namespace o2
20 changes: 9 additions & 11 deletions Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertic
for (const auto& vertex : vertices) {
mPrimaryVertices.emplace_back(vertex);
if (!isBeamPositionOverridden) {
const int w{vertex.getNContributors()};
const float w = vertex.getNContributors();
mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
mBeamPosWeight += w;
Expand Down Expand Up @@ -125,7 +125,7 @@ void TimeFrame<nLayers>::addPrimaryVertices(const gsl::span<const Vertex>& verti
mPrimaryVertices.emplace_back(vertex); // put a copy in the present
mTotVertPerIteration[iteration]++;
if (!isBeamPositionOverridden) { // beam position is updated only at first occurrence of the vertex. A bit sketchy if we have past/future vertices, it should not impact too much.
const int w{vertex.getNContributors()};
const float w = vertex.getNContributors();
mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
mBeamPosWeight += w;
Expand Down Expand Up @@ -165,7 +165,7 @@ int TimeFrame<nLayers>::loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
clearResizeBoundedVector(mClusterSize, clusters.size(), mMemoryPool.get());
for (auto& rof : rofs) {
for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
auto& c = clusters[clusterId];
const auto& c = clusters[clusterId];

int layer = geom->getLayer(c.getSensorID());

Expand Down Expand Up @@ -279,7 +279,7 @@ void TimeFrame<nLayers>::prepareClusters(const TrackingParameters& trkParam, con
c.radius = h.r;
c.indexTableBinIndex = h.bin;
}
for (unsigned int iB{0}; iB < clsPerBin.size(); ++iB) {
for (int iB{0}; iB < (int)clsPerBin.size(); ++iB) {
mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = lutPerBin[iB];
}
for (auto iB{clsPerBin.size()}; iB < (trkParam.ZBins * trkParam.PhiBins + 1); iB++) {
Expand Down Expand Up @@ -373,7 +373,7 @@ void TimeFrame<nLayers>::initialise(const int iteration, const TrackingParameter
const float cosTheta1half = o2::gpu::CAMath::Sqrt(1.f - Sq(0.5f * r1 * oneOverR));
const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - Sq(0.5f * r2 * oneOverR));
float x = r2 * cosTheta1half - r1 * cosTheta2half;
float delta = o2::gpu::CAMath::Sqrt(1. / (1.f - 0.25f * Sq(x * oneOverR)) * (Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta2half + cosTheta1half) * Sq(res1) + Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta1half + cosTheta2half) * Sq(res2)));
float delta = o2::gpu::CAMath::Sqrt(1.f / (1.f - 0.25f * Sq(x * oneOverR)) * (Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta2half + cosTheta1half) * Sq(res1) + Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta1half + cosTheta2half) * Sq(res2)));
mPhiCuts[iLayer] = std::min(o2::gpu::CAMath::ASin(0.5f * x * oneOverR) + 2.f * mMSangles[iLayer] + delta, constants::math::Pi * 0.5f);
}
}
Expand All @@ -400,13 +400,13 @@ template <int nLayers>
unsigned long TimeFrame<nLayers>::getArtefactsMemory() const
{
unsigned long size{0};
for (auto& trkl : mTracklets) {
for (const auto& trkl : mTracklets) {
size += sizeof(Tracklet) * trkl.size();
}
for (auto& cells : mCells) {
for (const auto& cells : mCells) {
size += sizeof(CellSeed) * cells.size();
}
for (auto& cellsN : mCellsNeighbours) {
for (const auto& cellsN : mCellsNeighbours) {
size += sizeof(int) * cellsN.size();
}
return size + sizeof(Road<nLayers - 2>) * mRoads.size();
Expand All @@ -421,9 +421,7 @@ void TimeFrame<nLayers>::printArtefactsMemory() const
template <int nLayers>
void TimeFrame<nLayers>::fillPrimaryVerticesXandAlpha()
{
if (mPValphaX.size()) {
mPValphaX.clear();
}
deepVectorClear(mPValphaX);
mPValphaX.reserve(mPrimaryVertices.size());
for (auto& pv : mPrimaryVertices) {
mPValphaX.emplace_back(std::array<float, 2>{o2::gpu::CAMath::Hypot(pv.getX(), pv.getY()), math_utils::computePhi(pv.getX(), pv.getY())});
Expand Down
14 changes: 7 additions & 7 deletions Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Tracker::Tracker(TrackerTraits7* traits) : mTraits(traits)
mTrkParams.resize(1);
}

void Tracker::clustersToTracks(LogFunc logger, LogFunc error)
void Tracker::clustersToTracks(const LogFunc& logger, const LogFunc& error)
{
LogFunc evalLog = [](const std::string&) {};

Expand Down Expand Up @@ -195,7 +195,7 @@ void Tracker::computeRoadsMClabels()
bool found{false};
for (size_t iOcc{0}; iOcc < occurrences.size(); ++iOcc) {
std::pair<o2::MCCompLabel, size_t>& occurrence = occurrences[iOcc];
for (auto& label : cl0labs) {
for (const auto& label : cl0labs) {
if (label == occurrence.first) {
++occurrence.second;
found = true;
Expand All @@ -204,7 +204,7 @@ void Tracker::computeRoadsMClabels()
}
}
if (!found) {
for (auto& label : cl0labs) {
for (const auto& label : cl0labs) {
occurrences.emplace_back(label, 1);
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ void Tracker::computeTracksMClabels()
bool found{false};
for (size_t iOcc{0}; iOcc < occurrences.size(); ++iOcc) {
std::pair<o2::MCCompLabel, size_t>& occurrence = occurrences[iOcc];
for (auto& label : labels) {
for (const auto& label : labels) {
if (label == occurrence.first) {
++occurrence.second;
found = true;
Expand All @@ -286,7 +286,7 @@ void Tracker::computeTracksMClabels()
}
}
if (!found) {
for (auto& label : labels) {
for (const auto& label : labels) {
occurrences.emplace_back(label, 1);
}
}
Expand All @@ -302,7 +302,7 @@ void Tracker::computeTracksMClabels()
auto clid = track.getClusterIndex(ic);
if (clid != constants::its::UnusedIndex) {
auto labelsSpan = mTimeFrame->getClusterLabels(ic, clid);
for (auto& currentLabel : labelsSpan) {
for (const auto& currentLabel : labelsSpan) {
if (currentLabel == maxOccurrencesValue) {
pattern |= 0x1 << (16 + ic); // set bit if correct
break;
Expand Down Expand Up @@ -335,7 +335,7 @@ void Tracker::rectifyClusterIndices()

void Tracker::getGlobalConfiguration()
{
auto& tc = o2::its::TrackerParamConfig::Instance();
const auto& tc = o2::its::TrackerParamConfig::Instance();
if (tc.useMatCorrTGeo) {
mTraits->setCorrType(o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrTGeo);
} else if (tc.useFastMaterial) {
Expand Down
6 changes: 3 additions & 3 deletions Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
const float inverseR0{1.f / currentCluster.radius};

for (int iV{startVtx}; iV < endVtx; ++iV) {
auto& primaryVertex{primaryVertices[iV]};
const auto& primaryVertex{primaryVertices[iV]};
if (primaryVertex.isFlagSet(2) && iteration != 3) {
continue;
}
Expand Down Expand Up @@ -830,8 +830,8 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
mTaskArena.execute([&] {
bounded_vector<int> perSeedCount(trackSeeds.size() + 1, 0, mMemoryPool.get());
tbb::parallel_for(
tbb::blocked_range<size_t>(size_t(0), trackSeeds.size()),
[&](const tbb::blocked_range<size_t>& Seeds) {
tbb::blocked_range<int>(0, (int)trackSeeds.size()),
[&](const tbb::blocked_range<int>& Seeds) {
for (int iSeed = Seeds.begin(); iSeed < Seeds.end(); ++iSeed) {
const CellSeed& seed{trackSeeds[iSeed]};
TrackITSExt temporaryTrack{seed};
Expand Down
Loading