9#include <rawdata/modules/Root2Binary.h>
37 B2INFO(
"Root2Binary: initialize() started.");
42 sprintf(err_buf,
"Cannot open an output file(%s): %s : Exiting...\n",
44 printf(
"%s\n", err_buf);
49 B2INFO(
"Root2Binary: initialize() done.");
56 B2INFO(
"endRun done.");
63 B2INFO(
"terminate called");
80 unsigned int prev_eve = *dblk_eve;
90 temp_raw_ftsw.
SetBuffer(temp_buf, nwords, delete_flag, num_nodes, num_events);
91 *dblk_eve = temp_raw_ftsw.
GetEveNo(0);
94 temp_raw_copper.
SetBuffer(temp_buf, nwords, delete_flag, num_nodes, num_events);
95 *dblk_eve = temp_raw_copper.
GetEveNo(0);
98 if (*dblk_eve != prev_eve && *first_flag == 1) {
102 fwrite((
char*)temp_buf, 1, nwords * 4,
m_fp_out);
103 printf(
"eve %u size %d j %d\n", *dblk_eve, nwords * 4, j);
120 B2INFO(
"Root2Binary: event() started.");
139 int copper_array = 0;
157 unsigned int dblk_eve;
158 unsigned int ftsw_eve;
159 unsigned int copper_eve;
160 unsigned int svd_eve;
161 unsigned int cdc_eve;
162 unsigned int ecl_eve;
163 unsigned int bpid_eve;
164 unsigned int epid_eve;
165 unsigned int klm_eve;
182 int array_entries = raw_dblkarray.
getEntries();
183 for (
int i = dblk_array; i < array_entries; i++) {
185 writeEvent(raw_dblkarray[ i ], &first_flag, &break_flag, &dblk_pos, &dblk_eve);
186 if (break_flag == 1) {
190 if (i == array_entries - 1) {
191 dblk_array = array_entries;
199 for (
int i = ftsw_array; i < array_entries; i++) {
201 writeEvent(raw_ftswarray[ i ], &first_flag, &break_flag, &ftsw_pos, &ftsw_eve);
202 if (break_flag == 1) {
206 if (i == array_entries - 1) {
207 ftsw_array = array_entries;
216 for (
int i = copper_array; i < array_entries; i++) {
218 writeEvent(raw_copperarray[ i ], &first_flag, &break_flag, &copper_pos, &copper_eve);
219 if (break_flag == 1) {
223 if (i == array_entries - 1) {
224 copper_array = array_entries;
233 for (
int i = svd_array; i < array_entries; i++) {
235 writeEvent(raw_svdarray[ i ], &first_flag, &break_flag, &svd_pos, &svd_eve);
236 if (break_flag == 1) {
240 if (i == array_entries - 1) {
241 svd_array = array_entries;
250 for (
int i = cdc_array; i < array_entries; i++) {
252 writeEvent(raw_cdcarray[ i ], &first_flag, &break_flag, &cdc_pos, &cdc_eve);
253 if (break_flag == 1) {
257 if (i == array_entries - 1) {
258 cdc_array = array_entries;
267 for (
int i = bpid_array; i < array_entries; i++) {
269 writeEvent(raw_bpidarray[ i ], &first_flag, &break_flag, &bpid_pos, &bpid_eve);
270 if (break_flag == 1) {
274 if (i == array_entries - 1) {
275 bpid_array = array_entries;
285 for (
int i = epid_array; i < array_entries; i++) {
287 writeEvent(raw_epidarray[ i ], &first_flag, &break_flag, &epid_pos, &epid_eve);
288 if (break_flag == 1) {
292 if (i == array_entries - 1) {
293 epid_array = array_entries;
303 for (
int i = ecl_array; i < array_entries; i++) {
305 writeEvent(raw_eclarray[ i ], &first_flag, &break_flag, &ecl_pos, &ecl_eve);
306 if (break_flag == 1) {
310 if (i == array_entries - 1) {
311 ecl_array = array_entries;
319 for (
int i = klm_array; i < array_entries; i++) {
321 writeEvent(raw_klmarray[ i ], &first_flag, &break_flag, &klm_pos, &klm_eve);
322 if (break_flag == 1) {
326 if (i == array_entries - 1) {
327 klm_array = array_entries;
330 if (write_flag == 0)
break;
Module to get data from DataStore and send it to another network node.
int n_basf2evt
No. of sent events.
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
The RawDataBlock class Base class for rawdata handling.
virtual int * GetBuffer(int n)
get nth buffer pointer
virtual int CheckFTSWID(int n)
get FTSW ID to check whether this data block is FTSW data or not
virtual int GetNumEntries()
get # of data blocks = (# of nodes)*(# of events)
virtual int GetBlockNwords(int n)
get size of a data block
unsigned int GetEveNo(int n)
Get event #.
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
virtual void writeEvent(RawDataBlock *raw_dblk, int *first_flag, int *break_flag, int *dblk_pos, unsigned int *dblk_eve)
write the contents of an event
Root2BinaryModule()
Constructor.
FILE * m_fp_out
File descripter.
virtual void initialize() override
Called at the beginning of data processing.
virtual void event() override
Called for each event.
virtual ~Root2BinaryModule()
Destructor.
virtual void endRun() override
Called if the current run ends.
virtual void terminate() override
Called at the end of data processing.
std::string m_fname_out
Output filename.
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(int n)
get subrun #(8bit)
Abstract base class for different kinds of events.