CbmRoot
Loading...
Searching...
No Matches
CbmMQTsaMultiSampler.h
Go to the documentation of this file.
1/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer], Pierre-Alain Loizeau */
4
12#ifndef CBMMQTSAMULTISAMPLER_H_
13#define CBMMQTSAMULTISAMPLER_H_
14
15
16#include "MicrosliceDescriptor.hpp"
17#include "StorableTimeslice.hpp"
18#include "Timeslice.hpp"
19#include "TimesliceSource.hpp"
20
21#include "FairMQDevice.h"
22
23class TCanvas;
24class TH1F;
25class TH1I;
26class TProfile;
27#include <TObjArray.h>
28
29#include <ctime>
30#include <string>
31#include <utility>
32#include <vector>
33
34class CbmMQTsaMultiSampler : public FairMQDevice {
35public:
37 virtual ~CbmMQTsaMultiSampler();
38
39protected:
41
42 std::string fFileName;
43 std::string fDirName;
44
45 std::vector<std::string> fInputFileList;
46 uint64_t fFileCounter;
47 std::string fHost;
48 uint64_t fPort;
50
51 bool fbNoSplitTs = false;
52 bool fbSendTsPerSysId = false;
53 bool fbSendTsPerChannel = false;
54
55 std::string fsChannelNameHistosInput = "histogram-in";
56 std::string fsChannelNameHistosConfig = "histo-conf";
57 std::string fsChannelNameCanvasConfig = "canvas-conf";
58 uint32_t fuPublishFreqTs = 0;
59 double_t fdMinPublishTime = 0.5;
60 double_t fdMaxPublishTime = 5;
61
62 uint64_t fuPrevTsIndex = 0;
63 uint64_t fTSCounter;
65
66 int fMaxMemory = 0;
67
68 virtual void InitTask();
69 virtual bool ConditionalRun();
70
71private:
72 bool InitHistograms();
73 bool CheckTimeslice(const fles::Timeslice& ts);
74 void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
75 void CalcRuntime();
76 bool IsChannelNameAllowed(std::string);
77 bool CreateAndSendComponent(const fles::Timeslice&, int);
78 bool CreateAndCombineComponentsPerSysId(const fles::Timeslice&);
79 bool CreateAndCombineComponentsPerChannel(const fles::Timeslice&);
80 bool CreateAndSendFullTs(const fles::Timeslice&);
81 bool SendData(const fles::StorableTimeslice&, int);
82 bool SendData(const fles::StorableTimeslice&, std::string);
83 bool SendMissedTsIdx(std::vector<uint64_t> vIndices);
84 bool SendCommand(std::string sCommand);
85 bool SendHistograms();
86 bool ResetHistograms();
87
88 fles::TimesliceSource* fSource;
89 std::chrono::steady_clock::time_point fTime;
90 std::chrono::system_clock::time_point fLastPublishTime;
91
92
93 // The vector fAllowedChannels contain the list of defined channel names
94 // which are used for connecting the different devices. For the time
95 // being the correct connection are done checking the names. A connection
96 // using the name stscomponent will receive timeslices containing the
97 // sts component only. The corresponding system ids are defined in the
98 // vector fSysId. At startup it is checked which channels are defined
99 // in the startup script such that later on only timeslices whith the
100 // corresponding data are send to the correct channels.
101 // TODO: Up to now we have three disconnected vectors which is very
102 // error prone. Find a better solution
103
104
105 std::vector<std::string> fAllowedChannels = {"stscomponent", "richcomponent", "trdcomponent", "muchcomponent",
106 "tofcomponent", "t0component", "psdcomponent"};
107 // std::vector<int> fSysId = {16, 48, 64, 96, 144, 80};
108 std::vector<int> fSysId = {0x10, 0x30, 0x40, 0x50, 0x60, 0x90, 0x80};
109
110 std::vector<int> fComponentsToSend = {0, 0, 0, 0, 0, 0, 0};
111 std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}, {}, {}, {}, {}};
112
114 std::vector<std::vector<uint32_t>> fvvCompPerSysId = {{}, {}, {}, {}, {}, {}, {}};
115
117 std::vector<std::string> fvChannelsToSend = {};
118 std::vector<std::vector<uint32_t>> fvvCompPerChannel = {};
119
120 std::string fsChannelNameMissedTs = "";
121 std::string fsChannelNameCommands = "";
122
124 TObjArray fArrayHisto = {};
126 std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
130 std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
131
133 TH1I* fhTsRate = nullptr;
134 TH1I* fhTsSize = nullptr;
135 TProfile* fhTsSizeEvo = nullptr;
136 TH1F* fhTsMaxSizeEvo = nullptr;
137 TH1I* fhMissedTS = nullptr;
138 TProfile* fhMissedTSEvo = nullptr;
139 TCanvas* fcSummary = nullptr;
140 uint64_t fuStartTime = 0;
141 double_t fdTimeToStart = 0.;
142 double_t fdLastMaxTime = 0.;
143 double_t fdTsMaxSize = 0.;
144};
145
146#endif /* CBMMQTSASAMPLER_H_ */
std::string fsChannelNameCanvasConfig
std::vector< std::string > fAllowedChannels
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
std::chrono::steady_clock::time_point fTime
bool SendData(const fles::StorableTimeslice &, int)
std::vector< std::vector< uint32_t > > fvvCompPerChannel
std::string fsChannelNameHistosConfig
std::vector< std::vector< uint32_t > > fvvCompPerSysId
std::vector< std::string > fInputFileList
List of input files.
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor &mdsc)
bool CreateAndCombineComponentsPerChannel(const fles::Timeslice &)
bool SendMissedTsIdx(std::vector< uint64_t > vIndices)
bool IsChannelNameAllowed(std::string)
bool CheckTimeslice(const fles::Timeslice &ts)
std::vector< std::vector< std::string > > fChannelsToSend
std::vector< int > fComponentsToSend
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
bool CreateAndSendFullTs(const fles::Timeslice &)
TObjArray fArrayHisto
Array of histograms to send to the histogram server.
std::chrono::system_clock::time_point fLastPublishTime
fles::TimesliceSource * fSource
std::vector< std::string > fvChannelsToSend
bool CreateAndCombineComponentsPerSysId(const fles::Timeslice &)
std::vector< int > fSysId
bool CreateAndSendComponent(const fles::Timeslice &, int)
bool SendCommand(std::string sCommand)