fCommonInput(NULL),
fCommonOutput(NULL),
fSelector(NULL),
- fGridHandler(NULL)
+ fGridHandler(NULL),
+ fExtraFiles("")
{
// Default constructor.
fgAnalysisManager = this;
fCommonInput(NULL),
fCommonOutput(NULL),
fSelector(NULL),
- fGridHandler(NULL)
+ fGridHandler(NULL),
+ fExtraFiles()
{
// Copy constructor.
fTasks = new TObjArray(*other.fTasks);
fCommonOutput = NULL;
fSelector = NULL;
fGridHandler = NULL;
+ fExtraFiles = other.fExtraFiles;
fgAnalysisManager = this;
}
return *this;
// 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
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;
+}
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);
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;}
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,
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