Project
Loading...
Searching...
No Matches
O2SimDevice.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
14#ifndef ALICEO2_DEVICES_SIMDEVICE_H_
15#define ALICEO2_DEVICES_SIMDEVICE_H_
16
17#include <memory>
18#include <string>
19#include <fairmq/Device.h>
20#include <FairRunSim.h>
21#include <TStopwatch.h>
22#include "PrimaryServerState.h"
23
24class TVirtualMC;
25
26namespace o2::steer
27{
28class O2MCApplication;
29}
30
31// a helper for logging with worker index prefixed
32void doLogInfo(int workerID, std::string const& message);
33
34namespace o2
35{
36namespace devices
37{
38
39// device representing a simulation worker
40class O2SimDevice final : public fair::mq::Device
41{
42 public:
43 O2SimDevice() = default;
44 O2SimDevice(o2::steer::O2MCApplication* vmcapp, TVirtualMC* vmc) : mVMCApp{vmcapp}, mVMC{vmc} {}
45
47 ~O2SimDevice() final;
48
51 void InitTask() final;
52
53 public:
54 void lateInit();
55
56 // initializes the simulation classes; queries the configuration on a given channel
57 static bool initSim(fair::mq::Channel& channel, std::unique_ptr<FairRunSim>& simptr);
58
59 bool isWorkAvailable(fair::mq::Channel& statuschannel, int workerID = -1);
60
61 bool Kernel(int workerID, fair::mq::Channel& requestchannel, fair::mq::Channel& dataoutchannel, fair::mq::Channel* statuschannel = nullptr);
62
65 bool ConditionalRun() final;
66
67 void PostRun() final;
68
69 private:
70 TStopwatch mTimer;
71 o2::steer::O2MCApplication* mVMCApp = nullptr;
72 TVirtualMC* mVMC = nullptr;
73 std::unique_ptr<FairRunSim> mSimRun;
74};
75
76} // namespace devices
77} // namespace o2
78
79#endif
void doLogInfo(int workerID, std::string const &message)
#define protected
static bool initSim(fair::mq::Channel &channel, std::unique_ptr< FairRunSim > &simptr)
~O2SimDevice() final
Default destructor.
O2SimDevice(o2::steer::O2MCApplication *vmcapp, TVirtualMC *vmc)
Definition O2SimDevice.h:44
bool isWorkAvailable(fair::mq::Channel &statuschannel, int workerID=-1)
void InitTask() final
Overloads the InitTask() method of fair::mq::Device.
bool ConditionalRun() final
Overloads the ConditionalRun() method of fair::mq::Device.
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
Definition ASoA.h:45
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...