FairRoot/PandaRoot
runPndTopixFileSink.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 <PndMQFileSink.h>
16 #include <iostream>
17 #include <TApplication.h>
18 
19 #include "boost/program_options.hpp"
20 
21 #include "FairMQLogger.h"
22 #include "FairMQParser.h"
23 #include "FairMQProgOptions.h"
24 
25 #include "PndSdsDigiTopix4.h"
26 
27 #ifdef NANOMSG
28 #include "FairMQTransportFactoryNN.h"
29 #else
30 #include "FairMQTransportFactoryZMQ.h"
31 #endif
32 
33 using namespace boost::program_options;
34 
35 int main(int argc, char** argv)
36 {
37  PndMQFileSink sink;
38  sink.CatchSignals();
39 
40  FairMQProgOptions config;
41 
42  try
43  {
44  config.ParseAll(argc, argv);
45 
46  std::string filename = config.GetValue<std::string>("config-json-file");
47  std::string id = config.GetValue<std::string>("id");
48 
49  config.UserParser<FairMQParser::JSON>(filename, id);
50 
51  sink.fChannels = config.GetFairMQMap();
52 
53  LOG(INFO) << "PID: " << getpid();
54 
55 #ifdef NANOMSG
56  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
57 #else
58  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
59 #endif
60 
61  sink.SetTransport(transportFactory);
62 
63  sink.SetProperty(FairMQDevice::Id, id);
64 
65  sink.ChangeState("INIT_DEVICE");
66  sink.WaitForEndOfState("INIT_DEVICE");
67 
68  sink.ChangeState("INIT_TASK");
69  sink.WaitForEndOfState("INIT_TASK");
70 
71  sink.InitOutputFile(id);
72 
73  sink.ChangeState("RUN");
74  sink.InteractiveStateLoop();
75  }
76  catch (std::exception& e)
77  {
78  LOG(ERROR) << e.what();
79  LOG(INFO) << "Command line options are the following: ";
80  config.PrintHelp();
81  return 1;
82  }
83 
84  return 0;
85 }
int main(int argc, char **argv)
virtual void InitOutputFile(TString defaultId="100")
Definition: PndMQFileSink.h:88
const string filename