00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 void xdf2C(const char *Input="$STAR/params",const char *Output="qweDB")
00018 {
00019 int ierr;
00020 gSystem->Load("St_base");
00021 gSystem->Load("xdf2root");
00022 gSystem->Load("St_Tables");
00023
00024 ofstream out;
00025 St_DataSet *TOP = new St_DataSet("TOP");
00026 St_DataSet *Top = new St_DataSet("Top");
00027 TString TSInp = Input;
00028 TString TSOut = Output;
00029 gSystem->ExpandPathName(TSInp);
00030 gSystem->ExpandPathName(TSOut);
00031
00032
00033
00034 TString Ipref = gSystem->DirName((const char*)TSInp);Ipref +="/";
00035 const char *params = "params" ;
00036 const char *params = gSystem->BaseName((const char*)TSInp);
00037
00038
00039
00040 TString Opref = TSOut; Opref +="/";
00041 gSystem->MakeDirectory((const char*)TSOut);
00042
00043 TString OuputFile,CWD ;
00044 TString InputFile = Ipref; InputFile += params;
00045
00046 St_FileSet *fs = new St_FileSet((char*)InputFile);
00047 TOP->Add(fs);
00048 St_DataSet *set;
00049 char path[100];
00050
00051
00052 St_DataSetIter next(TOP,9999);
00053 while (set = next()) {
00054 strcpy(path, (char*)(set->Path())+4);
00055 if (strstr(path,"CVS")) continue;
00056 InputFile = Ipref; InputFile.Append(path);
00057 OuputFile = Opref; OuputFile += path;
00058
00059 printf("InputFile=%s\n",(const char*)InputFile);
00060 printf("OuputFile=%s\n",(const char*)OuputFile);
00061
00062
00063 if (strcmp("directory",set->GetTitle())==0) {
00064 ierr = gSystem->MakeDirectory((char*)OuputFile);
00065 printf("MakeDir=%s %d\n",(char*)OuputFile,ierr);
00066 CWD = OuputFile;
00068 } else {
00069 if (!strstr((char*)InputFile,".xdf")) continue;
00070 printf("Process file %s -> %s\n",(char*)InputFile);
00071 St_XDFFile *xdf_in = new St_XDFFile((char*)InputFile,"r");
00072
00073 St_DataSet *zet= xdf_in->NextEventGet();
00074 Top->Add(zet);
00075 St_DataSetIter Param(Top,9999);
00076 St_DataSet *t;
00077
00078 while ((t = Param())) {
00079 strcpy(path,(char*)t->Path()+4);
00080
00081 TString FileC = CWD; FileC += "/"; FileC += path;
00082 printf("FileC=%s\n",(char*)FileC);
00083 if (t->HasData()){
00084 FileC +=".C";
00085 out.open((char*)FileC);
00086 printf("OpenOut %s \n",(char*)FileC);
00087 t->SavePrimitive(out,"");
00088 out.close();
00089 } else {
00090 ierr=gSystem->MakeDirectory((char*)FileC);
00091 printf("MakeXdfDir=%s %d\n",(char*)FileC,ierr);
00092 }
00093
00094 printf("%s\n",path);
00095 }
00096 delete zet;
00097 }
00098 }
00099 }