Project
Loading...
Searching...
No Matches
VisualisationEventSerializer.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
16
21#include <iostream>
22#include <iomanip>
23#include <sstream>
24#include <map>
25
27{
28std::map<std::string, VisualisationEventSerializer*> VisualisationEventSerializer::instances = {
32
33std::string VisualisationEventSerializer::fileNameIndexed(const std::string fileName, const int index)
34{
35 std::stringstream buffer;
36 buffer << fileName << std::setfill('0') << std::setw(3) << index << ".json";
37 return buffer.str();
38}
39
41{
43 *((unsigned*)&(result)) = serializedValue;
44 return result;
45}
46
48{
49 unsigned result;
50 result = *((unsigned*)&(gidValue));
51 return result;
52}
53
55 VisualisationEventSerializer::deserialize(unsigned int source, unsigned int index, unsigned int flags)
56{
57 return serialize(index + source * (1 << 25) + flags * (1 << 30));
58}
59
61{
62 static std::map<std::string, int> sources = {
63 {"ITS", 0},
64 {"TPC", 1},
65 {"TRD", 2},
66 {"TOF", 3},
67 {"PHS", 4},
68 {"CPV", 5},
69 {"EMC", 6},
70 {"HMP", 7},
71 {"MFT", 8},
72 {"MCH", 9},
73 {"MID", 10},
74 {"ZDC", 11},
75 {"FT0", 12},
76 {"FV0", 13},
77 {"FDD", 14},
78 {"ITS-TPC", 15},
79 {"TPC-TOF", 16},
80 {"TPC-TRD", 17},
81 {"MFT-MCH", 18},
82 {"ITS-TPC-TRD", 19},
83 {"ITS-TPC-TOF", 20},
84 {"TPC-TRD-TOF", 21},
85 {"MFT-MCH-MID", 22},
86 {"ITS-TPC-TRD-TOF", 23}, // full barrel track
87 {"ITSAB", 24}, // ITS AfterBurner tracklets
88 {"CTP", 25}};
89 const auto first = gid.find('/');
90 int source = 0;
91 int index = 0;
92 int flags = 0;
93 if (first == -1) {
94 source = sources[gid];
95 } else {
96 const auto second = gid.find('/', first + 1);
97 source = sources[gid.substr(1, first - 1)];
98 index = std::stoi(gid.substr(first + 1, second - 1));
99 flags = std::stoi(gid.substr(second + 1, gid.size() - 1));
100 }
101 return index + source * (1 << 25) + flags * (1 << 30);
102}
103
104time_t VisualisationEventSerializer::parseDateTime(const char* datetimeString)
105{
106 std::string date(datetimeString);
107 date += " GMT";
108 const char* format = "%A %B %d %H:%M:%S %Y %Z";
109 struct tm tmStruct;
110 strptime(datetimeString, format, &tmStruct);
111 return mktime(&tmStruct);
112}
113
115{
116 char buffer[90];
117 const char* format = "%a %b %-d %H:%M:%S %Y";
118 struct tm* timeinfo = localtime(&time);
119 strftime(buffer, sizeof(buffer), format, timeinfo);
120 return buffer;
121}
122
123std::string VisualisationEventSerializer::bits(unsigned number)
124{
125 char result[33];
126 result[32] = 0;
127 unsigned mask = 1;
128 for (int i = 31; i >= 0; i--) {
129 result[i] = (mask & number) ? '1' : '0';
130 mask <<= 1;
131 }
132 return result;
133}
134
135} // namespace o2::event_visualisation
int16_t time
Definition RawEventData.h:4
int32_t i
static std::string fileNameIndexed(const std::string fileName, const int index)
static unsigned serialize(o2::dataformats::GlobalTrackID gidValue)
static o2::dataformats::GlobalTrackID deserialize(unsigned seralizedValue)
static o2::dataformats::GlobalTrackID gidFromString(const std::string &gid)
GLuint64EXT * result
Definition glcorearb.h:5662
GLuint buffer
Definition glcorearb.h:655
GLuint index
Definition glcorearb.h:781
GLsizei GLsizei GLchar * source
Definition glcorearb.h:798
GLbitfield flags
Definition glcorearb.h:1570
GLint GLuint mask
Definition glcorearb.h:291
GLsizei GLenum * sources
Definition glcorearb.h:2516
GLint GLint GLsizei GLint GLenum format
Definition glcorearb.h:275