EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmReport.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmReport.cxx
1 
7 #include "CbmReport.h"
9 #include "CbmHtmlReportElement.h"
10 #include "CbmTextReportElement.h"
11 #include "TCanvas.h"
12 
13 #include <fstream>
14 #include <string>
15 using std::ofstream;
16 using std::string;
17 
19  fReportName("qa_report"),
20  fReportTitle("QA report"),
21  fOutputDir("./"),
22  fR(NULL),
23  fOut(NULL),
24  fReportType(kCoutReport),
25  fCanvases()
26 {
27 }
28 
30 {
31 }
32 
34  ReportType reportType)
35 {
36  fReportType = reportType;
37  if (NULL != fR) delete fR;
38  if (NULL != fOut && fReportType != kCoutReport) delete fOut;
39  if (reportType == kLatexReport) {
40  fR = new CbmLatexReportElement();
41  fOut = new ofstream(string(GetOutputDir() + fReportName + ".tex").c_str());
42  } else if (reportType == kHtmlReport) {
43  fR = new CbmHtmlReportElement();
44  fOut = new ofstream(string(GetOutputDir() + fReportName + ".html").c_str());
45  } else if (reportType == kTextReport) {
46  fR = new CbmTextReportElement();
47  fOut = new ofstream(string(GetOutputDir() + fReportName + ".txt").c_str());
48  } else if (reportType == kCoutReport) {
49  fR = new CbmTextReportElement();
50  fOut = &std::cout;
51  }
52 }
53 
55 {
56  // if (NULL != fR) delete fR;
57  // if (NULL != fOut && fReportType != kCoutReport) delete fOut;
58 }
59 
61 {
62  Draw(); // User has to implement this function!
64 // WriteCanvases();
65 
67  Create(); // User has to implement this function!
69 
71  Create(); // User has to implement this function!
73 
75  Create(); // User has to implement this function!
77 
79  Create(); // User has to implement this function!
81 }
82 
84  const char* name,
85  const char* title,
86  Int_t ww,
87  Int_t wh)
88 {
89  TCanvas* canvas = new TCanvas(name, title, ww, wh);
90  fCanvases.push_back(canvas);
91  return canvas;
92 }
93 
95 {
96  if (GetOutputDir() == "") return;
97  Int_t nofCanvases = fCanvases.size();
98  for (Int_t i = 0; i < nofCanvases; i++) {
99  TCanvas* canvas = fCanvases[i];
100  //canvas->SaveAs(string(GetOutputDir() + string(canvas->GetTitle()) + ".eps").c_str());
101  canvas->SaveAs(string(GetOutputDir() + string(canvas->GetTitle()) + ".png").c_str());
102  canvas->SaveAs(string(GetOutputDir() + string(canvas->GetTitle()) + ".gif").c_str());
103  }
104 }
105 
107 {
108  if (GetOutputDir() == "") return;
109  Int_t nofCanvases = fCanvases.size();
110  for (Int_t i = 0; i < nofCanvases; i++) {
111  fCanvases[i]->Write();
112  }
113 }
114 
116 {
117  Int_t nofCanvases = fCanvases.size();
118  for (Int_t i = 0; i < nofCanvases; i++) {
119  TCanvas* canvas = fCanvases[i];
120  Out() << R()->Image(canvas->GetName(), canvas->GetName());
121  }
122 }
123