Belle II Software development
ROIReadTestModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <tracking/modules/roiFinding/pxd/ROIReadTestModule.h>
10#include <tracking/dataobjects/ROIpayload.h>
11
12using namespace Belle2;
13
14//-----------------------------------------------------------------
15// Register the Module
16//-----------------------------------------------------------------
17
18REG_MODULE(ROIReadTest);
19
20//-----------------------------------------------------------------
21// Implementation
22//-----------------------------------------------------------------
23
25{
26 //Set module properties
27 setDescription("check the payload produced by the ROIPayloadAssembler Module");
28 // setPropertyFlags(c_ParallelProcessingCertified);
29
30 addParam("outfileName", m_outfileName, "name of the output file", std::string("ROIpayload.txt"));
31 addParam("ROIpayloadName", m_ROIpayloadName, "name of the payload of ROIs", std::string(""));
32
33}
34
36{
38
39 m_pFile = fopen(m_outfileName.c_str(), "w+");
40 if (!m_pFile) {
41 B2FATAL("Could not open " << m_outfileName);
42 }
43}
44
46{
47 int length = m_ROIPayloads->getLength();
48 unsigned char* rootdata = (unsigned char*) m_ROIPayloads->getRootdata();
49
50 if (!m_pFile) return;
51 for (int i = 0; i < 4 * length; i++) {
52 fputc(rootdata[i], m_pFile);
53 }
54}
55
57{
58 fclose(m_pFile);
59 m_pFile = nullptr;
60}
61
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void initialize() override
Initializes the Module.
std::string m_ROIpayloadName
ROI payload name.
void event() override
This method is called for each event.
ROIReadTestModule()
Constructor of the module.
void terminate() override
Termination action.
std::string m_outfileName
produced file name
StoreObjPtr< ROIpayload > m_ROIPayloads
ROIpayload StoreArray.
FILE * m_pFile
file handler
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.