FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runPixelSampler.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #include "PixelDigiBinSource.h"
10 #include "PixelDigiSource.h"
11 #include "runFairMQDevice.h"
12 
13 // PixelDetector example
14 #include "FairMQPixelSampler.h"
15 
16 #include <cstdint>
17 #include <string>
18 #include <vector>
19 
20 namespace bpo = boost::program_options;
21 
22 void addCustomOptions(bpo::options_description& options)
23 {
24  // clang-format off
25  options.add_options()
26  ("file-name", bpo::value<std::vector<std::string>>(), "Path to the input file")
27  ("max-index", bpo::value<int64_t>()->default_value(-1), "number of events to read")
28  ("branch-name", bpo::value<std::vector<std::string>>()->required(), "branch name")
29  ("sampler-type", bpo::value<std::string>()->default_value("FairFileSource"), "FairSource type")
30  ("out-channel", bpo::value<std::string>()->default_value("data-out"), "output channel name")
31  ("ack-channel", bpo::value<std::string>()->default_value(""), "ack channel name");
32  // clang-format on
33 }
34 
35 FairMQDevicePtr getDevice(const FairMQProgOptions& config)
36 {
37  std::string samplerType = config.GetValue<std::string>("sampler-type");
38  std::vector<std::string> filename = config.GetValue<std::vector<std::string>>("file-name");
39 
40  FairMQPixelSampler* sampler = new FairMQPixelSampler();
41 
42  if (samplerType == "FairFileSource") {
43  } else if (samplerType == "PixelDigiSource") {
44  if (!filename.empty()) {
45  PixelDigiSource* digiSource = new PixelDigiSource(filename.at(0));
46  sampler->SetSource(digiSource);
47  }
48  } else if (samplerType == "PixelDigiBinSource") {
49  if (!filename.empty()) {
50  PixelDigiBinSource* digiSource = new PixelDigiBinSource(filename.at(0));
51  sampler->SetSource(digiSource);
52  }
53  } else {
54  LOG(error) << "Sampler \"" << samplerType
55  << "\" unknown! Set it to \"FairFileSource\" or \"PixelDigiSource\" or \"PixelDigiBinSource\"";
56  return nullptr;
57  }
58 
59  return sampler;
60 }
void addCustomOptions(bpo::options_description &options)
FairMQDevicePtr getDevice(const FairMQProgOptions &config)