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>
44 addParam(
"outputFileName", m_filename,
"Output binary filename",
string(
"datafile.binary"));
45 addParam(
"expno", m_expno,
"experiment number for output raw file", 0);
46 addParam(
"runno", m_runno,
"run number for output raw file", 0);
49Root2RawModule::~Root2RawModule()
55 B2INFO(
"Root2Raw: initialize() started.");
57 m_file = open(m_filename.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0644);
63 B2INFO(
"Root2Raw: initialize() done.");
70 B2INFO(
"endRun done.");
77 B2INFO(
"terminate called");
85 B2INFO(
"Root2Raw: event() started.");
93 int* evtbuf = (
int*) malloc(MAXEVTSIZE);
116 for (
int i = 0; i < svdarray.
getEntries(); i++) {
118 RawSVD* svd = svdarray[i];
120 memcpy(databuf, svd->GetBuffer(0), svd->GetBlockNwords(0)*
sizeof(
int));
121 nwords += svd->GetBlockNwords(0);
122 databuf += svd->GetBlockNwords(0);
128 for (
int i = 0; i < cdcarray.
getEntries(); i++) {
130 RawCDC* cdc = cdcarray[i];
132 memcpy(databuf, cdc->GetBuffer(0), cdc->GetBlockNwords(0)*
sizeof(
int));
133 nwords += cdc->GetBlockNwords(0);
134 databuf += cdc->GetBlockNwords(0);
140 for (
int i = 0; i < toparray.
getEntries(); i++) {
142 RawTOP* top = toparray[i];
144 memcpy(databuf, top->GetBuffer(0), top->GetBlockNwords(0)*
sizeof(
int));
145 nwords += top->GetBlockNwords(0);
146 databuf += top->GetBlockNwords(0);
152 for (
int i = 0; i < aricharray.
getEntries(); i++) {
156 memcpy(databuf, arich->GetBuffer(0), arich->GetBlockNwords(0)*
sizeof(
int));
157 nwords += arich->GetBlockNwords(0);
158 databuf += arich->GetBlockNwords(0);
164 for (
int i = 0; i < eclarray.
getEntries(); i++) {
166 RawECL* ecl = eclarray[i];
168 memcpy(databuf, ecl->GetBuffer(0), ecl->GetBlockNwords(0)*
sizeof(
int));
169 nwords += ecl->GetBlockNwords(0);
170 databuf += ecl->GetBlockNwords(0);
176 for (
int i = 0; i < klmarray.
getEntries(); i++) {
178 RawKLM* klm = klmarray[i];
188 for (
int i = 0; i < ftswarray.
getEntries(); i++) {
222 nwords += trl.GetTrlNwords();
229 hdr.SetNumNodesinPacket(nblock);
232 rhdr.
SetBuffer(cdcarray[0]->GetBuffer(0));
233 hdr.SetEventNumber(rhdr.
GetEveNo());
242 if (m_expno != 0 && m_runno != 0) {
243 hdr.SetExpNum(m_expno);
244 hdr.SetRunNum(m_runno);
248 memcpy(databuf, trl.GetBuffer(), trl.GetTrlNwords()*
sizeof(
int));
250 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...
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.