20 #include "FairParAsciiFileIo.h"
21 #include "FairParGenericSet.h"
22 #include "FairParRootFileIo.h"
23 #include "FairRuntimeDb.h"
25 #include "FairMQLogger.h"
26 #include "FairMQProgOptions.h"
29 #include "TGeoManager.h"
31 #include "TObjString.h"
37 : fRtdb(FairRuntimeDb::instance())
38 , fFirstInputName(
"first_input.root")
39 , fFirstInputType(
"ROOT")
40 , fSecondInputName(
"")
41 , fSecondInputType(
"ROOT")
44 , fChannelName(
"data") {}
47 string loadLibs = fConfig->GetValue<
string>(
"libs-to-load");
48 if (loadLibs.length() > 0) {
49 LOG(info) <<
"There are libraries to load.";
50 if (loadLibs.find(
";") != std::string::npos) {
51 LOG(info) <<
"There are several libraries to load";
52 istringstream
f(loadLibs);
54 while (getline(
f, s,
';')) {
55 LOG(info) <<
"Load library " << s;
56 gSystem->Load(s.c_str());
59 LOG(info) <<
"Load library " << loadLibs;
60 gSystem->Load(loadLibs.c_str());
63 LOG(info) <<
"There are no libraries to load.";
70 fOutputName = fConfig->GetValue<
string>(
"output-name");
71 fOutputType = fConfig->GetValue<
string>(
"output-type");
72 fChannelName = fConfig->GetValue<
string>(
"channel-name");
77 FairParRootFileIo* par1R =
new FairParRootFileIo();
79 fRtdb->setFirstInput(par1R);
81 FairParAsciiFileIo* par1A =
new FairParAsciiFileIo();
83 LOG(info) <<
"File list found!";
84 TList* parFileList =
new TList();
85 TObjString* parFile(NULL);
88 while (getline(
f, s,
';')) {
89 LOG(info) <<
"File: " << s;
90 parFile =
new TObjString(s.c_str());
91 parFileList->Add(parFile);
92 par1A->open(parFileList,
"in");
95 LOG(info) <<
"Single input file found!";
98 fRtdb->setFirstInput(par1A);
104 FairParRootFileIo* par2R =
new FairParRootFileIo();
106 fRtdb->setSecondInput(par2R);
108 FairParAsciiFileIo* par2A =
new FairParAsciiFileIo();
110 LOG(info) <<
"File list found!";
111 TList* parFileList =
new TList();
112 TObjString* parFile(NULL);
115 while (getline(
f, s,
';')) {
116 LOG(info) <<
"File: " << s;
117 parFile =
new TObjString(s.c_str());
118 parFileList->Add(parFile);
119 par2A->open(parFileList,
"in");
122 LOG(info) <<
"Single input file found!";
125 fRtdb->setSecondInput(par2A);
132 FairParRootFileIo* parOut =
new FairParRootFileIo(kTRUE);
134 fRtdb->setOutput(parOut);
144 string parameterName =
"";
145 FairParGenericSet* par =
nullptr;
148 FairMQMessagePtr req(NewMessage());
151 string reqStr(
static_cast<char*
>(req->GetData()), req->GetSize());
152 LOG(info) <<
"Received parameter request from client: \"" << reqStr
155 size_t pos = reqStr.rfind(
",");
156 string newParameterName = reqStr.substr(0,
pos);
157 int runId = stoi(reqStr.substr(
pos + 1));
158 LOG(info) <<
"Parameter name: " << newParameterName;
159 LOG(info) <<
"Run ID: " << runId;
161 LOG(info) <<
"Retrieving parameter...";
163 if (newParameterName != parameterName) {
164 parameterName = newParameterName;
165 par =
static_cast<FairParGenericSet*
>(
166 fRtdb->getContainer(parameterName.c_str()));
168 LOG(info) <<
"Retrieving parameter...Done";
170 if (-1 != runId) {
fRtdb->initContainers(runId); }
172 LOG(info) <<
"Sending following parameter to the client:";
176 TMessage* tmsg =
new TMessage(kMESS_OBJECT);
177 tmsg->WriteObject(par);
179 FairMQMessagePtr rep(NewMessage(
182 [](
void* ,
void*
object) {
183 delete static_cast<TMessage*>(object);
188 LOG(error) <<
"failed sending reply";
192 LOG(error) <<
"Parameter uninitialized!";
194 FairMQMessagePtr rep(NewMessage());
196 LOG(error) <<
"failed sending reply";
206 gGeoManager->GetListOfVolumes()->Delete();
207 gGeoManager->GetListOfShapes()->Delete();