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