Rootana Display Framework
TRootanaDisplay is an attempt to provide a simple way of making ROOT event displays that can quickly be used to show ADC/TDC spectrum or whatever else you'd like to plot; based on ROOTANA package. There are also other alternative display methods, such as roody and the rootana javascript displays.
Using TRootanaDisplay
TRootanaDisplay is an abstract base class for event displays. Users need to define a class that derives from this class in order to make an event display. The only method that users must implement is the method AddAllCanvas(), where the user defines which tabs to use.
The user then needs to define how they what to update and plot histograms. The updating of histograms happens for each event. In online mode, the plotting of histograms only happens for each NN events, where NN is controlled by the user. For offline mode the plotting happens for each event.
There are several ways that users can decide to update and plot histograms:
- They can create histograms in their event display class and then fill the methods UpdateHistograms(TDataContainer) and PlotCanvas(TDataContainer). This histograms can then fill in the canvases that are added using AddSingleCanvas(std::string name).
- They can create classes that are derived from TCanvasHandleBase. The derived classes are then added using the method AddSingleCanvas(TCanvasHandleBase* handleClass).
- They can create a histogram-set class (derived from THistogramArrayBase) and pass it to TFancyHistogramCanvas. This provides a richer set of button control of the histogram display. This is principally meant as a way to display a number of different channels of the same type of plot.
There is no substantial difference between the first two methods. The third method is mainly meant to allow the user to separate the methods into separate files for code cleaniness.
The actual ROOT GUI is encapsulated in a separate class TMainDisplayWindow. The TRootanaDisplay has an instance of this TMainDisplayWindow class. Users will be need to access the TMainDisplayWindow by calling
TRootanaDisplay::GetDisplayWindow()
in order to grab the particular canvas that we want plot on.
The program rootana/libAnalyzerDisplay/display_example.cxx shows an nice example plot using all three methods for histogram filling. There is also a more complicated example in rootana/examples/anaDisplay.cxx. A trivial example using just the first method for filling histograms is shown below
#include <stdio.h> #include <iostream> #include "TRootanaDisplay.hxx" #include "TH1D.h" class MyTestLoop: public TRootanaDisplay { TH1F *sizeBankFR10; public: MyTestLoop() { // Initialize histograms. sizeBankFR10 = new TH1F("sizeBankFR10","Size of FR10 bank",2000,0,10000); } void AddAllCanvases(){ // Set up tabbed canvases AddSingleCanvas("FR10"); // Choose how many events to skip before updating SetNumberSkipEvent(20); // Choose display name SetDisplayName("Example Display"); }; virtual ~MyTestLoop() {}; void ResetHistograms(){ sizeBankFR10->Reset(); } void UpdateHistograms(TDataContainer& dataContainer){ void *ptr; // Update histograms int size = dataContainer.GetMidasData().LocateBank(NULL, "FR10", &ptr); sizeBankFR10->Fill(size); } void PlotCanvas(TDataContainer& dataContainer){ if(GetDisplayWindow()->GetCurrentTabName().compare("FR10") == 0){ TCanvas* c1 = GetDisplayWindow()->GetCanvas("FR10"); c1->Clear(); sizeBankFR10->Draw(); c1->Modified(); c1->Update(); } } }; int main(int argc, char *argv[]) { MyTestLoop::CreateSingleton<MyTestLoop>(); return MyTestLoop::Get().ExecuteLoop(argc, argv); }
Program Flow Control
The following images try to describe the program flow graphically.
Comparison of RootanaDisplay and Roody
rootana also provides a different way of visualizing histograms through roody and the TNetDirectoryServer. Should the user use TRootanaDisplay or roody? The following are some of the differences between the two tools:
- roody requires two programs to be running: an analyzer that produces the histogram and the roody program for displaying them. This has some advantages in that you can independently restart the roody part; also you can run the analyzer on the midas server machine, but run roody on your desktop. But it also some disadvantages in complexity, since you need to keep track of both programs.
- Using roody is simpler from a coding point of view, since all the visualization is handled for you. The TRootanaDisplay option requires some understanding of ROOT canvases and GUIs.
- roody can only handle a limited set of ROOT classes, like TH1 histograms. If you want to be able to plot more complicated ROOT options or plot them in a more complicated way (overlaying histograms, fits and labels) then TRootanaDisplay is a better option.
So, in summary: if you are only producing a simple set of ROOT histograms and/or you don't want to do much programming then roody might be the right solution; if you want complicated plots and don't mind using ROOT display classes, then TRootanaDisplay is the way to go.
Of course, the user can easily have a program that implements both solutions and get the best of both worlds.