FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runMQTrans.cxx
Go to the documentation of this file.
1 #include "runFairMQDevice.h"
2 
3 // MQRunSim
4 #include "FairCave.h"
6 #include "FairModule.h"
7 #include "FairOnlineSink.h"
8 #include "FairParAsciiFileIo.h"
9 #include "PixelDigitize.h"
10 
11 #include <TObjArray.h>
12 #include <TRandom.h>
13 #include <TString.h>
14 #include <TSystem.h>
15 #include <cstdlib>
16 #include <string>
17 #include <vector>
18 
19 namespace bpo = boost::program_options;
20 
21 void addCustomOptions(bpo::options_description& options)
22 {
23  // clang-format off
24  options.add_options()
25  ("random-seed", bpo::value<int64_t>()->default_value(0), "Random seed number")
26  ("transport-name", bpo::value<std::string>()->default_value("TGeant3"), "Transport name")
27  ("fairroot-config-dir", bpo::value<std::string>()->default_value(""), "FairRoot config dir")
28  ("param-channel-name", bpo::value<std::string>()->default_value("updateChannel"), "Parameter update channel name")
29  ("running-mode", bpo::value<std::string>()->default_value("pp"), "pp to pull, rr to request")
30  ("detector-library", bpo::value<std::vector<std::string>>(), "detector library")
31  ("run-digi-tasks", bpo::value<bool>()->default_value(false), "Run digi tasks");
32  // clang-format on
33 }
34 
35 FairMQDevicePtr getDevice(const FairMQProgOptions& config)
36 {
37  gRandom->SetSeed(config.GetValue<int64_t>("random-seed"));
38 
39  TString dir = getenv("VMCWORKDIR");
40  TString tutdir = dir + "/MQ/pixelDetector";
41 
42  TString tut_geomdir = dir + "/common/geometry";
43  gSystem->Setenv("GEOMPATH", tut_geomdir.Data());
44 
45  TString tut_configdir = config.GetValue<std::string>("fairroot-config-dir");
46  if (tut_configdir.Length() < 1)
47  tut_configdir = dir + "/common/gconfig";
48  gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
49 
51  run->RunInPullMode(true);
52  if (config.GetValue<std::string>("running-mode") == "rr") {
53  LOG(INFO) << "Going to request data.";
54  run->RunInPullMode(false);
55  } else {
56  LOG(INFO) << "Going to pull data.";
57  }
58 
59  // TString outputfilename = Form("outputfile_%d.root",(int)(getpid()));
60  // FairRootFileSink* sink = new FairRootFileSink(outputfilename);
61  FairOnlineSink* sink = new FairOnlineSink();
62  sink->SetMQRunDevice(run);
63  run->SetSink(sink);
64 
65  run->SetParamUpdateChannelName(config.GetValue<std::string>("param-channel-name"));
66 
67  run->SetTransportName(config.GetValue<std::string>("transport-name"));
68  run->SetMaterials("media.geo");
69 
70  TObjArray* detArray = new TObjArray();
71  FairModule* cave = new FairCave("CAVE");
72  cave->SetGeometryFileName("cave_vacuum.geo");
73  detArray->Add(cave);
74  // Pixel* det = new Pixel("PixelDetector", kTRUE);
75  // det->SetGeometryFileName("pixel.geo");
76  // detArray->Add(det);
77  run->SetDetectorArray(detArray);
78 
79  run->SetStoreTraj(false);
80 
81  if ((config.GetValue<bool>("run-digi-tasks")) == true) {
82  // Attach tasks if needed
83  TString digParFile = tutdir + "/param/pixel_digi.par";
84  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
85  parIo1->open(digParFile.Data(), "in");
86  run->SetFirstParameter(parIo1);
87 
88  TObjArray* taskArray = new TObjArray();
89  PixelDigitize* digiTask = new PixelDigitize();
90  taskArray->Add(digiTask);
91  run->SetTaskArray(taskArray);
92  }
93 
94  return run;
95 }
virtual void SetGeometryFileName(TString fname, TString geoVer="0")
Definition: FairModule.cxx:199
Bool_t open(const Text_t *fname, const Text_t *status="in")
void SetDetectorArray(TObjArray *array)
void addCustomOptions(bpo::options_description &options)
void RunInPullMode(bool tb=true)
void SetSink(FairSink *sink)
void SetMaterials(const std::string &str)
void SetFirstParameter(FairParIo *par)
void SetTransportName(const std::string &str)
virtual void SetMQRunDevice(FairMQRunDevice *mrs)
void SetTaskArray(TObjArray *array)
void SetStoreTraj(bool flag=true)
void SetParamUpdateChannelName(TString tString)
FairMQDevicePtr getDevice(const FairMQProgOptions &config)