ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
alien.C
Go to the documentation of this file.
1 //Example of use of the TAlien class (an implementation of TGrid)
2 //Author: Andreas Peters
3 
4 void alien()
5 {
6  TString testdir = "root-test3";
7  int nfiles = 10;
8 
9  // connect to AliEn
10  TGrid *alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "",
11  "-domain=cern.ch");
12  if (alien->IsZombie()) {
13  delete alien;
14  return;
15  }
16 
17  // get info on AliEn version
18  printf("Using AliEn version %s\n", alien->GetInfo());
19 
20  // print current working directory
21  printf("Current directory is %s\n", alien->Pwd());
22 
23  // check if directory exists
24  Long_t size, flags, modtime;
25  if (alien->GetPathInfo(testdir, &size, &flags, &modtime) == 0) {
26  // delete existing directory
27  alien->Rmdir(testdir);
28  }
29 
30  // create a directory
31  alien->Mkdir(testdir);
32 
33  // change directory
34  alien->Cd(testdir);
35 
36  printf("Current directory is %s\n", alien->Pwd());
37 
38  // insert nfiles into the catalog
39  Int_t i;
40  char lfn[32], pfn[256];
41  for (i = 0; i < nfiles; i++) {
42  sprintf(lfn, "test-%d.root", i);
43  sprintf(pfn, "rfio:/castor/cern.ch/user/r/rdm/mytest-%d.root", i);
44  alien->AddFile(lfn, pfn, 1000000000);
45  }
46 
47  // list the contents of a directory
48  alien->ls("", "l");
49 
50  // get physical file name from lfn
51  for (i = 0; i < nfiles; i++) {
52  sprintf(lfn, "test-%d.root", i);
53  char *pf = alien->GetPhysicalFileName(lfn);
54  if (i == nfiles-1)
55  printf("last pfn retrieved is: %s\n", pf);
56  delete [] pf;
57  }
58 
59  delete alien;
60 }
61 
virtual Bool_t Rmdir(const char *="", Option_t *="", Bool_t=kFALSE)
Definition: TGrid.h:101
Bool_t IsZombie() const
Definition: TObject.h:141
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
virtual Bool_t Cd(const char *="", Bool_t=kFALSE)
Definition: TGrid.h:97
virtual void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TObject.cxx:536
static TGrid * Connect(const char *grid, const char *uid=0, const char *pw=0, const char *options=0)
virtual Int_t Mkdir(const char *="", Option_t *="", Bool_t=kFALSE)
Definition: TGrid.h:99
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1575
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
virtual const char * Pwd(Bool_t=kFALSE)
Definition: TGrid.h:93
long Long_t
Definition: RtypesCore.h:50
void alien()
Definition: alien.C:4
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
Definition: TGrid.h:51