Project
Loading...
Searching...
No Matches
VtxTrackRef.h
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
15
16#ifndef O2_VERTEX_TRACK_REF
17#define O2_VERTEX_TRACK_REF
18
21#include <cassert>
22#include <array>
23#include <iosfwd>
24#include <string>
25
26namespace o2
27{
28namespace dataformats
29{
30
31/* Class to refer in start and number of contributors in the container of with consecutively filled conributors.
32 The contributors are suppossed to be sorted according to their sources.
33 Note: the only way to fill the references is to fill them all in increasing order and set the end!
34 VtxTrackIndex ref;
35 for (int i=0;i<VtxTrackIndex::Source::NSources;i++) {
36 ref.setFirstEntryOfSource(i, idxI); // idxI must be >= idxI-1 (if it is =, then source i has not entries
37 }
38 ref.setEnd(idxLast + 1); // i.e. idxLast+1 = idx0 + TotalNumberOfEntries
39 */
40
41class VtxTrackRef : public RangeReference<int, int>
42{
43 public:
45 {
46 for (int i = VtxTrackIndex::Source::NSources - 1; i--;) {
47 mFirstEntrySource[i] = -1; // only 1st source (base reference) is filled at constructor level
48 }
49 }
50
51 void print(bool skipEmpty = true) const;
52 std::string asString(bool skipEmpty = true) const;
53
54 // get 1st of entry of indices for given source
55 int getFirstEntryOfSource(int s) const
56 {
57 assert(s >= 0 && s < VtxTrackIndex::NSources);
58 return s ? mFirstEntrySource[s - 1] : getFirstEntry();
59 }
60
61 // get number of entries for given source
62 int getEntriesOfSource(int s) const
63 {
64 return (s == VtxTrackIndex::NSources - 1 ? (getFirstEntry() + getEntries()) : getFirstEntryOfSource(s + 1)) - getFirstEntryOfSource(s);
65 }
66
67 void setFirstEntryOfSource(int s, int i)
68 {
69 assert(s >= 0 && s < VtxTrackIndex::NSources);
70 if (s) {
71 mFirstEntrySource[s - 1] = i;
72 } else {
73 setFirstEntry(i);
74 }
75 }
76
77 void setVtxID(int i) { mVtxID = i; }
78 int getVtxID() const { return mVtxID; }
79
80 // set the last +1 element index and finalize all references
81 void setEnd(int end);
82
83 private:
84 using RangeReference<int, int>::RangeReference;
85 int mVtxID = -1; // vertex ID. The reference for unassigned tracks will have it negative!
86 std::array<int, VtxTrackIndex::Source::NSources - 1> mFirstEntrySource{0};
87
88 ClassDefNV(VtxTrackRef, 2);
89};
90
91std::ostream& operator<<(std::ostream& os, const o2::dataformats::VtxTrackRef& v);
92
93} // namespace dataformats
94} // namespace o2
95
96#endif
void print() const
int32_t i
Class to refer to the 1st entry and N elements of some group in the continuous container.
Extention of GlobalTrackID by flags relevant for verter-track association.
void setFirstEntryOfSource(int s, int i)
Definition VtxTrackRef.h:67
std::string asString(bool skipEmpty=true) const
int getEntriesOfSource(int s) const
Definition VtxTrackRef.h:62
int getFirstEntryOfSource(int s) const
Definition VtxTrackRef.h:55
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
std::ostream & operator<<(std::ostream &os, const o2::dataformats::MeanVertexObject &o)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...