Belle II Software  release-05-02-19
ROIReadTestModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2011 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Giulia Casarosa, Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/datastore/StoreObjPtr.h>
12 #include <tracking/modules/pxdDataReduction/ROIReadTestModule.h>
13 #include <tracking/dataobjects/ROIpayload.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
21 
22 REG_MODULE(ROIReadTest)
23 
24 //-----------------------------------------------------------------
25 // Implementation
26 //-----------------------------------------------------------------
27 
29 {
30  //Set module properties
31  setDescription("check the payload produced by the ROIPayloadAssembler Module");
32  // setPropertyFlags(c_ParallelProcessingCertified);
33 
34  addParam("outfileName", m_outfileName, "name of the output file", std::string("ROIpayload.txt"));
35  addParam("ROIpayloadName", m_ROIpayloadName, "name of the payload of ROIs", std::string(""));
36 
37 }
38 
39 
40 void ROIReadTestModule::initialize()
41 {
42 
43  StoreObjPtr<ROIpayload> roiPayloads;
44  roiPayloads.isRequired(m_ROIpayloadName);
45 
46  m_pFile = fopen(m_outfileName.c_str(), "w+");
47  if (!m_pFile) {
48  B2FATAL("Could not open " << m_outfileName);
49  }
50 }
51 
52 
53 void ROIReadTestModule::event()
54 {
55 
56  StoreObjPtr<ROIpayload> payloadPtr(m_ROIpayloadName);
57  int length = payloadPtr->getLength();
58  unsigned char* rootdata = (unsigned char*) payloadPtr->getRootdata();
59 
60  if (!m_pFile) return;
61 
62  for (int i = 0; i < 4 * length; i++) {
63  // if ((i % 4) == 0) printf(" ");
64  // printf("%02x", rootdata[i]);
65  fputc(rootdata[i], m_pFile);
66  }
67 
68  // cout << endl;
69 
70 }
71 
72 
73 void ROIReadTestModule::terminate()
74 {
75  fclose(m_pFile);
76  m_pFile = nullptr;
77 }
78 
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::ROIReadTestModule
The ROI to ONSEN Module.
Definition: ROIReadTestModule.h:40