/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 00024 #ifndef HISTMAN_HISTMAN_H 00025 #define HISTMAN_HISTMAN_H 00026 00027 #include <TFolder.h> 00028 #include <TH1.h> 00029 #include <vector> 00030 //#include <HistMan/RootHists.h> // needed for inside Cint.cc file 00031 00032 class TFile; 00033 00034 // Helper. Acts like "mkdir -p" to add a full path with 1 or more 00035 // subdirectories. Return last folder. This should be in TFolder.... 00036 TFolder& mkdir_p(TFolder& folder, const char* path); 00037 00038 class HistMan { 00039 TFolder* fFolder; 00040 bool fOwn; 00041 00042 00043 public: 00049 HistMan(const char* base_directory = ""); 00050 00057 HistMan(TFile& file, bool attach = true); 00058 00062 HistMan(TFolder* folder, bool own=true); 00063 00071 HistMan(const char** file_list, const char** hist_list); 00072 00074 ~HistMan(); 00075 00077 TFolder& BaseFolder(); 00078 00083 void RegisterWithRoot(); 00084 00086 void WriteOut(TFile& opened_file); 00087 00089 void WriteOut(const char* filename); 00090 00096 TObject* Adopt(const char* path, TObject* hist); 00097 00102 template<class THType> 00103 THType* Get(const char* pathname) { 00104 return dynamic_cast<THType*>(this->GetObject(pathname)); 00105 } 00106 00107 00109 TObject* GetObject(const char* pathname); 00111 TFolder* GetFolder(const char* pathname); 00113 TObject* GetObjectOrFolder(const char* pathname); 00115 std::vector<TObject*> GetObjects(const char* pathname); 00117 std::vector<TFolder*> GetSubFolders(const char* pathname); 00118 00120 00124 template<class THType> 00125 THType* Book(const char* name, const char* title, 00126 int nbinsx, Axis_t xmin, Axis_t xmax, 00127 const char* path=".", Bool_t sumw2=kFALSE) { 00128 THType* h = new THType(name,title,nbinsx,xmin,xmax); 00129 if ( sumw2 ) { 00130 h->Sumw2(); 00131 } 00132 TObject* o = Adopt(path, h); 00133 return dynamic_cast<THType*>(o); 00134 } 00135 00139 template<class THType> 00140 THType* Book(const char* name, const char* title, 00141 int nbinsx, Axis_t xmin, Axis_t xmax, 00142 int nbinsy, Axis_t ymin, Axis_t ymax, 00143 const char* path=".", Bool_t sumw2=kFALSE) { 00144 THType* h = new THType(name,title,nbinsx,xmin,xmax, nbinsy,ymin,ymax); 00145 if ( sumw2 ) { 00146 h->Sumw2(); 00147 } 00148 TObject* o = Adopt(path, h); 00149 return dynamic_cast<THType*>(o); 00150 } 00151 00155 bool Fill1d(const char* pathname, Axis_t x, Stat_t w=1.0); 00156 00160 bool Fill2d(const char* pathname, Axis_t x, Axis_t y, Stat_t w=1.0); 00161 00165 bool FillProfile(const char* pathname, Axis_t x, Axis_t y, Stat_t w=1.0); 00166 00167 }; 00168 00169 00170 00171 #endif // HISTMAN_HISTMAN_H