ROOTANA
TSimpleHistogramCanvas.cxx
Go to the documentation of this file.
2 
3 #include "TMesytecData.hxx"
4 #include "TH2.h"
5 
6 
7 TSimpleHistogramCanvas::TSimpleHistogramCanvas(TH1* histo, std::string name, std::string printoption): TCanvasHandleBase(name){
8 
9  fHisto = histo;
10  fGraph = 0;
11  fPrintOption = printoption;
12 
13  fExtraHistos = std::vector<TH1*>();
14  fExtraGraphs = std::vector<TGraph*>();
15 }
16 
17 TSimpleHistogramCanvas::TSimpleHistogramCanvas(TGraph* graph, std::string name): TCanvasHandleBase(name){
18 
19  fHisto = 0;
20  fGraph = graph;
21 
22  fExtraHistos = std::vector<TH1*>();
23  fExtraGraphs = std::vector<TGraph*>();
24 }
25 
26 
27 
29 
30  if(fHisto) delete fHisto;
31  if(fGraph) delete fGraph;
32 
33  for(unsigned int i = 0; i < fExtraHistos.size(); i++) delete fExtraHistos[i];
34  for(unsigned int i = 0; i < fExtraGraphs.size(); i++) delete fExtraGraphs[i];
35 
36 }
37 
38 
39 /// Reset the histograms in fHistoArray.
41  if(fHisto)fHisto->Reset();
42  for(unsigned int i = 0; i < fExtraHistos.size(); i++) fExtraHistos[i]->Reset();
43 }
44 
45 /// Update the histograms for this canvas.
47 
48 }
49 
50 
51 
52 /// Plot the histograms for this canvas
53 void TSimpleHistogramCanvas::PlotCanvas(TDataContainer& dataContainer, TRootEmbeddedCanvas *embedCanvas){
54 
55 
56  TCanvas* c1 = embedCanvas->GetCanvas();
57  c1->Clear();
58 
59  if(fHisto){
60  fHisto->Draw(fPrintOption.c_str());
61  }
62  if(fGraph){
63  fGraph->Draw("AP*");
64  fGraph->SetMarkerStyle(20);
65  }
66 
67  for(unsigned int i = 0; i < fExtraHistos.size(); i++){
68  std::string option = std::string("SAME") + fPrintOption;
69  fExtraHistos[i]->Draw(option.c_str());
70  fExtraHistos[i]->SetLineColor(i+2);
71  fExtraHistos[i]->SetMarkerColor(i+2);
72  }
73 
74  for(unsigned int i = 0; i < fExtraGraphs.size(); i++){
75  fExtraGraphs[i]->Draw("*");
76  fExtraGraphs[i]->SetMarkerStyle(20 + i+1);
77  fExtraGraphs[i]->SetMarkerColor(i+2);
78  }
79 
80  c1->Modified();
81  c1->Update();
82 
83 
84 }
85 
86 
87 
88 /// Take actions at begin run
89 void TSimpleHistogramCanvas::BeginRun(int transition,int run,int time){
90  if(fHisto)fHisto->Reset();
91 };
92 
93 /// Take actions at end run
94 void TSimpleHistogramCanvas::EndRun(int transition,int run,int time){
95 };
96 
97 
TGraph * fGraph
Pointer to the graph.
void BeginRun(int transition, int run, int time)
Take actions at begin run.
void UpdateCanvasHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas. Doesn't do anything.
std::vector< TH1 * > fExtraHistos
std::vector< TGraph * > fExtraGraphs
void ResetCanvasHistograms()
Reset the histograms for this canvas.
void EndRun(int transition, int run, int time)
Take actions at end run
TH1 * fHisto
Pointer to the histogram.
void PlotCanvas(TDataContainer &dataContainer, TRootEmbeddedCanvas *embedCanvas)
Plot the histograms for this canvas.