display_example.cxx

Go to the documentation of this file.
00001 /// This is an example of the a user defined event display.
00002 /// The user then needs to define how they what to update and plot histograms.
00003 /// The updating of histograms happens for each event.
00004 /// In online mode, the plotting of histograms only happens for each XX events;
00005 /// for offline mode the plotting happens for each event.
00006 ///
00007 /// There are two ways that users can decide to update and plot histograms:
00008 ///
00009 /// 1) They can create histograms in their event display class and then fill 
00010 ///    the methods UpdateHistograms(TMidasEvent*) and PlotCanvas(TMidasEvent*).
00011 ///    This histograms can then file in the canvases that are added using 
00012 ///    AddSingleCanvas(std::string name).
00013 ///
00014 ///    In this example this method is used for the histogram sizeBankFR10,
00015 ///    which is just a histogram of the size of the bank called "FR10".
00016 ///
00017 /// 2) They can create classes that are derived from TCanvasHandleBase.  The derived
00018 ///    classes are then added using the method AddSingleCanvas(TCanvasHandleBase* handleClass).
00019 ///    In this example there are two classes derived from TCanvasHandleBase:
00020 ///      a) TSimpleExampleCanvas: this class just creates a tab/canvas with a
00021 ///         histogram of the size of the bank called "FR11".
00022 ///      a) TComplicatedExampleCanvas: this class creates a set of four different
00023 ///         canvases/histograms which the user can select using a ROOT number widget.
00024 ///    
00025 /// The actual ROOT GUI is encapsulated in a separate class TMainDisplayWindow.
00026 /// The TRootanaDisplay has an instance of this TMainDisplayWindow class.
00027 /// Users will be need to access the TMainDisplayWindow by calling
00028 ///
00029 /// TRootanaDisplay::GetDisplayWindow()
00030 /// 
00031 /// in order to grab the particular canvas that we want plot on.
00032 
00033 
00034 #include <stdio.h>
00035 #include <iostream>
00036 
00037 #include "TRootanaDisplay.hxx"
00038 #include "TH1D.h"
00039 
00040 #include "TSimpleExampleCanvas.hxx"
00041 #include "TComplicatedExampleCanvas.hxx"
00042 
00043 class MyTestLoop: public TRootanaDisplay {
00044   
00045   TH1F *sizeBankFR10;
00046 public:
00047 
00048   MyTestLoop() {
00049     
00050     // Initialize histograms.
00051     sizeBankFR10 = new TH1F("sizeBankFR10","Size of FR10 bank",2000,0,10000);
00052   }
00053   
00054   void AddAllCanvases(){
00055     // Set up tabbed canvases
00056     AddSingleCanvas(new TSimpleExampleCanvas());
00057     AddSingleCanvas(new TComplicatedExampleCanvas());
00058     AddSingleCanvas("FR10"); 
00059     SetNumberSkipEvent(20);
00060     SetDisplayName("Example Display");
00061   };
00062 
00063   virtual ~MyTestLoop() {};
00064 
00065   void ResetHistograms(){
00066     sizeBankFR10->Reset();
00067   }
00068 
00069   void UpdateHistograms(TDataContainer& dataContainer){
00070     void *ptr;
00071     // Update histograms
00072     int size = dataContainer.GetMidasData().LocateBank(NULL, "FR10", &ptr);
00073     sizeBankFR10->Fill(size);
00074 
00075   }
00076 
00077 
00078   void PlotCanvas(TDataContainer& dataContainer){
00079 
00080     if(GetDisplayWindow()->GetCurrentTabName().compare("FR10") == 0){       
00081       TCanvas* c1 = GetDisplayWindow()->GetCanvas("FR10");
00082       c1->Clear();
00083       sizeBankFR10->Draw();
00084       c1->Modified();
00085       c1->Update();
00086     }
00087     
00088   }
00089 
00090 
00091 }; 
00092 
00093 
00094 
00095 
00096 
00097 
00098 int main(int argc, char *argv[])
00099 {
00100   MyTestLoop::CreateSingleton<MyTestLoop>();  
00101   return MyTestLoop::Get().ExecuteLoop(argc, argv);
00102 }
00103 

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1