3 * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4 * @date Wed Jan 23 21:51:40 2013
6 * @brief Helper script to download results from the Grid
9 * @ingroup pwglf_forward_trains_helper
16 # include <TObjArray.h>
17 # include <TObjString.h>
27 * @param base Base name
28 * @param dir Directory
29 * @param unpack If true, also unzip the retrieved archive
31 * @return true on success
33 Bool_t GetOne(const TString& base, const TString& dir, Bool_t unpack)
35 TString src(gSystem->ConcatFileName(base,dir));
36 src = gSystem->ConcatFileName(src,"root_archive.zip");
38 name.Form("root_archive_%s",dir.Data());
40 dest.Form("%s.zip",name.Data());
42 if (!TFile::Cp(src, dest)) {
43 Error("GetOne","Failed to download %s -> %s",
44 src.Data(), dest.Data());
47 if (!unpack) return true;
48 gSystem->Exec(Form("mkdir -p %s && (cd %s && unzip ../%s)",
49 name.Data(), name.Data(), dest.Data()));
53 void GridDownload(const TString& base, const TString& runs, Bool_t unpack)
55 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
56 if (!TGrid::Connect("alien://")) {
57 Error("Download","Failed to connect to AliEn");
61 TObjArray* runArray = runs.Tokenize(" ");
64 while ((run = static_cast<TObjString*>(next()))) {
65 GetOne(base, run->String(), unpack);