9#include <daq/rawdata/modules/Root2Raw.h>
11#include <daq/dataobjects/SendHeader.h>
12#include <daq/dataobjects/SendTrailer.h>
13#include <framework/core/Module.h>
14#include <framework/core/ModuleParamBase.h>
15#include <framework/datastore/StoreArray.h>
16#include <framework/logging/Logger.h>
17#include <rawdata/dataobjects/RawARICH.h>
18#include <rawdata/dataobjects/RawCDC.h>
19#include <rawdata/dataobjects/RawECL.h>
20#include <rawdata/dataobjects/RawFTSW.h>
21#include <rawdata/dataobjects/RawHeader_v1.h>
22#include <rawdata/dataobjects/RawKLM.h>
23#include <rawdata/dataobjects/RawSVD.h>
24#include <rawdata/dataobjects/RawTOP.h>
25#include <rawdata/dataobjects/RawTRG.h>
45 addParam(
"outputFileName", m_filename,
"Output binary filename",
string(
"datafile.binary"));
46 addParam(
"expno", m_expno,
"experiment number for output raw file", 0);
47 addParam(
"runno", m_runno,
"run number for output raw file", 0);
50Root2RawModule::~Root2RawModule()
56 B2INFO(
"Root2Raw: initialize() started.");
58 m_file = open(m_filename.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0644);
64 B2INFO(
"Root2Raw: initialize() done.");
71 B2INFO(
"endRun done.");
78 B2INFO(
"terminate called");
86 B2INFO(
"Root2Raw: event() started.");
94 int* evtbuf =
static_cast<int*
>(malloc(MAXEVTSIZE));
95 if (evtbuf == NULL) B2FATAL(
"Root2Raw: cannot allocate the event buffer");
118 for (
int i = 0; i < svdarray.
getEntries(); i++) {
120 RawSVD* svd = svdarray[i];
122 memcpy(databuf, svd->GetBuffer(0), svd->GetBlockNwords(0)*
sizeof(
int));
123 nwords += svd->GetBlockNwords(0);
124 databuf += svd->GetBlockNwords(0);
130 for (
int i = 0; i < cdcarray.
getEntries(); i++) {
132 RawCDC* cdc = cdcarray[i];
134 memcpy(databuf, cdc->GetBuffer(0), cdc->GetBlockNwords(0)*
sizeof(
int));
135 nwords += cdc->GetBlockNwords(0);
136 databuf += cdc->GetBlockNwords(0);
142 for (
int i = 0; i < toparray.
getEntries(); i++) {
144 RawTOP* top = toparray[i];
146 memcpy(databuf, top->GetBuffer(0), top->GetBlockNwords(0)*
sizeof(
int));
147 nwords += top->GetBlockNwords(0);
148 databuf += top->GetBlockNwords(0);
154 for (
int i = 0; i < aricharray.
getEntries(); i++) {
158 memcpy(databuf, arich->GetBuffer(0), arich->GetBlockNwords(0)*
sizeof(
int));
159 nwords += arich->GetBlockNwords(0);
160 databuf += arich->GetBlockNwords(0);
166 for (
int i = 0; i < eclarray.
getEntries(); i++) {
168 RawECL* ecl = eclarray[i];
170 memcpy(databuf, ecl->GetBuffer(0), ecl->GetBlockNwords(0)*
sizeof(
int));
171 nwords += ecl->GetBlockNwords(0);
172 databuf += ecl->GetBlockNwords(0);
178 for (
int i = 0; i < klmarray.
getEntries(); i++) {
180 RawKLM* klm = klmarray[i];
190 for (
int i = 0; i < trgarray.
getEntries(); i++) {
192 RawTRG* trg = trgarray[i];
202 for (
int i = 0; i < ftswarray.
getEntries(); i++) {
237 nwords += trl.GetTrlNwords();
244 hdr.SetNumNodesinPacket(nblock);
247 rhdr.
SetBuffer(cdcarray[0]->GetBuffer(0));
248 hdr.SetEventNumber(rhdr.
GetEveNo());
257 if (m_expno != 0 && m_runno != 0) {
258 hdr.SetExpNum(m_expno);
259 hdr.SetRunNum(m_runno);
263 memcpy(databuf, trl.GetBuffer(), trl.GetTrlNwords()*
sizeof(
int));
265 write(m_file, evtbuf, nwords *
sizeof(
int));
The Raw ARICH class Class for RawCOPPER class data taken by ARICH Currently, this class is almost sam...
The Raw CDC class Class for RawCOPPER class data taken by CDC Currently, this class is almost same as...
virtual int * GetBuffer(int n)
get nth buffer pointer
virtual int GetBlockNwords(int n)
get size of a data block
The Raw ECL class Class for RawCOPPER class data taken by ECL Currently, this class is almost same as...
The Raw KLM class Class for RawCOPPER class data taken by KLM.
The Raw SVD class Class for RawCOPPER class data taken by SVD Currently, this class is almost same as...
The Raw TOP class Class for RawCOPPER class data taken by TOP Currently, this class is almost same as...
The Raw TOP class Class for RawCOPPER class data taken by TOP Currently, this class is almost same as...
Root2RawModule()
Constructor / Destructor.
void initialize() override
Module functions to be called from main process.
void event() override
Module functions to be called from event process.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
void Initialize()
set buffer
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
unsigned int GetEveNo()
get restart #(8bit)
unsigned int GetExpRunSubrun()
get contents of header
Abstract base class for different kinds of events.