File indexing completed on 2024-04-06 12:33:36
0001 void CopyDir(TDirectory *source) {
0002
0003 source->ls();
0004 TDirectory *savdir = gDirectory;
0005 TDirectory *adir = savdir->mkdir(source->GetName());
0006 adir->cd();
0007
0008 TKey *key;
0009 TIter nextkey(source->GetListOfKeys());
0010 while ((key = (TKey*)nextkey())) {
0011 const char *classname = key->GetClassName();
0012 TClass *cl = gROOT->GetClass(classname);
0013 if (!cl) continue;
0014 if (cl->InheritsFrom("TDirectory")) {
0015 source->cd(key->GetName());
0016 TDirectory *subdir = gDirectory;
0017 adir->cd();
0018 CopyDir(subdir);
0019 adir->cd();
0020 } else if (cl->InheritsFrom("TTree")) {
0021 TTree *T = (TTree*)source->Get(key->GetName());
0022 adir->cd();
0023 TTree *newT = T->CloneTree(-1,"fast");
0024 newT->Write();
0025 } else {
0026 source->cd();
0027 TObject *obj = key->ReadObj();
0028 adir->cd();
0029 obj->Write();
0030 delete obj;
0031 }
0032 }
0033 adir->SaveSelf(kTRUE);
0034 savdir->cd();
0035 }
0036
0037
0038 void CopySubdir(const char* oldfile, const char* newfile) {
0039
0040 TFile *oldf = TFile::Open(oldfile);
0041
0042 bool success = oldf->cd("DQMData/Run 1/Vertexing/V0V/Run summary/EffFakes");
0043
0044
0045
0046 if(!success) success = oldf->cd("DQMData/Vertexing/V0V/EffFakes");
0047
0048 gDirectory->ls();
0049 TDirectory *dirold=gDirectory;
0050
0051
0052 TFile *newf =new TFile(newfile,"RECREATE");
0053 TDirectory *dirnew=newf->mkdir("DQMData");
0054 dirnew=dirnew->mkdir("Run 1");
0055 dirnew=dirnew->mkdir("Vertexing");
0056 dirnew=dirnew->mkdir("V0V");
0057 dirnew=dirnew->mkdir("Run summary");
0058
0059
0060 gDirectory=dirnew;
0061
0062 CopyDir(dirold);
0063
0064 gDirectory = dirold;
0065
0066 success = oldf->cd("DQMData/Run 1/Vertexing/V0V/Run summary/Other");
0067 if(!success) success = oldf->cd("DQMData/Vertexing/V0V/Other");
0068 TDirectory *dirold2 = gDirectory;
0069
0070
0071 gDirectory = dirnew;
0072 CopyDir(dirold2);
0073
0074
0075 }