#include #include #include #include #include #include #include #include #include #include #include #include #include // function declarations_________________________________________________________________ void readDir(TDirectory *dir); //_______________________________________________________________________________________ void readDir(TDirectory *dir) { TDirectory *dirsav = gDirectory; TDirectory *currentDir = gDirectory; TIter next(dir->GetListOfKeys()); TKey *key; while ((key = (TKey*)next())) { // if the Key is a folder read the directory and skip the rest of the block if (key->IsFolder()) { dir->cd(key->GetName()); currentDir = gDirectory; readDir(currentDir); dirsav->cd(); continue; } // so the key is not a folder TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1")) continue; TH1 *h = (TH1*)key->ReadObj(); // lädt das Objekt aus der Datei in den Speicher std::string histname = h->GetName(); size_t pos = histname.find("_uncorr"); if(pos!= string::npos){ std::string name_to_find = histname.substr(0,pos); TH1 *hist_to_find = 0; gDirectory->GetObject(name_to_find.c_str(),hist_to_find); // AS SOON AS YOU UNCOMMENT THE NEXT LINE SCRIPT CRASHES //if(hist_to_find) // std::cout << hist_to_find->GetName(); hist_to_find->Draw(); } } }