BmnRoot
Loading...
Searching...
No Matches
BmnReport.h
Go to the documentation of this file.
1#ifndef BMNREPORT_H_
2#define BMNREPORT_H_
3
4#include <iostream>
5#include <map>
6#include <string>
7#include <vector>
8// ROOT
9#include <TCanvas.h>
10#include <TFile.h>
11#include <THttpServer.h>
12#include <TObject.h>
13
14using std::map;
15using std::ostream;
16using std::string;
17using std::vector;
18
20
28class BmnReport : public TObject
29{
30 public:
35
39 virtual ~BmnReport();
40
45 const BmnReportElement* R() const { return fR; }
46
50 ostream& Out() const { return *fOut; }
51
52 void Register(string path);
53 void CallDraw() { Draw(); }
54
55 /* Setters */
56 void SetReportName(TString name) { fReportName = name.Data(); }
57 void SetReportTitle(const string& title) { fReportTitle = title; }
58 void SetOutputDir(const string& outputDir) { fOutputDir = outputDir; }
59
60 /* void SetObjDir(TFile* outFile = nullptr)
61 {
62 TDirectory* fDir = nullptr;
63 if (outFile)
64 fDir = outFile->mkdir((fReportName + "_hists").data());
65 //for (auto el : fCanvases)
66 // el->SetDirectory(fDir);
67 } */
68
69 void SetMonitorMode(const Bool_t mm) { fMonitorMode = mm; }
70 void SetObjServer(THttpServer* s) { fServer = s; }
71
72 /* Accessors */
73 const string& GetReportName() const { return fReportName; }
74 const string& GetReportTitle() const { return fReportTitle; }
75 const string& GetOutputDir() const { return fOutputDir; }
76 Bool_t GetMonitorMode() const { return fMonitorMode; }
77 THttpServer* GetObjServer() const { return fServer; }
78
79 protected:
85 virtual void Create() = 0;
86
92 virtual void Draw() = 0;
93
98
104 TCanvas* CreateCanvas(const char* name, const char* title, Int_t ww, Int_t wh);
105
110
114 void WriteCanvases() const;
115
119 void PrintCanvases() const;
120
121 THttpServer* fServer;
122 Bool_t fMonitorMode;
123 Bool_t fInitCanvasesDone;
124
125 private:
130 void CreateReportElement();
131
135 void DeleteReportElement();
136
137 string fReportName; // Name of report
138 string fReportTitle; // Title of report
139 string fOutputDir; // Output directory for the report files
140 BmnReportElement* fR; // Report element tool
141 mutable ostream* fOut; // Output stream
142
143 // Storage for TCanvas. All Canvases in this vector will be automatically saved
144 // to image and printed in the report.
145 // User can use CreateCanvas function which automatically push created canvas in this vector.
146 vector<TCanvas*> fCanvases;
147 map<string, TCanvas*> fCanvasMap;
148
149 // private:
150
151 BmnReport(const BmnReport&) = delete;
152 BmnReport& operator=(const BmnReport&) = delete;
153
154 ClassDef(BmnReport, 1)
155};
156
157#endif /* BmnREPORT_H_ */
Abstract class for basic report elements (headers, tables, images etc.).
Base class for reports.
Definition BmnReport.h:29
const string & GetReportTitle() const
Definition BmnReport.h:74
void SetMonitorMode(const Bool_t mm)
Definition BmnReport.h:69
void SetReportTitle(const string &title)
Definition BmnReport.h:57
const string & GetOutputDir() const
Definition BmnReport.h:75
virtual void Draw()=0
Pure abstract function which is called from public Create() function. This function has to draw all n...
void SetReportName(TString name)
Definition BmnReport.h:56
void PrintCanvases() const
Print images created from canvases in the report.
void CallDraw()
Definition BmnReport.h:53
const BmnReportElement * R() const
Accessor to BmnReportElement object. User has to write the report using available tags from BmnReport...
Definition BmnReport.h:45
virtual ~BmnReport()
Destructor.
BmnReport()
Constructor.
void SetOutputDir(const string &outputDir)
Definition BmnReport.h:58
TCanvas * CreateCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
Create canvas and put it to vector of TCanvases. Canvases created with this function will be automati...
void CreateReports()
Create all available report types.
ostream & Out() const
All text output goes to this stream.
Definition BmnReport.h:50
Bool_t fInitCanvasesDone
Definition BmnReport.h:123
void SetObjServer(THttpServer *s)
Definition BmnReport.h:70
THttpServer * GetObjServer() const
Definition BmnReport.h:77
void WriteCanvases() const
Write canvases to file.
void Register(string path)
virtual void Create()=0
Pure abstract function which is called from public Create() function. This function has to write repo...
const string & GetReportName() const
Definition BmnReport.h:73
Bool_t fMonitorMode
Definition BmnReport.h:122
void SaveCanvasesAsImages() const
Save all canvases to images.
THttpServer * fServer
Definition BmnReport.h:121
Bool_t GetMonitorMode() const
Definition BmnReport.h:76