Class Reference for E1039 Core & Analysis Software
Fun4AllServer.h
Go to the documentation of this file.
1 #ifndef FUN4ALLSERVER_H
2 #define FUN4ALLSERVER_H
3 
4 #include "Fun4AllBase.h"
5 #include "Fun4AllHistoManager.h"
6 
7 #include <phool/PHTimer2.h>
8 
9 #include <iostream>
10 #include <map>
11 #include <string>
12 #include <vector>
13 
15 class Fun4AllSyncManager;
17 class PHCompositeNode;
18 class PHTimeStamp;
19 class SubsysReco;
20 class TDirectory;
21 class TH1;
22 class TNamed;
23 
24 class Fun4AllServer : public Fun4AllBase
25 {
26  public:
27  static Fun4AllServer *instance();
28  virtual ~Fun4AllServer();
29 
30  virtual bool registerHisto(const char *hname, TNamed *h1d, const int replace = 0);
31  virtual bool registerHisto(TNamed *h1d, const int replace = 0);
32  template <typename T>
33  T *makeHisto(T *t)
34  {
35  return ServerHistoManager->makeHisto(t);
36  }
37  virtual int isHistoRegistered(const std::string &name) const;
38 
39  int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename = "TOP");
40  int unregisterSubsystem(SubsysReco *subsystem);
41  SubsysReco *getSubsysReco(const std::string &name);
43  Fun4AllOutputManager *getOutputManager(const std::string &name);
45  Fun4AllHistoManager *getHistoManager(const std::string &name);
46  TNamed *getHisto(const std::string &hname) const;
47  TNamed *getHisto(const unsigned int ihisto) const;
48  const char *getHistoName(const unsigned int ihisto) const;
49  virtual void Print(const std::string &what = "ALL") const;
50 
51  void InitAll();
52  int BeginRunTimeStamp(PHTimeStamp &TimeStp);
53  int dumpHistos(const std::string &filename = "", const std::string &openmode = "RECREATE");
55  int Reset();
56  virtual int BeginRun(const int runno);
57  virtual int EndRun(const int runno = 0);
58  virtual int End();
59  PHCompositeNode *topNode() const { return TopNode; }
60  PHCompositeNode *topNode(const std::string &name);
61  int outfileclose();
62  virtual int process_event();
63  PHCompositeNode *getNode(const char *name, const char *topnodename = "TOP");
64  int AddTopNode(const std::string &name);
65  int MakeNodesTransient(PHCompositeNode *startNode);
66  int MakeNodesPersistent(PHCompositeNode *startNode);
67 
68  int AddComplaint(const std::string &complaint, const std::string &remedy);
69 
70  // Interface to the default Input Master
72  Fun4AllInputManager *getInputManager(const char *name);
73  int PrdfEvents() const;
74  int DstEvents() const;
75 
77  int run(const int nevnts = 0, const bool require_nevents = false);
78 
83  int skip(const int nevnts = 0);
84 
85  int fileopen(const char *managername = "NONE", const char *filename = "NONE");
86  int fileclose(const std::string &managername = "");
87  int SegmentNumber();
88  int ResetNodeTree();
89  int BranchSelect(const char *managername, const char *branch, int iflag);
90  int BranchSelect(const char *branch, int iflag);
91  int setBranches(const char *managername);
92  int setBranches();
93  virtual int DisconnectDB();
94  virtual void identify(std::ostream &out = std::cout) const;
95  unsigned GetTopNodes(std::vector<std::string> &names) const;
96  void GetInputFullFileList(std::vector<std::string> &fnames) const;
97  void GetOutputManagerList(std::vector<std::string> &names) const;
98  void GetModuleList(std::vector<std::string> &names) const;
99  Fun4AllSyncManager *getSyncManager(const std::string &name = "DefaultSyncManager");
100  int registerSyncManager(Fun4AllSyncManager *newmaster);
101  int retcodestats(const int iret) { return retcodesmap[iret]; }
102  void EventNumber(const int evtno) { eventnumber = evtno; }
103  void NodeIdentify(const std::string &name);
104  void KeepDBConnection(const int i = 1) { keep_db_connected = i; }
105 
106  void PrintTimer(const std::string &name = "");
107  void ReadSpillTimer(double& time_subsys, double& time_output);
108  void ResetSpillTimer();
109 
110  int getRun() const { return runnumber; }
111  int setRun(const int runno);
112 
113  protected:
114  Fun4AllServer(const std::string &name = "Fun4AllServer");
116  int CountOutNodes(PHCompositeNode *startNode);
117  int CountOutNodesRecursive(PHCompositeNode *startNode, const int icount);
127  std::vector<std::string> ComplaintList;
129  std::vector<std::pair<SubsysReco *, PHCompositeNode *> > Subsystems;
130  std::vector<std::pair<SubsysReco *, PHCompositeNode *> > DeleteSubsystems;
131  std::vector<int> RetCodes;
132  std::vector<Fun4AllOutputManager *> OutputManager;
133  std::vector<TDirectory *> TDirCollection;
135  std::vector<Fun4AllHistoManager *> HistoManager;
136  std::map<std::string, PHCompositeNode *> topnodemap;
138  std::string default_Tdirectory;
140  std::vector<Fun4AllSyncManager *> SyncManagers;
141  std::map<int, int> retcodesmap;
142 
143  std::map<const std::string, PHTimer2> timer_map;
146 
149 };
150 
151 #endif /* __FUN4ALLSERVER_H */
void ResetSpillTimer()
void GetModuleList(std::vector< std::string > &names) const
int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename="TOP")
int retcodestats(const int iret)
Fun4AllInputManager * getInputManager(const char *name)
int run(const int nevnts=0, const bool require_nevents=false)
run n events (0 means up to end of file)
virtual int DisconnectDB()
std::vector< std::string > ComplaintList
virtual int isHistoRegistered(const std::string &name) const
T * makeHisto(T *t)
Definition: Fun4AllServer.h:33
void GetOutputManagerList(std::vector< std::string > &names) const
void ReadSpillTimer(double &time_subsys, double &time_output)
int InitNodeTree(PHCompositeNode *topNode)
Fun4AllSyncManager * defaultSyncManager
int CountOutNodesRecursive(PHCompositeNode *startNode, const int icount)
int registerHistoManager(Fun4AllHistoManager *manager)
int unregisterSubsystemsNow()
static Fun4AllServer * instance()
std::vector< std::pair< SubsysReco *, PHCompositeNode * > > Subsystems
const char * getHistoName(const unsigned int ihisto) const
int AddComplaint(const std::string &complaint, const std::string &remedy)
virtual bool registerHisto(const char *hname, TNamed *h1d, const int replace=0)
virtual int EndRun(const int runno=0)
int UpdateEventSelector(Fun4AllOutputManager *manager)
std::vector< int > RetCodes
int dumpHistos(const std::string &filename="", const std::string &openmode="RECREATE")
std::vector< Fun4AllOutputManager * > OutputManager
std::vector< Fun4AllSyncManager * > SyncManagers
virtual int process_event()
PHCompositeNode * topNode() const
Definition: Fun4AllServer.h:59
int CountOutNodes(PHCompositeNode *startNode)
PHTimer2 * timer_sp_output
Measure the time used by OutputManager in process_event().
int DstEvents() const
int AddTopNode(const std::string &name)
int BranchSelect(const char *managername, const char *branch, int iflag)
int PrdfEvents() const
int fileopen(const char *managername="NONE", const char *filename="NONE")
Fun4AllSyncManager * getSyncManager(const std::string &name="DefaultSyncManager")
int registerSyncManager(Fun4AllSyncManager *newmaster)
std::vector< Fun4AllHistoManager * > HistoManager
PHTimer2 * timer_sp_subsys
Measure the time used by SubsysReco in process_event().
Fun4AllServer(const std::string &name="Fun4AllServer")
int MakeNodesTransient(PHCompositeNode *startNode)
PHCompositeNode * TopNode
int registerOutputManager(Fun4AllOutputManager *manager)
void NodeIdentify(const std::string &name)
TNamed * getHisto(const std::string &hname) const
int unregisterSubsystem(SubsysReco *subsystem)
virtual void identify(std::ostream &out=std::cout) const
int skip(const int nevnts=0)
skip n events (0 means up to the end of file). Skip means read, don't process.
int registerInputManager(Fun4AllInputManager *InManager)
std::vector< std::pair< SubsysReco *, PHCompositeNode * > > DeleteSubsystems
virtual int End()
std::string default_Tdirectory
std::map< const std::string, PHTimer2 > timer_map
Fun4AllOutputManager * getOutputManager(const std::string &name)
int getRun() const
PHCompositeNode * getNode(const char *name, const char *topnodename="TOP")
unsigned GetTopNodes(std::vector< std::string > &names) const
std::map< int, int > retcodesmap
void GetInputFullFileList(std::vector< std::string > &fnames) const
void EventNumber(const int evtno)
SubsysReco * getSubsysReco(const std::string &name)
int MakeNodesPersistent(PHCompositeNode *startNode)
int setRun(const int runno)
PHTimeStamp * beginruntimestamp
Fun4AllHistoManager * ServerHistoManager
void KeepDBConnection(const int i=1)
std::vector< TDirectory * > TDirCollection
virtual void Print(const std::string &what="ALL") const
void PrintTimer(const std::string &name="")
std::map< std::string, PHCompositeNode * > topnodemap
virtual ~Fun4AllServer()
Fun4AllHistoManager * getHistoManager(const std::string &name)
int fileclose(const std::string &managername="")
static Fun4AllServer * __instance
virtual int BeginRun(const int runno)
int BeginRunTimeStamp(PHTimeStamp &TimeStp)
Class to measure the time spent by a code block.
Definition: PHTimer2.h:17