Project
Loading...
Searching...
No Matches
ClusterLabeler.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 <map>
19
20namespace o2
21{
22namespace mid
23{
24
25void ClusterLabeler::process(gsl::span<const PreCluster> preClusters, const o2::dataformats::MCTruthContainer<MCCompLabel>& inMCContainer, gsl::span<const Cluster> clusters, gsl::span<const std::array<size_t, 2>> correlations)
26{
28 mMCContainer.clear();
29
30 std::map<size_t, std::vector<size_t>> reordered;
31 for (auto& corr : correlations) {
32 reordered[corr[0]].emplace_back(corr[1]);
33 }
34
35 for (auto& corr : reordered) {
36 for (auto& pcIdx : corr.second) {
37 int cathode = static_cast<int>(preClusters[pcIdx].cathode);
38 auto labels = inMCContainer.getLabels(pcIdx);
39 addLabels(corr.first, cathode, labels);
40 }
41 }
42}
43
44MCClusterLabel* ClusterLabeler::findLabel(size_t idx, const MCCompLabel& pcLabel)
45{
47 if (idx >= mMCContainer.getIndexedSize()) {
48 return nullptr;
49 }
50
51 for (auto& cLabel : mMCContainer.getLabels(idx)) {
52 if (pcLabel.compare(cLabel) == 1) {
53 return &cLabel;
54 }
55 }
56
57 return nullptr;
58}
59
60void ClusterLabeler::addLabels(size_t idx, int cathode, gsl::span<const MCCompLabel>& labels)
61{
63 for (auto& pcLabel : labels) {
64 MCClusterLabel* foundLabel = findLabel(idx, pcLabel);
65 if (foundLabel) {
66 if (cathode == 0) {
67 foundLabel->setIsFiredBP(true);
68 } else {
69 foundLabel->setIsFiredNBP(true);
70 }
71 } else {
72 bool isFiredBP = (cathode == 0);
73 bool isFiredNBP = (cathode == 1);
74 MCClusterLabel cLabel(pcLabel.getTrackID(), pcLabel.getEventID(), pcLabel.getSourceID(), isFiredBP, isFiredNBP);
75 mMCContainer.addElement(idx, cLabel);
76 }
77 }
78}
79
80} // namespace mid
81} // namespace o2
ClusterLabeler for MID.
int getTrackID() const
int getSourceID() const
int getEventID() const
int compare(const MCCompLabel &other) const
Definition MCCompLabel.h:85
A container to hold and manage MC truth information/labels.
gsl::span< TruthElement > getLabels(uint32_t dataindex)
void process(gsl::span< const PreCluster > preClusters, const o2::dataformats::MCTruthContainer< MCCompLabel > &inMCContainer, gsl::span< const Cluster > clusters, gsl::span< const std::array< size_t, 2 > > correlations)
std::vector< Cluster > clusters
gsl::span< const PreCluster > preClusters(preClusterizer.getPreClusters().data(), preClusterizer.getPreClusters().size())
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...