/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Diff of /PamelaLevel2/src/PamLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.78 by pam-fi, Fri Mar 13 10:30:11 2009 UTC revision 1.79 by pam-fi, Wed Mar 18 09:02:01 2009 UTC
# Line 1867  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1867  TTree *PamLevel2::GetPamTree(TFile *f, T
1867  TList*  PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){  TList*  PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){
1868                    
1869      TString wdir = gSystem->WorkingDirectory();      TString wdir = gSystem->WorkingDirectory();
 //    cout << "Working directory: "<<wdir<<endl;  
1870    
     //    if(ddir=="")ddir = wdir;  
 //      TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);  
1871      if ( ddir != ""){      if ( ddir != ""){
1872          cout << "Level2 data directory : "<<  ddir << endl;          cout << "Level2 data directory : "<<  ddir << endl;
1873      } else {      } else {
# Line 1879  TList*  PamLevel2::GetListOfLevel2Files( Line 1876  TList*  PamLevel2::GetListOfLevel2Files(
1876      TList *contents  = new TList; // create output list      TList *contents  = new TList; // create output list
1877      contents->SetOwner();      contents->SetOwner();
1878            
1879  //    char *fullpath;      // --------------------------------------
1880  //    const char *fullpath;      // case 1 : input file/file-list provided
1881            // --------------------------------------
     // if no input file list is given:    
1882      if ( flisttxt != "" ){      if ( flisttxt != "" ){
1883                    
1884  //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){                  // --------------------------------------
1885  //      if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){          // a list of files given as input
1886  //          cout <<"File "<<flisttxt<<" not found"<<endl;          // --------------------------------------
 //          return 0;  
 //      }        
 //      flisttxt = fullpath;  
1887          if ( !flisttxt.EndsWith(".root") ){          if ( !flisttxt.EndsWith(".root") ){
1888    
1889              TString dir = gSystem->DirName(flisttxt);              TString dir = gSystem->DirName(flisttxt);
# Line 1913  TList*  PamLevel2::GetListOfLevel2Files( Line 1906  TList*  PamLevel2::GetListOfLevel2Files(
1906                  return 0;                  return 0;
1907              }                }  
1908              int line=0;              int line=0;
1909                // ...........................
1910                // loop over file-list records
1911                // ...........................
1912              while (1) {              while (1) {
1913                  TString file;                  TString file;
1914                  in >> file;                  in >> file;
1915                  if (!in.good()) break;                  if (!in.good()) break;
1916                  line++;                  line++;
1917  //          cout <<"(1) " << file << endl;                  cout <<"(*) " << file << endl;
1918                  if(file.IsNull()){                  if(file.IsNull()){
1919                      cout << "-- list interrupted at line "<<line <<endl;                      cout << "-- list interrupted at line "<<line <<endl;
1920                      break;                      break;
1921                  }                  }
1922                  if(file.Contains("#"))file = file(0,file.First("#"));                  if(file.Contains("#"))file = file(0,file.First("#"));
1923  //          cout <<"(2) " << file << endl;                  //
1924  //          if( gSystem->IsFileInIncludePath(file,&fullpath) ){                  // take only root files
1925  //          if( (fullpath = gSystem->FindFile(ddir,file)) ){                  //
1926                  if( file.EndsWith(".root") ){                  if( file.EndsWith(".root") ){
1927                      TString filedir;                      TString filedir;
1928                        cout << ddir << endl;
1929                      if (ddir != ""){                      if (ddir != ""){
1930                          filedir = ddir; // take the input dir                          filedir = ddir; // take the input dir
1931                      } else {                      } else {
1932                          gSystem->ChangeDirectory(wdir); // back to the working directory                          gSystem->ChangeDirectory(wdir); // back to the working directory
1933                          filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir                          filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir
1934                      };                      };
1935                        filedir.Append("/");
1936                      char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file));                      char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file));
1937                      contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list                      contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
1938                        cout << fullpath << endl;
1939                      delete fullpath;                      delete fullpath;
1940                  }                  }
1941  //          }else{  //          }else{
# Line 1944  TList*  PamLevel2::GetListOfLevel2Files( Line 1943  TList*  PamLevel2::GetListOfLevel2Files(
1943  //          };  //          };
1944              };              };
1945              in.close();              in.close();
1946            // --------------------------------------
1947            // a single root file given as input
1948            // --------------------------------------
1949          } else {          } else {
1950              if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#"));              if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#"));
1951              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
1952              contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list              contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
1953              delete fullpath;              delete fullpath;
1954          };                };      
1955        // ---------------------------------------------------------------------------------
1956        // case 2 : no input file/file-list provided --> read all files insede the directory
1957        // ---------------------------------------------------------------------------------
1958      }else{      }else{
1959                    
1960          cout << "No input file list given."<<endl;          cout << "No input file list given."<<endl;

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.23