Belle II Software development
DAQPerf.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 <daq/dataflow/modules/DAQPerf.h>
10
11#include <framework/datastore/StoreArray.h>
12#include <rawdata/dataobjects/RawCOPPER.h>
13
14//#define MAXEVTSIZE 400000000
15
16using namespace std;
17using namespace Belle2;
18
19//-----------------------------------------------------------------
20// Register the Module
21//-----------------------------------------------------------------
22REG_MODULE(DAQPerf);
23
24//-----------------------------------------------------------------
25// Implementation
26//-----------------------------------------------------------------
27
29{
30 //Set module properties
31 setDescription("Monitor DAQ transfer performance");
32 // setPropertyFlags(c_Input | c_ParallelProcessingCertified);
33
34 addParam("Cycle", m_ncycle, "Monitor cycle", 10000);
35 addParam("MonitorSize", m_mon, "SW to monitor data flow", false);
36
37 //Parameter definition
38 B2INFO("Rx: Constructor done.");
39}
40
41
42DAQPerfModule::~DAQPerfModule()
43{
44}
45
47{
48 m_nevent = 0;
49 m_t0.tv_sec = 0;
50 m_t0.tv_usec = 0;
51 m_totbytes = 0;
52}
53
54
56{
57}
58
59
61{
62 if (m_nevent % m_ncycle == 0) {
63 if (m_t0.tv_sec == 0) {
64 gettimeofday(&m_t0, NULL);
65 m_totbytes = 0;
66 } else {
67 timeval t;
68 gettimeofday(&t, NULL);
69 double now = (double)t.tv_sec + (double)t.tv_usec * 0.000001;
70 double t0 = (double)m_t0.tv_sec + (double)m_t0.tv_usec * 0.000001;
71 double elapsed = now - t0;
72 printf("Event = %d : took %5.2f sec for %d evts -> %5.2f kHz",
73 m_nevent, elapsed, m_ncycle, (double)m_ncycle / elapsed / 1000);
74 if (m_mon) {
75 double aveflow = m_totbytes / elapsed / 1000000.0;
76 m_totbytes = 0.0;
77 printf(", %3.2f (MB/s)", aveflow);
78 }
79 printf("\n");
80 gettimeofday(&m_t0, NULL);
81 }
82 }
83 // Calculate data size
84 if (m_mon) {
85 StoreArray<RawCOPPER> rawcprary;
86 double rawsize = 0;
87 for (int i = 0; i < rawcprary.getEntries(); ++i) {
88 rawsize += (double)(rawcprary[i]->TotalBufNwords());
89 }
90 m_totbytes += rawsize * 4;
91 }
92 m_nevent++;
93 return;
94 // return type;
95}
96
98{
99 //fill Run data
100}
101
102
104{
105}
106
void initialize() override
Module functions to be called from main process.
Definition: DAQPerf.cc:46
void event() override
This method is the core of the module.
Definition: DAQPerf.cc:60
void endRun() override
This method is called if the current run ends.
Definition: DAQPerf.cc:97
void terminate() override
This method is called at the end of the event processing.
Definition: DAQPerf.cc:103
DAQPerfModule()
Constructor / Destructor.
Definition: DAQPerf.cc:28
void beginRun() override
Module functions to be called from event process.
Definition: DAQPerf.cc:55
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
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.
STL namespace.