forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTrackMethods.h
More file actions
106 lines (99 loc) · 3.6 KB
/
TrackMethods.h
File metadata and controls
106 lines (99 loc) · 3.6 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// 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 TrackCuts.h
/// \brief Class to store some methods used in TrackCuts
/// \author antonio.palasciano@ba.infn.it
#ifndef O2_TRACK_METHODS_STUDY_H
#define O2_TRACK_METHODS_STUDY_H
#include "DataFormatsTPC/TrackTPC.h"
#include "GPUTPCGMMergedTrackHit.h"
#include "DataFormatsITS/TrackITS.h"
#include "ITSStudies/TrackCuts.h"
#include "ITSStudies/TrackMethods.h"
#include <set>
#include <vector>
namespace o2
{
namespace its
{
namespace study
{
class TrackMethods
{
public:
static void countTPCClusters(const o2::tpc::TrackTPC& track,
const gsl::span<const o2::tpc::TPCClRefElem>& tpcClusRefs,
const gsl::span<const unsigned char>& tpcClusShMap,
const o2::tpc::ClusterNativeAccess& tpcClusAcc,
uint8_t& shared, uint8_t& found, uint8_t& crossed)
{
LOGP(info, "tpcClusRefs {}/{}", (void*)tpcClusRefs.data(), tpcClusRefs.size());
LOGP(info, "tpcClusShMap {}/{}", (void*)tpcClusShMap.data(), tpcClusShMap.size());
LOGP(info, " tpcClusAcc{}/{}", (void*)tpcClusAcc.clustersLinear, tpcClusAcc.nClustersTotal);
constexpr int maxRows = 152;
constexpr int neighbour = 2;
std::array<bool, maxRows> clMap{}, shMap{};
uint8_t sectorIndex;
uint8_t rowIndex;
uint32_t clusterIndex;
shared = 0;
for (int i = 0; i < track.getNClusterReferences(); i++) {
o2::tpc::TrackTPC::getClusterReference(tpcClusRefs, i, sectorIndex, rowIndex, clusterIndex, track.getClusterRef());
unsigned int absoluteIndex = tpcClusAcc.clusterOffset[sectorIndex][rowIndex] + clusterIndex;
clMap[rowIndex] = true;
if (tpcClusShMap[absoluteIndex] & o2::gpu::GPUTPCGMMergedTrackHit::flagShared) {
if (!shMap[rowIndex]) {
shared++;
}
shMap[rowIndex] = true;
}
}
crossed = 0;
found = 0;
int last = -1;
for (int i = 0; i < maxRows; i++) {
if (clMap[i]) {
crossed++;
found++;
last = i;
} else if ((i - last) <= neighbour) {
crossed++;
} else {
int lim = std::min(i + 1 + neighbour, maxRows);
for (int j = i + 1; j < lim; j++) {
if (clMap[j]) {
crossed++;
}
}
}
}
}
static bool FulfillsITSHitRequirements(uint8_t itsClusterMap, std::vector<std::pair<int8_t, std::set<uint8_t>>> mRequiredITSHits)
{
constexpr uint8_t bit = 1;
for (auto& itsRequirement : mRequiredITSHits) {
auto hits = std::count_if(itsRequirement.second.begin(), itsRequirement.second.end(), [&](auto&& requiredLayer) { return itsClusterMap & (bit << requiredLayer); });
if ((itsRequirement.first == -1) && (hits > 0)) {
return false; // no hits were required in specified layers
} else if (hits < itsRequirement.first) {
return false; // not enough hits found in specified layers
}
}
return true;
}
private:
std::vector<std::pair<int8_t, std::set<uint8_t>>> mRequiredITSHits{};
ClassDefNV(TrackMethods, 1);
};
} // namespace study
} // namespace its
} // namespace o2
#endif