if (!callEnv.IsValid() && !list->IsEmpty()) {
cout << "No merge interface for data stored by " << GetName() << ". Merging not possible !" << endl;
return 1;
- }
-
+ }
+
if (list->IsEmpty()) return 1;
TIter next(list);
- AliAnalysisDataContainer *cont;
+ AliAnalysisDataContainer *cont;
// Make a list where to temporary store the data to be merged.
TList *collectionData = new TList();
Int_t count = 0; // object counter
printf(" ... merging object %s\n", data->GetName());
collectionData->Add(data);
count++;
- }
+ }
callEnv.SetParam((Long_t) collectionData);
callEnv.Execute(fData);
delete collectionData;
-
- return count+1;
+
+ return count+1;
}
//______________________________________________________________________________
opt.ToLower();
Bool_t dep = (opt.Contains("dep"))?kTRUE:kFALSE;
if (!dep) {
- printf("%sContainer: %s type: %s", ind.Data(), GetName(), GetTitle());
+ printf("%sContainer: %s type: %s POST_LOOP=%i", ind.Data(), GetName(), GetTitle(), IsPostEventLoop());
if (fProducer)
printf("%s = Data producer: task %s",ind.Data(),fProducer->GetName());
else
printf("%s = Consumer tasks: ", ind.Data());
if (!fConsumers || !fConsumers->GetEntriesFast()) printf("-none-\n");
else printf("\n");
- }
+ }
+ printf("Filename: %s\n", fFileName.Data());
TIter next(fConsumers);
AliAnalysisTask *task;
while ((task=(AliAnalysisTask*)next())) task->PrintTask(option, indent+3);
}
}
return kTRUE;
- }
+ }
// Check if it is the producer who published the data
if (fProducer->GetPublishedData()==data) {
fData = data;
if (!prod->GetListOfTasks()->FindObject(cons)) prod->Add(cons);
}
}
+
+//______________________________________________________________________________
+AliAnalysisDataWrapper *AliAnalysisDataContainer::ExportData() const
+{
+// Wraps data for sending it through the net.
+ AliAnalysisDataWrapper *pack = 0;
+ if (!fData) return pack;
+ pack = new AliAnalysisDataWrapper(fData);
+ pack->SetName(fName.Data());
+ return pack;
+}
+
+//______________________________________________________________________________
+void AliAnalysisDataContainer::ImportData(AliAnalysisDataWrapper *pack)
+{
+// Unwraps data from a data wrapper.
+ if (pack) {
+ fData = pack->Data();
+ fDataReady = kTRUE;
+ }
+}
+ClassImp (AliAnalysisDataWrapper)
+
+//______________________________________________________________________________
+AliAnalysisDataWrapper &AliAnalysisDataWrapper::operator=(const AliAnalysisDataWrapper &other)
+{
+// Assignment.
+ if (&other != this) {
+ TNamed::operator=(other);
+ fData = other.fData;
+ }
+ return *this;
+}
+
+//______________________________________________________________________________
+Long64_t AliAnalysisDataWrapper::Merge(TCollection *list)
+{
+// Merge a list of containers with this one. Containers in the list must have
+// data of the same type.
+ if (!fData) return 0;
+ if (!list || list->IsEmpty()) return 1;
+
+ printf("Merging %d data wrappers %s\n", list->GetSize()+1, GetName());
+ TMethodCall callEnv;
+ if (fData->InheritsFrom(TSeqCollection::Class())) {
+ TSeqCollection *coll = (TSeqCollection*)fData;
+ if (coll->IsEmpty()) return 0;
+ Int_t nentries = coll->GetEntries();
+ AliAnalysisDataWrapper *top, *crt;
+ TIter next(list);
+ TSeqCollection *collcrt = 0;
+ TList *list1 = 0;
+ // Loop entries of the collection attached to this wrapper.
+ for (Int_t i=0; i<nentries; i++) {
+ list1 = new TList();
+ top = new AliAnalysisDataWrapper(coll->At(i));
+ next.Reset();
+ // Loop wrappers coming in the 'to merge with' list
+ while ((crt=(AliAnalysisDataWrapper*)next())) {
+ collcrt = (TSeqCollection*)crt->Data();
+ list1->Add(new AliAnalysisDataWrapper(collcrt->At(i)));
+ }
+ // Now merge 'top' wrapper with 'list1'. This may go recursively.
+ top->Merge(list1);
+ delete top;
+ list1->Delete();
+ delete list1;
+ }
+ return nentries;
+ }
+
+ if (fData->IsA())
+ callEnv.InitWithPrototype(fData->IsA(), "Merge", "TCollection*");
+ if (!callEnv.IsValid()) {
+ cout << "No merge interface for data stored by " << GetName() << ". Merging not possible !" << endl;
+ return 1;
+ }
+
+ TIter next1(list);
+ AliAnalysisDataWrapper *cont;
+ // Make a list where to temporary store the data to be merged.
+ TList *collectionData = new TList();
+ Int_t count = 0; // object counter
+ while ((cont=(AliAnalysisDataWrapper*)next1())) {
+ TObject *data = cont->Data();
+ if (!data) continue;
+ collectionData->Add(data);
+ count++;
+ }
+ callEnv.SetParam((Long_t) collectionData);
+ callEnv.Execute(fData);
+ delete collectionData;
+
+ return count+1;
+}