forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPUO2InterfaceRefit.cxx
More file actions
71 lines (63 loc) · 3.64 KB
/
GPUO2InterfaceRefit.cxx
File metadata and controls
71 lines (63 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUO2InterfaceRefit.cxx
/// \author David Rohr
#include "GPUO2InterfaceRefit.h"
#include "DataFormatsTPC/ClusterNative.h"
#include "DataFormatsTPC/TrackTPC.h"
#include "GPUParam.h"
#include "GPUTPCGMMergedTrackHit.h"
#include "GPUTrackingRefit.h"
using namespace o2::gpu;
using namespace o2::tpc;
void GPUO2InterfaceRefit::fillSharedClustersMap(const ClusterNativeAccess* cl, const gsl::span<const TrackTPC> trks, const TPCClRefElem* trackRef, unsigned char* shmap)
{
if (!cl || !shmap) {
throw std::runtime_error("Must provide clusters access and preallocated recepient for shared map");
}
memset(shmap, 0, sizeof(char) * cl->nClustersTotal);
for (unsigned int i = 0; i < trks.size(); i++) {
for (unsigned int j = 0; j < trks[i].getNClusterReferences(); j++) {
size_t idx = &trks[i].getCluster(trackRef, j, *cl) - cl->clustersLinear;
shmap[idx] = shmap[idx] ? 2 : 1;
}
}
for (unsigned int i = 0; i < cl->nClustersTotal; i++) {
shmap[i] = (shmap[i] > 1 ? GPUTPCGMMergedTrackHit::flagShared : 0) | cl->clustersLinear[i].getFlags();
}
}
GPUO2InterfaceRefit::GPUO2InterfaceRefit(const ClusterNativeAccess* cl, const TPCFastTransform* trans, float bz, const TPCClRefElem* trackRef, const unsigned char* sharedmap, const std::vector<TrackTPC>* trks, o2::base::Propagator* p) : mParam(new GPUParam)
{
if (sharedmap == nullptr && trks == nullptr) {
throw std::runtime_error("Must provide either shared cluster map or vector of tpc tracks to build the map");
}
if (sharedmap == nullptr) {
mSharedMap.resize(cl->nClustersTotal);
sharedmap = mSharedMap.data();
fillSharedClustersMap(cl, *trks, trackRef, mSharedMap.data());
}
mRefit = std::make_unique<GPUTrackingRefit>();
mParam->SetDefaults(bz);
mRefit->SetGPUParam(mParam.get());
mRefit->SetClusterStateArray(sharedmap);
mRefit->SetPropagator(p);
mRefit->SetClusterNative(cl);
mRefit->SetTrackHitReferences(trackRef);
mRefit->SetFastTransform(trans);
}
int GPUO2InterfaceRefit::RefitTrackAsGPU(o2::tpc::TrackTPC& trk, bool outward, bool resetCov) { return mRefit->RefitTrackAsGPU(trk, outward, resetCov); }
int GPUO2InterfaceRefit::RefitTrackAsTrackParCov(o2::tpc::TrackTPC& trk, bool outward, bool resetCov) { return mRefit->RefitTrackAsTrackParCov(trk, outward, resetCov); }
int GPUO2InterfaceRefit::RefitTrackAsGPU(o2::track::TrackParCov& trk, const o2::tpc::TrackTPCClusRef& clusRef, float time0, float* chi2, bool outward, bool resetCov) { return mRefit->RefitTrackAsGPU(trk, clusRef, time0, chi2, outward, resetCov); }
int GPUO2InterfaceRefit::RefitTrackAsTrackParCov(o2::track::TrackParCov& trk, const o2::tpc::TrackTPCClusRef& clusRef, float time0, float* chi2, bool outward, bool resetCov) { return mRefit->RefitTrackAsTrackParCov(trk, clusRef, time0, chi2, outward, resetCov); }
void GPUO2InterfaceRefit::setIgnoreErrorsAtTrackEnds(bool v) { mRefit->mIgnoreErrorsOnTrackEnds = v; }
void GPUO2InterfaceRefit::setGPUTrackFitInProjections(bool v) { mParam->rec.fitInProjections = v; }
void GPUO2InterfaceRefit::setTrackReferenceX(float v) { mParam->rec.tpc.trackReferenceX = v; }
GPUO2InterfaceRefit::~GPUO2InterfaceRefit() = default;