EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ModuleHandler.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ModuleHandler.h
1 #ifndef MODULEHANDLER_HH
2 #define MODULEHANDLER_HH
3 
4 #include <iostream>
5 #include <vector>
6 
7 #include "TTree.h"
8 #include "external/ExRootAnalysis/ExRootTreeReader.h"
9 
10 #include "Module.h"
11 #include "CharmJetModule.h"
12 #include "KaonPIDModule.h"
13 #include "ElectronPIDModule.h"
14 #include "MuonPIDModule.h"
15 #include "TaggingModule.h"
16 #include "TaggingStudyModule.h"
17 #include "EventSelectionModule.h"
18 
19 using namespace std;
20 
23  std::vector<Module*> module_sequence;
24 
25  // Private constructor so that no objects can be created.
26  ModuleHandler(ExRootTreeReader* data) {
27  module_sequence = std::vector<Module*>();
28  _data = data;
29  }
30 
31  public:
32 
33  static ModuleHandler *getInstance(ExRootTreeReader* data) {
34  if (!instance)
35  instance = new ModuleHandler(data);
36  return instance;
37  }
38 
39  std::vector<Module*> getModules() {
40  return this -> module_sequence;
41  }
42 
43  void addModule(std::string name) {
44  Module* module = nullptr;
45 
46  if (name == "CharmJetModule") {
47  module = new CharmJetModule(_data);
48  }
49  else if (name == "KaonPIDModule") {
50  module = new KaonPIDModule(_data);
51  }
52  else if (name == "ElectronPIDModule") {
53  module = new ElectronPIDModule(_data);
54  }
55  else if (name == "MuonPIDModule") {
56  module = new MuonPIDModule(_data);
57  }
58  else if (name == "TaggingModule") {
59  module = new TaggingModule(_data);
60  }
61  else if (name == "TaggingStudyModule") {
62  module = new TaggingStudyModule(_data);
63  }
64  else if (name == "EventSelectionModule") {
65  module = new EventSelectionModule(_data);
66  } else {
67  std::cout << "ModuleHandler(): The requested module, " << name << ", is unknown to the ModuleHandler!" << std::endl;
68  assert(1==1);
69  }
70 
71  if (module != nullptr)
72  this -> module_sequence.push_back(module);
73  }
74 
75  private:
76  ExRootTreeReader* _data = nullptr;
77 
78 };
79 
80 #endif