]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added support for retrieving and merging dAOD's. The producer task has to call AliAna...
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 30 Apr 2009 13:49:23 +0000 (13:49 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 30 Apr 2009 13:49:23 +0000 (13:49 +0000)
ANALYSIS/AliAnalysisAlien.cxx
ANALYSIS/AliAnalysisManager.cxx
ANALYSIS/AliAnalysisManager.h

index 3d09307ed2ef7245663db07c435a78a824acf1f9..4b6c03af80047deda1f9bd9938642fc691df271e 100644 (file)
@@ -960,6 +960,11 @@ void AliAnalysisAlien::StartAnalysis(Long64_t /*nentries*/, Long64_t /*firstEntr
          if (fOutputFiles.Length()) fOutputFiles += " ";
          fOutputFiles += filename;
       }
+      // Add extra files registered to the analysis manager
+      if (mgr->GetExtraFiles().Length()) {
+         if (fOutputFiles.Length()) fOutputFiles += " ";
+         fOutputFiles += mgr->GetExtraFiles();
+      }   
    }
 //   if (!fCloseSE.Length()) fCloseSE = gSystem->Getenv("alien_CLOSE_SE");
    if (TestBit(AliAnalysisGrid::kOffline)) {
index c4f6d16508c2a84538752e0f7e2e2ec767b5fce5..5b8293722721b0d16c196ed6b7db9b9e4d744735 100644 (file)
@@ -73,7 +73,8 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title)
                     fCommonInput(NULL),
                     fCommonOutput(NULL),
                     fSelector(NULL),
-                    fGridHandler(NULL)
+                    fGridHandler(NULL),
+                    fExtraFiles("")
 {
 // Default constructor.
    fgAnalysisManager = this;
@@ -109,7 +110,8 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other)
                     fCommonInput(NULL),
                     fCommonOutput(NULL),
                     fSelector(NULL),
-                    fGridHandler(NULL)
+                    fGridHandler(NULL),
+                    fExtraFiles()
 {
 // Copy constructor.
    fTasks      = new TObjArray(*other.fTasks);
@@ -147,6 +149,7 @@ AliAnalysisManager& AliAnalysisManager::operator=(const AliAnalysisManager& othe
       fCommonOutput = NULL;
       fSelector   = NULL;
       fGridHandler = NULL;
+      fExtraFiles = other.fExtraFiles;
       fgAnalysisManager = this;
    }
    return *this;
@@ -582,33 +585,15 @@ void AliAnalysisManager::ImportWrappers(TList *source)
          // Copy merged file from PROOF scratch space. 
          // In case of grid the files are already in the current directory.
          if (!inGrid) {
-            char full_path[512];
-            char ch_url[512];
-            TObject *pof =  source->FindObject(filename);
-            if (!pof || !pof->InheritsFrom("TProofOutputFile")) {
-               Error("ImportWrappers", "TProofOutputFile object not found in output list for container %s", cont->GetName());
-               continue;
-            }
-            gROOT->ProcessLine(Form("sprintf((char*)0x%lx, \"%%s\", ((TProofOutputFile*)0x%lx)->GetOutputFileName();)", full_path, pof));
-            gROOT->ProcessLine(Form("sprintf((char*)0x%lx, \"%%s\", gProof->GetUrl();)", ch_url));
-            TString clientUrl(ch_url);
-            TString full_path_str(full_path);
-            if (clientUrl.Contains("localhost")){
-               TObjArray* array = full_path_str.Tokenize ( "//" );
-               TObjString *strobj = ( TObjString *)array->At(1);
-               TObjArray* arrayPort = strobj->GetString().Tokenize ( ":" );
-               TObjString *strobjPort = ( TObjString *) arrayPort->At(1);
-               full_path_str.ReplaceAll(strobj->GetString().Data(),"localhost:PORT");
-               full_path_str.ReplaceAll(":PORT",Form(":%s",strobjPort->GetString().Data()));
-               if (fDebug > 1) Info("ImportWrappers","Using tunnel from %s to %s",full_path_str.Data(),filename);
-            }
-            if (fDebug > 1) 
-               printf("   Copying file %s from PROOF scratch space\n", full_path_str.Data());
-            Bool_t gotit = TFile::Cp(full_path_str.Data(), filename); 
-            if (!gotit) {
-               Error("ImportWrappers", "Could not get file %s from proof scratch space", cont->GetFileName());
-               continue;
+            if (isManagedByHandler && fExtraFiles.Length()) {
+               // Copy extra registered dAOD files.
+               TObjArray *arr = fExtraFiles.Tokenize(" ");
+               TObjString *os;
+               TIter nextfilename(arr);
+               while ((os=(TObjString*)nextfilename())) GetFileFromWrapper(os->GetString(), source);
+               delete arr;
             }
+            if (!GetFileFromWrapper(filename, source)) continue;
          }   
          // Normally we should connect data from the copied file to the
          // corresponding output container, but it is not obvious how to do this
@@ -1304,3 +1289,48 @@ void AliAnalysisManager::SetOutputEventHandler(AliVEventHandler*  handler)
    fCommonOutput->SetSpecialOutput();
    Warning("SetOutputEventHandler", " An automatic output container for the output tree was created.\nPlease use: mgr->GetCommonOutputContainer() to access it.");
 }
+
+//______________________________________________________________________________
+void AliAnalysisManager::RegisterExtraFile(const char *fname)
+{
+// This method is used externally to register output files which are not
+// connected to any output container, so that the manager can properly register,
+// retrieve or merge them when running in distributed mode. The file names are
+// separated by blancs. The method has to be called in MyAnalysisTask::LocalInit().
+   if (fExtraFiles.Length()) fExtraFiles += " ";
+   fExtraFiles += fname;
+}
+
+//______________________________________________________________________________
+Bool_t AliAnalysisManager::GetFileFromWrapper(const char *filename, TList *source)
+{
+// Copy a file from the location specified ina the wrapper with the same name from the source list.
+   char full_path[512];
+   char ch_url[512];
+   TObject *pof =  source->FindObject(filename);
+   if (!pof || !pof->InheritsFrom("TProofOutputFile")) {
+      Error("GetFileFromWrapper", "TProofOutputFile object not found in output list for file %s", filename);
+      return kFALSE;
+   }
+   gROOT->ProcessLine(Form("sprintf((char*)0x%lx, \"%%s\", ((TProofOutputFile*)0x%lx)->GetOutputFileName();)", full_path, pof));
+   gROOT->ProcessLine(Form("sprintf((char*)0x%lx, \"%%s\", gProof->GetUrl();)", ch_url));
+   TString clientUrl(ch_url);
+   TString full_path_str(full_path);
+   if (clientUrl.Contains("localhost")){
+      TObjArray* array = full_path_str.Tokenize ( "//" );
+      TObjString *strobj = ( TObjString *)array->At(1);
+      TObjArray* arrayPort = strobj->GetString().Tokenize ( ":" );
+      TObjString *strobjPort = ( TObjString *) arrayPort->At(1);
+      full_path_str.ReplaceAll(strobj->GetString().Data(),"localhost:PORT");
+      full_path_str.ReplaceAll(":PORT",Form(":%s",strobjPort->GetString().Data()));
+      if (fDebug > 1) Info("GetFileFromWrapper","Using tunnel from %s to %s",full_path_str.Data(),filename);
+      delete arrayPort;
+      delete array;
+   }
+   if (fDebug > 1) 
+      Info("GetFileFromWrapper","Copying file %s from PROOF scratch space", full_path_str.Data());
+   Bool_t gotit = TFile::Cp(full_path_str.Data(), filename); 
+   if (!gotit)
+      Error("GetFileFromWrapper", "Could not get file %s from proof scratch space", filename);
+   return gotit;
+}
index e7c92f5dc59285e670c3a2605460fe8675bba265..32e3d050adbb8f2fde0d96d78313f5866838f0db 100644 (file)
@@ -57,7 +57,7 @@ enum EAliAnalysisFlags {
    AliAnalysisManager(const AliAnalysisManager& other);
    AliAnalysisManager& operator=(const AliAnalysisManager& other);
    
-   // Management
+   // Management methods called by the framework
    void                StartAnalysis(const char *type="local", TTree *tree=0, Long64_t nentries=1234567890, Long64_t firstentry=0);
    void                StartAnalysis(const char *type, const char *dataset, Long64_t nentries=1234567890, Long64_t firstentry=0);
 
@@ -87,6 +87,7 @@ enum EAliAnalysisFlags {
                        GetAnalysisType() const {return fMode;}
    Bool_t              IsUsingDataSet() const  {return TObject::TestBit(kUseDataSet);}
 
+   void                RegisterExtraFile(const char *fname);
    void                SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;}
    void                SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;}
    void                SetDebugLevel(UInt_t level) {fDebug = level;}
@@ -107,6 +108,8 @@ enum EAliAnalysisFlags {
    AliAnalysisDataContainer *GetCommonOutputContainer() {return fCommonOutput;}
    AliAnalysisGrid*    GetGridHandler()         {return fGridHandler;}
    AliVEventPool*      GetEventPool()           {return fEventPool;}
+   Bool_t              GetFileFromWrapper(const char *filename, TList *source);
+   TString             GetExtraFiles() const {return fExtraFiles;}
 
    // Container handling
    AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype, 
@@ -160,6 +163,7 @@ private:
    AliAnalysisDataContainer *fCommonOutput;      // Common output container
    AliAnalysisSelector    *fSelector;            //! Current selector
    AliAnalysisGrid        *fGridHandler;         //! Grid handler plugin
+   TString                 fExtraFiles;          //! List of extra files to be merged
 
    static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
    ClassDef(AliAnalysisManager,4)  // Analysis manager class