StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TestSaveView.C
1 TestSaveView(St_NodeView *viewFull)
2 {
3 // gSystem->MakeDirectory(GetName());
4 // gSystem->ChangeDirectory(GetName());
5  if (!viewFull) return;
6 
7  St_DataSetIter next(viewFull,0);
8  St_NodeView *view = 0;
9  Int_t iCounter = 0;
10 // Char_t buffer[100];
11  TString fileName;
12  TString topDirectory="./";
13  TString curDirectory = topDirectory;
14  Char_t *fullPath = gSystem->ConcatFileName(curDirectory.Data(),viewFull->GetName());
15  gSystem->MakeDirectory(fullPath);
16  delete [] fullPath;
17 
18  while( (view = (St_NodeView *)next()) )
19  {
20 
21  UInt_t numPosition = view->GetPosition()->GetId();
22 // sprintf(buffer,";%d",numPosition);
23 
24  curDirectory = topDirectory;
25  curDirectory += view->PathP();
26 // curDirectory += buffer;
27 
28 // fileName = view->GetName();
29 // fileName += buffer;
30  fileName = "Position";
31  fileName += ".C.";
32  fileName += "year_1b";
33 
34  // Create directory
35  cout << "Dir: " << curDirectory.Data() << endl;
36  if (gSystem->MakeDirectory(curDirectory.Data())) {
37  printf(" can not create %s for %s \n",curDirectory.Data(), view->GetName());
38  return;
39  }
40 
41  fullPath = gSystem->ConcatFileName(curDirectory.Data(),fileName.Data());
42  ofstream out;
43  out.open(fullPath);
44 //== cout << iCounter+1 << ". " << fullPath << endl;
45  delete [] fullPath;
46  view->SavePrimitive(out);
47  out.close();
48  iCounter++;
49  }
50  cout << iCounter << " files have been create" << endl;
51 };
virtual TString PathP() const
return the full path of this data set
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
to be documented