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