Belle II Software  release-06-01-15
DQMHistAnalysisInputSrv.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 <dqm/analysis/modules/DQMHistAnalysisInputSrv.h>
10 
11 #include <TKey.h>
12 #include <TSystem.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 //-----------------------------------------------------------------
18 // Register the Module
19 //-----------------------------------------------------------------
20 REG_MODULE(DQMHistAnalysisInputSrv)
21 
22 //-----------------------------------------------------------------
23 // Implementation
24 //-----------------------------------------------------------------
25 
28 {
29  //Parameter definition
30  addParam("HistMemoryPath", m_mempath, "Path to Input Hist memory", string(""));
31  addParam("HistMemorySize", m_memsize, "Size of Input Hist memory", 10000000);
32  addParam("RefreshInterval", m_interval, "Refresh interval of histograms in ms", 2000);
33  B2DEBUG(20, "DQMHistAnalysisInputSrv: Constructor done.");
34 }
35 
36 
37 DQMHistAnalysisInputSrvModule::~DQMHistAnalysisInputSrvModule() { }
38 
39 void DQMHistAnalysisInputSrvModule::initialize()
40 {
41  if (m_memory != nullptr) delete m_memory;
42  m_memory = new DqmMemFile(m_mempath.c_str());
43  m_eventMetaDataPtr.registerInDataStore();
44  //m_serv = new THttpServer("http:8081");
45  //m_serv->SetReadOnly(kFALSE);
46  B2DEBUG(20, "DQMHistAnalysisInputSrv: initialized.");
47 }
48 
49 
50 void DQMHistAnalysisInputSrvModule::beginRun()
51 {
52  B2DEBUG(20, "DQMHistAnalysisInputSrv: beginRun called.");
53 }
54 
55 void DQMHistAnalysisInputSrvModule::event()
56 {
57  std::vector<TH1*> h;
58  TMemFile* file = m_memory->LoadMemFile();
59  file->cd();
60  TIter next(file->GetListOfKeys());
61  TKey* key = NULL;
62  while ((key = (TKey*)next())) {
63  h.push_back((TH1*)key->ReadObj());
64  }
65  resetHist();
66  for (size_t i = 0; i < h.size(); i++) {
67  addHist("", h[i]->GetName(), h[i]);
68  B2DEBUG(2, "Found : " << h[i]->GetName() << " : " << h[i]->GetEntries());
69  }
70  m_count++;
71  m_eventMetaDataPtr.create();
72  m_eventMetaDataPtr->setExperiment(m_expno);
73  m_eventMetaDataPtr->setRun(m_runno);
74  m_eventMetaDataPtr->setEvent(m_count);
75 
76  TTimer t(m_interval, kFALSE);// in ms
77 
78  do { // call at least once!
79  //m_serv->ProcessRequests();
80  //gSystem->Sleep(10); // 10 ms sleep
81  } while (!t.CheckTimer(gSystem->Now()));
82 
83 }
84 
85 void DQMHistAnalysisInputSrvModule::endRun()
86 {
87  B2DEBUG(20, "DQMHistAnalysisInputSrv: endRun called");
88 }
89 
90 
91 void DQMHistAnalysisInputSrvModule::terminate()
92 {
93  B2DEBUG(20, "DQMHistAnalysisInputSrv: terminate called");
94 }
95 
Class definition for the output module of Sequential ROOT I/O.
The base class for the histogram analysis module.
#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.