CbmRoot
Loading...
Searching...
No Matches
CbmDeviceDigiEventSink.h
Go to the documentation of this file.
1/* Copyright (C) 2020-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
12#ifndef CBMDEVICEDIGIEVTSINK_H_
13#define CBMDEVICEDIGIEVTSINK_H_
14
16#include "CbmBmonDigi.h"
17#include "CbmDigiEvent.h"
18#include "CbmEvent.h"
19#include "CbmMqTMessage.h"
20#include "CbmMuchDigi.h"
21#include "CbmPsdDigi.h"
22#include "CbmRichDigi.h"
23#include "CbmStsDigi.h"
24#include "CbmTofDigi.h"
25#include "CbmTrdDigi.h"
26#include "CbmTsEventHeader.h"
27
28#include "TimesliceMetaData.h"
29
31#include "FairMQDevice.h"
32
34#include "Rtypes.h"
35#include "TClonesArray.h"
36#include "TObjArray.h"
37
39#include <chrono>
40#include <map>
41#include <vector>
42
43class TCanvas;
44class TFile;
45class TH1;
46class TProfile;
47class TList;
48class TClonesArray;
49//class TimesliceMetaData;
50class FairRunOnline;
51class FairRootManager;
52
55public:
56 CbmEventTimeslice(FairMQParts& parts, bool bDigiEvtInput = false);
58
59 void ExtractSelectedData(bool bExclusiveTrdExtract = true);
60 std::vector<CbmDigiEvent>& GetSelectedData(bool bExclusiveTrdExtract = true)
61 {
62 if (!fbDigiEvtInput) ExtractSelectedData(bExclusiveTrdExtract);
63 return fvDigiEvents;
64 }
65
67 bool fbDigiEvtInput = false;
71 std::vector<CbmBmonDigi> fvDigiBmon;
72 std::vector<CbmStsDigi> fvDigiSts;
73 std::vector<CbmMuchDigi> fvDigiMuch;
74 std::vector<CbmTrdDigi> fvDigiTrd;
75 std::vector<CbmTofDigi> fvDigiTof;
76 std::vector<CbmRichDigi> fvDigiRich;
77 std::vector<CbmPsdDigi> fvDigiPsd;
81 std::vector<CbmEvent> fvEvents;
83 std::vector<CbmDigiEvent> fvDigiEvents;
84};
85
86class CbmDeviceDigiEventSink : public FairMQDevice {
87public:
90
91protected:
92 virtual void InitTask();
93 bool HandleMissTsData(FairMQMessagePtr&, int);
94 bool HandleData(FairMQParts&, int);
95 bool HandleCommand(FairMQMessagePtr&, int);
96 virtual void PostRun();
97
98private:
100
102 bool fbStoreFullTs = false;
104 bool fbWriteMissingTs = false;
105 bool fbDisableCompression = false;
106 bool fbDigiEventInput = false;
108 bool fbFillHistos = false;
109 bool fbInitDone = false;
110 bool fbFinishDone = false;
111
114 std::string fsOutputFileName = "mcbm_digis_events.root";
116 std::string fsChannelNameMissedTs = "missedts";
117 std::string fsChannelNameDataInput = "events";
118 std::string fsChannelNameCommands = "commands";
119 std::string fsChannelNameHistosInput = "histogram-in";
121 int64_t fiTreeFileMaxSize = 10000000000LL;
123 uint32_t fuPublishFreqTs = 100;
124 double_t fdMinPublishTime = 0.5;
125 double_t fdMaxPublishTime = 5.0;
126 std::string fsHistosSuffix = "";
127
129 std::vector<std::string> fsAllowedChannels = {fsChannelNameDataInput};
130
132 // TList* fParCList = nullptr;
133 // Bool_t InitParameters( TList* fParCList );
134
136 uint64_t fuPrevTsIndex = 0;
137 uint64_t fulNumMessages = 0;
138 uint64_t fulTsCounter = 0;
139 uint64_t fulMissedTsCounter = 0;
140 uint64_t fulProcessedEvents = 0;
144 std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now();
145 std::chrono::system_clock::time_point fLastFillTime = std::chrono::system_clock::now();
146 std::chrono::system_clock::time_point fStartTime = std::chrono::system_clock::now();
147
149 bool fbReceivedEof = false;
150 uint64_t fuLastTsIndex = 0;
151 uint64_t fuTotalTsCount = 0;
152
157 TClonesArray* fTimeSliceMetaDataArray = nullptr;
158 // TimesliceMetaData* fTsMetaData = nullptr;
160 std::vector<CbmDigiEvent>* fEventsSel = nullptr;
162 std::vector<CbmBmonDigi>* fvDigiBmon = nullptr;
163 std::vector<CbmStsDigi>* fvDigiSts = nullptr;
164 std::vector<CbmMuchDigi>* fvDigiMuch = nullptr;
165 std::vector<CbmTrdDigi>* fvDigiTrd = nullptr;
166 std::vector<CbmTofDigi>* fvDigiTof = nullptr;
167 std::vector<CbmRichDigi>* fvDigiRich = nullptr;
168 std::vector<CbmPsdDigi>* fvDigiPsd = nullptr;
169
172 std::vector<uint64_t> fvulMissedTsIndices = {};
174 std::map<uint64_t, CbmEventTimeslice> fmFullTsStorage = {};
175
177 FairRunOnline* fpRun = nullptr;
178 FairRootManager* fpFairRootMgr = nullptr;
179
181 TObjArray fArrayHisto = {};
183 std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
187 std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
189 bool fbConfigSent = false;
190
198
200 bool IsChannelNameAllowed(std::string channelName);
201 bool InitHistograms();
202 bool ResetHistograms(bool bResetStartTime = false);
203 void CheckTsQueues();
205 void DumpTreeEntry();
207 bool SendHistograms();
208 void Finish();
209};
210
211#endif /* CBMDEVICEDIGIEVTSINK_H_ */
std::vector< CbmStsDigi > * fvDigiSts
bool fbBypassConsecutiveTs
If true, store digis vectors with full TS in addition to selected events.
std::vector< std::string > fsAllowedChannels
List of MQ channels names.
std::vector< CbmRichDigi > * fvDigiRich
bool fbFillHistos
Switch ON/OFF loop based extraction of TRD digis due to 1D/2D.
FairRunOnline * fpRun
Data storage.
bool HandleCommand(FairMQMessagePtr &, int)
std::chrono::system_clock::time_point fLastPublishTime
bool HandleMissTsData(FairMQMessagePtr &, int)
void PrepareTreeEntry(CbmEventTimeslice unpTs)
uint32_t fuPublishFreqTs
Histograms management.
uint64_t fuPrevTsIndex
Parameters management.
bool fbReceivedEof
Control Commands reception.
bool fbWriteMissingTs
Switch ON/OFF the bypass of the consecutive TS buffer before writing to file.
std::vector< CbmMuchDigi > * fvDigiMuch
std::chrono::system_clock::time_point fLastFillTime
bool fbInitDone
Switch ON/OFF filling of histograms.
bool fbExclusiveTrdExtract
Switch ON/OFF the input of CbmDigiEvents instead of raw data + CbmEvents.
TObjArray fArrayHisto
Array of histograms to send to the histogram server.
std::map< uint64_t, CbmEventTimeslice > fmFullTsStorage
Buffered TS.
int64_t fiTreeFileMaxSize
Output file/tree management.
TClonesArray * fTimeSliceMetaDataArray
TS MetaData storage.
std::string fsOutputFileName
Keep track of whether the Finish was already called.
bool HandleData(FairMQParts &, int)
bool IsChannelNameAllowed(std::string channelName)
Internal methods.
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
std::vector< CbmPsdDigi > * fvDigiPsd
bool ResetHistograms(bool bResetStartTime=false)
std::vector< CbmDigiEvent > * fEventsSel
CbmEvents.
std::vector< uint64_t > fvulMissedTsIndices
std::vector< CbmBmonDigi > * fvDigiBmon
Full TS Digis storage (optional usage, controlled by fbStoreFullTs!)
std::string fsChannelNameMissedTs
message queues
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
bool fbFinishDone
Keep track of whether the Init was already fully completed.
std::vector< CbmTofDigi > * fvDigiTof
bool fbConfigSent
Flag indicating whether the histograms and canvases configurations were already published.
std::vector< CbmTrdDigi > * fvDigiTrd
bool fbDigiEventInput
Switch ON/OFF the ROOT file compression.
std::chrono::system_clock::time_point fStartTime
bool fbDisableCompression
Switch ON/OFF writing of empty TS to file for the missing ones (if no bypass)
CbmTsEventHeader fCbmTsEventHeader
TS information in header.
std::vector< CbmRichDigi > fvDigiRich
bool fbDigiEvtInput
Input Type.
std::vector< CbmEvent > fvEvents
Raw events.
CbmEventTimeslice(FairMQParts &parts, bool bDigiEvtInput=false)
TODO: rename to CbmTsWithEvents.
std::vector< CbmDigiEvent > & GetSelectedData(bool bExclusiveTrdExtract=true)
std::vector< CbmTofDigi > fvDigiTof
std::vector< CbmDigiEvent > fvDigiEvents
Digi events.
std::vector< CbmStsDigi > fvDigiSts
std::vector< CbmPsdDigi > fvDigiPsd
void ExtractSelectedData(bool bExclusiveTrdExtract=true)
TimesliceMetaData fTsMetaData
extra Metadata
std::vector< CbmMuchDigi > fvDigiMuch
std::vector< CbmBmonDigi > fvDigiBmon
Raw data.
std::vector< CbmTrdDigi > fvDigiTrd