]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added AliAnalysisAlien::EnablePackage(const char *package) to be able to work with...
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Nov 2008 13:18:27 +0000 (13:18 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Nov 2008 13:18:27 +0000 (13:18 +0000)
(M. Gheata)

ANALYSIS/AliAnalysisAlien.cxx
ANALYSIS/AliAnalysisAlien.h
ANALYSIS/AliAnalysisGrid.h

index c1f298fdb6c5d37e806ce248897453f82decc0b8..504905fafd8be689f5ef64c608bd1065874a8dc5 100644 (file)
@@ -65,7 +65,8 @@ AliAnalysisAlien::AliAnalysisAlien()
                   fInputFormat(),
                   fDatasetName(),
                   fJDLName(),
-                  fInputFiles(0)
+                  fInputFiles(0),
+                  fPackages(0)
 {
 // Dummy ctor.
    SetDefaults();
@@ -100,7 +101,8 @@ AliAnalysisAlien::AliAnalysisAlien(const char *name)
                   fInputFormat(),
                   fDatasetName(),
                   fJDLName(),
-                  fInputFiles(0)
+                  fInputFiles(0),
+                  fPackages(0)
 {
 // Default ctor.
    SetDefaults();
@@ -135,7 +137,8 @@ AliAnalysisAlien::AliAnalysisAlien(const AliAnalysisAlien& other)
                   fInputFormat(other.fInputFormat),
                   fDatasetName(other.fDatasetName),
                   fJDLName(other.fJDLName),
-                  fInputFiles(0)
+                  fInputFiles(0),
+                  fPackages(0)
 {
 // Copy ctor.
    fGridJDL = (TGridJDL*)gROOT->ProcessLine("new TAlienJDL()");
@@ -146,6 +149,13 @@ AliAnalysisAlien::AliAnalysisAlien(const AliAnalysisAlien& other)
       while ((obj=next())) fInputFiles->Add(new TObjString(obj->GetName()));
       fInputFiles->SetOwner();
    }   
+   if (other.fPackages) {
+      fPackages = new TObjArray();
+      TIter next(other.fPackages);
+      TObject *obj;
+      while ((obj=next())) fPackages->Add(new TObjString(obj->GetName()));
+      fPackages->SetOwner();
+   }   
 }
 
 //______________________________________________________________________________
@@ -154,6 +164,7 @@ AliAnalysisAlien::~AliAnalysisAlien()
 // Destructor.
    if (fGridJDL) delete fGridJDL;
    if (fInputFiles) delete fInputFiles;
+   if (fPackages) delete fPackages;
 }   
 
 //______________________________________________________________________________
@@ -195,6 +206,13 @@ AliAnalysisAlien &AliAnalysisAlien::operator=(const AliAnalysisAlien& other)
          while ((obj=next())) fInputFiles->Add(new TObjString(obj->GetName()));
          fInputFiles->SetOwner();
       }   
+      if (other.fPackages) {
+         fPackages = new TObjArray();
+         TIter next(other.fPackages);
+         TObject *obj;
+         while ((obj=next())) fPackages->Add(new TObjString(obj->GetName()));
+         fPackages->SetOwner();
+      }   
    }
    return *this;
 }
@@ -513,6 +531,12 @@ Bool_t AliAnalysisAlien::CreateJDL()
          }   
          delete arr;   
       }
+      if (fPackages) {
+         TIter next(fPackages);
+         TObject *obj;
+         while ((obj=next()))
+            fGridJDL->AddToInputSandbox(Form("LF:%s/%s", workdir.Data(), obj->GetName()));
+      }
       if (fOutputArchive.Length()) {
          arr = fOutputArchive.Tokenize(" ");
          TIter next(arr);
@@ -602,13 +626,21 @@ Bool_t AliAnalysisAlien::CreateJDL()
          TObjString *os;
          TIter next(arr);
          while ((os=(TObjString*)next())) {
-            Info("CreateJDL", "\n#####   Copying dependency: <%s> to your alien workspace", os->GetString().Data());
             if (os->GetString().Contains(".so")) continue;
+            Info("CreateJDL", "\n#####   Copying dependency: <%s> to your alien workspace", os->GetString().Data());
             if (FileExists(os->GetString())) gGrid->Rm(os->GetString());
             TFile::Cp(Form("file:%s",os->GetString().Data()), Form("alien://%s/%s", workdir.Data(), os->GetString().Data()));
          }   
          delete arr;   
       }
+      if (fPackages) {
+         TIter next(fPackages);
+         TObject *obj;
+         while ((obj=next())) {
+            Info("CreateJDL", "\n#####   Copying dependency: <%s> to your alien workspace", obj->GetName());
+            TFile::Cp(Form("file:%s",obj->GetName()), Form("alien://%s/%s", workdir.Data(), obj->GetName()));
+         }   
+      }      
    } 
    return kTRUE;
 }
@@ -711,6 +743,27 @@ void AliAnalysisAlien::CheckDataType(const char *lfn, Bool_t &is_collection, Boo
    Info("CheckDataType", msg.Data());
 }
 
+//______________________________________________________________________________
+void AliAnalysisAlien::EnablePackage(const char *package)
+{
+// Enables a par file supposed to exist in the current directory.
+   TString pkg(package);
+   pkg.ReplaceAll(".par", "");
+   pkg += ".par";
+   if (gSystem->AccessPathName(pkg)) {
+      Error("EnablePackage", "Package %s not found", pkg.Data());
+      return;
+   }
+   if (!TObject::TestBit(AliAnalysisGrid::kUsePars))
+      Info("EnablePackage", "AliEn plugin will use .par packages");
+   TObject::SetBit(AliAnalysisGrid::kUsePars, kTRUE);
+   if (!fPackages) {
+      fPackages = new TObjArray();
+      fPackages->SetOwner();
+   }
+   fPackages->Add(new TObjString(pkg));
+}      
+
 //______________________________________________________________________________
 Bool_t AliAnalysisAlien::IsCollection(const char *lfn) const
 {
@@ -986,14 +1039,8 @@ void AliAnalysisAlien::WriteAnalysisMacro()
       out << "   gSystem->Load(\"libGeom\");" << endl;
       out << "   gSystem->Load(\"libVMC\");" << endl;
       out << "   gSystem->Load(\"libPhysics\");" << endl << endl;
-      out << "// load analysis framework libraries" << endl;
-      out << "   gSystem->Load(\"libSTEERBase\");" << endl;
-      out << "   gSystem->Load(\"libESD\");" << endl;
-      out << "   gSystem->Load(\"libAOD\");" << endl;
-      out << "   gSystem->Load(\"libANALYSIS\");" << endl;
-      out << "   gSystem->Load(\"libANALYSISalice\");" << endl << endl;
-      out << "// add aditional AliRoot libraries below" << endl;
       if (fAdditionalLibs.Length()) {
+         out << "// Add aditional AliRoot libraries" << endl;
          TObjArray *list = fAdditionalLibs.Tokenize(" ");
          TIter next(list);
          TObjString *str;
@@ -1004,8 +1051,22 @@ void AliAnalysisAlien::WriteAnalysisMacro()
          if (list) delete list;
       }
       out << endl;
-      out << "// include path (remove if using par files)" << endl;
-      out << "   gROOT->ProcessLine(\".include $ALICE_ROOT/include\");" << endl << endl;
+      if (!fPackages) {
+         out << "// Load analysis framework libraries" << endl;
+         out << "   gSystem->Load(\"libSTEERBase\");" << endl;
+         out << "   gSystem->Load(\"libESD\");" << endl;
+         out << "   gSystem->Load(\"libAOD\");" << endl;
+         out << "   gSystem->Load(\"libANALYSIS\");" << endl;
+         out << "   gSystem->Load(\"libANALYSISalice\");" << endl << endl;
+         out << "// include path (remove if using par files)" << endl;
+         out << "   gROOT->ProcessLine(\".include $ALICE_ROOT/include\");" << endl << endl;
+      } else {
+         out << "// Compile all par packages" << endl;
+         TIter next(fPackages);
+         TObject *obj;
+         while ((obj=next())) 
+            out << "   if (!SetupPar(\"" << obj->GetName() << "\")) return;" << endl;
+      }   
       out << "// analysis source to be compiled at runtime (if any)" << endl;
       if (fAnalysisSource.Length()) {
          TObjArray *list = fAnalysisSource.Tokenize(" ");
@@ -1100,6 +1161,45 @@ void AliAnalysisAlien::WriteAnalysisMacro()
          out << "   return chain;" << endl;
          out << "}" << endl;
       }   
+      if (fPackages) {
+         out << "Bool_t SetupPar(const char *package) {" << endl;
+         out << "// Compile the package and set it up." << endl;
+         out << "   TString pkgdir = package;" << endl;
+         out << "   pkgdir.ReplaceAll(\".par\",\"\");" << endl;
+         out << "   gSystem->Exec(Form(\"tar xvzf %s\", package));" << endl;
+         out << "   TString cdir = gSystem->WorkingDirectory();" << endl;
+         out << "   gSystem->ChangeDirectory(pkgdir);" << endl;
+         out << "   // Check for BUILD.sh and execute" << endl;
+         out << "   if (!gSystem->AccessPathName(\"PROOF-INF/BUILD.sh\")) {" << endl;
+         out << "      printf(\"*******************************\\n\");" << endl;
+         out << "      printf(\"*** Building PAR archive    ***\\n\");" << endl;
+         out << "      printf(\"*******************************\\n\");" << endl;
+         out << "      if (gSystem->Exec(\"PROOF-INF/BUILD.sh\")) {" << endl;
+         out << "         ::Error(\"SetupPar\", \"Cannot build par archive %s\", package);" << endl;
+         out << "         gSystem->ChangeDirectory(cdir);" << endl;
+         out << "         return kFALSE;" << endl;
+         out << "      }" << endl;
+         out << "   } else {" << endl;
+         out << "      ::Error(\"SetupPar\",\"Cannot access PROOF-INF/BUILD.sh for package %s\", package);" << endl;
+         out << "      gSystem->ChangeDirectory(cdir);" << endl;
+         out << "      return kFALSE;" << endl;
+         out << "   }" << endl;
+         out << "   // Check for SETUP.C and execute" << endl;
+         out << "   if (!gSystem->AccessPathName(\"PROOF-INF/SETUP.C\")) {" << endl;
+         out << "      printf(\"*******************************\\n\");" << endl;
+         out << "      printf(\"***    Setup PAR archive    ***\\n\");" << endl;
+         out << "      printf(\"*******************************\\n\");" << endl;
+         out << "      gROOT->Macro(\"PROOF-INF/SETUP.C\");" << endl;
+         out << "   } else {" << endl;
+         out << "      ::Error(\"SetupPar\",\"Cannot access PROOF-INF/SETUP.C for package %s\", package);" << endl;
+         out << "      gSystem->ChangeDirectory(cdir);" << endl;
+         out << "      return kFALSE;" << endl;
+         out << "   }" << endl;
+         out << "   // Restore original workdir" << endl;
+         out << "   gSystem->ChangeDirectory(cdir);" << endl;
+         out << "   return kTRUE;" << endl;
+         out << "}" << endl;
+      }
       Info("WriteAnalysisMacro", "\n#####   Analysis macro to run on worker nodes <%s> written",fAnalysisMacro.Data());
    }   
    Bool_t copy = kTRUE;
index f06771d86525b55f048cf4bd0faca5660273f33e..157049b778b096209433b07e8333fe9efccec7a9 100644 (file)
@@ -60,6 +60,7 @@ public:
 //Utilities
    virtual Bool_t      CreateDataset(const char *pattern);
    virtual Bool_t      CreateJDL();
+   virtual void        EnablePackage(const char *package);
    virtual Bool_t      MergeOutputs();
    virtual void        StartAnalysis(Long64_t nentries=123456789, Long64_t firstentry=0);
    virtual void        WriteAnalysisFile();
@@ -106,6 +107,7 @@ private:
    TString          fDatasetName;     // Dataset xml file to be created
    TString          fJDLName;         // JDL file to be generated
    TObjArray       *fInputFiles;      // List of input files to be processed by the job
+   TObjArray       *fPackages;        // List of packages to be used
    
    ClassDef(AliAnalysisAlien, 1)   // Class providing some AliEn utilities
 };
index a63fce64811cced905a7e00ba6de88427dd3d424..2ab88063dabf100ac720b18cd6a9b954b583b841 100644 (file)
@@ -27,7 +27,8 @@ enum EPluginRunMode {
    kUseTags  = BIT(18),
    kUseESD   = BIT(19),
    kUseAOD   = BIT(20),
-   kUseMC    = BIT(21)
+   kUseMC    = BIT(21),
+   kUsePars  = BIT(22)
 };   
 
    AliAnalysisGrid() {}
@@ -70,6 +71,7 @@ enum EPluginRunMode {
    static  Bool_t      CreateToken(const char *username=0);
    virtual Bool_t      CreateDataset(const char *pattern)                = 0;
    virtual Bool_t      CreateJDL()                                       = 0;
+   virtual void        EnablePackage(const char *package)                = 0;
    virtual Bool_t      MergeOutputs()                                    = 0;
    virtual void        StartAnalysis(Long64_t nentries=123456789, Long64_t firstentry=0) = 0;
    virtual void        WriteAnalysisFile()                               = 0;