AliPhysics  31210d0 (31210d0)
GridDownload.C
Go to the documentation of this file.
1 
11 #ifndef __CINT__
12 # include <TString.h>
13 # include <TSystem.h>
14 # include <TGrid.h>
15 # include <TFile.h>
16 # include <TObjArray.h>
17 # include <TObjString.h>
18 # include <TError.h>
19 # include <TEnv.h>
20 #else
21 class TString;
22 #endif
23 
33 Bool_t GetOne(const TString& base, const TString& dir, Bool_t unpack)
34 {
35  TString src(gSystem->ConcatFileName(base,dir));
36  src = gSystem->ConcatFileName(src,"root_archive.zip");
37  TString name;
38  name.Form("root_archive_%s",dir.Data());
39  TString dest;
40  dest.Form("%s.zip",name.Data());
41 
42  if (!TFile::Cp(src, dest)) {
43  Error("GetOne","Failed to download %s -> %s",
44  src.Data(), dest.Data());
45  return false;
46  }
47  if (!unpack) return true;
48  gSystem->Exec(Form("mkdir -p %s && (cd %s && unzip -n ../%s)",
49  name.Data(), name.Data(), dest.Data()));
50  return true;
51 }
52 
53 void GridDownload(const TString& base, const TString& runs, Bool_t unpack)
54 {
55  gEnv->SetValue("XSec.GSI.DelegProxy", "2");
56  if (!TGrid::Connect("alien://")) {
57  Error("Download","Failed to connect to AliEn");
58  return;
59  }
60 
61  TObjArray* runArray = runs.Tokenize(" ");
62  TObjString* run = 0;
63  TIter next(runArray);
64  while ((run = static_cast<TObjString*>(next()))) {
65  GetOne(base, run->String(), unpack);
66  }
67 }
68 // EOF
69 
Bool_t GetOne(const TString &base, const TString &dir, Bool_t unpack)
Definition: GridDownload.C:33
TSystem * gSystem
void GridDownload(const TString &base, const TString &runs, Bool_t unpack)
Definition: GridDownload.C:53
bool Bool_t
Definition: External.C:53
TDirectoryFile * dir