]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAnalysisDataContainer.cxx
fee26174d210d025255352635440a379a863f883
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisDataContainer.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17 // Author: Andrei Gheata, 31/05/2006
18
19 //==============================================================================
20 //   AliAnalysysDataContainer - Container of data of arbitrary type deriving
21 //      from TObject used for analysis. A container must be connected to the 
22 //      output data slot of a single analysis task (producer) , but also as 
23 //      input slot for possibly several other tasks (consumers). The connected 
24 //      slots must enforce the same data type as the container (or a derived type).
25 //      A container becomes the owner of the contained data once this was produced.
26 //
27 // Containers should be defined by the analysis module using:
28 //
29 //   AliAnalysisModule::AddContainer(const char *name, TClass *type);
30 //
31 // A container should be connected to a producer:
32
33 //   AliAnalysisModule::ConnectOutput(AliAnalysisTask *task,
34 //                                    AliAnalysisDataContainer *cont)
35 // and to its consumers:
36 //
37 //   AliAnalysisModule::ConnectInput(AliAnalysisTask *task, Int_t islot,
38 //                                   AliAnalysisDataContainer *cont)
39 //
40 // The container will create an implicit connection between the producer task 
41 // and all consumers, which will become sub-tasks of the producer.
42 //
43 //==============================================================================
44
45 #include <Riostream.h>
46 #include <TMethodCall.h>
47
48 #include <TClass.h>
49 #include <TSystem.h>
50 #include <TFile.h>
51 #include <TTree.h>
52 #include <TH1.h>
53 #include <TROOT.h>
54 #include <TStopwatch.h>
55
56 #include "AliAnalysisManager.h"
57 #include "AliAnalysisDataContainer.h"
58 #include "AliAnalysisDataSlot.h"
59 #include "AliAnalysisTask.h"
60
61 using std::endl;
62 using std::cout;
63 ClassImp(AliAnalysisDataContainer)
64
65 //______________________________________________________________________________
66 AliAnalysisDataContainer::AliAnalysisDataContainer() : TNamed(),
67                           fDataReady(kFALSE),
68                           fOwnedData(kFALSE),
69                           fFileName(),
70                           fFolderName(),
71                           fFile(NULL),
72                           fData(NULL),
73                           fType(NULL),
74                           fProducer(NULL),
75                           fConsumers(NULL)
76 {
77 // Dummy ctor.
78 }
79
80 //______________________________________________________________________________
81 AliAnalysisDataContainer::AliAnalysisDataContainer(const char *name, TClass *type)
82                          :TNamed(name,""),
83                           fDataReady(kFALSE),
84                           fOwnedData(kFALSE),
85                           fFileName(),
86                           fFolderName(),
87                           fFile(NULL),
88                           fData(NULL),
89                           fType(type),
90                           fProducer(NULL),
91                           fConsumers(NULL)
92 {
93 // Default constructor.
94    SetTitle(fType->GetName());
95 }
96
97 //______________________________________________________________________________
98 AliAnalysisDataContainer::AliAnalysisDataContainer(const AliAnalysisDataContainer &cont)
99                          :TNamed(cont),
100                           fDataReady(cont.fDataReady),
101                           fOwnedData(kFALSE),
102                           fFileName(cont.fFileName),
103                           fFolderName(cont.fFolderName),
104                           fFile(NULL),
105                           fData(cont.fData),
106                           fType(NULL),
107                           fProducer(cont.fProducer),
108                           fConsumers(NULL)
109 {
110 // Copy ctor.
111    GetType();
112    if (cont.fConsumers) {
113       fConsumers = new TObjArray(2);
114       Int_t ncons = cont.fConsumers->GetEntriesFast();
115       for (Int_t i=0; i<ncons; i++) fConsumers->Add(cont.fConsumers->At(i));
116    }   
117 }
118
119 //______________________________________________________________________________
120 AliAnalysisDataContainer::~AliAnalysisDataContainer()
121 {
122 // Destructor. Deletes data ! (What happens if data is a container ???)
123    if (fData && fOwnedData) delete fData;
124    if (fConsumers) delete fConsumers;
125 }
126
127 //______________________________________________________________________________
128 AliAnalysisDataContainer &AliAnalysisDataContainer::operator=(const AliAnalysisDataContainer &cont)
129 {
130 // Assignment.
131    if (&cont != this) {
132       TNamed::operator=(cont);
133       fDataReady = cont.fDataReady;
134       fOwnedData = kFALSE;
135       fFileName = cont.fFileName;
136       fFolderName = cont.fFolderName;
137       fFile = NULL;
138       fData = cont.fData;
139       GetType();
140       fProducer = cont.fProducer;
141       if (cont.fConsumers) {
142          fConsumers = new TObjArray(2);
143          Int_t ncons = cont.fConsumers->GetEntriesFast();
144          for (Int_t i=0; i<ncons; i++) fConsumers->Add(cont.fConsumers->At(i));
145       }   
146    }   
147    return *this;
148 }      
149
150 //______________________________________________________________________________
151 void AliAnalysisDataContainer::AddConsumer(AliAnalysisTask *consumer, Int_t islot)
152 {
153 // Add a consumer for contained data;
154    AliAnalysisDataSlot *slot = consumer->GetInputSlot(islot);
155    if (!slot || !slot->GetType()) {
156      cout<<"Consumer task "<< consumer->GetName()<<" does not have an input/type #"<<islot<<endl;
157      //AliError(Form("Consumer task %s does not have an input #%i", consumer->GetName(),islot));
158       return;
159    }
160    if (!slot->GetType()->InheritsFrom(GetType())) {
161      cout<<"Data type "<<slot->GetTitle()<<" for input slot "<<islot<<" of task "<<consumer->GetName()<<" does not match container type "<<GetTitle()<<endl;  
162      //AliError(Form("Data type %s for input slot %i of task %s does not match container type %s", slot->GetType()->GetName(),islot,consumer->GetName(),fType->GetName()));
163       return;
164    }   
165
166    if (!fConsumers) fConsumers = new TObjArray(2);   
167    fConsumers->Add(consumer);
168    // Add the consumer task to the list of task of the producer
169    if (fProducer && !fProducer->GetListOfTasks()->FindObject(consumer)) 
170       fProducer->Add(consumer);
171 }      
172
173 //______________________________________________________________________________
174 Bool_t AliAnalysisDataContainer::ClientsExecuted() const
175 {
176 // Check if all client tasks have executed.
177    TIter next(fConsumers);
178    AliAnalysisTask *task;
179    while ((task=(AliAnalysisTask*)next())) {
180       if (!task->HasExecuted()) return kFALSE;
181    }
182    return kTRUE;
183 }   
184
185 //______________________________________________________________________________
186 void AliAnalysisDataContainer::DeleteData()
187 {
188 // Delete data if not needed anymore.
189    if (!fDataReady || !ClientsExecuted()) {
190      cout<<"Data not ready or not all clients of container "<<GetName()<<" executed. Data not deleted."<<endl;
191      //AliWarning(Form("Data not ready or not all clients of container %s executed. Data not deleted.", GetName()));
192       return;
193    }
194    if (!fOwnedData) {
195      cout<<"Data not owned by container "<<GetName()<<". Not deleted."<<endl;
196      //AliWarning(Form("Data not owned by container %s. Not deleted.", GetName()));
197       return;
198    }
199    delete fData;
200    fData = 0;
201    fDataReady = kFALSE;
202 }   
203
204 //______________________________________________________________________________
205 TClass *AliAnalysisDataContainer::GetType() const
206 {
207 // Get class type for this slot.
208    AliAnalysisDataContainer *cont = (AliAnalysisDataContainer*)this;
209    if (!fType) cont->SetType(gROOT->GetClass(fTitle.Data()));
210    if (!fType) printf("AliAnalysisDataContainer: Unknown class: %s\n", GetTitle());
211    return fType;
212 }
213
214 //______________________________________________________________________________
215 void AliAnalysisDataContainer::GetEntry(Long64_t ientry)
216 {
217 // If data is ready and derives from TTree or from TBranch, this will get the
218 // requested entry in memory if not already loaded.
219    if (!fDataReady || !GetType()) return;
220    Bool_t istree = fType->InheritsFrom(TTree::Class());
221    if (istree) {
222       TTree *tree = (TTree*)fData;
223       if (tree->GetReadEntry() != ientry) tree->GetEntry(ientry);
224       return;
225    }   
226    Bool_t isbranch = fType->InheritsFrom(TBranch::Class());
227    if (isbranch) {
228       TBranch *branch = (TBranch*)fData;
229       if (branch->GetReadEntry() != ientry) branch->GetEntry(ientry);
230       return;
231    }   
232 }   
233
234 //______________________________________________________________________________
235 Long64_t AliAnalysisDataContainer::Merge(TCollection *list)
236 {
237 // Merge a list of containers with this one. Containers in the list must have
238 // data of the same type.
239    if (!list || !fData) return 0;
240    printf("Merging %d containers %s\n", list->GetSize()+1, GetName());
241    TMethodCall callEnv;
242    if (fData->IsA())
243       callEnv.InitWithPrototype(fData->IsA(), "Merge", "TCollection*");
244    if (!callEnv.IsValid() && !list->IsEmpty()) {
245       cout << "No merge interface for data stored by " << GetName() << ". Merging not possible !" << endl;
246       return 1;
247    }
248
249    if (list->IsEmpty()) return 1;
250
251    TIter next(list);
252    AliAnalysisDataContainer *cont;
253    // Make a list where to temporary store the data to be merged.
254    TList *collectionData = new TList();
255    Int_t count = 0; // object counter
256    while ((cont=(AliAnalysisDataContainer*)next())) {
257       TObject *data = cont->GetData();
258       if (!data) continue;
259       if (strcmp(cont->GetName(), GetName())) {
260          cout << "Not merging containers with different names !" << endl;
261          continue;
262       }
263       printf(" ... merging object %s\n", data->GetName());
264       collectionData->Add(data);
265       count++;
266    }
267    callEnv.SetParam((Long_t) collectionData);
268    callEnv.Execute(fData);
269    delete collectionData;
270
271    return count+1;
272 }
273
274 //______________________________________________________________________________
275 void AliAnalysisDataContainer::PrintContainer(Option_t *option, Int_t indent) const
276 {
277 // Print info about this container.
278    TString ind;
279    for (Int_t i=0; i<indent; i++) ind += " ";
280    TString opt(option);
281    opt.ToLower();
282    Bool_t dep = (opt.Contains("dep"))?kTRUE:kFALSE;
283    if (!dep) {
284       printf("%sContainer: %s  type: %s POST_LOOP=%i", ind.Data(), GetName(), GetTitle(), IsPostEventLoop());
285       if (fProducer) 
286          printf("%s = Data producer: task %s",ind.Data(),fProducer->GetName());
287       else
288          printf("%s= No data producer",ind.Data());
289       printf("%s = Consumer tasks: ", ind.Data());
290       if (!fConsumers || !fConsumers->GetEntriesFast()) printf("-none-\n");
291       else printf("\n");
292    }
293    if (fFolderName.Length())
294      printf("Filename: %s  folder: %s\n", fFileName.Data(), fFolderName.Data());
295    else
296      printf("Filename: %s\n", fFileName.Data());
297    TIter next(fConsumers);
298    AliAnalysisTask *task;
299    while ((task=(AliAnalysisTask*)next())) task->PrintTask(option, indent+3);
300 }   
301
302 //______________________________________________________________________________
303 Bool_t AliAnalysisDataContainer::SetData(TObject *data, Option_t *)
304 {
305 // Set the data as READY only if it was published by the producer.
306    // If there is no producer declared, this is a top level container.
307    AliAnalysisTask *task;
308    Bool_t init = kFALSE;
309    Int_t i, nc;
310    if (!fProducer) {
311       if (data != fData) init = kTRUE;
312       fData = data;
313       fDataReady = kTRUE;
314       if (fConsumers) {
315          nc = fConsumers->GetEntriesFast();
316          for (i=0; i<nc; i++) {
317             task = (AliAnalysisTask*)fConsumers->At(i);
318             task->CheckNotify(init);
319          }
320       }      
321       return kTRUE;
322    }
323    // Check if it is the producer who published the data     
324    if (fProducer->GetPublishedData()==data) {
325       fData = data;
326       fDataReady = kTRUE;
327       if (fConsumers) {
328          nc = fConsumers->GetEntriesFast();
329          for (i=0; i<nc; i++) {
330             task = (AliAnalysisTask*)fConsumers->At(i);
331             task->CheckNotify();
332          }
333       }      
334       return kTRUE;   
335    } else {
336      // Ignore data posting from other than the producer
337 //      cout<<"Data for container "<<GetName()<<" can be published only by producer task "<<fProducer->GetName()<<endl;
338       //AliWarning(Form("Data for container %s can be published only by producer task %s", GetName(), fProducer->GetName()));   
339       return kFALSE;           
340    }              
341 }
342
343 //______________________________________________________________________________
344 void AliAnalysisDataContainer::SetFileName(const char *filename)
345 {
346 // The filename field can be actually composed by the actual file name followed
347 // by :dirname (optional):
348 // filename = file_name[:dirname]
349 // No slashes (/) allowed
350   fFileName = filename;
351   fFolderName = "";
352   Int_t index = fFileName.Index(":");
353   // Fill the folder name
354   if (index >= 0) {
355     fFolderName = fFileName(index+1, fFileName.Length()-index);
356     fFileName.Remove(index);
357   }  
358   if (!fFileName.Length())
359     Fatal("SetFileName", "Empty file name");   
360   if (fFileName.Index("/")>=0)
361     Fatal("SetFileName", "No slashes (/) allowed in the file name");   
362 }
363
364 //______________________________________________________________________________
365 void AliAnalysisDataContainer::SetProducer(AliAnalysisTask *prod, Int_t islot)
366 {
367 // Set the producer of data. The slot number is required for data type checking.
368    if (fProducer) {
369      cout<<"Data container "<<GetName()<<" already has a producer: "<<fProducer->GetName()<<endl;
370      //AliWarning(Form("Data container %s already has a producer: %s",GetName(),fProducer->GetName()));
371    } 
372    if (fDataReady) {
373      cout<<GetName()<<" container contains data - cannot change producer!"<<endl;
374      //AliError(Form("%s container contains data - cannot change producer!", GetName()));
375       return;
376    }   
377    AliAnalysisDataSlot *slot = prod->GetOutputSlot(islot);
378    if (!slot) {
379      cout<<"Producer task "<<prod->GetName()<<" does not have an output #"<<islot<<endl;
380      //AliError(Form("Producer task %s does not have an output #%i", prod->GetName(),islot));
381       return;
382    }   
383    if (!slot->GetType()->InheritsFrom(GetType())) {
384      cout<<"Data type "<<slot->GetTitle()<<"for output slot "<<islot<<" of task "<<prod->GetName()<<" does not match container type "<<GetTitle()<<endl;
385      //AliError(Form("Data type %s for output slot %i of task %s does not match container type %s", slot->GetType()->GetName(),islot,prod->GetName(),fType->GetName()));
386       return;
387    }   
388    
389    fProducer = prod;
390    // Add all consumers as daughter tasks
391    TIter next(fConsumers);
392    AliAnalysisTask *cons;
393    while ((cons=(AliAnalysisTask*)next())) {
394       if (!prod->GetListOfTasks()->FindObject(cons)) prod->Add(cons);
395    }   
396 }   
397
398 //______________________________________________________________________________
399 AliAnalysisDataWrapper *AliAnalysisDataContainer::ExportData() const
400 {
401 // Wraps data for sending it through the net.
402    AliAnalysisDataWrapper *pack = 0;
403    if (!fData) {
404       Error("ExportData", "Container %s - No data to be wrapped !", GetName());
405       return pack;
406    } 
407    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
408    if (mgr->GetDebugLevel() > 1) printf("   ExportData: Wrapping data %s for container %s\n", fData->GetName(),GetName());
409    pack = new AliAnalysisDataWrapper(fData);
410    pack->SetName(fName.Data());
411    return pack;
412 }
413
414 //______________________________________________________________________________
415 void AliAnalysisDataContainer::ImportData(AliAnalysisDataWrapper *pack)
416 {
417 // Unwraps data from a data wrapper.
418    if (pack) {
419       fData = pack->Data();
420       if (!fData) {
421          Error("ImportData", "No data was wrapped for container %s", GetName());
422          return;
423       }   
424       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
425       if (mgr->GetDebugLevel() > 1) printf("   ImportData: Unwrapping data %s for container %s\n", fData->GetName(),GetName());
426       fDataReady = kTRUE;
427       // Imported wrappers do not own data anymore (AG 13-11-07)
428       pack->SetDeleteData(kFALSE);
429    }   
430 }      
431       
432 ClassImp (AliAnalysisDataWrapper)
433
434 //______________________________________________________________________________
435 AliAnalysisDataWrapper::AliAnalysisDataWrapper(TObject *data)
436                        :TNamed(),
437                         fData(data)
438 {
439 // Ctor.
440    if (data) SetName(data->GetName());
441 }
442
443 //______________________________________________________________________________
444 AliAnalysisDataWrapper::~AliAnalysisDataWrapper()
445 {
446 // Dtor.
447    if (fData && TObject::TestBit(kDeleteData)) delete fData;
448 }   
449
450 //______________________________________________________________________________
451 AliAnalysisDataWrapper &AliAnalysisDataWrapper::operator=(const AliAnalysisDataWrapper &other)
452 {
453 // Assignment.
454    if (&other != this) {
455       TNamed::operator=(other);
456       fData = other.fData;
457    }   
458    return *this;
459 }
460
461 //______________________________________________________________________________
462 Long64_t AliAnalysisDataWrapper::Merge(TCollection *list)
463 {
464 // Merge a list of containers with this one. Containers in the list must have
465 // data of the same type.
466    if (TH1::AddDirectoryStatus()) TH1::AddDirectory(kFALSE);
467    if (!fData) return 0;
468    if (!list || list->IsEmpty()) return 1;
469
470    SetDeleteData();
471
472    TMethodCall callEnv;
473    if (fData->IsA())
474       callEnv.InitWithPrototype(fData->IsA(), "Merge", "TCollection*");
475    if (!callEnv.IsValid()) {
476       cout << "No merge interface for data stored by " << GetName() << ". Merging not possible !" << endl;
477       return 1;
478    }
479
480    TIter next1(list);
481    AliAnalysisDataWrapper *cont;
482    // Make a list where to temporary store the data to be merged.
483    TList *collectionData = new TList();
484    Int_t count = 0; // object counter
485    // printf("Wrapper %s 0x%lx (data=%s) merged with:\n", GetName(), (ULong_t)this, fData->ClassName());
486    while ((cont=(AliAnalysisDataWrapper*)next1())) {
487       cont->SetDeleteData();
488       TObject *data = cont->Data();
489       if (!data) continue;
490       // printf("   - %s 0x%lx (data=%s)\n", cont->GetName(), (ULong_t)cont, data->ClassName());
491       collectionData->Add(data);
492       count++;
493    }
494    callEnv.SetParam((Long_t) collectionData);
495    callEnv.Execute(fData);
496    delete collectionData;
497
498    return count+1;
499 }
500
501 ClassImp(AliAnalysisFileDescriptor)
502
503 //______________________________________________________________________________
504 AliAnalysisFileDescriptor::AliAnalysisFileDescriptor()
505                           :TObject(), fLfn(), fGUID(), fUrl(), fPfn(), fSE(),
506                            fIsArchive(kFALSE), fImage(0), fNreplicas(0), 
507                            fStartBytes(0), fReadBytes(0), fSize(0), fOpenedAt(0), 
508                            fOpenTime(0.), fProcessingTime(0.), fThroughput(0.)
509 {
510 // I/O constructor
511 }
512
513 //______________________________________________________________________________
514 AliAnalysisFileDescriptor::AliAnalysisFileDescriptor(const TFile *file)
515                           :TObject(), fLfn(), fGUID(), fUrl(), fPfn(), fSE(),
516                            fIsArchive(kFALSE), fImage(0), fNreplicas(0), 
517                            fStartBytes(0), fReadBytes(0), fSize(0), fOpenedAt(0), 
518                            fOpenTime(0.), fProcessingTime(0.), fThroughput(0.)
519 {
520 // Normal constructor
521    if (file->InheritsFrom("TAlienFile")) {
522       fLfn =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetLfn();", file));
523       fGUID =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetGUID();", file));
524       fUrl =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetUrl();", file));
525       fPfn =(const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetPfn();", file));
526       fSE = (const char*)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetSE();", file));
527       fImage = (Int_t)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetImage();", file));
528       fNreplicas = (Int_t)gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetNreplicas();", file));
529       fOpenedAt = gROOT->ProcessLine(Form("((TAlienFile*)%p)->GetOpenTime();", file));
530       gROOT->ProcessLine(Form("((AliAnalysisFileDescriptor*)%p)->SetOpenTime(((TAlienFile*)%p)->GetElapsed());", this, file));
531    } else {
532       fLfn = file->GetName();
533       fPfn = file->GetName();
534       fUrl = file->GetName();
535       fSE = "local";
536       if (!fPfn.BeginsWith("/")) fPfn.Prepend(Form("%s/",gSystem->WorkingDirectory()));
537       fOpenedAt = time(0);
538    }
539    fStartBytes = TFile::GetFileBytesRead();
540    fIsArchive = file->IsArchive();
541    fSize = file->GetSize();
542 }
543
544 //______________________________________________________________________________
545 AliAnalysisFileDescriptor::AliAnalysisFileDescriptor(const AliAnalysisFileDescriptor &other)
546                           :TObject(other), fLfn(other.fLfn), fGUID(other.fGUID),
547                            fUrl(other.fUrl), fPfn(other.fPfn), fSE(other.fSE),
548                            fIsArchive(other.fIsArchive), fImage(other.fImage),
549                            fNreplicas(other.fNreplicas), fStartBytes(other.fStartBytes), fReadBytes(other.fReadBytes),
550                            fSize(other.fSize), fOpenedAt(other.fOpenedAt), fOpenTime(other.fOpenTime),
551                            fProcessingTime(other.fProcessingTime), fThroughput(other.fThroughput)
552 {
553 // CC
554 }
555
556 //______________________________________________________________________________
557 AliAnalysisFileDescriptor &AliAnalysisFileDescriptor::operator=(const AliAnalysisFileDescriptor &other)
558 {
559 // Assignment.
560    if (&other == this) return *this;
561    TObject::operator=(other);
562    fLfn       = other.fLfn;
563    fGUID      = other.fGUID;
564    fUrl       = other.fUrl; 
565    fPfn       = other.fPfn;
566    fSE        = other.fSE;
567    fIsArchive = other.fIsArchive;
568    fImage     = other.fImage;
569    fNreplicas = other.fNreplicas;
570    fStartBytes = other.fStartBytes;;
571    fReadBytes = other.fReadBytes;
572    fSize      = other.fSize;
573    fOpenedAt  = other.fOpenedAt;
574    fOpenTime  = other.fOpenTime;
575    fProcessingTime = other.fProcessingTime;
576    fThroughput = other.fThroughput;
577    return *this;
578 }
579
580 //______________________________________________________________________________
581 AliAnalysisFileDescriptor::~AliAnalysisFileDescriptor()
582 {
583 // Destructor
584 }
585
586 //______________________________________________________________________________
587 void AliAnalysisFileDescriptor::Done()
588 {
589 // Must be called at the end of processing, providing file->GetBytesRead() as argument.
590    const Double_t megabyte = 1048576.;
591    Long64_t stampnow = time(0);
592    fReadBytes = TFile::GetFileBytesRead()-fStartBytes;
593    fProcessingTime = stampnow-fOpenedAt;
594    Double_t readsize = fReadBytes/megabyte;
595    fThroughput = readsize/fProcessingTime;
596 }   
597
598 //______________________________________________________________________________
599 void AliAnalysisFileDescriptor::Print(Option_t*) const
600 {
601 // Print info about the file descriptor
602    const Double_t megabyte = 1048576.;
603    printf("===== Logical file name: %s =====\n", fLfn.Data());
604    printf("      Pfn: %s\n", fPfn.Data());
605    printf("      url: %s\n", fUrl.Data());
606    printf("      access time: %lld from SE: %s  image %d/%d\n", fOpenedAt, fSE.Data(), fImage, fNreplicas);
607    printf("      open time: %g [sec]\n", fOpenTime);
608    printf("      file size: %g [MB],  read size: %g [MB]\n", fSize/megabyte, fReadBytes/megabyte);
609    printf("      processing time [sec]: %g\n", fProcessingTime);
610    printf("      average throughput: %g [MB/sec]\n", fThroughput);
611 }
612
613 //______________________________________________________________________________
614 void AliAnalysisFileDescriptor::SavePrimitive(ostream &out, Option_t *)
615 {
616 // Stream info to file
617    const Double_t megabyte = 1048576.;
618    out << "#################################################################" << endl;
619    out << "pfn          " << fPfn.Data() << endl;
620    out << "url          " << fUrl.Data() << endl;
621    out << "se           " << fSE.Data() << endl;
622    out << "image        " << fImage << endl;
623    out << "nreplicas    " << fNreplicas << endl;
624    out << "openstamp    " << fOpenedAt << endl;
625    out << setiosflags(ios::fixed) << setprecision(3);
626    out << "opentime     " << fOpenTime << endl;
627    out << "runtime      " << fProcessingTime << endl;
628    out << "filesize     " << fSize/megabyte << endl;
629    out << "readsize     " << fReadBytes/megabyte << endl;
630    out << "throughput   " << fThroughput << endl;
631 }
632