TFancyHistogramCanvas.hxx

Go to the documentation of this file.
00001 #ifndef TFancyHistogramCanvas_h
00002 #define TFancyHistogramCanvas_h
00003 
00004 
00005 #include <iostream>
00006 #include <string>
00007 
00008 #include "TH1F.h"
00009 #include "TCanvasHandleBase.hxx"
00010 #include "TGNumberEntry.h"
00011 #include "TGLabel.h"
00012 #include "THistogramArrayBase.h"
00013 #include "TGButton.h"
00014 #include "TGButtonGroup.h"
00015 #include "TLegend.h"
00016 
00017 /// A canvas that plots THistogramArrayBase type histograms in 
00018 /// a nice way.
00019 /// The basic idea is to allow the user to easily plot an array
00020 /// of histograms in three different ways:
00021 /// 1) They can scroll through the histograms one by one, using
00022 ///    the "Histogram Number" button.
00023 /// 2) They can have a set of NNN different canvases, each 
00024 ///    with a different histogram, where NNN can be 2, 4, 8 or 16.
00025 /// 3) They can have multiple histograms overlaid on the same
00026 ///    canvas; the user can choose how many histograms to overlay.
00027 ///
00028 class TFancyHistogramCanvas : public TCanvasHandleBase{
00029 
00030 public:
00031 
00032   /// Pass the THistogramArrayBase pointer during constructor;
00033   /// does not pass ownership (TFancyHistogramCanvas will not delete histoArray);
00034   /// parameters:
00035   /// 'histoArray': this is the pointer to the class derived from THistogramArrayBase base;
00036   ///   - does not assume ownership of pointer memory.
00037   /// 'name' is the name that the histogram will have.
00038   /// 'numberChannelsInGroups': if this value is greater than 1, then the fancy canvas
00039   /// will have an additional button allowing the user to specify particular groups;
00040   /// the histograms will be organized into size/fNumberChannelsInGroups of groups,
00041   /// with each group having fNumberChannelsInGroups entries.
00042   /// will have an additional button allowing the user to specify particular groups.
00043   /// 'disableAutoUpdate' will tell fancy histogram to not call histoArray->UpdateHistograms()
00044   ///   -> the assumption is that the user will take care of calling this function.
00045   ///
00046   TFancyHistogramCanvas(THistogramArrayBase* histoArray, 
00047                         std::string name, int numberChannelsInGroups = -1,
00048                         bool disableAutoUpdate=false);
00049 
00050   ~TFancyHistogramCanvas();
00051 
00052   /// Reset the histograms for this canvas
00053   void ResetCanvasHistograms();
00054   
00055   /// Update the histograms for this canvas.
00056   void UpdateCanvasHistograms(TDataContainer& dataContainer);
00057   
00058   /// Plot the histograms for this canvas
00059   void PlotCanvas(TDataContainer& dataContainer, TRootEmbeddedCanvas *embedCanvas);
00060 
00061   /// Take actions at begin run
00062   void BeginRun(int transition,int run,int time);
00063 
00064   /// Take actions at end run  
00065   void EndRun(int transition,int run,int time);
00066 
00067 
00068   void SetUpCompositeFrame(TGCompositeFrame *compFrame, TRootanaDisplay *display);
00069   
00070   /// These methods are callbacks to ensure that multi-canvas and overlay-histo modes 
00071   /// are used exclusively.
00072   void ActivateMultiCanvasButton();
00073   void ActivateOverlayButton();
00074 
00075   /// Allow the user to set explicitly the group name.
00076   void SetGroupName(std::string groupName);
00077   /// Allow the user to set explicitly the channel name.
00078   void SetChannelName(std::string channelName);
00079 
00080 private:
00081 
00082   /// Pointer to the THistogramArrayBase class; memory is not owned by TFancyHistogramCanvas.
00083   THistogramArrayBase* fHistoArray;
00084 
00085   /// 'disableAutoUpdate' will tell fancy histogram to not call histoArray->UpdateHistograms()
00086   ///   -> the assumption is that the user will take care of calling this function.  
00087   bool fDisableAutoUpdate;
00088 
00089   /// 'fNumberChannelsInGroups': if this value is greater than 1, then the fancy canvas
00090   /// will have an additional button allowing the user to specify particular groups;
00091   /// the histograms will be organized into size/fNumberChannelsInGroups of groups,
00092   /// with each group having fNumberChannelsInGroups entries.
00093   int fNumberChannelsInGroups;
00094 
00095   /// Overall frame in which we will add buttons and widgets.
00096   TGHorizontalFrame *fLabelframe;
00097 
00098   /// Button for the histogram number.
00099   TGNumberEntry *fChannelCounterButton;
00100 
00101   /// A label for the histogram number button.
00102   TGLabel *fLabelChannels;
00103 
00104   /// Name for the channel button.
00105   std::string fChannelName;
00106 
00107   /// Button for the group number.
00108   TGNumberEntry *fGroupCounterButton;
00109 
00110   /// A label for the group button.
00111   TGLabel *fLabelGroup;
00112 
00113   /// Name for the group button.
00114   std::string fGroupName;
00115 
00116   /// This button controls whether to display mutliple sub-canvases.
00117   TGCheckButton *fMultiCanvasButton;
00118 
00119   /// Button group to select how many canvases to show.
00120   TGHButtonGroup *fNCanvasButtonGroup;
00121   TGRadioButton *fNCanvasButtons[4];
00122 
00123   /// This button controls whether to display overlaid histograms.
00124   TGCheckButton *fOverlayHistoButton;
00125 
00126   /// Button group to select how many histograms to show.
00127   TGNumberEntry *fNHistoButton;
00128   TGLabel *labelNHisto;
00129   TLegend *fNHistoLegend;
00130 
00131   /// Helper function to remove extra buttons if not needed anymore.
00132   void CheckExtraButtons();
00133 
00134   /// Cached pointer to rootana display; needed so that we can 
00135   /// create new buttons with correct callbacks.
00136   TRootanaDisplay *fDisplay;
00137 
00138   // Don't define default constructor.
00139   TFancyHistogramCanvas();
00140 
00141   // Need to rootcint this class, in order for call-backs to work.
00142   ClassDef(TFancyHistogramCanvas,1)
00143 };
00144 
00145 
00146 #endif

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1