Skip to content

Commit ae95a2f

Browse files
committed
Restore
1 parent b7b517a commit ae95a2f

2 files changed

Lines changed: 77 additions & 34 deletions

File tree

‎Detectors/Upgrades/ALICE3/GlobalReconstruction/reconstruction/include/ALICE3GlobalReconstruction/TrackerACTS.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#include <ITStracking/TimeFrame.h>
2626
#include <TH2F.h>
2727

28+
namespace Acts
29+
{
30+
class Surface;
31+
}
2832
namespace o2::trk
2933
{
3034

@@ -63,7 +67,7 @@ struct SpacePoint {
6367
int clusterId{-1};
6468
int rof{-1};
6569
int sensorId{-1};
66-
// const Acts::Surface* surface{nullptr};
70+
const Acts::Surface* surface{nullptr};
6771

6872
// Derived quantities
6973
float r() const { return std::hypot(x, y); }

‎Detectors/Upgrades/ALICE3/GlobalReconstruction/reconstruction/src/TrackerACTS.cxx‎

Lines changed: 72 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,76 @@ void TrackerACTS<nLayers>::buildSpacePoints(int rof)
6060
layerSPs.clear();
6161
}
6262

63-
// Get clusters from the TimeFrame and convert to space points
63+
auto& actsGeometryManager = o2::acts::TrackingGeometryManager::instance();
64+
auto* trkGeometry = o2::trk::GeometryTGeo::Instance();
65+
66+
trkGeometry->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
67+
68+
const auto& surfaceIndex = actsGeometryManager.getIndex(*trkGeometry, 1.e-3, [trkGeometry](int sensorID) {
69+
return std::string(trkGeometry->getMatrixPath(sensorID).Data());
70+
});
71+
72+
int nMapped = 0;
73+
int nMissing = 0;
74+
6475
for (int layer = 0; layer < nLayers; ++layer) {
65-
// For now we take unsorted clusters, as soon as the cluster trackin is in place we can piggy back on it and switch to the clusters
66-
auto clusters = mTimeFrame->getUnsortedClusters()[layer];
67-
// Resize the clusters to the first 100 clusters for testing
68-
// clusters = clusters.subspan(0, std::min<size_t>(clusters.size(), 100));
69-
LOG(debug) << "ACTSTracker: got " << clusters.size() << " clusters";
76+
const auto clusters = mTimeFrame->getUnsortedClustersOnLayer(rof, layer);
77+
const int firstCluster = mTimeFrame->getSortedStartIndex(rof, layer);
78+
79+
LOG(debug) << "ACTSTracker: got " << clusters.size() << " clusters on layer " << layer;
7080

7181
for (size_t iCluster = 0; iCluster < clusters.size(); ++iCluster) {
7282
const auto& cluster = clusters[iCluster];
83+
const int clusterIndex = firstCluster + static_cast<int>(iCluster);
84+
const int externalIndex = mTimeFrame->getClusterExternalIndex(layer, clusterIndex);
85+
86+
if (externalIndex < 0 || static_cast<size_t>(externalIndex) >= mInputClusters.size()) {
87+
LOG(error) << "Invalid external cluster index " << externalIndex
88+
<< " for layer " << layer << " cluster " << clusterIndex;
89+
++nMissing;
90+
continue;
91+
}
92+
93+
const int sensorID = mInputClusters[externalIndex].getSensorID();
94+
const auto* surface = surfaceIndex.getSurface(sensorID);
95+
96+
if (!surface) {
97+
LOG(error) << "No ACTS surface for sensor " << sensorID
98+
<< " on layer " << layer;
99+
++nMissing;
100+
continue;
101+
}
73102

74103
SpacePoint sp;
75-
// Check that these are in global coordinates
76104
sp.x = cluster.xCoordinate * Acts::UnitConstants::cm;
77105
sp.y = cluster.yCoordinate * Acts::UnitConstants::cm;
78106
sp.z = cluster.zCoordinate * Acts::UnitConstants::cm;
79107

80108
if (mHistSpacePoints) {
81109
mHistSpacePoints->Fill(sp.x / Acts::UnitConstants::cm, sp.y / Acts::UnitConstants::cm);
82110
}
111+
83112
sp.layer = layer;
84-
sp.clusterId = static_cast<int>(iCluster);
113+
sp.clusterId = clusterIndex;
85114
sp.rof = rof;
115+
sp.sensorId = sensorID;
116+
sp.surface = surface;
86117

87-
// Position uncertainties (could be refined based on cluster properties)
88-
sp.varianceR = 0.01f; // ~100 um resolution squared
118+
sp.varianceR = 0.01f;
89119
sp.varianceZ = 0.01f;
90120

91121
mSpacePoints.push_back(sp);
122+
++nMapped;
92123
}
93124
}
94125

95-
// Build per-layer pointers for seeding
96126
for (auto& sp : mSpacePoints) {
97127
if (sp.layer >= 0 && sp.layer < nLayers) {
98128
mSpacePointsPerLayer[sp.layer].push_back(&sp);
99129
}
100130
}
131+
132+
LOG(info) << "ACTS surface mapping: " << nMapped << " clusters mapped, " << nMissing << " clusters missing";
101133
}
102134

103135
template <int nLayers>
@@ -378,40 +410,47 @@ void TrackerACTS<nLayers>::clustersToTracks()
378410

379411
double totalTime = 0.;
380412
LOG(info) << "==== TRK ACTS Tracking ====";
381-
// LOG(info) << "Processing " << mTimeFrame->getNrof() << " ROFs with B = " << mBz << " T";
382-
383-
// Process each ROF
384-
// for (int iROF = 0; iROF < mTimeFrame->getNrof(); ++iROF) {
385-
// LOG(info) << "Processing ROF " << iROF;
386-
// // Build space points
387-
// mCurState = SpacePointBuilding;
388-
// totalTime += evaluateTask([this, iROF]() { buildSpacePoints(iROF); },
389-
// StateNames[mCurState]);
390-
391-
// // Run seeding
392-
// mCurState = Seeding;
393-
// totalTime += evaluateTask([this]() { createSeeds(); },
394-
// StateNames[mCurState]);
395-
396-
// // Find tracks
397-
// mCurState = TrackFinding;
398-
// totalTime += evaluateTask([this]() { findTracks(); },
399-
// StateNames[mCurState]);
400-
// }
401413

414+
// Initialize ACTS tracking geometry
402415
auto& actsGeometryManager = o2::acts::TrackingGeometryManager::instance();
403416

404417
const auto& trackingGeometry = actsGeometryManager.get();
405-
const auto& geometryContext = actsGeometryManager.getNominalContext();
418+
if (!trackingGeometry) {
419+
LOG(error) << "ACTS tracking geometry is not available";
420+
return;
421+
}
406422

407423
auto* trkGeometry = o2::trk::GeometryTGeo::Instance();
408-
409424
trkGeometry->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
410425

411426
const auto& surfaceIndex = actsGeometryManager.getIndex(*trkGeometry, 1.e-3, [trkGeometry](int sensorID) {
412427
return std::string(trkGeometry->getMatrixPath(sensorID).Data());
413428
});
414429

430+
LOG(info) << "ACTS tracking geometry initialized with "
431+
<< surfaceIndex.size() << " mapped sensors on "
432+
<< surfaceIndex.getNSurfaces() << " surfaces";
433+
434+
// Process each ROF
435+
for (int iROF = 0; iROF < mTimeFrame->getNrof(0); ++iROF) {
436+
LOG(info) << "Processing ROF " << iROF;
437+
438+
// Build space points
439+
mCurState = SpacePointBuilding;
440+
totalTime += evaluateTask([this, iROF]() { buildSpacePoints(iROF); },
441+
StateNames[mCurState]);
442+
443+
// Run seeding
444+
mCurState = Seeding;
445+
totalTime += evaluateTask([this]() { createSeeds(); },
446+
StateNames[mCurState]);
447+
448+
// Find tracks
449+
// mCurState = TrackFinding;
450+
// totalTime += evaluateTask([this]() { findTracks(); },
451+
// StateNames[mCurState]);
452+
}
453+
415454
// MC labeling
416455
if (mTimeFrame->hasMCinformation()) {
417456
computeTracksMClabels();

0 commit comments

Comments
 (0)