KaliVeda
Toolkit for HIC analysis
KVTreeAnalyzer.h
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 
147 class KVTreeAnalyzer : public TNamed {
148 private:
149  const Char_t* get_leaf_type_name(const TNamed* l);
151 
152  void init();
154 
158 
161 
162  /* leaves */
181 
186 
189 
191 
192  /* histos */
194  const TGMainFrame* GetMainWindow() const
195  {
196  return fMain_histolist;
197  }
203  enum {
218  };
219  void HistoFileMenu_Open();
220  void OpenChain();
221  void HistoFileMenu_Save();
264 
265  /* selections */
271 
280 
282 
286 
289  {
291  }
292 
294 
296 
298  {
300  }
302  {
303  return !fMethodCalled;
304  }
305 
306  void AddHisto(TH1*);
307  void AddCut(TCutG*);
308  void AddSelection(TEntryList*);
309  void ReconnectTree();
310 
311  void GenerateHistoTitle(TString& title, const Char_t* exp, const Char_t* sel, const Char_t* weight = "");
312  void FillLeafList();
313 
314  void AnalysisSaveCheck();
316 
317  void SetEntryList(TEntryList*);
318 
319  bool DefineWeight();
320  bool DefineUserBinning();
321  bool DefineUserBinning1F();
322  bool DefineUserBinningD();
323 
324  double GetTreeMaximum(const TString& leafname);
325  double GetTreeMinimum(const TString& leafname);
326 
327  void SetWindowTitle(const TString& tt)
328  {
330  }
331 
332 public:
333  KVTreeAnalyzer(Bool_t nogui = kTRUE);
334  KVTreeAnalyzer(TTree*, Bool_t nogui = kFALSE);
335  virtual ~KVTreeAnalyzer();
336  void DeleteThis()
337  {
338  delete this;
339  }
340 
341  void Copy(TObject& obj) const override;
342 
343  void SetTree(TTree* t);
344  void OpenGUI();
345  void GUIClosed();
346  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);
347  TH1* RemakeHisto(TH1* h, const Char_t* expr, const Char_t* weight = "");
348  TH1* MakeIntHisto(const Char_t* expr, const Char_t* selection, Int_t Xmin, Int_t Xmax, const Char_t* weight = "");
349  const KVList* GetHistoList() const
350  {
351  return &fHistolist;
352  }
353  TH1* GetHistogram(const Char_t* name) const;
354  TList* GetHistosByData(const Char_t* expr);
355  TList* GetHistosBySelection(const Char_t* expr);
356  TH1* GetHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight = "");
357  KVHistogram* GetHistoByTitle(const Char_t* title);
358  void DeleteHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight);
359  void DeleteSelectedHisto();
360  void AddSelectedHistos();
361  void HistoAddition(Double_t c1 = 1, Double_t c2 = 1);
362 
363  Bool_t MakeSelection(const Char_t* selection);
364  void UpdateEntryLists();
365  void GenerateSelection();
368  void CombineSelectionsAnd();
369  void CombineSelectionsOr();
370  void DeleteSelections();
371  void SelectionChanged();
372  void SetAlias(const Char_t* name, const Char_t* expr);
373  void GenerateAlias();
374  TNamed* GetAlias(const Char_t* expr)
375  {
376  return (TNamed*)fAliasList.FindObjectByType(expr);
377  }
379  {
380  fSelections.ls();
381  }
383  {
384  fTree->GetListOfLeaves()->ls();
385  }
386  void ShowAliases()
387  {
388  fAliasList.ls();
389  }
390  void ShowHistos()
391  {
392  fHistolist.ls();
393  }
394  void CurrentSelection();
395  Bool_t IsCurrentSelection(const Char_t* sel);
396  void SetSelection(TObject*);
397  void SetSelection(const Char_t*);
398  TEntryList* GetSelection(const Char_t*);
399 
400  void EnablePROOF(Bool_t yes = kTRUE);
402  {
403  return fPROOFEnabled;
404  }
406  {
411  return (gEnv->GetValue("KVTreeAnalyzer.PROOFSelections", 0) && fPROOFEnabled);
412  }
413 
414  static KVTreeAnalyzer* OpenFile(const Char_t* filename, Bool_t nogui = kFALSE);
415  void ReadFromFile(const Char_t* filename);
416  void ReadFromFile(TFile* f);
417  void OpenAnyFile(const Char_t* filepath);
418  void OpenChain(const TString& treename, const TString& treetitle, const TSeqCollection* files);
419 
420  void DrawHisto(TObject* o, Bool_t gen = kTRUE);
421  void DrawHistogram(TH1* histo, Bool_t same = false, Bool_t logscale = false);
422  void DrawCut(TCutG*);
423  void DrawLeaf(TObject*);
424  void DrawLeafExpr();
425  void DrawAsDalitz();
427  {
428  fUserBinning = ub;
429  }
431  {
432  fUserWeight = uw;
433  }
434 
435  void SetAutoSaveHisto(Bool_t yes = kTRUE)
436  {
437  fAutoSaveHisto = yes;
438  if (yes) SetUpHistoAutoSave();
439  }
440  void SetStatsHisto(Bool_t yes = kTRUE)
441  {
442  fStatsHisto = yes;
443  }
444  void SetNormHisto(Bool_t yes = kTRUE)
445  {
446  fNormHisto = yes;
449  }
450  void SetNormHistoEvents(Bool_t yes = kTRUE)
451  {
452  fNormHistoEvents = yes;
453  fNormHisto = (yes ? kFALSE : fNormHisto);
455  }
456  void SetDrawOption(Option_t* option = "") override
457  {
459  }
460 
461  void SetNewCanvas(Bool_t yes = kTRUE)
462  {
463  fNewCanvas = yes;
465  if (G_histo_same->IsOn()) {
467  fDrawSame = kFALSE;
468  }
469  }
470  void SetDrawSame(Bool_t yes = kTRUE)
471  {
472  fSameColorIndex = 0;
473  fDrawSame = yes;
475  if (G_histo_new_can->IsOn()) {
477  fNewCanvas = kFALSE;
478  }
479  }
480  void SetDrawLog(Bool_t yes = kTRUE)
481  {
482  fDrawLog = yes;
483  }
484  void SetApplySelection(Bool_t yes = kTRUE)
485  {
486  fApplySelection = yes;
487  }
488  void SetProfileHisto(Bool_t yes = kTRUE)
489  {
490  fProfileHisto = yes;
491  }
492  void LeafChanged();
493  void HistoSelectionChanged();
494  void Save();
495  void SaveAs(const char* filename = "", Option_t* option = "") const override;
502 
504  {
505  return fNx;
506  }
508  {
509  return fNy;
510  }
512  {
513  return fXmin;
514  }
516  {
517  return fXmax;
518  }
520  {
521  return fYmin;
522  }
524  {
525  return fYmax;
526  }
527 
529  {
530  return fNxD;
531  }
533  {
534  return fNxD;
535  }
537  {
538  return fOrderedDalitz;
539  }
540 
542  {
543  return fNxF;
544  }
546  {
547  return fXminF;
548  }
550  {
551  return fXmaxF;
552  }
553 
554  const char* GetWeight()
555  {
556  return fWeight;
557  }
558 
559  void SetUpHistoAutoSave();
560 
563  void AutoSaveHisto(TH1* h);
564 
568  void GenerateAllAliases(TCollection* list);
569  void HistoFileMenu_Apply();
570  void ReapplyAnyFile(const Char_t* filepath);
571  void SetTreeFileName(TTree* t);
572 
574  {
575  return fgAnalyzerList;
576  }
577  static KVTreeAnalyzer* GetAnalyzer(const Char_t* title)
578  {
580  }
581 
582  void MakeAbsoluteIPScale(const char* name, Double_t sigmaTot);
583  void GenerateConstantXSecSelections(const char* name, Double_t sigmaTot, Double_t sigmaBin);// *MENU*
584 
585  void HandleOptionsMenu(Int_t opt);
586  void OpenAnyFriendFile(const Char_t* filepath);
589  ClassDefOverride(KVTreeAnalyzer, 5) //KVTreeAnalyzer
590  void OpenSingleFile(TFile* file);
591 
592  TChain* GetChain() const
593  {
594  return fChain;
595  }
596  void GetHistosFromFile(TFile* file, const KVUnownedList& keys);
597 };
599 R__EXTERN KVTreeAnalyzer* gTreeAnalyzer;
600 
601 #endif
int Int_t
#define R__EXTERN
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
const char Option_t
R__EXTERN TEnv * gEnv
EButtonState
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Wrapper for histograms and graphical cuts used by KVTreeAnalyzer.
Definition: KVHistogram.h:20
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:146
Extended TList class which owns its objects by default.
Definition: KVList.h:28
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
void SetDrawOption(Option_t *option="") override
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
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
void SetWindowTitle(const TString &tt)
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
void SaveAs(const char *filename="", Option_t *option="") const override
void Copy(TObject &obj) const override
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
double GetTreeMinimum(const TString &leafname)
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
bool got_histos_or_tree_from_file
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
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)
ClassDefOverride(KVTreeAnalyzer, 5) void OpenSingleFile(TFile *file)
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)
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.
double GetTreeMaximum(const TString &leafname)
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 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:17
void ls(Option_t *option="") const override
virtual const char * GetValue(const char *name, const char *dflt) const
Bool_t IsOn() const override
void SetState(EButtonState state, Bool_t emit=kFALSE) override
void SetWindowName(const char *name=nullptr) override
virtual TObjArray * GetListOfLeaves()
long long Long64_t
TLine l
auto * tt