WildcardSource.cxx
Go to the documentation of this file.
2 
3 #include "CAFAna/Core/UtilsExt.h"
4 
5 #include <algorithm>
6 
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <unistd.h>
10 #include <iostream>
11 
12 namespace
13 {
14  // No-one else needs to see this
15  std::vector<std::string> sorted(const std::vector<std::string>& v)
16  {
17  std::vector<std::string> ret;
18  ret = v;
19  std::sort(ret.begin(), ret.end());
20  return ret;
21  }
22 }
23 
24 namespace ana
25 {
26  //----------------------------------------------------------------------
28  int stride, int offset, int limit)
29  : FileListSource(sorted(CheckedWildcard(wildcard)), stride, offset, limit)
30  {
31  }
32 
33  //----------------------------------------------------------------------
35  {
36  }
37 
38  //----------------------------------------------------------------------
39  std::vector<std::string> WildcardSource::
41  {
42  std::vector<std::string> ret = Wildcard(wildcard);
43 
44  struct stat ss;
45  // If we found nothing, it may be because pnfs isn't mounted.
46  if(ret.empty() &&
47  wildcard.find("/pnfs/") == 0 &&
48  stat("/pnfs/", &ss) != 0){
49 
50  std::cout << "No files matching " << wildcard << " but that's probably because /pnfs is not mounted on the current grid node. If you have to use your own files, either try running it interactivly or try sam_add_dataset to create one." << std::endl;
51  }
52 
53  return ret;
54  }
55 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
WildcardSource(const std::string &wildcard, int stride=-1, int offset=-1, int limit=-1)
std::vector< std::string > Wildcard(const std::string &wildcardString)
Find files matching a UNIX glob, plus expand environment variables.
Definition: UtilsExt.cxx:268
std::vector< std::string > CheckedWildcard(const std::string &wildcard) const
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
OStream cout
Definition: OStream.cxx:6
Simple file source based on an explicit list provided by the user.
enum BeamMode string