Belle II Software  release-08-01-10
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/pxdDataReduction/ROIReadTestModule.h>
10 
11 using namespace Belle2;
12 
13 //-----------------------------------------------------------------
14 // Register the Module
15 //-----------------------------------------------------------------
16 
17 REG_MODULE(ROIReadTest);
18 
19 //-----------------------------------------------------------------
20 // Implementation
21 //-----------------------------------------------------------------
22 
24 {
25  //Set module properties
26  setDescription("check the payload produced by the ROIPayloadAssembler Module");
27  // setPropertyFlags(c_ParallelProcessingCertified);
28 
29  addParam("outfileName", m_outfileName, "name of the output file", std::string("ROIpayload.txt"));
30  addParam("ROIpayloadName", m_ROIpayloadName, "name of the payload of ROIs", std::string(""));
31 
32 }
33 
35 {
36  m_ROIPayloads.isRequired(m_ROIpayloadName);
37 
38  m_pFile = fopen(m_outfileName.c_str(), "w+");
39  if (!m_pFile) {
40  B2FATAL("Could not open " << m_outfileName);
41  }
42 }
43 
45 {
46  int length = m_ROIPayloads->getLength();
47  unsigned char* rootdata = (unsigned char*) m_ROIPayloads->getRootdata();
48 
49  if (!m_pFile) return;
50  for (int i = 0; i < 4 * length; i++) {
51  fputc(rootdata[i], m_pFile);
52  }
53 }
54 
56 {
57  fclose(m_pFile);
58  m_pFile = nullptr;
59 }
60 
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
REG_MODULE(arichBtest)
Register the Module.
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
Abstract base class for different kinds of events.