Diana Software
QDriver.hh
Go to the documentation of this file.
1 
22 #ifndef _Q_DRIVER_H_
23 #define _Q_DRIVER_H_
24 
25 #include "QBaseModule.hh"
26 #include "QOptions.hh"
27 #include <vector>
28 
30 
31 
32 class QDriver : public QBaseModule {
33 
34  public:
35 
37 
38  virtual ~QDriver() {};
39 
41  enum ActionId {
56  };
57 
59  class Action {
60  public:
61  Action() {};
62  Action(ActionId id) { fActionId = id; }
65  };
66 
68  virtual Action Init(QEventAssembler& eva);
69 
71  virtual Action Do(QEventAssembler& eva);
73  virtual Action Do(QEventAssembler& eva, const QEventList& neigh);
74 
76  virtual Action Done() = 0;
77 
78  protected:
79 
81  const std::vector<QBaseModule*>& GetModulesList() const { return fModules; };
82 
84  std::map<std::string, QVdt*> GetModuleParameters(const std::string& name, int occ) { return QOptions::GetInstance().GetModuleParameters(GetSequence().GetName(), name,occ);}
85 
87  QSequence& GetSequence() const {return *my_sequence;}
88 
89  private:
91  void Begin(QEventAssembler& eva);
92 
94  bool Process( QEventAssembler& eva, QEventList& neigh,const bool exec, QEventList& oneigh);
95 
97  void End();
98 
100  void HandleAction(Action action);
101 
103  bool StopRun() { return fStopRun; }
104 
106  void SetModulesList(const std::vector<QBaseModule*>& modList) { fModules = modList; }
107 
109  const QError& JumpToEvent(Long64_t event) { return GetSequence().JumpToEvent(event,this); }
110 
111 
115  bool fStopRun;
117  bool fSkip;
121  std::vector<QBaseModule*> fModules;
124 
125  friend class QSequence;
126 
127 };
128 
130 
131 
132 #undef REGISTER_MODULE
133 #define REGISTER_MODULE(clazz) REGISTER_MOD(clazz,Diana::QDriver)
134 
135 
136 #endif
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
Base class for modules.
Definition: QBaseModule.hh:57
QSequence * my_sequence
Definition: QBaseModule.hh:190
const std::string & GetName() const
Get Module name.
Definition: QBaseModule.hh:131
class to store ActionId and fEventNumber (in case fActionId=ACT_GOTOEV)
Definition: QDriver.hh:59
int fEventNumber
Definition: QDriver.hh:64
Action(ActionId id)
Definition: QDriver.hh:62
ActionId fActionId
Definition: QDriver.hh:63
Base class for diana drivers.
Definition: QDriver.hh:32
QDriver()
Definition: QDriver.hh:36
void End()
End method is called after event loop and calls Done()
Definition: QDriver.cc:46
void SetModulesList(const std::vector< QBaseModule * > &modList)
method used by QSequence to set the list of modules in the QSequence
Definition: QDriver.hh:106
bool fStopRun
stop run or not
Definition: QDriver.hh:115
QSequence & GetSequence() const
get non-const reference to this sequence
Definition: QDriver.hh:87
std::map< std::string, QVdt * > GetModuleParameters(const std::string &name, int occ)
get list of parameters for a given QBaseModule with name name and occurrence occ
Definition: QDriver.hh:84
virtual Action Done()=0
Done method is called after event loop.
void Begin(QEventAssembler &eva)
Begin method is called before event loop, and calls Init()
Definition: QDriver.cc:27
virtual Action Do(QEventAssembler &eva)
Do method is called for each event, getting the QEventAssembler as argument.
Definition: QDriver.cc:16
virtual Action Init(QEventAssembler &eva)
Init method is called before event loop.
Definition: QDriver.cc:9
bool Process(QEventAssembler &eva, QEventList &neigh, const bool exec, QEventList &oneigh)
Process method is called for each event, getting the QEventAssembler as argument and calls Do()
Definition: QDriver.cc:54
int fCurrentEventNumber
current event number to make ACT_PREV use JumpToEvent(fCurrentEventNumber-1)
Definition: QDriver.hh:119
bool fSkip
skip event
Definition: QDriver.hh:117
bool StopRun()
method used by QSequence to check if the run should be stopped
Definition: QDriver.hh:103
const QError & JumpToEvent(Long64_t event)
next iteration diana will jump to event
Definition: QDriver.hh:109
std::vector< QBaseModule * > fModules
list of current modules
Definition: QDriver.hh:121
void HandleAction(Action action)
internal method to handle action returned by inheriting classes
Definition: QDriver.cc:71
virtual ~QDriver()
Definition: QDriver.hh:38
bool fSkipEvents
skip filtered events
Definition: QDriver.hh:123
ActionId
actions that the driver can perform
Definition: QDriver.hh:41
@ ACT_NONE
Definition: QDriver.hh:43
@ ACT_PREVEV
Definition: QDriver.hh:49
@ ACT_NEXTEV
Definition: QDriver.hh:45
@ ACT_GOTOEV
Definition: QDriver.hh:51
@ ACT_RERUN
Definition: QDriver.hh:53
@ ACT_SKIP
Definition: QDriver.hh:47
@ ACT_QUIT
Definition: QDriver.hh:55
const std::vector< QBaseModule * > & GetModulesList() const
get const list of QBaseModule (s) in the QSequence
Definition: QDriver.hh:81
Action fLastAction
last action performed
Definition: QDriver.hh:113
error class with error type and description
Definition: QError.hh:115
Visitor class of QEvent that provides full handling of QEvent.
list of references to const QEvent (s)
Definition: QEventList.hh:21
std::map< std::string, QVdt * > GetModuleParameters(const std::string &seq, const std::string &mod, size_t occ)
Definition: QOptions.cc:580
static QOptions & GetInstance()
Definition: QOptions.cc:23
Diana Reconstruction program.
Definition: QSequence.hh:40
const QError & JumpToEvent(Long64_t event, QBaseModule *caller)
Jump to an event in a particular in a module.
Definition: QSequence.cc:325