]>
Commit | Line | Data |
---|---|---|
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 | ||
702ab87e | 17 | /* History of cvs commits: |
18 | * | |
19 | * $Log$ | |
20 | */ | |
21 | ||
7f06a34f | 22 | //_________________________________________________________________________ |
23 | // To navigate in the Grid catalogue (very elementary) | |
43073eba | 24 | // check here : /afs/cern.ch/user/p/peters/public/README.ALIEN |
7f06a34f | 25 | //-- Author: Yves Schutz (CERN) |
26 | ||
27 | // --- ROOT system --- | |
43073eba | 28 | #include "TObjString.h" |
29 | #include "TGrid.h" | |
7f06a34f | 30 | #include "TGridResult.h" |
31 | ||
32 | // --- Standard library --- | |
33 | ||
34 | // --- AliRoot header files --- | |
351dd634 | 35 | #include "AliLog.h" |
43073eba | 36 | #include "AliPHOSGridFile.h" |
7f06a34f | 37 | |
925e6570 | 38 | ClassImp(AliPHOSGridFile) |
7f06a34f | 39 | |
40 | //____________________________________________________________________________ | |
41 | AliPHOSGridFile::AliPHOSGridFile(TString grid) | |
42 | { | |
43073eba | 43 | // default ctor; Doing initialisation ; |
44 | fGrid = 0 ; | |
45 | if (grid == "alien") | |
7f06a34f | 46 | fGrid = TGrid::Connect("alien://aliendb1.cern.ch:15000/?direct") ; |
43073eba | 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 ; | |
7f06a34f | 67 | |
68 | } | |
69 | ||
70 | //____________________________________________________________________________ | |
71 | AliPHOSGridFile::~AliPHOSGridFile() | |
72 | { | |
73 | } | |
74 | ||
75 | //____________________________________________________________________________ | |
76 | TString AliPHOSGridFile::GetLFN() const | |
77 | { | |
78 | TString fileName(Pwd()) ; | |
43073eba | 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 = "" ; | |
7f06a34f | 84 | } |
43073eba | 85 | else |
86 | fileName.Prepend("alien://") ; | |
87 | #else | |
88 | Error("GetLFN", "needs to be ported to new TGrid"); | |
89 | #endif | |
90 | return fileName ; | |
7f06a34f | 91 | } |
92 | ||
93 | //____________________________________________________________________________ | |
702ab87e | 94 | void AliPHOSGridFile::Copy(TObject & obj)const |
7f06a34f | 95 | { |
43073eba | 96 | //Copy method used by the Copy ctor |
702ab87e | 97 | AliPHOSGridFile &lfn = static_cast<AliPHOSGridFile &>(obj); |
98 | /* incorrect Copy, destination is OBJ, not this. | |
43073eba | 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) ; | |
702ab87e | 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) ; | |
7f06a34f | 116 | } |
117 | ||
118 | //____________________________________________________________________________ | |
119 | void AliPHOSGridFile::Help() | |
120 | { | |
121 | // Prints information on available lfn's | |
43073eba | 122 | |
123 | AliInfo(Form("")) ; | |
7f06a34f | 124 | |
125 | } | |
126 | ||
127 | //____________________________________________________________________________ | |
128 | void AliPHOSGridFile::ListEvents() const | |
129 | { | |
130 | // list the available events for the current path and run selected | |
131 | ||
43073eba | 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") ; | |
7f06a34f | 137 | TGridResult ar(gr) ; |
43073eba | 138 | ar.Print() ; |
139 | #else | |
140 | Error("ListEvents", "needs to be ported to new TGrid"); | |
141 | #endif | |
7f06a34f | 142 | } |
143 | ||
144 | //____________________________________________________________________________ | |
145 | void AliPHOSGridFile::ListRuns() const | |
146 | { | |
147 | // list the available runs for the current path selected | |
148 | ||
43073eba | 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) ; | |
7f06a34f | 154 | TGridResult ar(gr) ; |
43073eba | 155 | ar.Print() ; |
156 | #else | |
157 | Error("ListRuns", "needs to be ported to new TGrid"); | |
158 | #endif | |
7f06a34f | 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 ; | |
43073eba | 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() )) ; | |
351dd634 | 174 | } else { |
43073eba | 175 | rv = kTRUE ; |
176 | fYear = year ; | |
177 | fProd = prod ; | |
178 | fPath = path ; | |
7f06a34f | 179 | } |
43073eba | 180 | #else |
181 | Error("SetYearProd", "needs to be ported to new TGrid"); | |
182 | #endif | |
183 | return rv ; | |
7f06a34f | 184 | } |
185 | ||
186 | //____________________________________________________________________________ | |
43073eba | 187 | Bool_t AliPHOSGridFile::SetVers(TString vers) |
7f06a34f | 188 | { |
189 | // set the year and verifies if the directory exists | |
190 | Bool_t rv = kFALSE ; | |
43073eba | 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() )) ; | |
351dd634 | 200 | } else { |
43073eba | 201 | rv = kTRUE ; |
202 | fVers = vers ; | |
7f06a34f | 203 | fPath = path ; |
204 | } | |
43073eba | 205 | #else |
206 | Error("SetVers", "needs to be ported to new TGrid"); | |
207 | #endif | |
208 | return rv ; | |
7f06a34f | 209 | } |
210 | ||
211 | //____________________________________________________________________________ | |
43073eba | 212 | Bool_t AliPHOSGridFile::SetType(TString type) |
7f06a34f | 213 | { |
214 | // set the year and verifies if the directory exists | |
215 | Bool_t rv = kFALSE ; | |
43073eba | 216 | char tempo[80] ; |
217 | sprintf(tempo, "/%s-%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), type.Data()) ; | |
218 | ||
7f06a34f | 219 | TString path(fRoot) ; |
43073eba | 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() )) ; | |
351dd634 | 224 | } else { |
43073eba | 225 | rv = kTRUE ; |
226 | fType = type ; | |
227 | fPath = path ; | |
7f06a34f | 228 | } |
43073eba | 229 | #else |
230 | Error("SetType", "needs to be ported to new TGrid"); | |
231 | #endif | |
232 | return rv ; | |
7f06a34f | 233 | } |
234 | ||
235 | //____________________________________________________________________________ | |
43073eba | 236 | Bool_t AliPHOSGridFile::SetPath(TString year, TString prod, TString vers, TString type) |
7f06a34f | 237 | { |
238 | // set the year and verifies if the directory exists | |
43073eba | 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() )) ; | |
351dd634 | 248 | } else { |
43073eba | 249 | rv = kTRUE ; |
250 | fPath = path ; | |
251 | fYear += year ; | |
252 | fProd += prod ; | |
253 | fVers += vers ; | |
7f06a34f | 254 | fType += type ; |
255 | } | |
43073eba | 256 | #else |
257 | Error("SetPath", "needs to be ported to new TGrid"); | |
258 | #endif | |
259 | return rv ; | |
7f06a34f | 260 | } |
261 | ||
262 | //____________________________________________________________________________ | |
43073eba | 263 | Bool_t AliPHOSGridFile::SetRun(Int_t run) |
7f06a34f | 264 | { |
265 | // set the year and verifies if the directory exists | |
266 | Bool_t rv = kFALSE ; | |
267 | ||
43073eba | 268 | TString zero("00000") ; |
269 | TString srun ; | |
270 | srun += run ; | |
271 | Int_t nzero = zero.Length() - srun.Length() ; | |
7f06a34f | 272 | Int_t index ; |
43073eba | 273 | for (index = 0 ; index < nzero ; index++) |
274 | srun.Prepend("0") ; | |
7f06a34f | 275 | |
43073eba | 276 | char tempo[80] ; |
277 | sprintf(tempo, "/%s-%s/%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), srun.Data()) ; | |
7f06a34f | 278 | |
43073eba | 279 | TString path(fRoot) ; |
7f06a34f | 280 | path += tempo ; |
43073eba | 281 | #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0) |
282 | if ( !fGrid->OpenDir(path) ) { | |
283 | AliError(Form("Cannot find directory %s ", path.Data() )) ; | |
351dd634 | 284 | } else { |
43073eba | 285 | rv = kTRUE ; |
286 | fRun = srun ; | |
287 | fPath = path ; | |
7f06a34f | 288 | } |
43073eba | 289 | #else |
290 | Error("SetRun", "needs to be ported to new TGrid"); | |
291 | #endif | |
292 | return rv ; | |
7f06a34f | 293 | } |
294 | ||
295 | //____________________________________________________________________________ | |
43073eba | 296 | Bool_t AliPHOSGridFile::SetEvt(Int_t evt) |
7f06a34f | 297 | { |
298 | // set the year and verifies if the directory exists | |
43073eba | 299 | Bool_t rv = kFALSE ; |
7f06a34f | 300 | |
43073eba | 301 | TString zero("00000") ; |
302 | TString sevt ; | |
303 | sevt += evt ; | |
304 | Int_t nzero = zero.Length() - sevt.Length() ; | |
7f06a34f | 305 | Int_t index ; |
43073eba | 306 | for (index = 0 ; index < nzero ; index++) |
7f06a34f | 307 | sevt.Prepend("0") ; |
43073eba | 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) ; | |
7f06a34f | 312 | path += tempo ; |
43073eba | 313 | #if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0) |
314 | if ( !fGrid->OpenDir(path) ) { | |
315 | AliError(Form("Cannot find directory %s ", path.Data() )) ; | |
351dd634 | 316 | } else { |
43073eba | 317 | rv = kTRUE ; |
318 | fEvt = sevt ; | |
319 | fPath = path ; | |
7f06a34f | 320 | } |
43073eba | 321 | #else |
322 | Error("SetEvt", "needs to be ported to new TGrid"); | |
323 | #endif | |
324 | return rv ; | |
7f06a34f | 325 | } |