]>
Commit | Line | Data |
---|---|---|
07627591 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // TPC calibration class for parameters which saved per pad // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliTPCCalPad.h" | |
25 | #include "AliTPCCalROC.h" | |
184bcc16 | 26 | #include <TObjArray.h> |
27 | #include <TAxis.h> | |
28 | #include <TGraph.h> | |
200be8a6 | 29 | #include <TGraph2D.h> |
30 | #include <TH2F.h> | |
586007f3 | 31 | #include "TTreeStream.h" |
32 | ||
07627591 | 33 | ClassImp(AliTPCCalPad) |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliTPCCalPad::AliTPCCalPad():TNamed() | |
37 | { | |
38 | // | |
39 | // AliTPCCalPad default constructor | |
40 | // | |
41 | ||
42 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
43 | fROC[isec] = 0; | |
44 | } | |
45 | ||
46 | } | |
47 | ||
48 | //_____________________________________________________________________________ | |
49 | AliTPCCalPad::AliTPCCalPad(const Text_t *name, const Text_t *title) | |
50 | :TNamed(name,title) | |
51 | { | |
52 | // | |
53 | // AliTPCCalPad constructor | |
54 | // | |
55 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
56 | fROC[isec] = new AliTPCCalROC(isec); | |
57 | } | |
58 | } | |
59 | ||
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliTPCCalPad::AliTPCCalPad(const AliTPCCalPad &c):TNamed(c) | |
63 | { | |
64 | // | |
65 | // AliTPCCalPad copy constructor | |
66 | // | |
67 | ||
e6c51e6e | 68 | for (Int_t isec = 0; isec < kNsec; isec++) { |
7fb8d357 | 69 | fROC[isec] = 0; |
70 | if (c.fROC[isec]) | |
71 | fROC[isec] = new AliTPCCalROC(*(c.fROC[isec])); | |
e6c51e6e | 72 | } |
07627591 | 73 | } |
74 | ||
184bcc16 | 75 | //_____________________________________________________________________________ |
76 | AliTPCCalPad::AliTPCCalPad(TObjArray * array):TNamed() | |
77 | { | |
78 | // | |
79 | // AliTPCCalPad default constructor | |
80 | // | |
81 | ||
82 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
83 | fROC[isec] = (AliTPCCalROC *)array->At(isec); | |
84 | } | |
85 | ||
86 | } | |
87 | ||
88 | ||
07627591 | 89 | ///_____________________________________________________________________________ |
90 | AliTPCCalPad::~AliTPCCalPad() | |
91 | { | |
92 | // | |
93 | // AliTPCCalPad destructor | |
94 | // | |
95 | ||
96 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
97 | if (fROC[isec]) { | |
98 | delete fROC[isec]; | |
99 | fROC[isec] = 0; | |
100 | } | |
101 | } | |
102 | ||
103 | } | |
104 | ||
105 | //_____________________________________________________________________________ | |
106 | AliTPCCalPad &AliTPCCalPad::operator=(const AliTPCCalPad &c) | |
107 | { | |
108 | // | |
109 | // Assignment operator | |
110 | // | |
111 | ||
112 | if (this != &c) ((AliTPCCalPad &) c).Copy(*this); | |
113 | return *this; | |
114 | ||
115 | } | |
116 | ||
117 | //_____________________________________________________________________________ | |
118 | void AliTPCCalPad::Copy(TObject &c) const | |
119 | { | |
120 | // | |
121 | // Copy function | |
122 | // | |
123 | ||
124 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
125 | if (fROC[isec]) { | |
126 | fROC[isec]->Copy(*((AliTPCCalPad &) c).fROC[isec]); | |
127 | } | |
128 | } | |
129 | TObject::Copy(c); | |
130 | } | |
184bcc16 | 131 | |
90127643 | 132 | //_____________________________________________________________________________ |
133 | void AliTPCCalPad::Add(Float_t c1) | |
134 | { | |
135 | // | |
136 | // add constant for all channels of all ROCs | |
137 | // | |
138 | ||
139 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
140 | if (fROC[isec]){ | |
141 | fROC[isec]->Add(c1); | |
142 | } | |
143 | } | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | void AliTPCCalPad::Multiply(Float_t c1) | |
148 | { | |
149 | // | |
150 | // multiply constant for all channels of all ROCs | |
151 | // | |
152 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
153 | if (fROC[isec]){ | |
154 | fROC[isec]->Multiply(c1); | |
155 | } | |
156 | } | |
157 | } | |
158 | ||
159 | //_____________________________________________________________________________ | |
160 | void AliTPCCalPad::Add(const AliTPCCalPad * pad, Double_t c1) | |
161 | { | |
162 | // | |
163 | // add calpad channel by channel multiplied by c1 - all ROCs | |
164 | // | |
165 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
166 | if (fROC[isec]){ | |
167 | fROC[isec]->Add(pad->GetCalROC(isec),c1); | |
168 | } | |
169 | } | |
170 | } | |
171 | ||
172 | //_____________________________________________________________________________ | |
173 | void AliTPCCalPad::Multiply(const AliTPCCalPad * pad) | |
174 | { | |
175 | // | |
176 | // multiply calpad channel by channel - all ROCs | |
177 | // | |
178 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
179 | if (fROC[isec]){ | |
180 | fROC[isec]->Multiply(pad->GetCalROC(isec)); | |
181 | } | |
182 | } | |
183 | } | |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | void AliTPCCalPad::Divide(const AliTPCCalPad * pad) | |
187 | { | |
188 | // | |
189 | // divide calpad channel by channel - all ROCs | |
190 | // | |
191 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
192 | if (fROC[isec]){ | |
193 | fROC[isec]->Divide(pad->GetCalROC(isec)); | |
194 | } | |
195 | } | |
196 | } | |
197 | ||
198 | //_____________________________________________________________________________ | |
184bcc16 | 199 | TGraph * AliTPCCalPad::MakeGraph(Int_t type, Float_t ratio){ |
200 | // | |
201 | // type=1 - mean | |
202 | // 2 - median | |
203 | // 3 - LTM | |
204 | Int_t npoints = 0; | |
205 | for (Int_t i=0;i<72;i++) if (fROC[i]) npoints++; | |
206 | TGraph * graph = new TGraph(npoints); | |
207 | npoints=0; | |
208 | for (Int_t isec=0;isec<72;isec++){ | |
209 | if (!fROC[isec]) continue; | |
210 | if (type==0) graph->SetPoint(npoints,isec,fROC[isec]->GetMean()); | |
211 | if (type==1) graph->SetPoint(npoints,isec,fROC[isec]->GetMedian()); | |
212 | if (type==2) graph->SetPoint(npoints,isec,fROC[isec]->GetLTM(0,ratio)); | |
213 | npoints++; | |
214 | } | |
215 | ||
216 | graph->GetXaxis()->SetTitle("Sector"); | |
217 | if (type==0) { | |
218 | graph->GetYaxis()->SetTitle("Mean"); | |
219 | graph->SetMarkerStyle(22); | |
220 | } | |
221 | if (type==1) { | |
222 | graph->GetYaxis()->SetTitle("Median"); | |
223 | graph->SetMarkerStyle(22); | |
224 | } | |
225 | if (type==2) { | |
226 | graph->GetYaxis()->SetTitle(Form("Mean%f",ratio)); | |
227 | graph->SetMarkerStyle(24); | |
228 | } | |
229 | ||
230 | return graph; | |
231 | } | |
200be8a6 | 232 | |
90127643 | 233 | //_____________________________________________________________________________ |
234 | Double_t AliTPCCalPad::GetMeanRMS(Double_t &rms) | |
235 | { | |
236 | // | |
237 | // Calculate mean an RMS of all rocs | |
238 | // | |
239 | Double_t sum = 0, sum2 = 0, n=0, val=0; | |
240 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
241 | AliTPCCalROC *calRoc = fROC[isec]; | |
242 | if ( calRoc ){ | |
243 | for (UInt_t irow=0; irow<calRoc->GetNrows(); irow++){ | |
244 | for (UInt_t ipad=0; ipad<calRoc->GetNPads(irow); ipad++){ | |
245 | val = calRoc->GetValue(irow,ipad); | |
246 | sum+=val; | |
247 | sum2+=val*val; | |
248 | n++; | |
249 | } | |
250 | } | |
251 | ||
252 | } | |
253 | } | |
254 | Double_t n1 = 1./n; | |
255 | Double_t mean = sum*n1; | |
256 | rms = TMath::Sqrt(TMath::Abs(sum2*n1-mean*mean)); | |
257 | return mean; | |
258 | } | |
259 | ||
260 | ||
261 | //_____________________________________________________________________________ | |
262 | Double_t AliTPCCalPad::GetMean() | |
263 | { | |
264 | // | |
265 | // return mean of the mean of all ROCs | |
266 | // | |
267 | Double_t arr[kNsec]; | |
268 | Int_t n=0; | |
269 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
270 | AliTPCCalROC *calRoc = fROC[isec]; | |
271 | if ( calRoc ){ | |
272 | arr[n] = calRoc->GetMean(); | |
273 | n++; | |
274 | } | |
275 | } | |
276 | return TMath::Mean(n,arr); | |
277 | } | |
278 | ||
279 | //_____________________________________________________________________________ | |
280 | Double_t AliTPCCalPad::GetRMS() | |
281 | { | |
282 | // | |
283 | // return mean of the RMS of all ROCs | |
284 | // | |
285 | Double_t arr[kNsec]; | |
286 | Int_t n=0; | |
287 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
288 | AliTPCCalROC *calRoc = fROC[isec]; | |
289 | if ( calRoc ){ | |
290 | arr[n] = calRoc->GetRMS(); | |
291 | n++; | |
292 | } | |
293 | } | |
294 | return TMath::Mean(n,arr); | |
295 | } | |
296 | ||
297 | //_____________________________________________________________________________ | |
298 | Double_t AliTPCCalPad::GetMedian() | |
299 | { | |
300 | // | |
301 | // return mean of the median of all ROCs | |
302 | // | |
303 | Double_t arr[kNsec]; | |
304 | Int_t n=0; | |
305 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
306 | AliTPCCalROC *calRoc = fROC[isec]; | |
307 | if ( calRoc ){ | |
308 | arr[n] = calRoc->GetMedian(); | |
309 | n++; | |
310 | } | |
311 | } | |
312 | return TMath::Mean(n,arr); | |
313 | } | |
314 | ||
315 | //_____________________________________________________________________________ | |
316 | Double_t AliTPCCalPad::GetLTM(Double_t *sigma, Double_t fraction) | |
317 | { | |
318 | // | |
319 | // return mean of the LTM and sigma of all ROCs | |
320 | // | |
321 | Double_t arrm[kNsec]; | |
322 | Double_t arrs[kNsec]; | |
323 | Double_t *sTemp=0x0; | |
324 | Int_t n=0; | |
325 | ||
326 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
327 | AliTPCCalROC *calRoc = fROC[isec]; | |
328 | if ( calRoc ){ | |
329 | if ( sigma ) sTemp=arrs+n; | |
330 | arrm[n] = calRoc->GetLTM(sTemp,fraction); | |
331 | n++; | |
332 | } | |
333 | } | |
334 | if ( sigma ) *sigma = TMath::Mean(n,arrs); | |
335 | return TMath::Mean(n,arrm); | |
336 | } | |
337 | ||
338 | //_____________________________________________________________________________ | |
339 | TH1F * AliTPCCalPad::MakeHisto1D(Float_t min, Float_t max,Int_t type){ | |
340 | // | |
341 | // make 1D histo | |
342 | // type -1 = user defined range | |
343 | // 0 = nsigma cut nsigma=min | |
344 | if (type>=0){ | |
345 | if (type==0){ | |
346 | // nsigma range | |
347 | Float_t mean = GetMean(); | |
348 | Float_t sigma = GetRMS(); | |
349 | Float_t nsigma = TMath::Abs(min); | |
350 | min = mean-nsigma*sigma; | |
351 | max = mean+nsigma*sigma; | |
352 | } | |
353 | if (type==1){ | |
354 | // fixed range | |
355 | Float_t mean = GetMedian(); | |
356 | Float_t delta = min; | |
357 | min = mean-delta; | |
358 | max = mean+delta; | |
359 | } | |
360 | if (type==2){ | |
361 | // | |
362 | // LTM mean +- nsigma | |
363 | // | |
364 | Double_t sigma; | |
365 | Float_t mean = GetLTM(&sigma,max); | |
366 | sigma*=min; | |
367 | min = mean-sigma; | |
368 | max = mean+sigma; | |
369 | } | |
370 | } | |
371 | char name[1000]; | |
372 | sprintf(name,"%s Pad 1D",GetTitle()); | |
373 | TH1F * his = new TH1F(name,name,100, min,max); | |
374 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
375 | if (fROC[isec]){ | |
376 | for (UInt_t irow=0; irow<fROC[isec]->GetNrows(); irow++){ | |
377 | UInt_t npads = (Int_t)fROC[isec]->GetNPads(irow); | |
378 | for (UInt_t ipad=0; ipad<npads; ipad++){ | |
379 | his->Fill(fROC[isec]->GetValue(irow,ipad)); | |
380 | } | |
381 | } | |
382 | } | |
383 | } | |
384 | return his; | |
385 | } | |
386 | ||
387 | //_____________________________________________________________________________ | |
200be8a6 | 388 | TH2F *AliTPCCalPad::MakeHisto2D(Int_t side){ |
389 | // | |
390 | // Make 2D graph | |
391 | // side - specify the side A = 0 C = 1 | |
392 | // type - used types of determination of boundaries in z | |
393 | Float_t kEpsilon = 0.000000000001; | |
394 | TH2F * his = new TH2F(GetName(), GetName(), 250,-250,250,250,-250,250); | |
395 | AliTPCROC * roc = AliTPCROC::Instance(); | |
396 | for (Int_t isec=0; isec<72; isec++){ | |
397 | if (side==0 && isec%36>=18) continue; | |
398 | if (side>0 && isec%36<18) continue; | |
399 | if (fROC[isec]){ | |
400 | AliTPCCalROC * calRoc = fROC[isec]; | |
401 | for (UInt_t irow=0; irow<calRoc->GetNrows(); irow++) | |
402 | for (UInt_t ipad=0; ipad<calRoc->GetNPads(irow); ipad++) | |
403 | if (TMath::Abs(calRoc->GetValue(irow,ipad))>kEpsilon){ | |
404 | Float_t xyz[3]; | |
405 | roc->GetPositionGlobal(isec,irow,ipad,xyz); | |
406 | Int_t binx = 1+TMath::Nint((xyz[0]+250.)*0.5); | |
407 | Int_t biny = 1+TMath::Nint((xyz[1]+250.)*0.5); | |
408 | Float_t value = calRoc->GetValue(irow,ipad); | |
409 | his->SetBinContent(binx,biny,value); | |
410 | } | |
411 | } | |
412 | } | |
413 | his->SetXTitle("x (cm)"); | |
414 | his->SetYTitle("y (cm)"); | |
415 | return his; | |
416 | } | |
417 | ||
418 | ||
419 | ||
586007f3 | 420 | |
421 | void AliTPCCalPad::MakeTree(const char * fileName, TObjArray * array) { | |
422 | // | |
423 | // Write tree with all available information | |
424 | // | |
425 | TTreeSRedirector cstream(fileName); | |
426 | AliTPCROC* tpcROCinstance = AliTPCROC::Instance(); | |
7fb8d357 | 427 | Int_t arrayEntries = array->GetEntries(); |
586007f3 | 428 | |
7fb8d357 | 429 | TString* names = new TString[arrayEntries]; |
430 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) | |
586007f3 | 431 | names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName()); |
432 | ||
433 | for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) { | |
434 | // | |
435 | // get statistic for given sector | |
436 | // | |
7fb8d357 | 437 | TVectorF median(arrayEntries); |
438 | TVectorF mean(arrayEntries); | |
439 | TVectorF rms(arrayEntries); | |
440 | TVectorF ltm(arrayEntries); | |
586007f3 | 441 | |
7fb8d357 | 442 | TVectorF *vectorArray = new TVectorF[arrayEntries]; |
443 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) | |
586007f3 | 444 | vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); |
445 | ||
7fb8d357 | 446 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { |
586007f3 | 447 | AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); |
448 | AliTPCCalROC* calROC = calPad->GetCalROC(isector); | |
7fb8d357 | 449 | if (calROC) { |
450 | median[ivalue] = calROC->GetMedian(); | |
451 | mean[ivalue] = calROC->GetMean(); | |
452 | rms[ivalue] = calROC->GetRMS(); | |
453 | ltm[ivalue] = calROC->GetLTM(); | |
454 | } | |
455 | else { | |
456 | median[ivalue] = 0.; | |
457 | mean[ivalue] = 0.; | |
458 | rms[ivalue] = 0.; | |
459 | ltm[ivalue] = 0.; | |
460 | } | |
586007f3 | 461 | } |
462 | ||
463 | // | |
464 | // fill vectors of variable per pad | |
465 | // | |
466 | TVectorF *posArray = new TVectorF[6]; | |
467 | for (Int_t ivalue = 0; ivalue < 6; ivalue++) | |
468 | posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); | |
469 | ||
470 | Float_t posG[3] = {0}; | |
471 | Float_t posL[3] = {0}; | |
472 | Int_t ichannel = 0; | |
473 | for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) { | |
474 | for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) { | |
475 | tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL); | |
476 | tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG); | |
477 | posArray[0][ichannel] = irow; | |
478 | posArray[1][ichannel] = ipad; | |
479 | posArray[2][ichannel] = posL[0]; | |
480 | posArray[3][ichannel] = posL[1]; | |
481 | posArray[4][ichannel] = posG[0]; | |
482 | posArray[5][ichannel] = posG[1]; | |
483 | ||
484 | // loop over array containing AliTPCCalPads | |
7fb8d357 | 485 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { |
586007f3 | 486 | AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); |
7fb8d357 | 487 | AliTPCCalROC* calROC = calPad->GetCalROC(isector); |
488 | if (calROC) | |
489 | (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad); | |
490 | else | |
491 | (vectorArray[ivalue])[ichannel] = 0; | |
586007f3 | 492 | } |
493 | ichannel++; | |
494 | } | |
495 | } | |
496 | ||
497 | cstream << "calPads" << | |
498 | "sector=" << isector; | |
499 | ||
7fb8d357 | 500 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { |
586007f3 | 501 | cstream << "calPads" << |
7fb8d357 | 502 | (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] << |
503 | (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] << | |
504 | (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] << | |
505 | (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue]; | |
586007f3 | 506 | } |
507 | ||
7fb8d357 | 508 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { |
586007f3 | 509 | cstream << "calPads" << |
510 | (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue]; | |
511 | } | |
512 | ||
513 | cstream << "calPads" << | |
514 | "row.=" << &posArray[0] << | |
515 | "pad.=" << &posArray[1] << | |
516 | "lx.=" << &posArray[2] << | |
517 | "ly.=" << &posArray[3] << | |
518 | "gx.=" << &posArray[4] << | |
519 | "gy.=" << &posArray[5]; | |
520 | ||
521 | cstream << "calPads" << | |
522 | "\n"; | |
523 | ||
524 | delete[] posArray; | |
525 | delete[] vectorArray; | |
526 | } | |
527 | delete[] names; | |
528 | } | |
529 | ||
530 |