]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Replacing TFileMerger with simple TFile (P.Christakoglou)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 11 Oct 2005 15:16:16 +0000 (15:16 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 11 Oct 2005 15:16:16 +0000 (15:16 +0000)
STEER/AliTagCreator.cxx
STEER/AliTagCreator.h

index 9112448171ffd447aa95d050dd376f5f3aa032ed..0d627872a293422a647d7f85563835c0a70ecbd3 100644 (file)
 #include <TChain.h>
 #include <TFile.h>
 #include <TString.h>
-#include <THashTable.h>
 
 //ROOT-AliEn
 #include <TGrid.h>
-//#include <TAlienCollection.h>
 #include <TGridResult.h>
-#include <TFileMerger.h>
-#include <TMap.h>
-#include <TXMLParser.h>
-#include <TThread.h>
-#include <TTreePlayer.h>
-#include <TProof.h>
 
 //AliRoot
 #include "AliRunTag.h"
@@ -59,11 +51,13 @@ ClassImp(AliTagCreator)
 AliTagCreator::AliTagCreator() //local mode
 {
   //==============Default constructor for a AliTagCreator==================
+  fgridpath = "";
   fUser = "";
   fPasswd = "";  
   fSE = "";   
   fHost = "";
   fPort = 0; 
+  fStorage = 0; 
   fresult = 0;
 }
 
@@ -71,7 +65,9 @@ AliTagCreator::AliTagCreator() //local mode
 AliTagCreator::AliTagCreator(const char *host, Int_t port, const char *username)
 {
   //==============Default constructor for a AliTagCreator==================
+  fStorage = 0; 
   fresult = 0;
+  fgridpath = "";
   fHost = host;
   fUser = username;
   fPort = port;
@@ -95,7 +91,9 @@ AliTagCreator::AliTagCreator(const char *host, Int_t port, const char *username)
 AliTagCreator::AliTagCreator(const char *host, Int_t port, const char *username, const char *passwd)
 {
   //==============Default constructor for a AliTagCreator==================
+  fStorage = 0; 
   fresult = 0;
+  fgridpath = "";
   fHost = host;
   fUser = username;
   fPasswd = passwd;
@@ -128,6 +126,27 @@ void AliTagCreator::SetSE(const char *se)
   fSE = se;
 }
 
+//______________________________________________________________________________
+void AliTagCreator::SetGridPath(const char *gridpath)
+{
+  fgridpath = gridpath;
+}
+
+//______________________________________________________________________________
+void AliTagCreator::SetStorage(Int_t storage)
+{
+  fStorage = storage;
+  if(fStorage == 0)
+    AliInfo(Form("Tags will be stored locally...."));
+  if(fStorage == 1)
+    AliInfo(Form("Tags will be stored in the grid...."));
+  if((fStorage != 0)&&(fStorage != 1))
+    {
+      AliInfo(Form("Storage was not properly set!!!"));
+      abort();
+    }  
+}
+
 //______________________________________________________________________________
 Bool_t AliTagCreator::ConnectToGrid(const char *host, Int_t port, const char *username)
 {
@@ -406,9 +425,28 @@ void AliTagCreator::CreateTag(TFile* file, const char *guid, Int_t Counter)
   LocalfileName += ".Event"; LocalfileName += firstEvent; LocalfileName += "_"; LocalfileName += lastEvent; LocalfileName += "."; LocalfileName += Counter;
   LocalfileName += ".ESD.tag.root";
 
-  cout<<"Writing tags to local file: "<<LocalfileName<<endl;
+  TString AlienLocation = "/alien";
+  AlienLocation += gGrid->Pwd();
+  AlienLocation += fgridpath.Data();
+  AlienLocation += "/";
+  AlienLocation +=  LocalfileName;
+  AlienLocation += "?se=";
+  AlienLocation += fSE.Data();
+
+  TString FileName;
+  
+  if(fStorage == 0)
+    {
+      FileName = LocalfileName.Data();      
+      cout<<"Writing tags to local file: "<<FileName.Data()<<endl;
+    }
+  if(fStorage == 1)
+    {
+      FileName = AlienLocation.Data();
+      cout<<"Writing tags to grid file: "<<FileName.Data()<<endl;
+    }
 
-  TFile* ftag = TFile::Open(LocalfileName, "recreate");
+  TFile* ftag = TFile::Open(FileName, "recreate");
   ftag->cd();
   ttag.Write();
   ftag->Close();
@@ -421,39 +459,3 @@ void AliTagCreator::CreateTag(TFile* file, const char *guid, Int_t Counter)
   delete evTag;
 }
 
-//_____________________________________________________________________________
-Bool_t AliTagCreator::StoreGridTagFile(const char *localpath, const char *gridpath)
-{
-  gSystem->Load("libThread.so");
-  gSystem->Load("libTreePlayer.so");
-  gSystem->Load("libProof.so");
-  cout<<"Storing tag file to alien's file catalog..."<<endl;
-  TFileMerger merger;
-  const char * pattern = "tag.root";
-  // Open the working directory
-  void * dirp = gSystem->OpenDirectory(localpath);
-  const char * name = 0x0;
-  TString AlienLocation;
-  Char_t LocalLocation[256];
-  // Add all files matching *pattern* to the chain
-  while((name = gSystem->GetDirEntry(dirp)))
-    {
-      if (strstr(name,pattern))
-       {
-         sprintf(LocalLocation,"file:%s/%s",localpath,name);
-         AlienLocation = "/alien";
-         AlienLocation += gGrid->Pwd();
-         AlienLocation += gridpath;
-         AlienLocation += "/";
-         AlienLocation += name;
-         AlienLocation += "?se=";
-         AlienLocation += fSE.Data();
-         merger.Cp(LocalLocation,AlienLocation);
-           
-       }
-    }  
-  gSystem->FreeDirectory(dirp);
-   
-  return kTRUE;
-}
index 05e78154104ee8adb192a6ca66c4519f6ca9649e..ee11691096d851395ca8f9e6153b9b65c0e3aa73 100644 (file)
@@ -38,7 +38,9 @@ class AliTagCreator : public TObject {
   TString fPasswd;   //the username's password
   TString fSE;   //the defined storage element
   TString fHost; //the defined AliEn host
+  TString fgridpath;   //the alien location of the tag files
   Int_t fPort;  //the defined port for the host login
+  Int_t fStorage;  //0:local - 1:grid
   TGridResult *fresult; //the results from the grid query
 
   void CreateTag(TFile* file, const char *guid, Int_t Counter);
@@ -50,9 +52,10 @@ class AliTagCreator : public TObject {
   ~AliTagCreator(); 
 
   void SetSE(const char *se);
+  void SetStorage(Int_t storage);
+  void SetGridPath(const char *gridpath);
   Bool_t ConnectToGrid(const char *host, Int_t port, const char *username);
   Bool_t ReadESDCollection(TGridResult *result);
-  Bool_t StoreGridTagFile(const char *localpath, const char *gridpath);
 
   ClassDef(AliTagCreator,0)  
 };