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 "glogger.h"
20
22public:
28 GTrueInfoData(const std::unique_ptr<GHit>& ghit, std::shared_ptr<GLogger> logger);
29
33 ~GTrueInfoData() { if (log) log->debug(DESTRUCTOR, "GTrueInfoData"); }
34
39 std::string getIdentityString();
40
46 void includeVariable(const std::string& varName, double var);
47
53 void includeVariable(const std::string& varName, std::string var);
54
59 [[nodiscard]] inline std::map<std::string, double> getDoubleVariablesMap() const {
60 return trueInfoDoublesVariablesMap;
61 }
62
67 [[nodiscard]] inline std::map<std::string, std::string> getStringVariablesMap() const {
68 return trueInfoStringVariablesMap;
69 }
70
71 static std::unique_ptr<GTrueInfoData> create(std::shared_ptr<GLogger> logger) {
72 auto hit = GHit::create(logger);
73 auto true_info_data = std::make_unique<GTrueInfoData>(hit, logger);
74 auto counter = globalTrueInfoDataCounter.fetch_add(1, std::memory_order_relaxed);
75
76 true_info_data->includeVariable("totalEDeposited", counter * 0.1);
77 true_info_data->includeVariable("avgTime", counter * 1.0);
78 true_info_data->includeVariable("avgx", counter * 0.01);
79 true_info_data->includeVariable("avgy", counter * 0.02);
80 true_info_data->includeVariable("avgz", counter * 0.03);
81 true_info_data->includeVariable("hitn", counter);
82
83 return true_info_data;
84 }
85
86private:
87 std::map<std::string, double> trueInfoDoublesVariablesMap;
88 std::map<std::string, std::string> trueInfoStringVariablesMap;
89 std::vector<GIdentifier> gidentity;
90 std::shared_ptr<GLogger> log;
91
93 static std::atomic<int> globalTrueInfoDataCounter;
94};
95
void includeVariable(const std::string &varName, double var)
Includes a double variable in the true hit data.
~GTrueInfoData()
Destructor for GTrueInfoData.
GTrueInfoData(const std::unique_ptr< GHit > &ghit, std::shared_ptr< GLogger > logger)
Constructs a GTrueInfoData object.
std::map< std::string, double > getDoubleVariablesMap() const
Returns the map of double variables.
static std::unique_ptr< GTrueInfoData > create(std::shared_ptr< GLogger > logger)
std::map< std::string, std::string > getStringVariablesMap() const
Returns the map of string variables.
std::string getIdentityString()
Returns a string representation of the identity.