From f866cba528965e5b5303811baa205613e183cf52 Mon Sep 17 00:00:00 2001 From: agheata Date: Wed, 7 Apr 2010 08:33:26 +0000 Subject: [PATCH] The merging jobs run also the Terminate method of the tasks after merging. --- ANALYSIS/AliAnalysisAlien.cxx | 49 ++++++++++++++++++++++++----- ANALYSIS/AliAnalysisManager.cxx | 55 +++++++++++++++++---------------- 2 files changed, 70 insertions(+), 34 deletions(-) diff --git a/ANALYSIS/AliAnalysisAlien.cxx b/ANALYSIS/AliAnalysisAlien.cxx index 3863ced5522..89151be710c 100644 --- a/ANALYSIS/AliAnalysisAlien.cxx +++ b/ANALYSIS/AliAnalysisAlien.cxx @@ -894,6 +894,7 @@ Bool_t AliAnalysisAlien::CreateJDL() TString analysisFile = fExecutable; analysisFile.ReplaceAll(".sh", ".root"); fGridJDL->AddToInputSandbox(Form("LF:%s/%s", workdir.Data(),analysisFile.Data())); + fMergingJDL->AddToInputSandbox(Form("LF:%s/%s", workdir.Data(),analysisFile.Data())); if (IsUsingTags() && !gSystem->AccessPathName("ConfigureCuts.C")) fGridJDL->AddToInputSandbox(Form("LF:%s/ConfigureCuts.C", workdir.Data())); if (fAdditionalLibs.Length()) { @@ -1298,7 +1299,7 @@ void AliAnalysisAlien::CheckDataType(const char *lfn, Bool_t &is_collection, Boo } use_tags = slfn.Contains(".tag"); if (slfn.Contains(".root")) msg += " type: root file;"; - else msg += " type: unhnown file;"; + else msg += " type: unknown file;"; if (use_tags) msg += " using_tags: Yes"; else msg += " using_tags: No"; Info("CheckDataType", msg.Data()); @@ -1845,7 +1846,12 @@ void AliAnalysisAlien::SubmitMerging() printf("### Submitting %d merging jobs...\n", ntosubmit); for (Int_t i=0; iBaseName(fInputFiles->At(i)->GetName()); + runOutDir.ReplaceAll(".xml", ""); + if (fOutputToRunNo) + query = Form("submit %s %s", mergeJDLName.Data(), runOutDir.Data()); + else + query = Form("submit %s %03d", mergeJDLName.Data(), i); printf("********* %s\n",query.Data()); TGridResult *res = gGrid->Command(query); if (res) { @@ -2167,7 +2173,7 @@ void AliAnalysisAlien::WriteAnalysisMacro() out << " }" << endl << endl; out << " mgr->PrintStatus();" << endl; if (AliAnalysisManager::GetAnalysisManager()) { - if (AliAnalysisManager::GetAnalysisManager()->GetDebugLevel()>2) { + if (AliAnalysisManager::GetAnalysisManager()->GetDebugLevel()>3) { out << " gEnv->SetValue(\"XNet.Debug\", \"1\");" << endl; } else { out << " AliLog::SetGlobalLogLevel(AliLog::kError);" << endl; @@ -2491,6 +2497,31 @@ void AliAnalysisAlien::WriteMergingMacro() out << " return;" << endl; out << " }" << endl; out << " }" << endl; + out << "// read the analysis manager from file" << endl; + TString analysisFile = fExecutable; + analysisFile.ReplaceAll(".sh", ".root"); + out << " TFile *file = TFile::Open(\"" << analysisFile << "\");" << endl; + out << " if (!file) return;" << endl; + out << " TIter nextkey(file->GetListOfKeys());" << endl; + out << " AliAnalysisManager *mgr = 0;" << endl; + out << " TKey *key;" << endl; + out << " while ((key=(TKey*)nextkey())) {" << endl; + out << " if (!strcmp(key->GetClassName(), \"AliAnalysisManager\"))" << endl; + out << " mgr = (AliAnalysisManager*)file->Get(key->GetName());" << endl; + out << " };" << endl; + out << " if (!mgr) {" << endl; + out << " ::Error(\"" << func.Data() << "\", \"No analysis manager found in file" << analysisFile <<"\");" << endl; + out << " return;" << endl; + out << " }" << endl << endl; + out << " mgr->PrintStatus();" << endl; + if (AliAnalysisManager::GetAnalysisManager()) { + if (AliAnalysisManager::GetAnalysisManager()->GetDebugLevel()>3) { + out << " gEnv->SetValue(\"XNet.Debug\", \"1\");" << endl; + } else { + out << " AliLog::SetGlobalLogLevel(AliLog::kError);" << endl; + } + } + out << " mgr->StartAnalysis(\"gridterminate\");" << endl; out << "}" << endl << endl; if (hasANALYSISalice) { out <<"//________________________________________________________________________________" << endl; @@ -2826,11 +2857,13 @@ void AliAnalysisAlien::WriteValidationScript(Bool_t merge) out << "fi" << endl; } delete arr; - out << "if ! [ -f outputs_valid ] ; then" << endl; - out << " error=1" << endl; - out << " echo \"Output files were not validated by the analysis manager\" >> stdout" << endl; - out << " echo \"Output files were not validated by the analysis manager\" >> stderr" << endl; - out << "fi" << endl; + if (!merge) { + out << "if ! [ -f outputs_valid ] ; then" << endl; + out << " error=1" << endl; + out << " echo \"Output files were not validated by the analysis manager\" >> stdout" << endl; + out << " echo \"Output files were not validated by the analysis manager\" >> stderr" << endl; + out << "fi" << endl; + } out << "if [ $error = 0 ] ; then" << endl; out << " echo \"* ---------------- Job Validated ------------------*\"" << out_stream << endl; diff --git a/ANALYSIS/AliAnalysisManager.cxx b/ANALYSIS/AliAnalysisManager.cxx index 3e026490701..5ffbd1e8ba0 100644 --- a/ANALYSIS/AliAnalysisManager.cxx +++ b/ANALYSIS/AliAnalysisManager.cxx @@ -1283,33 +1283,36 @@ Long64_t AliAnalysisManager::StartAnalysis(const char *type, TTree * const tree, else if (anaType.Contains("mix")) fMode = kMixingAnalysis; if (fMode == kGridAnalysis) { - if (!fGridHandler) { - Error("StartAnalysis", "Cannot start grid analysis without a grid handler."); - Info("===", "Add an AliAnalysisAlien object as plugin for this manager and configure it."); - return -1; - } - // Write analysis manager in the analysis file - cout << "===== RUNNING GRID ANALYSIS: " << GetName() << endl; - // run local task configuration - TIter nextTask(fTasks); - AliAnalysisTask *task; - while ((task=(AliAnalysisTask*)nextTask())) { - task->LocalInit(); - } - if (!fGridHandler->StartAnalysis(nentries, firstentry)) { - Info("StartAnalysis", "Grid analysis was stopped and cannot be terminated"); - return -1; - } + if (!anaType.Contains("terminate")) { + if (!fGridHandler) { + Error("StartAnalysis", "Cannot start grid analysis without a grid handler."); + Info("===", "Add an AliAnalysisAlien object as plugin for this manager and configure it."); + return -1; + } + // Write analysis manager in the analysis file + cout << "===== RUNNING GRID ANALYSIS: " << GetName() << endl; + // run local task configuration + TIter nextTask(fTasks); + AliAnalysisTask *task; + while ((task=(AliAnalysisTask*)nextTask())) { + task->LocalInit(); + } + if (!fGridHandler->StartAnalysis(nentries, firstentry)) { + Info("StartAnalysis", "Grid analysis was stopped and cannot be terminated"); + return -1; + } - // Terminate grid analysis - if (fSelector && fSelector->GetStatus() == -1) return -1; - if (fGridHandler->GetRunMode() == AliAnalysisGrid::kOffline) return 0; - cout << "===== MERGING OUTPUTS REGISTERED BY YOUR ANALYSIS JOB: " << GetName() << endl; - if (!fGridHandler->MergeOutputs()) { - // Return if outputs could not be merged or if it alien handler - // was configured for offline mode or local testing. - return 0; - } + // Terminate grid analysis + if (fSelector && fSelector->GetStatus() == -1) return -1; + if (fGridHandler->GetRunMode() == AliAnalysisGrid::kOffline) return 0; + cout << "===== MERGING OUTPUTS REGISTERED BY YOUR ANALYSIS JOB: " << GetName() << endl; + if (!fGridHandler->MergeOutputs()) { + // Return if outputs could not be merged or if it alien handler + // was configured for offline mode or local testing. + return 0; + } + } + cout << "===== TERMINATING GRID ANALYSIS JOB: " << GetName() << endl; ImportWrappers(NULL); Terminate(); return 0; -- 2.43.0