CbmRoot
CbmMQTsaSamplerTof.h
Go to the documentation of this file.
1 
8 #ifndef CBMMQTSASAMPLERTOF_H_
9 #define CBMMQTSASAMPLERTOF_H_
10 
11 
12 #include "MicrosliceDescriptor.hpp"
13 #include "StorableTimeslice.hpp"
14 #include "Timeslice.hpp"
15 #include "TimesliceSource.hpp"
16 //#include "Message.hpp"
17 
18 #include "FairMQDevice.h"
19 
20 #include <ctime>
21 #include <string>
22 #include <vector>
23 
24 class CbmMQTsaSamplerTof : public FairMQDevice {
25 public:
27  virtual ~CbmMQTsaSamplerTof();
28 
29 protected:
30  uint64_t fMaxTimeslices;
31 
32  std::string fFileName;
33  std::string fDirName;
34 
35  std::vector<std::string> fInputFileList;
36  uint64_t fFileCounter;
37  std::string fHost;
38  uint64_t fPort;
39 
40  uint64_t fTSNumber;
41  uint64_t fTSCounter;
42  uint64_t fMessageCounter;
43 
44  int fMaxMemory = 0;
45 
46  virtual void InitTask();
47  virtual bool ConditionalRun();
48 
49 private:
50  bool OpenNextFile();
51 
52  bool CheckTimeslice(const fles::Timeslice& ts);
53  void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
54  bool SendData(const fles::StorableTimeslice& component);
55  void CalcRuntime();
56  bool IsChannelNameAllowed(std::string);
57  bool IsChannelUp(std::string);
58  bool CreateAndSendComponent(const fles::Timeslice&, int);
59  bool SendData(const fles::StorableTimeslice&, int);
60  bool CreateAndCombineComponents(const fles::Timeslice&, int);
61  bool AppendData(const fles::StorableTimeslice&, int);
62  bool SendTs();
63  void SendSysCmdStop();
64 
65  fles::TimesliceSource* fSource;
66  std::chrono::steady_clock::time_point fTime;
67 
68 
69  // The vector fAllowedChannels contain the list of defined channel names
70  // which are used for connecting the different devices. For the time
71  // being the correct connection are done checking the names. A connection
72  // using the name stscomponent will receive timeslices containing the
73  // sts component only. The corresponding system ids are defined in the
74  // vector fSysId. At startup it is checked which channels are defined
75  // in the startup script such that later on only timeslices whith the
76  // corresponding data are send to the correct channels.
77  // TODO: Up to now we have three disconnected vectors which is very
78  // error prone. Find a better solution
79 
80  std::vector<std::string> fAllowedChannels = {"stscomponent",
81  "trdcomponent",
82  "tofcomponent",
83  "syscmd",
84  "syscmdin"};
85  std::vector<int> fSysId = {16, 64, 96};
86 
87  std::vector<int> fComponentsToSend = {0, 0, 0};
88  std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}};
89 };
90 
91 #endif /* CBMMQTSASAMPLERTOF_H_ */
CbmMQTsaSamplerTof::fMessageCounter
uint64_t fMessageCounter
Definition: CbmMQTsaSamplerTof.h:42
CbmMQTsaSamplerTof::fPort
uint64_t fPort
Definition: CbmMQTsaSamplerTof.h:38
CbmMQTsaSamplerTof::CbmMQTsaSamplerTof
CbmMQTsaSamplerTof()
Definition: CbmMQTsaSamplerTof.cxx:41
CbmMQTsaSamplerTof::ConditionalRun
virtual bool ConditionalRun()
Definition: CbmMQTsaSamplerTof.cxx:266
CbmMQTsaSamplerTof::SendTs
bool SendTs()
Definition: CbmMQTsaSamplerTof.cxx:440
CbmMQTsaSamplerTof
Definition: CbmMQTsaSamplerTof.h:24
CbmMQTsaSamplerTof::fComponentsToSend
std::vector< int > fComponentsToSend
Definition: CbmMQTsaSamplerTof.h:87
CbmMQTsaSamplerTof::PrintMicroSliceDescriptor
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor &mdsc)
Definition: CbmMQTsaSamplerTof.cxx:540
CbmMQTsaSamplerTof::InitTask
virtual void InitTask()
Definition: CbmMQTsaSamplerTof.cxx:56
CbmMQTsaSamplerTof::fDirName
std::string fDirName
Definition: CbmMQTsaSamplerTof.h:33
CbmMQTsaSamplerTof::SendData
bool SendData(const fles::StorableTimeslice &component)
CbmMQTsaSamplerTof::IsChannelUp
bool IsChannelUp(std::string)
Definition: CbmMQTsaSamplerTof.cxx:250
CbmMQTsaSamplerTof::fAllowedChannels
std::vector< std::string > fAllowedChannels
Definition: CbmMQTsaSamplerTof.h:80
CbmMQTsaSamplerTof::fMaxTimeslices
uint64_t fMaxTimeslices
Definition: CbmMQTsaSamplerTof.h:30
CbmMQTsaSamplerTof::fInputFileList
std::vector< std::string > fInputFileList
List of input files.
Definition: CbmMQTsaSamplerTof.h:35
CbmMQTsaSamplerTof::fSource
fles::TimesliceSource * fSource
Definition: CbmMQTsaSamplerTof.h:65
CbmMQTsaSamplerTof::fMaxMemory
int fMaxMemory
Definition: CbmMQTsaSamplerTof.h:44
CbmMQTsaSamplerTof::fChannelsToSend
std::vector< std::vector< std::string > > fChannelsToSend
Definition: CbmMQTsaSamplerTof.h:88
CbmMQTsaSamplerTof::CalcRuntime
void CalcRuntime()
Definition: CbmMQTsaSamplerTof.cxx:531
CbmMQTsaSamplerTof::fTSNumber
uint64_t fTSNumber
Definition: CbmMQTsaSamplerTof.h:40
CbmMQTsaSamplerTof::fHost
std::string fHost
Definition: CbmMQTsaSamplerTof.h:37
CbmMQTsaSamplerTof::OpenNextFile
bool OpenNextFile()
Definition: CbmMQTsaSamplerTof.cxx:199
CbmMQTsaSamplerTof::fSysId
std::vector< int > fSysId
Definition: CbmMQTsaSamplerTof.h:85
CbmMQTsaSamplerTof::CreateAndSendComponent
bool CreateAndSendComponent(const fles::Timeslice &, int)
Definition: CbmMQTsaSamplerTof.cxx:458
CbmMQTsaSamplerTof::fFileName
std::string fFileName
Definition: CbmMQTsaSamplerTof.h:32
CbmMQTsaSamplerTof::CheckTimeslice
bool CheckTimeslice(const fles::Timeslice &ts)
Definition: CbmMQTsaSamplerTof.cxx:558
CbmMQTsaSamplerTof::AppendData
bool AppendData(const fles::StorableTimeslice &, int)
Definition: CbmMQTsaSamplerTof.cxx:420
CbmMQTsaSamplerTof::~CbmMQTsaSamplerTof
virtual ~CbmMQTsaSamplerTof()
Definition: CbmMQTsaSamplerTof.cxx:529
CbmMQTsaSamplerTof::fFileCounter
uint64_t fFileCounter
Definition: CbmMQTsaSamplerTof.h:36
CbmMQTsaSamplerTof::fTime
std::chrono::steady_clock::time_point fTime
Definition: CbmMQTsaSamplerTof.h:66
CbmMQTsaSamplerTof::SendSysCmdStop
void SendSysCmdStop()
Definition: CbmMQTsaSamplerTof.cxx:587
CbmMQTsaSamplerTof::fTSCounter
uint64_t fTSCounter
Definition: CbmMQTsaSamplerTof.h:41
CbmMQTsaSamplerTof::IsChannelNameAllowed
bool IsChannelNameAllowed(std::string)
Definition: CbmMQTsaSamplerTof.cxx:224
CbmMQTsaSamplerTof::CreateAndCombineComponents
bool CreateAndCombineComponents(const fles::Timeslice &, int)
Definition: CbmMQTsaSamplerTof.cxx:386