Skip to content

Commit dcccf09

Browse files
committed
GPU: Add interface to run TPC track refit without including GPU headers
1 parent 9af9cbf commit dcccf09

4 files changed

Lines changed: 116 additions & 2 deletions

File tree

GPU/GPUTracking/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ set(HDRS_INSTALL
135135

136136
# Sources only for O2
137137
if(ALIGPU_BUILD_TYPE STREQUAL "O2")
138-
set(SRCS ${SRCS} Interface/GPUO2Interface.cxx Interface/GPUO2InterfaceConfigurableParam.cxx)
139-
set(HDRS_CINT_O2 ${HDRS_CINT_O2} Interface/GPUO2Interface.h Interface/GPUO2InterfaceConfigurableParam.h dEdx/TPCdEdxCalibrationSplines.h)
138+
set(SRCS ${SRCS} Interface/GPUO2Interface.cxx Interface/GPUO2InterfaceRefit.cxx Interface/GPUO2InterfaceConfigurableParam.cxx)
139+
set(HDRS_CINT_O2 ${HDRS_CINT_O2} Interface/GPUO2Interface.h Interface/GPUO2InterfaceRefit.h Interface/GPUO2InterfaceConfigurableParam.h dEdx/TPCdEdxCalibrationSplines.h)
140140
set(HDRS_CINT_O2_ADDITIONAL Base/GPUSettings.h Base/GPUSettingsList.h) # Manual depencies for ROOT dictionary generation
141141
endif()
142142

GPU/GPUTracking/GPUTrackingLinkDef_O2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#pragma link off all functions;
1919

2020
#pragma link C++ class o2::gpu::GPUTPCO2Interface + ;
21+
#pragma link C++ class o2::gpu::GPUTPCO2InterfaceRefit + ;
2122
#pragma link C++ class o2::gpu::TPCdEdxCalibrationSplines + ;
2223
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsO2 + ;
2324
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRec + ;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
/// \file GPUO2InterfaceRefit.cxx
12+
/// \author David Rohr
13+
14+
#include "GPUO2InterfaceRefit.h"
15+
#include "DataFormatsTPC/ClusterNative.h"
16+
#include "DataFormatsTPC/TrackTPC.h"
17+
#include "GPUParam.h"
18+
#include "GPUTPCGMMergedTrackHit.h"
19+
20+
using namespace o2::gpu;
21+
using namespace o2::tpc;
22+
23+
GPUTPCO2InterfaceRefit::GPUTPCO2InterfaceRefit(const o2::tpc::ClusterNativeAccess* cl, const TPCFastTransform* trans, float bz, const TPCClRefElem* trackRef, const unsigned char* sharedmap, std::vector<o2::tpc::TrackTPC>* trks, o2::base::Propagator* p) : mRefit(), mParam(new GPUParam)
24+
{
25+
if (sharedmap == nullptr && trks == nullptr) {
26+
throw std::runtime_error("Must provide either shared cluster map or vector of tpc tracks to build the map");
27+
}
28+
if (sharedmap == nullptr) {
29+
mSharedMap.resize(cl->nClustersTotal);
30+
sharedmap = mSharedMap.data();
31+
std::fill(mSharedMap.begin(), mSharedMap.end(), 0);
32+
for (unsigned int i = 0; i < (*trks).size(); i++) {
33+
for (unsigned int j = 0; j < (*trks)[i].getNClusterReferences(); j++) {
34+
size_t idx = &(*trks)[i].getCluster(trackRef, j, *cl) - cl->clustersLinear;
35+
mSharedMap[idx] = mSharedMap[idx] ? 2 : 1;
36+
}
37+
}
38+
for (unsigned int i = 0; i < cl->nClustersTotal; i++) {
39+
mSharedMap[i] = (mSharedMap[i] > 1 ? GPUTPCGMMergedTrackHit::flagShared : 0) | cl->clustersLinear[i].getFlags();
40+
}
41+
}
42+
43+
mParam->SetDefaults(bz);
44+
mRefit.SetGPUParam(mParam.get());
45+
mRefit.SetClusterStateArray(sharedmap);
46+
mRefit.SetPropagator(p);
47+
mRefit.SetClusterNative(cl);
48+
mRefit.SetTrackHitReferences(trackRef);
49+
mRefit.SetFastTransform(trans);
50+
}
51+
52+
GPUTPCO2InterfaceRefit::~GPUTPCO2InterfaceRefit() = default;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
/// \file GPUO2InterfaceRefit.h
12+
/// \author David Rohr
13+
14+
#ifndef GPUO2INTERFACEREFIT_H
15+
#define GPUO2INTERFACEREFIT_H
16+
17+
// Some defines denoting that we are compiling for O2
18+
#ifndef HAVE_O2HEADERS
19+
#define HAVE_O2HEADERS
20+
#endif
21+
#ifndef GPUCA_TPC_GEOMETRY_O2
22+
#define GPUCA_TPC_GEOMETRY_O2
23+
#endif
24+
#ifndef GPUCA_O2_INTERFACE
25+
#define GPUCA_O2_INTERFACE
26+
#endif
27+
28+
#include "GPUTrackingRefit.h"
29+
#include <memory>
30+
#include <vector>
31+
32+
namespace o2::tpc
33+
{
34+
using TPCClRefElem = uint32_t;
35+
}
36+
37+
namespace o2::gpu
38+
{
39+
class GPUParam;
40+
class GPUTPCO2InterfaceRefit
41+
{
42+
public:
43+
// Must initialize with:
44+
// - In any case: Cluster Native access structure (cl), TPC Fast Transformation instance (trans), solenoid field (bz), TPC Track hit references (trackRef)
45+
// - Either the shared cluster map (sharedmap) or the vector of tpc tracks (trks) to build the shared cluster map internally
46+
// - o2::base::Propagator (p) in case RefitTrackAsTrackParCov is to be used
47+
48+
GPUTPCO2InterfaceRefit(const o2::tpc::ClusterNativeAccess* cl, const TPCFastTransform* trans, float bz, const o2::tpc::TPCClRefElem* trackRef, const unsigned char* sharedmap = nullptr, std::vector<o2::tpc::TrackTPC>* trks = nullptr, o2::base::Propagator* p = nullptr);
49+
~GPUTPCO2InterfaceRefit();
50+
51+
int RefitTrackAsGPU(o2::tpc::TrackTPC& trk, bool outward = false, bool resetCov = false) { return mRefit.RefitTrackAsGPU(trk, outward, resetCov); }
52+
int RefitTrackAsTrackParCov(o2::tpc::TrackTPC& trk, bool outward = false, bool resetCov = false) { return mRefit.RefitTrackAsTrackParCov(trk, outward, resetCov); }
53+
54+
private:
55+
GPUTrackingRefit mRefit;
56+
std::unique_ptr<GPUParam> mParam;
57+
std::vector<unsigned char> mSharedMap;
58+
};
59+
} // namespace o2::gpu
60+
61+
#endif

0 commit comments

Comments
 (0)