gdata
Loading...
Searching...
No Matches
gTrueInfoData.h
Go to the documentation of this file.
1#pragma once
2
38// c++
39#include <string>
40#include <map>
41#include <vector>
42#include <atomic>
43
44// gemc
45#include "ghit.h"
46#include "gbase.h"
47
49constexpr const char* GTRUEDATA_LOGGER = "true_data";
50
51namespace gtrue_data {
69 return goptions;
70}
71} // namespace gtrue_data
72
91class GTrueInfoData : public GBase<GTrueInfoData>
92{
93public:
107 GTrueInfoData(const std::shared_ptr<GOptions>& gopts, const GHit* ghit);
108
122 [[nodiscard]] std::string getIdentityString() const;
123
140 void includeVariable(const std::string& varName, double var);
141
158 void includeVariable(const std::string& varName, std::string var);
159
173 void accumulateVariable(const std::string& vname, double value);
174
184 [[nodiscard]] inline std::map<std::string, double> getDoubleVariablesMap() const {
185 return doubleObservablesMap;
186 }
187
197 [[nodiscard]] inline std::map<std::string, std::string> getStringVariablesMap() const {
198 return stringVariablesMap;
199 }
200
216 static std::unique_ptr<GTrueInfoData> create(const std::shared_ptr<GOptions>& gopts) {
217 auto hit = GHit::create(gopts);
218 auto true_info_data = std::make_unique<GTrueInfoData>(gopts, hit);
219 auto counter = globalTrueInfoDataCounter.fetch_add(1, std::memory_order_relaxed);
220
221 true_info_data->includeVariable("totalEDeposited", counter * 0.1);
222 true_info_data->includeVariable("avgTime", counter * 1.0);
223 true_info_data->includeVariable("avgx", counter * 0.01);
224 true_info_data->includeVariable("avgy", counter * 0.02);
225 true_info_data->includeVariable("avgz", counter * 0.03);
226
227 // Stored as double by implicit conversion; useful as a simple monotonically increasing tag.
228 true_info_data->includeVariable("hitn", counter);
229
230 return true_info_data;
231 }
232
233private:
235 std::map<std::string, double> doubleObservablesMap;
236
238 std::map<std::string, std::string> stringVariablesMap;
239
241 std::vector<GIdentifier> gidentity;
242
244 static std::atomic<int> globalTrueInfoDataCounter;
245};
static GHit * create(const std::shared_ptr< GOptions > &gopts)
Container for true (simulation-level) observables for one hit.
void includeVariable(const std::string &varName, double var)
Store/overwrite a numeric "true" observable for this hit.
void accumulateVariable(const std::string &vname, double value)
Accumulate a numeric observable into this object (run-level integration).
std::map< std::string, double > getDoubleVariablesMap() const
Get a copy of all numeric truth observables.
GTrueInfoData(const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
Construct true-hit data by copying identity from a hit.
static std::unique_ptr< GTrueInfoData > create(const std::shared_ptr< GOptions > &gopts)
Test/example factory: create a true-hit object with deterministic dummy data.
std::map< std::string, std::string > getStringVariablesMap() const
Get a copy of all string truth observables.
std::string getIdentityString() const
Return a human-readable identity string for debugging and labeling.
constexpr const char * GTRUEDATA_LOGGER
Logger domain name used by GTrueInfoData (controls verbosity/category in GLogger).
GOptions defineOptions()
Defines GOptions for the true-data logger domain.