KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVTreeAnalyzer.h
Go to the documentation of this file.
1 
4 #ifndef __KVTreeAnalyzer_H
5 #define __KVTreeAnalyzer_H
6 #ifndef ROOT_TGDockableFrame
7 #include "TGDockableFrame.h"
8 #endif
9 #ifndef ROOT_TGMenu
10 #include "TGMenu.h"
11 #endif
12 #ifndef ROOT_TGMdiDecorFrame
13 #include "TGMdiDecorFrame.h"
14 #endif
15 #ifndef ROOT_TG3DLine
16 #include "TG3DLine.h"
17 #endif
18 #ifndef ROOT_TGMdiFrame
19 #include "TGMdiFrame.h"
20 #endif
21 #ifndef ROOT_TGMdiMainFrame
22 #include "TGMdiMainFrame.h"
23 #endif
24 #ifndef ROOT_TGMdiMenu
25 #include "TGMdiMenu.h"
26 #endif
27 #ifndef ROOT_TGListBox
28 #include "TGListBox.h"
29 #endif
30 #ifndef ROOT_TGNumberEntry
31 #include "TGNumberEntry.h"
32 #endif
33 #ifndef ROOT_TGScrollBar
34 #include "TGScrollBar.h"
35 #endif
36 #ifndef ROOT_TGComboBox
37 #include "TGComboBox.h"
38 #endif
39 #ifndef ROOT_TRootBrowser
40 #include "TRootBrowser.h"
41 #endif
42 #ifndef ROOT_TGFrame
43 #include "TGFrame.h"
44 #endif
45 #ifndef ROOT_TGFileDialog
46 #include "TGFileDialog.h"
47 #endif
48 #ifndef ROOT_TGShutter
49 #include "TGShutter.h"
50 #endif
51 #ifndef ROOT_TGButtonGroup
52 #include "TGButtonGroup.h"
53 #endif
54 #ifndef ROOT_TGCommandPlugin
55 #include "TGCommandPlugin.h"
56 #endif
57 #ifndef ROOT_TGCanvas
58 #include "TGCanvas.h"
59 #endif
60 #ifndef ROOT_TGFSContainer
61 #include "TGFSContainer.h"
62 #endif
63 #ifndef ROOT_TGColorSelect
64 #include "TGColorSelect.h"
65 #endif
66 #ifndef ROOT_TGTextEdit
67 #include "TGTextEdit.h"
68 #endif
69 #ifndef ROOT_TGButton
70 #include "TGButton.h"
71 #endif
72 #ifndef ROOT_TGFSComboBox
73 #include "TGFSComboBox.h"
74 #endif
75 #ifndef ROOT_TGLabel
76 #include "TGLabel.h"
77 #endif
78 #ifndef ROOT_TGView
79 #include "TGView.h"
80 #endif
81 #ifndef ROOT_TGFileBrowser
82 #include "TGFileBrowser.h"
83 #endif
84 #ifndef ROOT_TGTab
85 #include "TGTab.h"
86 #endif
87 #ifndef ROOT_TGListView
88 #include "TGListView.h"
89 #endif
90 #ifndef ROOT_TGSplitter
91 #include "TGSplitter.h"
92 #endif
93 #ifndef ROOT_TGTextEditor
94 #include "TGTextEditor.h"
95 #endif
96 #ifndef ROOT_TRootCanvas
97 #include "TRootCanvas.h"
98 #endif
99 #ifndef ROOT_TGStatusBar
100 #include "TGStatusBar.h"
101 #endif
102 #ifndef ROOT_TGListTree
103 #include "TGListTree.h"
104 #endif
105 #ifndef ROOT_TGToolTip
106 #include "TGToolTip.h"
107 #endif
108 #ifndef ROOT_TGToolBar
109 #include "TGToolBar.h"
110 #endif
111 #ifndef ROOT_TGHtmlBrowser
112 #include "TGHtmlBrowser.h"
113 #endif
114 
115 #include "TEnv.h"
116 #include "Riostream.h"
117 #include "KVListView.h"
118 #include "TChain.h"
119 #include "TCutG.h"
120 #include "TH1.h"
121 #include "TEntryList.h"
122 #include "KVUniqueNameList.h"
123 #include "TBrowser.h"
124 #include <KVUnownedList.h>
125 
126 class KVHistogram;
127 
146 class KVTreeAnalyzer : public TNamed {
147 private:
148  const Char_t* get_leaf_type_name(const TNamed* l);
150 
151  void init();
153 
157 
160 
161  /* leaves */
180 
185 
188 
189  /* histos */
191  const TGMainFrame* GetMainWindow() const
192  {
193  return fMain_histolist;
194  }
200  enum {
215  };
216  void HistoFileMenu_Open();
217  void OpenChain();
218  void HistoFileMenu_Save();
261 
262  /* selections */
268 
277 
279 
283 
286  {
288  }
289 
291 
293 
295  {
297  }
299  {
300  return !fMethodCalled;
301  }
302 
303  void AddHisto(TH1*);
304  void AddCut(TCutG*);
305  void AddSelection(TEntryList*);
306  void ReconnectTree();
307 
308  void GenerateHistoTitle(TString& title, const Char_t* exp, const Char_t* sel, const Char_t* weight = "");
309  void FillLeafList();
310 
311  void AnalysisSaveCheck();
313 
314  void SetEntryList(TEntryList*);
315 
316  bool DefineWeight();
317  bool DefineUserBinning();
318  bool DefineUserBinning1F();
319  bool DefineUserBinningD();
320 
321 public:
322  KVTreeAnalyzer(Bool_t nogui = kTRUE);
323  KVTreeAnalyzer(TTree*, Bool_t nogui = kFALSE);
324  virtual ~KVTreeAnalyzer();
325  void DeleteThis()
326  {
327  delete this;
328  }
329 
330  void Copy(TObject& obj) const;
331 
332  void SetTree(TTree* t);
333  void OpenGUI();
334  void GUIClosed();
335  TH1* MakeHisto(const Char_t* expr, const Char_t* selection, Int_t nX, Int_t nY = 0, const Char_t* weight = "", Double_t xmin = -1, Double_t xmax = -1, Double_t ymin = -1, Double_t ymax = -1);
336  TH1* RemakeHisto(TH1* h, const Char_t* expr, const Char_t* weight = "");
337  TH1* MakeIntHisto(const Char_t* expr, const Char_t* selection, Int_t Xmin, Int_t Xmax, const Char_t* weight = "");
338  const KVList* GetHistoList() const
339  {
340  return &fHistolist;
341  }
342  TH1* GetHistogram(const Char_t* name) const;
343  TList* GetHistosByData(const Char_t* expr);
344  TList* GetHistosBySelection(const Char_t* expr);
345  TH1* GetHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight = "");
346  KVHistogram* GetHistoByTitle(const Char_t* title);
347  void DeleteHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight);
348  void DeleteSelectedHisto();
349  void AddSelectedHistos();
350  void HistoAddition(Double_t c1 = 1, Double_t c2 = 1);
351 
352  Bool_t MakeSelection(const Char_t* selection);
353  void UpdateEntryLists();
354  void GenerateSelection();
357  void CombineSelectionsAnd();
358  void CombineSelectionsOr();
359  void DeleteSelections();
360  void SelectionChanged();
361  void SetAlias(const Char_t* name, const Char_t* expr);
362  void GenerateAlias();
363  TNamed* GetAlias(const Char_t* expr)
364  {
365  return (TNamed*)fAliasList.FindObjectByType(expr);
366  }
368  {
369  fSelections.ls();
370  }
372  {
373  fTree->GetListOfLeaves()->ls();
374  }
375  void ShowAliases()
376  {
377  fAliasList.ls();
378  }
379  void ShowHistos()
380  {
381  fHistolist.ls();
382  }
383  void CurrentSelection();
384  Bool_t IsCurrentSelection(const Char_t* sel);
385  void SetSelection(TObject*);
386  void SetSelection(const Char_t*);
387  TEntryList* GetSelection(const Char_t*);
388 
389  void EnablePROOF(Bool_t yes = kTRUE);
391  {
392  return fPROOFEnabled;
393  }
395  {
400  return (gEnv->GetValue("KVTreeAnalyzer.PROOFSelections", 0) && fPROOFEnabled);
401  }
402 
403  static KVTreeAnalyzer* OpenFile(const Char_t* filename, Bool_t nogui = kFALSE);
404  void ReadFromFile(const Char_t* filename);
405  void ReadFromFile(TFile* f);
406  void OpenAnyFile(const Char_t* filepath);
407  void OpenChain(const TString& treename, const TString& treetitle, const TSeqCollection* files);
408 
409  void DrawHisto(TObject* o, Bool_t gen = kTRUE);
410  void DrawHistogram(TH1* histo, Bool_t same = false, Bool_t logscale = false);
411  void DrawCut(TCutG*);
412  void DrawLeaf(TObject*);
413  void DrawLeafExpr();
414  void DrawAsDalitz();
416  {
417  fUserBinning = ub;
418  }
420  {
421  fUserWeight = uw;
422  }
423 
424  void SetAutoSaveHisto(Bool_t yes = kTRUE)
425  {
426  fAutoSaveHisto = yes;
427  if (yes) SetUpHistoAutoSave();
428  }
429  void SetStatsHisto(Bool_t yes = kTRUE)
430  {
431  fStatsHisto = yes;
432  }
433  void SetNormHisto(Bool_t yes = kTRUE)
434  {
435  fNormHisto = yes;
438  }
439  void SetNormHistoEvents(Bool_t yes = kTRUE)
440  {
441  fNormHistoEvents = yes;
442  fNormHisto = (yes ? kFALSE : fNormHisto);
444  }
445  void SetDrawOption(Option_t* option = "")
446  {
447  fDrawOption = option;
448  }
449 
450  void SetNewCanvas(Bool_t yes = kTRUE)
451  {
452  fNewCanvas = yes;
454  if (G_histo_same->IsOn()) {
456  fDrawSame = kFALSE;
457  }
458  }
459  void SetDrawSame(Bool_t yes = kTRUE)
460  {
461  fSameColorIndex = 0;
462  fDrawSame = yes;
464  if (G_histo_new_can->IsOn()) {
466  fNewCanvas = kFALSE;
467  }
468  }
469  void SetDrawLog(Bool_t yes = kTRUE)
470  {
471  fDrawLog = yes;
472  }
473  void SetApplySelection(Bool_t yes = kTRUE)
474  {
475  fApplySelection = yes;
476  }
477  void SetProfileHisto(Bool_t yes = kTRUE)
478  {
479  fProfileHisto = yes;
480  }
481  void LeafChanged();
482  void HistoSelectionChanged();
483  void Save();
484  void SaveAs(const char* filename = "", Option_t* option = "") const;
491 
493  {
494  return fNx;
495  }
497  {
498  return fNy;
499  }
501  {
502  return fXmin;
503  }
505  {
506  return fXmax;
507  }
509  {
510  return fYmin;
511  }
513  {
514  return fYmax;
515  }
516 
518  {
519  return fNxD;
520  }
522  {
523  return fNxD;
524  }
526  {
527  return fOrderedDalitz;
528  }
529 
531  {
532  return fNxF;
533  }
535  {
536  return fXminF;
537  }
539  {
540  return fXmaxF;
541  }
542 
543  const char* GetWeight()
544  {
545  return fWeight;
546  }
547 
548  void SetUpHistoAutoSave();
549 
552  void AutoSaveHisto(TH1* h);
553 
557  void GenerateAllAliases(TCollection* list);
558  void HistoFileMenu_Apply();
559  void ReapplyAnyFile(const Char_t* filepath);
560  void SetTreeFileName(TTree* t);
561 
563  {
564  return fgAnalyzerList;
565  }
566  static KVTreeAnalyzer* GetAnalyzer(const Char_t* title)
567  {
569  }
570 
571  void MakeAbsoluteIPScale(const char* name, Double_t sigmaTot);
572  void GenerateConstantXSecSelections(const char* name, Double_t sigmaTot, Double_t sigmaBin);// *MENU*
573 
574  void HandleOptionsMenu(Int_t opt);
575  void OpenAnyFriendFile(const Char_t* filepath);
578  ClassDef(KVTreeAnalyzer, 5) //KVTreeAnalyzer
579  void OpenSingleFile(TFile* file);
580 
581  TChain* GetChain() const
582  {
583  return fChain;
584  }
585  void GetHistosFromFile(TFile* file, const KVUnownedList& keys);
586 };
589 
590 #endif
int Int_t
#define R__EXTERN
R__EXTERN KVTreeAnalyzer * gTreeAnalyzer
................ global variable
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
const char Option_t
R__EXTERN TEnv * gEnv
EButtonState
Wrapper for histograms and graphical cuts used by KVTreeAnalyzer.
Definition: KVHistogram.h:19
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:145
Extended TList class which owns its objects by default.
Definition: KVList.h:27
virtual TObject * FindObjectByType(const Char_t *) const
virtual TObject * FindObjectByTitle(const Char_t *) const
Will return object with given title (value of TObject::GetTitle() method).
GUI for simple intuitive analysis of data in TTree ,.
void DeleteHisto(const Char_t *expr, const Char_t *selection, const Char_t *weight)
Int_t fSelectionNumber
used for automatic naming of selections
TGTextButton * G_fitGG2
Bool_t IsPROOFEnabledForSelections() const
Bool_t fNoGui
=kTRUE if no graphical interface is required
static KVTreeAnalyzer * OpenFile(const Char_t *filename, Bool_t nogui=kFALSE)
TList * GetHistosByData(const Char_t *expr)
KVHistogram * GetHistoByTitle(const Char_t *title)
TChain * fChain
the analyzed TTree or TChain
Double_t GetXminF()
Bool_t fNormHisto
=kTRUE: generate normalised histograms (normalise to integral of histo)
TGCheckButton * G_histo_norm
void SaveAs(const char *filename="", Option_t *option="") const
Bool_t IsPROOFEnabled() const
void MakeAbsoluteIPScale(const char *name, Double_t sigmaTot)
void SetTreeFileName(TTree *t)
void SetNewCanvas(Bool_t yes=kTRUE)
TGMenuBar * fMenuBar
Int_t fHistoNumber
used for automatic naming of histograms
void SetTree(TTree *t)
Connects a TChain for analysis.
TGGroupFrame * fMain_leaflist
GUI for access to TTree leaves and aliases.
void DeleteSelections()
Delete the currently selected selection(s)
TGTextButton * G_fit3
void ReconnectTree()
Backwards compatibility: to read old analysis files.
const TGMainFrame * GetMainWindow() const
void OpenAnyFile(const Char_t *filepath)
KVListView * G_histolist
GUI list of histograms.
Bool_t MakeSelection(const Char_t *selection)
void ReapplyAnyFile(const Char_t *filepath)
Double_t GetYmax()
void SetAnalysisModifiedSinceLastSave(Bool_t)
TString fAutoSaveDir
directory for autosaving histos
Bool_t fStatsHisto
=kTRUE: display histo stats box
Double_t GetXmaxF()
TGCheckButton * G_histo_app_sel
KVList * fSelectedLeaves
const Char_t * get_leaf_type_name(const TNamed *l)
Bool_t fApplySelection
=kTRUE: apply current selection to existing histogram
TString fTreeName
name of analyzed TTree
TString fAnalysisSaveDir
Bool_t fDrawSame
=kTRUE: draw histograms in same plot
Double_t GetXmax()
void GenerateAllAliases(TCollection *list)
Generate all user aliases in list which are not already defined.
TGTextButton * G_fitGG3
Int_t fAliasNumber
used for automatic naming of TTree aliases
Double_t GetYmin()
TH1 * RemakeHisto(TH1 *h, const Char_t *expr, const Char_t *weight="")
TH1 * MakeHisto(const Char_t *expr, const Char_t *selection, Int_t nX, Int_t nY=0, const Char_t *weight="", Double_t xmin=-1, Double_t xmax=-1, Double_t ymin=-1, Double_t ymax=-1)
void SetAlias(const Char_t *name, const Char_t *expr)
Bool_t fDeletedByGUIClose
TGTextButton * G_fitGG1
void SetDrawLog(Bool_t yes=kTRUE)
static KVList * fgAnalyzerList
static list of all analyzers in memory
TString fTreeFileName
name of file containing analyzed TTree
void DeleteSelectedHisto()
Delete all currently selected histograms.
void GUIClosed()
Called when graphical window is closed.
void GenerateConstantXSecSelections(const char *name, Double_t sigmaTot, Double_t sigmaBin)
TGTextButton * G_fit1
TEntryList * GetSelection(const Char_t *)
Look for selection in list of selections.
Bool_t IsCurrentSelection(const Char_t *sel)
void AutoSaveHisto(TH1 *h)
void SetUserWeight(Bool_t uw)
void SetAutoSaveHisto(Bool_t yes=kTRUE)
TGTextEntry * G_alias_text
TGPopupMenu * fSelCombMenu
TGTextButton * G_make_ip_scale
void SetDrawSame(Bool_t yes=kTRUE)
Bool_t fNewCanvas
=kTRUE: draw each histogram in a new canvas
void init()
Default initialization.
TString fRelativePathToAnalysisFile
TGCheckButton * G_histo_log
static KVTreeAnalyzer * GetAnalyzer(const Char_t *title)
void AddHisto(TH1 *)
TGComboBox * G_histo_draw_option
KVUniqueNameList fSelections
list of TEntryList user selections
const KVList * GetHistoList() const
void GenerateAllHistograms(TCollection *)
Bool_t fNormHistoEvents
=kTRUE: generate normalised histograms (normalise to number of events)
void SetSelection(TObject *)
void CurrentSelection()
Print the currently active selection (TEntryList set on TTree).
KVList fLeafList
clones of leaves in TChain
TGCheckButton * G_histo_weight
void UpdateEntryLists()
regenerate entry lists for all selections
TGCheckButton * G_histo_prof
ClassDef(KVTreeAnalyzer, 5) void OpenSingleFile(TFile *file)
void SetEntryList(TEntryList *)
void DrawCut(TCutG *)
void HistoAddition(Double_t c1=1, Double_t c2=1)
void OpenGUI()
Launch the GUI (unless fNoGui=kTRUE in which case this does nothing)
void HistoFileMenu_OpenFriend()
void SetProfileHisto(Bool_t yes=kTRUE)
TGPictureButton * G_histo_add
void SetRelativePathToAnalysisFile(const Char_t *p)
TGPictureButton * G_histo_del
TGCheckButton * G_histo_stats
KVTreeAnalyzer(Bool_t nogui=kTRUE)
TGCheckButton * G_histo_new_can
void HandleHistoFileMenu(Int_t)
void SetNormHisto(Bool_t yes=kTRUE)
TGCheckButton * G_histo_bin
void HandleOptionsMenu(Int_t opt)
TGGroupFrame * fMain_selectionlist
GUI for handling selections.
TList * fSelectedHistos
void GetHistosFromFile(TFile *file, const KVUnownedList &keys)
TString fSaveAnalysisFileName
TGLabel * G_ip_histo
void AddCut(TCutG *)
TGPopupMenu * fMenuSelections
Bool_t MethodNotCalled()
TGPictureButton * G_leaf_draw
Bool_t fAutoSaveHisto
=kTRUE: on draw, generate image file of current displayed histo
void HandleSelectionsMenu(Int_t)
void SetDrawOption(Option_t *option="")
Double_t GetXmin()
void DrawHistogram(TH1 *histo, Bool_t same=false, Bool_t logscale=false)
void SetNormHistoEvents(Bool_t yes=kTRUE)
void EnablePROOF(Bool_t yes=kTRUE)
KVList fHistolist
list of generated histograms
TGPopupMenu * fMenuFile
TList * GetHistosBySelection(const Char_t *expr)
TGTextEntry * G_make_ip_selection
void OpenAnyFriendFile(const Char_t *filepath)
TTree * fTree
for backwards compatibility
TGCheckButton * G_histo_norm_events
TChain * GetChain() const
void GenerateAllSelections(TCollection *)
For applying existing analysis to new data.
TGPopupMenu * fSelGenerate
const char * GetWeight()
TString fAutoSaveType
filetype for autosaving histos
TH1 * GetHistogram(const Char_t *name) const
Return histogram with given name.
TGPopupMenu * fOptionMenu
Long64_t GetEntriesInCurrentSelection() const
KVListView * G_selectionlist
GUI list of TEntryList selections.
static KVList * GetListOfAnalyzers()
Bool_t GetOrderedDalitz()
TGLabel * G_leaf_expr
TGStatusBar * G_selection_status
status bar in selections GUI
void AddSelection(TEntryList *)
TGLayoutHints * fMenuBarItemLayout
TGCheckButton * G_histo_same
TH1 * MakeIntHisto(const Char_t *expr, const Char_t *selection, Int_t Xmin, Int_t Xmax, const Char_t *weight="")
virtual ~KVTreeAnalyzer()
Destructor.
void OpenChain()
Open a file or files containing TTrees to analyse.
TGTextButton * G_fit2
void SelectionChanged()
Method called whenever the selected selection in the GUI list changes.
TGMainFrame * fMain_histolist
GUI for handling histograms.
TH1 * GetHisto(const Char_t *expr, const Char_t *selection, const Char_t *weight="")
Bool_t fAnalysisModifiedSinceLastSave
TNamed * GetAlias(const Char_t *expr)
void HistoSelectionChanged()
Method called when user histo selection changes in GUI histogram list.
void SetUserBinning(Bool_t ub)
void GenerateHistoTitle(TString &title, const Char_t *exp, const Char_t *sel, const Char_t *weight="")
void ReadFromFile(const Char_t *filename)
open a previously saved analysis session.
Bool_t fDrawLog
=kTRUE: draw histograms with log-Y (1-D) or log-Z (2-D) scale
void HistoFileMenu_Open()
Open a previous analysis session.
void DrawLeaf(TObject *)
Method called when user double-clicks a leaf/alias in list.
void SetApplySelection(Bool_t yes=kTRUE)
KVList fAliasList
list of TTree aliases
TList * fSelectedSelections
void Copy(TObject &obj) const
void DrawHisto(TObject *o, Bool_t gen=kTRUE)
TGCheckButton * G_histo_autosave
TGTextEntry * G_selection_text
KVListView * G_leaflist
GUI list of TTree leaves and aliases.
Bool_t fMethodCalled
allows to know if context menu methods are called
void ResetMethodCalled()
void SetStatsHisto(Bool_t yes=kTRUE)
Optimised list in which named objects can only be placed once.
Extended TList class which does not own its objects by default.
Definition: KVUnownedList.h:16
virtual void ls(Option_t *option="") const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Bool_t IsOn() const
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
virtual TObjArray * GetListOfLeaves()
long long Long64_t
auto * l