]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSGridFile.cxx
Base Particle Cuts moved to the separate file. Property eneum defined namespace of...
[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)
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 "TGridResult.h"
25
26// --- Standard library ---
27
28// --- AliRoot header files ---
29
30#include "AliPHOSGridFile.h"
31
32ClassImp(AliPHOSGridFile) ;
33
34//____________________________________________________________________________
35AliPHOSGridFile::AliPHOSGridFile(TString grid)
36{
37 // default ctor; Doing initialisation ;
38 fGrid = 0 ;
39 if (grid == "alien")
40 fGrid = TGrid::Connect("alien://aliendb1.cern.ch:15000/?direct") ;
41 else
42 Error("AliPHOSGridFile", " %s is an unknown grid system", grid.Data()) ;
43 if ( !fGrid )
44 Error("ctor", "Cannot connect to alien://aliendb1.cern.ch:15000/?direct") ;
45
46 fRoot = "/alice/production/aliprod" ;
47 if ( !fGrid->OpenDir(fRoot) )
48 Error("ctor", "Cannot find directory %s ", fRoot.Data() ) ;
49
50 fYear = "" ;
51 fProd = "" ;
52 fVers = "" ;
53 fType = "" ;
54 fRun = "" ;
55 fEvt = "" ;
56
57 fPath += fRoot ;
58
59}
60
61//____________________________________________________________________________
62AliPHOSGridFile::~AliPHOSGridFile()
63{
64}
65
66//____________________________________________________________________________
67TString AliPHOSGridFile::GetLFN() const
68{
69 TString fileName(Pwd()) ;
70 fileName += "galice.root" ;
71 if ( !fGrid->GetAccessPath(fileName) ) {
72 Warning("GetLFN", "file %s does not exist", fileName.Data()) ;
73 fileName = "" ;
74 }
75 else
76 fileName.Prepend("alien://") ;
77 return fileName ;
78}
79
80//____________________________________________________________________________
81void AliPHOSGridFile::Copy(AliPHOSGridFile & lfn)
82{
83 //Copy method used by the Copy ctor
84 fRoot = lfn.fRoot ;
85 fYear = lfn.fYear ;
86 fProd = lfn.fProd ;
87 fVers = lfn.fVers ;
88 fType = lfn.fType ;
89 fRun = lfn.fRun ;
90 fEvt = lfn.fEvt ;
91 TObject::Copy(lfn) ;
92}
93
94//____________________________________________________________________________
95void AliPHOSGridFile::Help()
96{
97 // Prints information on available lfn's
98
99 Info("Info", " ") ;
100
101}
102
103//____________________________________________________________________________
104void AliPHOSGridFile::ListEvents() const
105{
106 // list the available events for the current path and run selected
107
108 char path[80] ;
109 sprintf(path, "%s/%s-%s/%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data()) ;
110 Info("ListEvents", "Searching %s", path) ;
111 Grid_ResultHandle_t gr = fGrid->Find(path, "galice.root") ;
112 TGridResult ar(gr) ;
113 ar.Print() ;
114}
115
116//____________________________________________________________________________
117void AliPHOSGridFile::ListRuns() const
118{
119 // list the available runs for the current path selected
120
121 char path[80] ;
122 sprintf(path, "%s/%s-%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data()) ;
123 Info("ListEvents", "Searching %s", path) ;
124 Grid_ResultHandle_t gr = fGrid->OpenDir(path) ;
125 TGridResult ar(gr) ;
126 ar.Print() ;
127}
128
129//____________________________________________________________________________
130Bool_t AliPHOSGridFile::SetYearProd(TString year, TString prod)
131{
132 // set the year and verifies if the directory exists
133 Bool_t rv = kFALSE ;
134 char tempo[80] ;
135 sprintf(tempo, "/%s-%s", year.Data(), prod.Data()) ;
136
137 TString path(fRoot) ;
138 path += tempo ;
139 if ( !fGrid->OpenDir(path) )
140 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
141 else {
142 rv = kTRUE ;
143 fYear = year ;
144 fProd = prod ;
145 fPath = path ;
146 }
147 return rv ;
148}
149
150//____________________________________________________________________________
151Bool_t AliPHOSGridFile::SetVers(TString vers)
152{
153 // set the year and verifies if the directory exists
154 Bool_t rv = kFALSE ;
155 char tempo[80] ;
156 sprintf(tempo, "/%s-%s/%s", fYear.Data(), fProd.Data(), vers.Data()) ;
157 fVers = tempo ;
158
159 TString path(fRoot) ;
160 path += tempo ;
161 if ( !fGrid->OpenDir(path) )
162 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
163 else {
164 rv = kTRUE ;
165 fVers = vers ;
166 fPath = path ;
167 }
168 return rv ;
169}
170
171//____________________________________________________________________________
172Bool_t AliPHOSGridFile::SetType(TString type)
173{
174 // set the year and verifies if the directory exists
175 Bool_t rv = kFALSE ;
176 char tempo[80] ;
177 sprintf(tempo, "/%s-%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), type.Data()) ;
178
179 TString path(fRoot) ;
180 path += tempo ;
181 if ( !fGrid->OpenDir(path) )
182 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
183 else {
184 rv = kTRUE ;
185 fType = type ;
186 fPath = path ;
187 }
188 return rv ;
189}
190
191//____________________________________________________________________________
192Bool_t AliPHOSGridFile::SetPath(TString year, TString prod, TString vers, TString type)
193{
194 // set the year and verifies if the directory exists
195 Bool_t rv = kFALSE ;
196 char tempo[80] ;
197 sprintf(tempo, "/%s-%s/%s/%s", year.Data(), prod.Data(), vers.Data(), type.Data()) ;
198
199 TString path(fRoot) ;
200 path += tempo ;
201 if ( !fGrid->OpenDir(path) )
202 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
203 else {
204 rv = kTRUE ;
205 fPath = path ;
206 fYear += year ;
207 fProd += prod ;
208 fVers += vers ;
209 fType += type ;
210 }
211 return rv ;
212}
213
214//____________________________________________________________________________
215Bool_t AliPHOSGridFile::SetRun(Int_t run)
216{
217 // set the year and verifies if the directory exists
218 Bool_t rv = kFALSE ;
219
220 TString zero("00000") ;
221 TString srun ;
222 srun += run ;
223 Int_t nzero = zero.Length() - srun.Length() ;
224 Int_t index ;
225 for (index = 0 ; index < nzero ; index++)
226 srun.Prepend("0") ;
227
228 char tempo[80] ;
229 sprintf(tempo, "/%s-%s/%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), srun.Data()) ;
230
231 TString path(fRoot) ;
232 path += tempo ;
233 if ( !fGrid->OpenDir(path) )
234 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
235 else {
236 rv = kTRUE ;
237 fRun = srun ;
238 fPath = path ;
239 }
240 return rv ;
241}
242
243//____________________________________________________________________________
244Bool_t AliPHOSGridFile::SetEvt(Int_t evt)
245{
246 // set the year and verifies if the directory exists
247 Bool_t rv = kFALSE ;
248
249 TString zero("00000") ;
250 TString sevt ;
251 sevt += evt ;
252 Int_t nzero = zero.Length() - sevt.Length() ;
253 Int_t index ;
254 for (index = 0 ; index < nzero ; index++)
255 sevt.Prepend("0") ;
256
257 char tempo[80] ;
258 sprintf(tempo, "/%s-%s/%s/%s/%s/%s/", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data(), sevt.Data()) ;
259 TString path(fRoot) ;
260 path += tempo ;
261 if ( !fGrid->OpenDir(path) )
262 Error("ctor", "Cannot find directory %s ", path.Data() ) ;
263 else {
264 rv = kTRUE ;
265 fEvt = sevt ;
266 fPath = path ;
267 }
268 return rv ;
269}
270
271