本文整理汇总了C++中TDirectory::SaveSelf方法的典型用法代码示例。如果您正苦于以下问题:C++ TDirectory::SaveSelf方法的具体用法?C++ TDirectory::SaveSelf怎么用?C++ TDirectory::SaveSelf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDirectory
的用法示例。
在下文中一共展示了TDirectory::SaveSelf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyDir
void CopyDir(TDirectory *source) {
//copy all objects and subdirs of directory source as a subdir of the current directory
source->ls();
TDirectory *savdir = gDirectory;
TDirectory *adir = savdir->mkdir(source->GetName());
adir->cd();
//loop on all entries of this directory
TKey *key;
TIter nextkey(source->GetListOfKeys());
while ((key = (TKey*)nextkey())) {
const char *classname = key->GetClassName();
TClass *cl = gROOT->GetClass(classname);
if (!cl) continue;
if (cl->InheritsFrom(TDirectory::Class())) {
source->cd(key->GetName());
TDirectory *subdir = gDirectory;
adir->cd();
CopyDir(subdir);
adir->cd();
} else if (cl->InheritsFrom(TTree::Class())) {
TTree *T = (TTree*)source->Get(key->GetName());
adir->cd();
TTree *newT = T->CloneTree(-1,"fast");
newT->Write();
} else {
source->cd();
TObject *obj = key->ReadObj();
adir->cd();
obj->Write();
delete obj;
}
}
adir->SaveSelf(kTRUE);
savdir->cd();
}
示例2: copyDir
//Clone the file excluding the histogram (code stolen from Rene Brun)
void copyDir(TDirectory *source,std::string iSkipHist,bool iFirst=true) {
//copy all objects and subdirs of directory source as a subdir of the current directory
TDirectory *savdir = gDirectory;
TDirectory *adir = savdir;
if(!iFirst) adir = savdir->mkdir(source->GetName());
if(!iFirst) adir->cd();
//loop on all entries of this directory
TKey *key;
TIter nextkey(source->GetListOfKeys());
while ((key = (TKey*)nextkey())) {
const char *classname = key->GetClassName();
TClass *cl = gROOT->GetClass(classname);
if (!cl) continue;
if (cl->InheritsFrom(TDirectory::Class())) {
source->cd(key->GetName());
TDirectory *subdir = gDirectory;
adir->cd();
copyDir(subdir,iSkipHist,false);
adir->cd();
} else {
source->cd();
TObject *obj = key->ReadObj();
std::string pFullName = std::string(adir->GetName())+"/"+std::string(obj->GetName());
std::string iSkipHist2 = iSkipHist;
std::string fine_binning = "_fine_binning";
iSkipHist2.replace(iSkipHist2.find(fine_binning), fine_binning.length(),"");
if(pFullName.find(iSkipHist) != std::string::npos || pFullName.find(iSkipHist2) != std::string::npos) {
continue;
}
adir->cd();
obj->Write();
delete obj;
}
}
adir->SaveSelf(kTRUE);
savdir->cd();
}