]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisDataContainer.cxx
pkg and CMakelib for BF efficiency task (forgot for previous commit)
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisDataContainer.cxx
CommitLineData
d3106602 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
c52c2132 45#include <Riostream.h>
46#include <TMethodCall.h>
11026a80 47
c52c2132 48#include <TClass.h>
9162405c 49#include <TSystem.h>
8d7d3b59 50#include <TFile.h>
c52c2132 51#include <TTree.h>
ca78991b 52#include <TH1.h>
c52c2132 53#include <TROOT.h>
9162405c 54#include <TStopwatch.h>
d3106602 55
8d7d3b59 56#include "AliAnalysisManager.h"
d3106602 57#include "AliAnalysisDataContainer.h"
58#include "AliAnalysisDataSlot.h"
59#include "AliAnalysisTask.h"
60
c82bb898 61using std::endl;
62using std::cout;
d3106602 63ClassImp(AliAnalysisDataContainer)
64
65//______________________________________________________________________________
37a26056 66AliAnalysisDataContainer::AliAnalysisDataContainer() : TNamed(),
67 fDataReady(kFALSE),
68 fOwnedData(kFALSE),
c52c2132 69 fFileName(),
84fcd93f 70 fFolderName(),
8d7d3b59 71 fFile(NULL),
37a26056 72 fData(NULL),
73 fType(NULL),
74 fProducer(NULL),
75 fConsumers(NULL)
d3106602 76{
c52c2132 77// Dummy ctor.
d3106602 78}
37a26056 79
d3106602 80//______________________________________________________________________________
81AliAnalysisDataContainer::AliAnalysisDataContainer(const char *name, TClass *type)
37a26056 82 :TNamed(name,""),
83 fDataReady(kFALSE),
0355fc48 84 fOwnedData(kFALSE),
c52c2132 85 fFileName(),
84fcd93f 86 fFolderName(),
8d7d3b59 87 fFile(NULL),
37a26056 88 fData(NULL),
89 fType(type),
90 fProducer(NULL),
91 fConsumers(NULL)
d3106602 92{
c52c2132 93// Default constructor.
94 SetTitle(fType->GetName());
37a26056 95}
96
97//______________________________________________________________________________
98AliAnalysisDataContainer::AliAnalysisDataContainer(const AliAnalysisDataContainer &cont)
99 :TNamed(cont),
100 fDataReady(cont.fDataReady),
101 fOwnedData(kFALSE),
c52c2132 102 fFileName(cont.fFileName),
84fcd93f 103 fFolderName(cont.fFolderName),
8d7d3b59 104 fFile(NULL),
37a26056 105 fData(cont.fData),
c52c2132 106 fType(NULL),
37a26056 107 fProducer(cont.fProducer),
108 fConsumers(NULL)
109{
110// Copy ctor.
c52c2132 111 GetType();
37a26056 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 }
d3106602 117}
118
119//______________________________________________________________________________
120AliAnalysisDataContainer::~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
37a26056 127//______________________________________________________________________________
128AliAnalysisDataContainer &AliAnalysisDataContainer::operator=(const AliAnalysisDataContainer &cont)
129{
130// Assignment.
131 if (&cont != this) {
132 TNamed::operator=(cont);
133 fDataReady = cont.fDataReady;
84fcd93f 134 fOwnedData = kFALSE;
c52c2132 135 fFileName = cont.fFileName;
84fcd93f 136 fFolderName = cont.fFolderName;
8d7d3b59 137 fFile = NULL;
37a26056 138 fData = cont.fData;
c52c2132 139 GetType();
37a26056 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
c52c2132 150//______________________________________________________________________________
151void 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//______________________________________________________________________________
174Bool_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//______________________________________________________________________________
186void 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//______________________________________________________________________________
205TClass *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//______________________________________________________________________________
215void 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//______________________________________________________________________________
235Long64_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;
37153431 247 }
248
c52c2132 249 if (list->IsEmpty()) return 1;
250
251 TIter next(list);
37153431 252 AliAnalysisDataContainer *cont;
c52c2132 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++;
37153431 266 }
c52c2132 267 callEnv.SetParam((Long_t) collectionData);
268 callEnv.Execute(fData);
269 delete collectionData;
37153431 270
271 return count+1;
c52c2132 272}
273
274//______________________________________________________________________________
275void 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) {
b1310ef5 284 printf("%sContainer: %s type: %s POST_LOOP=%i", ind.Data(), GetName(), GetTitle(), IsPostEventLoop());
c52c2132 285 if (fProducer)
12856ea6 286 printf("%s = Data producer: task %s",ind.Data(),fProducer->GetName());
c52c2132 287 else
12856ea6 288 printf("%s= No data producer",ind.Data());
289 printf("%s = Consumer tasks: ", ind.Data());
c52c2132 290 if (!fConsumers || !fConsumers->GetEntriesFast()) printf("-none-\n");
291 else printf("\n");
37153431 292 }
84fcd93f 293 if (fFolderName.Length())
294 printf("Filename: %s folder: %s\n", fFileName.Data(), fFolderName.Data());
295 else
296 printf("Filename: %s\n", fFileName.Data());
c52c2132 297 TIter next(fConsumers);
298 AliAnalysisTask *task;
299 while ((task=(AliAnalysisTask*)next())) task->PrintTask(option, indent+3);
300}
301
d3106602 302//______________________________________________________________________________
327eaf46 303Bool_t AliAnalysisDataContainer::SetData(TObject *data, Option_t *)
d3106602 304{
305// Set the data as READY only if it was published by the producer.
d3106602 306 // If there is no producer declared, this is a top level container.
307 AliAnalysisTask *task;
327eaf46 308 Bool_t init = kFALSE;
d3106602 309 Int_t i, nc;
310 if (!fProducer) {
327eaf46 311 if (data != fData) init = kTRUE;
d3106602 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);
327eaf46 318 task->CheckNotify(init);
d3106602 319 }
320 }
321 return kTRUE;
37153431 322 }
d3106602 323 // Check if it is the producer who published the data
324 if (fProducer->GetPublishedData()==data) {
325 fData = data;
326 fDataReady = kTRUE;
d3106602 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 {
737eef16 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;
d3106602 340 }
341}
342
d3106602 343//______________________________________________________________________________
84fcd93f 344void 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//______________________________________________________________________________
d3106602 365void 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) {
11026a80 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()));
d3106602 371 }
372 if (fDataReady) {
11026a80 373 cout<<GetName()<<" container contains data - cannot change producer!"<<endl;
374 //AliError(Form("%s container contains data - cannot change producer!", GetName()));
d3106602 375 return;
376 }
377 AliAnalysisDataSlot *slot = prod->GetOutputSlot(islot);
378 if (!slot) {
11026a80 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));
d3106602 381 return;
382 }
c52c2132 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;
11026a80 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()));
d3106602 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}
981f2614 397
398//______________________________________________________________________________
399AliAnalysisDataWrapper *AliAnalysisDataContainer::ExportData() const
400{
401// Wraps data for sending it through the net.
402 AliAnalysisDataWrapper *pack = 0;
8d7d3b59 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());
981f2614 409 pack = new AliAnalysisDataWrapper(fData);
410 pack->SetName(fName.Data());
411 return pack;
412}
413
414//______________________________________________________________________________
415void AliAnalysisDataContainer::ImportData(AliAnalysisDataWrapper *pack)
416{
417// Unwraps data from a data wrapper.
418 if (pack) {
419 fData = pack->Data();
8d7d3b59 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());
981f2614 426 fDataReady = kTRUE;
8167b1d0 427 // Imported wrappers do not own data anymore (AG 13-11-07)
428 pack->SetDeleteData(kFALSE);
981f2614 429 }
430}
d3106602 431
981f2614 432ClassImp (AliAnalysisDataWrapper)
433
8167b1d0 434//______________________________________________________________________________
435AliAnalysisDataWrapper::AliAnalysisDataWrapper(TObject *data)
436 :TNamed(),
437 fData(data)
438{
439// Ctor.
440 if (data) SetName(data->GetName());
441}
442
443//______________________________________________________________________________
444AliAnalysisDataWrapper::~AliAnalysisDataWrapper()
445{
446// Dtor.
447 if (fData && TObject::TestBit(kDeleteData)) delete fData;
448}
449
981f2614 450//______________________________________________________________________________
451AliAnalysisDataWrapper &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//______________________________________________________________________________
462Long64_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.
ca78991b 466 if (TH1::AddDirectoryStatus()) TH1::AddDirectory(kFALSE);
981f2614 467 if (!fData) return 0;
468 if (!list || list->IsEmpty()) return 1;
469
b3694163 470 SetDeleteData();
471
981f2614 472 TMethodCall callEnv;
981f2614 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
8eedd442 480 TIter next1(list);
981f2614 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
ca78991b 485 // printf("Wrapper %s 0x%lx (data=%s) merged with:\n", GetName(), (ULong_t)this, fData->ClassName());
8eedd442 486 while ((cont=(AliAnalysisDataWrapper*)next1())) {
b3694163 487 cont->SetDeleteData();
981f2614 488 TObject *data = cont->Data();
489 if (!data) continue;
ca78991b 490 // printf(" - %s 0x%lx (data=%s)\n", cont->GetName(), (ULong_t)cont, data->ClassName());
981f2614 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}
9162405c 500
501ClassImp(AliAnalysisFileDescriptor)
502
503//______________________________________________________________________________
504AliAnalysisFileDescriptor::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//______________________________________________________________________________
514AliAnalysisFileDescriptor::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//______________________________________________________________________________
545AliAnalysisFileDescriptor::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//______________________________________________________________________________
557AliAnalysisFileDescriptor &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//______________________________________________________________________________
581AliAnalysisFileDescriptor::~AliAnalysisFileDescriptor()
582{
583// Destructor
584}
585
586//______________________________________________________________________________
587void 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//______________________________________________________________________________
599void 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//______________________________________________________________________________
614void 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