ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4AllServer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4AllServer.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef FUN4ALL_FUN4ALLSERVER_H
4 #define FUN4ALL_FUN4ALLSERVER_H
5 
6 #include "Fun4AllBase.h"
7 
8 #include "Fun4AllHistoManager.h" // for Fun4AllHistoManager
9 
10 #include <phool/PHTimer.h>
11 
12 #include <iostream>
13 #include <map>
14 #include <string>
15 #include <utility> // for pair
16 #include <vector>
17 
20 class Fun4AllSyncManager;
22 class PHCompositeNode;
23 class PHTimeStamp;
24 class SubsysReco;
25 class TDirectory;
26 class TH1;
27 class TNamed;
28 
29 class Fun4AllServer : public Fun4AllBase
30 {
31  public:
32  static Fun4AllServer *instance();
33  ~Fun4AllServer() override;
34 
35  virtual bool registerHisto(const std::string &hname, TNamed *h1d, const int replace = 0);
36  virtual bool registerHisto(TNamed *h1d, const int replace = 0);
37  template <typename T>
39  {
40  return ServerHistoManager->makeHisto(t);
41  }
42  virtual int isHistoRegistered(const std::string &name) const;
43 
44  int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename = "TOP");
45  int unregisterSubsystem(SubsysReco *subsystem);
46  SubsysReco *getSubsysReco(const std::string &name);
48  Fun4AllOutputManager *getOutputManager(const std::string &name);
50  Fun4AllHistoManager *getHistoManager(const std::string &name);
51  TNamed *getHisto(const std::string &hname) const;
52  TNamed *getHisto(const unsigned int ihisto) const;
53  std::string getHistoName(const unsigned int ihisto) const;
54  void Print(const std::string &what = "ALL") const override;
55 
56  void InitAll();
57  int BeginRunTimeStamp(PHTimeStamp &TimeStp);
58  int dumpHistos(const std::string &filename, const std::string &openmode = "RECREATE");
59  int Reset();
60  virtual int BeginRun(const int runno);
61  virtual int EndRun(const int runno = 0);
62  virtual int End();
63  PHCompositeNode *topNode() const { return TopNode; }
64  PHCompositeNode *topNode(const std::string &name);
65  int outfileclose();
66  virtual int process_event();
67  PHCompositeNode *getNode(const std::string &name, const std::string &topnodename = "TOP");
68  int AddTopNode(const std::string &name);
69  int MakeNodesTransient(PHCompositeNode *startNode);
70  int MakeNodesPersistent(PHCompositeNode *startNode);
71 
72  int AddComplaint(const std::string &complaint, const std::string &remedy);
73 
74  // Interface to the default Input Master
76  Fun4AllInputManager *getInputManager(const std::string &name);
77  int PrdfEvents() const;
78  int DstEvents() const;
79 
81  int run(const int nevnts = 0, const bool require_nevents = false);
82 
87  int skip(const int nevnts = 0);
88 
89  int fileopen(const std::string &managername, const std::string &filename);
90  int fileclose(const std::string &managername);
91  int SegmentNumber();
92  int ResetNodeTree();
93  int BranchSelect(const std::string &managername, const std::string &branch, int iflag);
94  int BranchSelect(const std::string &branch, int iflag);
95  int setBranches(const std::string &managername);
96  int setBranches();
97  virtual int DisconnectDB();
98  virtual void identify(std::ostream &out = std::cout) const;
99  unsigned GetTopNodes(std::vector<std::string> &names) const;
100  void GetInputFullFileList(std::vector<std::string> &fnames) const;
101  void GetOutputManagerList(std::vector<std::string> &names) const;
102  void GetModuleList(std::vector<std::string> &names) const;
103  Fun4AllSyncManager *getSyncManager(const std::string &name = "DefaultSyncManager");
104  int registerSyncManager(Fun4AllSyncManager *newmaster);
105  int retcodestats(const int iret) { return retcodesmap[iret]; }
106  void EventNumber(const int evtno) { eventnumber = evtno; }
107  int EventNumber() const { return eventnumber; }
108  void NodeIdentify(const std::string &name);
109  void KeepDBConnection(const int i = 1) { keep_db_connected = i; }
110  void PrintTimer(const std::string &name = "");
111  void PrintMemoryTracker(const std::string &name = "") const;
112  int RunNumber() const {return runnumber;}
113  int EventCounter() const {return eventcounter;}
114 
115  protected:
116  Fun4AllServer(const std::string &name = "Fun4AllServer");
118  int CountOutNodes(PHCompositeNode *startNode);
119  int CountOutNodesRecursive(PHCompositeNode *startNode, const int icount);
122  int setRun(const int runnumber);
130 
131  int OutNodeCount = 0;
135  int runnumber = 0;
136  int eventnumber = 0;
137  int eventcounter = 0;
139 
140  std::vector<std::string> ComplaintList;
141  std::vector<std::pair<SubsysReco *, PHCompositeNode *> > Subsystems;
142  std::vector<std::pair<SubsysReco *, PHCompositeNode *> > DeleteSubsystems;
143  std::vector<int> RetCodes;
144  std::vector<Fun4AllOutputManager *> OutputManager;
145  std::vector<TDirectory *> TDirCollection;
146  std::vector<Fun4AllHistoManager *> HistoManager;
147  std::map<std::string, PHCompositeNode *> topnodemap;
148  std::string default_Tdirectory;
149  std::vector<Fun4AllSyncManager *> SyncManagers;
150  std::map<int, int> retcodesmap;
151  std::map<const std::string, PHTimer> timer_map;
152 };
153 
154 #endif