+// Usage:
+// makeResults.C("tasks?file_list")
+// tasks : "ALL" or one/more of the following separated by space:
+// "EFF" : TRD Tracking Efficiency
+// "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations
+// "RES" : TRD tracking Resolution
+// "CAL" : TRD calibration
+// "PID" : TRD PID - pion efficiency
+// "PIDR" : TRD PID - reference data
+// "DET" : Basic TRD Detector checks
+// "NOFR" : Data set does not have AliESDfriends.root
+// "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely
+// on MC information are switched off
+// file_list : is the list of the files to be processed.
+// They should contain the full path. Here is an example:
+// /lustre_alpha/alice/TRDdata/HEAD/1.0GeV/RUN0/TRD.TaskResolution.root
+// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN1/TRD.TaskResolution.root
+// /lustre_alpha/alice/TRDdata/HEAD/3.0GeV/RUN2/TRD.TaskResolution.root
+// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN0/TRD.TaskDetChecker.root
+// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN1/TRD.TaskDetChecker.root
+// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN2/TRD.TaskDetChecker.root
+// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN0/TRD.TaskTrackingEff.root
+//
+// The files which will be processed are the initersaction between the
+// condition on the tasks and the files iin the file list.
+//
+// Authors:
+// Alex Bercuci (A.Bercuci@gsi.de)
+// Markus Fasel (m.Fasel@gsi.de)
+//
+
#if ! defined (__CINT__) || defined (__MAKECINT__)
+#include <fstream>
#include "TError.h"
#include <TClass.h>
#include <TFileMerger.h>
#include <TGraph.h>
#include <TObjArray.h>
#include <TObjString.h>
-#include <TPython.h>
#include <TString.h>
#include <TROOT.h>
#include <TSystem.h>
#include "run.h"
-Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so", "libPyROOT"};
+Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so"};
-void makeResults(Char_t *tasks = "ALL", Char_t* dir=0x0)
+void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0)
{
// Load Libraries in interactive mode
Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
// select tasks to process; we should move it to an
// individual function and move the task identifiers
// outside the const space
- TObjArray *tasksArray = TString(tasks).Tokenize(" ");
+ TString tasks(opt);
+ TObjArray *tasksArray = tasks.Tokenize(" ");
Int_t fSteerTask = 0;
for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
if(s.CompareTo("ALL") == 0){
- for(Int_t itask = 1; itask < fknTasks; itask++) SETBIT(fSteerTask, itask);
+ for(Int_t itask = 1; itask < NQATASKS; itask++) SETBIT(fSteerTask, itask);
continue;
} else if(s.CompareTo("NOFR") == 0){
friends = kFALSE;
mc = kFALSE;
} else {
Bool_t foundOpt = kFALSE;
- for(Int_t itask = 1; itask < fknTasks; itask++){
- if(s.CompareTo(fTaskOpt[itask]) != 0) continue;
+ for(Int_t itask = 1; itask < NTRDTASKS; itask++){
+ if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
SETBIT(fSteerTask, itask);
foundOpt = kTRUE;
break;
if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
}
}
-
-
- // catch the list of files using the ROOT Python Interface
- TPython *pyshell = new TPython();
- pyshell->Exec("import commands");
+ // extra rules for calibration tasks
+ if(TSTBIT(fSteerTask, kClErrParam)) SETBIT(fSteerTask, kResolution);
+ if(TSTBIT(fSteerTask, kPIDRefMaker)) SETBIT(fSteerTask, kPIDChecker);
+ if(TSTBIT(fSteerTask, kAlignment)) SETBIT(fSteerTask, kResolution);
// file merger object
- TFileMerger *fFM = new TFileMerger();
- TClass *ctask = 0x0;
- TObject *o = 0x0;
- TObjArray *fContainer = 0x0;
+ TFileMerger *fFM = 0x0;
+ TClass *ctask = new TClass;
AliTRDrecoTask *task = 0x0;
+ Int_t nFiles;
if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
- printf("\n\tPROCESSING DATA FOR TASKS [%b]:\n", fSteerTask);
- for(Int_t itask = 1; itask <fknTasks; itask++){
- if(!TESTBIT(fSteerTask, itask)) continue;
+ for(Int_t itask = 1; itask<NTRDTASKS; itask++){
+ if(!TSTBIT(fSteerTask, itask)) continue;
- ctask = new TClass(fTaskClass[itask]);
+ new(ctask) TClass(fgkTRDtaskClassName[itask]);
task = (AliTRDrecoTask*)ctask->New();
task->SetDebugLevel(0);
task->SetMCdata(mc);
task->SetFriends(friends);
- printf("\t%s [%s]\n", task->GetTitle(), task->GetName());
// setup filelist
- TString pathname = gSystem->ExpandPathName( dir ? dir : "$PWD");
- TString filestring((const Char_t*) pyshell->Eval(Form("commands.getstatusoutput(\"find %s | grep TRD.Task%s.root\")[1]", pathname.Data(), task->GetName())));
- TObjArray *filenames = filestring.Tokenize("\n");
- Int_t nFiles = filenames->GetEntriesFast();
+ nFiles = 0;
+ TString mark(Form("%s.root", task->GetName()));
+ string filename;
+ if(files){
+ ifstream filestream(files);
+ while(getline(filestream, filename)){
+ if(Int_t(filename.find(mark.Data())) < 0) continue;
+ nFiles++;
+ }
+ } else {
+ nFiles = !gSystem->AccessPathName(Form("TRD.Task%s.root", task->GetName()));
+ }
+
if(!nFiles){
- printf("No Files found for Task %s\n", task->GetName());
+ Info("makeResults.C", Form("No Files found for Task %s", task->GetName()));
delete task;
- delete ctask;
continue;
}
+ Info("makeResults.C", Form(" Processing %d files for task %s ...", nFiles, task->GetName()));
- if(nFiles>1){
- fFM = new(fFM) TFileMerger(kTRUE);
+ if(files){
+ fFM = new TFileMerger(kTRUE);
fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
- for(Int_t ifile = 0; ifile < nFiles; ifile++){
- TString filename = (dynamic_cast<TObjString *>(filenames->UncheckedAt(ifile)))->String();
- if(filename.Contains("merge")) continue;
- //printf("\tProcessing %s ...\n", filename.Data());
- fFM->AddFile(filename.Data());
+
+ ifstream file(files);
+ while(getline(file, filename)){
+ if(Int_t(filename.find(mark.Data())) < 0) continue;
+ fFM->AddFile(filename.c_str());
}
fFM->Merge();
- fFM->~TFileMerger();
- task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
- } else task->Load((dynamic_cast<TObjString *>(filenames->UncheckedAt(0)))->String().Data());
+ delete fFM;
+ if(!task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
+ delete task;
+ break;
+ }
+ } else{
+ if(!task->Load(Form("%s/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
+ delete task;
+ break;
+ }
+ }
- if(!(fContainer = task->Container())) {
- delete task;
- delete ctask;
- continue;
- }
-
+ printf("Processing ...\n");
task->PostProcess();
+ TCanvas *c=new TCanvas();
for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
- TCanvas *c = new TCanvas("c", "", 500, 500);
- Int_t ifirst, ilast; Option_t *opt;
- TH1 *h = 0x0; TGraph *g = 0x0;
- task->GetRefFigure(ipic, ifirst, ilast, opt);
- if(!(o = fContainer->At(ifirst))) continue;
-
- if(o->InheritsFrom("TH1")){
- h = dynamic_cast<TH1*>(o);
- h->Draw(opt);
- } else if(o->InheritsFrom("TGraph")){
- g = dynamic_cast<TGraph*>(o);
- g->Draw(Form("a%s", opt));
- } else{
- printf("No idea how to plot object of type %s.\n", o->IsA()->GetName());
- printf("Please teach me.\n");
- continue;
- }
-
- for(Int_t ig=ifirst+1; ig<ilast; ig++){
- if(!(o = fContainer->At(ig))) continue;
- if(o->InheritsFrom("TH1")){
- h = dynamic_cast<TH1*>(o);
- h->Draw(Form("%ssame", opt));
- } else if(o->InheritsFrom("TGraph")){
- g = dynamic_cast<TGraph*>(o);
- g->Draw(opt);
- }
- }
+ if(!task->GetRefFigure(ipic)) continue;
c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
- delete c;
+ c->Clear();
}
+ delete c;
delete task;
- delete ctask;
}
- delete pyshell;
+ delete ctask;
}