gdata
Loading...
Searching...
No Matches
gTrueInfoData.h
Go to the documentation of this file.
1#pragma once
2
11// c++
12#include <string>
13#include <map>
14#include <vector>
15#include <atomic>
16
17// gemc
18#include "ghit.h"
19#include "gbase.h"
20
21constexpr const char* GTRUEDATA_LOGGER = "true_data";
22
23namespace gtrue_data {
24inline GOptions defineOptions() {
25 auto goptions = GOptions(GTRUEDATA_LOGGER);
26 return goptions;
27}
28}
29
30
31class GTrueInfoData : public GBase<GTrueInfoData> {
32public:
38 GTrueInfoData(const std::shared_ptr<GOptions>& gopts, const GHit* ghit);
39
44 [[nodiscard]] std::string getIdentityString() const;
45
51 void includeVariable(const std::string& varName, double var);
52
58 void includeVariable(const std::string& varName, std::string var);
59
64 [[nodiscard]] inline std::map<std::string, double> getDoubleVariablesMap() const {
65 return trueInfoDoublesVariablesMap;
66 }
67
72 [[nodiscard]] inline std::map<std::string, std::string> getStringVariablesMap() const {
73 return trueInfoStringVariablesMap;
74 }
75
76 static std::unique_ptr<GTrueInfoData> create(const std::shared_ptr<GOptions>& gopts) {
77 auto hit = GHit::create(gopts);
78 auto true_info_data = std::make_unique<GTrueInfoData>(gopts, hit);
79 auto counter = globalTrueInfoDataCounter.fetch_add(1, std::memory_order_relaxed);
80
81 true_info_data->includeVariable("totalEDeposited", counter * 0.1);
82 true_info_data->includeVariable("avgTime", counter * 1.0);
83 true_info_data->includeVariable("avgx", counter * 0.01);
84 true_info_data->includeVariable("avgy", counter * 0.02);
85 true_info_data->includeVariable("avgz", counter * 0.03);
86 true_info_data->includeVariable("hitn", counter);
87
88 return true_info_data;
89 }
90
91private:
92 std::map<std::string, double> trueInfoDoublesVariablesMap;
93 std::map<std::string, std::string> trueInfoStringVariablesMap;
94 std::vector<GIdentifier> gidentity;
95
97 static std::atomic<int> globalTrueInfoDataCounter;
98};
99
void includeVariable(const std::string &varName, double var)
Includes a double variable in the true hit data.
std::map< std::string, double > getDoubleVariablesMap() const
Returns the map of double variables.
GTrueInfoData(const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
Constructs a GTrueInfoData object.
static std::unique_ptr< GTrueInfoData > create(const std::shared_ptr< GOptions > &gopts)
std::map< std::string, std::string > getStringVariablesMap() const
Returns the map of string variables.
std::string getIdentityString() const
Returns a string representation of the identity.
constexpr const char * GTRUEDATA_LOGGER
GOptions defineOptions()