KaliVeda  1.12/06
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 "KVImpactParameter.h"
127 
128 class KVHistogram;
129 
148 class KVTreeAnalyzer : public TNamed {
149 private:
150  const Char_t* get_leaf_type_name(const TNamed* l);
152 
153  void init();
155 
159 
162 
163  /* leaves */
182 
187 
190 
191  /* histos */
198  enum {
213  };
214  void HistoFileMenu_Open();
215  void OpenChain();
216  void HistoFileMenu_Save();
260 
261  /* selections */
267 
276 
278 
282 
285  {
287  }
288 
290 
292 
294  {
296  }
298  {
299  return !fMethodCalled;
300  }
301 
302  void AddHisto(TH1*);
303  void AddCut(TCutG*);
304  void AddSelection(TEntryList*);
305  void ReconnectTree();
306 
307  void GenerateHistoTitle(TString& title, const Char_t* exp, const Char_t* sel, const Char_t* weight = "");
308  void FillLeafList();
309 
310  void AnalysisSaveCheck();
312 
313  void SetEntryList(TEntryList*);
314 
315 public:
316  KVTreeAnalyzer(Bool_t nogui = kTRUE);
317  KVTreeAnalyzer(TTree*, Bool_t nogui = kFALSE);
318  virtual ~KVTreeAnalyzer();
319  void DeleteThis()
320  {
321  delete this;
322  }
323 
324  void Copy(TObject& obj) const;
325 
326  void SetTree(TTree* t);
327  void OpenGUI();
328  void GUIClosed();
329  TH1* MakeHisto(const Char_t* expr, const Char_t* selection, Int_t nX, Int_t nY = 0, const Char_t* weight = "");
330  TH1* RemakeHisto(TH1* h, const Char_t* expr, const Char_t* weight = "");
331  TH1* MakeIntHisto(const Char_t* expr, const Char_t* selection, Int_t Xmin, Int_t Xmax, const Char_t* weight = "");
332  const KVList* GetHistoList() const
333  {
334  return &fHistolist;
335  }
336  TH1* GetHistogram(const Char_t* name) const;
337  TList* GetHistosByData(const Char_t* expr);
338  TList* GetHistosBySelection(const Char_t* expr);
339  TH1* GetHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight = "");
340  KVHistogram* GetHistoByTitle(const Char_t* title);
341  void DeleteHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight);
342  void DeleteSelectedHisto();
343  void AddSelectedHistos();
344  void HistoAddition(Double_t c1 = 1, Double_t c2 = 1);
345 
346  Bool_t MakeSelection(const Char_t* selection);
347  void UpdateEntryLists();
348  void GenerateSelection();
351  void CombineSelectionsAnd();
352  void CombineSelectionsOr();
353  void DeleteSelections();
354  void SelectionChanged();
355  void SetAlias(const Char_t* name, const Char_t* expr);
356  void GenerateAlias();
357  TNamed* GetAlias(const Char_t* expr)
358  {
359  return (TNamed*)fAliasList.FindObjectByType(expr);
360  }
362  {
363  fSelections.ls();
364  }
366  {
367  fTree->GetListOfLeaves()->ls();
368  }
369  void ShowAliases()
370  {
371  fAliasList.ls();
372  }
373  void ShowHistos()
374  {
375  fHistolist.ls();
376  }
377  void CurrentSelection();
378  Bool_t IsCurrentSelection(const Char_t* sel);
379  void SetSelection(TObject*);
380  void SetSelection(const Char_t*);
381  TEntryList* GetSelection(const Char_t*);
382 
383  void EnablePROOF(Bool_t yes = kTRUE);
385  {
386  return fPROOFEnabled;
387  }
389  {
394  return (gEnv->GetValue("KVTreeAnalyzer.PROOFSelections", 0) && fPROOFEnabled);
395  }
396 
397  static KVTreeAnalyzer* OpenFile(const Char_t* filename, Bool_t nogui = kFALSE);
398  void ReadFromFile(const Char_t* filename);
399  void ReadFromFile(TFile* f);
400  void OpenAnyFile(const Char_t* filepath);
401  void OpenChain(const TString& treename, const TString& treetitle, const TSeqCollection* files);
402 
403  void DrawHisto(TObject* o, Bool_t gen = kTRUE);
404  void DrawCut(TCutG*);
405  void DrawLeaf(TObject*);
406  void DrawLeafExpr();
407  void DrawAsDalitz();
409  {
410  fUserBinning = ub;
411  }
413  {
414  fUserWeight = uw;
415  }
416 
417  void SetAutoSaveHisto(Bool_t yes = kTRUE)
418  {
419  fAutoSaveHisto = yes;
420  if (yes) SetUpHistoAutoSave();
421  }
422  void SetStatsHisto(Bool_t yes = kTRUE)
423  {
424  fStatsHisto = yes;
425  }
426  void SetNormHisto(Bool_t yes = kTRUE)
427  {
428  fNormHisto = yes;
431  }
432  void SetNormHistoEvents(Bool_t yes = kTRUE)
433  {
434  fNormHistoEvents = yes;
435  fNormHisto = (yes ? kFALSE : fNormHisto);
437  }
438  void SetDrawOption(Option_t* option = "")
439  {
440  fDrawOption = option;
441  }
442 
443  void SetNewCanvas(Bool_t yes = kTRUE)
444  {
445  fNewCanvas = yes;
447  if (G_histo_same->IsOn()) {
449  fDrawSame = kFALSE;
450  }
451  }
452  void SetDrawSame(Bool_t yes = kTRUE)
453  {
454  fSameColorIndex = 0;
455  fDrawSame = yes;
457  if (G_histo_new_can->IsOn()) {
459  fNewCanvas = kFALSE;
460  }
461  }
462  void SetDrawLog(Bool_t yes = kTRUE)
463  {
464  fDrawLog = yes;
465  }
466  void SetApplySelection(Bool_t yes = kTRUE)
467  {
468  fApplySelection = yes;
469  }
470  void SetProfileHisto(Bool_t yes = kTRUE)
471  {
472  fProfileHisto = yes;
473  }
474  void LeafChanged();
475  void HistoSelectionChanged();
476  void Save();
477  void SaveAs(const char* filename = "", Option_t* option = "") const;
484 
486  {
487  return fNx;
488  }
490  {
491  return fNy;
492  }
494  {
495  return fXmin;
496  }
498  {
499  return fXmax;
500  }
502  {
503  return fYmin;
504  }
506  {
507  return fYmax;
508  }
509 
511  {
512  return fNxD;
513  }
515  {
516  return fNxD;
517  }
519  {
520  return fOrderedDalitz;
521  }
522 
524  {
525  return fNxF;
526  }
528  {
529  return fXminF;
530  }
532  {
533  return fXmaxF;
534  }
535 
536  const char* GetWeight()
537  {
538  return fWeight;
539  }
540 
541  void DefineUserBinning(Int_t Nx, Int_t Ny, Double_t Xmin, Double_t Xmax, Double_t Ymin, Double_t Ymax);// *MENU* *ARGS={Nx=>fNx,Ny=>fNy,Xmin=>fXmin,Xmax=>fXmax,Ymin=>fYmin,Ymax=>fYmax}
542  void DefineUserBinning1F(Int_t NxF, Double_t XminF, Double_t XmaxF);// *MENU* *ARGS={NxF=>fNxF,XminF=>fXminF,XmaxF=>fXmaxF}
543  void DefineUserBinningD(Int_t NxD, Int_t NyD, Int_t ordered);// *MENU* *ARGS={NxD=>fNxD,NyD=>fNyD,ordered=>fOrderedDalitz}
544  void DefineWeight(const Char_t* Weight);// *MENU* *ARGS={Weight=>fWeight}
545 
546  void SetUpHistoAutoSave();
547 
550  void AutoSaveHisto(TH1* h);
551 
555  void GenerateAllAliases(TCollection* list);
556  void HistoFileMenu_Apply();
557  void ReapplyAnyFile(const Char_t* filepath);
558  void SetTreeFileName(TTree* t);
559 
561  {
562  return fgAnalyzerList;
563  }
564  static KVTreeAnalyzer* GetAnalyzer(const Char_t* title)
565  {
567  }
568 
569  void MakeAbsoluteIPScale(const char* name, Double_t sigmaTot);
570  void GenerateConstantXSecSelections(const char* name, Double_t sigmaTot, Double_t sigmaBin);// *MENU*
571 
572  void HandleOptionsMenu(Int_t opt);
573  void OpenAnyFriendFile(const Char_t* filepath);
576  ClassDef(KVTreeAnalyzer, 5) //KVTreeAnalyzer
577  void OpenSingleFile(TFile* file);
578 
579  TChain* GetChain() const
580  {
581  return fChain;
582  }
583 };
586 
587 #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
Impact parameter analysis tools.
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()
void DefineUserBinning(Int_t Nx, Int_t Ny, Double_t Xmin, Double_t Xmax, Double_t Ymin, Double_t Ymax)
Bool_t fNormHisto
=kTRUE: generate normalised histograms (normalise to integral of histo)
TGCheckButton * G_histo_norm
void DefineUserBinning1F(Int_t NxF, Double_t XminF, Double_t XmaxF)
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.
void OpenAnyFile(const Char_t *filepath)
KVListView * G_histolist
GUI list of histograms.
Bool_t MakeSelection(const Char_t *selection)
void DefineUserBinningD(Int_t NxD, Int_t NyD, Int_t ordered)
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.
void DefineWeight(const Char_t *Weight)
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="")
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
KVImpactParameter * ipscale
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
TH1 * MakeHisto(const Char_t *expr, const Char_t *selection, Int_t nX, Int_t nY=0, const Char_t *weight="")
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
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 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.
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
RooCmdArg Weight(Double_t wgt)
auto * l