#include #include #include #include #include #include #include #include #include #include #include #include #include #include // function declarations_________________________________________________________________ void readDir(TDirectory *dir); //_______________________________________________________________________________________ void readDir(TDirectory *dir) //void script_Brun(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); //script_Brun(currentDir); dirsav->cd(); continue; } // so the key is not a folder TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1")) continue; std::string histname = key->GetName(); //cout << "key->GetName(): " << histname.c_str() << endl; size_t pos = histname.find("_uncorr"); if(pos!= string::npos){ std::string name_to_find = histname.substr(0,pos); TH1 *hist_to_find = (TH1*)key->ReadObj(); // AS SOON AS YOU UNCOMMENT THE NEXT LINE SCRIPT will not CRASH //if(hist_to_find) { //std::cout << hist_to_find->GetName(); // hist_to_find->Draw(); //} std::cout << "some output" << std::endl; } } }