Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

HistMan/HistMan.h

Go to the documentation of this file.
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>  // 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);
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

Generated on Mon Feb 15 11:06:47 2010 for loon by  doxygen 1.3.9.1