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