]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisDataContainer.cxx
added this pointer to special constructor, first version of esd to flat conversion...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisDataContainer.cxx
index 6e5a1d50d421d9a85155fed755090fd158726ec5..8784f502e51cc591e1c5c0f65f94f1a9a0c0ad61 100644 (file)
@@ -46,6 +46,7 @@
 #include <TMethodCall.h>
 
 #include <TClass.h>
+#include <TSystem.h>
 #include <TFile.h>
 #include <TTree.h>
 #include <TH1.h>
 #include "AliAnalysisDataSlot.h"
 #include "AliAnalysisTask.h"
 
+using std::endl;
+using std::cout;
+using std::ios;
+using std::setiosflags;
+using std::setprecision;
 ClassImp(AliAnalysisDataContainer)
 
 //______________________________________________________________________________
@@ -275,21 +281,26 @@ void AliAnalysisDataContainer::PrintContainer(Option_t *option, Int_t indent) co
    for (Int_t i=0; i<indent; i++) ind += " ";
    TString opt(option);
    opt.ToLower();
+   TString ctype = "Container";
+   if (IsExchange()) ctype = "Exchange container";
    Bool_t dep = (opt.Contains("dep"))?kTRUE:kFALSE;
    if (!dep) {
-      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= No data producer",ind.Data());
-      printf("%s = Consumer tasks: ", ind.Data());
-      if (!fConsumers || !fConsumers->GetEntriesFast()) printf("-none-\n");
-      else printf("\n");
+      if (IsPostEventLoop()) printf("%s%s: %s     DATA TYPE: %s POST_LOOP task\n", ind.Data(), ctype.Data(), GetName(), GetTitle());
+      else printf("%s%s: %s     DATA TYPE: %s\n", ind.Data(), ctype.Data(), GetName(), GetTitle());
+      if (!fProducer) 
+//         printf("%s = Data producer: task %s\n",ind.Data(),fProducer->GetName());
+//      else
+         printf("%s= Not connected to a data producer\n",ind.Data());
+      if (fConsumers && fConsumers->GetEntriesFast())
+         printf("%s = Client tasks indented below:\n", ind.Data());
    }
-   if (fFolderName.Length())
-     printf("Filename: %s  folder: %s\n", fFileName.Data(), fFolderName.Data());
-   else
-     printf("Filename: %s\n", fFileName.Data());
+   if (!IsExchange()) {
+      if (!fFolderName.IsNull())
+        printf("%s = Filename: %s  folder: %s\n", ind.Data(),fFileName.Data(), fFolderName.Data());
+      else
+        if (!fFileName.IsNull()) printf("%s = Filename: %s\n", ind.Data(),fFileName.Data());
+   }     
+   ((AliAnalysisDataContainer*)this)->SetTouched(kTRUE);  
    TIter next(fConsumers);
    AliAnalysisTask *task;
    while ((task=(AliAnalysisTask*)next())) task->PrintTask(option, indent+3);
@@ -401,7 +412,7 @@ AliAnalysisDataWrapper *AliAnalysisDataContainer::ExportData() const
       return pack;
    } 
    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-   if (mgr->GetDebugLevel() > 1) printf("   ExportData: Wrapping data %s for container %s\n", fData->GetName(),GetName());
+   if (mgr && mgr->GetDebugLevel() > 1) printf("   ExportData: Wrapping data %s for container %s\n", fData->GetName(),GetName());
    pack = new AliAnalysisDataWrapper(fData);
    pack->SetName(fName.Data());
    return pack;
@@ -418,7 +429,7 @@ void AliAnalysisDataContainer::ImportData(AliAnalysisDataWrapper *pack)
          return;
       }   
       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-      if (mgr->GetDebugLevel() > 1) printf("   ImportData: Unwrapping data %s for container %s\n", fData->GetName(),GetName());
+      if (mgr && mgr->GetDebugLevel() > 1) printf("   ImportData: Unwrapping data %s for container %s\n", fData->GetName(),GetName());
       fDataReady = kTRUE;
       // Imported wrappers do not own data anymore (AG 13-11-07)
       pack->SetDeleteData(kFALSE);
@@ -493,3 +504,140 @@ Long64_t AliAnalysisDataWrapper::Merge(TCollection *list)
 
    return count+1;
 }
+
+ClassImp(AliAnalysisFileDescriptor)
+
+//______________________________________________________________________________
+AliAnalysisFileDescriptor::AliAnalysisFileDescriptor()
+                          :TObject(), fLfn(), fGUID(), fUrl(), fPfn(), fSE(),
+                           fIsArchive(kFALSE), fImage(0), fNreplicas(0), 
+                           fStartBytes(0), fReadBytes(0), fSize(0), fOpenedAt(0), 
+                           fOpenTime(0.), fProcessingTime(0.), fThroughput(0.), fTimer()
+{
+// I/O constructor
+}
+
+//______________________________________________________________________________
+AliAnalysisFileDescriptor::AliAnalysisFileDescriptor(const TFile *file)
+                          :TObject(), fLfn(), fGUID(), fUrl(), fPfn(), fSE(),
+                           fIsArchive(kFALSE), fImage(0), fNreplicas(0), 
+                           fStartBytes(0), fReadBytes(0), fSize(0), fOpenedAt(0), 
+                           fOpenTime(0.), fProcessingTime(0.), fThroughput(0.), fTimer()
+{
+// Normal constructor
+   if (file->InheritsFrom("TAlienFile")) {
+      fLfn =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetLfn();", file));
+      fGUID =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetGUID();", file));
+      fUrl =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetUrl();", file));
+      fPfn =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetPfn();", file));
+      fSE = (const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetSE();", file));
+      fImage = (Int_t)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetImage();", file));
+      fNreplicas = (Int_t)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetNreplicas();", file));
+      fOpenedAt = gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetOpenTime();", file));
+      gROOT->ProcessLine(Form("((AliAnalysisFileDescriptor*)%p)->SetOpenTime(((TAlienFile*)%p)->GetElapsed());", this, file));
+   } else {
+      fLfn = file->GetName();
+      fPfn = file->GetName();
+      fUrl = file->GetName();
+      fSE = "local";
+      if (!fPfn.BeginsWith("/")) fPfn.Prepend(Form("%s/",gSystem->WorkingDirectory()));
+      fOpenedAt = time(0);
+   }
+   fStartBytes = TFile::GetFileBytesRead();
+   fIsArchive = file->IsArchive();
+   fSize = file->GetSize();
+}
+
+//______________________________________________________________________________
+AliAnalysisFileDescriptor::AliAnalysisFileDescriptor(const AliAnalysisFileDescriptor &other)
+                          :TObject(other), fLfn(other.fLfn), fGUID(other.fGUID),
+                           fUrl(other.fUrl), fPfn(other.fPfn), fSE(other.fSE),
+                           fIsArchive(other.fIsArchive), fImage(other.fImage),
+                           fNreplicas(other.fNreplicas), fStartBytes(other.fStartBytes), fReadBytes(other.fReadBytes),
+                           fSize(other.fSize), fOpenedAt(other.fOpenedAt), fOpenTime(other.fOpenTime),
+                           fProcessingTime(other.fProcessingTime), fThroughput(other.fThroughput), fTimer()
+{
+// CC
+}
+
+//______________________________________________________________________________
+AliAnalysisFileDescriptor &AliAnalysisFileDescriptor::operator=(const AliAnalysisFileDescriptor &other)
+{
+// Assignment.
+   if (&other == this) return *this;
+   TObject::operator=(other);
+   fLfn       = other.fLfn;
+   fGUID      = other.fGUID;
+   fUrl       = other.fUrl; 
+   fPfn       = other.fPfn;
+   fSE        = other.fSE;
+   fIsArchive = other.fIsArchive;
+   fImage     = other.fImage;
+   fNreplicas = other.fNreplicas;
+   fStartBytes = other.fStartBytes;;
+   fReadBytes = other.fReadBytes;
+   fSize      = other.fSize;
+   fOpenedAt  = other.fOpenedAt;
+   fOpenTime  = other.fOpenTime;
+   fProcessingTime = other.fProcessingTime;
+   fThroughput = other.fThroughput;
+   return *this;
+}
+
+//______________________________________________________________________________
+AliAnalysisFileDescriptor::~AliAnalysisFileDescriptor()
+{
+// Destructor
+}
+
+//______________________________________________________________________________
+void AliAnalysisFileDescriptor::Done()
+{
+// Must be called at the end of processing, providing file->GetBytesRead() as argument.
+   fTimer.Stop();
+   const Double_t megabyte = 1048576.;
+//   Long64_t stampnow = time(0);
+   fReadBytes = TFile::GetFileBytesRead()-fStartBytes;
+//   fProcessingTime = stampnow-fOpenedAt;
+   fProcessingTime = fTimer.RealTime();
+   Double_t readsize = fReadBytes/megabyte;
+   fThroughput = readsize/fProcessingTime;
+}   
+
+//______________________________________________________________________________
+void AliAnalysisFileDescriptor::Print(Option_t*) const
+{
+// Print info about the file descriptor
+   const Double_t megabyte = 1048576.;
+   printf("===== Logical file name: %s =====\n", fLfn.Data());
+   printf("      Pfn: %s\n", fPfn.Data());
+   printf("      url: %s\n", fUrl.Data());
+   printf("      access time: %lld from SE: %s  image %d/%d\n", fOpenedAt, fSE.Data(), fImage, fNreplicas);
+   printf("      open time: %g [sec]\n", fOpenTime);
+   printf("      file size: %g [MB],  read size: %g [MB]\n", fSize/megabyte, fReadBytes/megabyte);
+   printf("      processing time [sec]: %g\n", fProcessingTime);
+   printf("      average throughput: %g [MB/sec]\n", fThroughput);
+}
+
+//______________________________________________________________________________
+void AliAnalysisFileDescriptor::SavePrimitive(std::ostream &out, Option_t *)
+{
+// Stream info to file
+   const Double_t megabyte = 1048576.;
+   out << "#################################################################" << endl;
+   out << "pfn          " << fPfn.Data() << endl;
+   out << "url          " << fUrl.Data() << endl;
+   out << "se           " << fSE.Data() << endl;
+   out << "image        " << fImage << endl;
+   out << "nreplicas    " << fNreplicas << endl;
+   out << "openstamp    " << fOpenedAt << endl;
+   std::ios_base::fmtflags original_flags = out.flags();
+   out << setiosflags(std::ios::fixed) << std::setprecision(3);
+   out << "opentime     " << fOpenTime << endl;
+   out << "runtime      " << fProcessingTime << endl;
+   out << "filesize     " << fSize/megabyte << endl;
+   out << "readsize     " << fReadBytes/megabyte << endl;
+   out << "throughput   " << fThroughput << endl;
+   out.flags(original_flags);
+}
+