Project
Loading...
Searching...
No Matches
VariableContextHelpers.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#ifndef O2_FRAMEWORK_DATADESCRIPTORMATCHER_H_
12#define O2_FRAMEWORK_DATADESCRIPTORMATCHER_H_
13
16#include <variant>
17
18namespace o2::framework
19{
20
23 static inline uint32_t getFirstTFOrbit(data_matcher::VariableContext const& variables)
24 {
25 // tfCounter is always at register 14
26 auto pval = std::get_if<uint32_t>(&variables.get(data_matcher::FIRSTTFORBIT_POS));
27 if (pval == nullptr) {
28 return -1;
29 }
30 return *pval;
31 }
32
34 {
35 // timeslice is always at register 0
36 auto pval = std::get_if<uint64_t>(&variables.get(data_matcher::STARTTIME_POS));
37 if (pval == nullptr) {
39 }
40 return TimesliceId{*pval};
41 }
42
43 static inline uint32_t getRunNumber(data_matcher::VariableContext const& variables)
44 {
45 // firstTForbit is always at register 15
46 auto pval = std::get_if<uint32_t>(&variables.get(data_matcher::RUNNUMBER_POS));
47 if (pval == nullptr) {
48 return -1;
49 }
50 return *pval;
51 }
52
53 static inline uint32_t getFirstTFCounter(data_matcher::VariableContext const& variables)
54 {
55 // tfCounter is always at register 14
56 auto pval = std::get_if<uint32_t>(&variables.get(data_matcher::TFCOUNTER_POS));
57 if (pval == nullptr) {
58 return -1;
59 }
60 return *pval;
61 }
62
63 static inline uint64_t getCreationTime(data_matcher::VariableContext const& variables)
64 {
65 // creation time is always at register 14
66 auto pval = std::get_if<uint64_t>(&variables.get(data_matcher::CREATIONTIME_POS));
67 if (pval == nullptr) {
68 return -1UL;
69 }
70 return *pval;
71 }
72};
73} // namespace o2::framework
74
75#endif // O2_FRAMEWORK_DATADESCRIPTORMATCHER_H_
ContextElement::Value const & get(size_t pos) const
@ CREATIONTIME_POS
The DataHeader::runNumber associated to the timeslice.
@ FIRSTTFORBIT_POS
The DataHeader::tfCounter associated to the timeslice.
@ TFCOUNTER_POS
The DataProcessingHeader::startTime associated to the timeslice.
@ RUNNUMBER_POS
The DataHeader::firstTForbit associated to the timeslice.
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
static constexpr uint64_t INVALID
Helpers to fetch common variables.
static uint32_t getRunNumber(data_matcher::VariableContext const &variables)
static uint32_t getFirstTFCounter(data_matcher::VariableContext const &variables)
static uint64_t getCreationTime(data_matcher::VariableContext const &variables)
static uint32_t getFirstTFOrbit(data_matcher::VariableContext const &variables)
static TimesliceId getTimeslice(data_matcher::VariableContext const &variables)