CbmRoot
Loading...
Searching...
No Matches
CbmMQTsSamplerRepReq.h
Go to the documentation of this file.
1/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5/********
6 * TODO:
7 * Remove mode "Full TS spreading to multiple outputs"
8 * Keep track of components sent in split TS mode
9 * HW mark when sending independent components
10 * Use exceptions + try/catch instead of boolean return values
11 ********/
12
13#ifndef CBMMQTSSAMPLERREPREQ_H_
14#define CBMMQTSSAMPLERREPREQ_H_
15
16
17#include "MicrosliceDescriptor.hpp"
18#include "StorableTimeslice.hpp"
19#include "Timeslice.hpp"
20#include "TimesliceSource.hpp"
21
22#include "FairMQDevice.h"
23
24class TCanvas;
25class TH1F;
26class TH1I;
27class TProfile;
28#include <TObjArray.h>
29
30#include <ctime>
31#include <deque>
32#include <string>
33#include <utility>
34#include <vector>
35
36class CbmMQTsSamplerRepReq : public FairMQDevice {
37public:
39 virtual ~CbmMQTsSamplerRepReq();
40
41protected:
43
44 std::string fsFileName = "";
45 std::string fsDirName = "";
46
47 std::vector<std::string> fvsInputFileList = {};
48 std::string fsHost = "";
49 uint16_t fusPort = 0;
50 uint64_t fulHighWaterMark = 10;
51
52 std::string fsChannelNameTsRequest = "ts-request";
53 bool fbNoSplitTs = true;
54 bool fbSendTsPerSysId = false;
55 bool fbSendTsPerBlock = false;
56
57 std::string fsChannelNameHistosInput = "histogram-in";
58 uint32_t fuPublishFreqTs = 0;
59 double_t fdMinPublishTime = 0.5;
60 double_t fdMaxPublishTime = 5;
61 std::string fsHistosSuffix = "";
62
63 uint64_t fulFirstTsIndex = 0;
64 uint64_t fulPrevTsIndex = 0;
65 uint64_t fulTsCounter = 0;
66 uint64_t fulMessageCounter = 0;
67
68 virtual void InitTask();
69 bool HandleRequest(FairMQMessagePtr&, int);
70
71private:
72 void CalcRuntime();
73 bool IsChannelNameAllowed(std::string);
74
75 std::unique_ptr<fles::Timeslice> GetNewTs();
76 bool AddNewTsInBuffer();
79 bool CreateCombinedComponentsPerSysId(std::string sSystemName);
80 bool CreateCombinedComponentsPerSysId(int iSysId);
81 bool CreateCombinedComponentsPerSysId(uint uCompIndex);
83 bool CreateCombinedComponentsPerBlock(std::string sBlockName);
84
85 bool SendFirstTsIndex();
86 bool SendData(const fles::StorableTimeslice& component);
87 bool SendMissedTsIdx(std::vector<uint64_t> vIndices);
88 bool SendCommand(std::string sCommand);
89
90 bool InitHistograms();
92 bool SendHistograms();
93 bool ResetHistograms();
94
95 fles::TimesliceSource* fSource = nullptr;
96 std::chrono::steady_clock::time_point fTime;
97 std::chrono::system_clock::time_point fLastPublishTime;
98
99
100 // The vector fAllowedChannels contain the list of defined components names
101 // which are used for connecting the different devices. A request
102 // using the name stscomponent will receive timeslices containing the
103 // sts component only. The corresponding system ids are defined in the
104 // vector fSysId.
105 // The Blocks are defined by the user by combining a name with a list of components,
106 // either by name or by SysId
107 // A components can only be added to one block, attempts to double book will throw
108 // an init error
109 std::vector<std::string> fComponents = {"mvdcomponent", "stscomponent", "richcomponent", "muchcomponent",
110 "trdcomponent", "tofcomponent", "psdcomponent", "t0component"};
111 std::vector<int> fSysId = {0x20, 0x10, 0x30, 0x50, 0x40, 0x60, 0x80, 0x90};
112 std::vector<bool> fComponentActive = {false, false, false, false, false, false, false, false};
113
115 std::vector<std::vector<uint32_t>> fvvCompPerSysId = {{}, {}, {}, {}, {}, {}, {}, {}};
116
118 std::vector<std::pair<std::string, std::set<uint16_t>>> fvBlocksToSend = {};
119 std::vector<std::vector<uint32_t>> fvvCompPerBlock = {};
120
122 std::deque<std::unique_ptr<fles::Timeslice>> fdpTimesliceBuffer = {};
123 std::deque<std::vector<bool>> fdbCompSentFlags = {};
124
126 bool fbEofFound = false;
127
128 std::string fsChannelNameMissedTs = "";
129 std::string fsChannelNameCommands = "";
130
132 TObjArray fArrayHisto = {};
134 std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
138 std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
140 bool fbConfigSent = false;
141
143 TH1I* fhTsRate = nullptr;
144 TH1I* fhTsSize = nullptr;
145 TProfile* fhTsSizeEvo = nullptr;
146 TH1F* fhTsMaxSizeEvo = nullptr;
147 TH1I* fhMissedTS = nullptr;
148 TProfile* fhMissedTSEvo = nullptr;
149 TCanvas* fcSummary = nullptr;
150 uint64_t fuStartTime = 0;
151 double_t fdTimeToStart = 0.;
152 double_t fdLastMaxTime = 0.;
153 double_t fdTsMaxSize = 0.;
154};
155
156#endif /* CBMMQTSASAMPLER_H_ */
std::chrono::system_clock::time_point fLastPublishTime
std::deque< std::vector< bool > > fdbCompSentFlags
bool CreateCombinedComponentsPerBlock(std::string sBlockName)
TObjArray fArrayHisto
Array of histograms to send to the histogram server.
std::deque< std::unique_ptr< fles::Timeslice > > fdpTimesliceBuffer
Buffering of partially sent timeslices, limited by fulHighWaterMark.
std::vector< std::vector< uint32_t > > fvvCompPerSysId
bool SendMissedTsIdx(std::vector< uint64_t > vIndices)
bool IsChannelNameAllowed(std::string)
std::vector< int > fSysId
bool HandleRequest(FairMQMessagePtr &, int)
std::vector< std::string > fComponents
std::vector< bool > fComponentActive
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
bool fbConfigSent
Flag indicating whether the histograms and canvases configurations were already published.
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
std::vector< std::vector< uint32_t > > fvvCompPerBlock
bool fbEofFound
Flag indicating the EOF was reached to avoid sending an emergency STOP.
std::unique_ptr< fles::Timeslice > GetNewTs()
std::vector< std::pair< std::string, std::set< uint16_t > > > fvBlocksToSend
bool SendData(const fles::StorableTimeslice &component)
std::vector< std::string > fvsInputFileList
List of input files.
bool CreateCombinedComponentsPerSysId(std::string sSystemName)
std::chrono::steady_clock::time_point fTime
fles::TimesliceSource * fSource
bool SendCommand(std::string sCommand)