7 #include "boost/regex.hpp" 32 string name = histPtr->GetName();
35 cerr <<
"TH1Store::add() Error: '" << name <<
"' already exists. Aborting." << endl;
39 cout <<
"THStore::add() : Adding " << name << endl;
42 histPtr->SetDirectory(
nullptr);
43 if (directory.length()) {
52 cerr <<
"TH1Store::hist() Error: '" << name <<
"' does not exists. Aborting." << endl;
59 TFile *filePtr = TFile::Open(
filename.c_str(),
"RECREATE");
61 cerr <<
"TH1Store::write() Error: Can not open '" <<
filename <<
"' for output. Aborting." << endl;
64 write(filePtr, argsVec, inputFilesVec);
81 iter->second->Write();
86 if (!argsVec.empty()) {
87 dir->WriteObject(&argsVec,
"argsVec");
89 if (!inputFilesVec.empty()) {
90 dir->WriteObject(&inputFilesVec,
"inputFiles");
92 cout <<
"TH1Store::write(): Successfully written to '" << filePtr->GetName() <<
"'." << endl;
97 TDirectory *dirPtr = filePtr->GetDirectory(dirName.c_str());
104 const boost::regex subdirRE(
"(.+?)/([^/]+)");
106 TDirectory *parentDir =
nullptr;
108 if (boost::regex_match(dirName, matches, subdirRE)) {
110 useName = matches[2];
115 dirPtr = parentDir->mkdir(useName.c_str());
bool m_deleteOnDestruction
void add(TH1 *histPtr, const std::string &directory="")
TDirectory * _createDir(const std::string &dirname, TFile *filePtr) const
static const SVec kEmptyVec
void write(const std::string &filename, const SVec &argsVec=kEmptyVec, const SVec &inputFilesVec=kEmptyVec) const
STH1PtrMap::const_iterator STH1PtrMapConstIter
friend std::ostream & operator<<(std::ostream &o_stream, const TH1Store &rhs)
STH1PtrMap::iterator STH1PtrMapIter
std::vector< std::string > SVec
SSMap::const_iterator SSMapConstIter
TH1 * hist(const std::string &name)