Skip to content

Commit c8ca8d9

Browse files
committed
GPU Workflow: Add helper class to fill GPUIOPtr from RecoContainer (ITS Clusters / Tracks, TOF Clusters / Matches)
1 parent ce1c961 commit c8ca8d9

7 files changed

Lines changed: 196 additions & 4 deletions

File tree

DataFormats/Reconstruction/include/ReconstructionDataFormats/GlobalTrackID.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class GlobalTrackID : public AbstractRef<25, 5, 2>
7171
static constexpr std::string_view NONE{"none"}; ///< keywork for no sources
7272
static constexpr std::string_view ALL{"all"}; ///< keywork for all sources
7373
#endif
74+
static constexpr mask_t MASK_ALL = (1u << NSources) - 1;
7475

7576
// methods for detector level manipulations
7677
GPUd() static constexpr DetID::mask_t getSourceDetectorsMask(int i);

DataFormats/Reconstruction/src/GlobalTrackID.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ GlobalTrackID::mask_t GlobalTrackID::getSourcesMask(const std::string_view srcLi
3535
return mask;
3636
}
3737
if (ss.find(ALL) != std::string::npos) {
38-
mask = (0x1u << NSources) - 1;
38+
mask = MASK_ALL;
3939
return mask;
4040
}
4141
std::replace(ss.begin(), ss.end(), ' ', ',');

GPU/GPUTracking/DataTypes/GPUDataTypes.h

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ namespace constants
4747
namespace o2
4848
{
4949
class MCCompLabel;
50+
template <typename T>
51+
class BaseCluster;
5052
namespace base
5153
{
5254
template <typename T>
@@ -60,11 +62,26 @@ class GeometryFlat;
6062
namespace dataformats
6163
{
6264
class TrackTPCITS;
65+
class MatchInfoTOF;
6366
template <class T>
6467
class MCTruthContainer;
6568
template <class T>
6669
class ConstMCTruthContainerView;
6770
} // namespace dataformats
71+
namespace itsmft
72+
{
73+
class CompClusterExt;
74+
class ROFRecord;
75+
class TopologyDictionary;
76+
} // namespace itsmft
77+
namespace its
78+
{
79+
class TrackITS;
80+
} // namespace its
81+
namespace tof
82+
{
83+
class Cluster;
84+
} // namespace tof
6885
} // namespace o2
6986

7087
namespace GPUCA_NAMESPACE
@@ -183,6 +200,7 @@ struct GPUCalibObjectsTemplate {
183200
typename S<TPCdEdxCalibrationSplines>::type* dEdxSplines = nullptr;
184201
typename S<TPCPadGainCalib>::type* tpcPadGain = nullptr;
185202
typename S<o2::base::PropagatorImpl<float>>::type* o2Propagator = nullptr;
203+
typename S<o2::itsmft::TopologyDictionary>::type* itsPatternDict = nullptr;
186204
};
187205
typedef GPUCalibObjectsTemplate<DefaultPtr> GPUCalibObjects; // NOTE: These 2 must have identical layout since they are memcopied
188206
typedef GPUCalibObjectsTemplate<ConstPtr> GPUCalibObjectsConst;
@@ -215,8 +233,9 @@ struct GPUTrackingInOutDigits {
215233
struct GPUTrackingInOutPointers {
216234
GPUTrackingInOutPointers() = default;
217235
GPUTrackingInOutPointers(const GPUTrackingInOutPointers&) = default;
218-
static constexpr unsigned int NSLICES = GPUDataTypes::NSLICES;
219236

237+
// TPC
238+
static constexpr unsigned int NSLICES = GPUDataTypes::NSLICES;
220239
const GPUTrackingInOutZS* tpcZS = nullptr;
221240
const GPUTrackingInOutDigits* tpcPackedDigits = nullptr;
222241
const GPUTPCClusterData* clusterData[NSLICES] = {nullptr};
@@ -245,8 +264,8 @@ struct GPUTrackingInOutPointers {
245264
unsigned int nOutputClusRefsTPCO2 = 0;
246265
const o2::MCCompLabel* outputTracksTPCO2MC = nullptr;
247266
const o2::tpc::CompressedClustersFlat* tpcCompressedClusters = nullptr;
248-
const o2::dataformats::TrackTPCITS* tracksTPCITSO2 = nullptr;
249-
unsigned int nTracksTPCITSO2 = 0;
267+
268+
// TRD
250269
const GPUTRDTrackletWord* trdTracklets = nullptr;
251270
const GPUTRDSpacePoint* trdSpacePoints = nullptr;
252271
unsigned int nTRDTracklets = 0;
@@ -255,6 +274,34 @@ struct GPUTrackingInOutPointers {
255274
const float* trdTriggerTimes = nullptr;
256275
const int* trdTrackletIdxFirst = nullptr;
257276
unsigned int nTRDTriggerRecords = 0;
277+
278+
// TOF
279+
const o2::tof::Cluster* tofClusters = nullptr;
280+
unsigned int nTOFClusters = 0;
281+
const o2::dataformats::MatchInfoTOF* tofMatches = nullptr;
282+
unsigned int nTOFMatches = 0;
283+
const o2::dataformats::MatchInfoTOF* tpctofMatches = nullptr;
284+
unsigned int nTPCTOFMatches = 0;
285+
286+
// ITS
287+
const o2::itsmft::CompClusterExt* itsCompClusters = nullptr;
288+
const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* itsClusterMC = nullptr;
289+
const o2::BaseCluster<float>* itsClusters = nullptr;
290+
unsigned int nItsClusters = 0;
291+
const o2::itsmft::ROFRecord* itsClusterROF = nullptr;
292+
unsigned int nItsClusterROF = 0;
293+
const o2::its::TrackITS* itsTracks = nullptr;
294+
const o2::MCCompLabel* itsTrackMC = nullptr;
295+
unsigned int nItsTracks = 0;
296+
const int* itsTrackClusIdx = nullptr;
297+
const o2::itsmft::ROFRecord* itsTrackROF = nullptr;
298+
unsigned int nItsTrackROF = 0;
299+
300+
// TPC-ITS
301+
const o2::dataformats::TrackTPCITS* tracksTPCITSO2 = nullptr;
302+
unsigned int nTracksTPCITSO2 = 0;
303+
304+
// Common
258305
const GPUSettingsTF* settingsTF = nullptr;
259306
};
260307
#else

GPU/Workflow/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ if(ALIGPU_BUILD_TYPE STREQUAL "O2"
5656
O2::GlobalTrackingWorkflowHelpers)
5757
target_include_directories(${targetName} PUBLIC "include")
5858
endif()
59+
60+
add_subdirectory(helper)

GPU/Workflow/helper/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
o2_add_library(GPUWorkflowHelper
12+
SOURCES src/GPUWorkflowHelper.cxx
13+
TARGETVARNAME targetName
14+
PUBLIC_LINK_LIBRARIES O2::Framework
15+
O2::DataFormatsGlobalTracking
16+
O2::GPUDataTypeHeaders
17+
O2::GPUO2Interface
18+
O2::ITStracking)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#ifndef O2_GPU_WORKFLOW_HELPER_H
12+
#define O2_GPU_WORKFLOW_HELPER_H
13+
14+
#include "ReconstructionDataFormats/GlobalTrackID.h"
15+
#include "DataFormatsGlobalTracking/RecoContainer.h"
16+
#include "GPUDataTypes.h"
17+
#include <memory>
18+
19+
namespace o2::gpu
20+
{
21+
22+
class GPUWorkflowHelper
23+
{
24+
using GID = o2::dataformats::GlobalTrackID;
25+
26+
public:
27+
struct tmpDataContainer;
28+
static std::unique_ptr<const tmpDataContainer> fillIOPtr(GPUTrackingInOutPointers& ioPtr, const o2::globaltracking::RecoContainer& recoCont, const GPUCalibObjectsConst* calib = nullptr, GID::mask_t maskCl = GID::MASK_ALL, GID::mask_t maskTrk = GID::MASK_ALL, GID::mask_t maskMatch = GID::MASK_ALL);
29+
};
30+
31+
} // namespace o2::gpu
32+
33+
#endif
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#include "GPUWorkflowHelper/GPUWorkflowHelper.h"
12+
#include "ITStracking/IOUtils.h"
13+
using namespace o2::globaltracking;
14+
using namespace o2::gpu;
15+
16+
struct GPUWorkflowHelper::tmpDataContainer {
17+
std::vector<o2::BaseCluster<float>> ITSClustersArray;
18+
};
19+
20+
std::unique_ptr<const GPUWorkflowHelper::tmpDataContainer> GPUWorkflowHelper::fillIOPtr(GPUTrackingInOutPointers& ioPtr, const o2::globaltracking::RecoContainer& recoCont, const GPUCalibObjectsConst* calib, o2::dataformats::GlobalTrackID::mask_t maskCl, o2::dataformats::GlobalTrackID::mask_t maskTrk, o2::dataformats::GlobalTrackID::mask_t maskMatch)
21+
{
22+
auto retVal = std::make_unique<tmpDataContainer>();
23+
24+
if (maskCl[GID::ITS] && ioPtr.nItsClusters == 0) {
25+
const auto& ITSClusterROFRec = recoCont.getITSClustersROFRecords<o2::itsmft::ROFRecord>();
26+
const auto& clusITS = recoCont.getITSClusters<o2::itsmft::CompClusterExt>();
27+
if (clusITS.size() && ITSClusterROFRec.size()) {
28+
if (calib && calib->itsPatternDict) {
29+
const auto& patterns = recoCont.getITSClustersPatterns();
30+
auto pattIt = patterns.begin();
31+
retVal->ITSClustersArray.reserve(clusITS.size());
32+
o2::its::ioutils::convertCompactClusters(clusITS, pattIt, retVal->ITSClustersArray, *calib->itsPatternDict);
33+
ioPtr.itsClusters = retVal->ITSClustersArray.data();
34+
}
35+
const auto& ITSClsLabels = recoCont.mcITSClusters.get();
36+
ioPtr.nItsClusters = clusITS.size();
37+
ioPtr.itsCompClusters = clusITS.data();
38+
ioPtr.nItsClusterROF = ITSClusterROFRec.size();
39+
ioPtr.itsClusterROF = ITSClusterROFRec.data();
40+
ioPtr.itsClusterMC = ITSClsLabels;
41+
}
42+
}
43+
if (maskTrk[GID::ITS] && ioPtr.nItsTracks == 0) {
44+
const auto& ITSTracksArray = recoCont.getITSTracks<o2::its::TrackITS>();
45+
const auto& ITSTrackROFRec = recoCont.getITSTracksROFRecords<o2::itsmft::ROFRecord>();
46+
if (ITSTracksArray.size() && ITSTrackROFRec.size()) {
47+
const auto& ITSTrackClusIdx = recoCont.getITSTracksClusterRefs();
48+
const auto& ITSTrkLabels = recoCont.getITSTracksMCLabels();
49+
ioPtr.nItsTracks = ITSTracksArray.size();
50+
ioPtr.itsTracks = ITSTracksArray.data();
51+
ioPtr.itsTrackClusIdx = ITSTrackClusIdx.data();
52+
ioPtr.nItsTrackROF = ITSTrackROFRec.size();
53+
ioPtr.itsTrackROF = ITSTrackROFRec.data();
54+
ioPtr.itsTrackMC = ITSTrkLabels.data();
55+
}
56+
}
57+
58+
if (maskTrk[GID::ITSTPC] && ioPtr.nTracksTPCITSO2 == 0) {
59+
const auto& trkITSTPC = recoCont.getTPCITSTracks<o2d::TrackTPCITS>();
60+
if (trkITSTPC.size()) {
61+
ioPtr.nTracksTPCITSO2 = trkITSTPC.size();
62+
ioPtr.tracksTPCITS = trkITSTPC.data();
63+
}
64+
}
65+
66+
if (maskCl[GID::TOF] && ioPtr.nTOFClusters == 0) {
67+
const auto& tofClusters = recoCont.getTOFClusters<o2::tof::Cluster>();
68+
if (tofClusters.size()) {
69+
ioPtr.nTOFClusters = tofClusters.size();
70+
ioPtr.tofClusters = tofClusters.data();
71+
}
72+
}
73+
74+
if (maskMatch[GID::TOF] && ioPtr.nTOFMatches == 0) {
75+
const auto& tofMatches = recoCont.getTOFMatches<o2::dataformats::MatchInfoTOF>();
76+
if (tofMatches.size()) {
77+
ioPtr.nTOFMatches = tofMatches.size();
78+
ioPtr.tofMatches = tofMatches.data();
79+
}
80+
}
81+
82+
if (maskMatch[GID::TPCTOF] && ioPtr.nTPCTOFMatches == 0) {
83+
const auto& tpctofMatches = recoCont.getTPCTOFMatches<o2::dataformats::MatchInfoTOF>();
84+
if (tpctofMatches.size()) {
85+
ioPtr.nTPCTOFMatches = tpctofMatches.size();
86+
ioPtr.tpctofMatches = tpctofMatches.data();
87+
}
88+
}
89+
90+
return std::move(retVal);
91+
}

0 commit comments

Comments
 (0)