File indexing completed on 2023-03-17 11:15:40
0001
0002
0003 #if !defined(TH1Store_H)
0004 #define TH1Store_H
0005
0006 #include <map>
0007 #include <string>
0008 #include <set>
0009
0010 #include "TH1.h"
0011 #include "TFile.h"
0012 #include "TString.h"
0013 #include "TDirectory.h"
0014
0015 class TH1Store {
0016 public:
0017
0018
0019
0020
0021 typedef std::vector<std::string> SVec;
0022 typedef std::map<std::string, std::string> SSMap;
0023 typedef std::map<std::string, TH1 *> STH1PtrMap;
0024 typedef SSMap::const_iterator SSMapConstIter;
0025 typedef STH1PtrMap::iterator STH1PtrMapIter;
0026 typedef STH1PtrMap::const_iterator STH1PtrMapConstIter;
0027
0028 static const SVec kEmptyVec;
0029
0030
0031
0032
0033
0034 friend std::ostream &operator<<(std::ostream &o_stream, const TH1Store &rhs);
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 TH1Store();
0047 ~TH1Store();
0048
0049
0050
0051
0052
0053 void setDeleteOnDestruction(bool deleteOnDestruction = true) { m_deleteOnDestruction = deleteOnDestruction; }
0054
0055
0056
0057
0058
0059
0060 void add(TH1 *histPtr, const std::string &directory = "");
0061
0062
0063 TH1 *hist(const std::string &name);
0064 TH1 *hist(const char *name) { return hist((const std::string)name); }
0065 TH1 *hist(const TString &name) { return hist((const char *)name); }
0066
0067
0068 void write(const std::string &filename, const SVec &argsVec = kEmptyVec, const SVec &inputFilesVec = kEmptyVec) const;
0069 void write(TFile *filePtr, const SVec &argsVec = kEmptyVec, const SVec &inputFilesVec = kEmptyVec) const;
0070
0071
0072
0073
0074
0075
0076
0077 static void setVerbose(bool verbose = true) { sm_verbose = verbose; }
0078
0079 private:
0080
0081
0082
0083
0084
0085
0086
0087 TDirectory *_createDir(const std::string &dirname, TFile *filePtr) const;
0088
0089
0090
0091
0092
0093 bool m_deleteOnDestruction;
0094 STH1PtrMap m_ptrMap;
0095 SSMap m_nameDirMap;
0096
0097
0098
0099
0100
0101 static bool sm_verbose;
0102 };
0103
0104 #endif