/******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * PndMQSdsHitLoaderhis software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** * runPndMQSdsHitLoaderestDetectorSamplerBin.cxx * * @since 2013-04-29 * @author A. Rybalchenko, N. Winckler */ #include #include "boost/program_options.hpp" #include "FairMQLogger.h" #include "FairMQSampler.h" #include "FairMQParser.h" #ifdef NANOMSG #include "FairMQTransportFactoryNN.h" #else #include "FairMQTransportFactoryZMQ.h" #endif // data format for the task #include "PndMQSdsHitLoader.h" #include "PndSdsHit.h" #include "FairMQProgOptions.h" #include "FairMQSampler.h" // boost data format #include #include using namespace std; using namespace boost::program_options; int main(int argc, char** argv) { FairMQProgOptions config; FairMQSampler sampler; sampler.CatchSignals(); try { std::string InputFile, ParFile, Branch; options_description samplerOptions("Sampler options"); samplerOptions.add_options() ("InputFile", value(&InputFile)->default_value("")) ("ParameterFile", value(&ParFile)->default_value("")) ("Branch", value(&Branch)->default_value("")); config.AddToCmdLineOptions(samplerOptions); config.ParseAll(argc, argv); std::string filename = config.GetValue("config-json-file"); std::string id = config.GetValue("id"); config.UserParser(filename, id); sampler.fChannels = config.GetFairMQMap(); LOG(INFO) << "PID: " << getpid(); #ifdef NANOMSG FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); #else FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); #endif sampler.SetTransport(transportFactory); sampler.SetProperty(FairMQDevice::Id, id); sampler.SetProperty(FairMQSampler::InputFile, config.GetValue("InputFile")); sampler.SetProperty(FairMQSampler::ParFile, config.GetValue("ParameterFile")); sampler.SetProperty(FairMQSampler::Branch, config.GetValue("Branch")); //sampler.SetProperty(FairMQSampler::EventRate, options.eventRate); sampler.ChangeState("INIT_DEVICE"); sampler.WaitForEndOfState("INIT_DEVICE"); sampler.ChangeState("INIT_TASK"); sampler.WaitForEndOfState("INIT_TASK"); sampler.ChangeState("RUN"); sampler.InteractiveStateLoop(); } catch (std::exception& e) { LOG(ERROR) << e.what(); LOG(INFO) << "Command line options are the following: "; config.PrintHelp(); return 1; } return 0; }