fDropToShell(true),
fGridJobIDs(""),
fGridStages(""),
- fFriendLibs("")
+ fFriendLibs(""),
+ fTreeName()
{
// Dummy ctor.
SetDefaults();
fDropToShell(true),
fGridJobIDs(""),
fGridStages(""),
- fFriendLibs("")
+ fFriendLibs(""),
+ fTreeName()
{
// Default ctor.
SetDefaults();
fDropToShell(other.fDropToShell),
fGridJobIDs(other.fGridJobIDs),
fGridStages(other.fGridStages),
- fFriendLibs(other.fFriendLibs)
+ fFriendLibs(other.fFriendLibs),
+ fTreeName(other.fTreeName)
{
// Copy ctor.
fGridJDL = (TGridJDL*)gROOT->ProcessLine("new TAlienJDL()");
fGridJobIDs = other.fGridJobIDs;
fGridStages = other.fGridStages;
fFriendLibs = other.fFriendLibs;
+ fTreeName = other.fTreeName;
if (other.fInputFiles) {
fInputFiles = new TObjArray();
TIter next(other.fInputFiles);
// 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);
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());
// 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() && !fFriendLibs.Contains(".so")) {
- Fatal("SetFriendChainName()", "You should provide explicit library names (with extension)");
+ if (fFriendLibs.Length()) {
+ if(!fFriendLibs.Contains(".so"))
+ Fatal("SetFriendChainName()", "You should provide explicit library names (with extension)");
+ fFriendLibs.ReplaceAll(",", " ");
+ fFriendLibs.Strip();
+ fFriendLibs.ReplaceAll(" ", " ");
}
}
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;
}