22 :
FileListSource(LocationsForSAMQuery(query, stride, offset, limit), 1, 0)
34 return getenv(
"_CONDOR_SCRATCH_DIR") != 0;
45 dset.ReplaceAll(
" ",
"_");
46 dset.ReplaceAll(
"(",
"_OPEN_");
47 dset.ReplaceAll(
")",
"_CLOSE_");
48 dset.ReplaceAll(
":",
"_COLON_");
49 dset.ReplaceAll(
"'",
"_SQUOTE_");
50 dset.ReplaceAll(
"\"",
"_DQUOTE_");
58 dset.Data(), query.c_str()).Data());
68 std::cout <<
"SAMQuerySource::EnsureSnapshot(): definition '" 75 const char* cluster =
getenv(
"CLUSTER");
84 user, def.c_str(), cluster).Data();
92 user, def.c_str(), cluster).Data();
101 snaplock.c_str(),
process).Data()) == 0){
105 def.c_str(), snap.c_str()).Data());
114 std::cout <<
"We've been waiting a real long time for " << snap <<
" to be created. I don't think it's happening." <<
std::endl;
137 if(!query.Contains(
' ')){
138 if(
getenv(
"CAFANA_USE_SNAPSHOTS")){
139 query =
"dataset_def_name_newest_snapshot "+
query;
145 query =
"defname: "+
query;
159 std::cout <<
"Looking up files matching '" << query <<
"' using SAM...\n";
161 std::vector<std::string>
files;
166 files = i.translateConstraints(query.Data());
168 catch(ifdh_util_ns::WebAPIException&
e){
174 std::cerr <<
"\nCan't find any files matching '" << str
181 if(!files.empty() && files.back().empty()){
192 std::vector<std::string>
ret;
195 std::map<std::string, std::vector<std::string>> locmap;
206 const unsigned int kStep = 50;
207 for(
unsigned int fIdx = 0; fIdx < fnames.size(); fIdx += kStep){
208 prog.SetProgress(
double(fIdx)/fnames.size());
212 const std::vector<std::string> fslice(fnames.begin()+fIdx, fIdx+kStep < fnames.size() ? fnames.begin()+fIdx+kStep : fnames.end());
214 const auto locslice = i.locateFiles(fslice);
216 locmap.insert(locslice.begin(), locslice.end());
224 for(
auto it: locmap){
226 const std::vector<std::string>& locs =
it.second;
231 for(TString
loc: locs){
237 if(
loc.Contains(
"jinr.ru") &&
238 getenv(
"CAFANA_ALLOW_ALL_FILE_LOCATIONS") == 0)
continue;
254 if(
stat((resolved+
'/'+f).c_str(), &junk) == 0){
260 if(
loc.BeginsWith(
"dcache:") && best < 2){
267 loc.ReplaceAll(
"dcache:/pnfs/",
"/pnfs/");
269 if(
loc.First(
'(') >= 0)
loc.Resize(
loc.First(
'('));
273 if(
loc.BeginsWith(
"enstore:") && best < 1){
276 loc.ReplaceAll(
"enstore:/pnfs/",
"/pnfs/");
277 if(
loc.First(
'(') >= 0)
loc.Resize(
loc.First(
'('));
283 if(best == 0 || resolved.empty()){
284 std::cerr <<
"\nCouldn't find a usable location for " << f
289 ret.push_back((resolved+
'/'+f));
Cuts and Vars for the 2020 FD DiF Study.
system("rm -rf microbeam.root")
std::vector< std::string > LocationsForSAMQuery(const std::string &str, int stride, int offset, int limit=-1)
bool RunningOnGrid() const
SAMQuerySource(const std::string &query, int stride=-1, int offset=-1, int limit=-1)
std::string getenv(std::string const &name)
std::string EnsureDataset(const std::string &query) const
std::string EnsureSnapshot(const std::string &def) const
Simple file source based on an explicit list provided by the user.
std::vector< std::string > LocateSAMFiles(const std::vector< std::string > &fnames)
Take filenames, return locations suitable for TFile::Open()
bool SAMDefinitionExists(const std::string &def)
virtual ~SAMQuerySource()
assert(nhit_max >=nhit_nbins)
A simple ascii-art progress bar.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)