11 #include "CbmStsDigitizeParameters.h"
22 #include "FairMQLogger.h"
24 #include "FairMQProgOptions.h"
26 #include "FairField.h"
27 #include "FairGeoParSet.h"
28 #include "FairRunAna.h"
33 #include "TGeoManager.h"
48 #include <boost/archive/binary_iarchive.hpp>
52 using std::runtime_error::runtime_error;
70 gGeoManager->GetListOfVolumes()->Delete();
71 gGeoManager->GetListOfShapes()->Delete();
88 int noChannel = fChannels.size();
89 LOG(INFO) <<
"Number of defined channels: " << noChannel;
90 for (
auto const& entry : fChannels) {
91 LOG(INFO) <<
"Channel name: " << entry.first;
98 LOG(ERROR) << e.what();
106 std::size_t pos1 = channelName.find(entry);
107 if (pos1 != std::string::npos) {
108 const std::vector<std::string>::const_iterator
pos =
110 const std::vector<std::string>::size_type idx =
112 LOG(INFO) <<
"Found " << entry <<
" in " << channelName;
113 LOG(INFO) <<
"Channel name " << channelName
114 <<
" found in list of allowed channel names at position "
119 LOG(INFO) <<
"Channel name " << channelName
120 <<
" not found in list of allowed channel names.";
121 LOG(ERROR) <<
"Stop device.";
126 Bool_t initOK {kTRUE};
129 fRunId = fConfig->GetValue<
string>(
"run-id");
130 fvmcworkdir = fConfig->GetValue<
string>(
"vmcworkdir");
133 LOG(INFO) <<
"Init parameter containers for CbmDeviceStsLocalReco.";
138 std::string message {
"CbmStsDigitizeParameters,"};
140 LOG(INFO) <<
"Requesting parameter container CbmStsDigitizeParameters, "
144 FairMQMessagePtr req(NewSimpleMessage(message));
145 FairMQMessagePtr rep(NewMessage());
147 if (Send(req,
"parameters") > 0) {
148 if (Receive(rep,
"parameters") >= 0) {
149 if (rep->GetSize() != 0) {
151 fDigiPar =
dynamic_cast<CbmStsDigitizeParameters*
>(
152 tmsg.ReadObject(tmsg.GetClass()));
153 LOG(INFO) <<
"Received unpack parameter from parmq server: "
159 throw InitTaskError(
"Received empty reply. Parameter not available");
164 std::string message1 {
"FairGeoParSet,"};
166 LOG(INFO) <<
"Requesting parameter container FairGeoParSet, sending message: "
169 FairMQMessagePtr req1(NewSimpleMessage(message1));
170 FairMQMessagePtr rep1(NewMessage());
172 if (Send(req1,
"parameters") > 0) {
173 if (Receive(rep1,
"parameters") >= 0) {
174 if (rep1->GetSize() != 0) {
176 fGeoPar =
static_cast<FairGeoParSet*
>(tmsg.ReadObject(tmsg.GetClass()));
177 LOG(INFO) <<
"Received unpack parameter from parmq server: " <<
fGeoPar;
180 throw InitTaskError(
"No gGeoManager found in FairGeoParSet");
182 gGeoManager->Print();
185 throw InitTaskError(
"Received empty reply. Parameter not available");
190 std::string message2 {
"CbmFieldPar,"};
192 LOG(INFO) <<
"Requesting parameter container CbmFieldPar, sending message: "
195 FairMQMessagePtr req2(NewSimpleMessage(message2));
196 FairMQMessagePtr rep2(NewMessage());
198 if (Send(req2,
"parameters") > 0) {
199 if (Receive(rep2,
"parameters") >= 0) {
200 if (rep2->GetSize() != 0) {
203 LOG(info) <<
"Received unpack parameter from parmq server: " <<
fGeoPar;
208 LOG(info) <<
"Before creating the field";
210 LOG(info) <<
"After creating the field";
211 FairRunAna* run =
new FairRunAna();
212 run->SetField(field);
215 LOG(ERROR) <<
"Received empty reply. Parameter not available";
226 FairField* fMagneticField {
nullptr};
230 gSystem->Setenv(
"VMCWORKDIR",
fvmcworkdir.c_str());
246 std::stringstream ss;
247 ss <<
"Unknown field type " << fType;
250 LOG(info) <<
"New field at " << fMagneticField <<
", type " << fType;
253 if (fMagneticField) {
254 fMagneticField->Init();
255 fMagneticField->Print(
"");
258 LOG(info) <<
"Before return";
259 return fMagneticField;
272 std::string msgStr(
static_cast<char*
>(msg->GetData()), msg->GetSize());
273 std::istringstream iss(msgStr);
274 boost::archive::binary_iarchive inputArchive(iss);
279 LOG(INFO) <<
"Processed " <<
fNumMessages <<
" time slices";