19 #include <Compression.h> 20 #include <Riostream.h> 25 #include <TFileCollection.h> 26 #include <TTreeCache.h> 30 #include <TMethodCall.h> 35 #include <TStopwatch.h> 64 fInputEventHandler(0),
65 fOutputEventHandler(0),
66 fMCtruthEventHandler(0),
70 fMode(kLocalAnalysis),
77 fSpecialOutputLocation(""),
88 fCurrentDescriptor(0),
95 fAutoBranchHandling(kTRUE),
96 fAsyncReading(kFALSE),
101 fCacheSize(100000000),
103 fRequestedBranches(),
115 fgAnalysisManager =
this;
116 fgCommonFileName =
"AnalysisResults.root";
117 if (TClass::IsCallingNew() != TClass::kDummyNew) {
126 fGlobals =
new TMap();
128 fIOTimer =
new TStopwatch();
129 fCPUTimer =
new TStopwatch();
130 fInitTimer =
new TStopwatch();
138 fInputEventHandler(NULL),
139 fOutputEventHandler(NULL),
140 fMCtruthEventHandler(NULL),
145 fInitOK(other.fInitOK),
146 fMustClean(other.fMustClean),
147 fIsRemote(other.fIsRemote),
148 fLocked(other.fLocked),
149 fMCLoop(other.fMCLoop),
150 fDebug(other.fDebug),
151 fSpecialOutputLocation(
""),
162 fCurrentDescriptor(0),
167 fExtraFiles(other.fExtraFiles),
168 fFileInfoLog(other.fFileInfoLog),
169 fAutoBranchHandling(other.fAutoBranchHandling),
170 fAsyncReading(other.fAsyncReading),
173 fNcalls(other.fNcalls),
174 fMaxEntries(other.fMaxEntries),
175 fCacheSize(other.fCacheSize),
176 fStatisticsMsg(other.fStatisticsMsg),
177 fRequestedBranches(other.fRequestedBranches),
178 fStatistics(other.fStatistics),
179 fGlobals(other.fGlobals),
180 fIOTimer(new TStopwatch()),
181 fCPUTimer(new TStopwatch()),
182 fInitTimer(new TStopwatch()),
206 if (&other !=
this) {
207 TNamed::operator=(other);
294 Error(
"CreateReadCache",
"Current tree or tree file not yet defined");
298 if (
fDebug) Info(
"CreateReadCache",
"=== Read caching disabled ===");
301 gEnv->SetValue(
"TFile.AsyncPrefetching",(Int_t)
fAsyncReading);
305 TTreeCache::SetLearnEntries(1);
311 fTree->AddBranchToCache(obj->GetName(),kTRUE);
314 fTree->AddBranchToCache(
"*", kTRUE);
317 Info(
"CreateReadCache",
"Read cache enabled %lld bytes with async reading=%d",
fCacheSize, (Int_t)fAsyncReading);
331 cout <<
"===== RUNNING IN EVENT LOOP MODE: " << GetName() << endl;
333 Error(
"EventLoop",
"No input handler: exiting");
336 TTree *
tree =
new TTree(
"DummyTree",
"Dummy tree for AliAnalysisManager::EventLoop");
338 if (!
Init(tree))
return kFALSE;
340 for (Long64_t iev=0; iev<nevents; iev++)
359 Long64_t readbytes =
fTree->GetTree()->GetEntry(entry, getall);
362 return (Int_t)readbytes;
385 while ( spath.Tokenize(tok, from,
"/") ) {
391 if (tok ==
"alice") expect = 1;
399 else if (tok ==
"data") {
406 if (tok.BeginsWith(
"LHC")) expect = 3;
411 if (run >= 18000) expect = 4;
415 if (expect == 4)
break;
420 if (isData) type =
"real";
421 else type =
"simulated";
422 ::Info(
"AliAnalysisManager::GetRunFromAlienPath",
"Run %d of %s data", run, type);
425 ::Error(
"AliAnalysisManager::GetRunFromAlienPath",
"Invalid AliEn path string");
441 Bool_t
init = kFALSE;
442 if (!tree)
return kFALSE;
444 printf(
"->AliAnalysisManager::Init(%s)\n", tree->GetName());
454 Error(
"Init",
"Output event handler failed to initialize");
466 Error(
"Init",
"Input event handler failed to initialize tree");
472 if(!tree->GetTree()) {
473 Long64_t readEntry = tree->LoadTree(0);
474 if (readEntry == -2) {
475 Error(
"Init",
"Input tree has no entry. Exiting");
488 Error(
"Init",
"MC event handler failed to initialize");
504 Error(
"Init",
"No top input container !");
511 printf(
"<-AliAnalysisManager::Init(%s)\n", tree->GetName());
523 if (
fDebug > 1)
printf(
"->AliAnalysisManager::SlaveBegin()\n");
530 if (!
CheckTasks()) Fatal(
"SlaveBegin",
"Not all needed libraries were loaded");
531 static Bool_t isCalled = kFALSE;
532 Bool_t
init = kFALSE;
533 Bool_t initOK = kTRUE;
535 TDirectory *curdir = gDirectory;
545 if (!init) msg =
"Failed to initialize output handler on worker";
548 if (!init) msg =
"Failed to initialize output handler";
551 if (!
fSelector) Error(
"SlaveBegin",
"Selector not set");
559 if (!init) msg =
"Failed to initialize input handler on worker";
562 if (!init) msg =
"Failed to initialize input handler";
565 if (!
fSelector) Error(
"SlaveBegin",
"Selector not set");
572 if (!init) msg =
"Failed to initialize MC handler on worker";
575 if (!init) msg =
"Failed to initialize MC handler";
578 if (!
fSelector) Error(
"SlaveBegin",
"Selector not set");
581 if (curdir) curdir->cd();
589 Bool_t dirStatus = TH1::AddDirectoryStatus();
594 TH1::AddDirectory(kFALSE);
597 Error(
"SlaveBegin",
"####### IMPORTANT! ####### \n\n\n\ 598 Task %s (%s) did not call PostData() for all its outputs in (User)CreateOutputObjects()\n\n\ 599 ####### FIX YOUR CODE, THIS WILL PRODUCE A FATAL ERROR IN FUTURE! ##########", task->GetName(), task->ClassName());
604 TH1::AddDirectory(dirStatus);
605 if (curdir) curdir->cd();
610 if (
fDebug > 1)
printf(
"<-AliAnalysisManager::SlaveBegin()\n");
623 if (!
fTree)
return kFALSE;
629 TFile *curfile =
fTree->GetCurrentFile();
631 Error(
"Notify",
"No current file");
640 if (
fDebug > 1)
printf(
"->AliAnalysisManager::Notify() file: %s\n", curfile->GetName());
644 if (
fDebug > 1)
printf(
" ### run found from path: %d\n", run);
666 if (
fDebug > 1)
printf(
"<-AliAnalysisManager::Notify()\n");
703 if (
fDebug > 1)
printf(
"->AliAnalysisManager::PackOutput()\n");
711 if (out.bad()) Error(
"SavePrimitive",
"Bad file name: %s",
fFileInfoLog.Data());
715 while ((log=nextflog())) log->SavePrimitive(out,
"");
719 Error(
"PackOutput",
"No target. Exiting.");
722 TDirectory *cdir = gDirectory;
735 if (
fDebug > 1)
printf(
"->FinishTaskOutput: task %s\n", task->GetName());
738 if (
fDebug > 1)
printf(
"<-FinishTaskOutput: task %s\n", task->GetName());
747 Bool_t isManagedByHandler = kFALSE;
752 isManagedByHandler = kFALSE;
756 isManagedByHandler = kTRUE;
761 if (!output->
GetData() && !isManagedByHandler) {
762 Error(
"PackOutput",
"No data for output container %s. Forgot to PostData ?", output->GetName());
767 if (strlen(filename) && !isManagedByHandler) {
769 TDirectory *opwd = gDirectory;
772 TString openoption =
"RECREATE";
773 Bool_t firsttime = kTRUE;
777 filestmp.Add(
new TNamed(output->
GetFileName(),
""));
779 if (!gSystem->AccessPathName(output->
GetFileName()) && !firsttime) openoption =
"UPDATE";
782 if (output->
GetData()->InheritsFrom(TCollection::Class())) {
785 TCollection *coll = (TCollection*)output->
GetData();
786 coll->SetName(output->GetName());
789 if (output->
GetData()->InheritsFrom(TTree::Class())) {
794 if (tree->GetDirectory()==
gROOT) tree->SetDirectory(gDirectory);
801 if (
fDebug > 1)
printf(
"PackOutput %s: memory merge, file resident output\n", output->GetName());
811 if (opwd) opwd->cd();
814 if (
fDebug > 1)
printf(
"PackOutput %s: memory merge memory resident output\n", filename);
817 if (isManagedByHandler) {
819 wrap->SetName(output->GetName());
827 TDirectory *opwd = gDirectory;
828 TFile *file = output->
GetFile();
832 "File %s for special container %s was NOT opened in %s::CreateOutputObjects !!!",
833 output->
GetFileName(), output->GetName(), producer->ClassName());
836 TString outFilename = file->GetName();
837 if (
fDebug > 1)
printf(
"PackOutput %s: special output\n", output->GetName());
838 if (isManagedByHandler) {
843 printf(
" handled file %s listing content:\n", file->GetName());
850 if (output->
GetData()->InheritsFrom(TCollection::Class())) {
853 TCollection *coll = (TCollection*)output->
GetData();
854 coll->SetName(output->GetName());
855 coll->Write(output->GetName(), TObject::kSingleKey);
857 if (output->
GetData()->InheritsFrom(TTree::Class())) {
859 tree->SetDirectory(file);
875 if (opwd) opwd->cd();
880 Int_t gid =
gROOT->ProcessLine(
"gProofServ->GetGroupId();");
881 if (remote.BeginsWith(
"alien:")) {
882 gROOT->ProcessLine(
"TGrid::Connect(\"alien:\", gProofServ->GetUser());");
883 remote += outFilename;
884 remote.ReplaceAll(
".root", Form(
"_%d.root", gid));
886 remote += Form(
"%s_%d_", gSystem->HostName(), gid);
887 remote += outFilename;
890 Info(
"PackOutput",
"Output file for container %s to be copied \n at: %s. No merging.",
891 output->GetName(), remote.Data());
892 TFile::Cp ( outFilename.Data(), remote.Data() );
897 TIter nextfilename(arr);
898 while ((os=(TObjString*)nextfilename())) {
899 outFilename = os->GetString();
902 if (remote.BeginsWith(
"alien://")) {
903 remote += outFilename;
904 remote.ReplaceAll(
".root", Form(
"_%d.root", gid));
906 remote += Form(
"%s_%d_", gSystem->HostName(), gid);
907 remote += outFilename;
910 Info(
"PackOutput",
"Extra AOD file %s to be copied \n at: %s. No merging.",
911 outFilename.Data(), remote.Data());
912 TFile::Cp ( outFilename.Data(), remote.Data() );
919 if (
fDebug > 1)
printf(
" File for container %s to be merged via file merger...\n", output->GetName());
928 printf(
"=Analysis %s= init time: %g[sec]\ 929 \n I/O & data mng.: %g [sec]\ 930 \n task execution: %g [sec]\ 931 \n total time: CPU=%g [sec] REAL=%g[sec]\n",
934 out <<
"#summary#########################################################" << endl;
935 out <<
"train_name " << GetName() << endl;
936 out <<
"root_time " <<
fInitTimer->RealTime() << endl;
937 out <<
"root_cpu " <<
fInitTimer->CpuTime() << endl;
938 out <<
"init_time " <<
fInitTime << endl;
939 out <<
"io_mng_time " << fIOTime << endl;
940 out <<
"exec_time " << fCPUTime << endl;
941 TString aliensite = gSystem->Getenv(
"ALIEN_SITE");
942 out <<
"alien_site " << aliensite << endl;
944 TString hostname = gSystem->Getenv(
"ALIEN_HOSTNAME");
945 if (hostname.IsNull()) {
947 gSystem->Exec(Form(
"hostname -f >> %s",
fFileInfoLog.Data()));
949 out << hostname << endl;
954 if (cdir) cdir->cd();
955 if (
fDebug > 1)
printf(
"<-AliAnalysisManager::PackOutput: output list contains %d containers\n", target->GetSize());
963 if (
fDebug > 1)
printf(
"->AliAnalysisManager::ImportWrappers()\n");
970 TDirectory *cdir = gDirectory;
976 Bool_t isManagedByHandler = kFALSE;
978 isManagedByHandler = kTRUE;
990 TIter nextfilename(arr);
999 TFile *
f = (TFile*)
gROOT->GetListOfFiles()->FindObject(filename);
1002 Error(
"ImportWrappers",
"Cannot open file %s in read-only mode", filename);
1009 if (!folder.IsNull()) f->cd(folder);
1011 obj = gDirectory->Get(cont->GetName());
1013 Warning(
"ImportWrappers",
"Could not import object of type:%s for container %s in file %s:%s.\n Object will not be available in Terminate(). Try if possible to name the output object as the container (%s) or to embed it in a TList",
1014 cont->
GetType()->GetName(), cont->GetName(), filename, cont->
GetFolderName(), cont->GetName());
1022 Error(
"ImportWrappers",
"Container %s not found in analysis output !", cont->GetName());
1027 printf(
" Importing data for container %s\n", cont->GetName());
1028 if (strlen(filename))
printf(
" -> file %s\n", filename);
1033 if (cdir) cdir->cd();
1036 if (
fDebug > 1)
printf(
"<-AliAnalysisManager::ImportWrappers(): %d containers imported\n", icont);
1045 if (
fDebug > 1)
printf(
"->AliAnalysisManager::UnpackOutput()\n");
1047 Error(
"UnpackOutput",
"No target. Exiting.");
1050 if (
fDebug > 1)
printf(
" Source list contains %d containers\n", source->GetSize());
1057 if (!output->
GetData())
continue;
1063 Int_t ncons = list->GetEntriesFast();
1064 for (Int_t i=0; i<ncons; i++) {
1069 if (
fDebug > 1)
printf(
"== Executing post event loop task %s\n", task->GetName());
1071 task->ExecuteTask();
1079 if (
fDebug > 1)
printf(
"<-AliAnalysisManager::UnpackOutput()\n");
1089 if (
fDebug > 1)
printf(
"->AliAnalysisManager::Terminate()\n");
1091 TDirectory *cdir = gDirectory;
1103 TString pictname = Form(
"%s_%s", task->GetName(), task->ClassName());
1110 if (!
gROOT->IsBatch()) {
1111 if (
fDebug>1)
printf(
"Waiting 5 sec for %s::Terminate() to finish drawing ...\n", task->ClassName());
1113 while (timer.RealTime()<5) {
1115 gSystem->ProcessEvents();
1118 Int_t iend =
gROOT->GetListOfCanvases()->GetEntries();
1119 if (iend==0)
continue;
1121 for (Int_t ipict=0; ipict<iend; ipict++) {
1122 canvas = (TCanvas*)
gROOT->GetListOfCanvases()->At(ipict);
1123 if (!canvas)
continue;
1124 canvas->SaveAs(Form(
"%s_%02d.gif", pictname.Data(),ipict));
1126 gROOT->GetListOfCanvases()->Delete();
1136 for (icont=0; icont<
fOutputs->GetEntriesFast(); icont++) allOutputs->Add(
fOutputs->At(icont));
1138 for (icont=0; icont<
fParamCont->GetEntriesFast(); icont++) allOutputs->Add(
fParamCont->At(icont));
1139 TIter next1(allOutputs);
1140 TString handlerFile =
"";
1141 TString extraOutputs =
"";
1156 TString openoption =
"RECREATE";
1157 if (!(strcmp(filename,
"default")))
continue;
1158 if (!strlen(filename))
continue;
1159 if (!output->
GetData())
continue;
1160 TDirectory *opwd = gDirectory;
1161 TFile *file = output->
GetFile();
1162 if (!file) file = (TFile*)
gROOT->GetListOfFiles()->FindObject(filename);
1165 Bool_t firsttime = kTRUE;
1166 if (filestmp.FindObject(filename) || extraOutputs.Contains(filename)) {
1169 filestmp.Add(
new TNamed(filename,
""));
1171 if (!gSystem->AccessPathName(filename) && !firsttime) openoption =
"UPDATE";
1172 if (
fDebug>1)
printf(
"Opening file: %s option=%s\n",filename, openoption.Data());
1173 file =
new TFile(filename, openoption);
1174 file->SetCompressionSettings(ROOT::CompressionSettings(ROOT::kZLIB, 1));
1176 if (
fDebug>1)
printf(
"File <%s> already opened with option: <%s> \n", filename, file->GetOption());
1177 openoption = file->GetOption();
1178 if (openoption ==
"READ") {
1180 file->ReOpen(
"UPDATE");
1183 if (file->IsZombie()) {
1184 Error(
"Terminate",
"Cannot open output file %s", filename);
1191 if (!dir.IsNull()) {
1192 if (!file->GetDirectory(dir)) file->mkdir(dir);
1195 if (
fDebug > 1)
printf(
"...writing container %s to file %s:%s\n", output->GetName(), file->GetName(), output->
GetFolderName());
1196 if (output->
GetData()->InheritsFrom(TCollection::Class())) {
1199 TCollection *coll = (TCollection*)output->
GetData();
1200 coll->SetName(output->GetName());
1201 coll->Write(output->GetName(), TObject::kSingleKey);
1203 if (output->
GetData()->InheritsFrom(TTree::Class())) {
1205 tree->SetDirectory(gDirectory);
1211 if (opwd) opwd->cd();
1215 TString copiedFiles;
1218 TDirectory *opwd = gDirectory;
1225 if (copiedFiles.Contains(output->
GetFile()->GetName())) {
1226 if (opwd) opwd->cd();
1231 gROOT->ProcessLine(
"if (!gGrid) TGrid::Connect(\"alien:\");");
1232 TFile::Cp(output->
GetFile()->GetName(),
1234 copiedFiles += output->
GetFile()->GetName();
1238 if (opwd) opwd->cd();
1244 TDirectory *crtdir = gDirectory;
1245 TFile
f(
"syswatch.root",
"RECREATE");
1248 if (!f.IsZombie()) {
1250 tree->SetDirectory(&f);
1251 tree->SetName(
"syswatch");
1252 tree->SetMarkerStyle(kCircle);
1253 tree->SetMarkerColor(kBlue);
1254 tree->SetMarkerSize(0.5);
1255 if (!
gROOT->IsBatch()) {
1256 tree->SetAlias(
"event",
"id0");
1257 tree->SetAlias(
"task",
"id1");
1258 tree->SetAlias(
"stage",
"id2");
1264 TCanvas *canvas =
new TCanvas(
"SysInfo",
"SysInfo",10,10,1200,800);
1270 Int_t iopt = (Int_t)TMath::Sqrt((Double_t)npads);
1271 if (npads<iopt*(iopt+1))
1272 canvas->Divide(iopt, iopt+1, 0.01, 0.01);
1274 canvas->Divide(iopt+1, iopt+1, 0.01, 0.01);
1277 for (itask=0; itask<
fTopTasks->GetEntriesFast(); itask++) {
1280 cut.Form(
"task==%d && stage==1", itask);
1281 tree->Draw(
"deltaVM:event",cut,
"", 1234567890, 0);
1282 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1284 hist->SetTitle(Form(
"%s: Exec dVM[MB]/event", task->GetName()));
1285 hist->GetYaxis()->SetTitle(
"deltaVM [MB]");
1290 tree->SetMarkerStyle(kFullTriangleUp);
1291 tree->SetMarkerColor(kRed);
1292 tree->SetMarkerSize(0.8);
1293 cut =
"task>=0 && task<1000 && stage==0";
1294 tree->Draw(
"deltaVM:sname",cut,
"", 1234567890, 0);
1295 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1297 hist->SetTitle(
"Memory in CreateOutputObjects()");
1298 hist->GetYaxis()->SetTitle(
"deltaVM [MB]");
1299 hist->GetXaxis()->SetTitle(
"task");
1303 tree->SetMarkerStyle(kOpenSquare);
1304 tree->SetMarkerColor(kMagenta);
1305 cut =
"task>=0 && task<1000 && stage==2";
1306 tree->Draw(
"deltaVM:sname",cut,
"", 1234567890, 0);
1307 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1309 hist->SetTitle(
"Memory in Terminate()");
1310 hist->GetYaxis()->SetTitle(
"deltaVM [MB]");
1311 hist->GetXaxis()->SetTitle(
"task");
1315 tree->SetMarkerStyle(kFullCircle);
1316 tree->SetMarkerColor(kGreen);
1317 cut.Form(
"task==%d && stage==1",
fTopTasks->GetEntriesFast()-1);
1318 tree->Draw(
"VM:event",cut,
"", 1234567890, 0);
1319 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1321 hist->SetTitle(
"Virtual memory");
1322 hist->GetYaxis()->SetTitle(
"VM [MB]");
1326 tree->SetMarkerStyle(kCircle);
1327 tree->SetMarkerColor(kBlue);
1328 tree->SetMarkerSize(0.5);
1332 if (crtdir) crtdir->cd();
1337 out.open(
"outputs_valid", ios::out);
1340 if (cdir) cdir->cd();
1343 printf(
"=Analysis %s= Terminate time: %g[sec]\n", GetName(),
fInitTimer->RealTime());
1345 if (
fDebug > 1)
printf(
"<-AliAnalysisManager::Terminate()\n");
1354 Error(
"ProfileTask",
"There are only %d top tasks in the manager",
fTopTasks->GetEntries());
1366 if (gSystem->AccessPathName(
"syswatch.root")) {
1367 Error(
"ProfileTask",
"No file syswatch.root found in the current directory");
1370 if (
gROOT->IsBatch())
return;
1373 Error(
"ProfileTask",
"No top task named %s known by the manager.", name);
1377 Int_t itask =
fTasks->IndexOf(task);
1379 TDirectory *cdir = gDirectory;
1380 TFile
f(
"syswatch.root");
1381 TTree *
tree = (TTree*)f.Get(
"syswatch");
1383 Error(
"ProfileTask",
"No tree named <syswatch> found in file syswatch.root");
1386 if (
fDebug > 1)
printf(
"=== Profiling task %s (class %s)\n", name, task->ClassName());
1387 TCanvas *canvas =
new TCanvas(Form(
"profile_%d",itop),Form(
"Profile of task %s (class %s)",name,task->ClassName()),10,10,800,600);
1388 canvas->Divide(2, 2, 0.01, 0.01);
1394 cut.Form(
"task==%d && (stage==0 || stage==2)",itask);
1395 tree->Draw(
"deltaVM:sname",cut,
"", 1234567890, 0);
1396 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1398 hist->SetTitle(
"Alocated VM[MB] for COO and Terminate");
1399 hist->GetYaxis()->SetTitle(
"deltaVM [MB]");
1400 hist->GetXaxis()->SetTitle(
"method");
1404 cut.Form(
"task==%d && stage==1",itop);
1405 tree->Draw(
"deltaT:event",cut,
"", 1234567890, 0);
1406 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1408 hist->SetTitle(
"Execution time per event");
1409 hist->GetYaxis()->SetTitle(
"CPU/event [s]");
1413 cut.Form(
"task==%d && stage==1",itop);
1414 tree->Draw(
"deltaVM:event",cut,
"", 1234567890, 0);
1415 hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(
"htemp");
1417 hist->SetTitle(
"Alocated VM[MB] per event");
1418 hist->GetYaxis()->SetTitle(
"deltaVM [MB]");
1423 if (cdir) cdir->cd();
1432 Error(
"AddTask",
"Cannot add task %s since InitAnalysis was already called", task->GetName());
1436 if (
fTasks->FindObject(task)) {
1437 Warning(
"AddTask",
"Task %s: the same object already added to the analysis manager. Not adding.", task->GetName());
1440 task->SetActive(kFALSE);
1449 if (!
fTasks)
return NULL;
1459 return fTasks->IndexOf(task);
1474 Error(
"CreateContainer",
"A container named %s already defined !",name);
1485 if (filename && strlen(filename)) {
1492 if (filename && strlen(filename)) {
1513 Error(
"ConnectInput",
"Task pointer is NULL");
1516 if (!
fTasks->FindObject(task)) {
1518 Info(
"ConnectInput",
"Task %s was not registered. Now owned by analysis manager", task->GetName());
1531 Error(
"ConnectOutput",
"Task pointer is NULL");
1534 if (!
fTasks->FindObject(task)) {
1536 Warning(
"ConnectOutput",
"Task %s not registered. Now owned by analysis manager", task->GetName());
1564 if (!gSystem->AccessPathName(
"outputs_valid"))
1565 gSystem->Unlink(
"outputs_valid");
1568 Error(
"InitAnalysis",
"Analysis has no tasks !");
1576 Bool_t iszombie = kFALSE;
1577 Bool_t istop = kTRUE;
1583 for (i=0; i<ninputs; i++) {
1592 Error(
"InitAnalysis",
"Input slot %d of task %s has no container connected ! Declared zombie...",
1593 i, task->GetName());
1595 if (iszombie)
continue;
1597 if (istop && !
fInputs->FindObject(cont)) istop=kFALSE;
1606 Error(
"InitAnalysis",
"No top task defined. At least one task should be connected only to input containers");
1610 for (i=0; i<ntop; i++) {
1619 Warning(
"InitAnalysis",
"Task %s is orphan", task->GetName());
1624 for (i=0; i<ntop; i++) {
1627 Error(
"InitAnalysis",
"Found illegal circular dependencies between following tasks:");
1652 Error(
"InitAnalysis",
"Wrong container %s : a file name MUST be provided for special outputs", cont->GetName());
1661 Error(
"InitAnalysis",
"Manual branch loading requested but task %s of type %s does not define branches.\nUse: fBranchNames = \"ESD:br1,br2,...,brN AOD:bra1,bra2,...,braM\"",
1662 task->GetName(), task->ClassName());
1666 Error(
"InitAnalysis",
"Manual branch loading requested but no input handler defined or handler does not define data type.");
1669 TString taskbranches;
1671 if (taskbranches.IsNull()) {
1672 Error(
"InitAnalysis",
"Manual branch loading requested but task %s of type %s does not define branches of type %s:",
1688 TString br(branches);
1692 while ((obj=next())) {
1710 while ((obj=next())) {
1711 TBranch *br =
dynamic_cast<TBranch*
>(
fTable.FindObject(obj->GetName()));
1713 br =
fTree->GetBranch(obj->GetName());
1715 Error(
"CheckBranches",
"Could not find branch %s",obj->GetName());
1731 Int_t ntasks =
fTasks->GetEntries();
1733 Error(
"CheckTasks",
"No tasks connected to the manager. This may be due to forgetting to compile the task or to load their library.");
1739 while ((obj=next())) {
1740 if (strcmp(obj->ClassName(),
"AliAnalysisTaskSE") == 0)
1742 Error(
"CheckTasks",
"##################\n \ 1743 Class for task %s NOT loaded. You probably forgot to load the library for this task (or compile it dynamically).\n###########################\n",obj->GetName());
1756 Info(
"PrintStatus",
"Analysis manager %s not initialized : call InitAnalysis() first", GetName());
1762 Info(
"PrintStatus",
"System information will be collected each %lld events",
fNSysInfo);
1766 printf(
"=== TOP CONTAINER:\n");
1774 task->SetActive(kFALSE);
1779 TString sopt(option);
1782 if (sopt.Contains(
"ALL"))
1786 cout << TString(
'_',78) << endl;
1787 cout <<
"OutputEventHandler:" << endl;
1812 TDirectory *cdir = gDirectory;
1820 if (cdir) cdir->cd();
1831 TFile *file = tree->GetCurrentFile();
1834 TChain *
chain =
dynamic_cast<TChain*
>(
tree);
1835 if (!chain || !chain->GetNtrees())
return;
1836 basename = gSystem->BaseName(chain->GetListOfFiles()->First()->GetTitle());
1838 basename = gSystem->BaseName(file->GetName());
1840 Int_t index = basename.Index(
"#");
1841 fname = basename(index+1, basename.Length());
1850 Error(
"StartAnalysis",
"Cannot start analysis providing just the analysis type without a grid handler.");
1851 Info(
"===",
"Add an AliAnalysisAlien object as plugin for this manager and configure it.");
1866 TDirectory *cdir = gDirectory;
1869 Error(
"StartAnalysis",
"Analysis manager was not initialized !");
1870 if (cdir) cdir->cd();
1873 if (!
CheckTasks()) Fatal(
"StartAnalysis",
"Not all needed libraries were loaded");
1875 printf(
"StartAnalysis %s\n",GetName());
1880 TString anaType = type;
1883 if (anaType.Contains(
"file"))
fIsRemote = kTRUE;
1895 if (!anaType.Contains(
"terminate")) {
1897 Error(
"StartAnalysis",
"Cannot start grid analysis without a grid handler.");
1898 Info(
"===",
"Add an AliAnalysisAlien object as plugin for this manager and configure it.");
1899 if (cdir) cdir->cd();
1903 cout <<
"===== RUNNING GRID ANALYSIS: " << GetName() << endl;
1907 Info(
"StartAnalysis",
"Grid analysis was stopped and cannot be terminated");
1908 if (cdir) cdir->cd();
1915 cout <<
"===== MERGING OUTPUTS REGISTERED BY YOUR ANALYSIS JOB: " << GetName() << endl;
1919 if (cdir) cdir->cd();
1923 cout <<
"===== TERMINATING GRID ANALYSIS JOB: " << GetName() << endl;
1924 if (cdir) cdir->cd();
1927 if (cdir) cdir->cd();
1936 TString ttype =
"TTree";
1937 if (tree && tree->IsA() == TChain::Class()) {
1938 chain = (TChain*)tree;
1939 if (!chain || !chain->GetListOfFiles()->First()) {
1940 Error(
"StartAnalysis",
"Cannot process null or empty chain...");
1941 if (cdir) cdir->cd();
1963 Bool_t dirStatus = TH1::AddDirectoryStatus();
1965 TH1::AddDirectory(kFALSE);
1968 Error(
"SlaveBegin",
"####### IMPORTANT! ####### \n\n\n\ 1969 Task %s (%s) did not call PostData() for all its outputs in (User)CreateOutputObjects()\n\n\ 1970 ########### FIX YOUR CODE, THIS WILL PRODUCE A FATAL ERROR IN FUTURE! ###########", task->GetName(), task->ClassName());
1976 TH1::AddDirectory(dirStatus);
1978 Info(
"StartAnalysis",
"Initialization done. Event loop is controlled externally.\ 1979 \nSetData for top container, call ExecAnalysis in a loop and then Terminate manually");
1990 TString dataType =
"esdTree";
1998 Error(
"StartAnalysis",
"No chain for test mode. Aborting.");
2001 cout <<
"===== RUNNING LOCAL ANALYSIS" << GetName() <<
" ON CHAIN " << chain->GetName() << endl;
2002 retv = chain->Process(
fSelector,
"", nentries, firstentry);
2006 cout <<
"===== RUNNING LOCAL ANALYSIS " << GetName() <<
" ON TREE " << tree->GetName() << endl;
2007 retv = tree->Process(
fSelector,
"", nentries, firstentry);
2015 if (!
gROOT->GetListOfProofs() || !
gROOT->GetListOfProofs()->GetEntries()) {
2016 Error(
"StartAnalysis",
"No PROOF!!! Exiting.");
2017 if (cdir) cdir->cd();
2020 line = Form(
"gProof->AddInput((TObject*)%p);",
this);
2021 gROOT->ProcessLine(line);
2024 cout <<
"===== RUNNING PROOF ANALYSIS " << GetName() <<
" ON CHAIN " << chain->GetName() << endl;
2025 retv = chain->Process(
"AliAnalysisSelector",
"", nentries, firstentry);
2027 Error(
"StartAnalysis",
"No chain!!! Exiting.");
2028 if (cdir) cdir->cd();
2034 if (!anaType.Contains(
"terminate")) {
2036 Error(
"StartAnalysis",
"Cannot start grid analysis without a grid handler.");
2037 Info(
"===",
"Add an AliAnalysisAlien object as plugin for this manager and configure it.");
2038 if (cdir) cdir->cd();
2042 cout <<
"===== RUNNING GRID ANALYSIS: " << GetName() << endl;
2045 Info(
"StartAnalysis",
"Grid analysis was stopped and cannot be terminated");
2046 if (cdir) cdir->cd();
2053 cout <<
"===== MERGING OUTPUTS REGISTERED BY YOUR ANALYSIS JOB: " << GetName() << endl;
2057 if (cdir) cdir->cd();
2061 cout <<
"===== TERMINATING GRID ANALYSIS JOB: " << GetName() << endl;
2064 if (cdir) cdir->cd();
2069 Error(
"StartAnalysis",
"Cannot run event mixing without event pool");
2070 if (cdir) cdir->cd();
2073 cout <<
"===== RUNNING EVENT MIXING ANALYSIS " << GetName() << endl;
2082 Error(
"StartAnalysis",
"Mixing analysis failed");
2083 if (cdir) cdir->cd();
2090 if (cdir) cdir->cd();
2101 Error(
"StartAnalysis",
"Analysis manager was not initialized !");
2105 if (
fDebug > 1)
printf(
"StartAnalysis %s\n",GetName());
2106 TString anaType = type;
2108 if (!anaType.Contains(
"proof")) {
2109 Error(
"StartAnalysis",
"Cannot process datasets in %s mode. Try PROOF.", type);
2114 TString proofProcessOpt;
2122 Error(
"StartAnalysis",
"The grid plugin could not start PROOF analysis");
2127 dataset =
"test_collection";
2135 if (!
gROOT->GetListOfProofs() || !
gROOT->GetListOfProofs()->GetEntries()) {
2136 Error(
"StartAnalysis",
"No PROOF!!! Exiting.");
2143 line.Form(
"gProof->AddInput((TObject*)%p);",
this);
2144 gROOT->ProcessLine(line);
2146 line.Form(
"gProof->Process((const char *)%p, \"AliAnalysisSelector\", \"%s\", %lld, %lld);",
2147 dataset, proofProcessOpt.Data(), nentries, firstentry);
2148 char *dispDataset =
new char[101];
2149 strncpy(dispDataset, dataset, 100);
2150 strncpy(&dispDataset[97],
"...", 3);
2151 dispDataset[100] =
'\0';
2152 cout <<
"===== RUNNING PROOF ANALYSIS " << GetName() <<
" ON DATASET " << dispDataset << endl;
2153 delete [] dispDataset;
2154 retv = (Long_t)
gROOT->ProcessLine(line);
2164 AliInfo(
"Using the new direct TFileCollection interface !!!!");
2167 Error(
"StartAnalysis",
"Analysis manager was not initialized !");
2171 Error(
"StartAnalysis",
"Can not work with a NULL TFileCollection !");
2175 if (
fDebug > 1)
printf(
"StartAnalysis %s\n",GetName());
2176 TString anaType = type;
2178 if (!anaType.Contains(
"proof")) {
2179 Error(
"StartAnalysis",
"Cannot process datasets in %s mode. Try PROOF.", type);
2184 TString proofProcessOpt;
2190 if (!
gROOT->GetListOfProofs() || !
gROOT->GetListOfProofs()->GetEntries()) {
2191 Error(
"StartAnalysis",
"No PROOF!!! Exiting.");
2198 line.Form(
"gProof->AddInput((TObject*)%p);",
this);
2199 gROOT->ProcessLine(line);
2201 line.Form(
"gProof->Process((TFileCollection *)%p, \"AliAnalysisSelector\", \"%s\", %lld, %lld);",
2202 dataset, proofProcessOpt.Data(), nentries, firstentry);
2203 char *dispDataset =
new char[101];
2204 strncpy(dispDataset, dataset->GetName(), 100);
2205 strncpy(&dispDataset[97],
"...", 3);
2206 dispDataset[100] =
'\0';
2207 cout <<
"===== RUNNING PROOF ANALYSIS " << GetName() <<
" ON DATASET " << dispDataset << endl;
2208 delete [] dispDataset;
2209 retv = (Long_t)
gROOT->ProcessLine(line);
2224 if (filename.IsNull()) {
2225 ::Error(
"AliAnalysisManager::OpenFile",
"No file name specified for container %s", cont->GetName());
2233 f = (TFile*)
gROOT->GetListOfFiles()->FindObject(filename);
2236 TString opt(option);
2238 if ((opt==
"UPDATE") && (opt!=f->GetOption()))
2239 ::Info(
"AliAnalysisManager::OpenFile",
"File %s already opened in %s mode!", cont->
GetFileName(), f->GetOption());
2244 if (f && !f->IsZombie() && !f->TestBit(TFile::kRecovered)) {
2250 if (!dir.IsNull()) {
2251 if (!f->GetDirectory(dir)) f->mkdir(dir);
2256 ::Fatal(
"AliAnalysisManager::OpenFile",
"File %s could not be opened", filename.Data());
2270 if (strlen(extaod)) filename = extaod;
2273 else Fatal(
"OpenProofFile",
"No output container. Exiting.");
2277 Fatal(
"OpenProofFile",
"Cannot open PROOF file %s: no PROOF or selector",filename.Data());
2281 f = (TFile*)
gROOT->GetListOfFiles()->FindObject(filename);
2284 TString opt(option);
2286 if ((opt==
"UPDATE") && (opt!=f->GetOption()))
2287 ::Info(
"OpenProofFile",
"File %s already opened in %s mode!", cont->
GetFileName(), f->GetOption());
2289 f =
new TFile(filename, option);
2291 if (f && !f->IsZombie() && !f->TestBit(TFile::kRecovered)) {
2298 if (!f->GetDirectory(dir)) f->mkdir(dir);
2303 Fatal(
"OpenProofFile",
"File %s could not be opened", cont->
GetFileName());
2308 TObject *pof =
fSelector->GetOutputList()->FindObject(filename);
2311 line.Form(
"((TProofOutputFile*)%p)->GetFileName();", pof);
2312 filename = (
const char*)
gROOT->ProcessLine(line);
2314 printf(
"File: %s already booked via TProofOutputFile\n", filename.Data());
2316 f = (TFile*)
gROOT->GetListOfFiles()->FindObject(filename);
2318 Fatal(
"OpenProofFile",
"Proof output file found but no file opened for %s", filename.Data());
2322 TString opt(option);
2324 if ((opt==
"UPDATE") && (opt!=f->GetOption()))
2325 Fatal(
"OpenProofFile",
"File %s already opened, but not in UPDATE mode!", cont->
GetFileName());
2328 TString dsetName = filename;
2329 dsetName.ReplaceAll(
".root", cont->GetTitle());
2330 dsetName.ReplaceAll(
":",
"_");
2331 if (
fDebug>1)
printf(
"Booking dataset: %s\n", dsetName.Data());
2332 line.Form(
"TProofOutputFile *pf = new TProofOutputFile(\"%s\", \"DROV\", \"%s\");", filename.Data(), dsetName.Data());
2334 if (
fDebug>1)
printf(
"Booking TProofOutputFile: %s to be merged\n", filename.Data());
2335 line.Form(
"TProofOutputFile *pf = new TProofOutputFile(\"%s\");", filename.Data());
2338 gROOT->ProcessLine(line);
2339 line.Form(
"pf->OpenFile(\"%s\");", option);
2340 gROOT->ProcessLine(line);
2343 gROOT->ProcessLine(
"pf->Print()");
2344 printf(
" == proof file name: %s", f->GetName());
2347 line.Form(
"((TList*)%p)->Add(pf);",
fSelector->GetOutputList());
2349 gROOT->ProcessLine(line);
2351 if (f && !f->IsZombie() && !f->TestBit(TFile::kRecovered)) {
2357 if (!dir.IsNull()) {
2358 if (!f->GetDirectory(dir)) f->mkdir(dir);
2363 Fatal(
"OpenProofFile",
"File %s could not be opened", cont->
GetFileName());
2373 static Long64_t nentries = 0;
2374 static TTree *lastTree = 0;
2375 static TStopwatch *
timer =
new TStopwatch();
2385 nentries +=
fTree->GetEntries();
2393 TDirectory *cdir = gDirectory;
2397 Error(
"ExecAnalysis",
"Analysis manager was not initialized !");
2398 if (cdir) cdir->cd();
2407 if (getsysInfo && ((fNcalls%fNSysInfo)==0))
2415 Error(
"ExecAnalysis",
"Cannot execute analysis in TSelector mode without at least one top container");
2416 if (cdir) cdir->cd();
2420 Long64_t entry =
fTree->GetTree()->GetReadEntry();
2433 if (getsysInfo && ((fNcalls%fNSysInfo)==0))
2444 task->SetActive(kTRUE);
2446 cout <<
" Executing task " << task->GetName() << endl;
2449 task->ExecuteTask(option);
2452 if (getsysInfo && ((fNcalls%fNSysInfo)==0))
2465 if (getsysInfo && ((fNcalls%fNSysInfo)==0))
2467 if (cdir) cdir->cd();
2488 if (getsysInfo && ((fNcalls%fNSysInfo)==0))
2493 task->SetActive(kTRUE);
2495 cout <<
" Executing task " << task->GetName() << endl;
2498 task->ExecuteTask(option);
2510 if (getsysInfo && ((fNcalls%fNSysInfo)==0))
2512 if (cdir) cdir->cd();
2522 Bool_t ispipe = kFALSE;
2523 out.seekp(0, std::ios_base::cur);
2526 if (errno == ESPIPE) ispipe = kTRUE;
2558 Info(
"SetDebugLevel",
"Ignored. Disable the progress bar first.");
2569 Info(
"SetUseProgressBar",
"Progress bar enabled, updated every %d events.\n ### NOTE: Debug level reset to 0 ###", freq);
2596 TObject *pof = source->FindObject(filename);
2597 if (!pof || !pof->InheritsFrom(
"TProofOutputFile")) {
2598 Error(
"GetFileFromWrapper",
"TProofOutputFile object not found in output list for file %s", filename);
2601 gROOT->ProcessLine(Form(
"sprintf((char*)%p, \"%%s\", ((TProofOutputFile*)%p)->GetOutputFileName());", fullPath, pof));
2602 gROOT->ProcessLine(Form(
"sprintf((char*)%p, \"%%s\", gProof->GetUrl());",chUrl));
2603 TString clientUrl(chUrl);
2604 TString fullPath_str(fullPath);
2605 if (clientUrl.Contains(
"localhost")){
2607 TObjString *strobj = ( TObjString *)array->At(1);
2608 TObjArray* arrayPort = strobj->GetString().Tokenize (
":" );
2609 TObjString *strobjPort = ( TObjString *) arrayPort->At(1);
2610 fullPath_str.ReplaceAll(strobj->GetString().Data(),
"localhost:PORT");
2611 fullPath_str.ReplaceAll(
":PORT",Form(
":%s",strobjPort->GetString().Data()));
2612 if (
fDebug > 1) Info(
"GetFileFromWrapper",
"Using tunnel from %s to %s",fullPath_str.Data(),filename);
2616 else if (clientUrl.Contains(
"__lite__")) {
2618 gROOT->ProcessLine(Form(
"sprintf((char*)%p,\"%%s\",((TProofOutputFile*)%p)->GetDir());", tmp, pof));
2619 fullPath_str.Form(
"%s/%s", tmp, fullPath);
2622 Info(
"GetFileFromWrapper",
"Copying file %s from PROOF scratch space to %s", fullPath_str.Data(),filename);
2623 Bool_t gotit = TFile::Cp(fullPath_str.Data(), filename);
2625 Error(
"GetFileFromWrapper",
"Could not get file %s from proof scratch space", filename);
2656 TDirectory *cdir = gDirectory;
2657 TString openedFiles;
2661 if (filename ==
"default") {
2665 if (gSystem->AccessPathName(filename))
continue;
2668 if (openedFiles.Contains(filename))
continue;;
2669 TFile *file = (TFile*)
gROOT->GetListOfFiles()->FindObject(filename);
2671 Warning(
"ValidateOutputs",
"File %s was not closed. Closing.", filename.Data());
2677 if (!file || file->IsZombie() || file->TestBit(TFile::kRecovered)) {
2678 Error(
"ValidateOutputs",
"Output file <%s> was not created or invalid", filename.Data());
2679 if (cdir) cdir->cd();
2683 openedFiles += filename;
2686 if (cdir) cdir->cd();
2695 static Long64_t icount = 0;
2696 static TString
oname;
2697 static TString nname;
2698 static Long64_t ocurrent = 0;
2699 static Long64_t osize = 0;
2700 static Int_t oseconds = 0;
2701 static TStopwatch *owatch = 0;
2702 static Bool_t oneoftwo = kFALSE;
2703 static Int_t nrefresh = 0;
2704 static Int_t nchecks = 0;
2705 static char lastChar = 0;
2706 const char symbol[4] = {
'-',
'\\',
'|',
'/'};
2708 if (!lastChar) lastChar = (
IsPipe(std::cerr))?
'\r':
'\n';
2714 ocurrent = TMath::Abs(current);
2715 osize = TMath::Abs(size);
2716 if (ocurrent > osize) ocurrent=osize;
2723 char progress[11] =
" ";
2724 Int_t ichar = icount%4;
2729 if (owatch && !last) {
2731 time = owatch->RealTime();
2732 seconds = int(time) % 60;
2733 minutes = (int(time) / 60) % 60;
2734 hours = (int(time) / 60 / 60);
2736 if (oseconds==seconds) {
2740 oneoftwo = !oneoftwo;
2744 if (refresh && oneoftwo) {
2746 if (nchecks <= 0) nchecks = nrefresh+1;
2747 Int_t pctdone = (Int_t)(100.*nrefresh/nchecks);
2748 oname.Form(
" == %d%% ==", pctdone);
2750 Double_t percent = 100.0*ocurrent/osize;
2751 Int_t nchar = Int_t(percent/10);
2752 if (nchar>10) nchar=10;
2754 for (i=0; i<nchar; i++) progress[i] =
'=';
2755 progress[nchar] = symbol[ichar];
2756 for (i=nchar+1; i<10; i++) progress[i] =
' ';
2757 progress[10] =
'\0';
2760 if(size<10000) fprintf(stderr,
"%s [%10s] %4lld ", oname.Data(), progress, ocurrent);
2761 else if(size<100000) fprintf(stderr,
"%s [%10s] %5lld ",oname.Data(), progress, ocurrent);
2762 else fprintf(stderr,
"%s [%10s] %7lld ",oname.Data(), progress, ocurrent);
2764 Int_t full = Int_t(ocurrent > 0 ?
2765 time * (
float(osize)/ocurrent) + .5 :
2767 Int_t remain = Int_t(full - time);
2768 Int_t rsec = remain % 60;
2769 Int_t rmin = (remain / 60) % 60;
2770 Int_t rhour = (remain / 60 / 60);
2771 fprintf(stderr,
"[%6.2f %%] TIME %.2d:%.2d:%.2d ETA %.2d:%.2d:%.2d%c",
2772 percent, hours, minutes, seconds, rhour, rmin, rsec, lastChar);
2774 else fprintf(stderr,
"[%6.2f %%]%c", percent, lastChar);
2775 if (refresh && oneoftwo) oname = nname;
2776 if (owatch) owatch->Continue();
2785 fprintf(stderr,
"\n");
2794 static Long64_t crtEntry = -100;
2799 TBranch *br =
dynamic_cast<TBranch*
>(
fTable.FindObject(name));
2801 br =
fTree->GetBranch(name);
2803 Error(
"DoLoadBranch",
"Could not find branch %s",name);
2811 Error(
"DoLoadBranch",
"Could not load entry %lld from branch %s",
GetCurrentEntry(), name);
2830 Info(
"AddStatisticsTask",
"Already added");
2834 line.Form(
"AliAnalysisTaskStat::AddToManager(%u);", offlineMask);
2835 gROOT->ProcessLine(line);
2857 if (!strlen(line))
return;
2867 static Bool_t done = kFALSE;
2889 static TString oadbPath;
2891 if (gSystem->Getenv(
"OADB_PATH"))
2892 oadbPath = gSystem->Getenv(
"OADB_PATH");
2893 else if (gSystem->Getenv(
"ALICE_PHYSICS"))
2894 oadbPath.Form(
"%s/OADB", gSystem->Getenv(
"ALICE_PHYSICS"));
2896 ::Fatal(
"AliAnalysisManager::GetOADBPath",
"Cannot figure out AODB path. Define ALICE_PHYSICS or OADB_PATH!");
2912 Bool_t valid = kFALSE;
2915 ::Error(
"AliAnalysisManager::SetGlobalStr",
"Global %s = %s already defined.", key, existing.Data());
2918 mgr->
GetGlobals()->Add(
new TObjString(key),
new TObjString(value));
2929 TObject *value = mgr->
GetGlobals()->GetValue(key);
2930 if (!value)
return 0;
2932 return value->GetName();
2946 Bool_t valid = kFALSE;
2949 ::Error(
"AliAnalysisManager::SetGlobalInt",
"Global %s = %i already defined.", key, existing);
2952 mgr->
GetGlobals()->Add(
new TObjString(key),
new TObjString(TString::Format(
"%i",value)));
2963 TObject *value = mgr->
GetGlobals()->GetValue(key);
2964 if (!value)
return 0;
2966 TString s = value->GetName();
2981 Bool_t valid = kFALSE;
2984 ::Error(
"AliAnalysisManager::SetGlobalInt",
"Global %s = %g already defined.", key, existing);
2987 mgr->
GetGlobals()->Add(
new TObjString(key),
new TObjString(TString::Format(
"%f.16",value)));
2998 TObject *value = mgr->
GetGlobals()->GetValue(key);
2999 if (!value)
return 0;
3001 TString s = value->GetName();
3015 TNamed *debugOpt = (TNamed*)
fDebugOptions->FindObject(className);
3017 AliInfo(TString::Format(
"Adding debug level %d for class %s",debugLevel,className).Data());
3018 fDebugOptions->Add(
new TNamed(className,TString::Format(
"%d",debugLevel).Data()));
3020 TString oldDebugStr = debugOpt->GetTitle();
3021 Int_t oldDebug = oldDebugStr.Atoi();
3022 if (debugLevel > oldDebug) {
3023 AliWarning(TString::Format(
"Overwriting debug level to %d class %s, because it is higher then previously set (%d).",debugLevel,className,oldDebug).Data());
3024 debugOpt->SetTitle(TString::Format(
"%d",debugLevel).Data());
3026 AliWarning(TString::Format(
"Ignoring debug level to %d class %s, because it is smaller then previously set (%d).",debugLevel,className,oldDebug).Data());
3041 while ((debug=dynamic_cast<TNamed*>(next()))) {
3042 debugLevel = debug->GetTitle();
3043 AliInfo(TString::Format(
"Class=%s debulLevel=%d",debug->GetName(),debugLevel.Atoi()).Data());
3062 TString macroName = gSystem->BaseName(filename);
3064 Int_t index = macroName.Index(
"+");
3065 if (index>0) macroName.Remove(index);
3072 Int_t ret =
gROOT->LoadMacro(filename,error,check);
3074 if (ret)
return ret;
3092 Info(
"Lock",
"====== ANALYSIS MANAGER LOCKED ======");
3105 Info(
"UnLock",
"====== ANALYSIS MANAGER UNLOCKED ======");
3114 if (
fLocked) Fatal(
"Changed",
"Critical setter called in locked mode");
3127 if (classInputHandler.Contains(
"HLT")){
3135 Fatal(
"PropagateHLTEvent",
"Input Handler not of type HLT, we cannot use this method!");
3139 Fatal(
"PropagateHLTEvent",
"Input Handler not found, we cannot use this method!");
Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot, AliAnalysisDataContainer *cont)
AliAnalysysTask - Class representing a basic analysis task. Any user-defined task should derive from...
Bool_t GetFileFromWrapper(const char *filename, const TList *source)
TObjArray * fContainers
List of all containers.
AliAnalysisFileDescriptor * fCurrentDescriptor
! Current file descriptor
void InputFileFromTree(TTree *const tree, TString &fname)
AliAnalysisDataWrapper * ExportData() const
Wrapping.
TFile * OpenProofFile(AliAnalysisDataContainer *cont, const char *option, const char *extaod="")
virtual void Terminate(Option_t *option="")
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
virtual Bool_t StartAnalysis(Long64_t nentries=123456789, Long64_t firstentry=0)=0
TFile * Open(const char *filename, Long64_t &nevents)
virtual Bool_t Process(Long64_t entry)
void CheckNotify(Bool_t init=kFALSE)
static Int_t GetRunFromAlienPath(const char *path)
Bool_t HasBranches() const
void SetEventLoop(Bool_t flag=kTRUE)
void PrintStatus(Option_t *option="all") const
Bool_t CheckCircularDeps()
void WriteStatisticsMsg(Int_t nevents)
virtual void FinishTaskOutput()
AliAnalysisTask * GetTask(const char *name) const
static Int_t LoadMacro(const char *filename, Int_t *error=0, Bool_t check=kFALSE)
static TFile * OpenFile(AliAnalysisDataContainer *cont, const char *option, Bool_t ignoreProof=kFALSE)
static void SetGlobalLogLevel(EType_t type)
static TString fgMacroNames
! Loaded macro names
Bool_t fIsRemote
! Flag is set for remote analysis
void AddStatisticsTask(UInt_t offlineMask=0)
void SetDataOwned(Bool_t flag)
virtual TChain * GetNextChain()=0
void GetAnalysisTypeString(TString &type) const
virtual EPluginRunMode GetRunMode() const
Int_t fNcalls
Total number of calls (events) of ExecAnalysis.
static AliAnalysisManager * GetAnalysisManager()
static void SetClassDebugLevel(const char *className, Int_t level)
EAliAnalysisExecMode fMode
Execution mode.
TObject * GetData() const
Getters.
AliAnalysysManager Manager analysis class. Allows creation of several analysis tasks and data contain...
TString fStatisticsMsg
Statistics user message.
void DoLoadBranch(const char *name)
void SetSpecialOutput(Bool_t flag=kTRUE)
AliAnalysisTask * GetProducer() const
AliVEventHandler * fInputEventHandler
Optional common input event handler.
THashTable fTable
keep branch ptrs in case of manual branch loading
void PrintContainer(Option_t *option="all", Int_t indent=0) const
Print connected tasks/status.
virtual Bool_t Init(TTree *tree)
static void SetGlobalDbl(const char *key, Double_t value)
Long64_t GetNaccepted() const
TObjArray * GetConsumers() const
static const char * GetGlobalStr(const char *key, Bool_t &valid)
TObjArray * fTasks
List of analysis tasks.
void UnpackOutput(TList *source)
virtual Bool_t NotifyBinChange()
Long64_t GetNprocessed() const
static const char * GetMaskAsString(UInt_t mask)
virtual Bool_t TerminateIO()=0
UInt_t fDebug
Debug level.
static TTree * MakeTree(const char *lname, const char *fout=0)
virtual Bool_t FinishEvent()=0
AliAnalysysDataContainer AliAnalysysDataContainer - Container of data of arbitrary type deriving from...
Bool_t ClientsExecuted() const
Bool_t IsCollectThroughput()
void AddAccepted(Int_t nevents=1)
void SetZombie(Bool_t flag=kTRUE)
TMap * fGlobals
Map with global variables.
TStopwatch * fCPUTimer
! Timer for useful processing
TString fRequestedBranches
Requested branch names.
void AddFailed(Int_t nevents=1)
EAliAnalysisExecMode GetAnalysisType() const
#define AliWarning(message)
virtual TChain * GetChainForTestMode(const char *treeName) const =0
static TString fgCommonFileName
! Common output file name (not streamed)
Bool_t IsPostEventLoop() const
TObjArray * GetTasks() const
virtual void CreateOutputObjects()
AliAnalysisDataContainer * fCommonOutput
Common output container.
AliVEventPool * fEventPool
Event pool for mixing analysis.
Long64_t StartAnalysis(const char *type, TTree *const tree, Long64_t nentries=1234567890, Long64_t firstentry=0)
void RegisterExtraFile(const char *fname)
virtual Option_t * GetDataType() const
virtual void SetFriendEvent(AliVfriendEvent *)
Bool_t ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont)
void SetDebugLevel(UInt_t level)
Int_t GetTaskIndex(const AliAnalysisTask *task) const
AliAnalysisSelector * fSelector
! Current selector
#define AliErrorClass(message)
Bool_t HasConsumers() const
virtual void SetInputTree(TTree *tree)=0
Double_t fInitTime
! Cumulated time in initialization
TTree * fTree
! Input tree in case of TSelector model
virtual Bool_t BeginEvent(Long64_t entry)=0
void AddBranches(const char *branches)
AliAnalysisManager & operator=(const AliAnalysisManager &other)
AliAnalysisManager(const char *name="mgr", const char *title="")
virtual void SlaveBegin(TTree *tree)
void ImportData(AliAnalysisDataWrapper *pack)
Bool_t IsDataReady() const
Container status checking.
virtual TTree * GetTree() const
static void SetGlobalStr(const char *key, const char *value)
Long64_t GetNfailed() const
virtual TString GetProofProcessOpt()=0
Bool_t ValidateOutputFiles() const
TStopwatch * fInitTimer
! Timer for initialization
Bool_t IsExternalLoop() const
void SetOutputEventHandler(AliVEventHandler *const handler)
void AddInput(Int_t nevents=1)
void PackOutput(TList *target)
virtual const char * GetExtraOutputs(Bool_t merge=kFALSE) const
void SetUseProgressBar(Bool_t flag, Int_t freq=1)
TObjArray * fZombies
List of zombie tasks.
TObjArray * fOutputs
List of containers with results.
AliAnalysisSelector Transparent selector class instantiated by an analysis manager object...
void SetInputEventHandler(AliVEventHandler *const handler)
void ExecAnalysis(Option_t *option="")
Bool_t ConnectInput(Int_t islot, AliAnalysisDataContainer *cont)
Long64_t fNSysInfo
Event frequency for collecting system information.
Double_t fIOTime
! Cumulated time in IO
Bool_t fInitOK
Initialisation done.
void StartTimer(Int_t itask, const char *name, const char *classname="")
static Bool_t IsMacroLoaded(const char *filename)
static void SetVerbose(Bool_t v=kFALSE)
static AliAnalysisManager * fgAnalysisManager
! static pointer to object instance
Bool_t IsPostEventLoop() const
static Int_t fPBUpdateFreq
Progress bar update freq.
static void SetGlobalInt(const char *key, Int_t value)
TString fSpecialOutputLocation
URL/path where the special outputs will be copied.
TObjArray * fTopTasks
List of top tasks.
TStopwatch * fIOTimer
! Timer for I/O + deserialization
AliVEventHandler * fMCtruthEventHandler
Optional common MC Truth event handler.
AliAnalysisStatistics * fStatistics
Statistics info about input events.
void AddProcessed(Int_t nevents=1)
void AddClassDebug(const char *className, Int_t debugLevel)
void ProfileTask(const char *name, const char *option="VM") const
AliAnalysisDataContainer * fCommonInput
Common input container.
void SetDeleteData(Bool_t flag=kTRUE)
Bool_t fLocked
! Lock for the manager and handlers
AliAnalysisDataSlot * GetInputSlot(Int_t islot) const
static const char * GetOADBPath()
Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot, AliAnalysisDataContainer *cont)
static Double_t GetGlobalDbl(const char *key, Bool_t &valid)
const char * GetFolderName() const
AliAnalysisGrid * fGridHandler
! Grid handler plugin
void GetBranches(const char *type, TString &result) const
virtual void SetInputFileName(const char *)
void SetPostEventLoop(Bool_t flag=kTRUE)
Bool_t IsSkipTerminate() const
virtual Bool_t Terminate()=0
virtual Bool_t MergeOutputs()=0
TObjArray * fFileDescriptors
! List of file descriptors
void AddTask(AliAnalysisTask *task)
TString fExtraFiles
List of extra files to be merged.
void AddStatisticsMsg(const char *line)
void SetUsed(Bool_t flag=kTRUE)
Bool_t fAsyncReading
Enable async reading.
TObjArray * fExchangeCont
List of exchange containers.
virtual Bool_t Notify(const char *path)=0
virtual Bool_t InitTaskInputData(AliVEvent *, AliVfriendEvent *, TObjArray *)
virtual Bool_t CheckPostData() const
virtual Bool_t Init(Option_t *opt)=0
Bool_t IsSpecialOutput() const
const char * GetFileName() const
virtual const char * GetOutputFileName() const =0
TObjArray * fParamCont
List of containers with parameters.
void ImportWrappers(TList *source)
Bool_t fAutoBranchHandling
def=kTRUE, turn off if you use LoadBranch
void SetFileName(const char *filename)
Long64_t GetCurrentEntry() const
static void ProgressBar(const char *opname, Long64_t current, Long64_t size, TStopwatch *const watch=0, Bool_t last=kFALSE, Bool_t refresh=kFALSE)
void SetExternalLoop(Bool_t flag)
AliAnalysisDataContainer * GetContainer() const
TObjArray * fDebugOptions
List of debug options.
Long64_t fMaxEntries
Maximum number of entries.
virtual Bool_t SetData(TObject *data, Option_t *option="")
void SetExchange(Bool_t flag)
Bool_t IsRegisterDataset() const
static void AddStamp(const char *sname, Int_t id0=-1, Int_t id1=-1, Int_t id2=-1, Int_t id3=-1)
Long64_t GetNinput() const
AliVEventHandler * fOutputEventHandler
Optional common output event handler.
Bool_t IsTrainInitialized() const
TObjArray * fInputs
List of containers with input data.
Long64_t fCacheSize
Cache size in bytes.
Double_t fCPUTime
! Cumulated time in Exec
virtual AliVEvent * GetEvent() const
virtual void SetCacheSize(Long64_t)
TString fFileInfoLog
File name for fileinfo logs.
virtual void AdjustMCLabels(const AliVEvent *)
Bool_t EventLoop(Long64_t nevents)
Long64_t fCurrentEntry
! Current processed entry in the tree
UInt_t GetOfflineMask() const
virtual const char * GetProofDataSet() const =0
virtual ~AliAnalysisManager()
void InitInputData(AliVEvent *esdEvent, AliVfriendEvent *esdFriend)
Bool_t fMCLoop
External MC generator loop.
void SetTouched(Bool_t flag=kTRUE)
static Bool_t IsPipe(std::ostream &out)
Bool_t IsOwnedData() const
Int_t fRunFromPath
Run number retrieved from path to input data.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
static Int_t GetGlobalInt(const char *key, Bool_t &valid)
Bool_t CheckTasks() const
AliAnalysisDataContainer * CreateContainer(const char *name, TClass *datatype, EAliAnalysisContType type=kExchangeContainer, const char *filename=NULL)
void CheckBranches(Bool_t load=kFALSE)
void CountEvent(Int_t ninput, Int_t nprocessed, Int_t nfailed, Int_t naccepted)