REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestEventViewer.cxx
1 
19 #include "TRestEventViewer.h"
20 
21 #include "TRestBrowser.h"
22 
23 using namespace std;
24 
25 ClassImp(TRestEventViewer);
26 
27 TRestEventViewer::TRestEventViewer() {
28  // TRestEventViewer default constructor
29  // Initialize();
30  fPad = nullptr;
31  fCanvas = nullptr;
32 }
33 
34 TRestEventViewer::~TRestEventViewer() {
35  // TRestEventViewer destructor
36  // DeleteCurrentEvent( );
37 }
38 
39 void TRestEventViewer::Initialize() {
40  fPad = nullptr;
41 
42  if (fCanvas != nullptr) delete fCanvas;
43  fCanvas = new TCanvas("Event Viewer", "Event Viewer");
44 
45  fCanvas->SetWindowPosition(350, 10);
46 }
47 
48 void TRestEventViewer::Embed(TBrowser* b) {
49  if (b != nullptr) b->StartEmbedding(1, -1);
50 
51  Initialize();
52 
53  if (b != nullptr) b->StopEmbedding();
54 }
55 
56 void TRestEventViewer::AddEvent(TRestEvent* ev) { fEvent = ev; }
57 
58 void TRestEventViewer::Plot(const char* option) {
59  if (fPad == nullptr) fPad = new TPad();
60  if (fEvent != nullptr) {
61  fPad = fEvent->DrawEvent(option);
62  fCanvas->cd();
63  fPad->Draw();
64  fPad->Update();
65  fCanvas->Update();
66  } else {
67  fCanvas->cd();
68  fPad->Clear();
69  fPad->Update();
70  fCanvas->Update();
71  }
72 }
73 
74 void TRestEventViewer::DeleteCurrentEvent() { delete fEvent; }
A base class for any REST event.
Definition: TRestEvent.h:38