Analysis Software
Documentation for sPHENIX simulation 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 <deque>
13 #include <iostream>
14 #include <map>
15 #include <string>
16 #include <utility> // for pair
17 #include <vector>
18 
21 class Fun4AllSyncManager;
23 class PHCompositeNode;
24 class PHTimeStamp;
25 class SubsysReco;
26 class TDirectory;
27 class TH1;
28 class TNamed;
29 
30 class Fun4AllServer : public Fun4AllBase
31 {
32  public:
33  static Fun4AllServer *instance();
34  ~Fun4AllServer() override;
35 
36  // cppcheck-suppress [virtualCallInConstructor]
37  virtual bool registerHisto(const std::string &hname, TNamed *h1d, const int replace = 0);
38  virtual bool registerHisto(TNamed *h1d, const int replace = 0);
39  template <typename T>
41  {
42  return ServerHistoManager->makeHisto(t);
43  }
44  virtual int isHistoRegistered(const std::string &name) const;
45 
46  int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename = "TOP");
47  void addNewSubsystem(SubsysReco *subsystem, const std::string &topnodename = "TOP") { NewSubsystems.push_back(std::make_pair(subsystem, topnodename)); }
48  int unregisterSubsystem(SubsysReco *subsystem);
54  TNamed *getHisto(const std::string &hname) const;
55  TNamed *getHisto(const unsigned int ihisto) const;
56  std::string getHistoName(const unsigned int ihisto) const;
57  void Print(const std::string &what = "ALL") const override;
58 
59  void InitAll();
60  int BeginRunTimeStamp(PHTimeStamp &TimeStp);
61  int dumpHistos(const std::string &filename, const std::string &openmode = "RECREATE");
62  int Reset();
63  virtual int BeginRun(const int runno);
64  int BeginRunSubsystem(const std::pair<SubsysReco *, PHCompositeNode *> &subsys);
65  virtual int EndRun(const int runno = 0);
66  virtual int End();
67  PHCompositeNode *topNode() const { return TopNode; }
69  int outfileclose();
70  virtual int process_event();
71  PHCompositeNode *getNode(const std::string &name, const std::string &topnodename = "TOP");
72  int AddTopNode(const std::string &name);
73  int MakeNodesTransient(PHCompositeNode *startNode);
74  int MakeNodesPersistent(PHCompositeNode *startNode);
75 
76  int AddComplaint(const std::string &complaint, const std::string &remedy);
77 
78  // Interface to the default Input Master
81  int PrdfEvents() const;
82  int DstEvents() const;
83 
85  int run(const int nevnts = 0, const bool require_nevents = false);
86 
91  int skip(const int nevnts = 0);
92 
93  int fileopen(const std::string &managername, const std::string &filename);
94  int fileclose(const std::string &managername);
95  int SegmentNumber();
96  int ResetNodeTree();
97  int BranchSelect(const std::string &managername, const std::string &branch, int iflag);
98  int BranchSelect(const std::string &branch, int iflag);
99  int setBranches(const std::string &managername);
100  int setBranches();
101  virtual void identify(std::ostream &out = std::cout) const;
102  unsigned GetTopNodes(std::vector<std::string> &names) const;
103  void GetInputFullFileList(std::vector<std::string> &fnames) const;
104  void GetOutputManagerList(std::vector<std::string> &names) const;
105  void GetModuleList(std::vector<std::string> &names) const;
106  Fun4AllSyncManager *getSyncManager(const std::string &name = "DefaultSyncManager");
107  int registerSyncManager(Fun4AllSyncManager *newmaster);
108  int retcodestats(const int iret) { return retcodesmap[iret]; }
109  void EventNumber(const int evtno) { eventnumber = evtno; }
110  int EventNumber() const { return eventnumber; }
111  void NodeIdentify(const std::string &name);
112  void KeepDBConnection(const int i = 1) { keep_db_connected = i; }
113  void PrintTimer(const std::string &name = "");
114  void PrintMemoryTracker(const std::string &name = "") const;
115  int RunNumber() const { return runnumber; }
116  int EventCounter() const { return eventcounter; }
117  std::map<const std::string, PHTimer>::const_iterator timer_begin() { return timer_map.begin(); }
118  std::map<const std::string, PHTimer>::const_iterator timer_end() { return timer_map.end(); }
119 
120  protected:
121  Fun4AllServer(const std::string &name = "Fun4AllServer");
123  int CountOutNodes(PHCompositeNode *startNode);
124  int CountOutNodesRecursive(PHCompositeNode *startNode, const int icount);
127  int setRun(const int runnumber);
129  TH1 *FrameWorkVars = nullptr;
135 
136  int OutNodeCount = 0;
140  int runnumber = 0;
141  int eventnumber = 0;
142  int eventcounter = 0;
144 
145  std::vector<std::string> ComplaintList;
146  std::vector<std::pair<SubsysReco *, PHCompositeNode *>> Subsystems;
147  std::vector<std::pair<SubsysReco *, PHCompositeNode *>> DeleteSubsystems;
148  std::deque<std::pair<SubsysReco *, std::string>> NewSubsystems;
149  std::vector<int> RetCodes;
150  std::vector<Fun4AllOutputManager *> OutputManager;
151  std::vector<TDirectory *> TDirCollection;
152  std::vector<Fun4AllHistoManager *> HistoManager;
153  std::map<std::string, PHCompositeNode *> topnodemap;
155  std::vector<Fun4AllSyncManager *> SyncManagers;
156  std::map<int, int> retcodesmap;
157  std::map<const std::string, PHTimer> timer_map;
158 };
159 
160 #endif