]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSGridFile.cxx
Copy constructor is corrected (by T.P.)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGridFile.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15 /* $Id$ */
16
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)
21
22 // --- ROOT system ---
23 #include "TObjString.h"
24 #include "TGrid.h"
25 #include "TGridResult.h"
26
27 // --- Standard library ---
28
29 // --- AliRoot header files ---
30 #include "AliLog.h"
31 #include "AliPHOSGridFile.h"
32
33 ClassImp(AliPHOSGridFile)
34
35 //____________________________________________________________________________
36 AliPHOSGridFile::AliPHOSGridFile(TString grid)
37 {
38   // default ctor; Doing initialisation ;
39   fGrid = 0 ;
40   if (grid == "alien")
41     fGrid = TGrid::Connect("alien://aliendb1.cern.ch:15000/?direct") ;
42   else
43     Error("AliPHOSGridFile", " %s is an unknown grid system", grid.Data()) ;
44   if ( !fGrid )
45     Error("ctor", "Cannot connect to alien://aliendb1.cern.ch:15000/?direct") ;
46
47   fRoot = "/alice/production/aliprod" ;
48 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
49   if ( !fGrid->OpenDir(fRoot) )
50     Error("ctor", "Cannot find directory %s ", fRoot.Data() ) ;
51 #else
52   Error("AliPHOSGridFile", "needs to be ported to new TGrid");
53 #endif
54   fYear = "" ;
55   fProd = "" ;
56   fVers = "" ;
57   fType = "" ;
58   fRun  = "" ;
59   fEvt  = "" ;
60
61   fPath += fRoot ;
62
63 }
64
65 //____________________________________________________________________________
66 AliPHOSGridFile::~AliPHOSGridFile()
67 {
68 }
69
70 //____________________________________________________________________________
71 TString AliPHOSGridFile::GetLFN() const
72 {
73   TString fileName(Pwd()) ;
74   fileName += "galice.root" ;
75 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
76   if ( !fGrid->GetAccessPath(fileName) ) {
77     AliWarning(Form("file %s does not exist", fileName.Data())) ;
78     fileName = "" ;
79   }
80   else
81     fileName.Prepend("alien://") ;
82 #else
83   Error("GetLFN", "needs to be ported to new TGrid");
84 #endif
85   return fileName ;
86 }
87
88 //____________________________________________________________________________
89 void AliPHOSGridFile::Copy(AliPHOSGridFile & lfn)
90 {
91   //Copy method used by the Copy ctor
92   fRoot = lfn.fRoot ;
93   fYear = lfn.fYear ;
94   fProd = lfn.fProd ;
95   fVers = lfn.fVers ;
96   fType = lfn.fType ;
97   fRun  = lfn.fRun ;
98   fEvt  = lfn.fEvt ;
99   TObject::Copy(lfn) ;
100 }
101
102 //____________________________________________________________________________
103 void AliPHOSGridFile::Help()
104 {
105   // Prints information on available lfn's
106
107   AliInfo(Form("")) ;
108
109 }
110
111 //____________________________________________________________________________
112 void AliPHOSGridFile::ListEvents() const
113 {
114   // list the available events for the current path and run selected
115
116   char path[80] ;
117   sprintf(path, "%s/%s-%s/%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data()) ;
118   AliInfo(Form("Searching %s", path)) ;
119 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
120   Grid_ResultHandle_t gr = fGrid->Find(path, "galice.root") ;
121   TGridResult ar(gr) ;
122   ar.Print() ;
123 #else
124   Error("ListEvents", "needs to be ported to new TGrid");
125 #endif
126 }
127
128 //____________________________________________________________________________
129 void AliPHOSGridFile::ListRuns() const
130 {
131   // list the available runs for the current path selected
132
133   char path[80] ;
134   sprintf(path, "%s/%s-%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data()) ;
135   AliInfo(Form("Searching %s", path)) ;
136 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
137   Grid_ResultHandle_t gr = fGrid->OpenDir(path) ;
138   TGridResult ar(gr) ;
139   ar.Print() ;
140 #else
141   Error("ListRuns", "needs to be ported to new TGrid");
142 #endif
143 }
144
145 //____________________________________________________________________________
146 Bool_t AliPHOSGridFile::SetYearProd(TString year, TString prod)
147 {
148   // set the year and verifies if the directory exists
149   Bool_t rv = kFALSE ;
150   char tempo[80] ;
151   sprintf(tempo, "/%s-%s", year.Data(), prod.Data()) ;
152
153   TString path(fRoot) ;
154   path += tempo ;
155 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
156   if ( !fGrid->OpenDir(path) ) {
157     AliError(Form("Cannot find directory %s", path.Data() )) ;
158   } else {
159     rv = kTRUE ;
160     fYear = year ;
161     fProd = prod ;
162     fPath = path ;
163   }
164 #else
165   Error("SetYearProd", "needs to be ported to new TGrid");
166 #endif
167   return rv ;
168 }
169
170 //____________________________________________________________________________
171 Bool_t AliPHOSGridFile::SetVers(TString vers)
172 {
173   // set the year and verifies if the directory exists
174   Bool_t rv = kFALSE ;
175   char tempo[80] ;
176   sprintf(tempo, "/%s-%s/%s", fYear.Data(), fProd.Data(), vers.Data()) ;
177   fVers = tempo ;
178
179   TString path(fRoot) ;
180   path += tempo ;
181 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
182   if ( !fGrid->OpenDir(path) ) {
183     AliError(Form("Cannot find directory %s ", path.Data() )) ;
184   } else {
185     rv = kTRUE ;
186     fVers = vers ;
187     fPath = path ;
188   }
189 #else
190   Error("SetVers", "needs to be ported to new TGrid");
191 #endif
192   return rv ;
193 }
194
195 //____________________________________________________________________________
196 Bool_t AliPHOSGridFile::SetType(TString type)
197 {
198   // set the year and verifies if the directory exists
199   Bool_t rv = kFALSE ;
200   char tempo[80] ;
201   sprintf(tempo, "/%s-%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), type.Data()) ;
202
203   TString path(fRoot) ;
204   path += tempo ;
205 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
206   if ( !fGrid->OpenDir(path) ) {
207     AliError(Form("Cannot find directory %s ", path.Data() )) ;
208   } else {
209     rv = kTRUE ;
210     fType = type ;
211     fPath = path ;
212   }
213 #else
214   Error("SetType", "needs to be ported to new TGrid");
215 #endif
216   return rv ;
217 }
218
219 //____________________________________________________________________________
220 Bool_t AliPHOSGridFile::SetPath(TString year, TString prod, TString vers, TString type)
221 {
222   // set the year and verifies if the directory exists
223   Bool_t rv = kFALSE ;
224   char tempo[80] ;
225   sprintf(tempo, "/%s-%s/%s/%s", year.Data(), prod.Data(), vers.Data(), type.Data()) ;
226
227   TString path(fRoot) ;
228   path += tempo ;
229 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
230   if ( !fGrid->OpenDir(path) ) {
231     AliError(Form("Cannot find directory %s ", path.Data() )) ;
232   } else {
233     rv = kTRUE ;
234     fPath = path ;
235     fYear += year ;
236     fProd += prod ;
237     fVers += vers ;
238     fType += type ;
239   }
240 #else
241   Error("SetPath", "needs to be ported to new TGrid");
242 #endif
243   return rv ;
244 }
245
246 //____________________________________________________________________________
247 Bool_t AliPHOSGridFile::SetRun(Int_t run)
248 {
249   // set the year and verifies if the directory exists
250   Bool_t rv = kFALSE ;
251
252   TString zero("00000") ;
253   TString srun ;
254   srun += run ;
255   Int_t nzero = zero.Length() - srun.Length() ;
256   Int_t index ;
257   for (index = 0 ; index < nzero ; index++)
258     srun.Prepend("0") ;
259
260   char tempo[80] ;
261   sprintf(tempo, "/%s-%s/%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), srun.Data()) ;
262
263   TString path(fRoot) ;
264   path += tempo ;
265 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
266   if ( !fGrid->OpenDir(path) ) {
267     AliError(Form("Cannot find directory %s ", path.Data() )) ;
268   } else {
269     rv = kTRUE ;
270     fRun = srun ;
271     fPath = path ;
272   }
273 #else
274   Error("SetRun", "needs to be ported to new TGrid");
275 #endif
276   return rv ;
277 }
278
279 //____________________________________________________________________________
280 Bool_t AliPHOSGridFile::SetEvt(Int_t evt)
281 {
282   // set the year and verifies if the directory exists
283   Bool_t rv = kFALSE ;
284
285   TString zero("00000") ;
286   TString sevt ;
287   sevt += evt ;
288   Int_t nzero = zero.Length() - sevt.Length() ;
289   Int_t index ;
290   for (index = 0 ; index < nzero ; index++)
291     sevt.Prepend("0") ;
292
293   char tempo[80] ;
294   sprintf(tempo, "/%s-%s/%s/%s/%s/%s/", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data(), sevt.Data()) ;
295   TString path(fRoot) ;
296   path += tempo ;
297 #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
298   if ( !fGrid->OpenDir(path) ) {
299     AliError(Form("Cannot find directory %s ", path.Data() )) ;
300   } else {
301     rv = kTRUE ;
302     fEvt = sevt ;
303     fPath = path ;
304   }
305 #else
306   Error("SetEvt", "needs to be ported to new TGrid");
307 #endif
308   return rv ;
309 }