copy TRD performance train to PWG1
[u/mrichter/AliRoot.git] / PWG1 / TRD / macros / makeCalibResults.C
CommitLineData
1ee39b3a 1// Usage:
2// makeCalibResults.C("task", "file_list", kGRID)
3// tasks : "one/more of the following separated by space:
4// "CAL" : TRD calibration
5// "ALGN" : TRD alignment
6// "PIDR" : TRD PID - reference data
7// "CLRES": Cluster position and error parameterization
8// "NOFR" : Data set does not have AliESDfriends.root
9// "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely
10// on MC information are switched off
11// file_list : is the list of the files to be processed.
12// They should contain the full path. Here is an example:
13// /lustre/alice/local/TRDdata/SIM/P-Flat/TRUNK/RUN0/TRD.CalibName.root
14// or for GRID alien:///alice/cern.ch/user/m/mfasel/MinBiasProd/results/ppMinBias80000/1/TRD.Calib%.root
15// kGRID : specify if files are comming from a GRID collection [default kFALSE]
16//
17// HOW TO BUILD THE FILE LIST
18// 1. locally
19// ls -1 BaseDir/RUN*/TRD.Calib*.root > files.lst
20//
21// 2. on Grid
22// char *BaseDir="/alice/cern.ch/user/m/mfasel/MinBiasProd/results/ppMinBias80000/";
23// TGrid::Connect("alien://");
24// TGridResult *res = gGrid->Query(BaseDir, "%/TRD.Calib%.root");
25// TGridCollection *col = gGrid->OpenCollectionQuery(res);
26// col->Reset();
27// TMap *map = 0x0;
28// while(map = (TMap*)col->Next()){
29// TIter it((TCollection*)map);
30// TObjString *info = 0x0;
31// while(info=(TObjString*)it()){
32// printf("alien://%s\n", col->GetLFN(info->GetString().Data()));
33// }
34// }
35//
36// The files which will be processed are the intersection between the
37// condition on the tasks and the files in the file list.
38//
39// In compiled mode :
40// Don't forget to load first the libraries
41// gSystem->Load("libMemStat.so")
42// gSystem->Load("libMemStatGui.so")
43// gSystem->Load("libANALYSIS.so")
44// gSystem->Load("libANALYSISalice.so")
45// gSystem->Load("libTRDqaRec.so")
46// gSystem->Load("libSTAT.so")
47// gSystem->Load("libPWG1.so");
48// gSystem->Load("libNetx.so") ;
49// gSystem->Load("libRAliEn.so");
50//
51// Authors:
52// Alex Bercuci (A.Bercuci@gsi.de)
53// Markus Fasel (m.Fasel@gsi.de)
54//
55
56#if ! defined (__CINT__) || defined (__MAKECINT__)
57
58#include "qaRec/AliTRDrecoTask.h"
59#include <fstream>
60#include <TCanvas.h>
61#include <TStyle.h>
62#include <TGrid.h>
63#include <TGridResult.h>
64#include <TGridCollection.h>
65
66#endif
67
68#include "AliTRDperformanceTrain.h"
69#include "helper.C"
70//#include "../../PWG1/macros/AddPerformanceTask.h"
71
72Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so", "libSTAT.so"};
73// define setup
74TCanvas *c = 0x0;
75Bool_t mc(kFALSE), friends(kFALSE);
76
77void calibrateTRD(TNamed* task, Int_t itask);
78void makeCalibResults(Char_t *opt, const Char_t *files=0x0, Bool_t kGRID=kFALSE)
79{
80 if(kGRID){
81 if(!gSystem->Getenv("GSHELL_ROOT")){
82 Error("makeCalibResults.C", "AliEn not initialized.");
83 return;
84 }
85 TGrid::Connect("alien://");
86 }
87
88 // Load Libraries in interactive mode
89 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
90 for(Int_t ilib=0; ilib<nlibs; ilib++){
91 if(gSystem->Load(libs[ilib]) >= 0) continue;
92 Error("makeCalibResults.C", Form("Failed to load %s.", libs[ilib]));
93 return;
94 }
95
96 mc = HasReadMCData(opt);
97 friends = HasReadFriendData(opt);
98
99 gStyle->SetOptStat(0);
100 gStyle->SetOptFit(0);
101 Int_t fSteerTask = ParseOptions(opt);
102
103 if(!c) c=new TCanvas("c", "Calibration", 10, 10, 800, 500);
104
105 TClass *ctask = new TClass;
106 AliAnalysisTask *task = 0x0;
107 for(Int_t itask = NTRDQATASKS; itask<NTRDTASKS; itask++){
108 if(!TSTBIT(fSteerTask, itask)) continue;
109 new(ctask) TClass(fgkTRDtaskClassName[itask]);
110 task = (AliAnalysisTask*)ctask->New();
111 if(files) mergeProd(Form("TRD.Calib%s.root", task->GetName()), files);
112
113 if(task->IsA()->InheritsFrom("AliTRDrecoTask")) calibrateTRD(task, itask);
114 }
115 delete ctask;
116 delete c;
117}
118
119
120//______________________________________________________
121void calibrateTRD(TNamed *otask, Int_t itask)
122{
123 AliTRDrecoTask *task = dynamic_cast<AliTRDrecoTask*>(otask);
124 task->SetDebugLevel(0);
125
126 AliLog::SetClassDebugLevel(fgkTRDtaskClassName[itask], 3);
127 task->SetMCdata(mc);
128 task->SetFriends(friends);
129
130 if(!task->PostProcess()){
131 Error("makeCalibResults.C", Form("Processing data container for task %s failed.", task->GetName()));
132 delete task;
133 return;
134 }
135 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
136 c->Clear();
137 if(!task->GetRefFigure(ipic)) continue;
138 c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic));
139 }
140 delete task;
141}
142