]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
The merging jobs run also the Terminate method of the tasks after merging.
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 7 Apr 2010 08:33:26 +0000 (08:33 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 7 Apr 2010 08:33:26 +0000 (08:33 +0000)
ANALYSIS/AliAnalysisAlien.cxx
ANALYSIS/AliAnalysisManager.cxx

index 3863ced5522e91b0303a66aab5dc2a96c533627d..89151be710c829960b1c15a4f9226788dd1a6910 100644 (file)
@@ -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; i<ntosubmit; i++) {
       TString query;
-      query = Form("submit %s %03d", mergeJDLName.Data(), i);
+      TString runOutDir = gSystem->BaseName(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;
index 3e0264907010dbf3524ea67e100a04b9184a8ba6..5ffbd1e8ba0e5d57f232f251d1365814d427bfb1 100644 (file)
@@ -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;