gdata
Loading...
Searching...
No Matches
gTrueInfoData.h
Go to the documentation of this file.
1#pragma once
2
39#include <atomic>
40#include <map>
41#include <ostream>
42#include <string>
43#include <vector>
44
45// gemc
46#include "gbase.h"
47#include "ghit.h"
48
50constexpr const char* GTRUEDATA_LOGGER = "true_data";
51
52namespace gtrue_data {
53
65 return goptions;
66}
67
68} // namespace gtrue_data
69
103class GTrueInfoData : public GBase<GTrueInfoData>
104{
105public:
121 GTrueInfoData(const std::shared_ptr<GOptions>& gopts, const GHit* ghit);
122
138 void includeVariable(const std::string& varName, double var);
139
155 void includeVariable(const std::string& varName, std::string var);
156
170 void accumulateVariable(const std::string& vname, double value);
171
180 [[nodiscard]] inline std::map<std::string, double> getDoubleVariablesMap() const {
181 return doubleObservablesMap;
182 }
183
193 [[nodiscard]] inline std::map<std::string, std::string> getStringVariablesMap() const {
194 return stringVariablesMap;
195 }
196
217 static std::unique_ptr<GTrueInfoData> create(const std::shared_ptr<GOptions>& gopts) {
218 auto hit = GHit::create(gopts);
219 auto true_info_data = std::make_unique<GTrueInfoData>(gopts, hit);
220 auto counter = globalTrueInfoDataCounter.fetch_add(1, std::memory_order_relaxed);
221
222 true_info_data->includeVariable("totalEDeposited", counter * 0.1);
223 true_info_data->includeVariable("avgTime", counter * 1.0);
224 true_info_data->includeVariable("avgx", counter * 0.01);
225 true_info_data->includeVariable("avgy", counter * 0.02);
226 true_info_data->includeVariable("avgz", counter * 0.03);
227 true_info_data->includeVariable("hitn", counter);
228
229 return true_info_data;
230 }
231
238 [[nodiscard]] inline const std::vector<GIdentifier>& getIdentity() const { return gidentity; }
239
240private:
251 std::map<std::string, double> doubleObservablesMap;
252
259 std::map<std::string, std::string> stringVariablesMap;
260
268 std::vector<GIdentifier> gidentity;
269
276 static std::atomic<int> globalTrueInfoDataCounter;
277
278protected:
279 friend std::ostream& operator<<(std::ostream& os, const GTrueInfoData& data);
280};
static GHit * create(const std::shared_ptr< GOptions > &gopts)
Stores simulation-level observables for one hit.
void includeVariable(const std::string &varName, double var)
Stores or overwrites one numeric truth observable.
void accumulateVariable(const std::string &vname, double value)
Accumulates a numeric observable into the current object.
std::map< std::string, double > getDoubleVariablesMap() const
Returns a copy of the numeric truth observables.
const std::vector< GIdentifier > & getIdentity() const
Returns the identifier vectory.
GTrueInfoData(const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
Constructs the object and copies the hit identity from the source hit.
static std::unique_ptr< GTrueInfoData > create(const std::shared_ptr< GOptions > &gopts)
Creates deterministic example data for tests and examples.
std::map< std::string, std::string > getStringVariablesMap() const
Returns a copy of the string truth observables.
friend std::ostream & operator<<(std::ostream &os, const GTrueInfoData &data)
constexpr const char * GTRUEDATA_LOGGER
Logger domain name used by GTrueInfoData.
GOptions defineOptions()
Defines the options subtree used by the true-data logger domain.