/** * Get the size of a given run * * @param in Input stream * @param runNo Run number to search for * @param mc True for simulations * @param minSize Least size * * @return true on success */ Bool_t GetSize(std::istream& in, ULong_t runNo, Bool_t mc, ULong_t minSize=100000) { TString line; TString tgt2(mc ? "table_row_right" : "ESDs size"); Int_t cnt = 0; do { line.ReadLine(in); if (!line.Contains(tgt2)) continue; cnt++; if (mc && cnt < 3) continue; if (!mc) line.ReadLine(in); if (fDebug) Info("", line); TString ssiz; if (mc) { Int_t first = line.Index(">"); Int_t last = line.Index("<",first+1); if (first == kNPOS || last == kNPOS) { Error("GetDir", "Failed to get directory from %s", line.Data()); return false; } ssiz = line(first+1, last-first-1); } else { for (Int_t i = 0; i < line.Length(); i++) { if (line[i] == '<') break; if (line[i] == ' ' || line[i] == '\t' || line[i] == ',') continue; ssiz.Append(line[i]); } } Long_t size = ssiz.Atoll(); if (fDebug) Info("", "Got run %lu %lu" , runNo, size); if (size < 0) { Error("GetSize", "Failed to extract size for run %lu", runNo); return false; } if (ULong_t(size) < minSize) { Warning("GetSize","Run %lu does not have enough events %lu",runNo,size); return false; } break; } while (!in.eof()); return true; }
/** * Get list of runs associated with production * * @param url The production URL * @param mc True of MC * @param minSize Least size of runs to use * * @return true on success */ Bool_t GetRuns(const TString& url, Bool_t mc, ULong_t minSize) { TString index("job"); if (!Download(Form("%s%s", (mc ? "" : "raw/"), url.Data()), index)) return false; std::ifstream in(index.Data()); TString tgt1(mc ? "window.open" : "runDetails"); TString line = ""; do { line.ReadLine(in); if (!line.Contains(tgt1)) continue; Int_t first = -1; Int_t last = -1; if (!mc) { first = line.Index(tgt1); last = line.Index(")", first+tgt1.Length()+1); } else { Int_t tmp = line.Index(">"); first = line.Index(">", tmp+1); last = line.Index("<", first); } if (first == kNPOS || last == kNPOS) { Error("GetDir", "Failed to get directory from %s", line.Data()); return false; } first += (mc ? 1 : tgt1.Length()+1); last -= first; TString srun = line(first, last); ULong_t runNo = srun.Atoll(); if (fDebug) Info("", "Got run %lu (%s)", runNo, srun.Data()); if (!GetSize(in, runNo, mc, minSize)) continue; if (!GetDir(in, runNo, mc)) continue; if (!fRuns.IsNull()) fRuns.Append(","); fRuns.Append(Form("%lu", runNo)); } while (!in.eof()); in.close(); if (fRuns.IsNull()) return false; return true; }