23 #include <FairMQDevice.h>
24 #include <FairMQLogger.h>
25 #include <TCollection.h>
27 #include <TObjArray.h>
35 , fUpdateChannelName(
"updateChannel")
36 , fRunInitialized(false)
39 , fTransportName(
"TGeant3")
41 , fMagneticField(nullptr)
42 , fDetectorArray(nullptr)
43 , fPrimaryGenerator(nullptr)
44 , fStoreTrajFlag(false)
46 , fFirstParameter(nullptr)
47 , fSecondParameter(nullptr)
57 if (fFirstParameter || fSecondParameter) {
65 fRunSim->SetName(fTransportName.data());
69 if (fUserConfig.Length() > 0)
71 if (fUserCuts.Length() > 0)
82 for (
int idet = 0; idet < fDetectorArray->GetEntries(); idet++) {
93 std::string* askForRunNumber =
new string(
"ReportSimDevice");
94 FairMQMessagePtr req(NewMessage(
95 const_cast<char*>(askForRunNumber->c_str()),
96 askForRunNumber->length(),
97 [](
void* ,
void* object) {
delete static_cast<string*
>(object); },
99 FairMQMessagePtr rep(NewMessage());
101 unsigned int runId = 0;
102 if (Send(req, fUpdateChannelName) > 0) {
103 if (Receive(rep, fUpdateChannelName) > 0) {
104 std::string repString = string(static_cast<char*>(rep->GetData()), rep->GetSize());
105 LOG(info) <<
" -> " << repString.data();
106 runId = stoi(repString);
107 repString = repString.substr(repString.find_first_of(
'_') + 1, repString.length());
108 fSimDeviceId = stoi(repString);
109 LOG(info) <<
"runId = " << runId <<
" /// fSimDeviceId = " << fSimDeviceId;
113 if (fPrimaryGenerator) {
123 for (
int itask = 0; itask < fTaskArray->GetEntries(); itask++) {
132 fRunInitialized =
true;
137 if (!fRunInitialized) {
144 if (fSimDeviceId == 0)
145 UpdateParameterServer();
146 fRunSim->
Run(fNofEvents);
150 void FairMQSimDevice::UpdateParameterServer()
154 printf(
"FairMQSimDevice::UpdateParameterServer() (%d containers)\n", rtdb->
getListOfContainers()->GetEntries());
159 while ((cont = static_cast<FairParSet*>(next()))) {
160 std::string ridString = std::string(
"RUNID") + std::to_string(fRunSim->
GetRunId()) + std::string(
"RUNID")
161 + std::string(cont->getDescription());
166 printf(
"FairMQSimDevice::UpdateParameterServer() finished\n");
171 if (NewStatePending()) {
list of container factories
void SetField(FairField *field)
virtual bool ConditionalRun()
Bool_t setSecondInput(FairParIo *)
void SetRunId(UInt_t runId)
void SetGenerator(FairPrimaryGenerator *Gen)
void SetSink(FairSink *tempSink)
TList * getListOfContainers()
void SendObject(TObject *obj, const std::string &chan)
void SetIsMT(Bool_t isMT)
virtual void SendBranches()
virtual void SendBranches()
void SetEventNr(Int_t evtNr)
void SetUserCuts(const TString &Cuts)
FairRuntimeDb * GetRuntimeDb(void)
void SetMaterials(const char *MatFileName)
void SetUserConfig(const TString &Config)
virtual void AddTask(FairTask *t)
virtual void Run(Int_t NEvents=0, Int_t NotUsed=0)
void AddModule(FairModule *Mod)
Bool_t setFirstInput(FairParIo *)
void setDescription(const char *s)
void SetStoreTraj(Bool_t storeTraj=kTRUE)