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 = (
int*) malloc(MAXEVTSIZE);
117 for (
int i = 0; i < svdarray.
getEntries(); i++) {
119 RawSVD* svd = svdarray[i];
121 memcpy(databuf, svd->GetBuffer(0), svd->GetBlockNwords(0)*
sizeof(
int));
122 nwords += svd->GetBlockNwords(0);
123 databuf += svd->GetBlockNwords(0);
129 for (
int i = 0; i < cdcarray.
getEntries(); i++) {
131 RawCDC* cdc = cdcarray[i];
133 memcpy(databuf, cdc->GetBuffer(0), cdc->GetBlockNwords(0)*
sizeof(
int));
134 nwords += cdc->GetBlockNwords(0);
135 databuf += cdc->GetBlockNwords(0);
141 for (
int i = 0; i < toparray.
getEntries(); i++) {
143 RawTOP* top = toparray[i];
145 memcpy(databuf, top->GetBuffer(0), top->GetBlockNwords(0)*
sizeof(
int));
146 nwords += top->GetBlockNwords(0);
147 databuf += top->GetBlockNwords(0);
153 for (
int i = 0; i < aricharray.
getEntries(); i++) {
157 memcpy(databuf, arich->GetBuffer(0), arich->GetBlockNwords(0)*
sizeof(
int));
158 nwords += arich->GetBlockNwords(0);
159 databuf += arich->GetBlockNwords(0);
165 for (
int i = 0; i < eclarray.
getEntries(); i++) {
167 RawECL* ecl = eclarray[i];
169 memcpy(databuf, ecl->GetBuffer(0), ecl->GetBlockNwords(0)*
sizeof(
int));
170 nwords += ecl->GetBlockNwords(0);
171 databuf += ecl->GetBlockNwords(0);
177 for (
int i = 0; i < klmarray.
getEntries(); i++) {
179 RawKLM* klm = klmarray[i];
189 for (
int i = 0; i < trgarray.
getEntries(); i++) {
191 RawTRG* trg = trgarray[i];
201 for (
int i = 0; i < ftswarray.
getEntries(); i++) {
236 nwords += trl.GetTrlNwords();
243 hdr.SetNumNodesinPacket(nblock);
246 rhdr.
SetBuffer(cdcarray[0]->GetBuffer(0));
247 hdr.SetEventNumber(rhdr.
GetEveNo());
256 if (m_expno != 0 && m_runno != 0) {
257 hdr.SetExpNum(m_expno);
258 hdr.SetRunNum(m_runno);
262 memcpy(databuf, trl.GetBuffer(), trl.GetTrlNwords()*
sizeof(
int));
264 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.