gstreamer
Loading...
Searching...
No Matches
publishTrueInfo.cc
Go to the documentation of this file.
1// gstreamer
4
5// Implementation summary:
6// Write one detector true-information bank for the current event in text form.
7// Use '\n' instead of std::endl so each line does not force a flush.
8
9bool GstreamerTextFactory::publishEventTrueInfoDataImpl(const std::string& detectorName,
10 const std::vector<const GTrueInfoData*>& trueInfoData) {
11 if (!ofile.is_open()) { log->error(ERR_CANTOPENOUTPUT, SFUNCTION_NAME, "Error: can't access ", filename()); }
12
13 ofile << GTAB << "Detector <" << detectorName << "> True Info Bank {\n";
14
15 for (auto trueInfoHit : trueInfoData) {
16 auto identifierString = getIdentityString(trueInfoHit->getIdentity());
17
18 ofile << GTABTAB << "Hit address: " << identifierString << " {\n";
19
20 for (const auto& [variableName, value] : trueInfoHit->getDoubleVariablesMap()) {
21 ofile << GTABTABTAB << variableName << ": " << value << "\n";
22 }
23 for (const auto& [variableName, value] : trueInfoHit->getStringVariablesMap()) {
24 ofile << GTABTABTAB << variableName << ": " << value << "\n";
25 }
26
27 ofile << GTABTAB << "}\n";
28 }
29 ofile << GTAB << "}\n";
30
31 return true;
32}
33
34bool GstreamerTextFactory::publishEventGeneratedParticlesImpl(const std::string& bankName,
35 const GGeneratedParticleBank& particles) {
36 if (!ofile.is_open()) { log->error(ERR_CANTOPENOUTPUT, SFUNCTION_NAME, "Error: can't access ", filename()); }
37
38 ofile << GTAB << "Generated Particle Bank <" << bankName << "> {\n";
39
40 for (const auto& particle : particles) {
41 ofile << GTABTAB << "Particle {\n";
42 ofile << GTABTABTAB << "name: " << particle.name << "\n";
43 ofile << GTABTABTAB << "pid: " << particle.pid << "\n";
44 ofile << GTABTABTAB << "type: " << particle.type << "\n";
45 ofile << GTABTABTAB << "multiplicity: " << particle.multiplicity << "\n";
46 ofile << GTABTABTAB << "p: " << particle.p << "\n";
47 ofile << GTABTABTAB << "theta: " << particle.theta << "\n";
48 ofile << GTABTABTAB << "phi: " << particle.phi << "\n";
49 ofile << GTABTABTAB << "vx: " << particle.vx << "\n";
50 ofile << GTABTABTAB << "vy: " << particle.vy << "\n";
51 ofile << GTABTABTAB << "vz: " << particle.vz << "\n";
52 ofile << GTABTAB << "}\n";
53 }
54
55 ofile << GTAB << "}\n";
56 return true;
57}
std::shared_ptr< GLogger > log
void error(int exit_code, Args &&... args) const
std::vector< GGeneratedParticleData > GGeneratedParticleBank
std::string getIdentityString(std::vector< GIdentifier > gidentity)
ASCII streamer plugin declarations.
Shared constants and error codes for the gstreamer module.
#define ERR_CANTOPENOUTPUT
Output medium could not be opened successfully.
#define GTABTABTAB
#define GTAB
#define GTABTAB