FairRoot/PandaRoot
runPndTopixSampler.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
15 #include <iostream>
16 
17 #include "boost/program_options.hpp"
18 
19 #include "FairMQLogger.h"
20 #include "FairMQParser.h"
21 #include "FairMQProgOptions.h"
22 #include "PndMQTopix4Sampler.h"
23 
24 #ifdef NANOMSG
25 #include "FairMQTransportFactoryNN.h"
26 #else
27 #include "FairMQTransportFactoryZMQ.h"
28 #endif
29 
30 using namespace boost::program_options;
31 
32 int main(int argc, char** argv)
33 {
34  PndMQTopix4Sampler sampler;
35  sampler.CatchSignals();
36 
37  FairMQProgOptions config;
38 
39  try
40  {
41  std::string text;
42  int fe;
43  double timecorr;
44 
45  options_description samplerOptions("Sampler options");
46  samplerOptions.add_options()
47  ("FileName", value<std::string>(&text)->default_value("/Users/Stockmanns/PandaSoftware/pandaRoot/pandaRoot_ActualTrunk/macro/mvd/TestBeam/2014-10-27-00-06-02--101-data--1.txt"),
48  "FileName of data to send out")
49  ("FE", value<int>(&fe)->default_value(1), "Front-End Number")
50  ("TimeCorrection", value<double>(&timecorr)->default_value(0.0),"Time offset between FE chips");
51 
52 
53  config.AddToCmdLineOptions(samplerOptions);
54 
55  config.ParseAll(argc, argv);
56 
57  std::string filename = config.GetValue<std::string>("config-json-file");
58  std::string id = config.GetValue<std::string>("id");
59 
60  config.UserParser<FairMQParser::JSON>(filename, id);
61 
62  sampler.fChannels = config.GetFairMQMap();
63 
64  LOG(INFO) << "PID: " << getpid();
65 
66 #ifdef NANOMSG
67  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
68 #else
69  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
70 #endif
71 
72  sampler.SetTransport(transportFactory);
73 
74  sampler.SetProperty(PndMQTopix4Sampler::Id, id);
76 
77  sampler.ChangeState("INIT_DEVICE");
78  sampler.WaitForEndOfState("INIT_DEVICE");
79 
80  sampler.ChangeState("INIT_TASK");
81  sampler.WaitForEndOfState("INIT_TASK");
82 
83  sampler.ChangeState("RUN");
84  sampler.InteractiveStateLoop();
85  }
86  catch (std::exception& e)
87  {
88  LOG(ERROR) << e.what();
89  LOG(INFO) << "Command line options are the following: ";
90  config.PrintHelp();
91  return 1;
92  }
93 
94  return 0;
95 }
int main(int argc, char **argv)
virtual void SetProperty(const int key, const std::string &value)
int fe
Definition: anaLmdDigi.C:67
const string filename