KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVTreeAnalyzer.h
1
3
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
126class KVHistogram;
127
147class KVTreeAnalyzer : public TNamed {
148private:
149 const Char_t* get_leaf_type_name(const TNamed* l);
151
152 void init();
154
158
161
162 /* leaves */
181
186
189
190 /* histos */
193 {
194 return fMain_histolist;
195 }
201 enum {
216 };
217 void HistoFileMenu_Open();
218 void OpenChain();
219 void HistoFileMenu_Save();
262
263 /* selections */
269
278
280
284
290
292
294
296 {
298 }
300 {
301 return !fMethodCalled;
302 }
303
304 void AddHisto(TH1*);
305 void AddCut(TCutG*);
307 void ReconnectTree();
308
309 void GenerateHistoTitle(TString& title, const Char_t* exp, const Char_t* sel, const Char_t* weight = "");
310 void FillLeafList();
311
312 void AnalysisSaveCheck();
314
316
317 bool DefineWeight();
318 bool DefineUserBinning();
319 bool DefineUserBinning1F();
320 bool DefineUserBinningD();
321
322 double GetTreeMaximum(const TString& leafname);
323 double GetTreeMinimum(const TString& leafname);
324
325public:
326 KVTreeAnalyzer(Bool_t nogui = kTRUE);
327 KVTreeAnalyzer(TTree*, Bool_t nogui = kFALSE);
328 virtual ~KVTreeAnalyzer();
330 {
331 delete this;
332 }
333
334 void Copy(TObject& obj) const;
335
336 void SetTree(TTree* t);
337 void OpenGUI();
338 void GUIClosed();
339 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);
340 TH1* RemakeHisto(TH1* h, const Char_t* expr, const Char_t* weight = "");
341 TH1* MakeIntHisto(const Char_t* expr, const Char_t* selection, Int_t Xmin, Int_t Xmax, const Char_t* weight = "");
342 const KVList* GetHistoList() const
343 {
344 return &fHistolist;
345 }
346 TH1* GetHistogram(const Char_t* name) const;
349 TH1* GetHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight = "");
350 KVHistogram* GetHistoByTitle(const Char_t* title);
351 void DeleteHisto(const Char_t* expr, const Char_t* selection, const Char_t* weight);
352 void DeleteSelectedHisto();
353 void AddSelectedHistos();
354 void HistoAddition(Double_t c1 = 1, Double_t c2 = 1);
355
357 void UpdateEntryLists();
358 void GenerateSelection();
362 void CombineSelectionsOr();
363 void DeleteSelections();
364 void SelectionChanged();
365 void SetAlias(const Char_t* name, const Char_t* expr);
366 void GenerateAlias();
368 {
370 }
372 {
373 fSelections.ls();
374 }
376 {
378 }
380 {
381 fAliasList.ls();
382 }
384 {
385 fHistolist.ls();
386 }
387 void CurrentSelection();
388 Bool_t IsCurrentSelection(const Char_t* sel);
389 void SetSelection(TObject*);
390 void SetSelection(const Char_t*);
392
393 void EnablePROOF(Bool_t yes = kTRUE);
395 {
396 return fPROOFEnabled;
397 }
399 {
404 return (gEnv->GetValue("KVTreeAnalyzer.PROOFSelections", 0) && fPROOFEnabled);
405 }
406
407 static KVTreeAnalyzer* OpenFile(const Char_t* filename, Bool_t nogui = kFALSE);
408 void ReadFromFile(const Char_t* filename);
409 void ReadFromFile(TFile* f);
410 void OpenAnyFile(const Char_t* filepath);
411 void OpenChain(const TString& treename, const TString& treetitle, const TSeqCollection* files);
412
413 void DrawHisto(TObject* o, Bool_t gen = kTRUE);
414 void DrawHistogram(TH1* histo, Bool_t same = false, Bool_t logscale = false);
415 void DrawCut(TCutG*);
416 void DrawLeaf(TObject*);
417 void DrawLeafExpr();
418 void DrawAsDalitz();
420 {
422 }
424 {
425 fUserWeight = uw;
426 }
427
429 {
431 if (yes) SetUpHistoAutoSave();
432 }
434 {
436 }
449 void SetDrawOption(Option_t* option = "")
450 {
452 }
453
454 void SetNewCanvas(Bool_t yes = kTRUE)
455 {
456 fNewCanvas = yes;
458 if (G_histo_same->IsOn()) {
461 }
462 }
463 void SetDrawSame(Bool_t yes = kTRUE)
464 {
465 fSameColorIndex = 0;
466 fDrawSame = yes;
468 if (G_histo_new_can->IsOn()) {
471 }
472 }
473 void SetDrawLog(Bool_t yes = kTRUE)
474 {
475 fDrawLog = yes;
476 }
478 {
480 }
482 {
484 }
485 void LeafChanged();
487 void Save();
488 void SaveAs(const char* filename = "", Option_t* option = "") const;
495
497 {
498 return fNx;
499 }
501 {
502 return fNy;
503 }
505 {
506 return fXmin;
507 }
509 {
510 return fXmax;
511 }
513 {
514 return fYmin;
515 }
517 {
518 return fYmax;
519 }
520
522 {
523 return fNxD;
524 }
526 {
527 return fNxD;
528 }
530 {
531 return fOrderedDalitz;
532 }
533
535 {
536 return fNxF;
537 }
539 {
540 return fXminF;
541 }
543 {
544 return fXmaxF;
545 }
546
547 const char* GetWeight()
548 {
549 return fWeight;
550 }
551
552 void SetUpHistoAutoSave();
553
556 void AutoSaveHisto(TH1* h);
557
562 void HistoFileMenu_Apply();
563 void ReapplyAnyFile(const Char_t* filepath);
564 void SetTreeFileName(TTree* t);
565
567 {
568 return fgAnalyzerList;
569 }
570 static KVTreeAnalyzer* GetAnalyzer(const Char_t* title)
571 {
573 }
574
575 void MakeAbsoluteIPScale(const char* name, Double_t sigmaTot);
577
578 void HandleOptionsMenu(Int_t opt);
579 void OpenAnyFriendFile(const Char_t* filepath);
582 ClassDef(KVTreeAnalyzer, 5) //KVTreeAnalyzer
584
586 {
587 return fChain;
588 }
589 void GetHistosFromFile(TFile* file, const KVUnownedList& keys);
590};
592R__EXTERN KVTreeAnalyzer* gTreeAnalyzer;
593
594#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
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()
const char * GetWeight()
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.
void OpenAnyFile(const Char_t *filepath)
KVListView * G_histolist
GUI list of histograms.
TNamed * GetAlias(const Char_t *expr)
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)
static KVTreeAnalyzer * GetAnalyzer(const Char_t *title)
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
double GetTreeMinimum(const TString &leafname)
const TGMainFrame * GetMainWindow() const
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
TGComboBox * G_histo_draw_option
KVUniqueNameList fSelections
list of TEntryList user selections
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
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 *)
const KVList * GetHistoList() const
TGPopupMenu * fMenuSelections
Bool_t MethodNotCalled()
TGPictureButton * G_leaf_draw
static KVList * GetListOfAnalyzers()
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
void GenerateAllSelections(TCollection *)
For applying existing analysis to new data.
TGPopupMenu * fSelGenerate
TString fAutoSaveType
filetype for autosaving histos
TH1 * GetHistogram(const Char_t *name) const
Return histogram with given name.
TGPopupMenu * fOptionMenu
Long64_t GetEntriesInCurrentSelection() const
TChain * GetChain() const
KVListView * G_selectionlist
GUI list of TEntryList selections.
double GetTreeMaximum(const TString &leafname)
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
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 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.
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
virtual TObjArray * GetListOfLeaves()
long long Long64_t
TLine l