ROOTANA
display_example.cxx
Go to the documentation of this file.
1 /// This is an example of the a user defined event display.
2 /// The user then needs to define how they what to update and plot histograms.
3 /// The updating of histograms happens for each event.
4 /// In online mode, the plotting of histograms only happens for each XX events;
5 /// for offline mode the plotting happens for each event.
6 ///
7 /// There are two ways that users can decide to update and plot histograms:
8 ///
9 /// 1) They can create histograms in their event display class and then fill
10 /// the methods UpdateHistograms(TMidasEvent*) and PlotCanvas(TMidasEvent*).
11 /// This histograms can then file in the canvases that are added using
12 /// AddSingleCanvas(std::string name).
13 ///
14 /// In this example this method is used for the histogram sizeBankFR10,
15 /// which is just a histogram of the size of the bank called "FR10".
16 ///
17 /// 2) They can create classes that are derived from TCanvasHandleBase. The derived
18 /// classes are then added using the method AddSingleCanvas(TCanvasHandleBase* handleClass).
19 /// In this example there are two classes derived from TCanvasHandleBase:
20 /// a) TSimpleExampleCanvas: this class just creates a tab/canvas with a
21 /// histogram of the size of the bank called "FR11".
22 /// a) TComplicatedExampleCanvas: this class creates a set of four different
23 /// canvases/histograms which the user can select using a ROOT number widget.
24 ///
25 /// The actual ROOT GUI is encapsulated in a separate class TMainDisplayWindow.
26 /// The TRootanaDisplay has an instance of this TMainDisplayWindow class.
27 /// Users will be need to access the TMainDisplayWindow by calling
28 ///
29 /// TRootanaDisplay::GetDisplayWindow()
30 ///
31 /// in order to grab the particular canvas that we want plot on.
32 
33 
34 #include <stdio.h>
35 #include <iostream>
36 
37 #include "TRootanaDisplay.hxx"
38 #include "TH1D.h"
39 
40 #include "TSimpleExampleCanvas.hxx"
42 
43 class MyTestLoop: public TRootanaDisplay {
44 
45  TH1F *sizeBankFR10;
46 public:
47 
49 
50  // Initialize histograms.
51  sizeBankFR10 = new TH1F("sizeBankFR10","Size of FR10 bank",2000,0,10000);
52  }
53 
55  // Set up tabbed canvases
58  AddSingleCanvas("FR10");
60  SetDisplayName("Example Display");
61  };
62 
63  virtual ~MyTestLoop() {};
64 
66  sizeBankFR10->Reset();
67  }
68 
69  void UpdateHistograms(TDataContainer& dataContainer){
70  void *ptr;
71  // Update histograms
72  int size = dataContainer.GetMidasData().LocateBank(NULL, "FR10", &ptr);
73  sizeBankFR10->Fill(size);
74 
75  }
76 
77 
78  void PlotCanvas(TDataContainer& dataContainer){
79 
80  if(GetDisplayWindow()->GetCurrentTabName().compare("FR10") == 0){
81  TCanvas* c1 = GetDisplayWindow()->GetCanvas("FR10");
82  c1->Clear();
83  sizeBankFR10->Draw();
84  c1->Modified();
85  c1->Update();
86  }
87 
88  }
89 
90 
91 };
92 
93 
94 
95 
96 
97 
98 int main(int argc, char *argv[])
99 {
100  MyTestLoop::CreateSingleton<MyTestLoop>();
101  return MyTestLoop::Get().ExecuteLoop(argc, argv);
102 }
103 
void UpdateHistograms(TDataContainer &dataContainer)
This method can be implemented by users to update user histograms.
void PlotCanvas(TDataContainer &dataContainer)
This method can be implemented by users to plotting of current canvas.
void AddAllCanvases()
User must.
virtual ~MyTestLoop()
TH1F * sizeBankFR10
void ResetHistograms()
This method can be implemented by users to plotting of current canvas.
A complicated canvas example, using the values from V792 module.
TMidasEvent & GetMidasData() const
Get the MIDAS data for this event, in TMidasEvent format.
TCanvas * GetCanvas(const char *name)
Get a particular canvas based on canvas name.
int LocateBank(const void *unused, const char *bankName, void **bankPtr) const
void AddSingleCanvas(std::string name, std::string subtab_name=std::string(""))
Add a new canvas; user will interactively fill it.
void SetNumberSkipEvent(int number)
void SetDisplayName(std::string name)
Set Display name.
TMainDisplayWindow * GetDisplayWindow()
static TRootanaEventLoop & Get(void)
int ExecuteLoop(int argc, char *argv[])
Method to actually process the Midas information, either as file or online.
int main(int argc, char *argv[])