9 #include <svd/modules/svdDump/svdDumpModule.h>
11 #include <framework/logging/Logger.h>
29 setDescription(
"Module to create SVD data file");
33 addParam(
"outputFileName", m_outputFileName,
"Name of output file.",
string(
"svdDumpModule.dat"));
35 addParam(
"svdRawName", m_svdRawName,
"Name of the SVD Raw",
string(
""));
37 addParam(
"nFtbHeader", m_nFtbHeader,
"# of FTB header",
int(2));
38 addParam(
"nFtbTrailer", m_nFtbTrailer,
"# of FTB header",
int(1));
42 svdDumpModule::~svdDumpModule()
48 B2INFO(
"svdDumpModule: initialize() is called.");
50 m_rawSVD.isRequired(m_svdRawName);
54 m_outputFile =
new ofstream(m_outputFileName.c_str(), ios::trunc);
55 if (!(*m_outputFile)) {
56 B2FATAL(
"Output file: " << m_outputFileName.c_str() <<
" cannot be opened.");
64 B2INFO(
"svdDumpModule: terminate() is called.");
66 m_outputFile->close();
67 delete m_outputFile; m_outputFile =
nullptr;
75 B2INFO(
"svdDumpModule: beginRun() is called.");
80 B2INFO(
"svdDumpModule: endRun() is called.");
87 unsigned int total_nWords = 0;
88 for (
int i = 0; i < rawSVD.
getEntries(); i++) {
89 for (
int j = 0; j < rawSVD[ i ]->GetNumEntries(); j++) {
90 unsigned int nWords = rawSVD[i]->Get1stDetectorNwords(j);
91 if (((
int)nWords - m_nFtbHeader - m_nFtbTrailer) < 0) {
92 B2FATAL(
"Remaining data size is negative: " << ((
int)nWords - m_nFtbHeader - m_nFtbTrailer));
94 unsigned int remaining_nWords = (nWords - m_nFtbHeader - m_nFtbTrailer);
95 total_nWords += remaining_nWords;
98 uint32_t header = (0xf << 28);
99 header |= ((total_nWords & 0xffff) << 12) + (m_event & 0xfff);
100 m_outputFile->write((
char*)(&header),
sizeof(uint32_t));
102 for (
int i = 0; i < rawSVD.
getEntries(); i++) {
103 for (
int j = 0; j < rawSVD[ i ]->GetNumEntries(); j++) {
105 unsigned int nWords = rawSVD[i]->Get1stDetectorNwords(j);
106 unsigned int remaining_nWords = (nWords - m_nFtbHeader - m_nFtbTrailer);
108 uint32_t* data32 = (uint32_t*)rawSVD[i]->Get1stDetectorBuffer(j);
110 m_outputFile->write((
char*)(data32 + m_nFtbHeader),
sizeof(uint32_t)*remaining_nWords);
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Class definition of svdClsHistoManager module.
virtual void initialize() override
module functions
virtual void event() override
This method is the core of the module.
virtual void endRun() override
This method is called if the current run ends.
virtual void terminate() override
This method is called at the end of the event processing.
virtual void beginRun() override
Called when entering a new run.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.