gdata
Loading...
Searching...
No Matches
gframe_example.cc
Go to the documentation of this file.
1
42// gdata
44#include "frame/gFrameHeader.h"
46
47// gemc
48#include "glogger.h"
49#include <gtouchable_options.h>
50
51// c++
52#include <iostream>
53#include <vector>
54#include <string>
55
56using namespace std;
57
58// TODO: Run this in multiple threads and collect results into frames (similar to a runAction-style aggregator).
59int main(int argc, char* argv[]) {
60 auto gopts = std::make_shared<GOptions>(argc, argv, gevent_data::defineOptions());
61
62 auto log = std::make_shared<GLogger>(gopts, SFUNCTION_NAME, GEVENTDATA_LOGGER);
63 auto logt = std::make_shared<GLogger>(gopts, SFUNCTION_NAME, TOUCHABLE_LOGGER);
64
65 long int frameID = 1;
66 double frameDuration = 33.33; // Example frame duration (units could be ms or other)
67
68 auto frameHeader = new GFrameHeader(frameID, frameDuration, log);
69 auto frameData = new GFrameDataCollection(frameHeader, log);
70
71 vector<int> payload1 = {1, 2, 3, 100, 50};
72 vector<int> payload2 = {4, 5, 6, 200, 75};
73 vector<int> payload3 = {7, 8, 9, 150, 60};
74
75 frameData->addIntegralPayload(payload1);
76 frameData->addIntegralPayload(payload2);
77 frameData->addIntegralPayload(payload3);
78
79 cout << "Frame ID: " << frameData->getFrameID() << endl;
80 cout << "Frame Header Time: " << frameData->getHeader()->getTime() << endl;
81
82 const vector<GIntegralPayload*>* payloads = frameData->getIntegralPayload();
83 cout << "Number of integral payloads: " << payloads->size() << endl;
84
85 for (size_t i = 0; i < payloads->size(); ++i) {
86 vector<int> p = (*payloads)[i]->getPayload();
87 cout << "Payload " << (i + 1) << ": ";
88 for (auto v : p) {
89 cout << v << " ";
90 }
91 cout << endl;
92 }
93
94 delete frameData; // deletes header and all payloads inside
95
96 return EXIT_SUCCESS;
97}
98
Defines GEventDataCollection, event-level aggregation of per-detector hit data.
constexpr const char * GEVENTDATA_LOGGER
Defines GFrameDataCollection, a container for frame-level integrated payloads.
Defines the GFrameHeader class, a minimal header describing a "frame".
#define SFUNCTION_NAME
constexpr const char * TOUCHABLE_LOGGER
auto defineOptions() -> GOptions
Aggregated options for event-level data collection.
int main(int argc, char *argv[])