#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"
AliTagCreator::AliTagCreator() //local mode
{
//==============Default constructor for a AliTagCreator==================
+ fgridpath = "";
fUser = "";
fPasswd = "";
fSE = "";
fHost = "";
fPort = 0;
+ fStorage = 0;
fresult = 0;
}
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;
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;
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)
{
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();
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;
-}
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);
~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)
};