FairRoot/PandaRoot
runFileSamplerBursts.cxx
Go to the documentation of this file.
1 
3 #include <csignal>
4 
6 #include "FairMQLogger.h"
7 #include "runSimpleMQStateMachine.h"
8 
9 
10 // 9-PixelDetector example
12 
13 // ////////////////////////////////////////////////////////////////////////
14 namespace po = boost::program_options;
15 
16 using channelBranches = std::vector<std::pair<std::string, std::string> >;
17 
18 namespace std {
19  static inline std::istream& operator>>(std::istream& is, std::pair<std::string, std::string>& into)
20  {
21  char ch;
22  while (is >> ch && ch!='=') into.first += ch;
23  return is >> into.second;
24  }
25 }
26 
27 
28 
29 int main(int argc, char** argv)
30 {
31  try
32  {
33  std::vector<std::string> filename;
34  channelBranches branchnames;
35  int64_t maxindex;
36 
37 
38  po::options_description sampler_options("Sampler options");
39  sampler_options.add_options()
40  ("file-name", po::value<std::vector<std::string>>(&filename) , "Path to the input file")
41  ("max-index", po::value<int64_t> (&maxindex) ->default_value(-1), "number of events to read")
42  ("branch-name", po::value<channelBranches>(&branchnames) ->multitoken() , "branch name");
43 
44 
45  FairMQProgOptions config;
46  config.AddToCmdLineOptions(sampler_options);
47 
48  config.ParseAll(argc, argv);
49 
51 
52  for ( unsigned int ielem = 0 ; ielem < filename.size() ; ielem++ ) {
53  sampler.AddInputFileName(filename.at(ielem));
54  }
55 
56  sampler.SetMaxIndex(maxindex);
57 
58  for(int i = 0; i < branchnames.size(); i++){
59  LOG(INFO) << "BranchNames: " << branchnames[i].first << "/" << branchnames[i].second;
60  sampler.AddInputChannelBranchName(branchnames[i]);
61  }
62 
63 // sampler.AddInputBranchName("EventHeader.");
64 
65  runStateMachine(sampler, config);
66 
67 
68  }
69  catch (std::exception& e)
70  {
71  LOG(ERROR) << "Unhandled Exception reached the top of main: "
72  << e.what() << ", application will now exit";
73  return 1;
74  }
75 
76  return 0;
77 }
int main(int argc, char **argv)
Int_t i
Definition: run_full.C:25
static std::istream & operator>>(std::istream &is, std::pair< std::string, std::string > &into)
void AddInputFileName(std::string tempString)
std::vector< std::pair< std::string, std::string > > channelBranches
std
static int is
Definition: ranlxd.cxx:374
void AddInputChannelBranchName(std::pair< std::string, std::string > tempString)
const string filename