00001
00024 #ifndef HISTMAN_HISTMAN_H
00025 #define HISTMAN_HISTMAN_H
00026
00027 #include <TFolder.h>
00028 #include <TH1.h>
00029
00030 #include <HistMan/RootHists.h>
00031
00032 class TFile;
00033
00034
00035
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);
00110
00112
00116 template<class THType>
00117 THType* Book(const char* name, const char* title,
00118 int nbinsx, Axis_t xmin, Axis_t xmax,
00119 const char* path=".", Bool_t sumw2=kFALSE) {
00120 THType* h = new THType(name,title,nbinsx,xmin,xmax);
00121 if ( sumw2 ) {
00122 h->Sumw2();
00123 }
00124 TObject* o = Adopt(path, h);
00125 return dynamic_cast<THType*>(o);
00126 }
00127
00131 template<class THType>
00132 THType* Book(const char* name, const char* title,
00133 int nbinsx, Axis_t xmin, Axis_t xmax,
00134 int nbinsy, Axis_t ymin, Axis_t ymax,
00135 const char* path=".", Bool_t sumw2=kFALSE) {
00136 THType* h = new THType(name,title,nbinsx,xmin,xmax, nbinsy,ymin,ymax);
00137 if ( sumw2 ) {
00138 h->Sumw2();
00139 }
00140 TObject* o = Adopt(path, h);
00141 return dynamic_cast<THType*>(o);
00142 }
00143
00147 bool Fill1d(const char* pathname, Axis_t x, Stat_t w=1.0);
00148
00152 bool Fill2d(const char* pathname, Axis_t x, Axis_t y, Stat_t w=1.0);
00153
00157 bool FillProfile(const char* pathname, Axis_t x, Axis_t y, Stat_t w=1.0);
00158
00159 };
00160
00161
00162
00163 #endif // HISTMAN_HISTMAN_H