Project
Loading...
Searching...
No Matches
VertexUtils.h
Go to the documentation of this file.
1// Copyright 2019-2026 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
14
15#ifndef O2_ITS_TRACKING_VERTEXUTILS_H_
16#define O2_ITS_TRACKING_VERTEXUTILS_H_
17
21
22#include <limits>
23#include <unordered_map>
24#include <utility>
25
26namespace o2::its
27{
28
31template <typename Container>
32VertexLabel computeMainVertexLabel(const Container& elements)
33{
34 // we only care about the source&event of the tracks, not the trackId
35 auto composeVtxLabel = [](const o2::MCCompLabel& lbl) -> o2::MCCompLabel {
36 return {o2::MCCompLabel::maxTrackID(), lbl.getEventID(), lbl.getSourceID(), lbl.isFake()};
37 };
38 std::unordered_map<o2::MCCompLabel, size_t> frequency;
39 for (const auto& element : elements) {
40 ++frequency[composeVtxLabel(element)];
41 }
42 o2::MCCompLabel elem{};
43 size_t maxCount = 0;
44 for (const auto& [key, count] : frequency) {
45 if (count > maxCount) {
47 elem = key;
48 }
49 }
50 if (maxCount <= 1) { // need >50%
51 elem.setFakeFlag();
52 }
53 return std::make_pair(elem, static_cast<float>(maxCount) / static_cast<float>(elements.size()));
54}
55
57{
58 Vertex diamond(trkParam.Diamond, trkParam.DiamondCov, 1, 1.f);
59 diamond.setTimeStamp({0u, std::numeric_limits<TimeStampErrorType>::max()});
60 return diamond;
61}
62
63} // namespace o2::its
64
65#endif /* O2_ITS_TRACKING_VERTEXUTILS_H_ */
atype::type element
StringRef key
static constexpr int maxTrackID()
void setFakeFlag(bool v=true)
int getEventID() const
GLint GLsizei count
Definition glcorearb.h:399
GLsizei maxCount
Definition glcorearb.h:792
std::pair< o2::MCCompLabel, float > VertexLabel
Definition Vertex.h:27
VertexLabel computeMainVertexLabel(const Container &elements)
Definition VertexUtils.h:32
Vertex makeDiamondVertex(const TrackingParameters &trkParam)
Definition VertexUtils.h:56