JG ROOT Tools libraries  version 5.0 - august 2014
RRootFilesFunctions.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file RRootFilesFunctions.hh
3  *
4  * Include file for functions related to ROOT files.
5  */
6 //======================================================================
7 
8 #ifndef R_ROOT_FILE_FUNCTIONS_HH
9 #define R_ROOT_FILE_FUNCTIONS_HH
10 
11 #include <TH1.h>
12 
13 #include "RBaseFunctions.hh"
14 #include "RObject.hh"
15 
16 #include "GTreeNodeT.hh"
17 
18 //----------------------------------------------------------------------
19 // Reading objects in a ROOT file
20 extern TH1 * RGetFileHisto ( TDirectory * dir, const char histo_name[], bool recur = true );
21 extern TH1 * RGetFileHisto ( const char file_name[], const char histo_name[] );
22 
23 //----------------------------------------------------------------------
24 // Functions related to histograms in a ROOT file
25 extern Int_t RGetHistoNames ( const char file_name[],
26  string *& histo_names,
27  Int_t *& histo_dim,
28  Int_t dmin = 1,
29  Int_t dmax = 3);
30 
31 extern Int_t RGetHistoNames ( const char file_name[],
32  string *& histo_names,
33  Int_t dmin = 1,
34  Int_t dmax = 3);
35 
36 //----------------------------------------------------------------------
37 // Creating an arborescence of selected ROOT objects from a ROOT file
38 
39 extern bool RCheckDirObjects ( TDirectory * dir, const string & obj_class, bool recur = true );
40 extern u_int RCountDirObjects ( TDirectory * dir, const string & obj_class, bool recur = true );
41 
42 extern RTreeBranchTObject * RGetObjectTree ( TDirectory * dir, const string & obj_class );
43 
44 //----------------------------------------------------------------------
45 
46 extern bool RCheckDirHisto ( TDirectory * dir, bool recur = true ); // inline
47 extern u_int RCountDirHisto ( TDirectory * dir, bool recur = true ); // inline
48 
49 extern RTreeBranchTObject * RGetHistoTree ( TDirectory * dir, bool local = true );
50 
51 
52 //======================================================================
53 // inline functions
54 
55 /*! This function returns "true" if the ROOT directory contains one or
56  * more histograms.
57  * \param dir ROOT directory
58  * \param recur recursive search in sub-directories
59  */
60 inline bool RCheckDirHisto ( TDirectory * dir, bool recur )
61  { return ( RCheckDirObjects ( dir, "TH1", recur ) ); }
62 
63 /*! This function returns the number of ROOT histograms in the directory.
64  * If several versions of the histograms exist, they are counted only once.
65  * \param dir ROOT directory
66  * \param recur recursive search in sub-directories
67  */
68 inline u_int RCountDirHisto ( TDirectory * dir, bool recur )
69  { return ( RCountDirObjects ( dir, "TH1", recur ) ); }
70 
71 //======================================================================
72 #endif
RTreeBranchTObject * RGetHistoTree(TDirectory *dir, bool local)
Definition: RRootFilesFunctions.cpp:463
RTreeBranchTObject * RGetObjectTree(TDirectory *dir, const string &obj_class)
Definition: RRootFilesFunctions.cpp:400
u_int RCountDirHisto(TDirectory *dir, bool recur=true)
Definition: RRootFilesFunctions.hh:68
GTreeBranchT< RObject > RTreeBranchTObject
Definition: RObject.hh:27
bool RCheckDirHisto(TDirectory *dir, bool recur=true)
Definition: RRootFilesFunctions.hh:60
u_int RCountDirObjects(TDirectory *dir, const string &obj_class, bool recur)
Definition: RRootFilesFunctions.cpp:358
TH1 * RGetFileHisto(const char file_name[], const char histo_name[])
Definition: RRootFilesFunctions.cpp:23
Int_t RGetHistoNames(const char file_name[], string *&histo_names, Int_t *&histo_dim, Int_t dmin, Int_t dmax)
Definition: RRootFilesFunctions.cpp:174
bool RCheckDirObjects(TDirectory *dir, const string &obj_class, bool recur)
Definition: RRootFilesFunctions.cpp:305