AnalyzeLaser renamed to AnalyzeLaserCE (Marian)
[u/mrichter/AliRoot.git] / TPC / CalibMacros / AnalyzeLaserCE.C
CommitLineData
9e7da9da 1/*
2
3Macro to perform fits of the Laser Central electrode data
4Several fit methods implemented
5
60. RebuildCE("ce.root"); - rebuild data from the scratch
7
8
91. RebuildData() - transform arbitrary layout of the Input data to the internal format
10 StoreData(); - The data tree expected in file inname (see variable bellow)
11 StoreTree(); - Modify inname and xxside and tcor in order to transform data
12
13
142. MakeFit(); - Make a fit of the data - already in internal format
15 StoreData(); - Store
16 StoreTree();
17
183. MakeRes(); - Make the final calibration + combination of different components
19
204. LoadViewer(); - Browse the fit parameters
21
22
23.x ~/rootlogon.C
24gSystem->AddIncludePath("-I$ALICE_ROOT/TPC -I$ALICE_ROOT/STAT");
25gSystem->Load("libSTAT.so");
26.L $ALICE_ROOT/TPC/CalibMacros/AnalyzeLaserCE.C+
27// setup aliases
28qaside="CE_Q";
29taside="CE_T";
30raside="CE_RMS";
31qcside="CE_Q";
32tcside="CE_T";
33rcside="CE_RMS";
34
35
36
37
38Calibration viewer variables:
39
40Result - resulting correction
41out - outlyers not used for fit
42tcor - offset specified by user before fitting
43timeF1 - sector local fit - plane
44timeF2 - sector local fit - parabola
45timeIn - input times
46qIn - input charge
47out - outlyers not used for fit
48tcor - offset specified by user before fitting
49timeF1 - sector time local fit - plane
50timeF2 - sector time local fit - parabola
51qF1 - sector q local fit - plane
52qF2 - sector q local fit - parabola
53// fitted values
54//
55ffit0 - base fit
56ffit1 - adding common shifts - alpha dependendent
57ffit2 - adding opposite shifts - alpha dependent
58//
59fGXY - global fit parameter - XY
60fInOut - global fit parameter - inner-outer sector matching
61fLX - global LX dependence
62//
63Gloabl fit o consist of
64-fGXY~-fLX~-fTL~-fOff~:ffit0~
65
66//
67// Control variable - check results
68//
69//
70ffit2~-(timeIn~+tcor~):lx~ - fit value minus input time
71
72result cosntruction:
73(timeF2~-ffit2~+fTL~+fInOut~+tcor~):Result~+tcor~
74//
75timeF2~-Result~:ffit2~-fTL~-fInOut~
76
77
78*/
79#include "TString.h"
80#include "TSystem.h"
81#include "TTree.h"
82#include "TStatToolkit.h"
83#include "AliTPCCalibViewer.h"
84#include "AliTPCCalibViewerGUI.h"
85#include "AliTPCPreprocessorOnline.h"
86#include "AliTPCCalibCE.h"
87//
88//Define interesting variables - file names
89//
90char * inname = "treeCE.root"; // input file with tree
91//
92// variable name definition in input tree - change it according the input
93//
94TString qaside("CE_A00_Q_05");
95TString taside("CE_A00_T_05");
96TString raside("CE_A00_rms_05");
97TString qcside("CE_C00_Q_05");
98TString tcside("CE_C00_T_05");
99TString rcside("CE_C00_rms_05");
100//
101// correction variable - usually Pulser time
102//
103TString tcor("(sector%36>30)*2");
104
105//
106char * fname = "treefitCE.root"; // output file with tree
107char * oname = "fitCE.root"; // output file with CalPads fit
108
109//
110//
111// Input CalPads
112//
113AliTPCCalPad *calPadIn = 0; // original time pad
114AliTPCCalPad *calPadF1 = 0; // original time pad - fit plane
115AliTPCCalPad *calPadF2 = 0; // original time pad - fit parabola
116AliTPCCalPad *calPadQIn = 0; // original Q pad
117AliTPCCalPad *calPadQF1 = 0; // original Q pad
118AliTPCCalPad *calPadQF2 = 0; // original Q pad
119
120AliTPCCalPad *calPadCor = 0; // base correction CalPad
121AliTPCCalPad *calPadOut = 0; // outlyer CalPad
122//
123// cuts
124//
125const Float_t tThr=0.5; // max diff in the sector
126const Float_t qThr0=0.5; // max Q diff in the sector
127const Float_t qThr1=2; // max Q diff in the sector
128
129//
130//
131// fit Cal Pads
132AliTPCCalPad *calPad0 = 0; // global fit 0 - base
133AliTPCCalPad *calPad1 = 0; // global fit 1 - common behavior rotation -A-C
134AliTPCCalPad *calPad2 = 0; // gloabl fit 2 - CE missalign rotation A-C
135//
136AliTPCCalPad *calPadInOut = 0; // misaalign in-out
137AliTPCCalPad *calPadLX = 0; // local x missalign
138AliTPCCalPad *calPadTL = 0; // tan
139AliTPCCalPad *calPadQ = 0; // time (q) correction
140AliTPCCalPad *calPadGXY = 0; // global XY missalign (drift velocity grad)
141AliTPCCalPad *calPadOff = 0; // normalization offset fit
142AliTPCCalPad *calPadRes = 0; // final calibration
143
144
145//
146// working variables
147//
148AliTPCCalibViewerGUI * viewer=0; //viewerGUI
149AliTPCCalibViewer *makePad=0; //viewer
150TTree * tree=0; // working tree
151
152void LoadViewer();
153void RebuildData(); // transform the input data to the fit format
154void MakeFit(); // make fits
155//
156// internal functions
157//
158void MakeAliases0(); // Make Aliases 0 - for user tree
159void MakeAliases1(); // Make Aliases 1 - for default tree
160void LoadData(); // Load data
161void StoreData(); // store current data
162void StoreTree(); // store fit data in the output tree
163
164
165void AnalyzeLaser(){
166 //
167 //
168 //
169 LoadViewer();
170 MakeAliases1();
171}
172
173
174void MakeFit(){
175 //
176 //
177 LoadData();
178 LoadViewer();
179 TStatToolkit stat;
180 Int_t npoints;
181 Double_t chi2;
182 TVectorD vec0,vec1,vec2;
183 TMatrixD mat;
184 TString fstring="";
185 //
186 //Basic correction
187 //
188 fstring+="side++"; // offset on 2 different sides //1
189 //fstring+="(1/qp)++"; // Q -threshold effect correction //2
190 //fstring+="(qp)++"; // Q -threshold effect correction //3
191 fstring+="(inn)++"; // inner outer misalign - common //4
192 fstring+="(side*inn)++"; // - opposite //5
193 //
194 fstring+="(gyr)++"; // drift velocity gradient - common //6
195 fstring+="(side*gyr)++"; // - opposite //7
196 fstring+="(gxr)++"; // global x tilt - common //8
197 fstring+="(side*gxr)++"; // - opposite //9
198 //
199 fstring+="tl^2++"; // local phi correction //10
200 //
201 fstring+="(lxr)++"; // zr angle - common //11
202 fstring+="(side*lxr)++"; // - opposite //12
203 fstring+="(inn*lxr)++"; // inner outer angle - common //13
204 fstring+="(side*inn*lxr)++";// - opposite //14
205 fstring+="(lxr^2)++"; // zr second - common //15
206 fstring+="(side*lxr^2)++"; // - opposite //16
207 //
208 TString *fit0 =stat.FitPlane(tree,"dt",fstring.Data(),"cutF&&cutCE",chi2,npoints,vec0,mat);
209 tree->SetAlias("f0",fit0->Data());
210 //
211 // Common "deformation" tendencies
212 //
213 fstring+="(sin(atan2(gy.fElements,gx.fElements)))++";
214 fstring+="(cos(atan2(gy.fElements,gx.fElements)))++";
215 //
216 fstring+="(sin(atan2(gy.fElements,gx.fElements)*2))++";
217 fstring+="(cos(atan2(gy.fElements,gx.fElements)*2))++";
218 fstring+="(sin(atan2(gy.fElements,gx.fElements)*3))++";
219 fstring+="(cos(atan2(gy.fElements,gx.fElements)*3))++";
220 //
221 fstring+="(sin(atan2(gy.fElements,gx.fElements)*2))*lxr++";
222 fstring+="(cos(atan2(gy.fElements,gx.fElements)*2))*lxr++";
223 fstring+="(sin(atan2(gy.fElements,gx.fElements)*3))*lxr++";
224 fstring+="(cos(atan2(gy.fElements,gx.fElements)*3))*lxr++";
225 //
226
227 TString *fit1 =stat.FitPlane(tree,"dt",fstring.Data(),"cutF&&cutCE",chi2,npoints,vec1,mat);
228 tree->SetAlias("f1",fit1->Data());
229 //
230 // Central electrode "deformation"
231 //
232 fstring+="(side*sin(atan2(gy.fElements,gx.fElements)))++";
233 fstring+="(side*cos(atan2(gy.fElements,gx.fElements)))++";
234 //
235 fstring+="(side*sin(atan2(gy.fElements,gx.fElements)*2))++";
236 fstring+="(side*cos(atan2(gy.fElements,gx.fElements)*2))++";
237 fstring+="(side*sin(atan2(gy.fElements,gx.fElements)*3))++";
238 fstring+="(side*cos(atan2(gy.fElements,gx.fElements)*3))++";
239 //
240 fstring+="(side*sin(atan2(gy.fElements,gx.fElements)*2))*lxr++";
241 fstring+="(side*cos(atan2(gy.fElements,gx.fElements)*2))*lxr++";
242 fstring+="(side*sin(atan2(gy.fElements,gx.fElements)*3))*lxr++";
243 fstring+="(side*cos(atan2(gy.fElements,gx.fElements)*3))*lxr++";
244
245 TString *fit2 =stat.FitPlane(tree,"dt",fstring.Data(),"cutF&&abs(dt-f0)<0.7&&cutCE",chi2,npoints,vec2,mat);
246 tree->SetAlias("f2",fit2->Data());
247 //
248 // Extract variables
249 //
250 TString tmpstr = fstring;
251 TObjArray *arr = tmpstr.Tokenize("++");
252 TString fitQ("0"); // q correction
253 TString fitLX("0"); // lx correction
254 TString fitInOut("0"); // inner-outer - match
255 TString fitGXY("0"); // global xy fit
256 TString fitOff("0"); // side offsets
257 TString fitTL("0"); // side offsets
258 //
259 fitOff+="+";
260 fitOff+=vec2[0];
261 fitOff+="+side*";
262 fitOff+=vec2[1];
263 {
264 for(Int_t i=0;i<arr->GetEntriesFast();i++){
265 if (!arr->At(i)) continue;
266 TString *fitstr = new TString(arr->At(i)->GetName());
267 //
268 //Bool_t isQ = fitstr->Contains("qp)");
269 Bool_t isRot = fitstr->Contains("sin(")+fitstr->Contains("cos(");
270 Bool_t isLX = fitstr->Contains("lxr");
271 Bool_t isIn = fitstr->Contains("inn");
272 Bool_t isGXY = fitstr->Contains("gxr")+fitstr->Contains("gyr");
273 if (fitstr->Contains("tl^2")){
274 fitTL+="+";
275 fitTL+=(*fitstr)+"*";
276 fitTL+=vec2[i+1];
277 }
278 if (isGXY){
279 fitGXY+="+";
280 fitGXY+=(*fitstr)+"*";
281 fitGXY+=vec2[i+1];
282 }
283 //if (isQ){
284 // //
285 // fitQ+="+";
286 // fitQ+=(*fitstr)+"*";
287 // fitQ+=vec2[i+1];
288 //}
289 //
290 if (isLX&&!isRot&&!isIn){
291 fitLX+="+";
292 fitLX+=(*fitstr)+"*";
293 fitLX+=vec2[i+1];
294 }
295 //
296 if (!isRot&&isIn){
297 fitInOut+="+";
298 fitInOut+=(*fitstr)+"*";
299 fitInOut+=vec2[i+1];
300 }
301 }
302 }
303 //
304 tree->SetAlias("fInOut",fitInOut.Data());
305 tree->SetAlias("fLX",fitLX.Data());
306 tree->SetAlias("fGXY",fitGXY.Data());
307 tree->SetAlias("fOff",fitOff.Data());
308 //tree->SetAlias("fQ",fitQ.Data());
309 tree->SetAlias("fTL",fitTL.Data());
310 //
311 //
312 // fits
313 //
314 calPad0 = makePad->GetCalPad("f0","1", "ffit0");
315 calPad1 = makePad->GetCalPad("f1","1", "ffit1");
316 calPad2 = makePad->GetCalPad("f2","1", "ffit2");
317 calPadInOut = makePad->GetCalPad("fInOut","1", "fInOut");
318 calPadLX = makePad->GetCalPad("fLX","1", "fLX");
319 calPadTL = makePad->GetCalPad("fTL","1", "fTL");
320 //calPadQ = makePad->GetCalPad("fQ","1", "fQ");
321 calPadGXY = makePad->GetCalPad("fGXY","1", "fGXY");
322 calPadOff = makePad->GetCalPad("fOff","1", "fOff");
323}
324
325void LoadViewer(){
326 //
327 // Load calib Viewer
328 //
329 TObjArray * array = AliTPCCalibViewerGUI::ShowGUI(fname);
330 viewer = (AliTPCCalibViewerGUI*)array->At(0);
331 makePad = viewer->GetViewer();
332 tree = viewer->GetViewer()->GetTree();
333 MakeAliases1();
334}
335
336
337
338
339
340
341void RebuildData(){
342 //
343 // transform the input data to the fit format
344 //
345 makePad = new AliTPCCalibViewer(inname);
346 tree = makePad->GetTree();
347 MakeAliases0(); //
348 //
349 printf("0. GetCalPads\n");
350
351 calPadCor = makePad->GetCalPad("tcor","1", "tcor");
352 calPadOut = makePad->GetCalPad("1","!((cutA||cutC)&&abs(ly.fElements/lx.fElements)<0.155)", "out");
353 calPadIn = makePad->GetCalPad("dt-tcor","1","timeIn");
354 calPadF1 = calPadIn->GlobalFit("timeF1", calPadOut,kTRUE,0,0.9);
355 calPadQIn = makePad->GetCalPad("qa*(sector%36<18)+qc*(sector%36>17)","1","qIn");
356 //
357 //
358 printf("1. Create outlyer map\n");
359
360 //
361 // Update outlyer maps
362 //
363 for (Int_t isector=0;isector<72; isector++){
364 for (UInt_t ich=0;ich<calPadIn->GetCalROC(isector)->GetNchannels();ich++){
365 Float_t val0= calPadIn->GetCalROC(isector)->GetValue(ich);
366 Float_t val1= calPadF1->GetCalROC(isector)->GetValue(ich);
367 if (TMath::Abs(val0-val1)>tThr) calPadOut->GetCalROC(isector)->SetValue(ich,1);
368 }
369 }
370 printf("1. Fit sector parabolas\n");
371
372 calPadF1 = calPadIn->GlobalFit("timeF1", calPadOut,kTRUE,0,0.9);
373 calPadF2 = calPadIn->GlobalFit("timeF2", calPadOut,kTRUE,1,0.9);
374 calPadQF1 = calPadQIn->GlobalFit("qF1", calPadOut,kTRUE,0,0.9);
375 calPadQF2 = calPadQIn->GlobalFit("qF2", calPadOut,kFALSE,1);
376
377 //
378 // Update outlyer maps
379 //
380 printf("2. Update outlyer map\n");
381 for (Int_t isector=0;isector<72; isector++){
382 for (UInt_t ich=0;ich<calPadIn->GetCalROC(isector)->GetNchannels();ich++){
383 Float_t val0= calPadQIn->GetCalROC(isector)->GetValue(ich);
384 Float_t val1= calPadQF2->GetCalROC(isector)->GetValue(ich);
385 if (val1<0.1) {
386 calPadOut->GetCalROC(isector)->SetValue(ich,1);
387 continue;
388 }
389 if (TMath::Abs(val0/val1)<qThr0) calPadOut->GetCalROC(isector)->SetValue(ich,1);
390 if (TMath::Abs(val0/val1)>qThr1) calPadOut->GetCalROC(isector)->SetValue(ich,1);
391 }
392 }
393 printf("3. Redo fit of the of parabola \n");
394
395 calPadF1 = calPadIn->GlobalFit("timeF1", calPadOut,kTRUE,0,0.9);
396 calPadF2 = calPadIn->GlobalFit("timeF2", calPadOut,kTRUE,1,0.9);
397 calPadQF1 = calPadQIn->GlobalFit("qF1", calPadOut,kTRUE,0,0.9);
398 calPadQF2 = calPadQIn->GlobalFit("qF2", calPadOut,kFALSE,1);
399}
400
401void LoadData(){
402 //
403 // Get Data
404 //
405 TFile f(oname);
406 calPadIn = (AliTPCCalPad*)f.Get("timeIn"); // original time pad
407 calPadF1 = (AliTPCCalPad*)f.Get("timeF1"); // original time pad - fit plane
408 calPadF2 = (AliTPCCalPad*)f.Get("timeF2"); // original time pad - fit parabola
409 //
410 calPadQIn = (AliTPCCalPad*)f.Get("qIn"); // original time pad
411 calPadQF1 = (AliTPCCalPad*)f.Get("qF1"); // original time pad - fit plane
412 calPadQF2 = (AliTPCCalPad*)f.Get("qF2"); // original time pad - fit parabola
413 //
414 calPadCor = (AliTPCCalPad*)f.Get("tcor"); // base correction CalPad
415 calPadOut = (AliTPCCalPad*)f.Get("out"); // outlyer CalPad
416 //
417 calPad0 = (AliTPCCalPad*)f.Get("ffit0"); // global fit 0 - base
418 calPad1 = (AliTPCCalPad*)f.Get("ffit1"); // global fit 1 - common behavior rotation -A-C
419 calPad2 = (AliTPCCalPad*)f.Get("ffit2"); // gloabl fit 2 - CE missalign rotation A-C
420 calPadInOut = (AliTPCCalPad*)f.Get("fInOut");// misaalign in-out
421 calPadLX = (AliTPCCalPad*)f.Get("fLX"); // local x missalign
422 calPadTL = (AliTPCCalPad*)f.Get("fTL"); // local y/x missalign
423 calPadQ = (AliTPCCalPad*)f.Get("fQ"); // time (q) correction
424 calPadGXY = (AliTPCCalPad*)f.Get("fGXY"); // global XY missalign (drift velocity grad)
425 calPadOff = (AliTPCCalPad*)f.Get("fOff"); // normalization offset fit
426 calPadRes = (AliTPCCalPad*)f.Get("Result"); //resulting calibration
427}
428
429void StoreData(){
430 //
431 // Store data
432 //
433 TFile * fstore = new TFile(oname,"recreate");
434 if (calPadIn) calPadIn->Write("timeIn"); // original time pad
435 if (calPadF1) calPadF1->Write("timeF1"); // original time pad - fit plane
436 if (calPadF2) calPadF2->Write("timeF2"); // original time pad - fit parabola
437 //
438 if (calPadQIn) calPadQIn->Write("qIn"); // original time pad
439 if (calPadQF1) calPadQF1->Write("qF1"); // original time pad - fit plane
440 if (calPadQF2) calPadQF2->Write("qF2"); // original time pad - fit parabola
441 //
442 if (calPadCor) calPadCor->Write("tcor"); // base correction CalPad
443 if (calPadOut) calPadOut->Write("out"); // outlyer CalPad
444 //
445 if (calPad0) calPad0->Write("ffit0"); // global fit 0 - base
446 if (calPad1) calPad1->Write("ffit1"); // global fit 1 - common behavior rotation -A-C
447 if (calPad2) calPad2->Write("ffit2"); // gloabl fit 2 - CE missalign rotation A-C
448 if (calPadInOut)calPadInOut->Write("fInOut"); // misaalign in-out
449 if (calPadLX) calPadLX->Write("fLX"); // local x missalign
450 if (calPadTL) calPadTL->Write("fTL"); // local y/x missalign
451 if (calPadQ) calPadQ->Write("fQ"); // time (q) correction
452 if (calPadGXY) calPadGXY->Write("fGXY"); // global XY missalign (drift velocity grad)
453 if (calPadOff) calPadOff->Write("fOff"); // normalization offset fit
454 if (calPadRes) calPadRes->Write("Result"); //resulting calibration
455 fstore->Close();
456 delete fstore;
457}
458
459void StoreTree(){
460 //
461 //
462 //
463 AliTPCPreprocessorOnline * preprocesor = new AliTPCPreprocessorOnline;
464 //
465 if (calPadIn) preprocesor->AddComponent(calPadIn->Clone());
466 if (calPadF1) preprocesor->AddComponent(calPadF1->Clone());
467 if (calPadF2) preprocesor->AddComponent(calPadF2->Clone());
468 //
469 if (calPadQIn) preprocesor->AddComponent(calPadQIn->Clone());
470 if (calPadQF1) preprocesor->AddComponent(calPadQF1->Clone());
471 if (calPadQF2) preprocesor->AddComponent(calPadQF2->Clone());
472 //
473 if (calPadCor) preprocesor->AddComponent(calPadCor->Clone());
474 if (calPadOut) preprocesor->AddComponent(calPadOut->Clone());
475 //
476 if (calPad0) preprocesor->AddComponent(calPad0->Clone());
477 if (calPad1) preprocesor->AddComponent(calPad1->Clone());
478 if (calPad2) preprocesor->AddComponent(calPad2->Clone());
479 if (calPadInOut)preprocesor->AddComponent(calPadInOut->Clone());
480 if (calPadLX) preprocesor->AddComponent(calPadLX->Clone());
481 if (calPadTL) preprocesor->AddComponent(calPadTL->Clone());
482 if (calPadQ) preprocesor->AddComponent(calPadQ->Clone());
483 if (calPadGXY) preprocesor->AddComponent(calPadGXY->Clone());
484 if (calPadOff) preprocesor->AddComponent(calPadOff->Clone());
485 if (calPadRes) preprocesor->AddComponent(calPadRes->Clone());
486 preprocesor->DumpToFile(fname);
487 delete preprocesor;
488}
489
490
491void MakeAliases0(){
492 //
493 // Define variables and selection of outliers - for user defined tree
494 //
495 tree->SetAlias("tcor",tcor.Data()); // correction variable
496 tree->SetAlias("ta",taside+".fElements");
497 tree->SetAlias("tc",tcside+".fElements");
498 tree->SetAlias("qa",qaside+".fElements");
499 tree->SetAlias("qc",qcside+".fElements");
500 tree->SetAlias("ra",raside+".fElements");
501 tree->SetAlias("rc",rcside+".fElements");
502 tree->SetAlias("side","1-(sector%36>17)*2");
503 tree->SetAlias("dt","(ta)*(sector%36<18)+(tc)*(sector%36>17)+tcor");
504 tree->SetAlias("cutA","qa>30&&qa<400&&abs(ta)<2&&ra>0.5&&ra<2");
505 tree->SetAlias("cutC","qc>30&&qc<400&&abs(tc)<2&&rc>0.5&&rc<2");
506 tree->SetAlias("cutF","(pad.fElements%4==0)&&(row.fElements%3==0)");
507 tree->SetAlias("cutCE","V.out.fElements");
508 //
509 // fit param aliases
510 //
511 tree->SetAlias("inn","sector<36");
512 tree->SetAlias("gxr","(gx.fElements/250.)"); //
513 tree->SetAlias("gyr","(gy.fElements/250.)"); //
514 tree->SetAlias("lxr","(lx.fElements-133.41)/250.");
515 tree->SetAlias("qp","((sector%36<18)*sqrt(qa)/10.+(sector%36>17)*sqrt(qc)/10.)"); //
516 tree->SetAlias("tl","(ly.fElements/lx.fElements)/0.17");
517}
518
519
520void MakeAliases1(){
521 //
522 // Define variables and selection of outliers -for default usage
523 //
524 tree->SetAlias("tcor","tcor.fElements"); // correction variable
525 tree->SetAlias("side","1-(sector%36>17)*2");
526 tree->SetAlias("dt","timeIn.fElements+tcor");
527 //
528 tree->SetAlias("cutA","out.fElements==1");
529 tree->SetAlias("cutC","out.fElements==1");
530 tree->SetAlias("cutF","(pad.fElements%5==0)&&(row.fElements%4==0)");
531 tree->SetAlias("cutCE","out.fElements<0.5");
532 //
533 // fit param aliases
534 //
535 tree->SetAlias("inn","sector<36");
536 tree->SetAlias("gxr","(gx.fElements/250.)"); //
537 tree->SetAlias("gyr","(gy.fElements/250.)"); //
538 tree->SetAlias("lxr","(lx.fElements-133.41)/250.");
539 tree->SetAlias("qp","(sqrt(qIn.fElements)/10.+(out.fElements>0.5))"); //
540 tree->SetAlias("tl","(ly.fElements/lx.fElements)/0.17");
541}
542
543
544void MakeRes()
545{
546 //
547 // make final calibration
548 //
549 AliTPCCalPad * calPadRes0 =new AliTPCCalPad(*calPadIn);
550 calPadRes0->Add(calPadCor); // add correction
551 calPadRes0->Add(calPad2,-1); // remove global fit
552 calPadRes = calPadRes0->GlobalFit("Result", calPadOut,kTRUE,1,0.9);
553 //
554 //
555 {
556 Float_t tlmedian = calPadTL->GetMedian();
557 for (Int_t isector=0;isector<72; isector++){
558 for (UInt_t ich=0;ich<calPadIn->GetCalROC(isector)->GetNchannels();ich++){
559 //
560 //
561 Float_t val0 = calPadRes->GetCalROC(isector)->GetValue(ich);
562 if (TMath::Abs(val0)>0.5) calPadRes->GetCalROC(isector)->SetValue(ich,0);
563 Float_t tl = calPadTL->GetCalROC(isector)->GetValue(ich);
564 Float_t inOut = calPadInOut->GetCalROC(isector)->GetValue(ich);
565 calPadRes->GetCalROC(isector)->SetValue(ich,calPadRes->GetCalROC(isector)->GetValue(ich)+tl+inOut);
566 //
567 }
568 }
569 }
570 calPadRes->Add(calPadCor,-1); // remove back correction (e.g Pulser time 0)
571
572}
573
574
575
576
577void RebuildCE(char *finname){
578 //
579 // Transformation from the CE to the visualization-analisys output
580 //
581 // finname = CE_Vscan_Run_61684-50_170.root;
582 TFile f(finname);
583 AliTPCCalibCE * ce = (AliTPCCalibCE*)f.Get("AliTPCCalibCE");
584 //
585 AliTPCCalPad *padtime = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
586 AliTPCCalPad *padRMS = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
587 AliTPCCalPad *padq = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
588 padtime->SetName("CE_T");
589 padRMS->SetName("CE_RMS");
590 padq->SetName("CE_Q");
591 AliTPCPreprocessorOnline * preprocesor = new AliTPCPreprocessorOnline;
592 preprocesor->AddComponent(padtime);
593 preprocesor->AddComponent(padq);
594 preprocesor->AddComponent(padRMS);
595 preprocesor->DumpToFile(inname);
596}