FairRoot/PandaRoot
Functions
runHitSampler.cxx File Reference
#include <iostream>
#include "boost/program_options.hpp"
#include "FairMQLogger.h"
#include "FairMQSampler.h"
#include "FairMQParser.h"
#include "FairMQTransportFactoryZMQ.h"
#include "PndMQSdsHitLoader.h"
#include "PndSdsHit.h"
#include "FairMQProgOptions.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file runHitSampler.cxx.

References filename.

47 {
48 
49  FairMQProgOptions config;
50 
51  FairMQSampler<PndMQSdsHitLoader> sampler;
52  sampler.CatchSignals();
53 
54  try
55  {
56  std::string InputFile, ParFile, Branch;
57 
58  options_description samplerOptions("Sampler options");
59  samplerOptions.add_options()
60  ("InputFile", value<std::string>(&InputFile)->default_value(""))
61  ("ParameterFile", value<std::string>(&ParFile)->default_value(""))
62  ("Branch", value<std::string>(&Branch)->default_value(""));
63 
64  config.AddToCmdLineOptions(samplerOptions);
65 
66  config.ParseAll(argc, argv);
67 
68  std::string filename = config.GetValue<std::string>("config-json-file");
69  std::string id = config.GetValue<std::string>("id");
70 
71 
72 
73  config.UserParser<FairMQParser::JSON>(filename, id);
74  sampler.fChannels = config.GetFairMQMap();
75 
76  LOG(INFO) << "PID: " << getpid();
77 
78  #ifdef NANOMSG
79  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
80  #else
81  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
82  #endif
83 
84  sampler.SetTransport(transportFactory);
85 
86  sampler.SetProperty(FairMQDevice::Id, id);
87  sampler.SetProperty(FairMQSampler<PndMQSdsHitLoader>::InputFile, config.GetValue<string>("InputFile"));
88  sampler.SetProperty(FairMQSampler<PndMQSdsHitLoader>::ParFile, config.GetValue<string>("ParameterFile"));
89  sampler.SetProperty(FairMQSampler<PndMQSdsHitLoader>::Branch, config.GetValue<string>("Branch"));
90  //sampler.SetProperty(FairMQSampler::EventRate, options.eventRate);
91 
92  sampler.ChangeState("INIT_DEVICE");
93  sampler.WaitForEndOfState("INIT_DEVICE");
94 
95  sampler.ChangeState("INIT_TASK");
96  sampler.WaitForEndOfState("INIT_TASK");
97 
98  sampler.ChangeState("RUN");
99  sampler.InteractiveStateLoop();
100  }
101  catch (std::exception& e)
102  {
103  LOG(ERROR) << e.what();
104  LOG(INFO) << "Command line options are the following: ";
105  config.PrintHelp();
106  return 1;
107  }
108 
109  return 0;
110 }
const string filename