LCOV - code coverage report
Current view: top level - PHOS/PHOSrec - AliPHOSGridFile.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 110 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 19 5.3 %

          Line data    Source code
       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             : 
      41          20 : ClassImp(AliPHOSGridFile)
      42             : 
      43             : //____________________________________________________________________________
      44           0 : AliPHOSGridFile::AliPHOSGridFile(TString grid):
      45           0 :   fGrid(0),
      46           0 :   fRoot("/alice/production/aliprod"),
      47           0 :   fYear(""),
      48           0 :   fProd(""),
      49           0 :   fVers(""),
      50           0 :   fType(""),
      51           0 :   fRun(""),
      52           0 :   fEvt(""),
      53           0 :   fPath("")
      54           0 : {
      55             :   // default ctor; Doing initialisation ;
      56           0 :   if (grid == "alien")
      57           0 :     fGrid = TGrid::Connect("alien://aliendb1.cern.ch:15000/?direct") ;
      58             :   else
      59           0 :     Error("AliPHOSGridFile", " %s is an unknown grid system", grid.Data()) ;
      60           0 :   if ( !fGrid )
      61           0 :     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           0 :   Error("AliPHOSGridFile", "needs to be ported to new TGrid");
      68             : #endif
      69             : 
      70           0 :   fPath += fRoot ;
      71           0 : }
      72             : 
      73             : //____________________________________________________________________________
      74             : AliPHOSGridFile::AliPHOSGridFile(const AliPHOSGridFile &rhs) :
      75           0 :   TObject(rhs),
      76           0 :   fGrid(0),
      77           0 :   fRoot(""),
      78           0 :   fYear(""),
      79           0 :   fProd(""),
      80           0 :   fVers(""),
      81           0 :   fType(""),
      82           0 :   fRun(""),
      83           0 :   fEvt(""),
      84           0 :   fPath("")
      85           0 : {
      86             :   //copy ctor
      87           0 :   rhs.Copy(*this);
      88           0 : }
      89             : 
      90             : //____________________________________________________________________________
      91             : AliPHOSGridFile::~AliPHOSGridFile()
      92           0 : {
      93           0 : }
      94             : 
      95             : //____________________________________________________________________________
      96             : TString AliPHOSGridFile::GetLFN() const
      97             : {
      98           0 :   TString fileName(Pwd()) ;
      99           0 :   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           0 :   Error("GetLFN", "needs to be ported to new TGrid");
     109             : #endif
     110             :   return fileName ;
     111           0 : }
     112             : 
     113             : //____________________________________________________________________________
     114             : void AliPHOSGridFile::Copy(TObject & obj)const
     115             : {
     116             :   //Copy method used by the Copy ctor
     117           0 :   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           0 :   lfn.fRoot = fRoot ;
     129           0 :   lfn.fYear = fYear ;
     130           0 :   lfn.fProd = fProd ;
     131           0 :   lfn.fVers = fVers ;
     132           0 :   lfn.fType = fType ;
     133           0 :   lfn.fRun  = fRun ;
     134           0 :   lfn.fEvt  = fEvt ;
     135           0 :   TObject::Copy(lfn) ;
     136           0 : }
     137             : 
     138             : //____________________________________________________________________________
     139             : void AliPHOSGridFile::Help()
     140             : {
     141             :   // Prints information on available lfn's
     142             : 
     143           0 :   AliInfo(Form(" ")) ;
     144             : 
     145           0 : }
     146             : 
     147             : //____________________________________________________________________________
     148             : void AliPHOSGridFile::ListEvents() const
     149             : {
     150             :   // list the available events for the current path and run selected
     151             : 
     152           0 :   char path[80] ;
     153           0 :   snprintf(path,80,"%s/%s-%s/%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data()) ;
     154           0 :   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           0 :   Error("ListEvents", "needs to be ported to new TGrid");
     161             : #endif
     162           0 : }
     163             : 
     164             : //____________________________________________________________________________
     165             : void AliPHOSGridFile::ListRuns() const
     166             : {
     167             :   // list the available runs for the current path selected
     168             : 
     169           0 :   char path[80] ;
     170           0 :   snprintf(path,80,"%s/%s-%s/%s/%s", fRoot.Data(), fYear.Data(), fProd.Data(), fVers.Data(), fType.Data()) ;
     171           0 :   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           0 :   Error("ListRuns", "needs to be ported to new TGrid");
     178             : #endif
     179           0 : }
     180             : 
     181             : //____________________________________________________________________________
     182             : Bool_t AliPHOSGridFile::SetYearProd(TString year, TString prod)
     183             : {
     184             :   // set the year and verifies if the directory exists
     185             :   Bool_t rv = kFALSE ;
     186           0 :   char tempo[80] ;
     187           0 :   snprintf(tempo,80,"/%s-%s", year.Data(), prod.Data()) ;
     188             : 
     189           0 :   TString path(fRoot) ;
     190           0 :   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           0 :   Error("SetYearProd", "needs to be ported to new TGrid");
     202             : #endif
     203             :   return rv ;
     204           0 : }
     205             : 
     206             : //____________________________________________________________________________
     207             : Bool_t AliPHOSGridFile::SetVers(TString vers)
     208             : {
     209             :   // set the year and verifies if the directory exists
     210             :   Bool_t rv = kFALSE ;
     211           0 :   char tempo[80] ;
     212           0 :   snprintf(tempo,80,"/%s-%s/%s", fYear.Data(), fProd.Data(), vers.Data()) ;
     213           0 :   fVers = tempo ;
     214             : 
     215           0 :   TString path(fRoot) ;
     216           0 :   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           0 :   Error("SetVers", "needs to be ported to new TGrid");
     227             : #endif
     228             :   return rv ;
     229           0 : }
     230             : 
     231             : //____________________________________________________________________________
     232             : Bool_t AliPHOSGridFile::SetType(TString type)
     233             : {
     234             :   // set the year and verifies if the directory exists
     235             :   Bool_t rv = kFALSE ;
     236           0 :   char tempo[80] ;
     237           0 :   snprintf(tempo,80,"/%s-%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), type.Data()) ;
     238             : 
     239           0 :   TString path(fRoot) ;
     240           0 :   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           0 :   Error("SetType", "needs to be ported to new TGrid");
     251             : #endif
     252             :   return rv ;
     253           0 : }
     254             : 
     255             : //____________________________________________________________________________
     256             : Bool_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           0 :   char tempo[80] ;
     261           0 :   snprintf(tempo,80,"/%s-%s/%s/%s", year.Data(), prod.Data(), vers.Data(), type.Data()) ;
     262             : 
     263           0 :   TString path(fRoot) ;
     264           0 :   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           0 :   Error("SetPath", "needs to be ported to new TGrid");
     278             : #endif
     279             :   return rv ;
     280           0 : }
     281             : 
     282             : //____________________________________________________________________________
     283             : Bool_t AliPHOSGridFile::SetRun(Int_t run)
     284             : {
     285             :   // set the year and verifies if the directory exists
     286             :   Bool_t rv = kFALSE ;
     287             : 
     288           0 :   TString zero("00000") ;
     289           0 :   TString srun ;
     290           0 :   srun += run ;
     291           0 :   Int_t nzero = zero.Length() - srun.Length() ;
     292             :   Int_t index ;
     293           0 :   for (index = 0 ; index < nzero ; index++)
     294           0 :     srun.Prepend("0") ;
     295             : 
     296           0 :   char tempo[80] ;
     297           0 :   snprintf(tempo,80,"/%s-%s/%s/%s/%s", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), srun.Data()) ;
     298             : 
     299           0 :   TString path(fRoot) ;
     300           0 :   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           0 :   Error("SetRun", "needs to be ported to new TGrid");
     311             : #endif
     312             :   return rv ;
     313           0 : }
     314             : 
     315             : //____________________________________________________________________________
     316             : Bool_t AliPHOSGridFile::SetEvt(Int_t evt)
     317             : {
     318             :   // set the year and verifies if the directory exists
     319             :   Bool_t rv = kFALSE ;
     320             : 
     321           0 :   TString zero("00000") ;
     322           0 :   TString sevt ;
     323           0 :   sevt += evt ;
     324           0 :   Int_t nzero = zero.Length() - sevt.Length() ;
     325             :   Int_t index ;
     326           0 :   for (index = 0 ; index < nzero ; index++)
     327           0 :     sevt.Prepend("0") ;
     328             : 
     329           0 :   char tempo[80] ;
     330           0 :   snprintf(tempo,80,"/%s-%s/%s/%s/%s/%s/", fYear.Data(), fProd.Data(), fVers.Data(), fType.Data(), fRun.Data(), sevt.Data()) ;
     331           0 :   TString path(fRoot) ;
     332           0 :   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           0 :   Error("SetEvt", "needs to be ported to new TGrid");
     343             : #endif
     344             :   return rv ;
     345           0 : }

Generated by: LCOV version 1.11