Belle II Software  release-05-02-19
SubEventModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Pulvermacher *
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/datastore/StoreArray.h>
16 #include <boost/optional.hpp>
17 #include <memory>
18 
19 namespace Belle2 {
24  class Path;
27  class SubEventModule : public Module, public EventProcessor {
28  public:
30  enum EModes {
31  c_ForEach = 0,
32  c_DoWhile = 1,
33  };
34 
36  ~SubEventModule();
37 
39  void initSubEvent(const std::string& objectName, const std::string& loopOver, std::shared_ptr<Path> path);
41  void initSubLoop(std::shared_ptr<Path> path, const std::string& condition, unsigned int maxIterations);
42 
43  virtual void initialize() override;
44  virtual void beginRun() override;
45  virtual void endRun() override;
46  virtual void event() override;
47  virtual void terminate() override;
48 
49  private:
51  void setProperties();
55  void setDoWhileConditions();
57  boost::optional<std::string> m_objectName{boost::none};
59  boost::optional<std::string> m_loopOverName{boost::none};
61  StoreArray<TObject> m_loopOver;
63  std::shared_ptr<Path> m_path;
66  int m_processID{ -1};
68  unsigned int m_maxIterations{10000};
70  boost::optional<std::string> m_loopConditionString{boost::none};
72  std::unique_ptr<ModuleCondition> m_loopCondition;
76  int m_mode{c_ForEach};
77  };
79 }
Belle2::SubEventModule::m_loopCondition
std::unique_ptr< ModuleCondition > m_loopCondition
Condition object to evaluate if the loop is finished in case of doWhile()
Definition: SubEventModule.h:80
Belle2::SubEventModule::m_maxIterations
unsigned int m_maxIterations
maximum number of iterations before giving up in case of doWhile()
Definition: SubEventModule.h:76
Belle2::SubEventModule::m_mode
int m_mode
Mode for this module.
Definition: SubEventModule.h:84
Belle2::SubEventModule::m_objectName
boost::optional< std::string > m_objectName
name of our loop variable in case of forEach.
Definition: SubEventModule.h:65
Belle2::SubEventModule::m_loopConditionModule
Module * m_loopConditionModule
pointer to the module to provide the returnValue in case of doWhile()
Definition: SubEventModule.h:82
Belle2::SubEventModule::m_loopOverName
boost::optional< std::string > m_loopOverName
name for m_loopOver in case of forEach.
Definition: SubEventModule.h:67
Belle2::SubEventModule
Framework-internal module that implements the functionality of Path::forEach() as well as Path::doWhi...
Definition: SubEventModule.h:35
Belle2::SubEventModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: SubEventModule.cc:224
Belle2::SubEventModule::m_loopConditionString
boost::optional< std::string > m_loopConditionString
String for the condition when looping.
Definition: SubEventModule.h:78
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SubEventModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: SubEventModule.cc:181
Belle2::SubEventModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: SubEventModule.cc:147
Belle2::SubEventModule::initSubLoop
void initSubLoop(std::shared_ptr< Path > path, const std::string &condition, unsigned int maxIterations)
ised by Path::doWhile() to actually set parameters
Definition: SubEventModule.cc:61
Belle2::SubEventModule::event
virtual void event() override
This method is the core of the module.
Definition: SubEventModule.cc:235
Belle2::SubEventModule::initSubEvent
void initSubEvent(const std::string &objectName, const std::string &loopOver, std::shared_ptr< Path > path)
used by Path::forEach() to actually set parameters.
Definition: SubEventModule.cc:52
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SubEventModule::setDoWhileConditions
void setDoWhileConditions()
Set the necessary pointers for do_while(): the pointer to the module whose return value we'll use as ...
Definition: SubEventModule.cc:72
Belle2::SubEventModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: SubEventModule.cc:212
Belle2::SubEventModule::m_processID
int m_processID
when using multi-processing contains the ID of the process where event() is called (in that process o...
Definition: SubEventModule.h:74
Belle2::SubEventModule::m_loopOver
StoreArray< TObject > m_loopOver
array looped over in case of forEach
Definition: SubEventModule.h:69
Belle2::SubEventModule::setProperties
void setProperties()
Set properties for this module based on the modules found in m_path.
Definition: SubEventModule.cc:124
Belle2::SubEventModule::m_path
std::shared_ptr< Path > m_path
Path to execute.
Definition: SubEventModule.h:71
Belle2::SubEventModule::EModes
EModes
Define the constants for the different modes.
Definition: SubEventModule.h:38