CbmRoot
CbmDeviceMcbmEventSink.h
Go to the documentation of this file.
1 
8 #ifndef CBMDEVICEMCBMEVTSINK_H_
9 #define CBMDEVICEMCBMEVTSINK_H_
10 
12 #include "CbmEvent.h"
13 #include "CbmMuchBeamTimeDigi.h"
14 #include "CbmPsdDigi.h"
15 #include "CbmRichDigi.h"
16 #include "CbmStsDigi.h"
17 #include "CbmTofDigi.h"
18 #include "CbmTrdDigi.h"
19 #include "TimesliceMetaData.h"
20 
22 #include "FairMQDevice.h"
23 
25 #include "Rtypes.h"
26 #include "TClonesArray.h"
27 #include "TMessage.h"
28 #include "TObjArray.h"
29 
31 #include <chrono>
32 #include <map>
33 #include <vector>
34 
35 class TFile;
36 class TList;
37 class TClonesArray;
38 //class TimesliceMetaData;
39 class FairRunOnline;
40 class FairRootManager;
41 
44 public:
45  CbmUnpackedTimeslice(FairMQParts& parts);
46 
48  std::vector<CbmTofDigi> fvDigiT0;
49  std::vector<CbmStsDigi> fvDigiSts;
50  std::vector<CbmMuchBeamTimeDigi> fvDigiMuch;
51  std::vector<CbmTrdDigi> fvDigiTrd;
52  std::vector<CbmTofDigi> fvDigiTof;
53  std::vector<CbmRichDigi> fvDigiRich;
54  std::vector<CbmPsdDigi> fvDigiPsd;
55  TClonesArray fEventsArray;
56 };
57 
58 class CbmDeviceMcbmEventSink : public FairMQDevice {
59 public:
61  virtual ~CbmDeviceMcbmEventSink();
62 
63 protected:
64  virtual void InitTask();
65  bool HandleMissTsData(FairMQMessagePtr&, int);
66  bool HandleData(FairMQParts&, int);
67  bool HandleCommand(FairMQMessagePtr&, int);
68 
69 private:
71 
73  Bool_t fbFillHistos = kFALSE;
74  Bool_t fbFinishDone =
75  kFALSE;
76 
79  std::string fsOutputFileName = "mcbm_digis_events.root";
81  std::string fsChannelNameMissedTs = "missedts";
82  std::string fsChannelNameDataInput = "events";
83  std::string fsChannelNameCommands = "commands";
84  std::string fsChannelNameHistosInput = "histogram-in";
85  std::string fsChannelNameHistosConfig = "histo-conf";
86  std::string fsChannelNameCanvasConfig = "canvas-conf";
88  uint32_t fuPublishFreqTs = 100;
89  double_t fdMinPublishTime = 0.5;
90  double_t fdMaxPublishTime = 5.0;
91 
93  std::vector<std::string> fsAllowedChannels = {fsChannelNameDataInput};
94 
96  // TList* fParCList = nullptr;
97  // Bool_t InitParameters( TList* fParCList );
98 
100  uint64_t fuPrevTsIndex = 0;
101  uint64_t fulNumMessages = 0;
102  uint64_t fulTsCounter = 0;
103  uint64_t fulMissedTsCounter = 0;
104  std::chrono::system_clock::time_point fLastPublishTime =
105  std::chrono::system_clock::now();
106 
108  bool fbReceivedEof = false;
109  uint64_t fuLastTsIndex = 0;
110  uint64_t fuTotalTsCount = 0;
111 
114  // FairEventHeader* fEvtHeader;
116  TClonesArray* fTimeSliceMetaDataArray = nullptr;
119  std::vector<CbmTofDigi>* fvDigiT0 = nullptr;
120  std::vector<CbmStsDigi>* fvDigiSts = nullptr;
121  std::vector<CbmMuchBeamTimeDigi>* fvDigiMuch = nullptr;
122  std::vector<CbmTrdDigi>* fvDigiTrd = nullptr;
123  std::vector<CbmTofDigi>* fvDigiTof = nullptr;
124  std::vector<CbmRichDigi>* fvDigiRich = nullptr;
125  std::vector<CbmPsdDigi>* fvDigiPsd = nullptr;
127  TClonesArray* fEventsArray = nullptr;
128  // std::vector< CbmEvent * > & fEventVector; //! vector with all created events
129 
132  std::vector<uint64_t> fvulMissedTsIndices = {};
134  std::map<uint64_t, CbmUnpackedTimeslice> fmFullTsStorage = {};
135 
137  FairRunOnline* fpRun = nullptr;
138  FairRootManager* fpFairRootMgr = nullptr;
139  TFile* fpOutRootFile = nullptr;
140 
142  TObjArray fArrayHisto = {};
144  std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
148  std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
149 
151  bool IsChannelNameAllowed(std::string channelName);
152  // Bool_t InitContainers();
153  void CheckTsQueues();
155  void DumpTreeEntry();
156  bool SendHistograms();
157  void Finish();
158 };
159 
160 // special class to expose protected TMessage constructor
161 class CbmMQTMessage : public TMessage {
162 public:
163  CbmMQTMessage(void* buf, Int_t len) : TMessage(buf, len) {
164  ResetBit(kIsOwner);
165  }
166 };
167 
168 
169 #endif /* CBMDEVICEMCBMEVTSINK_H_ */
CbmDeviceMcbmEventSink::fvDigiPsd
std::vector< CbmPsdDigi > * fvDigiPsd
Definition: CbmDeviceMcbmEventSink.h:125
CbmDeviceMcbmEventSink::DumpTreeEntry
void DumpTreeEntry()
Definition: CbmDeviceMcbmEventSink.cxx:587
CbmDeviceMcbmEventSink::fsChannelNameCommands
std::string fsChannelNameCommands
Definition: CbmDeviceMcbmEventSink.h:83
CbmDeviceMcbmEventSink::HandleMissTsData
bool HandleMissTsData(FairMQMessagePtr &, int)
Definition: CbmDeviceMcbmEventSink.cxx:323
CbmUnpackedTimeslice
Definition: CbmDeviceMcbmEventSink.h:42
CbmPsdDigi.h
CbmDeviceMcbmEventSink::fpRun
FairRunOnline * fpRun
Data storage.
Definition: CbmDeviceMcbmEventSink.h:137
CbmDeviceMcbmEventSink::fsChannelNameCanvasConfig
std::string fsChannelNameCanvasConfig
Definition: CbmDeviceMcbmEventSink.h:86
CbmDeviceMcbmEventSink::CheckTsQueues
void CheckTsQueues()
Definition: CbmDeviceMcbmEventSink.cxx:481
CbmDeviceMcbmEventSink::IsChannelNameAllowed
bool IsChannelNameAllowed(std::string channelName)
Internal methods.
Definition: CbmDeviceMcbmEventSink.cxx:239
CbmUnpackedTimeslice::fvDigiT0
std::vector< CbmTofDigi > fvDigiT0
Definition: CbmDeviceMcbmEventSink.h:48
CbmDeviceMcbmEventSink::fsAllowedChannels
std::vector< std::string > fsAllowedChannels
List of MQ channels names.
Definition: CbmDeviceMcbmEventSink.h:93
CbmDeviceMcbmEventSink::fmFullTsStorage
std::map< uint64_t, CbmUnpackedTimeslice > fmFullTsStorage
Buffered TS.
Definition: CbmDeviceMcbmEventSink.h:134
CbmDeviceMcbmEventSink::fsChannelNameHistosConfig
std::string fsChannelNameHistosConfig
Definition: CbmDeviceMcbmEventSink.h:85
CbmDeviceMcbmEventSink::fvDigiRich
std::vector< CbmRichDigi > * fvDigiRich
Definition: CbmDeviceMcbmEventSink.h:124
CbmDeviceMcbmEventSink::fpOutRootFile
TFile * fpOutRootFile
Definition: CbmDeviceMcbmEventSink.h:139
CbmDeviceMcbmEventSink::fvulMissedTsIndices
std::vector< uint64_t > fvulMissedTsIndices
output container of CbmEvents
Definition: CbmDeviceMcbmEventSink.h:132
CbmDeviceMcbmEventSink::fdMinPublishTime
double_t fdMinPublishTime
Definition: CbmDeviceMcbmEventSink.h:89
TimesliceMetaData
Definition: TimesliceMetaData.h:11
CbmDeviceMcbmEventSink::fbFillHistos
Bool_t fbFillHistos
Constants.
Definition: CbmDeviceMcbmEventSink.h:73
CbmDeviceMcbmEventSink::CbmDeviceMcbmEventSink
CbmDeviceMcbmEventSink()
Definition: CbmDeviceMcbmEventSink.cxx:52
CbmMQTMessage
Definition: CbmDeviceEventBuilderEtofStar2019.h:96
CbmDeviceMcbmEventSink::fsOutputFileName
std::string fsOutputFileName
Keep track of whether the Finish was already called.
Definition: CbmDeviceMcbmEventSink.h:79
CbmTofDigi.h
CbmMQTMessage::CbmMQTMessage
CbmMQTMessage(void *buf, Int_t len)
Definition: CbmDeviceMcbmEventSink.h:163
CbmRichDigi.h
CbmDeviceMcbmEventSink::fTsMetaData
TimesliceMetaData * fTsMetaData
Definition: CbmDeviceMcbmEventSink.h:117
CbmDeviceMcbmEventSink::fbFinishDone
Bool_t fbFinishDone
Switch ON/OFF filling of histograms.
Definition: CbmDeviceMcbmEventSink.h:74
CbmEvent.h
CbmDeviceMcbmEventSink::fTimeSliceMetaDataArray
TClonesArray * fTimeSliceMetaDataArray
TS MetaData storage.
Definition: CbmDeviceMcbmEventSink.h:116
CbmDeviceMcbmEventSink::HandleData
bool HandleData(FairMQParts &, int)
Definition: CbmDeviceMcbmEventSink.cxx:341
CbmUnpackedTimeslice::CbmUnpackedTimeslice
CbmUnpackedTimeslice(FairMQParts &parts)
TODO: rename to CbmTsWithEvents.
Definition: CbmDeviceMcbmEventSink.cxx:689
CbmDeviceMcbmEventSink::fulMissedTsCounter
uint64_t fulMissedTsCounter
Definition: CbmDeviceMcbmEventSink.h:103
CbmDeviceMcbmEventSink::fdMaxPublishTime
double_t fdMaxPublishTime
Definition: CbmDeviceMcbmEventSink.h:90
CbmTrdDigi.h
CbmStsDigi.h
CbmDeviceMcbmEventSink::fvDigiT0
std::vector< CbmTofDigi > * fvDigiT0
Digis storage.
Definition: CbmDeviceMcbmEventSink.h:119
CbmUnpackedTimeslice::fvDigiTof
std::vector< CbmTofDigi > fvDigiTof
Definition: CbmDeviceMcbmEventSink.h:52
CbmDeviceMcbmEventSink::PrepareTreeEntry
void PrepareTreeEntry(CbmUnpackedTimeslice unpTs)
Definition: CbmDeviceMcbmEventSink.cxx:543
CbmDeviceMcbmEventSink::fvpsHistosFolder
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
Definition: CbmDeviceMcbmEventSink.h:144
CbmUnpackedTimeslice::fvDigiMuch
std::vector< CbmMuchBeamTimeDigi > fvDigiMuch
Definition: CbmDeviceMcbmEventSink.h:50
CbmMuchBeamTimeDigi.h
CbmDeviceMcbmEventSink::fbReceivedEof
bool fbReceivedEof
Control Commands reception.
Definition: CbmDeviceMcbmEventSink.h:108
CbmDeviceMcbmEventSink::HandleCommand
bool HandleCommand(FairMQMessagePtr &, int)
Definition: CbmDeviceMcbmEventSink.cxx:415
CbmDeviceMcbmEventSink::fuPrevTsIndex
uint64_t fuPrevTsIndex
Parameters management.
Definition: CbmDeviceMcbmEventSink.h:100
CbmDeviceMcbmEventSink::fEventsArray
TClonesArray * fEventsArray
CbmEvents.
Definition: CbmDeviceMcbmEventSink.h:127
CbmDeviceMcbmEventSink::fArrayHisto
TObjArray fArrayHisto
Array of histograms to send to the histogram server.
Definition: CbmDeviceMcbmEventSink.h:142
CbmDeviceMcbmEventSink::fsChannelNameMissedTs
std::string fsChannelNameMissedTs
message queues
Definition: CbmDeviceMcbmEventSink.h:81
CbmDeviceMcbmEventSink::~CbmDeviceMcbmEventSink
virtual ~CbmDeviceMcbmEventSink()
Definition: CbmDeviceMcbmEventSink.cxx:641
CbmDeviceMcbmEventSink::fsChannelNameHistosInput
std::string fsChannelNameHistosInput
Definition: CbmDeviceMcbmEventSink.h:84
CbmDeviceMcbmEventSink::fvDigiMuch
std::vector< CbmMuchBeamTimeDigi > * fvDigiMuch
Definition: CbmDeviceMcbmEventSink.h:121
CbmUnpackedTimeslice::fvDigiTrd
std::vector< CbmTrdDigi > fvDigiTrd
Definition: CbmDeviceMcbmEventSink.h:51
CbmUnpackedTimeslice::fEventsArray
TClonesArray fEventsArray
Definition: CbmDeviceMcbmEventSink.h:55
CbmDeviceMcbmEventSink::Finish
void Finish()
Definition: CbmDeviceMcbmEventSink.cxx:668
CbmDeviceMcbmEventSink::fvpsCanvasConfig
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
Definition: CbmDeviceMcbmEventSink.h:148
CbmDeviceMcbmEventSink::fsChannelNameDataInput
std::string fsChannelNameDataInput
Definition: CbmDeviceMcbmEventSink.h:82
CbmUnpackedTimeslice::fvDigiRich
std::vector< CbmRichDigi > fvDigiRich
Definition: CbmDeviceMcbmEventSink.h:53
CbmDeviceMcbmEventSink::fvDigiTof
std::vector< CbmTofDigi > * fvDigiTof
Definition: CbmDeviceMcbmEventSink.h:123
CbmDeviceMcbmEventSink::fuTotalTsCount
uint64_t fuTotalTsCount
Definition: CbmDeviceMcbmEventSink.h:110
CbmUnpackedTimeslice::fTsMetaData
TimesliceMetaData fTsMetaData
Definition: CbmDeviceMcbmEventSink.h:47
TimesliceMetaData.h
CbmDeviceMcbmEventSink::fvDigiTrd
std::vector< CbmTrdDigi > * fvDigiTrd
Definition: CbmDeviceMcbmEventSink.h:122
CbmDeviceMcbmEventSink::fulNumMessages
uint64_t fulNumMessages
Definition: CbmDeviceMcbmEventSink.h:101
CbmDeviceMcbmEventSink::fLastPublishTime
std::chrono::system_clock::time_point fLastPublishTime
Definition: CbmDeviceMcbmEventSink.h:104
CbmUnpackedTimeslice::fvDigiPsd
std::vector< CbmPsdDigi > fvDigiPsd
Definition: CbmDeviceMcbmEventSink.h:54
CbmDeviceMcbmEventSink::fulTsCounter
uint64_t fulTsCounter
Definition: CbmDeviceMcbmEventSink.h:102
CbmUnpackedTimeslice::fvDigiSts
std::vector< CbmStsDigi > fvDigiSts
Definition: CbmDeviceMcbmEventSink.h:49
CbmDeviceMcbmEventSink::fpFairRootMgr
FairRootManager * fpFairRootMgr
Definition: CbmDeviceMcbmEventSink.h:138
CbmDeviceMcbmEventSink::fvDigiSts
std::vector< CbmStsDigi > * fvDigiSts
Definition: CbmDeviceMcbmEventSink.h:120
CbmDeviceMcbmEventSink
Definition: CbmDeviceMcbmEventSink.h:58
CbmDeviceMcbmEventSink::InitTask
virtual void InitTask()
Definition: CbmDeviceMcbmEventSink.cxx:54
CbmDeviceMcbmEventSink::fuPublishFreqTs
uint32_t fuPublishFreqTs
Histograms management.
Definition: CbmDeviceMcbmEventSink.h:88
CbmDeviceMcbmEventSink::SendHistograms
bool SendHistograms()
Definition: CbmDeviceMcbmEventSink.cxx:623
CbmDeviceMcbmEventSink::fuLastTsIndex
uint64_t fuLastTsIndex
Definition: CbmDeviceMcbmEventSink.h:109