9#include <rawdata/modules/Convert2RawDet.h>
30 setDescription(
"convert from RawCOPPER or RawDataBlock to RawDetector objects");
42 gSystem->Load(
"libdataobjects");
69 B2INFO(
"beginRun called.");
77 vector<unsigned int> cpr_id;
83 for (
int i = 0; i < raw_svdarray.
getEntries(); i++) {
84 for (
int j = 0; j < raw_svdarray[ i ]->GetNumEntries(); j++) {
85 cpr_id.push_back(raw_svdarray[ i ]->GetNodeID(j));
90 for (
int i = 0; i < raw_cdcarray.
getEntries(); i++) {
91 for (
int j = 0; j < raw_cdcarray[ i ]->GetNumEntries(); j++) {
92 cpr_id.push_back(raw_cdcarray[ i ]->GetNodeID(j));
97 for (
int i = 0; i < raw_toparray.
getEntries(); i++) {
98 for (
int j = 0; j < raw_toparray[ i ]->GetNumEntries(); j++) {
99 cpr_id.push_back(raw_toparray[ i ]->GetNodeID(j));
104 for (
int i = 0; i < raw_aricharray.
getEntries(); i++) {
105 for (
int j = 0; j < raw_aricharray[ i ]->GetNumEntries(); j++) {
106 cpr_id.push_back(raw_aricharray[ i ]->GetNodeID(j));
111 for (
int i = 0; i < raw_eclarray.
getEntries(); i++) {
112 for (
int j = 0; j < raw_eclarray[ i ]->GetNumEntries(); j++) {
113 cpr_id.push_back(raw_eclarray[ i ]->GetNodeID(j));
118 for (
int i = 0; i < raw_klmarray.
getEntries(); i++) {
119 for (
int j = 0; j < raw_klmarray[ i ]->GetNumEntries(); j++) {
120 cpr_id.push_back(raw_klmarray[ i ]->GetNodeID(j));
125 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
126 for (
int j = 0; j < raw_trgarray[ i ]->GetNumEntries(); j++) {
127 cpr_id.push_back(raw_trgarray[ i ]->GetNodeID(j));
133 for (
int i = 0; i < raw_datablkarray.
getEntries(); i++) {
136 raw_datablkarray.
clear();
139 for (
int i = 0; i < raw_cprarray.
getEntries(); i++) {
142 raw_cprarray.
clear();
145 for (
unsigned int i = 0; i < cpr_id.size(); i++) {
146 for (
unsigned int j = i + 1; j < cpr_id.size(); j++) {
148 if (cpr_id[ i ] == cpr_id[ j ]) {
149 B2FATAL(
"Duplicated COPPER object is found. ID=0x" << hex << cpr_id[ i ] <<
" Exiting...");
166 printf(
"[FATAL] %s : This module should be used for data with num_eve = 1\n", __PRETTY_FUNCTION__);
182 for (
int j = 0; j < num_eve; j++) {
183 for (
int k = 0; k < num_nodes; k++) {
185 int blkid = j * num_nodes + k;
189 int* temp_buf =
new int[ nwords ];
190 memcpy(temp_buf, raw_dblk->
GetBuffer(blkid), nwords *
sizeof(
int));
195 const int temp_num_eve = 1;
196 const int temp_num_nodes = 1;
199 tempcpr.
SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
203 cpr_id.push_back((
unsigned int)subsys_id);
209 if ((subsys_id & DETECTOR_MASK) == SVD_ID) {
211 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
212 }
else if ((subsys_id & DETECTOR_MASK) == CDC_ID) {
214 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
215 }
else if ((subsys_id & DETECTOR_MASK) == TOP_ID) {
217 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
218 }
else if ((subsys_id & DETECTOR_MASK) == ARICH_ID) {
220 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
221 }
else if ((subsys_id & DETECTOR_MASK) == BECL_ID) {
223 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
224 }
else if ((subsys_id & DETECTOR_MASK) == EECL_ID) {
226 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
227 }
else if ((subsys_id & DETECTOR_MASK) == BKLM_ID) {
229 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
230 }
else if ((subsys_id & DETECTOR_MASK) == EKLM_ID) {
232 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
233 }
else if (((subsys_id & DETECTOR_MASK) & 0xF0000000) == TRGDATA_ID) {
235 (ary.
appendNew())->SetBuffer(temp_buf, nwords, delete_flag, temp_num_eve, temp_num_nodes);
237 printf(
"[FATAL] Undefined detector ID(0x%.8x). Exiting...\n", subsys_id);
255 B2INFO(
"Convert2RawDet: endRun done.");
261 B2INFO(
"Convert2RawDet: terminate called");
int m_nevt
No. of sent events.
StoreArray< RawSVD > m_rawSVD
Array for RawCOPPER
virtual void initialize() override
Called at the beginning of data processing.
virtual void event() override
Called for each event.
virtual void endRun() override
Called if the current run ends.
StoreArray< RawFTSW > m_rawFTSW
Array for RawTRG
virtual void terminate() override
Called at the end of data processing.
virtual void convertDataObject(RawDataBlock *raw_dblk, std::vector< unsigned int > &cpr_id)
function to register data buffer in DataStore as RawDetector
StoreArray< RawCOPPER > m_rawCOPPER
Array for RawDataBlock.
StoreArray< RawARICH > m_rawARICH
Array for RawTOP
virtual ~Convert2RawDetModule()
Destructor.
StoreArray< RawTRG > m_rawTRG
Array for RawKLM
virtual void beginRun() override
Called when entering a new run.
StoreArray< RawKLM > m_rawKLM
Array for RawECL
Convert2RawDetModule()
Constructor.
StoreArray< RawTOP > m_rawTOP
Array for RawCDC
StoreArray< RawDataBlock > m_rawDataBlock
Data members.
StoreArray< RawECL > m_rawECL
Array for RawARICH
StoreArray< RawCDC > m_rawCDC
Array for RawSVD
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_Input
This module is an input module (reads data).
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 GetNumNodes()
get # of data sources(e.g. # of COPPER boards) in m_buffer
virtual int GetBlockNwords(int n)
get size of a data block
virtual int GetNumEvents()
get # of events in m_buffer
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
void clear() override
Delete all entries in this array.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
unsigned int GetNodeID(int n)
get node-ID from data
Abstract base class for different kinds of events.