Project
Loading...
Searching...
No Matches
TrackLabeler.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
17
18#include <unordered_map>
19
20namespace o2
21{
22namespace mid
23{
24
25bool TrackLabeler::areBothSidesFired(const gsl::span<const MCClusterLabel>& labels) const
26{
28 bool isFiredBP = false, isFiredNBP = false;
29 for (auto& label : labels) {
30 if (label.isFiredBP()) {
31 isFiredBP = true;
32 }
33 if (label.isFiredNBP()) {
34 isFiredNBP = true;
35 }
36 }
37 return isFiredBP && isFiredNBP;
38}
39
40MCCompLabel TrackLabeler::makeTrackLabel(const Track& track, const o2::dataformats::MCTruthContainer<MCClusterLabel>& inMCContainer) const
41{
43 std::unordered_map<MCCompLabel, int> allLabels;
44 for (int ich = 0; ich < 4; ++ich) {
45 auto icl = track.getClusterMatched(ich);
46 if (icl < 0) {
47 continue;
48 }
49
50 auto clLabels = inMCContainer.getLabels(icl);
51
52 // First check if the BP and NBP were ever fired by a track
53 // If they are, it means that the chamber was efficient
54 bool bothFired = areBothSidesFired(clLabels);
55
56 for (auto& label : clLabels) {
57 // This track fired only one cathode
58 bool oneFired = (!label.isFiredBP() || !label.isFiredNBP());
59 if (bothFired && oneFired) {
60 // This condition means that the cluster was made from
61 // a track in the BP and a different track in the NBP.
62 // This happens when we have two tracks in the same column.
63 // This means that the cluster is a fake one, so we discard it
64 continue;
65 }
66 ++allLabels[label];
67 }
68 }
69
70 MCCompLabel outLabel;
71 int nMatched = 0;
72 for (auto& item : allLabels) {
73 if (item.second > nMatched) {
74 nMatched = item.second;
75 outLabel = item.first;
76 }
77 }
78
79 if (nMatched < 3) {
80 outLabel.setFakeFlag();
81 }
82
83 return outLabel;
84}
85
86void TrackLabeler::process(gsl::span<const Cluster> clusters, gsl::span<const Track> tracks, const o2::dataformats::MCTruthContainer<MCClusterLabel>& inMCContainer)
87{
89 mMCTracksLabels.clear();
90
91 for (auto& track : tracks) {
92 mMCTracksLabels.emplace_back(makeTrackLabel(track, inMCContainer));
93 }
94
95 // For the moment we store all clusters
96 // This can change if we decide to store only associated clusters
97 mMCTrackClustersLabels.clear();
98 mMCTrackClustersLabels.mergeAtBack(inMCContainer);
99}
100} // namespace mid
101} // namespace o2
Tracks labeler for MID.
A container to hold and manage MC truth information/labels.
gsl::span< TruthElement > getLabels(uint32_t dataindex)
void process(gsl::span< const Cluster > clusters, gsl::span< const Track > tracks, const o2::dataformats::MCTruthContainer< MCClusterLabel > &inMCContainer)
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
std::vector< Cluster > clusters
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...