fPackages(0),
fModules(0),
fProofParam(),
- fDropToShell(true),
- fGridJobIDs(""),
- fGridStages("")
+ fDropToShell(true),
+ fGridJobIDs(""),
+ fGridStages(""),
+ fFriendLibs(""),
+ fTreeName()
{
// Dummy ctor.
SetDefaults();
fProofParam(),
fDropToShell(true),
fGridJobIDs(""),
- fGridStages("")
+ fGridStages(""),
+ fFriendLibs(""),
+ fTreeName()
{
// Default ctor.
SetDefaults();
fProofParam(),
fDropToShell(other.fDropToShell),
fGridJobIDs(other.fGridJobIDs),
- fGridStages(other.fGridStages)
+ fGridStages(other.fGridStages),
+ fFriendLibs(other.fFriendLibs),
+ fTreeName(other.fTreeName)
{
// Copy ctor.
fGridJDL = (TGridJDL*)gROOT->ProcessLine("new TAlienJDL()");
fDropToShell = other.fDropToShell;
fGridJobIDs = other.fGridJobIDs;
fGridStages = other.fGridStages;
+ fFriendLibs = other.fFriendLibs;
+ fTreeName = other.fTreeName;
if (other.fInputFiles) {
fInputFiles = new TObjArray();
TIter next(other.fInputFiles);
return kFALSE;
}
if (!LoadModule(mod)) return kFALSE;
+ if (!LoadFriendLibs()) return kFALSE;
} else if (!LoadModules()) return kFALSE;
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
if (!mgr->InitAnalysis()) return kFALSE;
mod = (AliAnalysisTaskCfg*)fModules->At(imod);
if (!LoadModule(mod)) return kFALSE;
}
- return kTRUE;
+ // Load additional friend libraries
+ return LoadFriendLibs();
}
+//______________________________________________________________________________
+Bool_t AliAnalysisAlien::LoadFriendLibs() const
+{
+// Load libraries required for reading friends.
+ if (fFriendLibs.Length()) {
+ TObjArray *list = 0;
+ TString lib;
+ if (fFriendLibs.Contains(",")) list = fFriendLibs.Tokenize(",");
+ else list = fFriendLibs.Tokenize(" ");
+ for (Int_t ilib=0; ilib<list->GetEntriesFast(); ilib++) {
+ lib = list->At(ilib)->GetName();
+ lib.ReplaceAll(".so","");
+ lib.ReplaceAll(" ","");
+ if (lib.BeginsWith("lib")) lib.Remove(0, 3);
+ lib.Prepend("lib");
+ Int_t loaded = strlen(gSystem->GetLibraries(lib,"",kFALSE));
+ if (!loaded) loaded = gSystem->Load(lib);
+ if (loaded < 0) {
+ Error("LoadModules", "Cannot load library for friends %s", lib.Data());
+ return kFALSE;
+ }
+ }
+ delete list;
+ }
+ return kTRUE;
+}
+
//______________________________________________________________________________
void AliAnalysisAlien::SetRunPrefix(const char *prefix)
{
// Compose the 'find' command arguments
TString format;
TString command;
+ TString delimiter = pattern;
+ delimiter.Strip();
+ if (delimiter.Contains(" ")) delimiter = "";
+ else delimiter = " ";
TString options = "-x collection ";
if (TestBit(AliAnalysisGrid::kTest)) options += Form("-l %d ", fNtestFiles);
else options += Form("-l %d ", gMaxEntries); // Protection for the find command
if (!DirectoryExists(path)) {
Error("CreateDataset", "Path to data directory %s not valid",fGridDataDir.Data());
return kFALSE;
- }
+ }
// CdWork();
if (TestBit(AliAnalysisGrid::kTest)) file = "wn.xml";
else file = Form("%s.xml", gSystem->BaseName(path));
command = "find ";
command += Form("%s -o %d ",options.Data(), nstart);
command += path;
- command += " ";
+ command += delimiter;
command += pattern;
command += conditions;
printf("command: %s\n", command.Data());
while ((os=(TObjString*)next())) {
nstart = 0;
stage = 0;
- path = Form("%s/%s/ ", fGridDataDir.Data(), os->GetString().Data());
+ path = Form("%s/%s/", fGridDataDir.Data(), os->GetString().Data());
if (!DirectoryExists(path)) continue;
// CdWork();
if (TestBit(AliAnalysisGrid::kTest)) file = "wn.xml";
command = "find ";
command += Form("%s -o %d ",options.Data(), nstart);
command += path;
+ command += delimiter;
command += pattern;
command += conditions;
TGridResult *res = gGrid->Command(command);
} else {
// Process a full run range.
for (Int_t irun=fRunRange[0]; irun<=fRunRange[1]; irun++) {
- format = Form("%%s/%s ", fRunPrefix.Data());
+ format = Form("%%s/%s/", fRunPrefix.Data());
nstart = 0;
stage = 0;
path = Form(format.Data(), fGridDataDir.Data(), irun);
command = "find ";
command += Form("%s -o %d ",options.Data(), nstart);
command += path;
+ command += delimiter;
command += pattern;
command += conditions;
TGridResult *res = gGrid->Command(command);
fMergingJDL->AddToInputSandbox(Form("LF:%s/%s", workdir.Data(), obj->GetName()));
}
}
+ const char *comment = "List of output files and archives";
if (fOutputArchive.Length()) {
TString outputArchive = fOutputArchive;
if (!fRegisterExcludes.IsNull()) {
arr = outputArchive.Tokenize(" ");
TIter next(arr);
Bool_t first = kTRUE;
- const char *comment = "Files to be archived";
- const char *comment1 = comment;
while ((os=(TObjString*)next())) {
- if (!first) comment = NULL;
if (!os->GetString().Contains("@") && fCloseSE.Length())
- fGridJDL->AddToOutputArchive(Form("%s@%s",os->GetString().Data(), fCloseSE.Data()), comment);
+ fGridJDL->AddToSet("Output", Form("%s@%s",os->GetString().Data(), fCloseSE.Data()));
else
- fGridJDL->AddToOutputArchive(os->GetString(), comment);
+ fGridJDL->AddToSet("Output", os->GetString());
+ if (first) fGridJDL->AddToSetDescription("Output", comment);
first = kFALSE;
}
delete arr;
files.ReplaceAll(".root", "*.root");
if (mgr->IsCollectThroughput())
- outputArchive += Form("root_archive.zip:%s,*.stat,*%s@disk=%d",files.Data(),mgr->GetFileInfoLog(),fNreplicas);
+ outputArchive += Form("root_archive.zip:%s,*.stat@disk=%d %s@disk=%d",files.Data(),fNreplicas, mgr->GetFileInfoLog(),fNreplicas);
else
outputArchive += Form("root_archive.zip:%s,*.stat@disk=%d",files.Data(),fNreplicas);
} else {
}
arr = outputArchive.Tokenize(" ");
TIter next2(arr);
- comment = comment1;
first = kTRUE;
while ((os=(TObjString*)next2())) {
- if (!first) comment = NULL;
TString currentfile = os->GetString();
if (!currentfile.Contains("@") && fCloseSE.Length())
- fMergingJDL->AddToOutputArchive(Form("%s@%s",currentfile.Data(), fCloseSE.Data()), comment);
+ fMergingJDL->AddToSet("Output", Form("%s@%s",currentfile.Data(), fCloseSE.Data()));
else
- fMergingJDL->AddToOutputArchive(currentfile, comment);
+ fMergingJDL->AddToSet("Output", currentfile);
+ if (first) fMergingJDL->AddToSetDescription("Output", comment);
first = kFALSE;
}
delete arr;
arr = fOutputFiles.Tokenize(",");
TIter next(arr);
Bool_t first = kTRUE;
- const char *comment = "Files to be saved";
while ((os=(TObjString*)next())) {
// Ignore ouputs in jdl that are also in outputarchive
TString sout = os->GetString();
if (fRegisterExcludes.Contains(sout)) continue;
if (!first) comment = NULL;
if (!os->GetString().Contains("@") && fCloseSE.Length())
- fGridJDL->AddToOutputSandbox(Form("%s@%s",os->GetString().Data(), fCloseSE.Data()), comment);
+ fGridJDL->AddToSet("Output", Form("%s@%s",os->GetString().Data(), fCloseSE.Data()));
else
- fGridJDL->AddToOutputSandbox(os->GetString(), comment);
- first = kFALSE;
+ fGridJDL->AddToSet("Output", os->GetString());
+ if (first) fGridJDL->AddToSetDescription("Output", comment);
if (fMergeExcludes.Contains(sout)) continue;
if (!os->GetString().Contains("@") && fCloseSE.Length())
- fMergingJDL->AddToOutputSandbox(Form("%s@%s",os->GetString().Data(), fCloseSE.Data()), comment);
+ fMergingJDL->AddToSet("Output", Form("%s@%s",os->GetString().Data(), fCloseSE.Data()));
else
- fMergingJDL->AddToOutputSandbox(os->GetString(), comment);
+ fMergingJDL->AddToSet("Output", os->GetString());
+ if (first) fMergingJDL->AddToSetDescription("Output", comment);
+ first = kFALSE;
}
delete arr;
fGridJDL->SetPrice((UInt_t)fPrice, "AliEn price for this job");
}
TString sjdl2 = fMergingJDL->Generate();
Int_t index, index1;
- sjdl.ReplaceAll("\"LF:", "\n \"LF:");
+ sjdl.ReplaceAll("\",\"", "\",\n \"");
sjdl.ReplaceAll("(member", "\n (member");
sjdl.ReplaceAll("\",\"VO_", "\",\n \"VO_");
sjdl.ReplaceAll("{", "{\n ");
sjdl.ReplaceAll("{\n \n", "{\n");
sjdl.ReplaceAll("\n\n", "\n");
sjdl.ReplaceAll("OutputDirectory", "OutputDir");
- sjdl1.ReplaceAll("\"LF:", "\n \"LF:");
+ sjdl1.ReplaceAll("\",\"", "\",\n \"");
sjdl1.ReplaceAll("(member", "\n (member");
sjdl1.ReplaceAll("\",\"VO_", "\",\n \"VO_");
sjdl1.ReplaceAll("{", "{\n ");
sjdl1.ReplaceAll("{\n \n", "{\n");
sjdl1.ReplaceAll("\n\n", "\n");
sjdl1.ReplaceAll("OutputDirectory", "OutputDir");
- sjdl2.ReplaceAll("\"LF:", "\n \"LF:");
+ sjdl2.ReplaceAll("\",\"", "\",\n \"");
sjdl2.ReplaceAll("(member", "\n (member");
sjdl2.ReplaceAll("\",\"VO_", "\",\n \"VO_");
sjdl2.ReplaceAll("{", "{\n ");
TString streeName(treeName);
if (IsUseMCchain()) streeName = "TE";
TChain *chain = new TChain(streeName);
- TChain *chainFriend = 0;
- if (!fFriendChainName.IsNull()) chainFriend = new TChain(streeName);
+ TList *friends = new TList();
+ TChain *cfriend = 0;
+ if (!fFriendChainName.IsNull()) {
+ TObjArray *list = fFriendChainName.Tokenize(" ");
+ TIter next(list);
+ TObjString *str;
+ while((str=(TObjString*)next())) {
+ cfriend = new TChain(streeName, str->GetName());
+ friends->Add(cfriend);
+ chain->AddFriend(cfriend);
+ }
+ delete list;
+ }
+ TString bpath;
+ TIter nextfriend(friends);
while (in.good())
{
in >> line;
if (!fFriendChainName.IsNull()) {
if (esdFile.Index("#") > -1)
esdFile.Remove(esdFile.Index("#"));
- esdFile = gSystem->DirName(esdFile);
- esdFile += "/" + fFriendChainName;
- file = TFile::Open(esdFile);
- if (file && !file->IsZombie()) {
- file->Close();
- chainFriend->Add(esdFile);
- } else {
- Fatal("GetChainForTestMode", "Cannot open friend file: %s", esdFile.Data());
- return 0;
- }
+ bpath = gSystem->DirName(esdFile);
+ bpath += "/";
+ TString fileFriend;
+ nextfriend.Reset();
+ while ((cfriend=(TChain*)nextfriend())) {
+ fileFriend = bpath;
+ fileFriend += cfriend->GetTitle();
+ file = TFile::Open(fileFriend);
+ if (file && !file->IsZombie()) {
+ file->Close();
+ cfriend->Add(fileFriend);
+ } else {
+ Fatal("GetChainForTestMode", "Cannot open friend file: %s", fileFriend.Data());
+ return 0;
+ }
+ }
}
} else {
Error("GetChainforTestMode", "Skipping un-openable file: %s", esdFile.Data());
if (!chain->GetListOfFiles()->GetEntries()) {
Error("GetChainForTestMode", "No file from %s could be opened", fFileForTestMode.Data());
delete chain;
- delete chainFriend;
+ friends->Delete();
+ delete friends;
return NULL;
}
-// chain->ls();
- if (!fFriendChainName.IsNull()) chain->AddFriend(chainFriend);
return chain;
}
\n***** To disable, use: plugin->SetOverwriteMode(kFALSE);\n");
}
printf("= Copy files to grid: __________________________ %s\n", (IsUseCopy())?"YES":"NO");
- printf("= Check if files can be copied to grid: ________ %s\n", (IsCheckCopy())?"YES":"NO");
+ printf("= Check if files can be copied to grid: ________ %s\n", (IsCheckCopy())?"YES":"NO:Print");
printf("= Production mode:______________________________ %d\n", fProductionMode);
printf("= Version of API requested: ____________________ %s\n", fAPIVersion.Data());
printf("= Version of ROOT requested: ___________________ %s\n", fROOTVersion.Data());
printf("= User running the plugin: _____________________ %s\n", fUser.Data());
printf("= Grid workdir relative to user $HOME: _________ %s\n", fGridWorkingDir.Data());
printf("= Grid output directory relative to workdir: ___ %s\n", fGridOutputDir.Data());
- printf("= Data base directory path requested: __________ %s\n", fGridDataDir.Data());
- printf("= Data search pattern: _________________________ %s\n", fDataPattern.Data());
+ TString basedatadir = fGridDataDir;
+ TString pattern = fDataPattern;
+ pattern.Strip();
+ Int_t ind = pattern.Index(" ");
+ if (ind>=0) {
+ basedatadir += "/%run%/";
+ basedatadir += pattern(0, ind);
+ pattern = pattern(ind+1, pattern.Length());
+ }
+ printf("= Data base directory path requested: __________ %s\n", basedatadir.Data());
+ printf("= Data search pattern: _________________________ %s\n", pattern.Data());
printf("= Input data format: ___________________________ %s\n", fInputFormat.Data());
if (fRunNumbers.Length())
printf("= Run numbers to be processed: _________________ %s\n", fRunNumbers.Data());
fOverwriteMode = 1;
}
+//______________________________________________________________________________
+void AliAnalysisAlien::SetFriendChainName(const char *name, const char *libnames)
+{
+ // Set file name for the chain of friends and optionally additional libs to be loaded.
+ // Libs should be separated by blancs.
+ fFriendChainName = name;
+ fFriendChainName.ReplaceAll(",", " ");
+ fFriendChainName.Strip();
+ fFriendChainName.ReplaceAll(" ", " ");
+
+ fFriendLibs = libnames;
+ if (fFriendLibs.Length()) {
+ if(!fFriendLibs.Contains(".so"))
+ Fatal("SetFriendChainName()", "You should provide explicit library names (with extension)");
+ fFriendLibs.ReplaceAll(",", " ");
+ fFriendLibs.Strip();
+ fFriendLibs.ReplaceAll(" ", " ");
+ }
+}
+
//______________________________________________________________________________
void AliAnalysisAlien::SetRootVersionForProof(const char *version)
{
// Obsolete method. Use SetROOTVersion instead
Warning("SetRootVersionForProof", "Obsolete. Use SetROOTVersion instead");
- SetROOTVersion(version);
+ if (fROOTVersion.IsNull()) SetROOTVersion(version);
+ else Error("SetRootVersionForProof", "ROOT version already set to %s", fROOTVersion.Data());
}
//______________________________________________________________________________
if (!alirootMode.IsNull()) extraLibs = "ANALYSIS:OADB:ANALYSISalice";
// Parse the extra libs for .so
if (fAdditionalLibs.Length()) {
- TObjArray *list = fAdditionalLibs.Tokenize(" ");
+ TString additionalLibs = fAdditionalLibs;
+ additionalLibs.Strip();
+ if (additionalLibs.Length() && fFriendLibs.Length())
+ additionalLibs += " ";
+ additionalLibs += fFriendLibs;
+ TObjArray *list = additionalLibs.Tokenize(" ");
TIter next(list);
TObjString *str;
while((str=(TObjString*)next())) {
}
if (list) delete list;
}
- if (!extraLibs.IsNull()) {
- Info("StartAnalysis", "Adding extra libs: %s",extraLibs.Data());
- optionsList.Add(new TNamed("ALIROOT_EXTRA_LIBS",extraLibs.Data()));
- }
+ if (!extraLibs.IsNull()) {
+ Info("StartAnalysis", "Adding extra libs: %s",extraLibs.Data());
+ optionsList.Add(new TNamed("ALIROOT_EXTRA_LIBS",extraLibs.Data()));
+ }
// Check extra includes
if (!fIncludePath.IsNull()) {
TString includePath = fIncludePath;
// Compose the output archive.
fOutputArchive = "log_archive.zip:std*@disk=1 ";
if (mgr->IsCollectThroughput())
- fOutputArchive += Form("root_archive.zip:%s,*.stat,*%s@disk=%d",fOutputFiles.Data(),mgr->GetFileInfoLog(),fNreplicas);
+ fOutputArchive += Form("root_archive.zip:%s,*.stat@disk=%d %s@disk=%d",fOutputFiles.Data(),fNreplicas, mgr->GetFileInfoLog(),fNreplicas);
else
fOutputArchive += Form("root_archive.zip:%s,*.stat@disk=%d",fOutputFiles.Data(),fNreplicas);
}
out << " printf(\"Include path: %s\\n\", gSystem->GetIncludePath());" << endl << endl;
if (fAdditionalLibs.Length()) {
out << "// Add aditional AliRoot libraries" << endl;
- TObjArray *list = fAdditionalLibs.Tokenize(" ");
+ TString additionalLibs = fAdditionalLibs;
+ additionalLibs.Strip();
+ if (additionalLibs.Length() && fFriendLibs.Length())
+ additionalLibs += " ";
+ additionalLibs += fFriendLibs;
+ TObjArray *list = additionalLibs.Tokenize(" ");
TIter next(list);
TObjString *str;
while((str=(TObjString*)next())) {
out << " plugin->SetFileForTestMode(\"" << fFileForTestMode << "\");" << endl;
out << " plugin->SetNtestFiles(" << fNtestFiles << ");" << endl;
if (!fFriendChainName.IsNull())
- out << " plugin->SetFriendChainName(\"" << fFriendChainName << "\");" << endl;
+ out << " plugin->SetFriendChainName(\"" << fFriendChainName << "\",\"" << fFriendLibs << "\");" << endl;
if (IsUseMCchain())
out << " plugin->SetUseMCchain();" << endl;
out << " mgr->SetGridHandler(plugin);" << endl;
if (IsUseMCchain()) {
out << " TString treename = \"TE\";" << endl;
} else {
- out << " TString treename = type;" << endl;
- out << " treename.ToLower();" << endl;
- out << " treename += \"Tree\";" << endl;
+ if (!fTreeName.IsNull()) {
+ out << " TString treename = \"" << fTreeName << "\";" << endl;
+ } else {
+ out << " TString treename = type;" << endl;
+ out << " treename.ToLower();" << endl;
+ out << " treename += \"Tree\";" << endl;
+ }
}
out << " printf(\"***************************************\\n\");" << endl;
out << " printf(\" Getting chain of trees %s\\n\", treename.Data());" << endl;
out << " }" << endl;
out << " AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();" << endl;
out << " TChain *chain = new TChain(treename);" << endl;
- if(fFriendChainName!="") {
- out << " TChain *chainFriend = new TChain(treename);" << endl;
+ if(!fFriendChainName.IsNull()) {
+ out << " TList *friends = new TList();" << endl;
+ out << " TIter nextfriend(friends);" << endl;
+ out << " TChain *cfriend = 0;" << endl;
+ TObjArray *list = fFriendChainName.Tokenize(" ");
+ TIter next(list);
+ TObjString *str;
+ while((str=(TObjString*)next())) {
+ out << " cfriend = new TChain(treename, \"" << str->GetName() << "\");" << endl;
+ out << " friends->Add(cfriend);" << endl;
+ out << " chain->AddFriend(cfriend);" << endl;
+ }
+ delete list;
+// out << " TChain *chainFriend = new TChain(treename);" << endl;
}
out << " coll->Reset();" << endl;
out << " while (coll->Next()) {" << endl;
out << " }" << endl;
out << " }" << endl;
out << " chain->Add(filename);" << endl;
- if(fFriendChainName!="") {
- out << " TString fileFriend=coll->GetTURL(\"\");" << endl;
- out << " if (fileFriend.Index(\"#\") > -1) fileFriend.Remove(fileFriend.Index(\"#\"));" << endl;
- out << " fileFriend = gSystem->DirName(fileFriend);" << endl;
- out << " fileFriend += \"/\";" << endl;
- out << " fileFriend += \"" << fFriendChainName << "\";";
- out << " TFile *file = TFile::Open(fileFriend);" << endl;
- out << " if (file) {" << endl;
- out << " file->Close();" << endl;
- out << " chainFriend->Add(fileFriend.Data());" << endl;
- out << " } else {" << endl;
- out << " ::Fatal(\"CreateChain\", \"Cannot open friend file: %s\", fileFriend.Data());" << endl;
- out << " return 0;" << endl;
+ if(!fFriendChainName.IsNull()) {
+ out << " TString bpath=coll->GetTURL(\"\");" << endl;
+ out << " if (bpath.Index(\"#\") > -1) bpath.Remove(bpath.Index(\"#\"));" << endl;
+ out << " bpath = gSystem->DirName(bpath);" << endl;
+ out << " bpath += \"/\";" << endl;
+ out << " TString fileFriend;" << endl;
+ out << " nextfriend.Reset();" << endl;
+ out << " while ((cfriend=(TChain*)nextfriend())) {" << endl;
+ out << " fileFriend = bpath;" << endl;
+ out << " fileFriend += cfriend->GetTitle();" << endl;
+ out << " TFile *file = TFile::Open(fileFriend);" << endl;
+ out << " if (file) {" << endl;
+ out << " file->Close();" << endl;
+ out << " cfriend->Add(fileFriend.Data());" << endl;
+ out << " } else {" << endl;
+ out << " ::Fatal(\"CreateChain\", \"Cannot open friend file: %s\", fileFriend.Data());" << endl;
+ out << " return 0;" << endl;
+ out << " }" << endl;
out << " }" << endl;
}
out << " }" << endl;
out << " ::Error(\"CreateChain\", \"No tree found from collection %s\", xmlfile);" << endl;
out << " return NULL;" << endl;
out << " }" << endl;
- if(fFriendChainName!="") {
- out << " chain->AddFriend(chainFriend);" << endl;
- }
out << " return chain;" << endl;
out << "}" << endl << endl;
}
out << " printf(\"Include path: %s\\n\", gSystem->GetIncludePath());" << endl << endl;
if (fAdditionalLibs.Length()) {
out << "// Add aditional AliRoot libraries" << endl;
- TObjArray *list = fAdditionalLibs.Tokenize(" ");
+ TString additionalLibs = fAdditionalLibs;
+ additionalLibs.Strip();
+ if (additionalLibs.Length() && fFriendLibs.Length())
+ additionalLibs += " ";
+ additionalLibs += fFriendLibs;
+ TObjArray *list = additionalLibs.Tokenize(" ");
TIter next(list);
TObjString *str;
while((str=(TObjString*)next())) {