BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
decoder_proxy.cxx
Go to the documentation of this file.
1
#include "
DigiArrays.h
"
2
3
#include <RootSerializer.h>
4
#include <
TBuffer.h
>
5
#include <
TFile.h
>
6
#include <
TString.h
>
7
#include <
TTree.h
>
8
#include <fairmq/Device.h>
9
#include <fairmq/runDevice.h>
10
#include <string>
11
12
namespace
bpo = boost::program_options;
13
14
namespace
bmn::online
15
{
16
struct
DecoderProxy
: fair::mq::Device
17
{
18
protected
:
19
static
constexpr
auto
INPUT_CHANNEL_NAME
=
"in-channel"
;
20
static
constexpr
auto
OUTPUT_CHANNEL_NAME
=
"out-channel"
;
21
22
void
Init
()
override
{ OnData(
INPUT_CHANNEL_NAME
, &
DecoderProxy::HandleData
); }
23
24
Bool_t
HandleData
(fair::mq::MessagePtr& inputMessage,
Int_t
)
25
{
26
LOG(info) <<
"Event Received. Message size: "
<< inputMessage->GetSize();
27
28
auto
buffer = std::make_unique<TBufferFile>(
TBuffer::kRead
);
29
buffer->SetBuffer(inputMessage->GetData(), inputMessage->GetSize());
30
auto
eventData = std::unique_ptr<DigiArrays>(
static_cast<
DigiArrays
*
>
(buffer->ReadObject(
DigiArrays::Class
())));
31
32
auto
tree = std::make_unique<TTree>();
33
tree->Branch(
"SILICON"
, eventData->silicon);
34
tree->Branch(
"GEM"
, eventData->gem);
35
tree->Branch(
"CSC"
, eventData->csc);
36
tree->Branch(
"TOF400"
, eventData->tof400);
37
tree->Branch(
"TOF700"
, eventData->tof700);
38
tree->Branch(
"TOF701"
, eventData->tof701);
39
tree->Branch(
"ScWallDigi"
, eventData->scwall);
40
tree->Branch(
"FHCalDigi"
, eventData->fhcal);
41
tree->Branch(
"HodoDigi"
, eventData->hodo);
42
tree->Branch(
"HdetDigi"
, eventData->ndet);
43
tree->Branch(
"SiBT"
, eventData->sibt);
44
tree->Branch(
"BC2AT"
, eventData->trigAr);
45
tree->Fill();
46
47
auto
message = NewMessage();
48
RootSerializer().Serialize(*message, tree);
49
50
if
(Send(message,
OUTPUT_CHANNEL_NAME
) < 0) {
51
LOG(error) <<
"Sending message failed!"
;
52
return
kFALSE
;
53
}
54
55
buffer.release();
56
57
return
kTRUE
;
58
}
59
};
60
61
}
// namespace bmn::online
62
63
void
addCustomOptions
(bpo::options_description& options) {}
64
65
std::unique_ptr<fair::mq::Device>
getDevice
(fair::mq::ProgOptions&)
66
{
67
return
std::make_unique<bmn::online::DecoderProxy>();
68
}
DigiArrays.h
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
TBuffer.h
TFile.h
TString.h
TTree.h
DigiArrays
Definition
DigiArrays.h:10
TBuffer::kRead
kRead
TObject::Class
static TClass * Class()
getDevice
std::unique_ptr< fair::mq::Device > getDevice(fair::mq::ProgOptions &)
Definition
decoder_proxy.cxx:65
addCustomOptions
void addCustomOptions(bpo::options_description &options)
Definition
decoder_proxy.cxx:63
bmn::online
Definition
decoder_proxy.cxx:15
bmn::online::DecoderProxy
Definition
decoder_proxy.cxx:17
bmn::online::DecoderProxy::OUTPUT_CHANNEL_NAME
static constexpr auto OUTPUT_CHANNEL_NAME
Definition
decoder_proxy.cxx:20
bmn::online::DecoderProxy::INPUT_CHANNEL_NAME
static constexpr auto INPUT_CHANNEL_NAME
Definition
decoder_proxy.cxx:19
bmn::online::DecoderProxy::HandleData
Bool_t HandleData(fair::mq::MessagePtr &inputMessage, Int_t)
Definition
decoder_proxy.cxx:24
bmn::online::DecoderProxy::Init
void Init() override
Definition
decoder_proxy.cxx:22
online
decoder_proxy.cxx
Generated on
for BmnRoot by
1.17.0