Project
Loading...
Searching...
No Matches
DataPointIdentifier.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
12/*
13 * File: DataPointIdentifier.h
14 * Author: John Lång (john.larry.lang@cern.ch)
15 *
16 * Created on 23 September 2016, 12:00
17 */
18#ifndef O2_DCS_DATAPOINT_IDENTIFIER_H
19#define O2_DCS_DATAPOINT_IDENTIFIER_H
20
21#include <cstring>
22#include <string>
23#include <cstdint>
24#include <iostream>
25#include <iomanip>
26#include <functional>
27#include <unordered_map>
28
29#include "Rtypes.h"
33
34namespace o2::dcs
35{
41{
42 uint64_t pt1;
43 uint64_t pt2;
44 uint64_t pt3;
45 uint64_t pt4;
46 uint64_t pt5;
47 uint64_t pt6;
48 uint64_t pt7;
49 uint64_t pt8; // Contains the last 6 chars of alias and the type.
50
51 public:
59 DataPointIdentifier() noexcept : pt1(0), pt2(0), pt3(0), pt4(0), pt5(0), pt6(0), pt7(0), pt8(0)
60 {
61 }
62
72 DataPointIdentifier(const std::string& alias, const DeliveryType type) noexcept : DataPointIdentifier()
73 {
74 strncpy((char*)this, alias.c_str(), 62);
75 ((char*)&pt8)[7] = type;
76 }
77
81 DataPointIdentifier(const DataPointIdentifier& src) noexcept = default;
82
84
94 static inline void FILL(
95 const DataPointIdentifier& dpid,
96 const std::string& alias,
97 const DeliveryType type) noexcept
98 {
99 strncpy((char*)&dpid, alias.c_str(), 62);
100 ((char*)&dpid.pt8)[7] = type;
101 }
102
110 static inline void FILL(
111 const DataPointIdentifier& dpid,
112 const uint64_t* const data) noexcept
113 {
114 std::strncpy((char*)&dpid, (char*)data, 62);
115 ((char*)&dpid)[63] = ((data[7] & 0xFF00000000000000) >> 56);
116 }
117
125 inline bool operator==(const DataPointIdentifier& other) const
126 {
127 constexpr char mask = 0x7F;
128
129 return (memcmp((char*)this, (char*)&other, 63) == 0) &&
130 (((DeliveryType)this->get_type() & mask) == ((DeliveryType)other.get_type() & mask));
131 }
132
139 inline bool operator!=(const DataPointIdentifier& other) const
140 {
141 return !(*this == other);
142 }
143
148 friend inline std::ostream& operator<<(std::ostream& os,
149 const DataPointIdentifier& dpid) noexcept
150 {
151 return os << std::string((char*)&dpid) << ";" << o2::dcs::show((DeliveryType)((dpid.pt8 & 0xFF00000000000000) >> 56));
152 }
153
160 inline const char* const get_alias() const noexcept
161 {
162 return (char*)&pt1;
163 }
164
170 inline DeliveryType get_type() const noexcept
171 {
172 return (DeliveryType)((pt8 & 0xFF00000000000000) >> 56);
173 }
174
182 inline size_t hash_code() const noexcept
183 {
184 return o2::dcs::hash_code(std::string((char*)&pt1));
185 }
186
190 ~DataPointIdentifier() noexcept = default;
192};
193
202struct DPIDHash {
204 const
205 {
206 return dpid.hash_code();
207 }
208};
209} // namespace o2::dcs
210
211// specailized std::hash
212namespace std
213{
214template <>
215struct hash<o2::dcs::DataPointIdentifier> {
216 std::size_t operator()(const o2::dcs::DataPointIdentifier& dpid) const
217 {
218 return std::hash<uint64_t>{}(dpid.hash_code());
219 }
220};
221} // namespace std
222
223#endif /* O2_DCS_DATAPOINT_IDENTIFIER_H */
uint32_t hash
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
ClassDefNV(DataPointIdentifier, 1)
DataPointIdentifier(const std::string &alias, const DeliveryType type) noexcept
friend std::ostream & operator<<(std::ostream &os, const DataPointIdentifier &dpid) noexcept
DeliveryType get_type() const noexcept
bool operator==(const DataPointIdentifier &other) const
static void FILL(const DataPointIdentifier &dpid, const std::string &alias, const DeliveryType type) noexcept
static void FILL(const DataPointIdentifier &dpid, const uint64_t *const data) noexcept
bool operator!=(const DataPointIdentifier &other) const
size_t hash_code() const noexcept
DataPointIdentifier(const DataPointIdentifier &src) noexcept=default
~DataPointIdentifier() noexcept=default
const char *const get_alias() const noexcept
DataPointIdentifier & operator=(const DataPointIdentifier &src) noexcept=default
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLint GLuint mask
Definition glcorearb.h:291
uint64_t hash_code(const std::string &input) noexcept
std::string show(const DeliveryType type)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint64_t operator()(const o2::dcs::DataPointIdentifier &dpid) const
std::size_t operator()(const o2::dcs::DataPointIdentifier &dpid) const
VectorOfTObjectPtrs other