FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runMQGen.cxx
Go to the documentation of this file.
1 #include "runFairMQDevice.h"
2 
3 // MQRunSim
4 #include "FairBoxGenerator.h"
6 #include "FairPrimaryGenerator.h"
7 
8 #include <Rtypes.h>
9 #include <TRandom.h>
10 #include <TString.h>
11 #include <TSystem.h>
12 #include <cstdint>
13 #include <string>
14 
15 namespace bpo = boost::program_options;
16 
17 void addCustomOptions(bpo::options_description& options)
18 {
19  // clang-format off
20  options.add_options()
21  ("random-seed", bpo::value<int64_t>()->default_value(0), "Random seed number")
22  ("nof-events", bpo::value<int64_t>()->required(), "Number of events to simulate")
23  ("running-mode", bpo::value<std::string>()->default_value("pp"), "pp to push, rr to reply")
24  ("fairroot-config-dir", bpo::value<std::string>()->default_value(""), "FairRoot config dir")
25  ("chunk-size", bpo::value<int64_t>()->default_value(0), "Max nof primaries in chunk")
26  ("ack-channel", bpo::value<std::string>()->default_value(""), "Ack channel name");
27  // clang-format on
28 }
29 
30 FairMQDevicePtr getDevice(const FairMQProgOptions& config)
31 {
32  gRandom->SetSeed(config.GetValue<int64_t>("random-seed"));
33 
34  TString dir = getenv("VMCWORKDIR");
35  TString tutdir = dir + "/MQ/pixelDetector";
36 
37  TString tut_configdir = config.GetValue<std::string>("fairroot-config-dir");
38  if (tut_configdir.Length() < 1)
39  tut_configdir = dir + "/common/gconfig";
40  gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
41 
42  Int_t partPdgC[] = {211, 11, 2212}; //{"pions","eplus","proton"}
43  Int_t chosenPart = 0;
44 
46  FairBoxGenerator* boxGen = new FairBoxGenerator(partPdgC[chosenPart], 100);
47  boxGen->SetPRange(1, 2);
48  boxGen->SetThetaRange(0, 180);
49  boxGen->SetPhiRange(0, 360);
50  primGen->AddGenerator(boxGen);
51 
53  LOG(INFO) << "Going to generate " << config.GetValue<int64_t>("nof-events") << " events.";
54  mqDevice->SetChunkSize(config.GetValue<int64_t>("chunk-size"));
55  mqDevice->RunInPushMode(true);
56  if (config.GetValue<std::string>("running-mode") == "rr") {
57  LOG(INFO) << "Going to reply with data.";
58  mqDevice->RunInPushMode(false);
59  } else {
60  LOG(INFO) << "Going to push data.";
61  }
62 
63  mqDevice->SetNofEvents(config.GetValue<int64_t>("nof-events"));
64  mqDevice->SetGenerator(primGen);
65 
66  return mqDevice;
67 }
void SetGenerator(FairPrimaryGenerator *primGen)
void addCustomOptions(bpo::options_description &options)
void SetPRange(Double32_t pmin=0, Double32_t pmax=10)
void AddGenerator(FairGenerator *generator)
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
FairMQDevicePtr getDevice(const FairMQProgOptions &config)
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)