HistoSource.h
Go to the documentation of this file.
1 #ifndef OM_HISTOFILE_H
2 #define OM_HISTOFILE_H
3 #include <list>
4 #include <string>
5 class TObject;
6 class TH1F;
7 class TH2F;
8 class TFile;
9 namespace om { class IPC; }
10 
11 namespace om {
12  ///
13  /// Define the base class for any source (root files, shared memory,
14  /// etc...) of histograms to be displayed by the viewer.
15  ///
17  {
18  public:
19  virtual ~HistoSourceBase() { }
20  public:
21  /// Set the source name.
22  virtual void SetName(const char* nm) = 0;
23 
24  /// Read a copy of a named histogram into memory. User accepts
25  /// ownership and responsibility for deletetion
26  virtual TH1F* GetTH1FCopy(const char* n) = 0;
27 
28  /// Read a copy of a named histogram into memory. User accepts
29  /// ownership and responsibility for deletion.
30  virtual TH2F* GetTH2FCopy(const char* n) = 0;
31 
32  /// Get a list of all histograms held by this source
33  virtual void GetHistogramList(std::list<std::string>& h) = 0;
34 
35  /// Get the histogram server status
36  virtual void GetStatus(std::string& nm,
37  unsigned int* run,
38  unsigned int* subrun,
39  unsigned int* event,
40  pid_t* pid,
41  long* stime,
42  long* utime,
43  long* cpu,
44  long* rsize,
45  time_t* t) { }
46 
47  public:
48  /// Return the names of all objects in the file who's names match
49  /// a particular set of patterns
50  ///
51  /// \param include_pattern - Names must match this expression
52  /// \param exclude_pattern - Names must not match this expression
53  /// \param objs - List of object names that satisfy the above
54  ///
55  void FindAllMatches(const char* include_pattern,
56  const char* exclude_pattern,
57  std::list<std::string>& objs);
58  };
59 
60  ///
61  /// Histograms from a root file
62  ///
63  class HistoFile : public HistoSourceBase
64  {
65  public:
66  HistoFile(const char* n);
67  ~HistoFile();
68  public:
69  void SetName(const char* nm);
70  TH1F* GetTH1FCopy(const char* n);
71  TH2F* GetTH2FCopy(const char* n);
72  void GetHistogramList(std::list<std::string>& h);
73  private:
74  TFile* fFile; ///< The root histogram file
75  };
76 
77  ///
78  /// Histograms from a shared memory segment
79  ///
80  class HistoSHM : public HistoSourceBase
81  {
82  public:
83  HistoSHM(const char* n);
84  ~HistoSHM();
85  public:
86  void SetName(const char* nm);
87  TH1F* GetTH1FCopy(const char* n);
88  TH2F* GetTH2FCopy(const char* n);
89  void GetHistogramList(std::list<std::string>& h);
90  void GetStatus(std::string& nm,
91  unsigned int* run,
92  unsigned int* subrun,
93  unsigned int* event,
94  pid_t* pid,
95  long* stime,
96  long* utime,
97  long* cpu,
98  long* rsize,
99  time_t* t);
100  private:
101  IPC* fIPC; ///< Shared memory handler
102  };
103 
104  ///
105  /// The generic source. Figures out which of the above to use based
106  /// on the . extension
107  ///
108  class HistoSource : public HistoSourceBase
109  {
110  public:
111  HistoSource(const char* n);
112  ~HistoSource();
113  public:
114  void SetName(const char* nm);
115  TH1F* GetTH1FCopy(const char* n);
116  TH2F* GetTH2FCopy(const char* n);
117  void GetHistogramList(std::list<std::string>& h);
118  void GetStatus(std::string& nm,
119  unsigned int* run,
120  unsigned int* subrun,
121  unsigned int* event,
122  pid_t* pid,
123  long* stime,
124  long* utime,
125  long* cpu,
126  long* rsize,
127  time_t* t);
128  private:
130  };
131 }
132 
133 #endif
134 ////////////////////////////////////////////////////////////////////////
virtual void SetName(const char *nm)=0
Set the source name.
virtual void GetStatus(std::string &nm, unsigned int *run, unsigned int *subrun, unsigned int *event, pid_t *pid, long *stime, long *utime, long *cpu, long *rsize, time_t *t)
Get the histogram server status.
Definition: HistoSource.h:36
void FindAllMatches(const char *include_pattern, const char *exclude_pattern, std::list< std::string > &objs)
Definition: HistoSource.cxx:10
virtual TH1F * GetTH1FCopy(const char *n)=0
static constexpr Double_t nm
Definition: Munits.h:133
TFile * fFile
The root histogram file.
Definition: HistoSource.h:74
virtual void GetHistogramList(std::list< std::string > &h)=0
Get a list of all histograms held by this source.
IPC * fIPC
Shared memory handler.
Definition: HistoSource.h:101
virtual ~HistoSourceBase()
Definition: HistoSource.h:19
HistoSourceBase * fSource
Definition: HistoSource.h:129
Definition: run.py:1
Definition: IPC.h:29
virtual TH2F * GetTH2FCopy(const char *n)=0
Online Monitoring package header.
enum BeamMode string