/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Functions | Variables
HistMan.cc File Reference
#include "HistMan/HistMan.h"
#include <TSystem.h>
#include <TKey.h>
#include <TROOT.h>
#include <TFile.h>
#include <TH1.h>
#include <TH2.h>
#include <TProfile.h>
#include <TTree.h>
#include <string>
#include <vector>
#include <iostream>
#include <cassert>
#include <algorithm>
Include dependency graph for HistMan.cc:

Go to the source code of this file.

Functions

vector< string > parse_path (const char *path)
TFolder & mkdir_p (TFolder &top, const char *path)
static TFolder * directory_to_folder (TDirectory &directory)
static void folder_to_directory (TFolder *folder, TDirectory &directory)

Variables

const char baseName [] = "stats"
static int histcount = 0

Function Documentation

vector<string> parse_path ( const char *  path)

Definition at line 22 of file HistMan.cc.

{
    vector<string> vs;
    string p(path);
    string::iterator it1=p.begin(), it2, done=p.end();
    for (it2=find(p.begin(),done,'/'); it2 != done; it2=find(it1,done,'/')) {
        if (it1==it2) {
            ++it1;
            continue;
        }
        string dir(it1,it2);
        if (dir != ".")
            vs.push_back(dir);
        it1 = it2+1;
    }
    if (it1 != it2) {
        string dir(it1,it2);
        if (dir != ".")
            vs.push_back(string(it1,it2));
    }
    return vs;
}
TFolder& mkdir_p ( TFolder &  top,
const char *  path 
)

Definition at line 45 of file HistMan.cc.

{
    if (!path || path[0] == '\0') return top;

    vector<string> vp = parse_path(path);
    TFolder* folder = &top;
    for (unsigned int ind=0; ind < vp.size(); ++ind) {
        const char* name = vp[ind].c_str();
        TFolder* tmp = dynamic_cast<TFolder*>(folder->FindObject(name));
        if (tmp) folder = tmp;
        else folder = folder->AddFolder(name,name);
    }
    return *folder;
}
static TFolder* directory_to_folder ( TDirectory &  directory) [static]

Definition at line 80 of file HistMan.cc.

{
    TFolder* folder = new TFolder(directory.GetName(),directory.GetName());

    TList *l = directory.GetListOfKeys();
    if (!l) return folder;

    TIter it(l->MakeIterator());
    TObject *obj=0;
    while ( (obj=it()) ) {
        TKey* key = dynamic_cast<TKey*>(obj);
        assert(key);
        obj = directory.Get(key->GetName());
        TDirectory* dir = dynamic_cast<TDirectory*>(obj);
        if (dir) {
            TFolder* fol = directory_to_folder(*dir);
            //cerr << "Adding folder " << fol->GetName()
            //<< " to folder " << folder->GetName()
            //<< " from directory " << dir->GetName() << endl;
            folder->Add(fol);
        }
        else {
            //cerr << "Adding object " << obj->GetName()
            //<< " to folder " << folder->GetName() << endl;
            folder->Add(obj);
        }
    }
    return folder;
}
static void folder_to_directory ( TFolder *  folder,
TDirectory &  directory 
) [static]

Definition at line 211 of file HistMan.cc.

{
    TDirectory*& prevdir = gDirectory, *dir = 0;

    TObject* obj = directory.Get(folder->GetName());
    if (obj) {
        dir = dynamic_cast<TDirectory*>(obj);
        if (!dir) {
            cerr << "Non-directory object \"" << folder->GetName()
                 << "\" already in directory\n";
            return;
        }
    }
    else
        dir = directory.mkdir(folder->GetName());

    dir->cd();

    TCollection* sf = folder->GetListOfFolders();
    if (!sf) {
        prevdir->cd();
        return;
    }

    TIter it(sf->MakeIterator());
    obj=0;
    while ( (obj=it()) ) {
        TFolder *fol = dynamic_cast<TFolder*>(obj);
        if (fol) folder_to_directory(fol,*dir);
        else {
            dir->cd();
            obj->Write();
        }
    }
    prevdir->cd();
}

Variable Documentation

const char baseName[] = "stats"

Definition at line 20 of file HistMan.cc.

int histcount = 0 [static]

Definition at line 60 of file HistMan.cc.

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:51:37 for HistMan by doxygen 1.7.4