Belle II Software  release-06-02-00
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 <framework/datastore/StoreObjPtr.h>
10 #include <tracking/modules/pxdDataReduction/ROIReadTestModule.h>
11 #include <tracking/dataobjects/ROIpayload.h>
12 
13 using namespace std;
14 using namespace Belle2;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 
20 REG_MODULE(ROIReadTest)
21 
22 //-----------------------------------------------------------------
23 // Implementation
24 //-----------------------------------------------------------------
25 
27 {
28  //Set module properties
29  setDescription("check the payload produced by the ROIPayloadAssembler Module");
30  // setPropertyFlags(c_ParallelProcessingCertified);
31 
32  addParam("outfileName", m_outfileName, "name of the output file", std::string("ROIpayload.txt"));
33  addParam("ROIpayloadName", m_ROIpayloadName, "name of the payload of ROIs", std::string(""));
34 
35 }
36 
37 
38 void ROIReadTestModule::initialize()
39 {
40 
41  StoreObjPtr<ROIpayload> roiPayloads;
42  roiPayloads.isRequired(m_ROIpayloadName);
43 
44  m_pFile = fopen(m_outfileName.c_str(), "w+");
45  if (!m_pFile) {
46  B2FATAL("Could not open " << m_outfileName);
47  }
48 }
49 
50 
51 void ROIReadTestModule::event()
52 {
53 
54  StoreObjPtr<ROIpayload> payloadPtr(m_ROIpayloadName);
55  int length = payloadPtr->getLength();
56  unsigned char* rootdata = (unsigned char*) payloadPtr->getRootdata();
57 
58  if (!m_pFile) return;
59 
60  for (int i = 0; i < 4 * length; i++) {
61  // if ((i % 4) == 0) printf(" ");
62  // printf("%02x", rootdata[i]);
63  fputc(rootdata[i], m_pFile);
64  }
65 
66  // cout << endl;
67 
68 }
69 
70 
71 void ROIReadTestModule::terminate()
72 {
73  fclose(m_pFile);
74  m_pFile = nullptr;
75 }
76 
Base class for Modules.
Definition: Module.h:72
The ROI to ONSEN Module.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
#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.