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