// a personalized JDL, finding and creating a dataset.
//==============================================================================
+#include "AliAnalysisAlien.h"
+
#include "Riostream.h"
#include "TEnv.h"
#include "TBits.h"
#include "AliAnalysisManager.h"
#include "AliVEventHandler.h"
#include "AliAnalysisDataContainer.h"
-#include "AliAnalysisAlien.h"
+#include "AliMultiInputEventHandler.h"
ClassImp(AliAnalysisAlien)
void AliAnalysisAlien::AddRunNumber(const char* run)
{
// Add a run number to the list of runs to be processed.
- if (fRunNumbers.Length()) fRunNumbers += " ";
- fRunNumbers += run;
+ TString runs = run;
+ TObjString *os;
+ TObjArray *arr = runs.Tokenize(" ");
+ TIter next(arr);
+ TString prefix;
+ prefix.Append(fRunPrefix, fRunPrefix.Index("%d"));
+ while ((os=(TObjString*)next())){
+ if (fRunNumbers.Length()) fRunNumbers += " ";
+ fRunNumbers += Form("%s%s", prefix.Data(), os->GetString().Data());
+ }
+ delete arr;
}
//______________________________________________________________________________
TObjString *os;
TIter next(arr);
while ((os=(TObjString*)next())) {
- 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";
return kFALSE;
}
// Get the output path
- if (!fGridOutputDir.Contains("/")) fGridOutputDir = Form("/%s/%s/%s", gGrid->GetHomeDirectory(), fGridWorkingDir.Data(), fGridOutputDir.Data());
+ if (!fGridOutputDir.Contains("/")) fGridOutputDir = Form("%s/%s/%s", gGrid->GetHomeDirectory(), fGridWorkingDir.Data(), fGridOutputDir.Data());
if (!DirectoryExists(fGridOutputDir)) {
Error("MergeOutputs", "Grid output directory %s not found. Terminate() will NOT be executed", fGridOutputDir.Data());
return kFALSE;
}
// Make sure we change the temporary directory
gSystem->Setenv("TMPDIR", gSystem->pwd());
+ // Set temporary compilation directory to current one
+ gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
TObjArray *list = fOutputFiles.Tokenize(",");
TIter next(list);
TObjString *str;
}
if (list) delete list;
}
- if (!extraLibs.IsNull()) 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;
includePath.ReplaceAll(" ",":");
- includePath.ReplaceAll("$ALICE_ROOT","");
- includePath.ReplaceAll("${ALICE_ROOT}","");
+ includePath.ReplaceAll("$ALICE_ROOT/","");
+ includePath.ReplaceAll("${ALICE_ROOT}/","");
includePath.ReplaceAll("-I","");
- includePath.Strip(TString::kTrailing, ':');
+ includePath.Remove(TString::kTrailing, ':');
Info("StartAnalysis", "Adding extra includes: %s",includePath.Data());
optionsList.Add(new TNamed("ALIROOT_EXTRA_INCLUDES",includePath.Data()));
}
return kFALSE;
}
} else {
- if (gROOT->ProcessLine(Form("gProof->EnablePackage(\"VO_ALICE@AliRoot::%s\", (TList*)%p, kTRUE);",
- fAliROOTVersion.Data(), &optionsList))) {
- Error("StartAnalysis", "There was an error trying to enable package VO_ALICE@AliRoot::%s", fAliROOTVersion.Data());
- return kFALSE;
- }
+ if ( ! fAliROOTVersion.IsNull() ) {
+ if (gROOT->ProcessLine(Form("gProof->EnablePackage(\"VO_ALICE@AliRoot::%s\", (TList*)%p, kTRUE);",
+ fAliROOTVersion.Data(), &optionsList))) {
+ Error("StartAnalysis", "There was an error trying to enable package VO_ALICE@AliRoot::%s", fAliROOTVersion.Data());
+ return kFALSE;
+ }
+ }
}
// Enable first par files from fAdditionalLibs
if (!parLibs.IsNull()) {
TString spkg = package->GetName();
spkg.ReplaceAll(".par", "");
gSystem->Exec(TString::Format("rm -rf %s", spkg.Data()));
- if (gROOT->ProcessLine(Form("gProof->UploadPackage(\"%s\");", package->GetName()))) {
+ if (!gROOT->ProcessLine(Form("gProof->UploadPackage(\"%s\");", package->GetName()))) {
if (gROOT->ProcessLine(Form("gProof->EnablePackage(\"%s\",kTRUE);", package->GetName()))) {
Error("StartAnalysis", "There was an error trying to enable package %s", package->GetName());
return kFALSE;
TObjString *str;
while((str=(TObjString*)next())) {
gROOT->ProcessLine(Form("gProof->Load(\"%s+g\", kTRUE);", str->GetName()));
- }
+ }
if (list) delete list;
}
if (testMode) {
Bool_t AliAnalysisAlien::SubmitMerging()
{
// Submit all merging jobs.
- if (!fGridOutputDir.Contains("/")) fGridOutputDir = Form("/%s/%s/%s", gGrid->GetHomeDirectory(), fGridWorkingDir.Data(), fGridOutputDir.Data());
+ if (!fGridOutputDir.Contains("/")) fGridOutputDir = Form("%s/%s/%s", gGrid->GetHomeDirectory(), fGridWorkingDir.Data(), fGridOutputDir.Data());
gGrid->Cd(fGridOutputDir);
TString mergeJDLName = fExecutable;
mergeJDLName.ReplaceAll(".sh", "_merge.jdl");
printf("### Submitting merging job for run <%s>\n", runOutDir.Data());
runOutDir = Form("%s/%s", fGridOutputDir.Data(), runOutDir.Data());
} else {
- // The output directory is the master number in 3 digits format
- printf("### Submitting merging job for master <%03d>\n", i);
- runOutDir = Form("%s/%03d",fGridOutputDir.Data(), i);
+ if (!fRunNumbers.Length() && !fRunRange[0]) {
+ // The output directory is the grid outdir
+ printf("### Submitting merging job for the full output directory %s.\n", fGridOutputDir.Data());
+ runOutDir = fGridOutputDir;
+ } else {
+ // The output directory is the master number in 3 digits format
+ printf("### Submitting merging job for master <%03d>\n", i);
+ runOutDir = Form("%s/%03d",fGridOutputDir.Data(), i);
+ }
}
// Check now the number of merging stages.
TObjArray *list = fOutputFiles.Tokenize(",");
delete list;
Bool_t done = CheckMergedFiles(outputFile, runOutDir, fMaxMergeFiles, mergeJDLName);
if (!done && (i==ntosubmit-1)) return kFALSE;
+ if (!fRunNumbers.Length() && !fRunRange[0]) break;
}
if (!ntosubmit) return kTRUE;
Info("StartAnalysis", "\n #### STARTING AN ALIEN SHELL FOR YOU. You can exit any time or inspect your jobs in a different shell.##########\
if (mgr->GetMCtruthEventHandler()) TObject::SetBit(AliAnalysisGrid::kUseMC);
handler = (TObject*)mgr->GetInputEventHandler();
if (handler) {
- if (handler->InheritsFrom("AliESDInputHandler")) TObject::SetBit(AliAnalysisGrid::kUseESD);
- if (handler->InheritsFrom("AliAODInputHandler")) TObject::SetBit(AliAnalysisGrid::kUseAOD);
+ if (handler->InheritsFrom("AliMultiInputEventHandler")) {
+ AliMultiInputEventHandler *multiIH = (AliMultiInputEventHandler*)handler;
+ if (multiIH->GetFirstInputEventHandler()->InheritsFrom("AliESDInputHandler")) TObject::SetBit(AliAnalysisGrid::kUseESD);
+ if (multiIH->GetFirstInputEventHandler()->InheritsFrom("AliAODInputHandler")) TObject::SetBit(AliAnalysisGrid::kUseAOD);
+ } else {
+ if (handler->InheritsFrom("AliESDInputHandler")) TObject::SetBit(AliAnalysisGrid::kUseESD);
+ if (handler->InheritsFrom("AliAODInputHandler")) TObject::SetBit(AliAnalysisGrid::kUseAOD);
+ }
}
TDirectory *cdir = gDirectory;
TFile *file = TFile::Open(analysisFile, "RECREATE");
// Change temp directory to current one
out << "// Set temporary merging directory to current one" << endl;
out << " gSystem->Setenv(\"TMPDIR\", gSystem->pwd());" << endl << endl;
+ out << "// Set temporary compilation directory to current one" << endl;
+ out << " gSystem->SetBuildDir(gSystem->pwd(), kTRUE);" << endl << endl;
// Reset existing include path
out << "// Reset existing include path and add current directory first in the search" << endl;
out << " gSystem->SetIncludePath(\"-I.\");" << endl;
out << " gSystem->Load(\"libESD\");" << endl;
out << " gSystem->Load(\"libAOD\");" << endl;
}
+ out << " gSystem->Load(\"libOADB\");" << endl;
out << " gSystem->Load(\"libANALYSIS\");" << endl;
out << " gSystem->Load(\"libANALYSISalice\");" << endl;
out << " gSystem->Load(\"libCORRFW\");" << endl << endl;
else out << " if (!" << setupPar << "(\"ESD\")) return;" << endl;
if (!hasAOD) out << " gSystem->Load(\"libAOD\");" << endl;
else out << " if (!" << setupPar << "(\"AOD\")) return;" << endl;
+ out << " gSystem->Load(\"libOADB\");" << endl;
if (!hasANALYSIS) out << " gSystem->Load(\"libANALYSIS\");" << endl;
else out << " if (!" << setupPar << "(\"ANALYSIS\")) return;" << endl;
if (!hasANALYSISalice) out << " gSystem->Load(\"libANALYSISalice\");" << endl;
}
TString mergingMacro = fExecutable;
mergingMacro.ReplaceAll(".sh","_merge.C");
- if (!fGridOutputDir.Contains("/")) fGridOutputDir = Form("/%s/%s/%s", gGrid->GetHomeDirectory(), fGridWorkingDir.Data(), fGridOutputDir.Data());
+ if (!fGridOutputDir.Contains("/")) fGridOutputDir = Form("%s/%s/%s", gGrid->GetHomeDirectory(), fGridWorkingDir.Data(), fGridOutputDir.Data());
if (!TestBit(AliAnalysisGrid::kSubmit)) {
ofstream out;
out.open(mergingMacro.Data(), ios::out);
out << " gSystem->Load(\"libESD\");" << endl;
out << " gSystem->Load(\"libAOD\");" << endl;
}
+ out << " gSystem->Load(\"libOADB\");" << endl;
out << " gSystem->Load(\"libANALYSIS\");" << endl;
out << " gSystem->Load(\"libANALYSISalice\");" << endl;
out << " gSystem->Load(\"libCORRFW\");" << endl << endl;
else out << " if (!" << setupPar << "(\"ESD\")) return;" << endl;
if (!hasAOD) out << " gSystem->Load(\"libAOD\");" << endl;
else out << " if (!" << setupPar << "(\"AOD\")) return;" << endl;
+ out << " gSystem->Load(\"libOADB\");" << endl;
if (!hasANALYSIS) out << " gSystem->Load(\"libANALYSIS\");" << endl;
else out << " if (!" << setupPar << "(\"ANALYSIS\")) return;" << endl;
if (!hasANALYSISalice) out << " gSystem->Load(\"libANALYSISalice\");" << endl;
// Change temp directory to current one
out << "// Set temporary merging directory to current one" << endl;
out << " gSystem->Setenv(\"TMPDIR\", gSystem->pwd());" << endl << endl;
+ out << "// Set temporary compilation directory to current one" << endl;
+ out << " gSystem->SetBuildDir(gSystem->pwd(), kTRUE);" << endl << endl;
out << "// Connect to AliEn" << endl;
out << " if (!TGrid::Connect(\"alien://\")) return;" << endl;
out << " TString outputDir = dir;" << endl;