]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisDataContainer.cxx
delete the AliSurvey objs after use
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisDataContainer.cxx
index 0aa772a5a2ddc3c195efa43128de4a35b66a8342..982915b2507f764b3d25a08957c1d9bc5a22d106 100644 (file)
@@ -266,7 +266,7 @@ void AliAnalysisDataContainer::PrintContainer(Option_t *option, Int_t indent) co
    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
@@ -354,4 +354,99 @@ void AliAnalysisDataContainer::SetProducer(AliAnalysisTask *prod, Int_t islot)
       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;
+}