]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSGridFile.cxx
Copy constructor is corrected (by T.P.)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGridFile.cxx
CommitLineData
7f06a34f 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)
43073eba 19// check here : /afs/cern.ch/user/p/peters/public/README.ALIEN
7f06a34f 20//-- Author: Yves Schutz (CERN)
21
22// --- ROOT system ---
43073eba 23#include "TObjString.h"
24#include "TGrid.h"
7f06a34f 25#include "TGridResult.h"
26
27// --- Standard library ---
28
29// --- AliRoot header files ---
351dd634 30#include "AliLog.h"
43073eba 31#include "AliPHOSGridFile.h"
7f06a34f 32
925e6570 33ClassImp(AliPHOSGridFile)
7f06a34f 34
35//____________________________________________________________________________
36AliPHOSGridFile::AliPHOSGridFile(TString grid)
37{
43073eba 38 // default ctor; Doing initialisation ;
39 fGrid = 0 ;
40 if (grid == "alien")
7f06a34f 41 fGrid = TGrid::Connect("alien://aliendb1.cern.ch:15000/?direct") ;
43073eba 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 ;
7f06a34f 62
63}
64
65//____________________________________________________________________________
66AliPHOSGridFile::~AliPHOSGridFile()
67{
68}
69
70//____________________________________________________________________________
71TString AliPHOSGridFile::GetLFN() const
72{
73 TString fileName(Pwd()) ;
43073eba 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 = "" ;
7f06a34f 79 }
43073eba 80 else
81 fileName.Prepend("alien://") ;
82#else
83 Error("GetLFN", "needs to be ported to new TGrid");
84#endif
85 return fileName ;
7f06a34f 86}
87
88//____________________________________________________________________________
43073eba 89void AliPHOSGridFile::Copy(AliPHOSGridFile & lfn)
7f06a34f 90{
43073eba 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) ;
7f06a34f 100}
101
102//____________________________________________________________________________
103void AliPHOSGridFile::Help()
104{
105 // Prints information on available lfn's
43073eba 106
107 AliInfo(Form("")) ;
7f06a34f 108
109}
110
111//____________________________________________________________________________
112void AliPHOSGridFile::ListEvents() const
113{
114 // list the available events for the current path and run selected
115
43073eba 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") ;
7f06a34f 121 TGridResult ar(gr) ;
43073eba 122 ar.Print() ;
123#else
124 Error("ListEvents", "needs to be ported to new TGrid");
125#endif
7f06a34f 126}
127
128//____________________________________________________________________________
129void AliPHOSGridFile::ListRuns() const
130{
131 // list the available runs for the current path selected
132
43073eba 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) ;
7f06a34f 138 TGridResult ar(gr) ;
43073eba 139 ar.Print() ;
140#else
141 Error("ListRuns", "needs to be ported to new TGrid");
142#endif
7f06a34f 143}
144
145//____________________________________________________________________________
146Bool_t AliPHOSGridFile::SetYearProd(TString year, TString prod)
147{
148 // set the year and verifies if the directory exists
149 Bool_t rv = kFALSE ;
43073eba 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() )) ;
351dd634 158 } else {
43073eba 159 rv = kTRUE ;
160 fYear = year ;
161 fProd = prod ;
162 fPath = path ;
7f06a34f 163 }
43073eba 164#else
165 Error("SetYearProd", "needs to be ported to new TGrid");
166#endif
167 return rv ;
7f06a34f 168}
169
170//____________________________________________________________________________
43073eba 171Bool_t AliPHOSGridFile::SetVers(TString vers)
7f06a34f 172{
173 // set the year and verifies if the directory exists
174 Bool_t rv = kFALSE ;
43073eba 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() )) ;
351dd634 184 } else {
43073eba 185 rv = kTRUE ;
186 fVers = vers ;
7f06a34f 187 fPath = path ;
188 }
43073eba 189#else
190 Error("SetVers", "needs to be ported to new TGrid");
191#endif
192 return rv ;
7f06a34f 193}
194
195//____________________________________________________________________________
43073eba 196Bool_t AliPHOSGridFile::SetType(TString type)
7f06a34f 197{
198 // set the year and verifies if the directory exists
199 Bool_t rv = kFALSE ;
43073eba 200 char tempo[80] ;
201 sprintf(tempo, "/%s-%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), type.Data()) ;
202
7f06a34f 203 TString path(fRoot) ;
43073eba 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() )) ;
351dd634 208 } else {
43073eba 209 rv = kTRUE ;
210 fType = type ;
211 fPath = path ;
7f06a34f 212 }
43073eba 213#else
214 Error("SetType", "needs to be ported to new TGrid");
215#endif
216 return rv ;
7f06a34f 217}
218
219//____________________________________________________________________________
43073eba 220Bool_t AliPHOSGridFile::SetPath(TString year, TString prod, TString vers, TString type)
7f06a34f 221{
222 // set the year and verifies if the directory exists
43073eba 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() )) ;
351dd634 232 } else {
43073eba 233 rv = kTRUE ;
234 fPath = path ;
235 fYear += year ;
236 fProd += prod ;
237 fVers += vers ;
7f06a34f 238 fType += type ;
239 }
43073eba 240#else
241 Error("SetPath", "needs to be ported to new TGrid");
242#endif
243 return rv ;
7f06a34f 244}
245
246//____________________________________________________________________________
43073eba 247Bool_t AliPHOSGridFile::SetRun(Int_t run)
7f06a34f 248{
249 // set the year and verifies if the directory exists
250 Bool_t rv = kFALSE ;
251
43073eba 252 TString zero("00000") ;
253 TString srun ;
254 srun += run ;
255 Int_t nzero = zero.Length() - srun.Length() ;
7f06a34f 256 Int_t index ;
43073eba 257 for (index = 0 ; index < nzero ; index++)
258 srun.Prepend("0") ;
7f06a34f 259
43073eba 260 char tempo[80] ;
261 sprintf(tempo, "/%s-%s/%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), srun.Data()) ;
7f06a34f 262
43073eba 263 TString path(fRoot) ;
7f06a34f 264 path += tempo ;
43073eba 265#if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
266 if ( !fGrid->OpenDir(path) ) {
267 AliError(Form("Cannot find directory %s ", path.Data() )) ;
351dd634 268 } else {
43073eba 269 rv = kTRUE ;
270 fRun = srun ;
271 fPath = path ;
7f06a34f 272 }
43073eba 273#else
274 Error("SetRun", "needs to be ported to new TGrid");
275#endif
276 return rv ;
7f06a34f 277}
278
279//____________________________________________________________________________
43073eba 280Bool_t AliPHOSGridFile::SetEvt(Int_t evt)
7f06a34f 281{
282 // set the year and verifies if the directory exists
43073eba 283 Bool_t rv = kFALSE ;
7f06a34f 284
43073eba 285 TString zero("00000") ;
286 TString sevt ;
287 sevt += evt ;
288 Int_t nzero = zero.Length() - sevt.Length() ;
7f06a34f 289 Int_t index ;
43073eba 290 for (index = 0 ; index < nzero ; index++)
7f06a34f 291 sevt.Prepend("0") ;
43073eba 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) ;
7f06a34f 296 path += tempo ;
43073eba 297#if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
298 if ( !fGrid->OpenDir(path) ) {
299 AliError(Form("Cannot find directory %s ", path.Data() )) ;
351dd634 300 } else {
43073eba 301 rv = kTRUE ;
302 fEvt = sevt ;
303 fPath = path ;
7f06a34f 304 }
43073eba 305#else
306 Error("SetEvt", "needs to be ported to new TGrid");
307#endif
308 return rv ;
7f06a34f 309}