]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TRD/macros/makeCalibResults.C
update to AliTRDpwg1Helper class by Markus
[u/mrichter/AliRoot.git] / PWG1 / TRD / macros / makeCalibResults.C
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("libTENDER.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 "AliLog.h"
59 #include "PWG1/TRD/AliTRDrecoTask.h"
60 #include <fstream>
61 #include <TCanvas.h>
62 #include <TStyle.h>
63 #include <TGrid.h>
64 #include <TGridResult.h>
65 #include <TGridCollection.h>
66
67 #endif
68
69 Char_t const *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libSTAT.so", "libPWG1.so"};
70
71 // define setup
72 TClass *ctask = new TClass;
73 TCanvas *c(NULL);
74 Bool_t fMC(kFALSE), fFriends(kFALSE);
75 Char_t const *fFiles(NULL);
76
77 void calibrateTRD(Int_t itask, Char_t const* ntask=NULL, Char_t const* nfile=NULL);
78 void makeCalibResults(Char_t *opt, Char_t const *files=NULL, 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   fMC = HasReadMCData(opt);
97   fFriends = HasReadFriendData(opt);
98   fFiles = files;
99
100   gStyle->SetOptStat(0);
101   gStyle->SetOptFit(0);
102   Int_t fSteerTask = ParseOptions(opt);
103
104   if(!c) c=new TCanvas("c", "Calibration", 10, 10, 800, 500);
105
106   for(Int_t itask = AliTRDpwg1Helper::kNTRDQATASKS; itask<AliTRDpwg1Helper::NTRDTASKS; itask++){
107     if(!TESTBIT(fSteerTask, itask)) continue;
108     switch(itask){
109     case AliTRDpwg1Helper::kPIDRefMaker:
110       calibrateTRD(itask, "AliTRDpidRefMakerLQ", "PIDrefMaker");
111       //calibrateTRD(itask, "AliTRDpidRefMakerNN", "PIDrefMaker");
112       break;
113     default:
114       calibrateTRD(itask);
115       break;
116     }
117   }
118   delete ctask;
119   delete c;
120 }
121
122
123 //______________________________________________________
124 void calibrateTRD(Int_t itask, Char_t const* ntask, Char_t const* nfile)
125 {
126   if(!ntask) ntask=AliTRDpwg1Helper::fgkTRDtaskClassName[itask];
127   new(ctask) TClass(ntask);
128   if(!ctask){
129     Error("makeCalibResults.C", Form("Asking for wrong class name [%s].", ntask));
130     return;
131   }
132   AliTRDrecoTask *task = static_cast<AliTRDrecoTask*>(ctask->New());
133   if(!task){
134     Error("makeCalibResults.C", Form("Class name [%s] does not inherit from AliTRDrecoTask.", ntask));
135     return;
136   }
137   if(!nfile) nfile=Form("TRD.Calib%s.root", task->GetName());
138   if(fFiles) mergeProd(Form("TRD.Calib%s.root", nfile), fFiles);
139   task->SetDebugLevel(0);
140   task->SetMCdata(fMC);
141   task->SetFriends(fFriends);
142   AliLog::SetClassDebugLevel(ntask, 3); 
143
144   if(!task->Load(nfile)){
145     Error("makeCalibResults.C", Form("Loading data container for task[%s] failed.", ntask));
146     delete task;
147     return;
148   }
149   if(!task->PostProcess()){
150     Error("makeCalibResults.C", Form("Processing data container for task[%s] failed.", ntask));
151     delete task;
152     return;
153   }
154   for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
155     c->Clear();
156     if(!task->GetRefFigure(ipic)) continue;
157     c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic));
158   }
159   delete task;
160 }
161