Belle II Software  release-05-02-19
pEventProcessor.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Ryosuke Itoh *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/Module.h>
14 #include <framework/core/EventProcessor.h>
15 #include <framework/core/Path.h>
16 
17 
18 namespace Belle2 {
24  class ProcHandler;
25  class RingBuffer;
26 
30  class pEventProcessor : public EventProcessor {
31 
32  public:
33 
36 
38  virtual ~pEventProcessor();
39 
47  void process(const PathPtr& spath, long maxEvent);
48 
55  void gotSigINT();
56 
61  void killRingBuffers();
62 
64  void cleanup();
65 
66  private:
68  void analyzePath(const PathPtr& path);
69 
71  void preparePaths();
72 
74  RingBuffer* connectViaRingBuffer(const char* name, const PathPtr& a, PathPtr& b);
75 
77  void dump_modules(const std::string&, const ModulePtrList&);
78 
84  void clearFileList();
85 
91  static void prependModulesIfNotPresent(ModulePtrList* modules, const ModulePtrList& prependModules);
92 
93  private:
95  std::unique_ptr<ProcHandler> m_procHandler;
96 
103 
105  RingBuffer* m_rbin = nullptr;
107  RingBuffer* m_rbout = nullptr;;
108 
111 
112  };
113 
115 }
Belle2::pEventProcessor::cleanup
void cleanup()
clean up IPC resources (should only be called in one process).
Definition: pEventProcessor.cc:75
Belle2::pEventProcessor::m_histoman
ModulePtr m_histoman
Pointer to HistoManagerModule, or nullptr if not found.
Definition: pEventProcessor.h:115
Belle2::pEventProcessor::getModulesWithoutFlag
static ModulePtrList getModulesWithoutFlag(const ModulePtrList &modules, Module::EModulePropFlags flag)
Return only modules which do not have the given Module flag set.
Definition: pEventProcessor.cc:443
Belle2::pEventProcessor::m_rbin
RingBuffer * m_rbin
input RingBuffer
Definition: pEventProcessor.h:113
Belle2::pEventProcessor::m_procHandler
std::unique_ptr< ProcHandler > m_procHandler
handler to fork and manage processes.
Definition: pEventProcessor.h:103
Belle2::pEventProcessor::clearFileList
void clearFileList()
TFiles are stored in a global list and cleaned up by root since this will happen in all forked proces...
Definition: pEventProcessor.cc:99
Belle2::pEventProcessor::getModulesWithFlag
static ModulePtrList getModulesWithFlag(const ModulePtrList &modules, Module::EModulePropFlags flag)
Return only modules which have the given Module flag set.
Definition: pEventProcessor.cc:433
Belle2::pEventProcessor::gotSigINT
void gotSigINT()
signal handler for Ctrl+C (async-safe)
Definition: pEventProcessor.cc:86
Belle2::pEventProcessor::m_outputPath
PathPtr m_outputPath
Output path.
Definition: pEventProcessor.h:110
Belle2::RingBuffer
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:36
Belle2::pEventProcessor::process
void process(const PathPtr &spath, long maxEvent)
Processes the full module chain, starting with the first module in the given path.
Definition: pEventProcessor.cc:107
Belle2::pEventProcessor::pEventProcessor
pEventProcessor()
Constructor.
Definition: pEventProcessor.cc:62
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ModulePtrList
std::list< ModulePtr > ModulePtrList
Defines a std::list of shared module pointers.
Definition: Module.h:586
Belle2::PathPtr
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:30
Belle2::ModulePtr
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:42
Belle2::pEventProcessor::analyzePath
void analyzePath(const PathPtr &path)
Analyze given path.
Definition: pEventProcessor.cc:296
Belle2::pEventProcessor::~pEventProcessor
virtual ~pEventProcessor()
Destructor.
Definition: pEventProcessor.cc:69
Belle2::Module::EModulePropFlags
EModulePropFlags
Each module can be tagged with property flags, which indicate certain features of the module.
Definition: Module.h:79
Belle2::pEventProcessor::preparePaths
void preparePaths()
Adds internal modules to paths, prepare RingBuffers.
Definition: pEventProcessor.cc:398
Belle2::pEventProcessor::connectViaRingBuffer
RingBuffer * connectViaRingBuffer(const char *name, const PathPtr &a, PathPtr &b)
Create RingBuffer with name from given environment variable, add Tx and Rx modules to a and b.
Definition: pEventProcessor.cc:373
Belle2::pEventProcessor::dump_modules
void dump_modules(const std::string &, const ModulePtrList &)
Dump module names in the ModulePtrList.
Definition: pEventProcessor.cc:413
Belle2::pEventProcessor::m_rbout
RingBuffer * m_rbout
output RingBuffer
Definition: pEventProcessor.h:115
Belle2::pEventProcessor::m_inputPath
PathPtr m_inputPath
Input path.
Definition: pEventProcessor.h:106
Belle2::pEventProcessor::prependModulesIfNotPresent
static void prependModulesIfNotPresent(ModulePtrList *modules, const ModulePtrList &prependModules)
Prepend given 'prependModules' to 'modules', if they're not already present.
Definition: pEventProcessor.cc:453
Belle2::pEventProcessor::m_mainPath
PathPtr m_mainPath
Main (parallel section) path.
Definition: pEventProcessor.h:108
Belle2::pEventProcessor::killRingBuffers
void killRingBuffers()
signal handler (async-safe)
Definition: pEventProcessor.cc:92