forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualisationEventJSONSerializer.h
More file actions
66 lines (53 loc) · 2.77 KB
/
VisualisationEventJSONSerializer.h
File metadata and controls
66 lines (53 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file VisualisationEventSerializer.h
/// \author Julian Myrcha
///
#ifndef O2EVE_VISUALISATIONEVENTJSONSERIALIZER_H
#define O2EVE_VISUALISATIONEVENTJSONSERIALIZER_H
#include "EventVisualisationDataConverter/VisualisationEventSerializer.h"
#include "EventVisualisationDataConverter/VisualisationTrack.h"
#include <string>
namespace o2
{
namespace event_visualisation
{
class VisualisationEventJSONSerializer : public VisualisationEventSerializer
{
public:
const std::string serializerName() const override { return std::string("VisualisationEventJSONSerializer"); }
static int getIntOrDefault(rapidjson::Value& tree, const char* key, int defaultValue = 0);
static uint64_t getUIntOrDefault(rapidjson::Value& tree, const char* key, uint64_t defaultValue = 0);
static float getFloatOrDefault(rapidjson::Value& tree, const char* key, float defaultValue = 0.0f);
static std::string getStringOrDefault(rapidjson::Value& tree, const char* key, const char* defaultValue = "");
private:
std::string toJson(const VisualisationEvent& event) const;
void fromJson(VisualisationEvent& event, std::string json);
// create calo from their JSON representation
VisualisationCalo caloFromJSON(rapidjson::Value& tree);
// create JSON representation of the calo
rapidjson::Value jsonTree(const VisualisationCalo& calo, rapidjson::Document::AllocatorType& allocator) const;
// create cluster from their JSON representation
VisualisationCluster clusterFromJSON(rapidjson::Value& tree, const VisualisationTrack* track);
rapidjson::Value jsonTree(const VisualisationCluster& cluster, rapidjson::Document::AllocatorType& allocator, const VisualisationTrack* track) const;
// create track from their JSON representation
VisualisationTrack trackFromJSON(rapidjson::Value& tree);
// create JSON representation of the track
rapidjson::Value jsonTree(const VisualisationTrack& track, rapidjson::Document::AllocatorType& allocator) const;
public:
bool fromFile(VisualisationEvent& event, std::string fileName) override;
void toFile(const VisualisationEvent& event, Location& location) override;
~VisualisationEventJSONSerializer() override = default;
};
} // namespace event_visualisation
} // namespace o2
#endif // O2EVE_VISUALISATIONEVENTJSONSERIALIZER_H