1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //_________________________________________________________________________
18 // To navigate in the Grid catalogue (very elementary)
19 // check here : /afs/cern.ch/user/p/peters/public/README.ALIEN
20 //-- Author: Yves Schutz (CERN)
22 // --- ROOT system ---
23 #include "TObjString.h"
24 #include "TGridResult.h"
26 // --- Standard library ---
28 // --- AliRoot header files ---
30 #include "AliPHOSGridFile.h"
32 ClassImp(AliPHOSGridFile) ;
34 //____________________________________________________________________________
35 AliPHOSGridFile::AliPHOSGridFile(TString grid)
37 // default ctor; Doing initialisation ;
40 fGrid = TGrid::Connect("alien://aliendb1.cern.ch:15000/?direct") ;
42 Error("AliPHOSGridFile", " %s is an unknown grid system", grid.Data()) ;
44 Error("ctor", "Cannot connect to alien://aliendb1.cern.ch:15000/?direct") ;
46 fRoot = "/alice/production/aliprod" ;
47 if ( !fGrid->OpenDir(fRoot) )
48 Error("ctor", "Cannot find directory %s ", fRoot.Data() ) ;
61 //____________________________________________________________________________
62 AliPHOSGridFile::~AliPHOSGridFile()
66 //____________________________________________________________________________
67 TString AliPHOSGridFile::GetLFN() const
69 TString fileName(Pwd()) ;
70 fileName += "galice.root" ;
71 if ( !fGrid->GetAccessPath(fileName) ) {
72 Warning("GetLFN", "file %s does not exist", fileName.Data()) ;
76 fileName.Prepend("alien://") ;
80 //____________________________________________________________________________
81 void AliPHOSGridFile::Copy(AliPHOSGridFile & lfn)
83 //Copy method used by the Copy ctor
94 //____________________________________________________________________________
95 void AliPHOSGridFile::Help()
97 // Prints information on available lfn's
103 //____________________________________________________________________________
104 void AliPHOSGridFile::ListEvents() const
106 // list the available events for the current path and run selected
109 sprintf(path, "%s/%s-%s/%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data()) ;
110 Info("ListEvents", "Searching %s", path) ;
111 Grid_ResultHandle_t gr = fGrid->Find(path, "galice.root") ;
116 //____________________________________________________________________________
117 void AliPHOSGridFile::ListRuns() const
119 // list the available runs for the current path selected
122 sprintf(path, "%s/%s-%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data()) ;
123 Info("ListEvents", "Searching %s", path) ;
124 Grid_ResultHandle_t gr = fGrid->OpenDir(path) ;
129 //____________________________________________________________________________
130 Bool_t AliPHOSGridFile::SetYearProd(TString year, TString prod)
132 // set the year and verifies if the directory exists
135 sprintf(tempo, "/%s-%s", year.Data(), prod.Data()) ;
137 TString path(fRoot) ;
139 if ( !fGrid->OpenDir(path) )
140 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
150 //____________________________________________________________________________
151 Bool_t AliPHOSGridFile::SetVers(TString vers)
153 // set the year and verifies if the directory exists
156 sprintf(tempo, "/%s-%s/%s", fYear.Data(), fProd.Data(), vers.Data()) ;
159 TString path(fRoot) ;
161 if ( !fGrid->OpenDir(path) )
162 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
171 //____________________________________________________________________________
172 Bool_t AliPHOSGridFile::SetType(TString type)
174 // set the year and verifies if the directory exists
177 sprintf(tempo, "/%s-%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), type.Data()) ;
179 TString path(fRoot) ;
181 if ( !fGrid->OpenDir(path) )
182 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
191 //____________________________________________________________________________
192 Bool_t AliPHOSGridFile::SetPath(TString year, TString prod, TString vers, TString type)
194 // set the year and verifies if the directory exists
197 sprintf(tempo, "/%s-%s/%s/%s", year.Data(), prod.Data(), vers.Data(), type.Data()) ;
199 TString path(fRoot) ;
201 if ( !fGrid->OpenDir(path) )
202 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
214 //____________________________________________________________________________
215 Bool_t AliPHOSGridFile::SetRun(Int_t run)
217 // set the year and verifies if the directory exists
220 TString zero("00000") ;
223 Int_t nzero = zero.Length() - srun.Length() ;
225 for (index = 0 ; index < nzero ; index++)
229 sprintf(tempo, "/%s-%s/%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), srun.Data()) ;
231 TString path(fRoot) ;
233 if ( !fGrid->OpenDir(path) )
234 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
243 //____________________________________________________________________________
244 Bool_t AliPHOSGridFile::SetEvt(Int_t evt)
246 // set the year and verifies if the directory exists
249 TString zero("00000") ;
252 Int_t nzero = zero.Length() - sevt.Length() ;
254 for (index = 0 ; index < nzero ; index++)
258 sprintf(tempo, "/%s-%s/%s/%s/%s/%s/", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data(), sevt.Data()) ;
259 TString path(fRoot) ;
261 if ( !fGrid->OpenDir(path) )
262 Error("ctor", "Cannot find directory %s ", path.Data() ) ;